| Required role: | TenantReader |
| POST | /api/collections/ | Creates a new collection | |
|---|---|---|---|
| POST | /collections/ | Creates a new collection |
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 ValueDataType
{
String,
Number,
Boolean,
List,
}
enum Environments
{
Lab,
Poc,
Dev,
Test,
Int,
Uat,
Prod,
}
class VariableDto implements IConvertible
{
String name = "";
/**
* 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
*/
String value = "";
/**
* The data type of the value property
*/
ValueDataType type;
String? description;
bool isInherited;
Environments? environment;
VariableDto({this.name,this.value,this.type,this.description,this.isInherited,this.environment});
VariableDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
name = json['name'];
value = json['value'];
type = JsonConverters.fromJson(json['type'],'ValueDataType',context!);
description = json['description'];
isInherited = json['isInherited'];
environment = JsonConverters.fromJson(json['environment'],'Environments',context!);
return this;
}
Map<String, dynamic> toJson() => {
'name': name,
'value': value,
'type': JsonConverters.toJson(type,'ValueDataType',context!),
'description': description,
'isInherited': isInherited,
'environment': JsonConverters.toJson(environment,'Environments',context!)
};
getTypeName() => "VariableDto";
TypeContext? context = _ctx;
}
class TenantDto extends ConfigItemDto implements IConvertible
{
/**
* Variables defined on tenant level
*/
List<VariableDto>? variables;
/**
* Allowed email domains used for authentication
*/
List<String>? allowedMailDomains;
/**
* List of licensed modules for this tenant
*/
List<String>? licensedModules;
/**
* Amount of days until a Deployment expires
*/
int defaultDeploymentLifetimeDays = 0;
/**
* Max amount of days until a Deployment expires
*/
int maxDeploymentLifetimeDays = 0;
/**
* Amount of days without patching until a unpatched warning is shown
*/
int systemUnpatchedWarningDays = 0;
/**
* Amount of hours without backup until a backup missing warning is shown
*/
int systemBackupMissingWarningHours = 0;
/**
* Amount of days until a vulnerable resource is getting stopped
*/
int stopVulnerableResourceAfterDays = 0;
/**
* Amount of days before deployment expiration, which triggers the expiration warning
*/
int deploymentExpirationWarningDays = 0;
/**
* Amount of days the patch notification is sent out prior to the patch date
*/
int patchNotificationDays = 0;
/**
* Use a pool with your own hostnames (true) or let the hostname be auto generated (false)
*/
bool useCustomHostnames;
/**
* After how many days inactive vulnerabilities will be purged from database
*/
int removeInactiveVulnerabilitiesAfterDays = 0;
List<LinkDto>? links;
TenantDto({this.variables,this.allowedMailDomains,this.licensedModules,this.defaultDeploymentLifetimeDays,this.maxDeploymentLifetimeDays,this.systemUnpatchedWarningDays,this.systemBackupMissingWarningHours,this.stopVulnerableResourceAfterDays,this.deploymentExpirationWarningDays,this.patchNotificationDays,this.useCustomHostnames,this.removeInactiveVulnerabilitiesAfterDays,this.links});
TenantDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
variables = JsonConverters.fromJson(json['variables'],'List<VariableDto>',context!);
allowedMailDomains = JsonConverters.fromJson(json['allowedMailDomains'],'List<String>',context!);
licensedModules = JsonConverters.fromJson(json['licensedModules'],'List<String>',context!);
defaultDeploymentLifetimeDays = json['defaultDeploymentLifetimeDays'];
maxDeploymentLifetimeDays = json['maxDeploymentLifetimeDays'];
systemUnpatchedWarningDays = json['systemUnpatchedWarningDays'];
systemBackupMissingWarningHours = json['systemBackupMissingWarningHours'];
stopVulnerableResourceAfterDays = json['stopVulnerableResourceAfterDays'];
deploymentExpirationWarningDays = json['deploymentExpirationWarningDays'];
patchNotificationDays = json['patchNotificationDays'];
useCustomHostnames = json['useCustomHostnames'];
removeInactiveVulnerabilitiesAfterDays = json['removeInactiveVulnerabilitiesAfterDays'];
links = JsonConverters.fromJson(json['links'],'List<LinkDto>',context!);
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'variables': JsonConverters.toJson(variables,'List<VariableDto>',context!),
'allowedMailDomains': JsonConverters.toJson(allowedMailDomains,'List<String>',context!),
'licensedModules': JsonConverters.toJson(licensedModules,'List<String>',context!),
'defaultDeploymentLifetimeDays': defaultDeploymentLifetimeDays,
'maxDeploymentLifetimeDays': maxDeploymentLifetimeDays,
'systemUnpatchedWarningDays': systemUnpatchedWarningDays,
'systemBackupMissingWarningHours': systemBackupMissingWarningHours,
'stopVulnerableResourceAfterDays': stopVulnerableResourceAfterDays,
'deploymentExpirationWarningDays': deploymentExpirationWarningDays,
'patchNotificationDays': patchNotificationDays,
'useCustomHostnames': useCustomHostnames,
'removeInactiveVulnerabilitiesAfterDays': removeInactiveVulnerabilitiesAfterDays,
'links': JsonConverters.toJson(links,'List<LinkDto>',context!)
});
getTypeName() => "TenantDto";
TypeContext? context = _ctx;
}
class DeploymentCollectionDto extends ConfigItemDto implements IHasTenantId, IConvertible
{
String tenantId = "";
TenantDto? tenant;
/**
* A collection scoped list of variables
*/
List<VariableDto>? variables;
/**
* Defines the collection where scanned but not deployed resources will be stored
*/
bool isLostAndFound;
/**
* The monthly cost budget for the whole collection
*/
double? monthlyBudget;
/**
* Whether to send budget information mails to the collection owners
*/
bool? sendBudgetNotificationMails;
/**
* A threshold, when to send the first budget warning mail
*/
int? budgetWarningThresholdPercent;
List<LinkDto>? links;
DeploymentCollectionDto({this.tenantId,this.tenant,this.variables,this.isLostAndFound,this.monthlyBudget,this.sendBudgetNotificationMails,this.budgetWarningThresholdPercent,this.links});
DeploymentCollectionDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
tenantId = json['tenantId'];
tenant = JsonConverters.fromJson(json['tenant'],'TenantDto',context!);
variables = JsonConverters.fromJson(json['variables'],'List<VariableDto>',context!);
isLostAndFound = json['isLostAndFound'];
monthlyBudget = JsonConverters.toDouble(json['monthlyBudget']);
sendBudgetNotificationMails = json['sendBudgetNotificationMails'];
budgetWarningThresholdPercent = json['budgetWarningThresholdPercent'];
links = JsonConverters.fromJson(json['links'],'List<LinkDto>',context!);
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'tenantId': tenantId,
'tenant': JsonConverters.toJson(tenant,'TenantDto',context!),
'variables': JsonConverters.toJson(variables,'List<VariableDto>',context!),
'isLostAndFound': isLostAndFound,
'monthlyBudget': monthlyBudget,
'sendBudgetNotificationMails': sendBudgetNotificationMails,
'budgetWarningThresholdPercent': budgetWarningThresholdPercent,
'links': JsonConverters.toJson(links,'List<LinkDto>',context!)
});
getTypeName() => "DeploymentCollectionDto";
TypeContext? context = _ctx;
}
/**
* Creates a new collection
*/
// @Api(Description="Creates a new collection")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(DeploymentCollectionDto), StatusCode=201)
class CreateCollection implements ICreateRequest, IHasTenantName, IPost, IConvertible
{
// @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
// @Validate(Validator="NotEmpty")
String tenantName = "";
/**
* The collections name
*/
// @ApiMember(DataType="string", Description="The collections 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 collections display name
*/
// @ApiMember(DataType="string", Description="The collections display name", ParameterType="body")
// @Validate(Validator="MaximumLength(250)")
String? displayName;
/**
* A more detailed description for the collection
*/
// @ApiMember(DataType="string", Description="A more detailed description for the collection", ParameterType="body")
// @Validate(Validator="MaximumLength(8000)")
String? description;
/**
* Defines the collections where scanned but not deployed resources will be stored
*/
// @ApiMember(DataType="bool", Description="Defines the collections where scanned but not deployed resources will be stored")
bool? isLostAndFound;
// @ApiMember(DataType="array", ParameterType="body")
List<VariableDto>? variables;
// @ApiMember(DataType="array", ParameterType="body")
List<TagDto>? tags;
CreateCollection({this.tenantName,this.name,this.displayName,this.description,this.isLostAndFound,this.variables,this.tags});
CreateCollection.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
tenantName = json['tenantName'];
name = json['name'];
displayName = json['displayName'];
description = json['description'];
isLostAndFound = json['isLostAndFound'];
variables = JsonConverters.fromJson(json['variables'],'List<VariableDto>',context!);
tags = JsonConverters.fromJson(json['tags'],'List<TagDto>',context!);
return this;
}
Map<String, dynamic> toJson() => {
'tenantName': tenantName,
'name': name,
'displayName': displayName,
'description': description,
'isLostAndFound': isLostAndFound,
'variables': JsonConverters.toJson(variables,'List<VariableDto>',context!),
'tags': JsonConverters.toJson(tags,'List<TagDto>',context!)
};
getTypeName() => "CreateCollection";
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>[]),
'ValueDataType': TypeInfo(TypeOf.Enum, enumValues:ValueDataType.values),
'Environments': TypeInfo(TypeOf.Enum, enumValues:Environments.values),
'VariableDto': TypeInfo(TypeOf.Class, create:() => VariableDto()),
'TenantDto': TypeInfo(TypeOf.Class, create:() => TenantDto()),
'List<VariableDto>': TypeInfo(TypeOf.Class, create:() => <VariableDto>[]),
'DeploymentCollectionDto': TypeInfo(TypeOf.Class, create:() => DeploymentCollectionDto()),
'CreateCollection': TypeInfo(TypeOf.Class, create:() => CreateCollection()),
});
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
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /api/collections/ 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","isLostAndFound":false,"variables":null,"tags":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","tenant":{"variables":null,"allowedMailDomains":null,"licensedModules":null,"defaultDeploymentLifetimeDays":0,"maxDeploymentLifetimeDays":0,"systemUnpatchedWarningDays":0,"systemBackupMissingWarningHours":0,"stopVulnerableResourceAfterDays":0,"deploymentExpirationWarningDays":0,"patchNotificationDays":0,"useCustomHostnames":false,"removeInactiveVulnerabilitiesAfterDays":0,"links":[{"caption":"Collections","rel":"down","hRef":"/collections/","method":"GET"}],"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"},"variables":null,"isLostAndFound":false,"monthlyBudget":0,"sendBudgetNotificationMails":false,"budgetWarningThresholdPercent":0,"links":[{"caption":"Index","rel":"up","hRef":"/collections/","method":"GET"},{"caption":"Deployments","rel":"down","hRef":"/deployments?parentId=00000000-0000-0000-0000-000000000000","method":"GET"}],"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"}