| Required roles: | TenantReader, TenantAdmin |
| POST | /api/timeseries/ | Creates a new time series definition | |
|---|---|---|---|
| POST | /timeseries/ | Creates a new time series definition |
import Foundation
import ServiceStack
/**
* Creates a new time series definition
*/
// @Api(Description="Creates a new time series definition")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(TimeSeriesDefinitionDto), StatusCode=201)
public class CreateTimeSeriesDefinition : ICreateRequest, IHasTenantName, IPost, ITimeSeriesDefinitionRequest, Codable
{
// @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
// @Validate(Validator="NotEmpty")
public var tenantName:String
/**
* The unique name of the time series
*/
// @ApiMember(DataType="string", Description="The unique name of the time series", IsRequired=true, ParameterType="body")
// @Validate(Validator="NotEmpty")
// @Validate(Validator="MaximumLength(100)")
// @Validate(Validator="RegularExpression(′^[0-9a-z]′)")
public var name:String
/**
* The time series display name
*/
// @ApiMember(DataType="string", Description="The time series display name", ParameterType="body")
// @Validate(Validator="MaximumLength(250)")
public var displayName:String
/**
* A more detailed description for the series
*/
// @ApiMember(DataType="string", Description="A more detailed description for the series", ParameterType="body")
// @Validate(Validator="MaximumLength(8000)")
public var Description:String
/**
* The source type of the time series. Only used when AutoCollection is true
*/
// @ApiMember(DataType="string", Description="The source type of the time series. Only used when AutoCollection is true", ParameterType="body")
// @Validate(Validator="MaximumLength(50)")
public var sourceType:ObjectTypes?
/**
* The query used to extract datapoints from source table. Only used when AutoCollection is true
*/
// @ApiMember(DataType="string", Description="The query used to extract datapoints from source table. Only used when AutoCollection is true", ParameterType="body")
// @Validate(Validator="MaximumLength(2147483647)")
public var autoCollectionQuery:String
/**
* How often a datapoint will be collected, Only used when AutoCollection is true
*/
// @ApiMember(DataType="int", Description="How often a datapoint will be collected, Only used when AutoCollection is true", ParameterType="body")
public var autoCollectionInterval:Int?
/**
* The interval unit for auto collection, Only used when AutoCollection is true
*/
// @ApiMember(DataType="int", Description="The interval unit for auto collection, Only used when AutoCollection is true", ParameterType="body")
public var autoCollectionIntervalUnit:IntervalUnits?
/**
* The time (UTC), when the query will be executed to collect the datapoints, Only used when AutoCollection is true
*/
// @ApiMember(DataType="string", Description="The time (UTC), when the query will be executed to collect the datapoints, Only used when AutoCollection is true", Format="TimeOnly", ParameterType="body")
@TimeSpan public var autoCollectionTime:TimeInterval?
/**
* How often a datapoint will be collected, Only used when AutoCollection is true
*/
// @ApiMember(DataType="bool", Description="How often a datapoint will be collected, Only used when AutoCollection is true", ParameterType="body")
public var autoCollection:Bool
/**
* How many months to keep data in the time series before deleting them
*/
// @ApiMember(DataType="double", Description="How many months to keep data in the time series before deleting them", ParameterType="body")
public var retentionTimeMonths:Double?
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 enum IntervalUnits : String, Codable
{
case Second
case Minute
case Hour
case Day
case Week
case Month
case Year
}
public class TimeSeriesDefinitionDto : Codable
{
public var id:String
public var name:String
public var Description:String
public var sourceType:ObjectTypes
public var autoCollectionQuery:String
public var autoCollectionInterval:Double?
public var autoCollectionIntervalUnit:IntervalUnits?
@TimeSpan public var autoCollectionTime:TimeInterval?
public var lastAutoCollected:Date?
public var autoCollection:Bool
public var retentionTimeMonths:Int?
required public init(){}
}
Swift CreateTimeSeriesDefinition 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
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /api/timeseries/ 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","sourceType":"None","autoCollectionQuery":"String","autoCollectionInterval":0,"autoCollectionIntervalUnit":"Second","autoCollectionTime":"00:00","autoCollection":false,"retentionTimeMonths":0,"txId":"00000000-0000-0000-0000-000000000000"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"id":"00000000-0000-0000-0000-000000000000","name":"String","description":"String","sourceType":"None","autoCollectionQuery":"String","autoCollectionInterval":0,"autoCollectionIntervalUnit":"Second","autoCollectionTime":"00:00","lastAutoCollected":"0001-01-01T00:00:00.0000000Z","autoCollection":false,"retentionTimeMonths":0}