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
<?php namespace dtos;

use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};


enum ObjectTypes : string
{
    case None = 'None';
    case ConfigItem = 'ConfigItem';
    case Tenant = 'Tenant';
    case Collection = 'Collection';
    case Resource = 'Resource';
    case ComputeNode = 'ComputeNode';
    case VirtualMachine = 'VirtualMachine';
    case PhysicalMachine = 'PhysicalMachine';
    case Disk = 'Disk';
    case Subnet = 'Subnet';
    case IPAddress = 'IPAddress';
    case Job = 'Job';
    case JobEvent = 'JobEvent';
    case FreezePeriod = 'FreezePeriod';
    case ResourceGroup = 'ResourceGroup';
    case Deployment = 'Deployment';
    case ResourceGroupTemplate = 'ResourceGroupTemplate';
    case DeploymentTemplate = 'DeploymentTemplate';
    case ResourceProvider = 'ResourceProvider';
    case GenericResource = 'GenericResource';
    case Role = 'Role';
    case Permission = 'Permission';
    case User = 'User';
    case PatchingWindow = 'PatchingWindow';
    case Update = 'Update';
    case ReportDefinition = 'ReportDefinition';
    case TimeSeries = 'TimeSeries';
    case DataPoint = 'DataPoint';
    case Action = 'Action';
    case ActionAssignment = 'ActionAssignment';
    case UserNote = 'UserNote';
}

class TagDto implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $name='',
        /** @var string|null */
        public ?string $value=null,
        /** @var bool|null */
        public ?bool $isProtected=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['value'])) $this->value = $o['value'];
        if (isset($o['isProtected'])) $this->isProtected = $o['isProtected'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->value)) $o['value'] = $this->value;
        if (isset($this->isProtected)) $o['isProtected'] = $this->isProtected;
        return empty($o) ? new class(){} : $o;
    }
}

class PathItemDto implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $label='',
        /** @var string */
        public string $link='',
        /** @var ObjectTypes|null */
        public ?ObjectTypes $objectType=null,
        /** @var string */
        public string $objectId=''
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['label'])) $this->label = $o['label'];
        if (isset($o['link'])) $this->link = $o['link'];
        if (isset($o['objectType'])) $this->objectType = JsonConverters::from('ObjectTypes', $o['objectType']);
        if (isset($o['objectId'])) $this->objectId = $o['objectId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->label)) $o['label'] = $this->label;
        if (isset($this->link)) $o['link'] = $this->link;
        if (isset($this->objectType)) $o['objectType'] = JsonConverters::to('ObjectTypes', $this->objectType);
        if (isset($this->objectId)) $o['objectId'] = $this->objectId;
        return empty($o) ? new class(){} : $o;
    }
}

class LinkDto implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $caption='',
        /** @var string */
        public string $rel='',
        /** @var string */
        public string $hRef='',
        /** @var string */
        public string $method=''
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['caption'])) $this->caption = $o['caption'];
        if (isset($o['rel'])) $this->rel = $o['rel'];
        if (isset($o['hRef'])) $this->hRef = $o['hRef'];
        if (isset($o['method'])) $this->method = $o['method'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->caption)) $o['caption'] = $this->caption;
        if (isset($this->rel)) $o['rel'] = $this->rel;
        if (isset($this->hRef)) $o['hRef'] = $this->hRef;
        if (isset($this->method)) $o['method'] = $this->method;
        return empty($o) ? new class(){} : $o;
    }
}

