| | 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.Collections.Generic; |
| | 10 | | using System.Text.Json; |
| | 11 | | using System.Threading; |
| | 12 | | using System.Threading.Tasks; |
| | 13 | | using Azure; |
| | 14 | | using Azure.Core; |
| | 15 | | using Azure.Core.Pipeline; |
| | 16 | | using Azure.ResourceManager.Compute.Models; |
| | 17 | |
|
| | 18 | | namespace Azure.ResourceManager.Compute |
| | 19 | | { |
| | 20 | | internal partial class VirtualMachineExtensionImagesRestOperations |
| | 21 | | { |
| | 22 | | private string subscriptionId; |
| | 23 | | private Uri endpoint; |
| | 24 | | private ClientDiagnostics _clientDiagnostics; |
| | 25 | | private HttpPipeline _pipeline; |
| | 26 | |
|
| | 27 | | /// <summary> Initializes a new instance of VirtualMachineExtensionImagesRestOperations. </summary> |
| | 28 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 29 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 30 | | /// <param name="subscriptionId"> Subscription credentials which uniquely identify Microsoft Azure subscription. |
| | 31 | | /// <param name="endpoint"> server parameter. </param> |
| | 32 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 396 | 33 | | public VirtualMachineExtensionImagesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, s |
| | 34 | | { |
| 396 | 35 | | if (subscriptionId == null) |
| | 36 | | { |
| 0 | 37 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 38 | | } |
| 396 | 39 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 40 | |
|
| 396 | 41 | | this.subscriptionId = subscriptionId; |
| 396 | 42 | | this.endpoint = endpoint; |
| 396 | 43 | | _clientDiagnostics = clientDiagnostics; |
| 396 | 44 | | _pipeline = pipeline; |
| 396 | 45 | | } |
| | 46 | |
|
| | 47 | | internal HttpMessage CreateGetRequest(string location, string publisherName, string type, string version) |
| | 48 | | { |
| 4 | 49 | | var message = _pipeline.CreateMessage(); |
| 4 | 50 | | var request = message.Request; |
| 4 | 51 | | request.Method = RequestMethod.Get; |
| 4 | 52 | | var uri = new RawRequestUriBuilder(); |
| 4 | 53 | | uri.Reset(endpoint); |
| 4 | 54 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 55 | | uri.AppendPath(subscriptionId, true); |
| 4 | 56 | | uri.AppendPath("/providers/Microsoft.Compute/locations/", false); |
| 4 | 57 | | uri.AppendPath(location, true); |
| 4 | 58 | | uri.AppendPath("/publishers/", false); |
| 4 | 59 | | uri.AppendPath(publisherName, true); |
| 4 | 60 | | uri.AppendPath("/artifacttypes/vmextension/types/", false); |
| 4 | 61 | | uri.AppendPath(type, true); |
| 4 | 62 | | uri.AppendPath("/versions/", false); |
| 4 | 63 | | uri.AppendPath(version, true); |
| 4 | 64 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 4 | 65 | | request.Uri = uri; |
| 4 | 66 | | return message; |
| | 67 | | } |
| | 68 | |
|
| | 69 | | /// <summary> Gets a virtual machine extension image. </summary> |
| | 70 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 71 | | /// <param name="publisherName"> The String to use. </param> |
| | 72 | | /// <param name="type"> The String to use. </param> |
| | 73 | | /// <param name="version"> The String to use. </param> |
| | 74 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 75 | | public async Task<Response<VirtualMachineExtensionImage>> GetAsync(string location, string publisherName, string |
| | 76 | | { |
| 2 | 77 | | if (location == null) |
| | 78 | | { |
| 0 | 79 | | throw new ArgumentNullException(nameof(location)); |
| | 80 | | } |
| 2 | 81 | | if (publisherName == null) |
| | 82 | | { |
| 0 | 83 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 84 | | } |
| 2 | 85 | | if (type == null) |
| | 86 | | { |
| 0 | 87 | | throw new ArgumentNullException(nameof(type)); |
| | 88 | | } |
| 2 | 89 | | if (version == null) |
| | 90 | | { |
| 0 | 91 | | throw new ArgumentNullException(nameof(version)); |
| | 92 | | } |
| | 93 | |
|
| 2 | 94 | | using var message = CreateGetRequest(location, publisherName, type, version); |
| 2 | 95 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 96 | | switch (message.Response.Status) |
| | 97 | | { |
| | 98 | | case 200: |
| | 99 | | { |
| 2 | 100 | | VirtualMachineExtensionImage value = default; |
| 2 | 101 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 102 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 103 | | { |
| 0 | 104 | | value = null; |
| | 105 | | } |
| | 106 | | else |
| | 107 | | { |
| 2 | 108 | | value = VirtualMachineExtensionImage.DeserializeVirtualMachineExtensionImage(document.RootEl |
| | 109 | | } |
| 2 | 110 | | return Response.FromValue(value, message.Response); |
| | 111 | | } |
| | 112 | | default: |
| 0 | 113 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 114 | | } |
| 2 | 115 | | } |
| | 116 | |
|
| | 117 | | /// <summary> Gets a virtual machine extension image. </summary> |
| | 118 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 119 | | /// <param name="publisherName"> The String to use. </param> |
| | 120 | | /// <param name="type"> The String to use. </param> |
| | 121 | | /// <param name="version"> The String to use. </param> |
| | 122 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 123 | | public Response<VirtualMachineExtensionImage> Get(string location, string publisherName, string type, string ver |
| | 124 | | { |
| 2 | 125 | | if (location == null) |
| | 126 | | { |
| 0 | 127 | | throw new ArgumentNullException(nameof(location)); |
| | 128 | | } |
| 2 | 129 | | if (publisherName == null) |
| | 130 | | { |
| 0 | 131 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 132 | | } |
| 2 | 133 | | if (type == null) |
| | 134 | | { |
| 0 | 135 | | throw new ArgumentNullException(nameof(type)); |
| | 136 | | } |
| 2 | 137 | | if (version == null) |
| | 138 | | { |
| 0 | 139 | | throw new ArgumentNullException(nameof(version)); |
| | 140 | | } |
| | 141 | |
|
| 2 | 142 | | using var message = CreateGetRequest(location, publisherName, type, version); |
| 2 | 143 | | _pipeline.Send(message, cancellationToken); |
| 2 | 144 | | switch (message.Response.Status) |
| | 145 | | { |
| | 146 | | case 200: |
| | 147 | | { |
| 2 | 148 | | VirtualMachineExtensionImage value = default; |
| 2 | 149 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 150 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 151 | | { |
| 0 | 152 | | value = null; |
| | 153 | | } |
| | 154 | | else |
| | 155 | | { |
| 2 | 156 | | value = VirtualMachineExtensionImage.DeserializeVirtualMachineExtensionImage(document.RootEl |
| | 157 | | } |
| 2 | 158 | | return Response.FromValue(value, message.Response); |
| | 159 | | } |
| | 160 | | default: |
| 0 | 161 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 162 | | } |
| 2 | 163 | | } |
| | 164 | |
|
| | 165 | | internal HttpMessage CreateListTypesRequest(string location, string publisherName) |
| | 166 | | { |
| 4 | 167 | | var message = _pipeline.CreateMessage(); |
| 4 | 168 | | var request = message.Request; |
| 4 | 169 | | request.Method = RequestMethod.Get; |
| 4 | 170 | | var uri = new RawRequestUriBuilder(); |
| 4 | 171 | | uri.Reset(endpoint); |
| 4 | 172 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 173 | | uri.AppendPath(subscriptionId, true); |
| 4 | 174 | | uri.AppendPath("/providers/Microsoft.Compute/locations/", false); |
| 4 | 175 | | uri.AppendPath(location, true); |
| 4 | 176 | | uri.AppendPath("/publishers/", false); |
| 4 | 177 | | uri.AppendPath(publisherName, true); |
| 4 | 178 | | uri.AppendPath("/artifacttypes/vmextension/types", false); |
| 4 | 179 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 4 | 180 | | request.Uri = uri; |
| 4 | 181 | | return message; |
| | 182 | | } |
| | 183 | |
|
| | 184 | | /// <summary> Gets a list of virtual machine extension image types. </summary> |
| | 185 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 186 | | /// <param name="publisherName"> The String to use. </param> |
| | 187 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 188 | | public async Task<Response<IReadOnlyList<VirtualMachineExtensionImage>>> ListTypesAsync(string location, string |
| | 189 | | { |
| 2 | 190 | | if (location == null) |
| | 191 | | { |
| 0 | 192 | | throw new ArgumentNullException(nameof(location)); |
| | 193 | | } |
| 2 | 194 | | if (publisherName == null) |
| | 195 | | { |
| 0 | 196 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 197 | | } |
| | 198 | |
|
| 2 | 199 | | using var message = CreateListTypesRequest(location, publisherName); |
| 2 | 200 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 201 | | switch (message.Response.Status) |
| | 202 | | { |
| | 203 | | case 200: |
| | 204 | | { |
| 2 | 205 | | IReadOnlyList<VirtualMachineExtensionImage> value = default; |
| 2 | 206 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 207 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 208 | | { |
| 0 | 209 | | value = null; |
| | 210 | | } |
| | 211 | | else |
| | 212 | | { |
| 2 | 213 | | List<VirtualMachineExtensionImage> array = new List<VirtualMachineExtensionImage>(); |
| 20 | 214 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 215 | | { |
| 8 | 216 | | if (item.ValueKind == JsonValueKind.Null) |
| | 217 | | { |
| 0 | 218 | | array.Add(null); |
| | 219 | | } |
| | 220 | | else |
| | 221 | | { |
| 8 | 222 | | array.Add(VirtualMachineExtensionImage.DeserializeVirtualMachineExtensionImage(item) |
| | 223 | | } |
| | 224 | | } |
| 2 | 225 | | value = array; |
| | 226 | | } |
| 2 | 227 | | return Response.FromValue(value, message.Response); |
| | 228 | | } |
| | 229 | | default: |
| 0 | 230 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 231 | | } |
| 2 | 232 | | } |
| | 233 | |
|
| | 234 | | /// <summary> Gets a list of virtual machine extension image types. </summary> |
| | 235 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 236 | | /// <param name="publisherName"> The String to use. </param> |
| | 237 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 238 | | public Response<IReadOnlyList<VirtualMachineExtensionImage>> ListTypes(string location, string publisherName, Ca |
| | 239 | | { |
| 2 | 240 | | if (location == null) |
| | 241 | | { |
| 0 | 242 | | throw new ArgumentNullException(nameof(location)); |
| | 243 | | } |
| 2 | 244 | | if (publisherName == null) |
| | 245 | | { |
| 0 | 246 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 247 | | } |
| | 248 | |
|
| 2 | 249 | | using var message = CreateListTypesRequest(location, publisherName); |
| 2 | 250 | | _pipeline.Send(message, cancellationToken); |
| 2 | 251 | | switch (message.Response.Status) |
| | 252 | | { |
| | 253 | | case 200: |
| | 254 | | { |
| 2 | 255 | | IReadOnlyList<VirtualMachineExtensionImage> value = default; |
| 2 | 256 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 257 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 258 | | { |
| 0 | 259 | | value = null; |
| | 260 | | } |
| | 261 | | else |
| | 262 | | { |
| 2 | 263 | | List<VirtualMachineExtensionImage> array = new List<VirtualMachineExtensionImage>(); |
| 20 | 264 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 265 | | { |
| 8 | 266 | | if (item.ValueKind == JsonValueKind.Null) |
| | 267 | | { |
| 0 | 268 | | array.Add(null); |
| | 269 | | } |
| | 270 | | else |
| | 271 | | { |
| 8 | 272 | | array.Add(VirtualMachineExtensionImage.DeserializeVirtualMachineExtensionImage(item) |
| | 273 | | } |
| | 274 | | } |
| 2 | 275 | | value = array; |
| | 276 | | } |
| 2 | 277 | | return Response.FromValue(value, message.Response); |
| | 278 | | } |
| | 279 | | default: |
| 0 | 280 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 281 | | } |
| 2 | 282 | | } |
| | 283 | |
|
| | 284 | | internal HttpMessage CreateListVersionsRequest(string location, string publisherName, string type, string filter |
| | 285 | | { |
| 4 | 286 | | var message = _pipeline.CreateMessage(); |
| 4 | 287 | | var request = message.Request; |
| 4 | 288 | | request.Method = RequestMethod.Get; |
| 4 | 289 | | var uri = new RawRequestUriBuilder(); |
| 4 | 290 | | uri.Reset(endpoint); |
| 4 | 291 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 292 | | uri.AppendPath(subscriptionId, true); |
| 4 | 293 | | uri.AppendPath("/providers/Microsoft.Compute/locations/", false); |
| 4 | 294 | | uri.AppendPath(location, true); |
| 4 | 295 | | uri.AppendPath("/publishers/", false); |
| 4 | 296 | | uri.AppendPath(publisherName, true); |
| 4 | 297 | | uri.AppendPath("/artifacttypes/vmextension/types/", false); |
| 4 | 298 | | uri.AppendPath(type, true); |
| 4 | 299 | | uri.AppendPath("/versions", false); |
| 4 | 300 | | if (filter != null) |
| | 301 | | { |
| 0 | 302 | | uri.AppendQuery("$filter", filter, true); |
| | 303 | | } |
| 4 | 304 | | if (top != null) |
| | 305 | | { |
| 0 | 306 | | uri.AppendQuery("$top", top.Value, true); |
| | 307 | | } |
| 4 | 308 | | if (orderby != null) |
| | 309 | | { |
| 0 | 310 | | uri.AppendQuery("$orderby", orderby, true); |
| | 311 | | } |
| 4 | 312 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 4 | 313 | | request.Uri = uri; |
| 4 | 314 | | return message; |
| | 315 | | } |
| | 316 | |
|
| | 317 | | /// <summary> Gets a list of virtual machine extension image versions. </summary> |
| | 318 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 319 | | /// <param name="publisherName"> The String to use. </param> |
| | 320 | | /// <param name="type"> The String to use. </param> |
| | 321 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 322 | | /// <param name="top"> The Integer to use. </param> |
| | 323 | | /// <param name="orderby"> The String to use. </param> |
| | 324 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 325 | | public async Task<Response<IReadOnlyList<VirtualMachineExtensionImage>>> ListVersionsAsync(string location, stri |
| | 326 | | { |
| 2 | 327 | | if (location == null) |
| | 328 | | { |
| 0 | 329 | | throw new ArgumentNullException(nameof(location)); |
| | 330 | | } |
| 2 | 331 | | if (publisherName == null) |
| | 332 | | { |
| 0 | 333 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 334 | | } |
| 2 | 335 | | if (type == null) |
| | 336 | | { |
| 0 | 337 | | throw new ArgumentNullException(nameof(type)); |
| | 338 | | } |
| | 339 | |
|
| 2 | 340 | | using var message = CreateListVersionsRequest(location, publisherName, type, filter, top, orderby); |
| 2 | 341 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 342 | | switch (message.Response.Status) |
| | 343 | | { |
| | 344 | | case 200: |
| | 345 | | { |
| 2 | 346 | | IReadOnlyList<VirtualMachineExtensionImage> value = default; |
| 2 | 347 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 348 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 349 | | { |
| 0 | 350 | | value = null; |
| | 351 | | } |
| | 352 | | else |
| | 353 | | { |
| 2 | 354 | | List<VirtualMachineExtensionImage> array = new List<VirtualMachineExtensionImage>(); |
| 60 | 355 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 356 | | { |
| 28 | 357 | | if (item.ValueKind == JsonValueKind.Null) |
| | 358 | | { |
| 0 | 359 | | array.Add(null); |
| | 360 | | } |
| | 361 | | else |
| | 362 | | { |
| 28 | 363 | | array.Add(VirtualMachineExtensionImage.DeserializeVirtualMachineExtensionImage(item) |
| | 364 | | } |
| | 365 | | } |
| 2 | 366 | | value = array; |
| | 367 | | } |
| 2 | 368 | | return Response.FromValue(value, message.Response); |
| | 369 | | } |
| | 370 | | default: |
| 0 | 371 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 372 | | } |
| 2 | 373 | | } |
| | 374 | |
|
| | 375 | | /// <summary> Gets a list of virtual machine extension image versions. </summary> |
| | 376 | | /// <param name="location"> The name of a supported Azure region. </param> |
| | 377 | | /// <param name="publisherName"> The String to use. </param> |
| | 378 | | /// <param name="type"> The String to use. </param> |
| | 379 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 380 | | /// <param name="top"> The Integer to use. </param> |
| | 381 | | /// <param name="orderby"> The String to use. </param> |
| | 382 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 383 | | public Response<IReadOnlyList<VirtualMachineExtensionImage>> ListVersions(string location, string publisherName, |
| | 384 | | { |
| 2 | 385 | | if (location == null) |
| | 386 | | { |
| 0 | 387 | | throw new ArgumentNullException(nameof(location)); |
| | 388 | | } |
| 2 | 389 | | if (publisherName == null) |
| | 390 | | { |
| 0 | 391 | | throw new ArgumentNullException(nameof(publisherName)); |
| | 392 | | } |
| 2 | 393 | | if (type == null) |
| | 394 | | { |
| 0 | 395 | | throw new ArgumentNullException(nameof(type)); |
| | 396 | | } |
| | 397 | |
|
| 2 | 398 | | using var message = CreateListVersionsRequest(location, publisherName, type, filter, top, orderby); |
| 2 | 399 | | _pipeline.Send(message, cancellationToken); |
| 2 | 400 | | switch (message.Response.Status) |
| | 401 | | { |
| | 402 | | case 200: |
| | 403 | | { |
| 2 | 404 | | IReadOnlyList<VirtualMachineExtensionImage> value = default; |
| 2 | 405 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 406 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 407 | | { |
| 0 | 408 | | value = null; |
| | 409 | | } |
| | 410 | | else |
| | 411 | | { |
| 2 | 412 | | List<VirtualMachineExtensionImage> array = new List<VirtualMachineExtensionImage>(); |
| 60 | 413 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 414 | | { |
| 28 | 415 | | if (item.ValueKind == JsonValueKind.Null) |
| | 416 | | { |
| 0 | 417 | | array.Add(null); |
| | 418 | | } |
| | 419 | | else |
| | 420 | | { |
| 28 | 421 | | array.Add(VirtualMachineExtensionImage.DeserializeVirtualMachineExtensionImage(item) |
| | 422 | | } |
| | 423 | | } |
| 2 | 424 | | value = array; |
| | 425 | | } |
| 2 | 426 | | return Response.FromValue(value, message.Response); |
| | 427 | | } |
| | 428 | | default: |
| 0 | 429 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 430 | | } |
| 2 | 431 | | } |
| | 432 | | } |
| | 433 | | } |