| Required role: | TenantReader |
| POST | /api/deploymenttemplates/ | Create a new deployment template | |
|---|---|---|---|
| POST | /deploymenttemplates/ | Create a new deployment template |
import Foundation
import ServiceStack
/**
* Create a new deployment template
*/
// @Api(Description="Create a new deployment template")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(DeploymentTemplateDto), StatusCode=201)
public class CreateDeploymentTemplate : 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
/**
* Specify the environments the deployment template is allowed for
*/
// @ApiMember(DataType="array", Description="Specify the environments the deployment template is allowed for", ParameterType="body")
public var allowedEnvironments:IList<Environments>
/**
* Specify the resource providers the deployment template is allowed for
*/
// @ApiMember(DataType="array", Description="Specify the resource providers the deployment template is allowed for", ParameterType="body")
public var allowedResourceProviderIds:IList<String>
required public init(){}
}
public enum Environments : String, Codable
{
case Lab
case Poc
case Dev
case Test
case Int
case Uat
case Prod
}
public class DeploymentTemplateDto : 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 as json/yaml
*/
public var definition:String
/**
* Template variables
*/
public var variables:IList<VariableDto>
/**
* Template parameters
*/
public var parameters:IList<ParameterDto>
/**
* Disabled templates should not be selected for deployments
*/
public var isDisabled:Bool
/**
* The template with the highest version number has IsLatest set to true
*/
public var isLatest:Bool
/**
* This template can be deployed only to the environments listed below
*/
public var allowedEnvironments:IList<Environments>
/**
* This template can be deployed only to the resource providers listed below
*/
public var allowedResourceProviders:IList<ResourceProviderDto>
/**
* An optional list of the child resource group templates
*/
public var resourceGroupTemplates:IList<ResourceGroupTemplateDto>
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 isDisabled
case isLatest
case allowedEnvironments
case allowedResourceProviders
case resourceGroupTemplates
}
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)
isDisabled = try container.decodeIfPresent(Bool.self, forKey: .isDisabled)
isLatest = try container.decodeIfPresent(Bool.self, forKey: .isLatest)
allowedEnvironments = try container.decodeIfPresent(IList<Environments>.self, forKey: .allowedEnvironments)
allowedResourceProviders = try container.decodeIfPresent(IList<ResourceProviderDto>.self, forKey: .allowedResourceProviders)
resourceGroupTemplates = try container.decodeIfPresent(IList<ResourceGroupTemplateDto>.self, forKey: .resourceGroupTemplates)
}
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 isDisabled != nil { try container.encode(isDisabled, forKey: .isDisabled) }
if isLatest != nil { try container.encode(isLatest, forKey: .isLatest) }
if allowedEnvironments != nil { try container.encode(allowedEnvironments, forKey: .allowedEnvironments) }
if allowedResourceProviders != nil { try container.encode(allowedResourceProviders, forKey: .allowedResourceProviders) }
if resourceGroupTemplates != nil { try container.encode(resourceGroupTemplates, forKey: .resourceGroupTemplates) }
}
}
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 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 ResourceProviderDto : ConfigItemDto, IHasTenantId
{
public var tenantId:String
/**
* If environment cannot be detected while scanning, default environment will be used
*/
public var defaultEnvironment:Environments
/**
* List off all allowed environments for this resource provider
*/
public var allowedEnvironments:IList<Environments>
/**
* Defines the provider type (e.g. Azure, Aws)
*/
public var type:ResourceProviderTypes
/**
* Additional generic data which varies depending on ProviderType
*/
public var config:IList<ProviderConfigEntryDto>
/**
* Disabled ResourceProviders cannot be selected for new deployments
*/
public var isDisabled:Bool
/**
* Shows if a ResourceProvider has been initialized and can accept deployments (resources)
*/
public var isReadyForDeployments:Bool
/**
* The cost for the current month
*/
public var costCurrentMonth:Double
/**
* The cost for the last month
*/
public var costLastMonth:Double
/**
* The cost currency
*/
public var costCurrency:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case tenantId
case defaultEnvironment
case allowedEnvironments
case type
case config
case isDisabled
case isReadyForDeployments
case costCurrentMonth
case costLastMonth
case costCurrency
}
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)
defaultEnvironment = try container.decodeIfPresent(Environments.self, forKey: .defaultEnvironment)
allowedEnvironments = try container.decodeIfPresent(IList<Environments>.self, forKey: .allowedEnvironments)
type = try container.decodeIfPresent(ResourceProviderTypes.self, forKey: .type)
config = try container.decodeIfPresent(IList<ProviderConfigEntryDto>.self, forKey: .config)
isDisabled = try container.decodeIfPresent(Bool.self, forKey: .isDisabled)
isReadyForDeployments = try container.decodeIfPresent(Bool.self, forKey: .isReadyForDeployments)
costCurrentMonth = try container.decodeIfPresent(Double.self, forKey: .costCurrentMonth)
costLastMonth = try container.decodeIfPresent(Double.self, forKey: .costLastMonth)
costCurrency = try container.decodeIfPresent(String.self, forKey: .costCurrency)
}
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 defaultEnvironment != nil { try container.encode(defaultEnvironment, forKey: .defaultEnvironment) }
if allowedEnvironments != nil { try container.encode(allowedEnvironments, forKey: .allowedEnvironments) }
if type != nil { try container.encode(type, forKey: .type) }
if config != nil { try container.encode(config, forKey: .config) }
if isDisabled != nil { try container.encode(isDisabled, forKey: .isDisabled) }
if isReadyForDeployments != nil { try container.encode(isReadyForDeployments, forKey: .isReadyForDeployments) }
if costCurrentMonth != nil { try container.encode(costCurrentMonth, forKey: .costCurrentMonth) }
if costLastMonth != nil { try container.encode(costLastMonth, forKey: .costLastMonth) }
if costCurrency != nil { try container.encode(costCurrency, forKey: .costCurrency) }
}
}
public enum ResourceProviderTypes : String, Codable
{
case Azure
case AmazonWebServices
case GoogleCloudPlatform
case ActiveDirectoryServices
case DomainNameSystem
case SwisscomESC
case AzureKeyVault
}
public class ProviderConfigEntryDto : Codable
{
public var name:String
public var value:String
public var isSecure:Bool
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 ResourceTemplateDto : Codable
{
public var name:String
public var displayName:String
public var Description:String
public var type:ObjectTypes
required public init(){}
}
Swift CreateDeploymentTemplate 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/deploymenttemplates/ HTTP/1.1
Host: core.starburst.svc
Accept: application/json
Content-Type: application/json
Content-Length: length
{"tenantName":"String","schemaVersion":0,"definition":"String","allowedEnvironments":null,"allowedResourceProviderIds":null,"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,"isDisabled":false,"isLatest":false,"allowedEnvironments":null,"allowedResourceProviders":null,"resourceGroupTemplates":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}