class ConfigItemDto implements IConfigItem, JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $id='',
        /** @var string */
        public string $name='',
        /** @var string */
        public string $displayName='',
        /** @var string|null */
        public ?string $description=null,
        /** @var ObjectTypes|null */
        public ?ObjectTypes $objectType=null,
        /** @var string */
        public string $selfLink='',
        /** @var array<TagDto>|null */
        public ?array $tags=null,
        /** @var array<PathItemDto>|null */
        public ?array $path=null,
        /** @var DateTime */
        public DateTime $created=new DateTime(),
        /** @var string */
        public string $createUser='',
        /** @var string */
        public string $createUserId='',
        /** @var DateTime */
        public DateTime $modified=new DateTime(),
        /** @var string */
        public string $modifyUser='',
        /** @var string */
        public string $modifyUserId='',
        /** @var bool|null */
        public ?bool $isDeleted=null,
        /** @var DateTime|null */
        public ?DateTime $deleted=null,
        /** @var string|null */
        public ?string $deleteUser=null,
        /** @var string|null */
        public ?string $deleteUserId=null,
        /** @var array<LinkDto>|null */
        public ?array $links=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['displayName'])) $this->displayName = $o['displayName'];
        if (isset($o['description'])) $this->description = $o['description'];
        if (isset($o['objectType'])) $this->objectType = JsonConverters::from('ObjectTypes', $o['objectType']);
        if (isset($o['selfLink'])) $this->selfLink = $o['selfLink'];
        if (isset($o['tags'])) $this->tags = JsonConverters::fromArray('TagDto', $o['tags']);
        if (isset($o['path'])) $this->path = JsonConverters::fromArray('PathItemDto', $o['path']);
        if (isset($o['created'])) $this->created = JsonConverters::from('DateTime', $o['created']);
        if (isset($o['createUser'])) $this->createUser = $o['createUser'];
        if (isset($o['createUserId'])) $this->createUserId = $o['createUserId'];
        if (isset($o['modified'])) $this->modified = JsonConverters::from('DateTime', $o['modified']);
        if (isset($o['modifyUser'])) $this->modifyUser = $o['modifyUser'];
        if (isset($o['modifyUserId'])) $this->modifyUserId = $o['modifyUserId'];
        if (isset($o['isDeleted'])) $this->isDeleted = $o['isDeleted'];
        if (isset($o['deleted'])) $this->deleted = JsonConverters::from('DateTime', $o['deleted']);
        if (isset($o['deleteUser'])) $this->deleteUser = $o['deleteUser'];
        if (isset($o['deleteUserId'])) $this->deleteUserId = $o['deleteUserId'];
        if (isset($o['links'])) $this->links = JsonConverters::fromArray('LinkDto', $o['links']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->displayName)) $o['displayName'] = $this->displayName;
        if (isset($this->description)) $o['description'] = $this->description;
        if (isset($this->objectType)) $o['objectType'] = JsonConverters::to('ObjectTypes', $this->objectType);
        if (isset($this->selfLink)) $o['selfLink'] = $this->selfLink;
        if (isset($this->tags)) $o['tags'] = JsonConverters::toArray('TagDto', $this->tags);
        if (isset($this->path)) $o['path'] = JsonConverters::toArray('PathItemDto', $this->path);
        if (isset($this->created)) $o['created'] = JsonConverters::to('DateTime', $this->created);
        if (isset($this->createUser)) $o['createUser'] = $this->createUser;
        if (isset($this->createUserId)) $o['createUserId'] = $this->createUserId;
        if (isset($this->modified)) $o['modified'] = JsonConverters::to('DateTime', $this->modified);
        if (isset($this->modifyUser)) $o['modifyUser'] = $this->modifyUser;
        if (isset($this->modifyUserId)) $o['modifyUserId'] = $this->modifyUserId;
        if (isset($this->isDeleted)) $o['isDeleted'] = $this->isDeleted;
        if (isset($this->deleted)) $o['deleted'] = JsonConverters::to('DateTime', $this->deleted);
        if (isset($this->deleteUser)) $o['deleteUser'] = $this->deleteUser;
        if (isset($this->deleteUserId)) $o['deleteUserId'] = $this->deleteUserId;
        if (isset($this->links)) $o['links'] = JsonConverters::toArray('LinkDto', $this->links);
        return empty($o) ? new class(){} : $o;
    }
}

enum Environments : string
{
    case Lab = 'Lab';
    case Poc = 'Poc';
    case Dev = 'Dev';
    case Test = 'Test';
    case Int = 'Int';
    case Uat = 'Uat';
    case Prod = 'Prod';
}

enum ResourceProviderTypes : string
{
    case Azure = 'Azure';
    case AmazonWebServices = 'AmazonWebServices';
    case GoogleCloudPlatform = 'GoogleCloudPlatform';
    case ActiveDirectoryServices = 'ActiveDirectoryServices';
    case DomainNameSystem = 'DomainNameSystem';
    case SwisscomESC = 'SwisscomESC';
    case AzureKeyVault = 'AzureKeyVault';
}

class ProviderConfigEntryDto implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $name='',
        /** @var string */
        public string $value='',
        /** @var bool|null */
        public ?bool $isSecure=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['value'])) $this->value = $o['value'];
        if (isset($o['isSecure'])) $this->isSecure = $o['isSecure'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->value)) $o['value'] = $this->value;
        if (isset($this->isSecure)) $o['isSecure'] = $this->isSecure;
        return empty($o) ? new class(){} : $o;
    }
}

