CoreService

<back to all web services

CreateDeploymentTemplate

DeploymentTemplate - CRUD

Create a new deployment template

Requires Authentication
Required role:TenantReader
The following routes are available for this service:
POST/api/deploymenttemplates/Create a new deployment template
POST/deploymenttemplates/Create a new deployment template
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using ServiceStack;
using ServiceStack.DataAnnotations;
using CoreService.ServiceModel.Dtos.Templates.Deployment.Crud;
using CoreService.ServiceModel.Enums;
using CoreService.ServiceModel.Dtos.Templates.Deployment.Responses;
using CoreService.ServiceModel.Dtos.Base.Responses;
using YCO.Dune.Models.Enums;
using CoreService.ServiceModel.Dtos.ResourceProviders.Responses;
using CoreService.ServiceModel.Dtos.Templates.ResourceGroup.Responses;

namespace CoreService.ServiceModel.Dtos.Base.Responses
{
    public partial class ConfigItemDto
        : IConfigItem
    {
        public virtual Guid Id { get; set; }
        public virtual string Name { get; set; }
        public virtual string DisplayName { get; set; }
        public virtual string? Description { get; set; }
        public virtual ObjectTypes ObjectType { get; set; }
        public virtual string SelfLink { get; set; }
        public virtual IList<TagDto> Tags { get; set; }
        public virtual IList<PathItemDto> Path { get; set; }
        public virtual DateTime Created { get; set; }
        public virtual string CreateUser { get; set; }
        public virtual string CreateUserId { get; set; }
        public virtual DateTime Modified { get; set; }
        public virtual string ModifyUser { get; set; }
        public virtual string ModifyUserId { get; set; }
        public virtual bool IsDeleted { get; set; }
        public virtual DateTime? Deleted { get; set; }
        public virtual string? DeleteUser { get; set; }
        public virtual string? DeleteUserId { get; set; }
        public virtual IList<LinkDto> Links { get; set; }
    }

    public partial class LinkDto
    {
        public virtual string Caption { get; set; }
        public virtual string Rel { get; set; }
        public virtual string HRef { get; set; }
        public virtual string Method { get; set; }
    }

    public partial class ParameterDto
    {
        public virtual string Name { get; set; }
        public virtual string? Description { get; set; }
        ///<summary>
        ///Value in form of a json string (e.g. Number = 1234, String = "foo", Boolean = false). Note: string values need extra quotes
        ///</summary>
        public virtual string? Value { get; set; }
        ///<summary>
        ///Optional default value for the frontend. Needs to be in the same format as the value
        ///</summary>
        public virtual string? Default { get; set; }
        ///<summary>
        ///Optional parameters do not need to have a value. Default -> Optional=false
        ///</summary>
        public virtual bool Optional { get; set; }
        ///<summary>
        ///The data type of the value and default property
        ///</summary>
        public virtual ParameterValueType Type { get; set; }
        public virtual string? Validation { get; set; }
    }

    public partial class PathItemDto
    {
        public virtual string Label { get; set; }
        public virtual string Link { get; set; }
        public virtual ObjectTypes ObjectType { get; set; }
        public virtual Guid ObjectId { get; set; }
    }

    public partial class TagDto
    {
        public virtual string Name { get; set; }
        public virtual string? Value { get; set; }
        public virtual bool IsProtected { get; set; }
    }

    public partial class VariableDto
    {
        public virtual string Name { get; set; }
        ///<summary>
        ///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
        ///</summary>
        public virtual string Value { get; set; }
        ///<summary>
        ///The data type of the value property
        ///</summary>
        public virtual ValueDataType Type { get; set; }
        public virtual string? Description { get; set; }
        public virtual bool IsInherited { get; set; }
        public virtual Environments? Environment { get; set; }
    }

}

namespace CoreService.ServiceModel.Dtos.ResourceProviders.Responses
{
    public partial class ProviderConfigEntryDto
    {
        public virtual string Name { get; set; }
        public virtual string Value { get; set; }
        public virtual bool isSecure { get; set; }
    }

