| | 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 ImagesRestOperations |
| | 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 ImagesRestOperations. </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 ImagesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, U |
| | 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 imageName, Image parameters) |
| | 47 | | { |
| 16 | 48 | | var message = _pipeline.CreateMessage(); |
| 16 | 49 | | var request = message.Request; |
| 16 | 50 | | request.Method = RequestMethod.Put; |
| 16 | 51 | | var uri = new RawRequestUriBuilder(); |
| 16 | 52 | | uri.Reset(endpoint); |
| 16 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 54 | | uri.AppendPath(subscriptionId, true); |
| 16 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 57 | | uri.AppendPath("/providers/Microsoft.Compute/images/", false); |
| 16 | 58 | | uri.AppendPath(imageName, true); |
| 16 | 59 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 16 | 60 | | request.Uri = uri; |
| 16 | 61 | | request.Headers.Add("Content-Type", "application/json"); |
| 16 | 62 | | var content = new Utf8JsonRequestContent(); |
| 16 | 63 | | content.JsonWriter.WriteObjectValue(parameters); |
| 16 | 64 | | request.Content = content; |
| 16 | 65 | | return message; |
| | 66 | | } |
| | 67 | |
|
| | 68 | | /// <summary> Create or update an image. </summary> |
| | 69 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 70 | | /// <param name="imageName"> The name of the image. </param> |
| | 71 | | /// <param name="parameters"> Parameters supplied to the Create Image operation. </param> |
| | 72 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 73 | | public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string imageName, Image parameters, Ca |
| | 74 | | { |
| 4 | 75 | | if (resourceGroupName == null) |
| | 76 | | { |
| 0 | 77 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 78 | | } |
| 4 | 79 | | if (imageName == null) |
| | 80 | | { |
| 0 | 81 | | throw new ArgumentNullException(nameof(imageName)); |
| | 82 | | } |
| 4 | 83 | | if (parameters == null) |
| | 84 | | { |
| 0 | 85 | | throw new ArgumentNullException(nameof(parameters)); |
| | 86 | | } |
| | 87 | |
|
| 4 | 88 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, imageName, parameters); |
| 4 | 89 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 90 | | switch (message.Response.Status) |
| | 91 | | { |
| | 92 | | case 200: |
| | 93 | | case 201: |
| 4 | 94 | | return message.Response; |
| | 95 | | default: |
| 0 | 96 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 97 | | } |
| 4 | 98 | | } |
| | 99 | |
|
| | 100 | | /// <summary> Create or update an image. </summary> |
| | 101 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 102 | | /// <param name="imageName"> The name of the image. </param> |
| | 103 | | /// <param name="parameters"> Parameters supplied to the Create Image operation. </param> |
| | 104 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 105 | | public Response CreateOrUpdate(string resourceGroupName, string imageName, Image parameters, CancellationToken c |
| | 106 | | { |
| 4 | 107 | | if (resourceGroupName == null) |
| | 108 | | { |
| 0 | 109 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 110 | | } |
| 4 | 111 | | if (imageName == null) |
| | 112 | | { |
| 0 | 113 | | throw new ArgumentNullException(nameof(imageName)); |
| | 114 | | } |
| 4 | 115 | | if (parameters == null) |
| | 116 | | { |
| 0 | 117 | | throw new ArgumentNullException(nameof(parameters)); |
| | 118 | | } |
| | 119 | |
|
| 4 | 120 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, imageName, parameters); |
| 4 | 121 | | _pipeline.Send(message, cancellationToken); |
| 4 | 122 | | switch (message.Response.Status) |
| | 123 | | { |
| | 124 | | case 200: |
| | 125 | | case 201: |
| 4 | 126 | | return message.Response; |
| | 127 | | default: |
| 0 | 128 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 129 | | } |
| 4 | 130 | | } |
| | 131 | |
|
| | 132 | | internal HttpMessage CreateUpdateRequest(string resourceGroupName, string imageName, ImageUpdate parameters) |
| | 133 | | { |
| 8 | 134 | | var message = _pipeline.CreateMessage(); |
| 8 | 135 | | var request = message.Request; |
| 8 | 136 | | request.Method = RequestMethod.Patch; |
| 8 | 137 | | var uri = new RawRequestUriBuilder(); |
| 8 | 138 | | uri.Reset(endpoint); |
| 8 | 139 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 140 | | uri.AppendPath(subscriptionId, true); |
| 8 | 141 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 142 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 143 | | uri.AppendPath("/providers/Microsoft.Compute/images/", false); |
| 8 | 144 | | uri.AppendPath(imageName, true); |
| 8 | 145 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 8 | 146 | | request.Uri = uri; |
| 8 | 147 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 148 | | var content = new Utf8JsonRequestContent(); |
| 8 | 149 | | content.JsonWriter.WriteObjectValue(parameters); |
| 8 | 150 | | request.Content = content; |
| 8 | 151 | | return message; |
| | 152 | | } |
| | 153 | |
|
| | 154 | | /// <summary> Update an image. </summary> |
| | 155 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 156 | | /// <param name="imageName"> The name of the image. </param> |
| | 157 | | /// <param name="parameters"> Parameters supplied to the Update Image operation. </param> |
| | 158 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 159 | | public async Task<Response> UpdateAsync(string resourceGroupName, string imageName, ImageUpdate parameters, Canc |
| | 160 | | { |
| 2 | 161 | | if (resourceGroupName == null) |
| | 162 | | { |
| 0 | 163 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 164 | | } |
| 2 | 165 | | if (imageName == null) |
| | 166 | | { |
| 0 | 167 | | throw new ArgumentNullException(nameof(imageName)); |
| | 168 | | } |
| 2 | 169 | | if (parameters == null) |
| | 170 | | { |
| 0 | 171 | | throw new ArgumentNullException(nameof(parameters)); |
| | 172 | | } |
| | 173 | |
|
| 2 | 174 | | using var message = CreateUpdateRequest(resourceGroupName, imageName, parameters); |
| 2 | 175 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 176 | | switch (message.Response.Status) |
| | 177 | | { |
| | 178 | | case 200: |
| | 179 | | case 201: |
| 2 | 180 | | return message.Response; |
| | 181 | | default: |
| 0 | 182 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 183 | | } |
| 2 | 184 | | } |
| | 185 | |
|
| | 186 | | /// <summary> Update an image. </summary> |
| | 187 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 188 | | /// <param name="imageName"> The name of the image. </param> |
| | 189 | | /// <param name="parameters"> Parameters supplied to the Update Image operation. </param> |
| | 190 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 191 | | public Response Update(string resourceGroupName, string imageName, ImageUpdate parameters, CancellationToken can |
| | 192 | | { |
| 2 | 193 | | if (resourceGroupName == null) |
| | 194 | | { |
| 0 | 195 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 196 | | } |
| 2 | 197 | | if (imageName == null) |
| | 198 | | { |
| 0 | 199 | | throw new ArgumentNullException(nameof(imageName)); |
| | 200 | | } |
| 2 | 201 | | if (parameters == null) |
| | 202 | | { |
| 0 | 203 | | throw new ArgumentNullException(nameof(parameters)); |
| | 204 | | } |
| | 205 | |
|
| 2 | 206 | | using var message = CreateUpdateRequest(resourceGroupName, imageName, parameters); |
| 2 | 207 | | _pipeline.Send(message, cancellationToken); |
| 2 | 208 | | switch (message.Response.Status) |
| | 209 | | { |
| | 210 | | case 200: |
| | 211 | | case 201: |
| 2 | 212 | | return message.Response; |
| | 213 | | default: |
| 0 | 214 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 215 | | } |
| 2 | 216 | | } |
| | 217 | |
|
| | 218 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string imageName) |
| | 219 | | { |
| 16 | 220 | | var message = _pipeline.CreateMessage(); |
| 16 | 221 | | var request = message.Request; |
| 16 | 222 | | request.Method = RequestMethod.Delete; |
| 16 | 223 | | var uri = new RawRequestUriBuilder(); |
| 16 | 224 | | uri.Reset(endpoint); |
| 16 | 225 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 226 | | uri.AppendPath(subscriptionId, true); |
| 16 | 227 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 228 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 229 | | uri.AppendPath("/providers/Microsoft.Compute/images/", false); |
| 16 | 230 | | uri.AppendPath(imageName, true); |
| 16 | 231 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 16 | 232 | | request.Uri = uri; |
| 16 | 233 | | return message; |
| | 234 | | } |
| | 235 | |
|
| | 236 | | /// <summary> Deletes an Image. </summary> |
| | 237 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 238 | | /// <param name="imageName"> The name of the image. </param> |
| | 239 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 240 | | public async Task<Response> DeleteAsync(string resourceGroupName, string imageName, CancellationToken cancellati |
| | 241 | | { |
| 4 | 242 | | if (resourceGroupName == null) |
| | 243 | | { |
| 0 | 244 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 245 | | } |
| 4 | 246 | | if (imageName == null) |
| | 247 | | { |
| 0 | 248 | | throw new ArgumentNullException(nameof(imageName)); |
| | 249 | | } |
| | 250 | |
|
| 4 | 251 | | using var message = CreateDeleteRequest(resourceGroupName, imageName); |
| 4 | 252 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 253 | | switch (message.Response.Status) |
| | 254 | | { |
| | 255 | | case 200: |
| | 256 | | case 202: |
| | 257 | | case 204: |
| 4 | 258 | | return message.Response; |
| | 259 | | default: |
| 0 | 260 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 261 | | } |
| 4 | 262 | | } |
| | 263 | |
|
| | 264 | | /// <summary> Deletes an Image. </summary> |
| | 265 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 266 | | /// <param name="imageName"> The name of the image. </param> |
| | 267 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 268 | | public Response Delete(string resourceGroupName, string imageName, CancellationToken cancellationToken = default |
| | 269 | | { |
| 4 | 270 | | if (resourceGroupName == null) |
| | 271 | | { |
| 0 | 272 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 273 | | } |
| 4 | 274 | | if (imageName == null) |
| | 275 | | { |
| 0 | 276 | | throw new ArgumentNullException(nameof(imageName)); |
| | 277 | | } |
| | 278 | |
|
| 4 | 279 | | using var message = CreateDeleteRequest(resourceGroupName, imageName); |
| 4 | 280 | | _pipeline.Send(message, cancellationToken); |
| 4 | 281 | | switch (message.Response.Status) |
| | 282 | | { |
| | 283 | | case 200: |
| | 284 | | case 202: |
| | 285 | | case 204: |
| 4 | 286 | | return message.Response; |
| | 287 | | default: |
| 0 | 288 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 289 | | } |
| 4 | 290 | | } |
| | 291 | |
|
| | 292 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string imageName, string expand) |
| | 293 | | { |
| 12 | 294 | | var message = _pipeline.CreateMessage(); |
| 12 | 295 | | var request = message.Request; |
| 12 | 296 | | request.Method = RequestMethod.Get; |
| 12 | 297 | | var uri = new RawRequestUriBuilder(); |
| 12 | 298 | | uri.Reset(endpoint); |
| 12 | 299 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 300 | | uri.AppendPath(subscriptionId, true); |
| 12 | 301 | | uri.AppendPath("/resourceGroups/", false); |
| 12 | 302 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 303 | | uri.AppendPath("/providers/Microsoft.Compute/images/", false); |
| 12 | 304 | | uri.AppendPath(imageName, true); |
| 12 | 305 | | if (expand != null) |
| | 306 | | { |
| 0 | 307 | | uri.AppendQuery("$expand", expand, true); |
| | 308 | | } |
| 12 | 309 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 12 | 310 | | request.Uri = uri; |
| 12 | 311 | | return message; |
| | 312 | | } |
| | 313 | |
|
| | 314 | | /// <summary> Gets an image. </summary> |
| | 315 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 316 | | /// <param name="imageName"> The name of the image. </param> |
| | 317 | | /// <param name="expand"> The expand expression to apply on the operation. </param> |
| | 318 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 319 | | public async Task<Response<Image>> GetAsync(string resourceGroupName, string imageName, string expand = null, Ca |
| | 320 | | { |
| 6 | 321 | | if (resourceGroupName == null) |
| | 322 | | { |
| 0 | 323 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 324 | | } |
| 6 | 325 | | if (imageName == null) |
| | 326 | | { |
| 0 | 327 | | throw new ArgumentNullException(nameof(imageName)); |
| | 328 | | } |
| | 329 | |
|
| 6 | 330 | | using var message = CreateGetRequest(resourceGroupName, imageName, expand); |
| 6 | 331 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 332 | | switch (message.Response.Status) |
| | 333 | | { |
| | 334 | | case 200: |
| | 335 | | { |
| 6 | 336 | | Image value = default; |
| 6 | 337 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6 | 338 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 339 | | { |
| 0 | 340 | | value = null; |
| | 341 | | } |
| | 342 | | else |
| | 343 | | { |
| 6 | 344 | | value = Image.DeserializeImage(document.RootElement); |
| | 345 | | } |
| 6 | 346 | | return Response.FromValue(value, message.Response); |
| | 347 | | } |
| | 348 | | default: |
| 0 | 349 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 350 | | } |
| 6 | 351 | | } |
| | 352 | |
|
| | 353 | | /// <summary> Gets an image. </summary> |
| | 354 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 355 | | /// <param name="imageName"> The name of the image. </param> |
| | 356 | | /// <param name="expand"> The expand expression to apply on the operation. </param> |
| | 357 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 358 | | public Response<Image> Get(string resourceGroupName, string imageName, string expand = null, CancellationToken c |
| | 359 | | { |
| 6 | 360 | | if (resourceGroupName == null) |
| | 361 | | { |
| 0 | 362 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 363 | | } |
| 6 | 364 | | if (imageName == null) |
| | 365 | | { |
| 0 | 366 | | throw new ArgumentNullException(nameof(imageName)); |
| | 367 | | } |
| | 368 | |
|
| 6 | 369 | | using var message = CreateGetRequest(resourceGroupName, imageName, expand); |
| 6 | 370 | | _pipeline.Send(message, cancellationToken); |
| 6 | 371 | | switch (message.Response.Status) |
| | 372 | | { |
| | 373 | | case 200: |
| | 374 | | { |
| 6 | 375 | | Image value = default; |
| 6 | 376 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6 | 377 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 378 | | { |
| 0 | 379 | | value = null; |
| | 380 | | } |
| | 381 | | else |
| | 382 | | { |
| 6 | 383 | | value = Image.DeserializeImage(document.RootElement); |
| | 384 | | } |
| 6 | 385 | | return Response.FromValue(value, message.Response); |
| | 386 | | } |
| | 387 | | default: |
| 0 | 388 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 389 | | } |
| 6 | 390 | | } |
| | 391 | |
|
| | 392 | | internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName) |
| | 393 | | { |
| 4 | 394 | | var message = _pipeline.CreateMessage(); |
| 4 | 395 | | var request = message.Request; |
| 4 | 396 | | request.Method = RequestMethod.Get; |
| 4 | 397 | | var uri = new RawRequestUriBuilder(); |
| 4 | 398 | | uri.Reset(endpoint); |
| 4 | 399 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 400 | | uri.AppendPath(subscriptionId, true); |
| 4 | 401 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 402 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 403 | | uri.AppendPath("/providers/Microsoft.Compute/images", false); |
| 4 | 404 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 4 | 405 | | request.Uri = uri; |
| 4 | 406 | | return message; |
| | 407 | | } |
| | 408 | |
|
| | 409 | | /// <summary> Gets the list of images under a resource group. </summary> |
| | 410 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 411 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 412 | | public async Task<Response<ImageListResult>> ListByResourceGroupAsync(string resourceGroupName, CancellationToke |
| | 413 | | { |
| 2 | 414 | | if (resourceGroupName == null) |
| | 415 | | { |
| 0 | 416 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 417 | | } |
| | 418 | |
|
| 2 | 419 | | using var message = CreateListByResourceGroupRequest(resourceGroupName); |
| 2 | 420 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 421 | | switch (message.Response.Status) |
| | 422 | | { |
| | 423 | | case 200: |
| | 424 | | { |
| 2 | 425 | | ImageListResult value = default; |
| 2 | 426 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 427 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 428 | | { |
| 0 | 429 | | value = null; |
| | 430 | | } |
| | 431 | | else |
| | 432 | | { |
| 2 | 433 | | value = ImageListResult.DeserializeImageListResult(document.RootElement); |
| | 434 | | } |
| 2 | 435 | | return Response.FromValue(value, message.Response); |
| | 436 | | } |
| | 437 | | default: |
| 0 | 438 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 439 | | } |
| 2 | 440 | | } |
| | 441 | |
|
| | 442 | | /// <summary> Gets the list of images under a resource group. </summary> |
| | 443 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 444 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 445 | | public Response<ImageListResult> ListByResourceGroup(string resourceGroupName, CancellationToken cancellationTok |
| | 446 | | { |
| 2 | 447 | | if (resourceGroupName == null) |
| | 448 | | { |
| 0 | 449 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 450 | | } |
| | 451 | |
|
| 2 | 452 | | using var message = CreateListByResourceGroupRequest(resourceGroupName); |
| 2 | 453 | | _pipeline.Send(message, cancellationToken); |
| 2 | 454 | | switch (message.Response.Status) |
| | 455 | | { |
| | 456 | | case 200: |
| | 457 | | { |
| 2 | 458 | | ImageListResult value = default; |
| 2 | 459 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 460 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 461 | | { |
| 0 | 462 | | value = null; |
| | 463 | | } |
| | 464 | | else |
| | 465 | | { |
| 2 | 466 | | value = ImageListResult.DeserializeImageListResult(document.RootElement); |
| | 467 | | } |
| 2 | 468 | | return Response.FromValue(value, message.Response); |
| | 469 | | } |
| | 470 | | default: |
| 0 | 471 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 472 | | } |
| 2 | 473 | | } |
| | 474 | |
|
| | 475 | | internal HttpMessage CreateListRequest() |
| | 476 | | { |
| 0 | 477 | | var message = _pipeline.CreateMessage(); |
| 0 | 478 | | var request = message.Request; |
| 0 | 479 | | request.Method = RequestMethod.Get; |
| 0 | 480 | | var uri = new RawRequestUriBuilder(); |
| 0 | 481 | | uri.Reset(endpoint); |
| 0 | 482 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 483 | | uri.AppendPath(subscriptionId, true); |
| 0 | 484 | | uri.AppendPath("/providers/Microsoft.Compute/images", false); |
| 0 | 485 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 486 | | request.Uri = uri; |
| 0 | 487 | | return message; |
| | 488 | | } |
| | 489 | |
|
| | 490 | | /// <summary> Gets the list of Images in the subscription. Use nextLink property in the response to get the next |
| | 491 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 492 | | public async Task<Response<ImageListResult>> ListAsync(CancellationToken cancellationToken = default) |
| | 493 | | { |
| 0 | 494 | | using var message = CreateListRequest(); |
| 0 | 495 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 496 | | switch (message.Response.Status) |
| | 497 | | { |
| | 498 | | case 200: |
| | 499 | | { |
| 0 | 500 | | ImageListResult value = default; |
| 0 | 501 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 502 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 503 | | { |
| 0 | 504 | | value = null; |
| | 505 | | } |
| | 506 | | else |
| | 507 | | { |
| 0 | 508 | | value = ImageListResult.DeserializeImageListResult(document.RootElement); |
| | 509 | | } |
| 0 | 510 | | return Response.FromValue(value, message.Response); |
| | 511 | | } |
| | 512 | | default: |
| 0 | 513 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 514 | | } |
| 0 | 515 | | } |
| | 516 | |
|
| | 517 | | /// <summary> Gets the list of Images in the subscription. Use nextLink property in the response to get the next |
| | 518 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 519 | | public Response<ImageListResult> List(CancellationToken cancellationToken = default) |
| | 520 | | { |
| 0 | 521 | | using var message = CreateListRequest(); |
| 0 | 522 | | _pipeline.Send(message, cancellationToken); |
| 0 | 523 | | switch (message.Response.Status) |
| | 524 | | { |
| | 525 | | case 200: |
| | 526 | | { |
| 0 | 527 | | ImageListResult value = default; |
| 0 | 528 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 529 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 530 | | { |
| 0 | 531 | | value = null; |
| | 532 | | } |
| | 533 | | else |
| | 534 | | { |
| 0 | 535 | | value = ImageListResult.DeserializeImageListResult(document.RootElement); |
| | 536 | | } |
| 0 | 537 | | return Response.FromValue(value, message.Response); |
| | 538 | | } |
| | 539 | | default: |
| 0 | 540 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 541 | | } |
| 0 | 542 | | } |
| | 543 | |
|
| | 544 | | internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string resourceGroupName) |
| | 545 | | { |
| 0 | 546 | | var message = _pipeline.CreateMessage(); |
| 0 | 547 | | var request = message.Request; |
| 0 | 548 | | request.Method = RequestMethod.Get; |
| 0 | 549 | | var uri = new RawRequestUriBuilder(); |
| 0 | 550 | | uri.Reset(endpoint); |
| 0 | 551 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 552 | | request.Uri = uri; |
| 0 | 553 | | return message; |
| | 554 | | } |
| | 555 | |
|
| | 556 | | /// <summary> Gets the list of images under a resource group. </summary> |
| | 557 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 558 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 559 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 560 | | public async Task<Response<ImageListResult>> ListByResourceGroupNextPageAsync(string nextLink, string resourceGr |
| | 561 | | { |
| 0 | 562 | | if (nextLink == null) |
| | 563 | | { |
| 0 | 564 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 565 | | } |
| 0 | 566 | | if (resourceGroupName == null) |
| | 567 | | { |
| 0 | 568 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 569 | | } |
| | 570 | |
|
| 0 | 571 | | using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName); |
| 0 | 572 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 573 | | switch (message.Response.Status) |
| | 574 | | { |
| | 575 | | case 200: |
| | 576 | | { |
| 0 | 577 | | ImageListResult value = default; |
| 0 | 578 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 579 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 580 | | { |
| 0 | 581 | | value = null; |
| | 582 | | } |
| | 583 | | else |
| | 584 | | { |
| 0 | 585 | | value = ImageListResult.DeserializeImageListResult(document.RootElement); |
| | 586 | | } |
| 0 | 587 | | return Response.FromValue(value, message.Response); |
| | 588 | | } |
| | 589 | | default: |
| 0 | 590 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 591 | | } |
| 0 | 592 | | } |
| | 593 | |
|
| | 594 | | /// <summary> Gets the list of images under a resource group. </summary> |
| | 595 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 596 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 597 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 598 | | public Response<ImageListResult> ListByResourceGroupNextPage(string nextLink, string resourceGroupName, Cancella |
| | 599 | | { |
| 0 | 600 | | if (nextLink == null) |
| | 601 | | { |
| 0 | 602 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 603 | | } |
| 0 | 604 | | if (resourceGroupName == null) |
| | 605 | | { |
| 0 | 606 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 607 | | } |
| | 608 | |
|
| 0 | 609 | | using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName); |
| 0 | 610 | | _pipeline.Send(message, cancellationToken); |
| 0 | 611 | | switch (message.Response.Status) |
| | 612 | | { |
| | 613 | | case 200: |
| | 614 | | { |
| 0 | 615 | | ImageListResult value = default; |
| 0 | 616 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 617 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 618 | | { |
| 0 | 619 | | value = null; |
| | 620 | | } |
| | 621 | | else |
| | 622 | | { |
| 0 | 623 | | value = ImageListResult.DeserializeImageListResult(document.RootElement); |
| | 624 | | } |
| 0 | 625 | | return Response.FromValue(value, message.Response); |
| | 626 | | } |
| | 627 | | default: |
| 0 | 628 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 629 | | } |
| 0 | 630 | | } |
| | 631 | |
|
| | 632 | | internal HttpMessage CreateListNextPageRequest(string nextLink) |
| | 633 | | { |
| 0 | 634 | | var message = _pipeline.CreateMessage(); |
| 0 | 635 | | var request = message.Request; |
| 0 | 636 | | request.Method = RequestMethod.Get; |
| 0 | 637 | | var uri = new RawRequestUriBuilder(); |
| 0 | 638 | | uri.Reset(endpoint); |
| 0 | 639 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 640 | | request.Uri = uri; |
| 0 | 641 | | return message; |
| | 642 | | } |
| | 643 | |
|
| | 644 | | /// <summary> Gets the list of Images in the subscription. Use nextLink property in the response to get the next |
| | 645 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 646 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 647 | | public async Task<Response<ImageListResult>> ListNextPageAsync(string nextLink, CancellationToken cancellationTo |
| | 648 | | { |
| 0 | 649 | | if (nextLink == null) |
| | 650 | | { |
| 0 | 651 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 652 | | } |
| | 653 | |
|
| 0 | 654 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 655 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 656 | | switch (message.Response.Status) |
| | 657 | | { |
| | 658 | | case 200: |
| | 659 | | { |
| 0 | 660 | | ImageListResult value = default; |
| 0 | 661 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 662 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 663 | | { |
| 0 | 664 | | value = null; |
| | 665 | | } |
| | 666 | | else |
| | 667 | | { |
| 0 | 668 | | value = ImageListResult.DeserializeImageListResult(document.RootElement); |
| | 669 | | } |
| 0 | 670 | | return Response.FromValue(value, message.Response); |
| | 671 | | } |
| | 672 | | default: |
| 0 | 673 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 674 | | } |
| 0 | 675 | | } |
| | 676 | |
|
| | 677 | | /// <summary> Gets the list of Images in the subscription. Use nextLink property in the response to get the next |
| | 678 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 679 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 680 | | public Response<ImageListResult> ListNextPage(string nextLink, CancellationToken cancellationToken = default) |
| | 681 | | { |
| 0 | 682 | | if (nextLink == null) |
| | 683 | | { |
| 0 | 684 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 685 | | } |
| | 686 | |
|
| 0 | 687 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 688 | | _pipeline.Send(message, cancellationToken); |
| 0 | 689 | | switch (message.Response.Status) |
| | 690 | | { |
| | 691 | | case 200: |
| | 692 | | { |
| 0 | 693 | | ImageListResult value = default; |
| 0 | 694 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 695 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 696 | | { |
| 0 | 697 | | value = null; |
| | 698 | | } |
| | 699 | | else |
| | 700 | | { |
| 0 | 701 | | value = ImageListResult.DeserializeImageListResult(document.RootElement); |
| | 702 | | } |
| 0 | 703 | | return Response.FromValue(value, message.Response); |
| | 704 | | } |
| | 705 | | default: |
| 0 | 706 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 707 | | } |
| 0 | 708 | | } |
| | 709 | | } |
| | 710 | | } |