| Required role: | TenantReader |
| POST | /api/deployments/ | Creates a new deployment | |
|---|---|---|---|
| POST | /deployments/ | Creates a new deployment |
import Foundation
import ServiceStack
/**
* Creates a new deployment
*/
// @Api(Description="Creates a new deployment")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(DeploymentDto), StatusCode=201)
public class CreateDeployment : ICreateRequest, IHasTenantName, IHasParent, IPost, Codable
{
// @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
// @Validate(Validator="NotEmpty")
public var tenantName:String
/**
* The name of the deployment
*/
// @ApiMember(DataType="string", Description="The name of the deployment", IsRequired=true, ParameterType="body")
// @Validate(Validator="NotEmpty")
// @Validate(Validator="MaximumLength(100)")
// @Validate(Validator="RegularExpression(′^([0-9a-z]+[0-9a-z-]*[0-9a-z]+)_([a-z]+)$′)")
public var name:String
/**
* The deployments display name
*/
// @ApiMember(DataType="string", Description="The deployments display name", ParameterType="body")
// @Validate(Validator="MaximumLength(250)")
public var displayName:String
/**
* A more detailed description for the deployment
*/
// @ApiMember(DataType="string", Description="A more detailed description for the deployment", ParameterType="body")
// @Validate(Validator="MaximumLength(8000)")
public var Description:String
/**
* The id of the collection, this deployment belongs to
*/
// @ApiMember(DataType="string", Description="The id of the collection, this deployment belongs to", Format="guid", IsRequired=true, ParameterType="body")
public var parentId:String
/**
* The id of the template, this deployment is based on
*/
// @ApiMember(DataType="string", Description="The id of the template, this deployment is based on", Format="guid", ParameterType="body")
public var templateId:String?
/**
* The default resource provider for this deployment
*/
// @ApiMember(DataType="string", Description="The default resource provider for this deployment", Format="guid", IsRequired=true, ParameterType="body")
public var defaultResourceProviderId:String
/**
* What kind of environment is this deployment
*/
// @ApiMember(Description="What kind of environment is this deployment", IsRequired=true, ParameterType="body")
public var environment:Environments
// @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>
/**
* The expiry date of the environment
*/
// @ApiMember(DataType="string", Description="The expiry date of the environment", ParameterType="body")
public var validUntil:Date?
/**
* Set if the environment should never expire
*/
// @ApiMember(DataType="bool", Description="Set if the environment should never expire", ParameterType="body")
public var isNeverExpiring:Bool?
// @ApiMember(DataType="array", IsRequired=true, ParameterType="body")
// @Validate(Validator="NotEmpty")
public var ownerUserIds:IList<Int>
required public init(){}
}
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 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 TagDto : Codable
{
public var name:String
public var value:String
public var isProtected:Bool
required public init(){}
}
public class DeploymentDto : ConfigItemDto, IHasParentDto, IHasTenantId, IEnvironmentSpecific
{
/**
* The operational state of the deployment (Running, Stopped, None, Unknown)
*/
public var operationalState:OperationalStates
/**
* How many start/stop-capable resources are currently running
*/
public var resourcesRunning:Int
/**
* Total number of start/stop-capable resources in this deployment
*/
public var resourcesTotal:Int
/**
* Shorter id than the guid which can be used for automation (tenant wide unique) prefixed with a 'd'. E.g. dr36x3
*/
public var shortId:String
/**
* The user defined part of the name property {userDefined}_{environment}
*/
public var nameUserDefinedPart:String
/**
* The id of the tenant
*/
public var tenantId:String
/**
* The state of the deployment
*/
public var state:LifecycleStates
/**
* The environment the deployment is deployed in
*/
public var environment:Environments
/**
* The id of the template which was used to create the deployment
*/
public var templateId:String?
/**
* Shows if a deployment was rolled out through a dune template or not
*/
public var isTemplateBased:Bool
/**
* The parameters which were used to create this deployment
*/
public var parameters:IList<ParameterDto>
/**
* A deployment scoped list of variables used for deployment of resources
*/
public var variables:IList<VariableDto>
/**
* A snapshot of the varialbs used to create the deployment
*/
public var variablesSnapshot:IList<VariableDto>
/**
* The id of the parent (collection) of the deployment
*/
public var parentId:String
/**
* The parent (collection) of the deployment
*/
public var parent:ConfigItemDto
/**
* The Date when the resources got deployed
*/
public var validFrom:Date
/**
* The Date when the deployment expires and has to be reevaluated
*/
public var validUntil:Date?
/**
* The deployment will never expire
*/
public var isNeverExpiring:Bool
/**
* The date, when the deployments resources will receive updates
*/
public var nextPatchDate:Date?
/**
* The default resource provider where the resources are deployed
*/
public var defaultResourceProviderId:String
/**
* Deployments which have issues in Jobs are marked with NeedsAttention
*/
public var needsAttention:Bool
/**
* Composition show if all resources in the deployment are dune native, dune foreign or a mix of both
*/
public var composition:ResourceCompositions
/**
* The monthly cost budget for the whole collection
*/
public var monthlyBudget:Double?
/**
* Whether to send budget information mails to the collection owners
*/
public var sendBudgetNotificationMails:Bool?
/**
* A threshold, when to send the first budget warning mail
*/
public var budgetWarningThresholdPercent:Int?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case operationalState
case resourcesRunning
case resourcesTotal
case shortId
case nameUserDefinedPart
case tenantId
case state
case environment
case templateId
case isTemplateBased
case parameters
case variables
case variablesSnapshot
case parentId
case parent
case validFrom
case validUntil
case isNeverExpiring
case nextPatchDate
case defaultResourceProviderId
case needsAttention
case composition
case monthlyBudget
case sendBudgetNotificationMails
case budgetWarningThresholdPercent
case links
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
operationalState = try container.decodeIfPresent(OperationalStates.self, forKey: .operationalState)
resourcesRunning = try container.decodeIfPresent(Int.self, forKey: .resourcesRunning)
resourcesTotal = try container.decodeIfPresent(Int.self, forKey: .resourcesTotal)
shortId = try container.decodeIfPresent(String.self, forKey: .shortId)
nameUserDefinedPart = try container.decodeIfPresent(String.self, forKey: .nameUserDefinedPart)
tenantId = try container.decodeIfPresent(String.self, forKey: .tenantId)
state = try container.decodeIfPresent(LifecycleStates.self, forKey: .state)
environment = try container.decodeIfPresent(Environments.self, forKey: .environment)
templateId = try container.decodeIfPresent(String.self, forKey: .templateId)
isTemplateBased = try container.decodeIfPresent(Bool.self, forKey: .isTemplateBased)
parameters = try container.decodeIfPresent(IList<ParameterDto>.self, forKey: .parameters)
variables = try container.decodeIfPresent(IList<VariableDto>.self, forKey: .variables)
variablesSnapshot = try container.decodeIfPresent(IList<VariableDto>.self, forKey: .variablesSnapshot)
parentId = try container.decodeIfPresent(String.self, forKey: .parentId)
parent = try container.decodeIfPresent(ConfigItemDto.self, forKey: .parent)
validFrom = try container.decodeIfPresent(Date.self, forKey: .validFrom)
validUntil = try container.decodeIfPresent(Date.self, forKey: .validUntil)
isNeverExpiring = try container.decodeIfPresent(Bool.self, forKey: .isNeverExpiring)
nextPatchDate = try container.decodeIfPresent(Date.self, forKey: .nextPatchDate)
defaultResourceProviderId = try container.decodeIfPresent(String.self, forKey: .defaultResourceProviderId)
needsAttention = try container.decodeIfPresent(Bool.self, forKey: .needsAttention)
composition = try container.decodeIfPresent(ResourceCompositions.self, forKey: .composition)
monthlyBudget = try container.decodeIfPresent(Double.self, forKey: .monthlyBudget)
sendBudgetNotificationMails = try container.decodeIfPresent(Bool.self, forKey: .sendBudgetNotificationMails)
budgetWarningThresholdPercent = try container.decodeIfPresent(Int.self, forKey: .budgetWarningThresholdPercent)
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 operationalState != nil { try container.encode(operationalState, forKey: .operationalState) }
if resourcesRunning != nil { try container.encode(resourcesRunning, forKey: .resourcesRunning) }
if resourcesTotal != nil { try container.encode(resourcesTotal, forKey: .resourcesTotal) }
if shortId != nil { try container.encode(shortId, forKey: .shortId) }
if nameUserDefinedPart != nil { try container.encode(nameUserDefinedPart, forKey: .nameUserDefinedPart) }
if tenantId != nil { try container.encode(tenantId, forKey: .tenantId) }
if state != nil { try container.encode(state, forKey: .state) }
if environment != nil { try container.encode(environment, forKey: .environment) }
if templateId != nil { try container.encode(templateId, forKey: .templateId) }
if isTemplateBased != nil { try container.encode(isTemplateBased, forKey: .isTemplateBased) }
if parameters != nil { try container.encode(parameters, forKey: .parameters) }
if variables != nil { try container.encode(variables, forKey: .variables) }
if variablesSnapshot != nil { try container.encode(variablesSnapshot, forKey: .variablesSnapshot) }
if parentId != nil { try container.encode(parentId, forKey: .parentId) }
if parent != nil { try container.encode(parent, forKey: .parent) }
if validFrom != nil { try container.encode(validFrom, forKey: .validFrom) }
if validUntil != nil { try container.encode(validUntil, forKey: .validUntil) }
if isNeverExpiring != nil { try container.encode(isNeverExpiring, forKey: .isNeverExpiring) }
if nextPatchDate != nil { try container.encode(nextPatchDate, forKey: .nextPatchDate) }
if defaultResourceProviderId != nil { try container.encode(defaultResourceProviderId, forKey: .defaultResourceProviderId) }
if needsAttention != nil { try container.encode(needsAttention, forKey: .needsAttention) }
if composition != nil { try container.encode(composition, forKey: .composition) }
if monthlyBudget != nil { try container.encode(monthlyBudget, forKey: .monthlyBudget) }
if sendBudgetNotificationMails != nil { try container.encode(sendBudgetNotificationMails, forKey: .sendBudgetNotificationMails) }
if budgetWarningThresholdPercent != nil { try container.encode(budgetWarningThresholdPercent, forKey: .budgetWarningThresholdPercent) }
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 OperationalStates : String, Codable
{
case None
case Starting
case Running
case Stopping
case Stopped
case Restarting
case Deleting
case Unknown
}
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
}
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/deployments/ 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","defaultResourceProviderId":"00000000-0000-0000-0000-000000000000","environment":"Lab","parameters":null,"variables":null,"tags":null,"validUntil":"0001-01-01T00:00:00.0000000Z","isNeverExpiring":false,"ownerUserIds":null,"txId":"00000000-0000-0000-0000-000000000000"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"operationalState":"None","resourcesRunning":0,"resourcesTotal":0,"shortId":"String","nameUserDefinedPart":"String","tenantId":"00000000-0000-0000-0000-000000000000","state":"New","environment":"Lab","templateId":"00000000-0000-0000-0000-000000000000","isTemplateBased":true,"parameters":null,"variables":null,"variablesSnapshot":null,"parentId":"00000000-0000-0000-0000-000000000000","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},"validFrom":"0001-01-01T00:00:00.0000000Z","validUntil":"0001-01-01T00:00:00.0000000Z","isNeverExpiring":false,"nextPatchDate":"0001-01-01T00:00:00.0000000Z","defaultResourceProviderId":"00000000-0000-0000-0000-000000000000","needsAttention":false,"composition":"Native","monthlyBudget":0,"sendBudgetNotificationMails":false,"budgetWarningThresholdPercent":0,"links":[{"caption":"Index","rel":"index","hRef":"/deployments/","method":"GET"},{"caption":"Collection","rel":"up","hRef":"/collections/00000000-0000-0000-0000-000000000000","method":"GET"},{"caption":"Resourcegroups","rel":"down","hRef":"/resourcegroups?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"}