    public partial class ResourceProviderDto
        : ConfigItemDto, IHasTenantId
    {
        public virtual Guid TenantId { get; set; }
        ///<summary>
        ///If environment cannot be detected while scanning, default environment will be used
        ///</summary>
        public virtual Environments DefaultEnvironment { get; set; }
        ///<summary>
        ///List off all allowed environments for this resource provider
        ///</summary>
        public virtual IList<Environments> AllowedEnvironments { get; set; }
        ///<summary>
        ///Defines the provider type (e.g. Azure, Aws)
        ///</summary>
        public virtual ResourceProviderTypes Type { get; set; }
        ///<summary>
        ///Additional generic data which varies depending on ProviderType
        ///</summary>
        public virtual IList<ProviderConfigEntryDto> Config { get; set; }
        ///<summary>
        ///Disabled ResourceProviders cannot be selected for new deployments
        ///</summary>
        public virtual bool IsDisabled { get; set; }
        ///<summary>
        ///Shows if a ResourceProvider has been initialized and can accept deployments (resources)
        ///</summary>
        public virtual bool IsReadyForDeployments { get; set; }
        ///<summary>
        ///The cost for the current month
        ///</summary>
        public virtual decimal CostCurrentMonth { get; set; }
        ///<summary>
        ///The cost for the last month
        ///</summary>
        public virtual decimal CostLastMonth { get; set; }
        ///<summary>
        ///The cost currency
        ///</summary>
        public virtual string CostCurrency { get; set; }
    }

}

namespace CoreService.ServiceModel.Dtos.Templates.Deployment.Crud
{
    ///<summary>
    ///Create a new deployment template
    ///</summary>
    [Api(Description="Create a new deployment template")]
    [ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(CoreService.ServiceModel.Dtos.Templates.Deployment.Responses.DeploymentTemplateDto), StatusCode=201)]
    public partial class CreateDeploymentTemplate
        : IBaseRequest, IHasTenantName, IPost
    {
        [ApiMember(DataType="string", IsRequired=true, ParameterType="header")]
        [Validate("NotEmpty")]
        public virtual string TenantName { get; set; }

        ///<summary>
        ///The version of the template structure
        ///</summary>
        [ApiMember(DataType="integer", Description="The version of the template structure", IsRequired=true, ParameterType="body")]
        [Validate("GreaterThan(0)")]
        public virtual int SchemaVersion { get; set; }

        ///<summary>
        ///The definition of the template (YAML)
        ///</summary>
        [ApiMember(DataType="string", Description="The definition of the template (YAML)", Format="yaml", IsRequired=true, ParameterType="body")]
        [Validate("NotEmpty")]
        public virtual string Definition { get; set; }

        ///<summary>
        ///Specify the environments the deployment template is allowed for
        ///</summary>
        [ApiMember(DataType="array", Description="Specify the environments the deployment template is allowed for", ParameterType="body")]
        public virtual IList<Environments>? AllowedEnvironments { get; set; }

        ///<summary>
        ///Specify the resource providers the deployment template is allowed for
        ///</summary>
        [ApiMember(DataType="array", Description="Specify the resource providers the deployment template is allowed for", ParameterType="body")]
        public virtual IList<Guid>? AllowedResourceProviderIds { get; set; }
    }

}

