CoreService

<back to all web services

CreateResourceProvider

ResourceProvider - CRUD

Creates a new resourceprovider

Requires Authentication
Required roles:TenantReader, TenantAdmin
The following routes are available for this service:
POST/api/resourceproviders/Creates a new resourceprovider
POST/resourceproviders/Creates a new resourceprovider
import Foundation
import ServiceStack

/**
* Creates a new resourceprovider
*/
// @Api(Description="Creates a new resourceprovider")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(ResourceProviderDto), StatusCode=201)
public class CreateResourceProvider : ICreateRequest, IHasTenantName, IPost, Codable
{
    // @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
    // @Validate(Validator="NotEmpty")
    public var tenantName:String

    /**
    * The resource providers name
    */
    // @ApiMember(DataType="string", Description="The resource providers 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 resource providers display name
    */
    // @ApiMember(DataType="string", Description="The resource providers display name", ParameterType="body")
    // @Validate(Validator="MaximumLength(250)")
    public var displayName:String

    /**
    * A more detailed description for the resource provider
    */
    // @ApiMember(DataType="string", Description="A more detailed description for the resource provider", ParameterType="body")
    // @Validate(Validator="MaximumLength(8000)")
    public var Description:String

    /**
    * If environment cannot be detected while scanning, default environment will be used
    */
    // @ApiMember(Description="If environment cannot be detected while scanning, default environment will be used", IsRequired=true, ParameterType="body")
    // @Validate(Validator="NotNull")
    public var defaultEnvironment:Environments

    /**
    * List off all allowed environments for this resource provider
    */
    // @ApiMember(Description="List off all allowed environments for this resource provider", IsRequired=true, ParameterType="body")
    // @Validate(Validator="NotEmpty")
    public var allowedEnvironments:IList<Environments>

    /**
    * The provider type (e.g. Azure)
    */
    // @ApiMember(Description="The provider type (e.g. Azure)", IsRequired=true, ParameterType="body")
    // @Validate(Validator="NotNull")
    public var type:ResourceProviderTypes?

    /**
    * The resource provider config
    */
    // @ApiMember(DataType="array", Description="The resource provider config", IsRequired=true, ParameterType="body")
    // @Validate(Validator="NotNull")
    public var config:IList<ProviderConfigEntryDto>

    // @ApiMember(DataType="array", ParameterType="body")
    public var tags:IList<TagDto>

    /**
    * Disabled resource providers will be ignored when scanning, etc.
    */
    // @ApiMember(Description="Disabled resource providers will be ignored when scanning, etc.", IsRequired=true, ParameterType="body")
    // @Validate(Validator="NotNull")
    public var isDisabled:Bool

    /**
    * Start the initialization process, which enables the resource provider for deployments if successfull
    */
    // @ApiMember(Description="Start the initialization process, which enables the resource provider for deployments if successfull", IsRequired=true, ParameterType="body")
    // @Validate(Validator="NotNull")
    public var initializeForDeployments:Bool

    required public init(){}
}

public enum Environments : String, Codable
{
    case Lab
    case Poc
    case Dev
    case Test
    case Int
    case Uat
    case Prod
}

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 TagDto : Codable
{
    public var name:String
    public var value:String
    public var isProtected:Bool

    required public init(){}
}

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 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(){}
}


Swift CreateResourceProvider 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.

POST /api/resourceproviders/ 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","defaultEnvironment":"Lab","allowedEnvironments":null,"type":"Azure","config":null,"tags":null,"isDisabled":false,"initializeForDeployments":false,"txId":"00000000-0000-0000-0000-000000000000"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"tenantId":"00000000-0000-0000-0000-000000000000","defaultEnvironment":"Lab","allowedEnvironments":null,"type":"Azure","config":null,"isDisabled":false,"isReadyForDeployments":false,"costCurrentMonth":0,"costLastMonth":0,"costCurrency":"String","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}