CoreService

<back to all web services

GetDeployment

Deployment - CRUD

Returns a deployment by its ID

Requires Authentication
Required role:TenantReader
The following routes are available for this service:
GET/api/deployments/{Id}Returns a deployment
GET/deployments/{Id}Returns a deployment
import Foundation
import ServiceStack

/**
* Returns a deployment by its ID
*/
// @Api(Description="Returns a deployment by its ID")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(DeploymentDto), StatusCode=200)
public class GetDeployment : IGetSingleRequest, IHasTenantName, IGet, Codable
{
    // @ApiMember(DataType="string", Format="guid", IsRequired=true, ParameterType="path")
    public var id:String

    // @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
    // @Validate(Validator="NotEmpty")
    public var tenantName:String

    // @ApiMember(ParameterType="query", Verb="GET")
    public var includeReferencedObjects:Bool?

    /**
    * If true, also soft deleted items will be returned
    */
    // @ApiMember(Description="If true, also soft deleted items will be returned", ParameterType="query")
    public var includeDeleted: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 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 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 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 enum ResourceCompositions : String, Codable
{
    case Native
    case Foreign
    case Mixed
}


Swift GetDeployment 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

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

GET /api/deployments/{Id} HTTP/1.1 
Host: core.starburst.svc 
Accept: application/json
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"}