| Required role: | TenantReader |
| POST | /api/resourcegroups/ | Creates a new resourcegroup | |
|---|---|---|---|
| POST | /resourcegroups/ | Creates a new resourcegroup |
import Foundation
import ServiceStack
/**
* Create a new resourcegroup
*/
// @Api(Description="Create a new resourcegroup")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(ResourceGroupDto), StatusCode=201)
public class CreateResourceGroup : ICreateRequest, IHasTenantName, IHasParent, IPost, Codable
{
// @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
// @Validate(Validator="NotEmpty")
public var tenantName:String
/**
* The resourcegroups name
*/
// @ApiMember(DataType="string", Description="The resourcegroups name", IsRequired=true, ParameterType="body")
// @Validate(Validator="NotEmpty")
// @Validate(Validator="MaximumLength(50)")
// @Validate(Validator="RegularExpression(′^[0-9a-z]+[0-9a-z-]*[0-9a-z]+$′)")
public var name:String
/**
* The resourcegroups display name
*/
// @ApiMember(DataType="string", Description="The resourcegroups display name", ParameterType="body")
// @Validate(Validator="MaximumLength(250)")
public var displayName:String
/**
* A more detailed description for the resourcegroup
*/
// @ApiMember(DataType="string", Description="A more detailed description for the resourcegroup", ParameterType="body")
// @Validate(Validator="MaximumLength(8000)")
public var Description:String
/**
* The id of the deployment, this resourcegroup belongs to
*/
// @ApiMember(DataType="string", Description="The id of the deployment, this resourcegroup belongs to", Format="guid", IsRequired=true, ParameterType="body")
public var parentId:String
/**
* The id of the template, this resourcegroup is based on
*/
// @ApiMember(DataType="string", Description="The id of the template, this resourcegroup is based on", Format="guid", ParameterType="body")
public var templateId:String?
// @ApiMember(DataType="array", ParameterType="body")
public var parameters:IList<ParameterDto>
// @ApiMember(DataType="array", ParameterType="body")
public var variables:IList<VariableDto>
// @ApiMember(DataType="array", ParameterType="body")
public var tags:IList<TagDto>
required public init(){}
}
public class ParameterDto : Codable
{
public var name:String
public var Description:String
/**
* Value in form of a json string (e.g. Number = 1234, String = "foo", Boolean = false). Note: string values need extra quotes
*/
public var value:String
/**
* Optional default value for the frontend. Needs to be in the same format as the value
*/
public var `default`:String
/**
* Optional parameters do not need to have a value. Default -> Optional=false
*/
public var optional:Bool
/**
* The data type of the value and default property
*/
public var type:ParameterValueType
public var validation:String
required public init(){}
}
public enum ParameterValueType : String, Codable
{
case String
case Number
case Boolean
case SecureString
}
public class VariableDto : Codable
{
public var name:String
/**
* Value in form of a json string (e.g. Number = 1234, String = "foo", Boolean = false, List = [1,2,3,4]). Note: string values need extra quotes
*/
public var value:String
/**
* The data type of the value property
*/
public var type:ValueDataType
public var Description:String
public var isInherited:Bool
public var environment:Environments?
required public init(){}
}
public enum ValueDataType : String, Codable
{
case String
case Number
case Boolean
case List
}
public enum Environments : String, Codable
{
case Lab
case Poc
case Dev
case Test
case Int
case Uat
case Prod
}
public class TagDto : Codable
{
public var name:String
public var value:String
public var isProtected:Bool
required public init(){}
}
public class ResourceGroupDto : ConfigItemDto, IHasParent, IHasTenantId, IEnvironmentSpecific
{
/**
* Shorter id than the guid which can be used for automation (tenant wide unique) prefixed with a 'g'. E.g. gk36x3
*/
public var shortId:String
/**
* The id of the tenant
*/
public var tenantId:String
/**
* The environment the resourcegroup is deployed in
*/
public var environment:Environments
/**
* The state of the deployment
*/
public var state:LifecycleStates
/**
* The id of the parent (deployment) of the resourcegroup
*/
public var parentId:String
/**
* The id of the template which was used to create the resourcegroup
*/
public var templateId:String?
/**
* Shows if a resourcegroup was rolled out through a dune template or not
*/
public var isTemplateBased:Bool
/**
* The parent (deployment) of the resourcegroup
*/
public var parent:ConfigItemDto
/**
* The parameters which were used to create this resourcegroup
*/
public var parameters:IList<ParameterDto>
/**
* A resourcegroup scoped list of variables used for resourcegroup of resources
*/
public var variables:IList<VariableDto>
/**
* The date, when the resourcegroups resources will receive updates
*/
public var nextPatchDate:Date?
/**
* Composition show if all resources in the resourcegroup are dune native, dune foreign or a mix of both
*/
public var composition:ResourceCompositions
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case shortId
case tenantId
case environment
case state
case parentId
case templateId
case isTemplateBased
case parent
case parameters
case variables
case nextPatchDate
case composition
case links
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
shortId = try container.decodeIfPresent(String.self, forKey: .shortId)
tenantId = try container.decodeIfPresent(String.self, forKey: .tenantId)
environment = try container.decodeIfPresent(Environments.self, forKey: .environment)
state = try container.decodeIfPresent(LifecycleStates.self, forKey: .state)
parentId = try container.decodeIfPresent(String.self, forKey: .parentId)
templateId = try container.decodeIfPresent(String.self, forKey: .templateId)
isTemplateBased = try container.decodeIfPresent(Bool.self, forKey: .isTemplateBased)
parent = try container.decodeIfPresent(ConfigItemDto.self, forKey: .parent)
parameters = try container.decodeIfPresent(IList<ParameterDto>.self, forKey: .parameters)
variables = try container.decodeIfPresent(IList<VariableDto>.self, forKey: .variables)
nextPatchDate = try container.decodeIfPresent(Date.self, forKey: .nextPatchDate)
composition = try container.decodeIfPresent(ResourceCompositions.self, forKey: .composition)
links = try container.decodeIfPresent(IList<LinkDto>.self, forKey: .links)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if shortId != nil { try container.encode(shortId, forKey: .shortId) }
if tenantId != nil { try container.encode(tenantId, forKey: .tenantId) }
if environment != nil { try container.encode(environment, forKey: .environment) }
if state != nil { try container.encode(state, forKey: .state) }
if parentId != nil { try container.encode(parentId, forKey: .parentId) }
if templateId != nil { try container.encode(templateId, forKey: .templateId) }
if isTemplateBased != nil { try container.encode(isTemplateBased, forKey: .isTemplateBased) }
if parent != nil { try container.encode(parent, forKey: .parent) }
if parameters != nil { try container.encode(parameters, forKey: .parameters) }
if variables != nil { try container.encode(variables, forKey: .variables) }
if nextPatchDate != nil { try container.encode(nextPatchDate, forKey: .nextPatchDate) }
if composition != nil { try container.encode(composition, forKey: .composition) }
if links != nil { try container.encode(links, forKey: .links) }
}
}
public class ConfigItemDto : IConfigItem, Codable
{
public var id:String
public var name:String
public var displayName:String
public var Description:String
public var objectType:ObjectTypes
public var selfLink:String
public var tags:IList<TagDto>
public var path:IList<PathItemDto>
public var created:Date
public var createUser:String
public var createUserId:String
public var modified:Date
public var modifyUser:String
public var modifyUserId:String
public var isDeleted:Bool
public var deleted:Date?
public var deleteUser:String
public var deleteUserId:String
public var links:IList<LinkDto>
required public init(){}
}
public enum ObjectTypes : String, Codable
{
case None
case ConfigItem
case Tenant
case Collection
case Resource
case ComputeNode
case VirtualMachine
case PhysicalMachine
case Disk
case Subnet
case IPAddress
case Job
case JobEvent
case FreezePeriod
case ResourceGroup
case Deployment
case ResourceGroupTemplate
case DeploymentTemplate
case ResourceProvider
case GenericResource
case Role
case Permission
case User
case PatchingWindow
case Update
case ReportDefinition
case TimeSeries
case DataPoint
case Action
case ActionAssignment
case UserNote
}
public class PathItemDto : Codable
{
public var label:String
public var link:String
public var objectType:ObjectTypes
public var objectId:String
required public init(){}
}
public class LinkDto : Codable
{
public var caption:String
public var rel:String
public var hRef:String
public var method:String
required public init(){}
}
public enum LifecycleStates : String, Codable
{
case New
case Deploying
case Deployed
case Removing
case Removed
case Failure
case Imported
}
public enum ResourceCompositions : String, Codable
{
case Native
case Foreign
case Mixed
}
Swift CreateResourceGroup DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /api/resourcegroups/ HTTP/1.1
Host: core.starburst.svc
Accept: application/json
Content-Type: application/json
Content-Length: length
{"tenantName":"String","name":"String","displayName":"String","description":"String","parentId":"00000000-0000-0000-0000-000000000000","templateId":"00000000-0000-0000-0000-000000000000","parameters":null,"variables":null,"tags":null,"txId":"00000000-0000-0000-0000-000000000000"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"shortId":"String","tenantId":"00000000-0000-0000-0000-000000000000","environment":"Lab","state":"New","parentId":"00000000-0000-0000-0000-000000000000","templateId":"00000000-0000-0000-0000-000000000000","isTemplateBased":true,"parent":{"id":"00000000-0000-0000-0000-000000000000","name":"String","displayName":"String","description":"String","objectType":"None","selfLink":"String","tags":null,"path":null,"created":"0001-01-01T00:00:00.0000000Z","createUser":"String","createUserId":"String","modified":"0001-01-01T00:00:00.0000000Z","modifyUser":"String","modifyUserId":"String","isDeleted":false,"deleted":"0001-01-01T00:00:00.0000000Z","deleteUser":"String","deleteUserId":"String","links":null},"parameters":null,"variables":null,"nextPatchDate":"0001-01-01T00:00:00.0000000Z","composition":"Native","links":[{"caption":"Index","rel":"index","hRef":"/resourcegroups/","method":"GET"},{"caption":"Deployment","rel":"up","hRef":"/deployments/00000000-0000-0000-0000-000000000000","method":"GET"},{"caption":"Resources","rel":"down","hRef":"/resources?parentId=00000000-0000-0000-0000-000000000000","method":"GET"}],"id":"00000000-0000-0000-0000-000000000000","name":"String","displayName":"String","description":"String","objectType":"None","selfLink":"String","tags":null,"path":null,"created":"0001-01-01T00:00:00.0000000Z","createUser":"String","createUserId":"String","modified":"0001-01-01T00:00:00.0000000Z","modifyUser":"String","modifyUserId":"String","isDeleted":false,"deleted":"0001-01-01T00:00:00.0000000Z","deleteUser":"String","deleteUserId":"String"}