| Required roles: | TenantReader, TenantAdmin |
| POST | /api/timeseries/ | Creates a new time series definition | |
|---|---|---|---|
| POST | /timeseries/ | Creates a new time series definition |
import 'package:servicestack/servicestack.dart';
enum ObjectTypes
{
None,
ConfigItem,
Tenant,
Collection,
Resource,
ComputeNode,
VirtualMachine,
PhysicalMachine,
Disk,
Subnet,
IPAddress,
Job,
JobEvent,
FreezePeriod,
ResourceGroup,
Deployment,
ResourceGroupTemplate,
DeploymentTemplate,
ResourceProvider,
GenericResource,
Role,
Permission,
User,
PatchingWindow,
Update,
ReportDefinition,
TimeSeries,
DataPoint,
Action,
ActionAssignment,
UserNote,
}
enum IntervalUnits
{
Second,
Minute,
Hour,
Day,
Week,
Month,
Year,
}
class TimeSeriesDefinitionDto implements IConvertible
{
String id = "";
String name = "";
String? description;
ObjectTypes sourceType;
String? autoCollectionQuery;
double? autoCollectionInterval;
IntervalUnits? autoCollectionIntervalUnit;
Duration? autoCollectionTime;
DateTime? lastAutoCollected;
bool autoCollection;
int? retentionTimeMonths;
TimeSeriesDefinitionDto({this.id,this.name,this.description,this.sourceType,this.autoCollectionQuery,this.autoCollectionInterval,this.autoCollectionIntervalUnit,this.autoCollectionTime,this.lastAutoCollected,this.autoCollection,this.retentionTimeMonths});
TimeSeriesDefinitionDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
description = json['description'];
sourceType = JsonConverters.fromJson(json['sourceType'],'ObjectTypes',context!);
autoCollectionQuery = json['autoCollectionQuery'];
autoCollectionInterval = JsonConverters.toDouble(json['autoCollectionInterval']);
autoCollectionIntervalUnit = JsonConverters.fromJson(json['autoCollectionIntervalUnit'],'IntervalUnits',context!);
autoCollectionTime = JsonConverters.fromJson(json['autoCollectionTime'],'Duration',context!);
lastAutoCollected = JsonConverters.fromJson(json['lastAutoCollected'],'DateTime',context!);
autoCollection = json['autoCollection'];
retentionTimeMonths = json['retentionTimeMonths'];
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'description': description,
'sourceType': JsonConverters.toJson(sourceType,'ObjectTypes',context!),
'autoCollectionQuery': autoCollectionQuery,
'autoCollectionInterval': autoCollectionInterval,
'autoCollectionIntervalUnit': JsonConverters.toJson(autoCollectionIntervalUnit,'IntervalUnits',context!),
'autoCollectionTime': JsonConverters.toJson(autoCollectionTime,'Duration',context!),
'lastAutoCollected': JsonConverters.toJson(lastAutoCollected,'DateTime',context!),
'autoCollection': autoCollection,
'retentionTimeMonths': retentionTimeMonths
};
getTypeName() => "TimeSeriesDefinitionDto";
TypeContext? context = _ctx;
}
/**
* Creates a new time series definition
*/
// @Api(Description="Creates a new time series definition")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(TimeSeriesDefinitionDto), StatusCode=201)
class CreateTimeSeriesDefinition implements ICreateRequest, IHasTenantName, IPost, ITimeSeriesDefinitionRequest, IConvertible
{
// @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
// @Validate(Validator="NotEmpty")
String tenantName = "";
/**
* 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]′)")
String name = "";
/**
* The time series display name
*/
// @ApiMember(DataType="string", Description="The time series display name", ParameterType="body")
// @Validate(Validator="MaximumLength(250)")
String? displayName;
/**
* A more detailed description for the series
*/
// @ApiMember(DataType="string", Description="A more detailed description for the series", ParameterType="body")
// @Validate(Validator="MaximumLength(8000)")
String? 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)")
ObjectTypes? sourceType;
/**
* 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)")
String? autoCollectionQuery;
/**
* 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")
int? autoCollectionInterval;
/**
* 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")
IntervalUnits? autoCollectionIntervalUnit;
/**
* 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")
Duration? autoCollectionTime;
/**
* 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")
bool autoCollection;
/**
* 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")
double? retentionTimeMonths;
CreateTimeSeriesDefinition({this.tenantName,this.name,this.displayName,this.description,this.sourceType,this.autoCollectionQuery,this.autoCollectionInterval,this.autoCollectionIntervalUnit,this.autoCollectionTime,this.autoCollection,this.retentionTimeMonths});
CreateTimeSeriesDefinition.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
tenantName = json['tenantName'];
name = json['name'];
displayName = json['displayName'];
description = json['description'];
sourceType = JsonConverters.fromJson(json['sourceType'],'ObjectTypes',context!);
autoCollectionQuery = json['autoCollectionQuery'];
autoCollectionInterval = json['autoCollectionInterval'];
autoCollectionIntervalUnit = JsonConverters.fromJson(json['autoCollectionIntervalUnit'],'IntervalUnits',context!);
autoCollectionTime = JsonConverters.fromJson(json['autoCollectionTime'],'Duration',context!);
autoCollection = json['autoCollection'];
retentionTimeMonths = JsonConverters.toDouble(json['retentionTimeMonths']);
return this;
}
Map<String, dynamic> toJson() => {
'tenantName': tenantName,
'name': name,
'displayName': displayName,
'description': description,
'sourceType': JsonConverters.toJson(sourceType,'ObjectTypes',context!),
'autoCollectionQuery': autoCollectionQuery,
'autoCollectionInterval': autoCollectionInterval,
'autoCollectionIntervalUnit': JsonConverters.toJson(autoCollectionIntervalUnit,'IntervalUnits',context!),
'autoCollectionTime': JsonConverters.toJson(autoCollectionTime,'Duration',context!),
'autoCollection': autoCollection,
'retentionTimeMonths': retentionTimeMonths
};
getTypeName() => "CreateTimeSeriesDefinition";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'duneframework.com', types: <String, TypeInfo> {
'ObjectTypes': TypeInfo(TypeOf.Enum, enumValues:ObjectTypes.values),
'IntervalUnits': TypeInfo(TypeOf.Enum, enumValues:IntervalUnits.values),
'TimeSeriesDefinitionDto': TypeInfo(TypeOf.Class, create:() => TimeSeriesDefinitionDto()),
'CreateTimeSeriesDefinition': TypeInfo(TypeOf.Class, create:() => CreateTimeSeriesDefinition()),
});
Dart 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}