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