-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathServerReference.cs
More file actions
226 lines (198 loc) · 14.9 KB
/
Copy pathServerReference.cs
File metadata and controls
226 lines (198 loc) · 14.9 KB
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
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OpenStack.Compute.v2_1.Serialization;
using OpenStack.Serialization;
namespace OpenStack.Compute.v2_1
{
/// <summary>
/// Reference to a server instance.
/// </summary>
public class ServerReference : IHaveExtraData, IServiceResource
{
/// <summary>
/// The server identifier.
/// </summary>
[JsonProperty("id")]
public Identifier Id { get; set; }
[JsonExtensionData]
IDictionary<string, JToken> IHaveExtraData.Data { get; set; } = new Dictionary<string, JToken>();
object IServiceResource.Owner { get; set; }
/// <inheritdoc cref="ComputeApi.GetServerAsync{T}" />
public async Task<Server> GetServerAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return await compute.GetServerAsync<Server>(Id, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.GetServerAddressAsync{T}" />
/// <summary />
public async Task<IList<ServerAddress>> GetAddressAsync(string key, CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return await compute.GetServerAddressAsync<ServerAddress>(Id, key, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.GetServerMetadataAsync{T}" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public Task<ServerMetadata> GetMetadataAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var owner = this.GetOwnerOrThrow<ComputeApi>();
return owner.GetServerMetadataAsync<ServerMetadata>(Id, cancellationToken);
}
/// <inheritdoc cref="ComputeApi.GetServerMetadataItemAsync" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public Task<string> GetMetadataItemAsync(string key, CancellationToken cancellationToken = default(CancellationToken))
{
var owner = this.GetOwnerOrThrow<ComputeApi>();
return owner.GetServerMetadataItemAsync(Id, key, cancellationToken);
}
/// <inheritdoc cref="ComputeApi.ListServerAddressesAsync{T}" />
public async Task<IDictionary<string, IList<ServerAddress>>> ListAddressesAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return await compute.ListServerAddressesAsync<ServerAddressCollection>(Id, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.DeleteServerAsync" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public Task DeleteAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var owner = this.GetOwnerOrThrow<ComputeApi>();
return owner.DeleteServerAsync(Id, cancellationToken);
}
/// <inheritdoc cref="ComputeApi.WaitUntilServerIsDeletedAsync{TServer,TStatus}" />
/// <exception cref="InvalidOperationException">When the <see cref="Server"/> instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public virtual async Task WaitUntilDeletedAsync(TimeSpan? refreshDelay = null, TimeSpan? timeout = null, IProgress<bool> progress = null, CancellationToken cancellationToken = default(CancellationToken))
{
var owner = this.GetOwnerOrThrow<ComputeApi>();
await owner.WaitUntilServerIsDeletedAsync<Server, ServerStatus>(Id, null, refreshDelay, timeout, progress, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.SnapshotServerAsync{T}" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task<Image> SnapshotAsync(SnapshotServerRequest request, CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return await compute.SnapshotServerAsync<Image>(Id, request, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.StartServerAsync" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task StartAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
await compute.StartServerAsync(Id, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.StopServerAsync" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task StopAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
await compute.StopServerAsync(Id, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.SuspendServerAsync" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task SuspendAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
await compute.SuspendServerAsync(Id, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.ResumeServerAsync" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task ResumeAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
await compute.ResumeServerAsync(Id, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.RebootServerAsync{T}" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task RebootAsync(RebootServerRequest request = null, CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
await compute.RebootServerAsync(Id, request, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.ListServerVolumesAsync{T}" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task<IEnumerable<ServerVolume>> ListVolumesAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return await compute.ListServerVolumesAsync<ServerVolumeCollection>(Id, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.GetVncConsoleAsync{T}" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task<RemoteConsole> GetVncConsoleAsync(RemoteConsoleType type, CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return await compute.GetVncConsoleAsync<RemoteConsole>(Id, type, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.GetSpiceConsoleAsync{T}" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task<RemoteConsole> GetSpiceConsoleAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return await compute.GetSpiceConsoleAsync<RemoteConsole>(Id,RemoteConsoleType.SpiceHtml5, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.GetSerialConsoleAsync{T}" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task<RemoteConsole> GetSerialConsoleAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return await compute.GetSerialConsoleAsync<RemoteConsole>(Id, RemoteConsoleType.Serial, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.GetRdpConsoleAsync{T}" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task<RemoteConsole> GetRdpConsoleAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return await compute.GetRdpConsoleAsync<RemoteConsole>(Id, RemoteConsoleType.RdpHtml5, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.GetConsoleOutputAsync" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task<string> GetConsoleOutputAsync(int length = -1, CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return await compute.GetConsoleOutputAsync(Id, length, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.RescueServerAsync" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task<string> RescueAsync(RescueServerRequest request = null, CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return await compute.RescueServerAsync(Id, request, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc cref="ComputeApi.UnrescueServerAsync" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public Task UnrescueAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return compute.UnrescueServerAsync(Id, cancellationToken);
}
/// <inheritdoc cref="ComputeApi.ResizeServerAsync" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public Task ResizeAsync(Identifier flavorId, CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return compute.ResizeServerAsync(Id, flavorId, cancellationToken);
}
/// <inheritdoc cref="ComputeApi.ConfirmResizeServerAsync" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public Task ConfirmResizeAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return compute.ConfirmResizeServerAsync(Id, cancellationToken);
}
/// <inheritdoc cref="ComputeApi.CancelResizeServerAsync" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public Task CancelResizeAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return compute.CancelResizeServerAsync(Id, cancellationToken);
}
/// <inheritdoc cref="ComputeApi.ListServerActionSummariesAsync{T}" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public async Task<IEnumerable<ServerActionSummary>> ListActionSummariesAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var compute = this.GetOwnerOrThrow<ComputeApi>();
return await compute.ListServerActionSummariesAsync<ServerActionSummaryCollection>(Id, cancellationToken).ConfigureAwait(false);
}
}
}