-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathDeleteApi.cs
119 lines (106 loc) · 5.45 KB
/
DeleteApi.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using System;
using System.Threading;
using System.Threading.Tasks;
using InfluxDB.Client.Api.Domain;
using InfluxDB.Client.Api.Service;
using InfluxDB.Client.Core;
namespace InfluxDB.Client
{
public interface IDeleteApi
{
/// <summary>
/// Delete Time series data from InfluxDB.
/// </summary>
/// <param name="start">Start time</param>
/// <param name="stop">Stop time</param>
/// <param name="predicate">Sql where like delete statement</param>
/// <param name="bucket">The bucket from which data will be deleted</param>
/// <param name="org">The organization of the above bucket</param>
/// <param name="cancellationToken">Cancellation token</param>
Task Delete(DateTime start, DateTime stop, string predicate, Bucket bucket, Organization org,
CancellationToken cancellationToken = default);
/// <summary>
/// Delete Time series data from InfluxDB.
/// </summary>
/// <param name="start">Start time</param>
/// <param name="stop">Stop time</param>
/// <param name="predicate">Sql where like delete statement</param>
/// <param name="bucket">The bucket from which data will be deleted</param>
/// <param name="org">The organization of the above bucket</param>
/// <param name="cancellationToken">Cancellation token</param>
Task Delete(DateTime start, DateTime stop, string predicate, string bucket, string org,
CancellationToken cancellationToken = default);
/// <summary>
/// Delete Time series data from InfluxDB.
/// </summary>
/// <param name="predicate">Predicate delete request</param>
/// <param name="bucket">The bucket from which data will be deleted</param>
/// <param name="org">The organization of the above bucket</param>
/// <param name="cancellationToken">Cancellation token</param>
Task Delete(DeletePredicateRequest predicate, string bucket, string org,
CancellationToken cancellationToken = default);
}
public class DeleteApi : IDeleteApi
{
private readonly DeleteService _service;
protected internal DeleteApi(DeleteService service)
{
Arguments.CheckNotNull(service, nameof(service));
_service = service;
}
/// <summary>
/// Delete Time series data from InfluxDB.
/// </summary>
/// <param name="start">Start time</param>
/// <param name="stop">Stop time</param>
/// <param name="predicate">Sql where like delete statement</param>
/// <param name="bucket">The bucket from which data will be deleted</param>
/// <param name="org">The organization of the above bucket</param>
/// <param name="cancellationToken">Cancellation token</param>
public Task Delete(DateTime start, DateTime stop, string predicate, Bucket bucket, Organization org,
CancellationToken cancellationToken = default)
{
Arguments.CheckNotNull(start, "Start is required");
Arguments.CheckNotNull(stop, "Stop is required");
Arguments.CheckNotNull(predicate, "Predicate is required");
Arguments.CheckNotNull(bucket, "Bucket is required");
Arguments.CheckNotNull(org, "Organization is required");
return Delete(start, stop, predicate, bucket.Id, org.Id, cancellationToken);
}
/// <summary>
/// Delete Time series data from InfluxDB.
/// </summary>
/// <param name="start">Start time</param>
/// <param name="stop">Stop time</param>
/// <param name="predicate">Sql where like delete statement</param>
/// <param name="bucket">The bucket from which data will be deleted</param>
/// <param name="org">The organization of the above bucket</param>
/// <param name="cancellationToken">Cancellation token</param>
public Task Delete(DateTime start, DateTime stop, string predicate, string bucket, string org,
CancellationToken cancellationToken = default)
{
Arguments.CheckNotNull(start, "Start is required");
Arguments.CheckNotNull(stop, "Stop is required");
Arguments.CheckNotNull(predicate, "Predicate is required");
Arguments.CheckNonEmptyString(bucket, "Bucket is required");
Arguments.CheckNonEmptyString(org, "Organization is required");
var predicateRequest = new DeletePredicateRequest(start, stop, predicate);
return Delete(predicateRequest, bucket, org, cancellationToken);
}
/// <summary>
/// Delete Time series data from InfluxDB.
/// </summary>
/// <param name="predicate">Predicate delete request</param>
/// <param name="bucket">The bucket from which data will be deleted</param>
/// <param name="org">The organization of the above bucket</param>
/// <param name="cancellationToken">Cancellation token</param>
public Task Delete(DeletePredicateRequest predicate, string bucket, string org,
CancellationToken cancellationToken = default)
{
Arguments.CheckNotNull(predicate, "Predicate is required");
Arguments.CheckNonEmptyString(bucket, "Bucket is required");
Arguments.CheckNonEmptyString(org, "Organization is required");
return _service.PostDeleteAsync(predicate, null, org, bucket, null, null, cancellationToken);
}
}
}