class ResourceProviderDto extends ConfigItemDto implements IHasTenantId, JsonSerializable
{
    /**
     * @param string $id
     * @param string $name
     * @param string $displayName
     * @param string|null $description
     * @param ObjectTypes|null $objectType
     * @param string $selfLink
     * @param array<TagDto>|null $tags
     * @param array<PathItemDto>|null $path
     * @param DateTime $created
     * @param string $createUser
     * @param string $createUserId
     * @param DateTime $modified
     * @param string $modifyUser
     * @param string $modifyUserId
     * @param bool|null $isDeleted
     * @param DateTime|null $deleted
     * @param string|null $deleteUser
     * @param string|null $deleteUserId
     * @param array<LinkDto>|null $links
     */
    public function __construct(
        string $id='',
        string $name='',
        string $displayName='',
        ?string $description=null,
        ?ObjectTypes $objectType=null,
        string $selfLink='',
        ?array $tags=null,
        ?array $path=null,
        DateTime $created=new DateTime(),
        string $createUser='',
        string $createUserId='',
        DateTime $modified=new DateTime(),
        string $modifyUser='',
        string $modifyUserId='',
        ?bool $isDeleted=null,
        ?DateTime $deleted=null,
        ?string $deleteUser=null,
        ?string $deleteUserId=null,
        ?array $links=null,
        /** @var string */
        public string $tenantId='',
        /** @description If environment cannot be detected while scanning, default environment will be used */
        /** @var Environments|null */
        public ?Environments $defaultEnvironment=null,
        /** @description List off all allowed environments for this resource provider */
        /** @var array<Environments>|null */
        public ?array $allowedEnvironments=null,
        /** @description Defines the provider type (e.g. Azure, Aws) */
        /** @var ResourceProviderTypes|null */
        public ?ResourceProviderTypes $type=null,
        /** @description Additional generic data which varies depending on ProviderType */
        /** @var array<ProviderConfigEntryDto>|null */
        public ?array $config=null,
        /** @description Disabled ResourceProviders cannot be selected for new deployments */
        /** @var bool|null */
        public ?bool $isDisabled=null,
        /** @description Shows if a ResourceProvider has been initialized and can accept deployments (resources) */
        /** @var bool|null */
        public ?bool $isReadyForDeployments=null,
        /** @description The cost for the current month */
        /** @var float */
        public float $costCurrentMonth=0.0,
        /** @description The cost for the last month */
        /** @var float */
        public float $costLastMonth=0.0,
        /** @description The cost currency */
        /** @var string */
        public string $costCurrency=''
    ) {
        parent::__construct($id,$name,$displayName,$description,$objectType,$selfLink,$tags,$path,$created,$createUser,$createUserId,$modified,$modifyUser,$modifyUserId,$isDeleted,$deleted,$deleteUser,$deleteUserId,$links);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['tenantId'])) $this->tenantId = $o['tenantId'];
        if (isset($o['defaultEnvironment'])) $this->defaultEnvironment = JsonConverters::from('Environments', $o['defaultEnvironment']);
        if (isset($o['allowedEnvironments'])) $this->allowedEnvironments = JsonConverters::fromArray('Environments', $o['allowedEnvironments']);
        if (isset($o['type'])) $this->type = JsonConverters::from('ResourceProviderTypes', $o['type']);
        if (isset($o['config'])) $this->config = JsonConverters::fromArray('ProviderConfigEntryDto', $o['config']);
        if (isset($o['isDisabled'])) $this->isDisabled = $o['isDisabled'];
        if (isset($o['isReadyForDeployments'])) $this->isReadyForDeployments = $o['isReadyForDeployments'];
        if (isset($o['costCurrentMonth'])) $this->costCurrentMonth = $o['costCurrentMonth'];
        if (isset($o['costLastMonth'])) $this->costLastMonth = $o['costLastMonth'];
        if (isset($o['costCurrency'])) $this->costCurrency = $o['costCurrency'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->tenantId)) $o['tenantId'] = $this->tenantId;
        if (isset($this->defaultEnvironment)) $o['defaultEnvironment'] = JsonConverters::to('Environments', $this->defaultEnvironment);
        if (isset($this->allowedEnvironments)) $o['allowedEnvironments'] = JsonConverters::toArray('Environments', $this->allowedEnvironments);
        if (isset($this->type)) $o['type'] = JsonConverters::to('ResourceProviderTypes', $this->type);
        if (isset($this->config)) $o['config'] = JsonConverters::toArray('ProviderConfigEntryDto', $this->config);
        if (isset($this->isDisabled)) $o['isDisabled'] = $this->isDisabled;
        if (isset($this->isReadyForDeployments)) $o['isReadyForDeployments'] = $this->isReadyForDeployments;
        if (isset($this->costCurrentMonth)) $o['costCurrentMonth'] = $this->costCurrentMonth;
        if (isset($this->costLastMonth)) $o['costLastMonth'] = $this->costLastMonth;
        if (isset($this->costCurrency)) $o['costCurrency'] = $this->costCurrency;
        return empty($o) ? new class(){} : $o;
    }
}

