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