| Required roles: | TenantReader, TenantAdmin |
| POST | /api/timeseries/ | Creates a new time series definition | |
|---|---|---|---|
| POST | /timeseries/ | Creates a new time series definition |
<?php namespace dtos;
use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};
enum ObjectTypes : string
{
case None = 'None';
case ConfigItem = 'ConfigItem';
case Tenant = 'Tenant';
case Collection = 'Collection';
case Resource = 'Resource';
case ComputeNode = 'ComputeNode';
case VirtualMachine = 'VirtualMachine';
case PhysicalMachine = 'PhysicalMachine';
case Disk = 'Disk';
case Subnet = 'Subnet';
case IPAddress = 'IPAddress';
case Job = 'Job';
case JobEvent = 'JobEvent';
case FreezePeriod = 'FreezePeriod';
case ResourceGroup = 'ResourceGroup';
case Deployment = 'Deployment';
case ResourceGroupTemplate = 'ResourceGroupTemplate';
case DeploymentTemplate = 'DeploymentTemplate';
case ResourceProvider = 'ResourceProvider';
case GenericResource = 'GenericResource';
case Role = 'Role';
case Permission = 'Permission';
case User = 'User';
case PatchingWindow = 'PatchingWindow';
case Update = 'Update';
case ReportDefinition = 'ReportDefinition';
case TimeSeries = 'TimeSeries';
case DataPoint = 'DataPoint';
case Action = 'Action';
case ActionAssignment = 'ActionAssignment';
case UserNote = 'UserNote';
}
enum IntervalUnits : string
{
case Second = 'Second';
case Minute = 'Minute';
case Hour = 'Hour';
case Day = 'Day';
case Week = 'Week';
case Month = 'Month';
case Year = 'Year';
}
class TimeSeriesDefinitionDto implements JsonSerializable
{
public function __construct(
/** @var string */
public string $id='',
/** @var string */
public string $name='',
/** @var string|null */
public ?string $description=null,
/** @var ObjectTypes|null */
public ?ObjectTypes $sourceType=null,
/** @var string|null */
public ?string $autoCollectionQuery=null,
/** @var float|null */
public ?float $autoCollectionInterval=null,
/** @var IntervalUnits|null */
public ?IntervalUnits $autoCollectionIntervalUnit=null,
/** @var DateInterval|null */
public ?DateInterval $autoCollectionTime=null,
/** @var DateTime|null */
public ?DateTime $lastAutoCollected=null,
/** @var bool|null */
public ?bool $autoCollection=null,
/** @var int|null */
public ?int $retentionTimeMonths=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['name'])) $this->name = $o['name'];
if (isset($o['description'])) $this->description = $o['description'];
if (isset($o['sourceType'])) $this->sourceType = JsonConverters::from('ObjectTypes', $o['sourceType']);
if (isset($o['autoCollectionQuery'])) $this->autoCollectionQuery = $o['autoCollectionQuery'];
if (isset($o['autoCollectionInterval'])) $this->autoCollectionInterval = $o['autoCollectionInterval'];
if (isset($o['autoCollectionIntervalUnit'])) $this->autoCollectionIntervalUnit = JsonConverters::from('IntervalUnits', $o['autoCollectionIntervalUnit']);
if (isset($o['autoCollectionTime'])) $this->autoCollectionTime = JsonConverters::from('TimeOnly', $o['autoCollectionTime']);
if (isset($o['lastAutoCollected'])) $this->lastAutoCollected = JsonConverters::from('DateTime', $o['lastAutoCollected']);
if (isset($o['autoCollection'])) $this->autoCollection = $o['autoCollection'];
if (isset($o['retentionTimeMonths'])) $this->retentionTimeMonths = $o['retentionTimeMonths'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->name)) $o['name'] = $this->name;
if (isset($this->description)) $o['description'] = $this->description;
if (isset($this->sourceType)) $o['sourceType'] = JsonConverters::to('ObjectTypes', $this->sourceType);
if (isset($this->autoCollectionQuery)) $o['autoCollectionQuery'] = $this->autoCollectionQuery;
if (isset($this->autoCollectionInterval)) $o['autoCollectionInterval'] = $this->autoCollectionInterval;
if (isset($this->autoCollectionIntervalUnit)) $o['autoCollectionIntervalUnit'] = JsonConverters::to('IntervalUnits', $this->autoCollectionIntervalUnit);
if (isset($this->autoCollectionTime)) $o['autoCollectionTime'] = JsonConverters::to('TimeOnly', $this->autoCollectionTime);
if (isset($this->lastAutoCollected)) $o['lastAutoCollected'] = JsonConverters::to('DateTime', $this->lastAutoCollected);
if (isset($this->autoCollection)) $o['autoCollection'] = $this->autoCollection;
if (isset($this->retentionTimeMonths)) $o['retentionTimeMonths'] = $this->retentionTimeMonths;
return empty($o) ? new class(){} : $o;
}
}
/** @description Creates a new time series definition */
// @Api(Description="Creates a new time series definition")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType="typeof(CoreService.ServiceModel.Dtos.TimeSeries.Reponses.TimeSeriesDefinitionDto)", StatusCode=201)
class CreateTimeSeriesDefinition implements ICreateRequest, IHasTenantName, IPost, ITimeSeriesDefinitionRequest, JsonSerializable
{
public function __construct(
// @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
// @Validate(Validator="NotEmpty")
/** @var string */
public string $tenantName='',
/** @description 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]′)")
/** @var string */
public string $name='',
/** @description The time series display name */
// @ApiMember(DataType="string", Description="The time series display name", ParameterType="body")
// @Validate(Validator="MaximumLength(250)")
/** @var string|null */
public ?string $displayName=null,
/** @description A more detailed description for the series */
// @ApiMember(DataType="string", Description="A more detailed description for the series", ParameterType="body")
// @Validate(Validator="MaximumLength(8000)")
/** @var string|null */
public ?string $description=null,
/** @description 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)")
/** @var ObjectTypes|null */
public ?ObjectTypes $sourceType=null,
/** @description 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)")
/** @var string|null */
public ?string $autoCollectionQuery=null,
/** @description 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")
/** @var int|null */
public ?int $autoCollectionInterval=null,
/** @description 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")
/** @var IntervalUnits|null */
public ?IntervalUnits $autoCollectionIntervalUnit=null,
/** @description 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")
/** @var DateInterval|null */
public ?DateInterval $autoCollectionTime=null,
/** @description 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")
/** @var bool|null */
public ?bool $autoCollection=null,
/** @description 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")
/** @var float|null */
public ?float $retentionTimeMonths=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['tenantName'])) $this->tenantName = $o['tenantName'];
if (isset($o['name'])) $this->name = $o['name'];
if (isset($o['displayName'])) $this->displayName = $o['displayName'];
if (isset($o['description'])) $this->description = $o['description'];
if (isset($o['sourceType'])) $this->sourceType = JsonConverters::from('ObjectTypes', $o['sourceType']);
if (isset($o['autoCollectionQuery'])) $this->autoCollectionQuery = $o['autoCollectionQuery'];
if (isset($o['autoCollectionInterval'])) $this->autoCollectionInterval = $o['autoCollectionInterval'];
if (isset($o['autoCollectionIntervalUnit'])) $this->autoCollectionIntervalUnit = JsonConverters::from('IntervalUnits', $o['autoCollectionIntervalUnit']);
if (isset($o['autoCollectionTime'])) $this->autoCollectionTime = JsonConverters::from('TimeOnly', $o['autoCollectionTime']);
if (isset($o['autoCollection'])) $this->autoCollection = $o['autoCollection'];
if (isset($o['retentionTimeMonths'])) $this->retentionTimeMonths = $o['retentionTimeMonths'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->tenantName)) $o['tenantName'] = $this->tenantName;
if (isset($this->name)) $o['name'] = $this->name;
if (isset($this->displayName)) $o['displayName'] = $this->displayName;
if (isset($this->description)) $o['description'] = $this->description;
if (isset($this->sourceType)) $o['sourceType'] = JsonConverters::to('ObjectTypes', $this->sourceType);
if (isset($this->autoCollectionQuery)) $o['autoCollectionQuery'] = $this->autoCollectionQuery;
if (isset($this->autoCollectionInterval)) $o['autoCollectionInterval'] = $this->autoCollectionInterval;
if (isset($this->autoCollectionIntervalUnit)) $o['autoCollectionIntervalUnit'] = JsonConverters::to('IntervalUnits', $this->autoCollectionIntervalUnit);
if (isset($this->autoCollectionTime)) $o['autoCollectionTime'] = JsonConverters::to('TimeOnly', $this->autoCollectionTime);
if (isset($this->autoCollection)) $o['autoCollection'] = $this->autoCollection;
if (isset($this->retentionTimeMonths)) $o['retentionTimeMonths'] = $this->retentionTimeMonths;
return empty($o) ? new class(){} : $o;
}
}
PHP 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}