| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.ResourceManager.Compute.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.Compute |
| | 18 | | { |
| | 19 | | internal partial class DisksRestOperations |
| | 20 | | { |
| | 21 | | private string subscriptionId; |
| | 22 | | private Uri endpoint; |
| | 23 | | private ClientDiagnostics _clientDiagnostics; |
| | 24 | | private HttpPipeline _pipeline; |
| | 25 | |
|
| | 26 | | /// <summary> Initializes a new instance of DisksRestOperations. </summary> |
| | 27 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 28 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 29 | | /// <param name="subscriptionId"> Subscription credentials which uniquely identify Microsoft Azure subscription. |
| | 30 | | /// <param name="endpoint"> server parameter. </param> |
| | 31 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 396 | 32 | | public DisksRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Ur |
| | 33 | | { |
| 396 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 396 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 396 | 40 | | this.subscriptionId = subscriptionId; |
| 396 | 41 | | this.endpoint = endpoint; |
| 396 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 396 | 43 | | _pipeline = pipeline; |
| 396 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string diskName, Disk disk) |
| | 47 | | { |
| 180 | 48 | | var message = _pipeline.CreateMessage(); |
| 180 | 49 | | var request = message.Request; |
| 180 | 50 | | request.Method = RequestMethod.Put; |
| 180 | 51 | | var uri = new RawRequestUriBuilder(); |
| 180 | 52 | | uri.Reset(endpoint); |
| 180 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 180 | 54 | | uri.AppendPath(subscriptionId, true); |
| 180 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 180 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 180 | 57 | | uri.AppendPath("/providers/Microsoft.Compute/disks/", false); |
| 180 | 58 | | uri.AppendPath(diskName, true); |
| 180 | 59 | | uri.AppendQuery("api-version", "2019-11-01", true); |
| 180 | 60 | | request.Uri = uri; |
| 180 | 61 | | request.Headers.Add("Content-Type", "application/json"); |
| 180 | 62 | | var content = new Utf8JsonRequestContent(); |
| 180 | 63 | | content.JsonWriter.WriteObjectValue(disk); |
| 180 | 64 | | request.Content = content; |
| 180 | 65 | | return message; |
| | 66 | | } |
| | 67 | |
|
| | 68 | | /// <summary> Creates or updates a disk. </summary> |
| | 69 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 70 | | /// <param name="diskName"> The name of the managed disk that is being created. The name can't be changed a |
| | 71 | | /// <param name="disk"> Disk object supplied in the body of the Put disk operation. </param> |
| | 72 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 73 | | public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string diskName, Disk disk, Cancellati |
| | 74 | | { |
| 46 | 75 | | if (resourceGroupName == null) |
| | 76 | | { |
| 0 | 77 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 78 | | } |
| 46 | 79 | | if (diskName == null) |
| | 80 | | { |
| 0 | 81 | | throw new ArgumentNullException(nameof(diskName)); |
| | 82 | | } |
| 46 | 83 | | if (disk == null) |
| | 84 | | { |
| 0 | 85 | | throw new ArgumentNullException(nameof(disk)); |
| | 86 | | } |
| | 87 | |
|
| 46 | 88 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, diskName, disk); |
| 46 | 89 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 46 | 90 | | switch (message.Response.Status) |
| | 91 | | { |
| | 92 | | case 200: |
| | 93 | | case 202: |
| 44 | 94 | | return message.Response; |
| | 95 | | default: |
| 2 | 96 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 97 | | } |
| 44 | 98 | | } |
| | 99 | |
|
| | 100 | | /// <summary> Creates or updates a disk. </summary> |
| | 101 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 102 | | /// <param name="diskName"> The name of the managed disk that is being created. The name can't be changed a |
| | 103 | | /// <param name="disk"> Disk object supplied in the body of the Put disk operation. </param> |
| | 104 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 105 | | public Response CreateOrUpdate(string resourceGroupName, string diskName, Disk disk, CancellationToken cancellat |
| | 106 | | { |
| 46 | 107 | | if (resourceGroupName == null) |
| | 108 | | { |
| 0 | 109 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 110 | | } |
| 46 | 111 | | if (diskName == null) |
| | 112 | | { |
| 0 | 113 | | throw new ArgumentNullException(nameof(diskName)); |
| | 114 | | } |
| 46 | 115 | | if (disk == null) |
| | 116 | | { |
| 0 | 117 | | throw new ArgumentNullException(nameof(disk)); |
| | 118 | | } |
| | 119 | |
|
| 46 | 120 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, diskName, disk); |
| 46 | 121 | | _pipeline.Send(message, cancellationToken); |
| 46 | 122 | | switch (message.Response.Status) |
| | 123 | | { |
| | 124 | | case 200: |
| | 125 | | case 202: |
| 44 | 126 | | return message.Response; |
| | 127 | | default: |
| 2 | 128 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 129 | | } |
| 44 | 130 | | } |
| | 131 | |
|
| | 132 | | internal HttpMessage CreateUpdateRequest(string resourceGroupName, string diskName, DiskUpdate disk) |
| | 133 | | { |
| 24 | 134 | | var message = _pipeline.CreateMessage(); |
| 24 | 135 | | var request = message.Request; |
| 24 | 136 | | request.Method = RequestMethod.Patch; |
| 24 | 137 | | var uri = new RawRequestUriBuilder(); |
| 24 | 138 | | uri.Reset(endpoint); |
| 24 | 139 | | uri.AppendPath("/subscriptions/", false); |
| 24 | 140 | | uri.AppendPath(subscriptionId, true); |
| 24 | 141 | | uri.AppendPath("/resourceGroups/", false); |
| 24 | 142 | | uri.AppendPath(resourceGroupName, true); |
| 24 | 143 | | uri.AppendPath("/providers/Microsoft.Compute/disks/", false); |
| 24 | 144 | | uri.AppendPath(diskName, true); |
| 24 | 145 | | uri.AppendQuery("api-version", "2019-11-01", true); |
| 24 | 146 | | request.Uri = uri; |
| 24 | 147 | | request.Headers.Add("Content-Type", "application/json"); |
| 24 | 148 | | var content = new Utf8JsonRequestContent(); |
| 24 | 149 | | content.JsonWriter.WriteObjectValue(disk); |
| 24 | 150 | | request.Content = content; |
| 24 | 151 | | return message; |
| | 152 | | } |
| | 153 | |
|
| | 154 | | /// <summary> Updates (patches) a disk. </summary> |
| | 155 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 156 | | /// <param name="diskName"> The name of the managed disk that is being created. The name can't be changed a |
| | 157 | | /// <param name="disk"> Disk object supplied in the body of the Patch disk operation. </param> |
| | 158 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 159 | | public async Task<Response> UpdateAsync(string resourceGroupName, string diskName, DiskUpdate disk, Cancellation |
| | 160 | | { |
| 6 | 161 | | if (resourceGroupName == null) |
| | 162 | | { |
| 0 | 163 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 164 | | } |
| 6 | 165 | | if (diskName == null) |
| | 166 | | { |
| 0 | 167 | | throw new ArgumentNullException(nameof(diskName)); |
| | 168 | | } |
| 6 | 169 | | if (disk == null) |
| | 170 | | { |
| 0 | 171 | | throw new ArgumentNullException(nameof(disk)); |
| | 172 | | } |
| | 173 | |
|
| 6 | 174 | | using var message = CreateUpdateRequest(resourceGroupName, diskName, disk); |
| 6 | 175 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 176 | | switch (message.Response.Status) |
| | 177 | | { |
| | 178 | | case 200: |
| | 179 | | case 202: |
| 6 | 180 | | return message.Response; |
| | 181 | | default: |
| 0 | 182 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 183 | | } |
| 6 | 184 | | } |
| | 185 | |
|
| | 186 | | /// <summary> Updates (patches) a disk. </summary> |
| | 187 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 188 | | /// <param name="diskName"> The name of the managed disk that is being created. The name can't be changed a |
| | 189 | | /// <param name="disk"> Disk object supplied in the body of the Patch disk operation. </param> |
| | 190 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 191 | | public Response Update(string resourceGroupName, string diskName, DiskUpdate disk, CancellationToken cancellatio |
| | 192 | | { |
| 6 | 193 | | if (resourceGroupName == null) |
| | 194 | | { |
| 0 | 195 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 196 | | } |
| 6 | 197 | | if (diskName == null) |
| | 198 | | { |
| 0 | 199 | | throw new ArgumentNullException(nameof(diskName)); |
| | 200 | | } |
| 6 | 201 | | if (disk == null) |
| | 202 | | { |
| 0 | 203 | | throw new ArgumentNullException(nameof(disk)); |
| | 204 | | } |
| | 205 | |
|
| 6 | 206 | | using var message = CreateUpdateRequest(resourceGroupName, diskName, disk); |
| 6 | 207 | | _pipeline.Send(message, cancellationToken); |
| 6 | 208 | | switch (message.Response.Status) |
| | 209 | | { |
| | 210 | | case 200: |
| | 211 | | case 202: |
| 6 | 212 | | return message.Response; |
| | 213 | | default: |
| 0 | 214 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 215 | | } |
| 6 | 216 | | } |
| | 217 | |
|
| | 218 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string diskName) |
| | 219 | | { |
| 80 | 220 | | var message = _pipeline.CreateMessage(); |
| 80 | 221 | | var request = message.Request; |
| 80 | 222 | | request.Method = RequestMethod.Get; |
| 80 | 223 | | var uri = new RawRequestUriBuilder(); |
| 80 | 224 | | uri.Reset(endpoint); |
| 80 | 225 | | uri.AppendPath("/subscriptions/", false); |
| 80 | 226 | | uri.AppendPath(subscriptionId, true); |
| 80 | 227 | | uri.AppendPath("/resourceGroups/", false); |
| 80 | 228 | | uri.AppendPath(resourceGroupName, true); |
| 80 | 229 | | uri.AppendPath("/providers/Microsoft.Compute/disks/", false); |
| 80 | 230 | | uri.AppendPath(diskName, true); |
| 80 | 231 | | uri.AppendQuery("api-version", "2019-11-01", true); |
| 80 | 232 | | request.Uri = uri; |
| 80 | 233 | | return message; |
| | 234 | | } |
| | 235 | |
|
| | 236 | | /// <summary> Gets information about a disk. </summary> |
| | 237 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 238 | | /// <param name="diskName"> The name of the managed disk that is being created. The name can't be changed a |
| | 239 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 240 | | public async Task<Response<Disk>> GetAsync(string resourceGroupName, string diskName, CancellationToken cancella |
| | 241 | | { |
| 40 | 242 | | if (resourceGroupName == null) |
| | 243 | | { |
| 0 | 244 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 245 | | } |
| 40 | 246 | | if (diskName == null) |
| | 247 | | { |
| 0 | 248 | | throw new ArgumentNullException(nameof(diskName)); |
| | 249 | | } |
| | 250 | |
|
| 40 | 251 | | using var message = CreateGetRequest(resourceGroupName, diskName); |
| 40 | 252 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 40 | 253 | | switch (message.Response.Status) |
| | 254 | | { |
| | 255 | | case 200: |
| | 256 | | { |
| 32 | 257 | | Disk value = default; |
| 32 | 258 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 32 | 259 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 260 | | { |
| 0 | 261 | | value = null; |
| | 262 | | } |
| | 263 | | else |
| | 264 | | { |
| 32 | 265 | | value = Disk.DeserializeDisk(document.RootElement); |
| | 266 | | } |
| 32 | 267 | | return Response.FromValue(value, message.Response); |
| | 268 | | } |
| | 269 | | default: |
| 8 | 270 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 271 | | } |
| 32 | 272 | | } |
| | 273 | |
|
| | 274 | | /// <summary> Gets information about a disk. </summary> |
| | 275 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 276 | | /// <param name="diskName"> The name of the managed disk that is being created. The name can't be changed a |
| | 277 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 278 | | public Response<Disk> Get(string resourceGroupName, string diskName, CancellationToken cancellationToken = defau |
| | 279 | | { |
| 40 | 280 | | if (resourceGroupName == null) |
| | 281 | | { |
| 0 | 282 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 283 | | } |
| 40 | 284 | | if (diskName == null) |
| | 285 | | { |
| 0 | 286 | | throw new ArgumentNullException(nameof(diskName)); |
| | 287 | | } |
| | 288 | |
|
| 40 | 289 | | using var message = CreateGetRequest(resourceGroupName, diskName); |
| 40 | 290 | | _pipeline.Send(message, cancellationToken); |
| 40 | 291 | | switch (message.Response.Status) |
| | 292 | | { |
| | 293 | | case 200: |
| | 294 | | { |
| 32 | 295 | | Disk value = default; |
| 32 | 296 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 32 | 297 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 298 | | { |
| 0 | 299 | | value = null; |
| | 300 | | } |
| | 301 | | else |
| | 302 | | { |
| 32 | 303 | | value = Disk.DeserializeDisk(document.RootElement); |
| | 304 | | } |
| 32 | 305 | | return Response.FromValue(value, message.Response); |
| | 306 | | } |
| | 307 | | default: |
| 8 | 308 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 309 | | } |
| 32 | 310 | | } |
| | 311 | |
|
| | 312 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string diskName) |
| | 313 | | { |
| 72 | 314 | | var message = _pipeline.CreateMessage(); |
| 72 | 315 | | var request = message.Request; |
| 72 | 316 | | request.Method = RequestMethod.Delete; |
| 72 | 317 | | var uri = new RawRequestUriBuilder(); |
| 72 | 318 | | uri.Reset(endpoint); |
| 72 | 319 | | uri.AppendPath("/subscriptions/", false); |
| 72 | 320 | | uri.AppendPath(subscriptionId, true); |
| 72 | 321 | | uri.AppendPath("/resourceGroups/", false); |
| 72 | 322 | | uri.AppendPath(resourceGroupName, true); |
| 72 | 323 | | uri.AppendPath("/providers/Microsoft.Compute/disks/", false); |
| 72 | 324 | | uri.AppendPath(diskName, true); |
| 72 | 325 | | uri.AppendQuery("api-version", "2019-11-01", true); |
| 72 | 326 | | request.Uri = uri; |
| 72 | 327 | | return message; |
| | 328 | | } |
| | 329 | |
|
| | 330 | | /// <summary> Deletes a disk. </summary> |
| | 331 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 332 | | /// <param name="diskName"> The name of the managed disk that is being created. The name can't be changed a |
| | 333 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 334 | | public async Task<Response> DeleteAsync(string resourceGroupName, string diskName, CancellationToken cancellatio |
| | 335 | | { |
| 18 | 336 | | if (resourceGroupName == null) |
| | 337 | | { |
| 0 | 338 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 339 | | } |
| 18 | 340 | | if (diskName == null) |
| | 341 | | { |
| 0 | 342 | | throw new ArgumentNullException(nameof(diskName)); |
| | 343 | | } |
| | 344 | |
|
| 18 | 345 | | using var message = CreateDeleteRequest(resourceGroupName, diskName); |
| 18 | 346 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 18 | 347 | | switch (message.Response.Status) |
| | 348 | | { |
| | 349 | | case 200: |
| | 350 | | case 202: |
| | 351 | | case 204: |
| 18 | 352 | | return message.Response; |
| | 353 | | default: |
| 0 | 354 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 355 | | } |
| 18 | 356 | | } |
| | 357 | |
|
| | 358 | | /// <summary> Deletes a disk. </summary> |
| | 359 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 360 | | /// <param name="diskName"> The name of the managed disk that is being created. The name can't be changed a |
| | 361 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 362 | | public Response Delete(string resourceGroupName, string diskName, CancellationToken cancellationToken = default) |
| | 363 | | { |
| 18 | 364 | | if (resourceGroupName == null) |
| | 365 | | { |
| 0 | 366 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 367 | | } |
| 18 | 368 | | if (diskName == null) |
| | 369 | | { |
| 0 | 370 | | throw new ArgumentNullException(nameof(diskName)); |
| | 371 | | } |
| | 372 | |
|
| 18 | 373 | | using var message = CreateDeleteRequest(resourceGroupName, diskName); |
| 18 | 374 | | _pipeline.Send(message, cancellationToken); |
| 18 | 375 | | switch (message.Response.Status) |
| | 376 | | { |
| | 377 | | case 200: |
| | 378 | | case 202: |
| | 379 | | case 204: |
| 18 | 380 | | return message.Response; |
| | 381 | | default: |
| 0 | 382 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 383 | | } |
| 18 | 384 | | } |
| | 385 | |
|
| | 386 | | internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName) |
| | 387 | | { |
| 16 | 388 | | var message = _pipeline.CreateMessage(); |
| 16 | 389 | | var request = message.Request; |
| 16 | 390 | | request.Method = RequestMethod.Get; |
| 16 | 391 | | var uri = new RawRequestUriBuilder(); |
| 16 | 392 | | uri.Reset(endpoint); |
| 16 | 393 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 394 | | uri.AppendPath(subscriptionId, true); |
| 16 | 395 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 396 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 397 | | uri.AppendPath("/providers/Microsoft.Compute/disks", false); |
| 16 | 398 | | uri.AppendQuery("api-version", "2019-11-01", true); |
| 16 | 399 | | request.Uri = uri; |
| 16 | 400 | | return message; |
| | 401 | | } |
| | 402 | |
|
| | 403 | | /// <summary> Lists all the disks under a resource group. </summary> |
| | 404 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 405 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 406 | | public async Task<Response<DiskList>> ListByResourceGroupAsync(string resourceGroupName, CancellationToken cance |
| | 407 | | { |
| 8 | 408 | | if (resourceGroupName == null) |
| | 409 | | { |
| 0 | 410 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 411 | | } |
| | 412 | |
|
| 8 | 413 | | using var message = CreateListByResourceGroupRequest(resourceGroupName); |
| 8 | 414 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 8 | 415 | | switch (message.Response.Status) |
| | 416 | | { |
| | 417 | | case 200: |
| | 418 | | { |
| 8 | 419 | | DiskList value = default; |
| 8 | 420 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 8 | 421 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 422 | | { |
| 0 | 423 | | value = null; |
| | 424 | | } |
| | 425 | | else |
| | 426 | | { |
| 8 | 427 | | value = DiskList.DeserializeDiskList(document.RootElement); |
| | 428 | | } |
| 8 | 429 | | return Response.FromValue(value, message.Response); |
| | 430 | | } |
| | 431 | | default: |
| 0 | 432 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 433 | | } |
| 8 | 434 | | } |
| | 435 | |
|
| | 436 | | /// <summary> Lists all the disks under a resource group. </summary> |
| | 437 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 438 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 439 | | public Response<DiskList> ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken = de |
| | 440 | | { |
| 8 | 441 | | if (resourceGroupName == null) |
| | 442 | | { |
| 0 | 443 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 444 | | } |
| | 445 | |
|
| 8 | 446 | | using var message = CreateListByResourceGroupRequest(resourceGroupName); |
| 8 | 447 | | _pipeline.Send(message, cancellationToken); |
| 8 | 448 | | switch (message.Response.Status) |
| | 449 | | { |
| | 450 | | case 200: |
| | 451 | | { |
| 8 | 452 | | DiskList value = default; |
| 8 | 453 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 8 | 454 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 455 | | { |
| 0 | 456 | | value = null; |
| | 457 | | } |
| | 458 | | else |
| | 459 | | { |
| 8 | 460 | | value = DiskList.DeserializeDiskList(document.RootElement); |
| | 461 | | } |
| 8 | 462 | | return Response.FromValue(value, message.Response); |
| | 463 | | } |
| | 464 | | default: |
| 0 | 465 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 466 | | } |
| 8 | 467 | | } |
| | 468 | |
|
| | 469 | | internal HttpMessage CreateListRequest() |
| | 470 | | { |
| 8 | 471 | | var message = _pipeline.CreateMessage(); |
| 8 | 472 | | var request = message.Request; |
| 8 | 473 | | request.Method = RequestMethod.Get; |
| 8 | 474 | | var uri = new RawRequestUriBuilder(); |
| 8 | 475 | | uri.Reset(endpoint); |
| 8 | 476 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 477 | | uri.AppendPath(subscriptionId, true); |
| 8 | 478 | | uri.AppendPath("/providers/Microsoft.Compute/disks", false); |
| 8 | 479 | | uri.AppendQuery("api-version", "2019-11-01", true); |
| 8 | 480 | | request.Uri = uri; |
| 8 | 481 | | return message; |
| | 482 | | } |
| | 483 | |
|
| | 484 | | /// <summary> Lists all the disks under a subscription. </summary> |
| | 485 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 486 | | public async Task<Response<DiskList>> ListAsync(CancellationToken cancellationToken = default) |
| | 487 | | { |
| 4 | 488 | | using var message = CreateListRequest(); |
| 4 | 489 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 490 | | switch (message.Response.Status) |
| | 491 | | { |
| | 492 | | case 200: |
| | 493 | | { |
| 4 | 494 | | DiskList value = default; |
| 4 | 495 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 496 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 497 | | { |
| 0 | 498 | | value = null; |
| | 499 | | } |
| | 500 | | else |
| | 501 | | { |
| 4 | 502 | | value = DiskList.DeserializeDiskList(document.RootElement); |
| | 503 | | } |
| 4 | 504 | | return Response.FromValue(value, message.Response); |
| | 505 | | } |
| | 506 | | default: |
| 0 | 507 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 508 | | } |
| 4 | 509 | | } |
| | 510 | |
|
| | 511 | | /// <summary> Lists all the disks under a subscription. </summary> |
| | 512 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 513 | | public Response<DiskList> List(CancellationToken cancellationToken = default) |
| | 514 | | { |
| 4 | 515 | | using var message = CreateListRequest(); |
| 4 | 516 | | _pipeline.Send(message, cancellationToken); |
| 4 | 517 | | switch (message.Response.Status) |
| | 518 | | { |
| | 519 | | case 200: |
| | 520 | | { |
| 4 | 521 | | DiskList value = default; |
| 4 | 522 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 523 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 524 | | { |
| 0 | 525 | | value = null; |
| | 526 | | } |
| | 527 | | else |
| | 528 | | { |
| 4 | 529 | | value = DiskList.DeserializeDiskList(document.RootElement); |
| | 530 | | } |
| 4 | 531 | | return Response.FromValue(value, message.Response); |
| | 532 | | } |
| | 533 | | default: |
| 0 | 534 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 535 | | } |
| 4 | 536 | | } |
| | 537 | |
|
| | 538 | | internal HttpMessage CreateGrantAccessRequest(string resourceGroupName, string diskName, GrantAccessData grantAc |
| | 539 | | { |
| 24 | 540 | | var message = _pipeline.CreateMessage(); |
| 24 | 541 | | var request = message.Request; |
| 24 | 542 | | request.Method = RequestMethod.Post; |
| 24 | 543 | | var uri = new RawRequestUriBuilder(); |
| 24 | 544 | | uri.Reset(endpoint); |
| 24 | 545 | | uri.AppendPath("/subscriptions/", false); |
| 24 | 546 | | uri.AppendPath(subscriptionId, true); |
| 24 | 547 | | uri.AppendPath("/resourceGroups/", false); |
| 24 | 548 | | uri.AppendPath(resourceGroupName, true); |
| 24 | 549 | | uri.AppendPath("/providers/Microsoft.Compute/disks/", false); |
| 24 | 550 | | uri.AppendPath(diskName, true); |
| 24 | 551 | | uri.AppendPath("/beginGetAccess", false); |
| 24 | 552 | | uri.AppendQuery("api-version", "2019-11-01", true); |
| 24 | 553 | | request.Uri = uri; |
| 24 | 554 | | request.Headers.Add("Content-Type", "application/json"); |
| 24 | 555 | | var content = new Utf8JsonRequestContent(); |
| 24 | 556 | | content.JsonWriter.WriteObjectValue(grantAccessData); |
| 24 | 557 | | request.Content = content; |
| 24 | 558 | | return message; |
| | 559 | | } |
| | 560 | |
|
| | 561 | | /// <summary> Grants access to a disk. </summary> |
| | 562 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 563 | | /// <param name="diskName"> The name of the managed disk that is being created. The name can't be changed a |
| | 564 | | /// <param name="grantAccessData"> Access data object supplied in the body of the get disk access operation. </p |
| | 565 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 566 | | public async Task<Response> GrantAccessAsync(string resourceGroupName, string diskName, GrantAccessData grantAcc |
| | 567 | | { |
| 6 | 568 | | if (resourceGroupName == null) |
| | 569 | | { |
| 0 | 570 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 571 | | } |
| 6 | 572 | | if (diskName == null) |
| | 573 | | { |
| 0 | 574 | | throw new ArgumentNullException(nameof(diskName)); |
| | 575 | | } |
| 6 | 576 | | if (grantAccessData == null) |
| | 577 | | { |
| 0 | 578 | | throw new ArgumentNullException(nameof(grantAccessData)); |
| | 579 | | } |
| | 580 | |
|
| 6 | 581 | | using var message = CreateGrantAccessRequest(resourceGroupName, diskName, grantAccessData); |
| 6 | 582 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 583 | | switch (message.Response.Status) |
| | 584 | | { |
| | 585 | | case 200: |
| | 586 | | case 202: |
| 6 | 587 | | return message.Response; |
| | 588 | | default: |
| 0 | 589 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 590 | | } |
| 6 | 591 | | } |
| | 592 | |
|
| | 593 | | /// <summary> Grants access to a disk. </summary> |
| | 594 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 595 | | /// <param name="diskName"> The name of the managed disk that is being created. The name can't be changed a |
| | 596 | | /// <param name="grantAccessData"> Access data object supplied in the body of the get disk access operation. </p |
| | 597 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 598 | | public Response GrantAccess(string resourceGroupName, string diskName, GrantAccessData grantAccessData, Cancella |
| | 599 | | { |
| 6 | 600 | | if (resourceGroupName == null) |
| | 601 | | { |
| 0 | 602 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 603 | | } |
| 6 | 604 | | if (diskName == null) |
| | 605 | | { |
| 0 | 606 | | throw new ArgumentNullException(nameof(diskName)); |
| | 607 | | } |
| 6 | 608 | | if (grantAccessData == null) |
| | 609 | | { |
| 0 | 610 | | throw new ArgumentNullException(nameof(grantAccessData)); |
| | 611 | | } |
| | 612 | |
|
| 6 | 613 | | using var message = CreateGrantAccessRequest(resourceGroupName, diskName, grantAccessData); |
| 6 | 614 | | _pipeline.Send(message, cancellationToken); |
| 6 | 615 | | switch (message.Response.Status) |
| | 616 | | { |
| | 617 | | case 200: |
| | 618 | | case 202: |
| 6 | 619 | | return message.Response; |
| | 620 | | default: |
| 0 | 621 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 622 | | } |
| 6 | 623 | | } |
| | 624 | |
|
| | 625 | | internal HttpMessage CreateRevokeAccessRequest(string resourceGroupName, string diskName) |
| | 626 | | { |
| 24 | 627 | | var message = _pipeline.CreateMessage(); |
| 24 | 628 | | var request = message.Request; |
| 24 | 629 | | request.Method = RequestMethod.Post; |
| 24 | 630 | | var uri = new RawRequestUriBuilder(); |
| 24 | 631 | | uri.Reset(endpoint); |
| 24 | 632 | | uri.AppendPath("/subscriptions/", false); |
| 24 | 633 | | uri.AppendPath(subscriptionId, true); |
| 24 | 634 | | uri.AppendPath("/resourceGroups/", false); |
| 24 | 635 | | uri.AppendPath(resourceGroupName, true); |
| 24 | 636 | | uri.AppendPath("/providers/Microsoft.Compute/disks/", false); |
| 24 | 637 | | uri.AppendPath(diskName, true); |
| 24 | 638 | | uri.AppendPath("/endGetAccess", false); |
| 24 | 639 | | uri.AppendQuery("api-version", "2019-11-01", true); |
| 24 | 640 | | request.Uri = uri; |
| 24 | 641 | | return message; |
| | 642 | | } |
| | 643 | |
|
| | 644 | | /// <summary> Revokes access to a disk. </summary> |
| | 645 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 646 | | /// <param name="diskName"> The name of the managed disk that is being created. The name can't be changed a |
| | 647 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 648 | | public async Task<Response> RevokeAccessAsync(string resourceGroupName, string diskName, CancellationToken cance |
| | 649 | | { |
| 6 | 650 | | if (resourceGroupName == null) |
| | 651 | | { |
| 0 | 652 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 653 | | } |
| 6 | 654 | | if (diskName == null) |
| | 655 | | { |
| 0 | 656 | | throw new ArgumentNullException(nameof(diskName)); |
| | 657 | | } |
| | 658 | |
|
| 6 | 659 | | using var message = CreateRevokeAccessRequest(resourceGroupName, diskName); |
| 6 | 660 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 661 | | switch (message.Response.Status) |
| | 662 | | { |
| | 663 | | case 200: |
| | 664 | | case 202: |
| 6 | 665 | | return message.Response; |
| | 666 | | default: |
| 0 | 667 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 668 | | } |
| 6 | 669 | | } |
| | 670 | |
|
| | 671 | | /// <summary> Revokes access to a disk. </summary> |
| | 672 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 673 | | /// <param name="diskName"> The name of the managed disk that is being created. The name can't be changed a |
| | 674 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 675 | | public Response RevokeAccess(string resourceGroupName, string diskName, CancellationToken cancellationToken = de |
| | 676 | | { |
| 6 | 677 | | if (resourceGroupName == null) |
| | 678 | | { |
| 0 | 679 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 680 | | } |
| 6 | 681 | | if (diskName == null) |
| | 682 | | { |
| 0 | 683 | | throw new ArgumentNullException(nameof(diskName)); |
| | 684 | | } |
| | 685 | |
|
| 6 | 686 | | using var message = CreateRevokeAccessRequest(resourceGroupName, diskName); |
| 6 | 687 | | _pipeline.Send(message, cancellationToken); |
| 6 | 688 | | switch (message.Response.Status) |
| | 689 | | { |
| | 690 | | case 200: |
| | 691 | | case 202: |
| 6 | 692 | | return message.Response; |
| | 693 | | default: |
| 0 | 694 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 695 | | } |
| 6 | 696 | | } |
| | 697 | |
|
| | 698 | | internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string resourceGroupName) |
| | 699 | | { |
| 0 | 700 | | var message = _pipeline.CreateMessage(); |
| 0 | 701 | | var request = message.Request; |
| 0 | 702 | | request.Method = RequestMethod.Get; |
| 0 | 703 | | var uri = new RawRequestUriBuilder(); |
| 0 | 704 | | uri.Reset(endpoint); |
| 0 | 705 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 706 | | request.Uri = uri; |
| 0 | 707 | | return message; |
| | 708 | | } |
| | 709 | |
|
| | 710 | | /// <summary> Lists all the disks under a resource group. </summary> |
| | 711 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 712 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 713 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 714 | | public async Task<Response<DiskList>> ListByResourceGroupNextPageAsync(string nextLink, string resourceGroupName |
| | 715 | | { |
| 0 | 716 | | if (nextLink == null) |
| | 717 | | { |
| 0 | 718 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 719 | | } |
| 0 | 720 | | if (resourceGroupName == null) |
| | 721 | | { |
| 0 | 722 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 723 | | } |
| | 724 | |
|
| 0 | 725 | | using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName); |
| 0 | 726 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 727 | | switch (message.Response.Status) |
| | 728 | | { |
| | 729 | | case 200: |
| | 730 | | { |
| 0 | 731 | | DiskList value = default; |
| 0 | 732 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 733 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 734 | | { |
| 0 | 735 | | value = null; |
| | 736 | | } |
| | 737 | | else |
| | 738 | | { |
| 0 | 739 | | value = DiskList.DeserializeDiskList(document.RootElement); |
| | 740 | | } |
| 0 | 741 | | return Response.FromValue(value, message.Response); |
| | 742 | | } |
| | 743 | | default: |
| 0 | 744 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 745 | | } |
| 0 | 746 | | } |
| | 747 | |
|
| | 748 | | /// <summary> Lists all the disks under a resource group. </summary> |
| | 749 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 750 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 751 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 752 | | public Response<DiskList> ListByResourceGroupNextPage(string nextLink, string resourceGroupName, CancellationTok |
| | 753 | | { |
| 0 | 754 | | if (nextLink == null) |
| | 755 | | { |
| 0 | 756 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 757 | | } |
| 0 | 758 | | if (resourceGroupName == null) |
| | 759 | | { |
| 0 | 760 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 761 | | } |
| | 762 | |
|
| 0 | 763 | | using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName); |
| 0 | 764 | | _pipeline.Send(message, cancellationToken); |
| 0 | 765 | | switch (message.Response.Status) |
| | 766 | | { |
| | 767 | | case 200: |
| | 768 | | { |
| 0 | 769 | | DiskList value = default; |
| 0 | 770 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 771 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 772 | | { |
| 0 | 773 | | value = null; |
| | 774 | | } |
| | 775 | | else |
| | 776 | | { |
| 0 | 777 | | value = DiskList.DeserializeDiskList(document.RootElement); |
| | 778 | | } |
| 0 | 779 | | return Response.FromValue(value, message.Response); |
| | 780 | | } |
| | 781 | | default: |
| 0 | 782 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 783 | | } |
| 0 | 784 | | } |
| | 785 | |
|
| | 786 | | internal HttpMessage CreateListNextPageRequest(string nextLink) |
| | 787 | | { |
| 0 | 788 | | var message = _pipeline.CreateMessage(); |
| 0 | 789 | | var request = message.Request; |
| 0 | 790 | | request.Method = RequestMethod.Get; |
| 0 | 791 | | var uri = new RawRequestUriBuilder(); |
| 0 | 792 | | uri.Reset(endpoint); |
| 0 | 793 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 794 | | request.Uri = uri; |
| 0 | 795 | | return message; |
| | 796 | | } |
| | 797 | |
|
| | 798 | | /// <summary> Lists all the disks under a subscription. </summary> |
| | 799 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 800 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 801 | | public async Task<Response<DiskList>> ListNextPageAsync(string nextLink, CancellationToken cancellationToken = d |
| | 802 | | { |
| 0 | 803 | | if (nextLink == null) |
| | 804 | | { |
| 0 | 805 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 806 | | } |
| | 807 | |
|
| 0 | 808 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 809 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 810 | | switch (message.Response.Status) |
| | 811 | | { |
| | 812 | | case 200: |
| | 813 | | { |
| 0 | 814 | | DiskList value = default; |
| 0 | 815 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 816 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 817 | | { |
| 0 | 818 | | value = null; |
| | 819 | | } |
| | 820 | | else |
| | 821 | | { |
| 0 | 822 | | value = DiskList.DeserializeDiskList(document.RootElement); |
| | 823 | | } |
| 0 | 824 | | return Response.FromValue(value, message.Response); |
| | 825 | | } |
| | 826 | | default: |
| 0 | 827 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 828 | | } |
| 0 | 829 | | } |
| | 830 | |
|
| | 831 | | /// <summary> Lists all the disks under a subscription. </summary> |
| | 832 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 833 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 834 | | public Response<DiskList> ListNextPage(string nextLink, CancellationToken cancellationToken = default) |
| | 835 | | { |
| 0 | 836 | | if (nextLink == null) |
| | 837 | | { |
| 0 | 838 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 839 | | } |
| | 840 | |
|
| 0 | 841 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 842 | | _pipeline.Send(message, cancellationToken); |
| 0 | 843 | | switch (message.Response.Status) |
| | 844 | | { |
| | 845 | | case 200: |
| | 846 | | { |
| 0 | 847 | | DiskList value = default; |
| 0 | 848 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 849 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 850 | | { |
| 0 | 851 | | value = null; |
| | 852 | | } |
| | 853 | | else |
| | 854 | | { |
| 0 | 855 | | value = DiskList.DeserializeDiskList(document.RootElement); |
| | 856 | | } |
| 0 | 857 | | return Response.FromValue(value, message.Response); |
| | 858 | | } |
| | 859 | | default: |
| 0 | 860 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 861 | | } |
| 0 | 862 | | } |
| | 863 | | } |
| | 864 | | } |