/** @description Creates a new resourceprovider */
// @Api(Description="Creates a new resourceprovider")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType="typeof(CoreService.ServiceModel.Dtos.ResourceProviders.Responses.ResourceProviderDto)", StatusCode=201)
class CreateResourceProvider implements ICreateRequest, IHasTenantName, IPost, JsonSerializable
{
    public function __construct(
        // @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
        // @Validate(Validator="NotEmpty")
        /** @var string */
        public string $tenantName='',

        /** @description 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]+$′)")
        /** @var string */
        public string $name='',

        /** @description The resource providers display name */
        // @ApiMember(DataType="string", Description="The resource providers display name", ParameterType="body")
        // @Validate(Validator="MaximumLength(250)")
        /** @var string|null */
        public ?string $displayName=null,

        /** @description 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)")
        /** @var string|null */
        public ?string $description=null,

        /** @description 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")
        /** @var Environments|null */
        public ?Environments $defaultEnvironment=null,

        /** @description 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")
        /** @var array<Environments>|null */
        public ?array $allowedEnvironments=null,

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

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

        // @ApiMember(DataType="array", ParameterType="body")
        /** @var array<TagDto>|null */
        public ?array $tags=null,

        /** @description 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")
        /** @var bool|null */
        public ?bool $isDisabled=null,

        /** @description 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")
        /** @var bool|null */
        public ?bool $initializeForDeployments=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['tenantName'])) $this->tenantName = $o['tenantName'];
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['displayName'])) $this->displayName = $o['displayName'];
        if (isset($o['description'])) $this->description = $o['description'];
        if (isset($o['defaultEnvironment'])) $this->defaultEnvironment = JsonConverters::from('Environments', $o['defaultEnvironment']);
        if (isset($o['allowedEnvironments'])) $this->allowedEnvironments = JsonConverters::fromArray('Environments', $o['allowedEnvironments']);
        if (isset($o['type'])) $this->type = JsonConverters::from('ResourceProviderTypes', $o['type']);
        if (isset($o['config'])) $this->config = JsonConverters::fromArray('ProviderConfigEntryDto', $o['config']);
        if (isset($o['tags'])) $this->tags = JsonConverters::fromArray('TagDto', $o['tags']);
        if (isset($o['isDisabled'])) $this->isDisabled = $o['isDisabled'];
        if (isset($o['initializeForDeployments'])) $this->initializeForDeployments = $o['initializeForDeployments'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->tenantName)) $o['tenantName'] = $this->tenantName;
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->displayName)) $o['displayName'] = $this->displayName;
        if (isset($this->description)) $o['description'] = $this->description;
        if (isset($this->defaultEnvironment)) $o['defaultEnvironment'] = JsonConverters::to('Environments', $this->defaultEnvironment);
        if (isset($this->allowedEnvironments)) $o['allowedEnvironments'] = JsonConverters::toArray('Environments', $this->allowedEnvironments);
        if (isset($this->type)) $o['type'] = JsonConverters::to('ResourceProviderTypes', $this->type);
        if (isset($this->config)) $o['config'] = JsonConverters::toArray('ProviderConfigEntryDto', $this->config);
        if (isset($this->tags)) $o['tags'] = JsonConverters::toArray('TagDto', $this->tags);
        if (isset($this->isDisabled)) $o['isDisabled'] = $this->isDisabled;
        if (isset($this->initializeForDeployments)) $o['initializeForDeployments'] = $this->initializeForDeployments;
        return empty($o) ? new class(){} : $o;
    }
}

PHP 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}