forked from splunk/splunk-sdk-csharp-pcl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIApplication.cs
336 lines (296 loc) · 11.2 KB
/
IApplication.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/*
* Copyright 2014 Splunk, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"): you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
namespace Splunk.Client
{
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Net.Http;
using System.Threading.Tasks;
using Splunk.Client.Arguments;
using Splunk.Client.Entities;
/// <summary>
/// Provides an operational interface to Splunk application entities.
/// </summary>
/// <seealso cref="T:IEntity"/>
[ContractClass(typeof(IApplicationContract))]
public interface IApplication : IEntity
{
#region Properties
/// <summary>
/// Gets the application author.
/// </summary>
/// <value>
/// The application author.
/// </value>
string ApplicationAuthor
{ get; }
/// <summary>
/// Gets the username of the splunk.com account for publishing the current
/// <see cref="Application"/> to Splunkbase.
/// </summary>
/// <value>
/// The author.
/// </value>
string Author
{ get; }
/// <summary>
/// Gets a value that indicates whether Splunk should check Splunkbase for
/// updates to the current <see cref="Application"/>.
/// </summary>
/// <value>
/// <c>true</c> if check for updates, <c>false</c> if not.
/// </value>
bool CheckForUpdates
{ get; }
/// <summary>
/// Gets a value that indicates whether custom setup has been performed on
/// the current <see cref="Application"/>.
/// </summary>
/// <value>
/// <c>true</c> if configured, <c>false</c> if not.
/// </value>
bool Configured
{ get; }
/// <summary>
/// Gets the short explanatory string displayed underneath the title of the
/// current <see cref="Application"/> in Launcher.
/// </summary>
/// <value>
/// The description.
/// </value>
string Description
{ get; }
/// <summary>
/// Gets a value indicating whether the current <see cref="Application"/>
/// is disabled.
/// </summary>
/// <value>
/// <c>true</c> if disabled, <c>false</c> if not.
/// </value>
bool Disabled
{ get; }
/// <summary>
/// Gets the extensible administration interface properties for the current
/// <see cref= "Application"/>.
/// </summary>
/// <value>
/// The extensible administration interface properties.
/// </value>
Eai Eai
{ get; }
/// <summary>
/// Gets the name of the current <see cref="Application"/> for display in the
/// Splunk GUI and Launcher.
/// </summary>
/// <value>
/// The label.
/// </value>
string Label
{ get; }
/// <summary>
/// Gets the links.
/// </summary>
/// <value>
/// The links.
/// </value>
IReadOnlyDictionary<string, Uri> Links
{ get; }
/// <summary>
/// Gets a value that indicates whether objects contained in the current
/// <see cref="Application"/> should be reloaded.
/// </summary>
/// <value>
/// <c>true</c> if refresh, <c>false</c> if not.
/// </value>
bool Refresh
{ get; }
/// <summary>
/// Gets a value that indicates whether changing the state of the current
/// <see cref="Application"/> always requires restarting Splunk.
/// </summary>
/// <remarks>
/// A value of <c>true</c> indicates that a state change always requires a
/// restart. A value of <c>false</c> indicates that modifying state may or
/// may not require a restart depending on what state has been changed. A
/// value of <c>false</c> does not indicate that a restart will never be
/// required to effect a state change. State changes include enabling or
/// disabling an <see cref="Application"/>.
/// </remarks>
/// <value>
/// <c>true</c> if a state change requires a restart, <c>false</c> if not.
/// </value>
bool StateChangeRequiresRestart
{ get; }
/// <summary>
/// Gets the version string for the current <see cref="Application"/>.
/// </summary>
/// <remarks>
/// Version strings are a number followed by a sequence of numbers or dots.
/// Pre-release versions may append a space and a single-word suffix like
/// "beta2".
/// <example>Examples:</example>
/// <code>
/// "1.2"
/// "11.0.34"
/// "2.0 beta"
/// "1.3 beta2"
/// "1.0 b2"
/// "12.4 alpha"
/// "11.0.34.234.254"
/// </code>
/// </remarks>
/// <value>
/// The version.
/// </value>
string Version
{ get; }
/// <summary>
/// Gets a value that indicates if the current <see cref="Application"/>
/// is visible and navigable from Splunk Web.
/// </summary>
/// <value>
/// <c>true</c> if visible, <c>false</c> if not.
/// </value>
bool Visible
{ get; }
#endregion
#region Methods
/// <summary>
/// Asynchronously disables the current <see cref="Application"/>.
/// </summary>
/// <remarks>
/// This method uses the POST apps/local/{name}/disable endpoint to disable
/// the current <see cref="Application"/>.
/// </remarks>
/// <returns>
/// A <see cref="Task"/> representing the operation.
/// </returns>
Task DisableAsync();
/// <summary>
/// Asynchronously enables the current <see cref="Application"/>.
/// </summary>
/// <remarks>
/// This method uses the POST apps/local/{name}/enable endpoint to enable the
/// current <see cref="Application"/>.
/// </remarks>
/// <returns>
/// A <see cref="Task"/> representing the operation.
/// </returns>
Task EnableAsync();
/// <summary>
/// Asynchronously retrieves setup information for the current
/// <see cref="Application"/>.
/// </summary>
/// <remarks>
/// This method uses the <a href="http://goo.gl/mUT9gU">GET
/// apps/local/{name}/setup</a> endpoint to construct the
/// <see cref= "ApplicationSetupInfo"/> instance it returns.
/// </remarks>
/// <returns>
/// An object containing setup information for the current
/// <see cref= "Application"/>.
/// </returns>
Task<ApplicationSetupInfo> GetSetupInfoAsync();
/// <summary>
/// Asynchronously gets update information for the current
/// <see cref= "Application"/>.
/// </summary>
/// <remarks>
/// This method uses the <a href="http://goo.gl/mrbtRj">GET
/// apps/local/{name}/update</a> endpoint to construct the
/// <see cref= "ApplicationUpdateInfo"/> instance it returns.
/// </remarks>
/// <returns>
/// An object containing update information for the current
/// <see cref= "Application"/>.
/// </returns>
Task<ApplicationUpdateInfo> GetUpdateInfoAsync();
/// <summary>
/// Asynchronously archives the current <see cref="Application"/>.
/// </summary>
/// <remarks>
/// This method uses the <a href="http://goo.gl/DJkT7S">GET
/// apps/local/{name}/package</a> endpoint to create an archive of the
/// current <see cref="Application"/>.
/// </remarks>
/// <returns>
/// An object containing information about the newly created archive.
/// </returns>
Task<ApplicationArchiveInfo> PackageAsync();
/// <summary>
/// Asynchronously updates the attributes of the application represented by
/// the current instance.
/// </summary>
/// <remarks>
/// This method uses the <a href="http://goo.gl/dKraaR">POST
/// apps/local/{name}</a> endpoint to update the attributes of the current
/// <see cref="Application"/> and optionally check for updates on Splunkbase.
/// </remarks>
/// <param name="attributes">
/// New attributes for the current <see cref="Application"/> instance.
/// </param>
/// <param name="checkForUpdates">
/// A value of <c>true</c>, if Splunk should check Splunkbase for updates to
/// the current <see cref="Application"/> instance.
/// </param>
/// <returns>
/// <c>true</c> if the current snapshot was also updated.
/// </returns>
Task<bool> UpdateAsync(ApplicationAttributes attributes, bool checkForUpdates = false);
#endregion
}
/// <summary>
/// An application contract.
/// </summary>
/// <seealso cref="T:Splunk.Client.IApplication"/>
[ContractClassFor(typeof(IApplication))]
abstract class IApplicationContract : IApplication
{
#region Properties
public abstract string ApplicationAuthor { get; }
public abstract string Author { get; }
public abstract bool CheckForUpdates { get; }
public abstract bool Configured { get; }
public abstract string Description { get; }
public abstract bool Disabled { get; }
public abstract Eai Eai { get; }
public abstract string Label { get; }
public abstract IReadOnlyDictionary<string, Uri> Links { get; }
public abstract bool Refresh { get; }
public abstract bool StateChangeRequiresRestart { get; }
public abstract string Version { get; }
public abstract bool Visible { get; }
#endregion
#region Methods
public abstract Task DisableAsync();
public abstract Task EnableAsync();
public abstract Task GetAsync();
public abstract Task<ApplicationSetupInfo> GetSetupInfoAsync();
public abstract Task<ApplicationUpdateInfo> GetUpdateInfoAsync();
public abstract Task<ApplicationArchiveInfo> PackageAsync();
public abstract Task RemoveAsync();
public abstract Task<bool> SendAsync(HttpMethod method, string action, params Argument[] arguments);
public abstract Task<bool> UpdateAsync(params Argument[] arguments);
public abstract Task<bool> UpdateAsync(IEnumerable<Argument> arguments);
public Task<bool> UpdateAsync(ApplicationAttributes attributes, bool checkForUpdates)
{
Contract.Requires<ArgumentNullException>(attributes != null);
return default(Task<bool>);
}
#endregion
}
}