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 'package:servicestack/servicestack.dart';

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

class TagDto implements IConvertible
{
    String name = "";
    String? value;
    bool isProtected;

    TagDto({this.name,this.value,this.isProtected});
    TagDto.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        name = json['name'];
        value = json['value'];
        isProtected = json['isProtected'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'name': name,
        'value': value,
        'isProtected': isProtected
    };

    getTypeName() => "TagDto";
    TypeContext? context = _ctx;
}

class PathItemDto implements IConvertible
{
    String label = "";
    String link = "";
    ObjectTypes objectType;
    String objectId = "";

    PathItemDto({this.label,this.link,this.objectType,this.objectId});
    PathItemDto.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        label = json['label'];
        link = json['link'];
        objectType = JsonConverters.fromJson(json['objectType'],'ObjectTypes',context!);
        objectId = json['objectId'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'label': label,
        'link': link,
        'objectType': JsonConverters.toJson(objectType,'ObjectTypes',context!),
        'objectId': objectId
    };

    getTypeName() => "PathItemDto";
    TypeContext? context = _ctx;
}

class LinkDto implements IConvertible
{
    String caption = "";
    String rel = "";
    String hRef = "";
    String method = "";

    LinkDto({this.caption,this.rel,this.hRef,this.method});
    LinkDto.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        caption = json['caption'];
        rel = json['rel'];
        hRef = json['hRef'];
        method = json['method'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'caption': caption,
        'rel': rel,
        'hRef': hRef,
        'method': method
    };

    getTypeName() => "LinkDto";
    TypeContext? context = _ctx;
}

class ConfigItemDto implements IConfigItem, IConvertible
{
    String id = "";
    String name = "";
    String displayName = "";
    String? description;
    ObjectTypes objectType;
    String selfLink = "";
    List<TagDto>? tags;
    List<PathItemDto>? path;
    DateTime created = DateTime(0);
    String createUser = "";
    String createUserId = "";
    DateTime modified = DateTime(0);
    String modifyUser = "";
    String modifyUserId = "";
    bool isDeleted;
    DateTime? deleted;
    String? deleteUser;
    String? deleteUserId;
    List<LinkDto>? links;

    ConfigItemDto({this.id,this.name,this.displayName,this.description,this.objectType,this.selfLink,this.tags,this.path,this.created,this.createUser,this.createUserId,this.modified,this.modifyUser,this.modifyUserId,this.isDeleted,this.deleted,this.deleteUser,this.deleteUserId,this.links});
    ConfigItemDto.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        id = json['id'];
        name = json['name'];
        displayName = json['displayName'];
        description = json['description'];
        objectType = JsonConverters.fromJson(json['objectType'],'ObjectTypes',context!);
        selfLink = json['selfLink'];
        tags = JsonConverters.fromJson(json['tags'],'List<TagDto>',context!);
        path = JsonConverters.fromJson(json['path'],'List<PathItemDto>',context!);
        created = JsonConverters.fromJson(json['created'],'DateTime',context!);
        createUser = json['createUser'];
        createUserId = json['createUserId'];
        modified = JsonConverters.fromJson(json['modified'],'DateTime',context!);
        modifyUser = json['modifyUser'];
        modifyUserId = json['modifyUserId'];
        isDeleted = json['isDeleted'];
        deleted = JsonConverters.fromJson(json['deleted'],'DateTime',context!);
        deleteUser = json['deleteUser'];
        deleteUserId = json['deleteUserId'];
        links = JsonConverters.fromJson(json['links'],'List<LinkDto>',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'id': id,
        'name': name,
        'displayName': displayName,
        'description': description,
        'objectType': JsonConverters.toJson(objectType,'ObjectTypes',context!),
        'selfLink': selfLink,
        'tags': JsonConverters.toJson(tags,'List<TagDto>',context!),
        'path': JsonConverters.toJson(path,'List<PathItemDto>',context!),
        'created': JsonConverters.toJson(created,'DateTime',context!),
        'createUser': createUser,
        'createUserId': createUserId,
        'modified': JsonConverters.toJson(modified,'DateTime',context!),
        'modifyUser': modifyUser,
        'modifyUserId': modifyUserId,
        'isDeleted': isDeleted,
        'deleted': JsonConverters.toJson(deleted,'DateTime',context!),
        'deleteUser': deleteUser,
        'deleteUserId': deleteUserId,
        'links': JsonConverters.toJson(links,'List<LinkDto>',context!)
    };

