CoreService

<back to all web services

CreateTimeSeriesDefinition

TimeSeries - CRUD

Creates a new time series definition

Requires Authentication
Required roles:TenantReader, TenantAdmin
The following routes are available for this service:
POST/api/timeseries/Creates a new time series definition
POST/timeseries/Creates a new time series definition
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
Object = TypeVar('Object')


class ObjectTypes(str, Enum):
    NONE = 'None'
    CONFIG_ITEM = 'ConfigItem'
    TENANT = 'Tenant'
    COLLECTION = 'Collection'
    RESOURCE = 'Resource'
    COMPUTE_NODE = 'ComputeNode'
    VIRTUAL_MACHINE = 'VirtualMachine'
    PHYSICAL_MACHINE = 'PhysicalMachine'
    DISK = 'Disk'
    SUBNET = 'Subnet'
    IP_ADDRESS = 'IPAddress'
    JOB = 'Job'
    JOB_EVENT = 'JobEvent'
    FREEZE_PERIOD = 'FreezePeriod'
    RESOURCE_GROUP = 'ResourceGroup'
    DEPLOYMENT = 'Deployment'
    RESOURCE_GROUP_TEMPLATE = 'ResourceGroupTemplate'
    DEPLOYMENT_TEMPLATE = 'DeploymentTemplate'
    RESOURCE_PROVIDER = 'ResourceProvider'
    GENERIC_RESOURCE = 'GenericResource'
    ROLE = 'Role'
    PERMISSION = 'Permission'
    USER = 'User'
    PATCHING_WINDOW = 'PatchingWindow'
    UPDATE = 'Update'
    REPORT_DEFINITION = 'ReportDefinition'
    TIME_SERIES = 'TimeSeries'
    DATA_POINT = 'DataPoint'
    ACTION = 'Action'
    ACTION_ASSIGNMENT = 'ActionAssignment'
    USER_NOTE = 'UserNote'


class IntervalUnits(str, Enum):
    SECOND = 'Second'
    MINUTE = 'Minute'
    HOUR = 'Hour'
    DAY = 'Day'
    WEEK = 'Week'
    MONTH = 'Month'
    YEAR = 'Year'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class TimeSeriesDefinitionDto:
    id: Optional[str] = None
    name: Optional[str] = None
    description: Optional[str] = None
    source_type: Optional[ObjectTypes] = None
    auto_collection_query: Optional[str] = None
    auto_collection_interval: Optional[float] = None
    auto_collection_interval_unit: Optional[IntervalUnits] = None
    auto_collection_time: Optional[datetime.timedelta] = None
    last_auto_collected: Optional[datetime.datetime] = None
    auto_collection: bool = False
    retention_time_months: Optional[int] = None


# @Api(Description="Creates a new time series definition")
# @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(TimeSeriesDefinitionDto), StatusCode=201)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateTimeSeriesDefinition(ICreateRequest, IHasTenantName, IPost, ITimeSeriesDefinitionRequest):
    """
    Creates a new time series definition
    """

    # @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
    # @Validate(Validator="NotEmpty")
    tenant_name: Optional[str] = None

    # @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]′)")
    name: Optional[str] = None
    """
    The unique name of the time series
    """


    # @ApiMember(DataType="string", Description="The time series display name", ParameterType="body")
    # @Validate(Validator="MaximumLength(250)")
    display_name: Optional[str] = None
    """
    The time series display name
    """


    # @ApiMember(DataType="string", Description="A more detailed description for the series", ParameterType="body")
    # @Validate(Validator="MaximumLength(8000)")
    description: Optional[str] = None
    """
    A more detailed description for the series
    """


    # @ApiMember(DataType="string", Description="The source type of the time series. Only used when AutoCollection is true", ParameterType="body")
    # @Validate(Validator="MaximumLength(50)")
    source_type: Optional[ObjectTypes] = None
    """
    The source type of the time series. 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)")
    auto_collection_query: Optional[str] = None
    """
    The query used to extract datapoints from source table. 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")
    auto_collection_interval: Optional[int] = None
    """
    How often a datapoint will be collected, Only used when AutoCollection is true
    """


    # @ApiMember(DataType="int", Description="The interval unit for auto collection, Only used when AutoCollection is true", ParameterType="body")
    auto_collection_interval_unit: Optional[IntervalUnits] = None
    """
    The interval unit for auto collection, 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")
    auto_collection_time: Optional[datetime.timedelta] = None
    """
    The time (UTC), when the query will be executed to collect the datapoints, 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")
    auto_collection: bool = False
    """
    How often a datapoint will be collected, Only used when AutoCollection is true
    """


    # @ApiMember(DataType="double", Description="How many months to keep data in the time series before deleting them", ParameterType="body")
    retention_time_months: Optional[float] = None
    """
    How many months to keep data in the time series before deleting them
    """

Python 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

HTTP + JSON

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}