| Required role: | TenantReader |
| POST | /api/collections/ | Creates a new collection | |
|---|---|---|---|
| POST | /collections/ | Creates a new collection |
import Foundation
import ServiceStack
/**
* Creates a new collection
*/
// @Api(Description="Creates a new collection")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(DeploymentCollectionDto), StatusCode=201)
public class CreateCollection : ICreateRequest, IHasTenantName, IPost, Codable
{
// @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
// @Validate(Validator="NotEmpty")
public var tenantName:String
/**
* 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]+$′)")
public var name:String
/**
* The collections display name
*/
// @ApiMember(DataType="string", Description="The collections display name", ParameterType="body")
// @Validate(Validator="MaximumLength(250)")
public var displayName:String
/**
* A more detailed description for the collection
*/
// @ApiMember(DataType="string", Description="A more detailed description for the collection", ParameterType="body")
// @Validate(Validator="MaximumLength(8000)")
public var Description:String
/**
* 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")
public var isLostAndFound:Bool?
// @ApiMember(DataType="array", ParameterType="body")
public var variables:IList<VariableDto>
// @ApiMember(DataType="array", ParameterType="body")
public var tags:IList<TagDto>
required public init(){}
}
public class VariableDto : Codable
{
public var name:String
/**
* 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
*/
public var value:String
/**
* The data type of the value property
*/
public var type:ValueDataType
public var Description:String
public var isInherited:Bool
public var environment:Environments?
required public init(){}
}
public enum ValueDataType : String, Codable
{
case String
case Number
case Boolean
case List
}
public enum Environments : String, Codable
{
case Lab
case Poc
case Dev
case Test
case Int
case Uat
case Prod
}
public class TagDto : Codable
{
public var name:String
public var value:String
public var isProtected:Bool
required public init(){}
}
public class DeploymentCollectionDto : ConfigItemDto, IHasTenantId
{
public var tenantId:String
public var tenant:TenantDto
/**
* A collection scoped list of variables
*/
public var variables:IList<VariableDto>
/**
* Defines the collection where scanned but not deployed resources will be stored
*/
public var isLostAndFound:Bool
/**
* The monthly cost budget for the whole collection
*/
public var monthlyBudget:Double?
/**
* Whether to send budget information mails to the collection owners
*/
public var sendBudgetNotificationMails:Bool?
/**
* A threshold, when to send the first budget warning mail
*/
public var budgetWarningThresholdPercent:Int?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case tenantId
case tenant
case variables
case isLostAndFound
case monthlyBudget
case sendBudgetNotificationMails
case budgetWarningThresholdPercent
case links
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
tenantId = try container.decodeIfPresent(String.self, forKey: .tenantId)
tenant = try container.decodeIfPresent(TenantDto.self, forKey: .tenant)
variables = try container.decodeIfPresent(IList<VariableDto>.self, forKey: .variables)
isLostAndFound = try container.decodeIfPresent(Bool.self, forKey: .isLostAndFound)
monthlyBudget = try container.decodeIfPresent(Double.self, forKey: .monthlyBudget)
sendBudgetNotificationMails = try container.decodeIfPresent(Bool.self, forKey: .sendBudgetNotificationMails)
budgetWarningThresholdPercent = try container.decodeIfPresent(Int.self, forKey: .budgetWarningThresholdPercent)
links = try container.decodeIfPresent(IList<LinkDto>.self, forKey: .links)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if tenantId != nil { try container.encode(tenantId, forKey: .tenantId) }
if tenant != nil { try container.encode(tenant, forKey: .tenant) }
if variables != nil { try container.encode(variables, forKey: .variables) }
if isLostAndFound != nil { try container.encode(isLostAndFound, forKey: .isLostAndFound) }
if monthlyBudget != nil { try container.encode(monthlyBudget, forKey: .monthlyBudget) }
if sendBudgetNotificationMails != nil { try container.encode(sendBudgetNotificationMails, forKey: .sendBudgetNotificationMails) }
if budgetWarningThresholdPercent != nil { try container.encode(budgetWarningThresholdPercent, forKey: .budgetWarningThresholdPercent) }
if links != nil { try container.encode(links, forKey: .links) }
}
}
public class ConfigItemDto : IConfigItem, Codable
{
public var id:String
public var name:String
public var displayName:String
public var Description:String
public var objectType:ObjectTypes
public var selfLink:String
public var tags:IList<TagDto>
public var path:IList<PathItemDto>
public var created:Date
public var createUser:String
public var createUserId:String
public var modified:Date
public var modifyUser:String
public var modifyUserId:String
public var isDeleted:Bool
public var deleted:Date?
public var deleteUser:String
public var deleteUserId:String
public var links:IList<LinkDto>
required public init(){}
}
public enum ObjectTypes : String, Codable
{
case None
case ConfigItem
case Tenant
case Collection
case Resource
case ComputeNode
case VirtualMachine
case PhysicalMachine
case Disk
case Subnet
case IPAddress
case Job
case JobEvent
case FreezePeriod
case ResourceGroup
case Deployment
case ResourceGroupTemplate
case DeploymentTemplate
case ResourceProvider
case GenericResource
case Role
case Permission
case User
case PatchingWindow
case Update
case ReportDefinition
case TimeSeries
case DataPoint
case Action
case ActionAssignment
case UserNote
}
public class PathItemDto : Codable
{
public var label:String
public var link:String
public var objectType:ObjectTypes
public var objectId:String
required public init(){}
}
public class LinkDto : Codable
{
public var caption:String
public var rel:String
public var hRef:String
public var method:String
required public init(){}
}
public class TenantDto : ConfigItemDto
{
/**
* Variables defined on tenant level
*/
public var variables:IList<VariableDto>
/**
* Allowed email domains used for authentication
*/
public var allowedMailDomains:IList<String>
/**
* List of licensed modules for this tenant
*/
public var licensedModules:IList<String>
/**
* Amount of days until a Deployment expires
*/
public var defaultDeploymentLifetimeDays:Int16
/**
* Max amount of days until a Deployment expires
*/
public var maxDeploymentLifetimeDays:Int16
/**
* Amount of days without patching until a unpatched warning is shown
*/
public var systemUnpatchedWarningDays:Int16
/**
* Amount of hours without backup until a backup missing warning is shown
*/
public var systemBackupMissingWarningHours:Int16
/**
* Amount of days until a vulnerable resource is getting stopped
*/
public var stopVulnerableResourceAfterDays:Int16
/**
* Amount of days before deployment expiration, which triggers the expiration warning
*/
public var deploymentExpirationWarningDays:Int16
/**
* Amount of days the patch notification is sent out prior to the patch date
*/
public var patchNotificationDays:Int16
/**
* Use a pool with your own hostnames (true) or let the hostname be auto generated (false)
*/
public var useCustomHostnames:Bool
/**
* After how many days inactive vulnerabilities will be purged from database
*/
public var removeInactiveVulnerabilitiesAfterDays:Int16
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case variables
case allowedMailDomains
case licensedModules
case defaultDeploymentLifetimeDays
case maxDeploymentLifetimeDays
case systemUnpatchedWarningDays
case systemBackupMissingWarningHours
case stopVulnerableResourceAfterDays
case deploymentExpirationWarningDays
case patchNotificationDays
case useCustomHostnames
case removeInactiveVulnerabilitiesAfterDays
case links
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
variables = try container.decodeIfPresent(IList<VariableDto>.self, forKey: .variables)
allowedMailDomains = try container.decodeIfPresent(IList<String>.self, forKey: .allowedMailDomains)
licensedModules = try container.decodeIfPresent(IList<String>.self, forKey: .licensedModules)
defaultDeploymentLifetimeDays = try container.decodeIfPresent(Int16.self, forKey: .defaultDeploymentLifetimeDays)
maxDeploymentLifetimeDays = try container.decodeIfPresent(Int16.self, forKey: .maxDeploymentLifetimeDays)
systemUnpatchedWarningDays = try container.decodeIfPresent(Int16.self, forKey: .systemUnpatchedWarningDays)
systemBackupMissingWarningHours = try container.decodeIfPresent(Int16.self, forKey: .systemBackupMissingWarningHours)
stopVulnerableResourceAfterDays = try container.decodeIfPresent(Int16.self, forKey: .stopVulnerableResourceAfterDays)
deploymentExpirationWarningDays = try container.decodeIfPresent(Int16.self, forKey: .deploymentExpirationWarningDays)
patchNotificationDays = try container.decodeIfPresent(Int16.self, forKey: .patchNotificationDays)
useCustomHostnames = try container.decodeIfPresent(Bool.self, forKey: .useCustomHostnames)
removeInactiveVulnerabilitiesAfterDays = try container.decodeIfPresent(Int16.self, forKey: .removeInactiveVulnerabilitiesAfterDays)
links = try container.decodeIfPresent(IList<LinkDto>.self, forKey: .links)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if variables != nil { try container.encode(variables, forKey: .variables) }
if allowedMailDomains != nil { try container.encode(allowedMailDomains, forKey: .allowedMailDomains) }
if licensedModules != nil { try container.encode(licensedModules, forKey: .licensedModules) }
if defaultDeploymentLifetimeDays != nil { try container.encode(defaultDeploymentLifetimeDays, forKey: .defaultDeploymentLifetimeDays) }
if maxDeploymentLifetimeDays != nil { try container.encode(maxDeploymentLifetimeDays, forKey: .maxDeploymentLifetimeDays) }
if systemUnpatchedWarningDays != nil { try container.encode(systemUnpatchedWarningDays, forKey: .systemUnpatchedWarningDays) }
if systemBackupMissingWarningHours != nil { try container.encode(systemBackupMissingWarningHours, forKey: .systemBackupMissingWarningHours) }
if stopVulnerableResourceAfterDays != nil { try container.encode(stopVulnerableResourceAfterDays, forKey: .stopVulnerableResourceAfterDays) }
if deploymentExpirationWarningDays != nil { try container.encode(deploymentExpirationWarningDays, forKey: .deploymentExpirationWarningDays) }
if patchNotificationDays != nil { try container.encode(patchNotificationDays, forKey: .patchNotificationDays) }
if useCustomHostnames != nil { try container.encode(useCustomHostnames, forKey: .useCustomHostnames) }
if removeInactiveVulnerabilitiesAfterDays != nil { try container.encode(removeInactiveVulnerabilitiesAfterDays, forKey: .removeInactiveVulnerabilitiesAfterDays) }
if links != nil { try container.encode(links, forKey: .links) }
}
}
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"}