    getTypeName() => "ConfigItemDto";
    TypeContext? context = _ctx;
}

enum Environments
{
    Lab,
    Poc,
    Dev,
    Test,
    Int,
    Uat,
    Prod,
}

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

class ProviderConfigEntryDto implements IConvertible
{
    String name = "";
    String value = "";
    bool isSecure;

    ProviderConfigEntryDto({this.name,this.value,this.isSecure});
    ProviderConfigEntryDto.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        name = json['name'];
        value = json['value'];
        isSecure = json['isSecure'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'name': name,
        'value': value,
        'isSecure': isSecure
    };

    getTypeName() => "ProviderConfigEntryDto";
    TypeContext? context = _ctx;
}

class ResourceProviderDto extends ConfigItemDto implements IHasTenantId, IConvertible
{
    String tenantId = "";
    /**
    * If environment cannot be detected while scanning, default environment will be used
    */
    Environments defaultEnvironment;
    /**
    * List off all allowed environments for this resource provider
    */
    List<Environments>? allowedEnvironments;
    /**
    * Defines the provider type (e.g. Azure, Aws)
    */
    ResourceProviderTypes type;
    /**
    * Additional generic data which varies depending on ProviderType
    */
    List<ProviderConfigEntryDto>? config;
    /**
    * Disabled ResourceProviders cannot be selected for new deployments
    */
    bool isDisabled;
    /**
    * Shows if a ResourceProvider has been initialized and can accept deployments (resources)
    */
    bool isReadyForDeployments;
    /**
    * The cost for the current month
    */
    double costCurrentMonth = 0;
    /**
    * The cost for the last month
    */
    double costLastMonth = 0;
    /**
    * The cost currency
    */
    String costCurrency = "";

