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 datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
Object = TypeVar('Object')


class ObjectTypes(str, Enum):
    NONE = 'None'
    CONFIG_ITEM = 'ConfigItem'
    TENANT = 'Tenant'
    COLLECTION = 'Collection'
    RESOURCE = 'Resource'
    COMPUTE_NODE = 'ComputeNode'
    VIRTUAL_MACHINE = 'VirtualMachine'
    PHYSICAL_MACHINE = 'PhysicalMachine'
    DISK = 'Disk'
    SUBNET = 'Subnet'
    IP_ADDRESS = 'IPAddress'
    JOB = 'Job'
    JOB_EVENT = 'JobEvent'
    FREEZE_PERIOD = 'FreezePeriod'
    RESOURCE_GROUP = 'ResourceGroup'
    DEPLOYMENT = 'Deployment'
    RESOURCE_GROUP_TEMPLATE = 'ResourceGroupTemplate'
    DEPLOYMENT_TEMPLATE = 'DeploymentTemplate'
    RESOURCE_PROVIDER = 'ResourceProvider'
    GENERIC_RESOURCE = 'GenericResource'
    ROLE = 'Role'
    PERMISSION = 'Permission'
    USER = 'User'
    PATCHING_WINDOW = 'PatchingWindow'
    UPDATE = 'Update'
    REPORT_DEFINITION = 'ReportDefinition'
    TIME_SERIES = 'TimeSeries'
    DATA_POINT = 'DataPoint'
    ACTION = 'Action'
    ACTION_ASSIGNMENT = 'ActionAssignment'
    USER_NOTE = 'UserNote'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class TagDto:
    name: Optional[str] = None
    value: Optional[str] = None
    is_protected: bool = False


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PathItemDto:
    label: Optional[str] = None
    link: Optional[str] = None
    object_type: Optional[ObjectTypes] = None
    object_id: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class LinkDto:
    caption: Optional[str] = None
    rel: Optional[str] = None
    h_ref: Optional[str] = None
    method: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ConfigItemDto(IConfigItem):
    id: Optional[str] = None
    name: Optional[str] = None
    display_name: Optional[str] = None
    description: Optional[str] = None
    object_type: Optional[ObjectTypes] = None
    self_link: Optional[str] = None
    tags: Optional[IList[TagDto]] = None
    path: Optional[IList[PathItemDto]] = None
    created: datetime.datetime = datetime.datetime(1, 1, 1)
    create_user: Optional[str] = None
    create_user_id: Optional[str] = None
    modified: datetime.datetime = datetime.datetime(1, 1, 1)
    modify_user: Optional[str] = None
    modify_user_id: Optional[str] = None
    is_deleted: bool = False
    deleted: Optional[datetime.datetime] = None
    delete_user: Optional[str] = None
    delete_user_id: Optional[str] = None
    links: Optional[IList[LinkDto]] = None


class Environments(str, Enum):
    LAB = 'Lab'
    POC = 'Poc'
    DEV = 'Dev'
    TEST = 'Test'
    INT_ = 'Int'
    UAT = 'Uat'
    PROD = 'Prod'


class ResourceProviderTypes(str, Enum):
    AZURE = 'Azure'
    AMAZON_WEB_SERVICES = 'AmazonWebServices'
    GOOGLE_CLOUD_PLATFORM = 'GoogleCloudPlatform'
    ACTIVE_DIRECTORY_SERVICES = 'ActiveDirectoryServices'
    DOMAIN_NAME_SYSTEM = 'DomainNameSystem'
    SWISSCOM_E_S_C = 'SwisscomESC'
    AZURE_KEY_VAULT = 'AzureKeyVault'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ProviderConfigEntryDto:
    name: Optional[str] = None
    value: Optional[str] = None
    is_secure: bool = False


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ResourceProviderDto(ConfigItemDto, IHasTenantId):
    tenant_id: Optional[str] = None
    default_environment: Optional[Environments] = None
    """
    If environment cannot be detected while scanning, default environment will be used
    """

    allowed_environments: Optional[IList[Environments]] = None
    """
    List off all allowed environments for this resource provider
    """

    type: Optional[ResourceProviderTypes] = None
    """
    Defines the provider type (e.g. Azure, Aws)
    """

    config: Optional[IList[ProviderConfigEntryDto]] = None
    """
    Additional generic data which varies depending on ProviderType
    """

    is_disabled: bool = False
    """
    Disabled ResourceProviders cannot be selected for new deployments
    """

    is_ready_for_deployments: bool = False
    """
    Shows if a ResourceProvider has been initialized and can accept deployments (resources)
    """

    cost_current_month: Decimal = decimal.Decimal(0)
    """
    The cost for the current month
    """

    cost_last_month: Decimal = decimal.Decimal(0)
    """
    The cost for the last month
    """

    cost_currency: Optional[str] = None
    """
    The cost currency
    """


# @Api(Description="Creates a new resourceprovider")
# @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(ResourceProviderDto), StatusCode=201)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateResourceProvider(ICreateRequest, IHasTenantName, IPost):
    """
    Creates a new resourceprovider
    """

    # @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
    # @Validate(Validator="NotEmpty")
    tenant_name: Optional[str] = None

    # @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]+$′)")
    name: Optional[str] = None
    """
    The resource providers name
    """


    # @ApiMember(DataType="string", Description="The resource providers display name", ParameterType="body")
    # @Validate(Validator="MaximumLength(250)")
    display_name: Optional[str] = None
    """
    The resource providers display name
    """


    # @ApiMember(DataType="string", Description="A more detailed description for the resource provider", ParameterType="body")
    # @Validate(Validator="MaximumLength(8000)")
    description: Optional[str] = None
    """
    A more detailed description for the resource provider
    """


    # @ApiMember(Description="If environment cannot be detected while scanning, default environment will be used", IsRequired=true, ParameterType="body")
    # @Validate(Validator="NotNull")
    default_environment: Optional[Environments] = None
    """
    If environment cannot be detected while scanning, default environment will be used
    """


    # @ApiMember(Description="List off all allowed environments for this resource provider", IsRequired=true, ParameterType="body")
    # @Validate(Validator="NotEmpty")
    allowed_environments: Optional[IList[Environments]] = None
    """
    List off all allowed environments for this resource provider
    """


    # @ApiMember(Description="The provider type (e.g. Azure)", IsRequired=true, ParameterType="body")
    # @Validate(Validator="NotNull")
    type: Optional[ResourceProviderTypes] = None
    """
    The provider type (e.g. Azure)
    """


    # @ApiMember(DataType="array", Description="The resource provider config", IsRequired=true, ParameterType="body")
    # @Validate(Validator="NotNull")
    config: Optional[IList[ProviderConfigEntryDto]] = None
    """
    The resource provider config
    """


    # @ApiMember(DataType="array", ParameterType="body")
    tags: Optional[IList[TagDto]] = None

    # @ApiMember(Description="Disabled resource providers will be ignored when scanning, etc.", IsRequired=true, ParameterType="body")
    # @Validate(Validator="NotNull")
    is_disabled: bool = False
    """
    Disabled resource providers will be ignored when scanning, etc.
    """


    # @ApiMember(Description="Start the initialization process, which enables the resource provider for deployments if successfull", IsRequired=true, ParameterType="body")
    # @Validate(Validator="NotNull")
    initialize_for_deployments: bool = False
    """
    Start the initialization process, which enables the resource provider for deployments if successfull
    """

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