namespace CoreService.ServiceModel.Dtos.Templates.Deployment.Responses
{
    public partial class DeploymentTemplateDto
        : ConfigItemDto, IHasTenantId
    {
        public virtual Guid TenantId { get; set; }
        ///<summary>
        ///The schema version of the attached definition (json/yaml structure)
        ///</summary>
        public virtual int SchemaVersion { get; set; }
        ///<summary>
        ///The version of the template (changes with each change to the template)
        ///</summary>
        public virtual string Version { get; set; }
        ///<summary>
        ///The version in a numeric (padded) form which can be used for sorting
        ///</summary>
        public virtual int VersionNumeric { get; set; }
        ///<summary>
        ///The template definition as json/yaml
        ///</summary>
        public virtual string? Definition { get; set; }
        ///<summary>
        ///Template variables
        ///</summary>
        public virtual IList<VariableDto> Variables { get; set; }
        ///<summary>
        ///Template parameters
        ///</summary>
        public virtual IList<ParameterDto> Parameters { get; set; }
        ///<summary>
        ///Disabled templates should not be selected for deployments
        ///</summary>
        public virtual bool IsDisabled { get; set; }
        ///<summary>
        ///The template with the highest version number has IsLatest set to true
        ///</summary>
        public virtual bool IsLatest { get; set; }
        ///<summary>
        ///This template can be deployed only to the environments listed below
        ///</summary>
        public virtual IList<Environments>? AllowedEnvironments { get; set; }
        ///<summary>
        ///This template can be deployed only to the resource providers listed below
        ///</summary>
        public virtual IList<ResourceProviderDto>? AllowedResourceProviders { get; set; }
        ///<summary>
        ///An optional list of the child resource group templates
        ///</summary>
        public virtual IList<ResourceGroupTemplateDto>? ResourceGroupTemplates { get; set; }
    }

}

namespace CoreService.ServiceModel.Dtos.Templates.ResourceGroup.Responses
{
    public partial class ResourceGroupTemplateDto
        : ConfigItemDto, IHasTenantId
    {
        public virtual Guid TenantId { get; set; }
        ///<summary>
        ///The schema version of the attached definition (json/yaml structure)
        ///</summary>
        public virtual int SchemaVersion { get; set; }
        ///<summary>
        ///The version of the template (changes with each change to the template)
        ///</summary>
        public virtual string Version { get; set; }
        ///<summary>
        ///The version in a numeric (padded) form which can be used for sorting
        ///</summary>
        public virtual int VersionNumeric { get; set; }
        ///<summary>
        ///The template definition/body either as json or yaml
        ///</summary>
        public virtual string? Definition { get; set; }
        ///<summary>
        ///Template variables
        ///</summary>
        public virtual IList<VariableDto> Variables { get; set; }
        ///<summary>
        ///Template parameters
        ///</summary>
        public virtual IList<ParameterDto> Parameters { get; set; }
        ///<summary>
        ///The template with the highest version number has IsLatest set to true
        ///</summary>
        public virtual bool IsLatest { get; set; }
        ///<summary>
        ///List of contained resources
        ///</summary>
        public virtual IList<ResourceTemplateDto> ResourceTemplates { get; set; }
    }

    public partial class ResourceTemplateDto
    {
        public virtual string Name { get; set; }
        public virtual string DisplayName { get; set; }
        public virtual string Description { get; set; }
        public virtual ObjectTypes Type { get; set; }
    }

}

namespace CoreService.ServiceModel.Enums
{
    public enum Environments
    {
        Lab,
        Poc,
        Dev,
        Test,
        Int,
        Uat,
        Prod,
    }

    public enum ParameterValueType
    {
        String,
        Number,
        Boolean,
        SecureString,
    }

    public enum ResourceProviderTypes
    {
        Azure,
        AmazonWebServices,
        GoogleCloudPlatform,
        ActiveDirectoryServices,
        DomainNameSystem,
        SwisscomESC,
        AzureKeyVault,
    }

    public enum ValueDataType
    {
        String,
        Number,
        Boolean,
        List,
    }

}

namespace YCO.Dune.Models.Enums
{
    public enum ObjectTypes
    {
        None,
        ConfigItem,
        Tenant,
        Collection,
        Resource,
        ComputeNode,
        VirtualMachine,
        PhysicalMachine,
        Disk,
        Subnet,
        IPAddress,
        Job,
        JobEvent,
        FreezePeriod,
        ResourceGroup,
        Deployment,
        ResourceGroupTemplate,
        DeploymentTemplate,
        ResourceProvider,
        GenericResource,
        Role,
        Permission,
        User,
        PatchingWindow,
        Update,
        ReportDefinition,
        TimeSeries,
        DataPoint,
        Action,
        ActionAssignment,
        UserNote,
    }

}

C# 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

HTTP + JSON

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}