| Required role: | TenantReader |
| GET | /api/timeseries/ | Returns all timeseries | |
|---|---|---|---|
| GET | /timeseries/ | Returns all timeseries |
import Foundation
import ServiceStack
/**
* Returns a list of all timeseries within a tenant
*/
// @Api(Description="Returns a list of all timeseries within a tenant")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(0, Culture=neutral, PublicKeyToken=null]]), StatusCode=200)
public class QueryTimeSeriesDefinitions : QueryDb<TimeSeriesDefinition>, IGetMultipleRequest, IHasTenantName, IGet, IGroupable
{
// @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
// @Validate(Validator="NotEmpty")
public var tenantName:String
/**
* If true, also soft deleted items will be returned
*/
// @ApiMember(Description="If true, also soft deleted items will be returned", ParameterType="query")
public var includeDeleted:Bool?
/**
* The property, the data will be grouped on
*/
// @ApiMember(Description="The property, the data will be grouped on", ParameterType="query")
public var groupBy:String
/**
* The property, used for aggregation
*/
// @ApiMember(Description="The property, used for aggregation", ParameterType="query")
public var aggregateOn:String
/**
* The aggregation function to use
*/
// @ApiMember(Description="The aggregation function to use", ParameterType="query")
public var aggregation:Aggregations?
/**
* Returns all referenced object
*/
// @ApiMember(Description="Returns all referenced object", ParameterType="query")
public var includeReferencedObjects:Bool?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case tenantName
case includeDeleted
case groupBy
case aggregateOn
case aggregation
case includeReferencedObjects
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
tenantName = try container.decodeIfPresent(String.self, forKey: .tenantName)
includeDeleted = try container.decodeIfPresent(Bool.self, forKey: .includeDeleted)
groupBy = try container.decodeIfPresent(String.self, forKey: .groupBy)
aggregateOn = try container.decodeIfPresent(String.self, forKey: .aggregateOn)
aggregation = try container.decodeIfPresent(Aggregations.self, forKey: .aggregation)
includeReferencedObjects = try container.decodeIfPresent(Bool.self, forKey: .includeReferencedObjects)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if tenantName != nil { try container.encode(tenantName, forKey: .tenantName) }
if includeDeleted != nil { try container.encode(includeDeleted, forKey: .includeDeleted) }
if groupBy != nil { try container.encode(groupBy, forKey: .groupBy) }
if aggregateOn != nil { try container.encode(aggregateOn, forKey: .aggregateOn) }
if aggregation != nil { try container.encode(aggregation, forKey: .aggregation) }
if includeReferencedObjects != nil { try container.encode(includeReferencedObjects, forKey: .includeReferencedObjects) }
}
}
public class TimeSeriesDefinition : Auditable, IHasIdName, IHasTenantId, IHasObjectType
{
public var id:String
// @References(typeof(Tenant))
public var tenantId:String
public var tenant:Tenant
public var name:String
public var displayName:String
// @Ignore()
public var selfLink:String
// @Required()
public var objectType:ObjectTypes?
public var Description:String
public var sourceType:ObjectTypes
public var autoCollection:Bool
public var autoCollectionQuery:String
public var autoCollectionInterval:Int?
public var autoCollectionIntervalUnit:IntervalUnits?
@TimeSpan public var autoCollectionTime:TimeInterval?
public var lastAutoCollected:Date?
public var retentionTimeMonths:Int
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case id
case tenantId
case tenant
case name
case displayName
case selfLink
case objectType
case Description
case sourceType
case autoCollection
case autoCollectionQuery
case autoCollectionInterval
case autoCollectionIntervalUnit
case autoCollectionTime
case lastAutoCollected
case retentionTimeMonths
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decodeIfPresent(String.self, forKey: .id)
tenantId = try container.decodeIfPresent(String.self, forKey: .tenantId)
tenant = try container.decodeIfPresent(Tenant.self, forKey: .tenant)
name = try container.decodeIfPresent(String.self, forKey: .name)
displayName = try container.decodeIfPresent(String.self, forKey: .displayName)
selfLink = try container.decodeIfPresent(String.self, forKey: .selfLink)
objectType = try container.decodeIfPresent(ObjectTypes.self, forKey: .objectType)
Description = try container.decodeIfPresent(String.self, forKey: .Description)
sourceType = try container.decodeIfPresent(ObjectTypes.self, forKey: .sourceType)
autoCollection = try container.decodeIfPresent(Bool.self, forKey: .autoCollection)
autoCollectionQuery = try container.decodeIfPresent(String.self, forKey: .autoCollectionQuery)
autoCollectionInterval = try container.decodeIfPresent(Int.self, forKey: .autoCollectionInterval)
autoCollectionIntervalUnit = try container.decodeIfPresent(IntervalUnits.self, forKey: .autoCollectionIntervalUnit)
autoCollectionTime = try container.convertIfPresent(TimeInterval.self, forKey: .autoCollectionTime)
lastAutoCollected = try container.decodeIfPresent(Date.self, forKey: .lastAutoCollected)
retentionTimeMonths = try container.decodeIfPresent(Int.self, forKey: .retentionTimeMonths)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if id != nil { try container.encode(id, forKey: .id) }
if tenantId != nil { try container.encode(tenantId, forKey: .tenantId) }
if tenant != nil { try container.encode(tenant, forKey: .tenant) }
if name != nil { try container.encode(name, forKey: .name) }
if displayName != nil { try container.encode(displayName, forKey: .displayName) }
if selfLink != nil { try container.encode(selfLink, forKey: .selfLink) }
if objectType != nil { try container.encode(objectType, forKey: .objectType) }
if Description != nil { try container.encode(Description, forKey: .Description) }
if sourceType != nil { try container.encode(sourceType, forKey: .sourceType) }
if autoCollection != nil { try container.encode(autoCollection, forKey: .autoCollection) }
if autoCollectionQuery != nil { try container.encode(autoCollectionQuery, forKey: .autoCollectionQuery) }
if autoCollectionInterval != nil { try container.encode(autoCollectionInterval, forKey: .autoCollectionInterval) }
if autoCollectionIntervalUnit != nil { try container.encode(autoCollectionIntervalUnit, forKey: .autoCollectionIntervalUnit) }
if autoCollectionTime != nil { try container.encode(autoCollectionTime, forKey: .autoCollectionTime) }
if lastAutoCollected != nil { try container.encode(lastAutoCollected, forKey: .lastAutoCollected) }
if retentionTimeMonths != nil { try container.encode(retentionTimeMonths, forKey: .retentionTimeMonths) }
}
}
public class Auditable : IAuditable, Codable
{
// @Required()
public var created:Date?
// @Required()
public var createUser:String?
// @Required()
public var createUserId:String?
// @Required()
public var modified:Date?
// @Required()
public var modifyUser:String?
// @Required()
public var modifyUserId:String?
// @Required()
public var isDeleted:Bool?
public var deleted:Date?
public var deleteUser:String
public var deleteUserId:String
required public init(){}
}
public class Tenant : ConfigItem, IHasVariables
{
// @Required()
public var variables:IList<Variable>?
// @Required()
public var allowedMailDomains:IList<String>?
// @Required()
public var licensedModules:IList<String>?
// @Required()
public var defaultDeploymentLifetimeDays:Int16?
// @Required()
public var maxDeploymentLifetimeDays:Int16?
// @Required()
public var systemUnpatchedWarningDays:Int16?
// @Required()
public var systemBackupMissingWarningHours:Int16?
// @Required()
public var stopVulnerableResourceAfterDays:Int16?
// @Required()
public var deploymentExpirationWarningDays:Int16?
// @Required()
public var patchNotificationDays:Int16?
// @Required()
public var useCustomHostnames:Bool?
// @Required()
public var removeInactiveVulnerabilitiesAfterDays:Int16?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case name
case objectType
case selfLink
case variables
case allowedMailDomains
case licensedModules
case defaultDeploymentLifetimeDays
case maxDeploymentLifetimeDays
case systemUnpatchedWarningDays
case systemBackupMissingWarningHours
case stopVulnerableResourceAfterDays
case deploymentExpirationWarningDays
case patchNotificationDays
case useCustomHostnames
case removeInactiveVulnerabilitiesAfterDays
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
name = try container.decodeIfPresent(String.self, forKey: .name)
objectType = try container.decodeIfPresent(ObjectTypes.self, forKey: .objectType)
selfLink = try container.decodeIfPresent(String.self, forKey: .selfLink)
variables = try container.decodeIfPresent(IList<Variable>.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)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if name != nil { try container.encode(name, forKey: .name) }
if objectType != nil { try container.encode(objectType, forKey: .objectType) }
if selfLink != nil { try container.encode(selfLink, forKey: .selfLink) }
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) }
}
}
public class ConfigItem : Auditable, IConfigItem
{
public var id:String
// @Required()
public var name:String?
// @Required()
// @StringLength(250)
public var displayName:String?
// @StringLength(8000)
public var Description:String
public var objectType:ObjectTypes
// @Ignore()
public var selfLink:String
// @Required()
public var tags:IList<Tag>?
// @Required()
public var path:IList<PathItem>?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case id
case name
case displayName
case Description
case objectType
case selfLink
case tags
case path
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decodeIfPresent(String.self, forKey: .id)
name = try container.decodeIfPresent(String.self, forKey: .name)
displayName = try container.decodeIfPresent(String.self, forKey: .displayName)
Description = try container.decodeIfPresent(String.self, forKey: .Description)
objectType = try container.decodeIfPresent(ObjectTypes.self, forKey: .objectType)
selfLink = try container.decodeIfPresent(String.self, forKey: .selfLink)
tags = try container.decodeIfPresent(IList<Tag>.self, forKey: .tags)
path = try container.decodeIfPresent(IList<PathItem>.self, forKey: .path)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if id != nil { try container.encode(id, forKey: .id) }
if name != nil { try container.encode(name, forKey: .name) }
if displayName != nil { try container.encode(displayName, forKey: .displayName) }
if Description != nil { try container.encode(Description, forKey: .Description) }
if objectType != nil { try container.encode(objectType, forKey: .objectType) }
if selfLink != nil { try container.encode(selfLink, forKey: .selfLink) }
if tags != nil { try container.encode(tags, forKey: .tags) }
if path != nil { try container.encode(path, forKey: .path) }
}
}
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 Tag : Codable
{
public var name:String
public var value:String
public var isProtected:Bool
required public init(){}
}
public class PathItem : Codable
{
public var label:String
public var link:String
public var objectType:ObjectTypes
public var objectId:String
required public init(){}
}
public class Variable : Codable
{
public var name:String
public var value:String
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 enum IntervalUnits : String, Codable
{
case Second
case Minute
case Hour
case Day
case Week
case Month
case Year
}
public enum Aggregations : String, Codable
{
case None
case Count
case DistinctCount
case Sum
case Min
case Max
case Avg
case First
}
Swift QueryTimeSeriesDefinitions 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.
GET /api/timeseries/ HTTP/1.1 Host: core.starburst.svc Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"offset":0,"total":0,"results":[{"id":"00000000-0000-0000-0000-000000000000","tenantId":"00000000-0000-0000-0000-000000000000","tenant":{"name":"String","objectType":"Tenant","selfLink":"/tenants/00000000-0000-0000-0000-000000000000","variables":null,"allowedMailDomains":null,"licensedModules":null,"defaultDeploymentLifetimeDays":0,"maxDeploymentLifetimeDays":0,"systemUnpatchedWarningDays":0,"systemBackupMissingWarningHours":0,"stopVulnerableResourceAfterDays":0,"deploymentExpirationWarningDays":0,"patchNotificationDays":0,"useCustomHostnames":false,"removeInactiveVulnerabilitiesAfterDays":0,"id":"00000000-0000-0000-0000-000000000000","displayName":"String","description":"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"},"name":"String","displayName":"String","selfLink":"/timeseries/00000000-0000-0000-0000-000000000000","objectType":"TimeSeries","description":"String","sourceType":"None","autoCollection":false,"autoCollectionQuery":"String","autoCollectionInterval":0,"autoCollectionIntervalUnit":"Second","autoCollectionTime":"00:00","lastAutoCollected":"0001-01-01T00:00:00.0000000Z","retentionTimeMonths":0,"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"}],"meta":{"String":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}