    ResourceProviderDto({this.tenantId,this.defaultEnvironment,this.allowedEnvironments,this.type,this.config,this.isDisabled,this.isReadyForDeployments,this.costCurrentMonth,this.costLastMonth,this.costCurrency});
    ResourceProviderDto.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        tenantId = json['tenantId'];
        defaultEnvironment = JsonConverters.fromJson(json['defaultEnvironment'],'Environments',context!);
        allowedEnvironments = JsonConverters.fromJson(json['allowedEnvironments'],'List<Environments>',context!);
        type = JsonConverters.fromJson(json['type'],'ResourceProviderTypes',context!);
        config = JsonConverters.fromJson(json['config'],'List<ProviderConfigEntryDto>',context!);
        isDisabled = json['isDisabled'];
        isReadyForDeployments = json['isReadyForDeployments'];
        costCurrentMonth = JsonConverters.toDouble(json['costCurrentMonth']);
        costLastMonth = JsonConverters.toDouble(json['costLastMonth']);
        costCurrency = json['costCurrency'];
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'tenantId': tenantId,
        'defaultEnvironment': JsonConverters.toJson(defaultEnvironment,'Environments',context!),
        'allowedEnvironments': JsonConverters.toJson(allowedEnvironments,'List<Environments>',context!),
        'type': JsonConverters.toJson(type,'ResourceProviderTypes',context!),
        'config': JsonConverters.toJson(config,'List<ProviderConfigEntryDto>',context!),
        'isDisabled': isDisabled,
        'isReadyForDeployments': isReadyForDeployments,
        'costCurrentMonth': costCurrentMonth,
        'costLastMonth': costLastMonth,
        'costCurrency': costCurrency
    });

    getTypeName() => "ResourceProviderDto";
    TypeContext? context = _ctx;
}

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

    /**
    * 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]+$′)")
    String name = "";

    /**
    * The resource providers display name
    */
    // @ApiMember(DataType="string", Description="The resource providers display name", ParameterType="body")
    // @Validate(Validator="MaximumLength(250)")
    String? displayName;

    /**
    * 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)")
    String? 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")
    Environments defaultEnvironment;

    /**
    * 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")
    List<Environments>? allowedEnvironments;

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

    /**
    * The resource provider config
    */
    // @ApiMember(DataType="array", Description="The resource provider config", IsRequired=true, ParameterType="body")
    // @Validate(Validator="NotNull")
    List<ProviderConfigEntryDto>? config;

    // @ApiMember(DataType="array", ParameterType="body")
    List<TagDto>? tags;

    /**
    * 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")
    bool isDisabled;

    /**
    * 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")
    bool initializeForDeployments;

    CreateResourceProvider({this.tenantName,this.name,this.displayName,this.description,this.defaultEnvironment,this.allowedEnvironments,this.type,this.config,this.tags,this.isDisabled,this.initializeForDeployments});
    CreateResourceProvider.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        tenantName = json['tenantName'];
        name = json['name'];
        displayName = json['displayName'];
        description = json['description'];
        defaultEnvironment = JsonConverters.fromJson(json['defaultEnvironment'],'Environments',context!);
        allowedEnvironments = JsonConverters.fromJson(json['allowedEnvironments'],'List<Environments>',context!);
        type = JsonConverters.fromJson(json['type'],'ResourceProviderTypes',context!);
        config = JsonConverters.fromJson(json['config'],'List<ProviderConfigEntryDto>',context!);
        tags = JsonConverters.fromJson(json['tags'],'List<TagDto>',context!);
        isDisabled = json['isDisabled'];
        initializeForDeployments = json['initializeForDeployments'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'tenantName': tenantName,
        'name': name,
        'displayName': displayName,
        'description': description,
        'defaultEnvironment': JsonConverters.toJson(defaultEnvironment,'Environments',context!),
        'allowedEnvironments': JsonConverters.toJson(allowedEnvironments,'List<Environments>',context!),
        'type': JsonConverters.toJson(type,'ResourceProviderTypes',context!),
        'config': JsonConverters.toJson(config,'List<ProviderConfigEntryDto>',context!),
        'tags': JsonConverters.toJson(tags,'List<TagDto>',context!),
        'isDisabled': isDisabled,
        'initializeForDeployments': initializeForDeployments
    };

    getTypeName() => "CreateResourceProvider";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'duneframework.com', types: <String, TypeInfo> {
    'ObjectTypes': TypeInfo(TypeOf.Enum, enumValues:ObjectTypes.values),
    'TagDto': TypeInfo(TypeOf.Class, create:() => TagDto()),
    'PathItemDto': TypeInfo(TypeOf.Class, create:() => PathItemDto()),
    'LinkDto': TypeInfo(TypeOf.Class, create:() => LinkDto()),
    'ConfigItemDto': TypeInfo(TypeOf.Class, create:() => ConfigItemDto()),
    'List<TagDto>': TypeInfo(TypeOf.Class, create:() => <TagDto>[]),
    'List<PathItemDto>': TypeInfo(TypeOf.Class, create:() => <PathItemDto>[]),
    'List<LinkDto>': TypeInfo(TypeOf.Class, create:() => <LinkDto>[]),
    'Environments': TypeInfo(TypeOf.Enum, enumValues:Environments.values),
    'ResourceProviderTypes': TypeInfo(TypeOf.Enum, enumValues:ResourceProviderTypes.values),
    'ProviderConfigEntryDto': TypeInfo(TypeOf.Class, create:() => ProviderConfigEntryDto()),
    'ResourceProviderDto': TypeInfo(TypeOf.Class, create:() => ResourceProviderDto()),
    'List<Environments>': TypeInfo(TypeOf.Class, create:() => <Environments>[]),
    'List<ProviderConfigEntryDto>': TypeInfo(TypeOf.Class, create:() => <ProviderConfigEntryDto>[]),
    'CreateResourceProvider': TypeInfo(TypeOf.Class, create:() => CreateResourceProvider()),
});

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