| Required roles: | TenantReader, TenantAdmin |
| POST | /api/timeseries/ | Creates a new time series definition | |
|---|---|---|---|
| POST | /timeseries/ | Creates a new time series definition |
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using ServiceStack;
using ServiceStack.DataAnnotations;
using CoreService.ServiceModel.Dtos.TimeSeries.Crud;
using YCO.Dune.Models.Enums;
using CoreService.ServiceModel.Dtos.TimeSeries.Reponses;
namespace CoreService.ServiceModel.Dtos.TimeSeries.Crud
{
///<summary>
///Creates a new time series definition
///</summary>
[Api(Description="Creates a new time series definition")]
[ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(CoreService.ServiceModel.Dtos.TimeSeries.Reponses.TimeSeriesDefinitionDto), StatusCode=201)]
public partial class CreateTimeSeriesDefinition
: ICreateRequest, IHasTenantName, IPost, ITimeSeriesDefinitionRequest
{
[ApiMember(DataType="string", IsRequired=true, ParameterType="header")]
[Validate("NotEmpty")]
public virtual string TenantName { get; set; }
///<summary>
///The unique name of the time series
///</summary>
[ApiMember(DataType="string", Description="The unique name of the time series", IsRequired=true, ParameterType="body")]
[Validate("NotEmpty")]
[Validate("MaximumLength(100)")]
[Validate("RegularExpression(′^[0-9a-z]′)")]
public virtual string Name { get; set; }
///<summary>
///The time series display name
///</summary>
[ApiMember(DataType="string", Description="The time series display name", ParameterType="body")]
[Validate("MaximumLength(250)")]
public virtual string? DisplayName { get; set; }
///<summary>
///A more detailed description for the series
///</summary>
[ApiMember(DataType="string", Description="A more detailed description for the series", ParameterType="body")]
[Validate("MaximumLength(8000)")]
public virtual string? Description { get; set; }
///<summary>
///The source type of the time series. Only used when AutoCollection is true
///</summary>
[ApiMember(DataType="string", Description="The source type of the time series. Only used when AutoCollection is true", ParameterType="body")]
[Validate("MaximumLength(50)")]
public virtual ObjectTypes? SourceType { get; set; }
///<summary>
///The query used to extract datapoints from source table. Only used when AutoCollection is true
///</summary>
[ApiMember(DataType="string", Description="The query used to extract datapoints from source table. Only used when AutoCollection is true", ParameterType="body")]
[Validate("MaximumLength(2147483647)")]
public virtual string? AutoCollectionQuery { get; set; }
///<summary>
///How often a datapoint will be collected, Only used when AutoCollection is true
///</summary>
[ApiMember(DataType="int", Description="How often a datapoint will be collected, Only used when AutoCollection is true", ParameterType="body")]
public virtual int? AutoCollectionInterval { get; set; }
///<summary>
///The interval unit for auto collection, Only used when AutoCollection is true
///</summary>
[ApiMember(DataType="int", Description="The interval unit for auto collection, Only used when AutoCollection is true", ParameterType="body")]
public virtual IntervalUnits? AutoCollectionIntervalUnit { get; set; }
///<summary>
///The time (UTC), when the query will be executed to collect the datapoints, Only used when AutoCollection is true
///</summary>
[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")]
public virtual TimeOnly? AutoCollectionTime { get; set; }
///<summary>
///How often a datapoint will be collected, Only used when AutoCollection is true
///</summary>
[ApiMember(DataType="bool", Description="How often a datapoint will be collected, Only used when AutoCollection is true", ParameterType="body")]
public virtual bool AutoCollection { get; set; }
///<summary>
///How many months to keep data in the time series before deleting them
///</summary>
[ApiMember(DataType="double", Description="How many months to keep data in the time series before deleting them", ParameterType="body")]
public virtual double? RetentionTimeMonths { get; set; }
}
}
namespace CoreService.ServiceModel.Dtos.TimeSeries.Reponses
{
public partial class TimeSeriesDefinitionDto
{
public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
public virtual string? Description { get; set; }
public virtual ObjectTypes SourceType { get; set; }
public virtual string? AutoCollectionQuery { get; set; }
public virtual double? AutoCollectionInterval { get; set; }
public virtual IntervalUnits? AutoCollectionIntervalUnit { get; set; }
public virtual TimeOnly? AutoCollectionTime { get; set; }
public virtual DateTime? LastAutoCollected { get; set; }
public virtual bool AutoCollection { get; set; }
public virtual int? RetentionTimeMonths { get; set; }
}
}
namespace YCO.Dune.Models.Enums
{
public enum IntervalUnits
{
Second,
Minute,
Hour,
Day,
Week,
Month,
Year,
}
public 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,
}
}
C# 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}