forked from splunk/splunk-sdk-csharp-pcl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIStoragePassword.cs
173 lines (149 loc) · 5.03 KB
/
IStoragePassword.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
/*
* 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>
/// Interface for storage password.
/// </summary>
/// <seealso cref="T:IEntity"/>
[ContractClass(typeof(IStoragePasswordContract))]
public interface IStoragePassword : IEntity
{
#region Properties
/// <summary>
/// Gets the plain text version of the current <see cref= "StoragePassword"/>.
/// </summary>
/// <value>
/// The clear password.
/// </value>
string ClearPassword
{ get; }
/// <summary>
/// Gets the extensible administration interface properties for the current
/// <see cref= "StoragePassword"/>.
/// </summary>
/// <value>
/// The extensible administration interface properties.
/// </value>
Eai Eai
{ get; }
/// <summary>
/// Gets an encrypted version of the current <see cref= "StoragePassword"/>.
/// </summary>
/// <value>
/// The encrypted password.
/// </value>
string EncryptedPassword
{ get; }
/// <summary>
/// Gets the masked version of the current <see cref="StoragePassword"/>.
/// </summary>
/// <remarks>
/// This is always stored as <c>"********"</c>.
/// </remarks>
/// <value>
/// The password.
/// </value>
string Password
{ get; }
/// <summary>
/// Gets the realm in which the current <see cref="StoragePassword"/>
/// is valid.
/// </summary>
/// <value>
/// The realm.
/// </value>
string Realm
{ get; }
/// <summary>
/// Gets the Splunk username associated with the current
/// <see cref= "StoragePassword"/>.
/// </summary>
/// <value>
/// The username.
/// </value>
string Username
{ get; }
#endregion
#region Methods
/// <summary>
/// Asynchronously updates the storage password represented by the current
/// instance.
/// </summary>
/// <remarks>
/// This method uses the <a href="http://goo.gl/s0Bw7H">POST
/// storage/passwords/{name}</a> endpoint to update the storage password
/// represented by the current instance.
/// </remarks>
///
/// <exception cref="ArgumentNullException">
/// <paramref name="password"/> is <c>null</c>.
/// </exception>
/// <exception cref="RequestException">
///
/// </exception>
/// <exception cref="ResourceNotFoundException">
///
/// </exception>
/// <exception cref="UnauthorizedAccessException">
///
/// </exception>
/// <param name="password">
/// New storage password.
/// </param>
/// <returns>
/// A <see cref="Task"/> representing the operation.
/// </returns>
Task UpdateAsync(string password);
#endregion
}
/// <summary>
/// A storage password contract.
/// </summary>
/// <seealso cref="T:Splunk.Client.IStoragePassword"/>
[ContractClassFor(typeof(IStoragePassword))]
abstract class IStoragePasswordContract : IStoragePassword
{
#region Properties
public abstract string ClearPassword { get; }
public abstract Eai Eai { get; }
public abstract string EncryptedPassword { get; }
public abstract string Password { get; }
public abstract string Realm { get; }
public abstract string Username { get; }
#endregion
#region Methods
public abstract Task GetAsync();
public abstract Task<bool> InvokeAsync(string action);
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 UpdateAsync(string password)
{
Contract.Requires<ArgumentNullException>(password != null);
return default(Task);
}
#endregion
}
}