| Required role: | TenantReader |
| POST | /api/resourcegrouptemplates/ | Creates a new resourcegroup template | |
|---|---|---|---|
| POST | /resourcegrouptemplates/ | Creates a new resourcegroup template |
import Foundation
import ServiceStack
/**
* Create a new resourcegroup template
*/
// @Api(Description="Create a new resourcegroup template")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(ResourceGroupTemplateDto), StatusCode=201)
public class CreateResourceGroupTemplate : IBaseRequest, IHasTenantName, IPost, Codable
{
// @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
// @Validate(Validator="NotEmpty")
public var tenantName:String
/**
* The version of the template structure
*/
// @ApiMember(DataType="integer", Description="The version of the template structure", IsRequired=true, ParameterType="body")
// @Validate(Validator="GreaterThan(0)")
public var schemaVersion:Int
/**
* The definition of the template (YAML)
*/
// @ApiMember(DataType="string", Description="The definition of the template (YAML)", Format="yaml", IsRequired=true, ParameterType="body")
// @Validate(Validator="NotEmpty")
public var definition:String
required public init(){}
}
public class ResourceGroupTemplateDto : ConfigItemDto, IHasTenantId
{
public var tenantId:String
/**
* The schema version of the attached definition (json/yaml structure)
*/
public var schemaVersion:Int
/**
* The version of the template (changes with each change to the template)
*/
public var version:String
/**
* The version in a numeric (padded) form which can be used for sorting
*/
public var versionNumeric:Int
/**
* The template definition/body either as json or yaml
*/
public var definition:String
/**
* Template variables
*/
public var variables:IList<VariableDto>
/**
* Template parameters
*/
public var parameters:IList<ParameterDto>
/**
* The template with the highest version number has IsLatest set to true
*/
public var isLatest:Bool
/**
* List of contained resources
*/
public var resourceTemplates:IList<ResourceTemplateDto>
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case tenantId
case schemaVersion
case version
case versionNumeric
case definition
case variables
case parameters
case isLatest
case resourceTemplates
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
tenantId = try container.decodeIfPresent(String.self, forKey: .tenantId)
schemaVersion = try container.decodeIfPresent(Int.self, forKey: .schemaVersion)
version = try container.decodeIfPresent(String.self, forKey: .version)
versionNumeric = try container.decodeIfPresent(Int.self, forKey: .versionNumeric)
definition = try container.decodeIfPresent(String.self, forKey: .definition)
variables = try container.decodeIfPresent(IList<VariableDto>.self, forKey: .variables)
parameters = try container.decodeIfPresent(IList<ParameterDto>.self, forKey: .parameters)
isLatest = try container.decodeIfPresent(Bool.self, forKey: .isLatest)
resourceTemplates = try container.decodeIfPresent(IList<ResourceTemplateDto>.self, forKey: .resourceTemplates)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if tenantId != nil { try container.encode(tenantId, forKey: .tenantId) }
if schemaVersion != nil { try container.encode(schemaVersion, forKey: .schemaVersion) }
if version != nil { try container.encode(version, forKey: .version) }
if versionNumeric != nil { try container.encode(versionNumeric, forKey: .versionNumeric) }
if definition != nil { try container.encode(definition, forKey: .definition) }
if variables != nil { try container.encode(variables, forKey: .variables) }
if parameters != nil { try container.encode(parameters, forKey: .parameters) }
if isLatest != nil { try container.encode(isLatest, forKey: .isLatest) }
if resourceTemplates != nil { try container.encode(resourceTemplates, forKey: .resourceTemplates) }
}
}
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 TagDto : Codable
{
public var name:String
public var value:String
public var isProtected:Bool
required public init(){}
}
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 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 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 ResourceTemplateDto : Codable
{
public var name:String
public var displayName:String
public var Description:String
public var type:ObjectTypes
required public init(){}
}
Swift CreateResourceGroupTemplate 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/resourcegrouptemplates/ HTTP/1.1
Host: core.starburst.svc
Accept: application/json
Content-Type: application/json
Content-Length: length
{"tenantName":"String","schemaVersion":0,"definition":"String","txId":"00000000-0000-0000-0000-000000000000"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"tenantId":"00000000-0000-0000-0000-000000000000","schemaVersion":0,"version":"String","versionNumeric":0,"definition":"String","variables":null,"parameters":null,"isLatest":false,"resourceTemplates":null,"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}