| | 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.Threading; |
| | 10 | | using System.Threading.Tasks; |
| | 11 | | using Azure; |
| | 12 | | using Azure.Core; |
| | 13 | | using Azure.Core.Pipeline; |
| | 14 | | using Azure.ResourceManager.Compute.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.Compute |
| | 17 | | { |
| | 18 | | /// <summary> The Images service client. </summary> |
| | 19 | | public partial class ImagesOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 56 | 23 | | internal ImagesRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of ImagesOperations for mocking. </summary> |
| 396 | 25 | | protected ImagesOperations() |
| | 26 | | { |
| 396 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of ImagesOperations. </summary> |
| | 29 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 30 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 31 | | /// <param name="subscriptionId"> Subscription credentials which uniquely identify Microsoft Azure subscription. |
| | 32 | | /// <param name="endpoint"> server parameter. </param> |
| 396 | 33 | | internal ImagesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri |
| | 34 | | { |
| 396 | 35 | | RestClient = new ImagesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); |
| 396 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 396 | 37 | | _pipeline = pipeline; |
| 396 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> Gets an image. </summary> |
| | 41 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 42 | | /// <param name="imageName"> The name of the image. </param> |
| | 43 | | /// <param name="expand"> The expand expression to apply on the operation. </param> |
| | 44 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 45 | | public virtual async Task<Response<Image>> GetAsync(string resourceGroupName, string imageName, string expand = |
| | 46 | | { |
| 6 | 47 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.Get"); |
| 6 | 48 | | scope.Start(); |
| | 49 | | try |
| | 50 | | { |
| 6 | 51 | | return await RestClient.GetAsync(resourceGroupName, imageName, expand, cancellationToken).ConfigureAwait |
| | 52 | | } |
| 0 | 53 | | catch (Exception e) |
| | 54 | | { |
| 0 | 55 | | scope.Failed(e); |
| 0 | 56 | | throw; |
| | 57 | | } |
| 6 | 58 | | } |
| | 59 | |
|
| | 60 | | /// <summary> Gets an image. </summary> |
| | 61 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 62 | | /// <param name="imageName"> The name of the image. </param> |
| | 63 | | /// <param name="expand"> The expand expression to apply on the operation. </param> |
| | 64 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 65 | | public virtual Response<Image> Get(string resourceGroupName, string imageName, string expand = null, Cancellatio |
| | 66 | | { |
| 6 | 67 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.Get"); |
| 6 | 68 | | scope.Start(); |
| | 69 | | try |
| | 70 | | { |
| 6 | 71 | | return RestClient.Get(resourceGroupName, imageName, expand, cancellationToken); |
| | 72 | | } |
| 0 | 73 | | catch (Exception e) |
| | 74 | | { |
| 0 | 75 | | scope.Failed(e); |
| 0 | 76 | | throw; |
| | 77 | | } |
| 6 | 78 | | } |
| | 79 | |
|
| | 80 | | /// <summary> Gets the list of images under a resource group. </summary> |
| | 81 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 82 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 83 | | public virtual AsyncPageable<Image> ListByResourceGroupAsync(string resourceGroupName, CancellationToken cancell |
| | 84 | | { |
| 2 | 85 | | if (resourceGroupName == null) |
| | 86 | | { |
| 0 | 87 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 88 | | } |
| | 89 | |
|
| | 90 | | async Task<Page<Image>> FirstPageFunc(int? pageSizeHint) |
| | 91 | | { |
| 2 | 92 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.ListByResourceGroup"); |
| 2 | 93 | | scope.Start(); |
| | 94 | | try |
| | 95 | | { |
| 2 | 96 | | var response = await RestClient.ListByResourceGroupAsync(resourceGroupName, cancellationToken).Confi |
| 2 | 97 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 98 | | } |
| 0 | 99 | | catch (Exception e) |
| | 100 | | { |
| 0 | 101 | | scope.Failed(e); |
| 0 | 102 | | throw; |
| | 103 | | } |
| 2 | 104 | | } |
| | 105 | | async Task<Page<Image>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 106 | | { |
| 0 | 107 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.ListByResourceGroup"); |
| 0 | 108 | | scope.Start(); |
| | 109 | | try |
| | 110 | | { |
| 0 | 111 | | var response = await RestClient.ListByResourceGroupNextPageAsync(nextLink, resourceGroupName, cancel |
| 0 | 112 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 113 | | } |
| 0 | 114 | | catch (Exception e) |
| | 115 | | { |
| 0 | 116 | | scope.Failed(e); |
| 0 | 117 | | throw; |
| | 118 | | } |
| 0 | 119 | | } |
| 2 | 120 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 121 | | } |
| | 122 | |
|
| | 123 | | /// <summary> Gets the list of images under a resource group. </summary> |
| | 124 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 125 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 126 | | public virtual Pageable<Image> ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken |
| | 127 | | { |
| 2 | 128 | | if (resourceGroupName == null) |
| | 129 | | { |
| 0 | 130 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 131 | | } |
| | 132 | |
|
| | 133 | | Page<Image> FirstPageFunc(int? pageSizeHint) |
| | 134 | | { |
| 2 | 135 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.ListByResourceGroup"); |
| 2 | 136 | | scope.Start(); |
| | 137 | | try |
| | 138 | | { |
| 2 | 139 | | var response = RestClient.ListByResourceGroup(resourceGroupName, cancellationToken); |
| 2 | 140 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 141 | | } |
| 0 | 142 | | catch (Exception e) |
| | 143 | | { |
| 0 | 144 | | scope.Failed(e); |
| 0 | 145 | | throw; |
| | 146 | | } |
| 2 | 147 | | } |
| | 148 | | Page<Image> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 149 | | { |
| 0 | 150 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.ListByResourceGroup"); |
| 0 | 151 | | scope.Start(); |
| | 152 | | try |
| | 153 | | { |
| 0 | 154 | | var response = RestClient.ListByResourceGroupNextPage(nextLink, resourceGroupName, cancellationToken |
| 0 | 155 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 156 | | } |
| 0 | 157 | | catch (Exception e) |
| | 158 | | { |
| 0 | 159 | | scope.Failed(e); |
| 0 | 160 | | throw; |
| | 161 | | } |
| 0 | 162 | | } |
| 2 | 163 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 164 | | } |
| | 165 | |
|
| | 166 | | /// <summary> Gets the list of Images in the subscription. Use nextLink property in the response to get the next |
| | 167 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 168 | | public virtual AsyncPageable<Image> ListAsync(CancellationToken cancellationToken = default) |
| | 169 | | { |
| | 170 | | async Task<Page<Image>> FirstPageFunc(int? pageSizeHint) |
| | 171 | | { |
| 0 | 172 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.List"); |
| 0 | 173 | | scope.Start(); |
| | 174 | | try |
| | 175 | | { |
| 0 | 176 | | var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false); |
| 0 | 177 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 178 | | } |
| 0 | 179 | | catch (Exception e) |
| | 180 | | { |
| 0 | 181 | | scope.Failed(e); |
| 0 | 182 | | throw; |
| | 183 | | } |
| 0 | 184 | | } |
| | 185 | | async Task<Page<Image>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 186 | | { |
| 0 | 187 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.List"); |
| 0 | 188 | | scope.Start(); |
| | 189 | | try |
| | 190 | | { |
| 0 | 191 | | var response = await RestClient.ListNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false) |
| 0 | 192 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 193 | | } |
| 0 | 194 | | catch (Exception e) |
| | 195 | | { |
| 0 | 196 | | scope.Failed(e); |
| 0 | 197 | | throw; |
| | 198 | | } |
| 0 | 199 | | } |
| 0 | 200 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 201 | | } |
| | 202 | |
|
| | 203 | | /// <summary> Gets the list of Images in the subscription. Use nextLink property in the response to get the next |
| | 204 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 205 | | public virtual Pageable<Image> List(CancellationToken cancellationToken = default) |
| | 206 | | { |
| | 207 | | Page<Image> FirstPageFunc(int? pageSizeHint) |
| | 208 | | { |
| 0 | 209 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.List"); |
| 0 | 210 | | scope.Start(); |
| | 211 | | try |
| | 212 | | { |
| 0 | 213 | | var response = RestClient.List(cancellationToken); |
| 0 | 214 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 215 | | } |
| 0 | 216 | | catch (Exception e) |
| | 217 | | { |
| 0 | 218 | | scope.Failed(e); |
| 0 | 219 | | throw; |
| | 220 | | } |
| 0 | 221 | | } |
| | 222 | | Page<Image> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 223 | | { |
| 0 | 224 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.List"); |
| 0 | 225 | | scope.Start(); |
| | 226 | | try |
| | 227 | | { |
| 0 | 228 | | var response = RestClient.ListNextPage(nextLink, cancellationToken); |
| 0 | 229 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 230 | | } |
| 0 | 231 | | catch (Exception e) |
| | 232 | | { |
| 0 | 233 | | scope.Failed(e); |
| 0 | 234 | | throw; |
| | 235 | | } |
| 0 | 236 | | } |
| 0 | 237 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 238 | | } |
| | 239 | |
|
| | 240 | | /// <summary> Create or update an image. </summary> |
| | 241 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 242 | | /// <param name="imageName"> The name of the image. </param> |
| | 243 | | /// <param name="parameters"> Parameters supplied to the Create Image operation. </param> |
| | 244 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 245 | | public virtual async Task<ImagesCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resourceGroupName, stri |
| | 246 | | { |
| 4 | 247 | | if (resourceGroupName == null) |
| | 248 | | { |
| 0 | 249 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 250 | | } |
| 4 | 251 | | if (imageName == null) |
| | 252 | | { |
| 0 | 253 | | throw new ArgumentNullException(nameof(imageName)); |
| | 254 | | } |
| 4 | 255 | | if (parameters == null) |
| | 256 | | { |
| 0 | 257 | | throw new ArgumentNullException(nameof(parameters)); |
| | 258 | | } |
| | 259 | |
|
| 4 | 260 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.StartCreateOrUpdate"); |
| 4 | 261 | | scope.Start(); |
| | 262 | | try |
| | 263 | | { |
| 4 | 264 | | var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, imageName, parameters, ca |
| 4 | 265 | | return new ImagesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateR |
| | 266 | | } |
| 0 | 267 | | catch (Exception e) |
| | 268 | | { |
| 0 | 269 | | scope.Failed(e); |
| 0 | 270 | | throw; |
| | 271 | | } |
| 4 | 272 | | } |
| | 273 | |
|
| | 274 | | /// <summary> Create or update an image. </summary> |
| | 275 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 276 | | /// <param name="imageName"> The name of the image. </param> |
| | 277 | | /// <param name="parameters"> Parameters supplied to the Create Image operation. </param> |
| | 278 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 279 | | public virtual ImagesCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string imageName, Ima |
| | 280 | | { |
| 4 | 281 | | if (resourceGroupName == null) |
| | 282 | | { |
| 0 | 283 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 284 | | } |
| 4 | 285 | | if (imageName == null) |
| | 286 | | { |
| 0 | 287 | | throw new ArgumentNullException(nameof(imageName)); |
| | 288 | | } |
| 4 | 289 | | if (parameters == null) |
| | 290 | | { |
| 0 | 291 | | throw new ArgumentNullException(nameof(parameters)); |
| | 292 | | } |
| | 293 | |
|
| 4 | 294 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.StartCreateOrUpdate"); |
| 4 | 295 | | scope.Start(); |
| | 296 | | try |
| | 297 | | { |
| 4 | 298 | | var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, imageName, parameters, cancellationT |
| 4 | 299 | | return new ImagesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateR |
| | 300 | | } |
| 0 | 301 | | catch (Exception e) |
| | 302 | | { |
| 0 | 303 | | scope.Failed(e); |
| 0 | 304 | | throw; |
| | 305 | | } |
| 4 | 306 | | } |
| | 307 | |
|
| | 308 | | /// <summary> Update an image. </summary> |
| | 309 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 310 | | /// <param name="imageName"> The name of the image. </param> |
| | 311 | | /// <param name="parameters"> Parameters supplied to the Update Image operation. </param> |
| | 312 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 313 | | public virtual async Task<ImagesUpdateOperation> StartUpdateAsync(string resourceGroupName, string imageName, Im |
| | 314 | | { |
| 2 | 315 | | if (resourceGroupName == null) |
| | 316 | | { |
| 0 | 317 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 318 | | } |
| 2 | 319 | | if (imageName == null) |
| | 320 | | { |
| 0 | 321 | | throw new ArgumentNullException(nameof(imageName)); |
| | 322 | | } |
| 2 | 323 | | if (parameters == null) |
| | 324 | | { |
| 0 | 325 | | throw new ArgumentNullException(nameof(parameters)); |
| | 326 | | } |
| | 327 | |
|
| 2 | 328 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.StartUpdate"); |
| 2 | 329 | | scope.Start(); |
| | 330 | | try |
| | 331 | | { |
| 2 | 332 | | var originalResponse = await RestClient.UpdateAsync(resourceGroupName, imageName, parameters, cancellati |
| 2 | 333 | | return new ImagesUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateUpdateRequest(resourceG |
| | 334 | | } |
| 0 | 335 | | catch (Exception e) |
| | 336 | | { |
| 0 | 337 | | scope.Failed(e); |
| 0 | 338 | | throw; |
| | 339 | | } |
| 2 | 340 | | } |
| | 341 | |
|
| | 342 | | /// <summary> Update an image. </summary> |
| | 343 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 344 | | /// <param name="imageName"> The name of the image. </param> |
| | 345 | | /// <param name="parameters"> Parameters supplied to the Update Image operation. </param> |
| | 346 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 347 | | public virtual ImagesUpdateOperation StartUpdate(string resourceGroupName, string imageName, ImageUpdate paramet |
| | 348 | | { |
| 2 | 349 | | if (resourceGroupName == null) |
| | 350 | | { |
| 0 | 351 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 352 | | } |
| 2 | 353 | | if (imageName == null) |
| | 354 | | { |
| 0 | 355 | | throw new ArgumentNullException(nameof(imageName)); |
| | 356 | | } |
| 2 | 357 | | if (parameters == null) |
| | 358 | | { |
| 0 | 359 | | throw new ArgumentNullException(nameof(parameters)); |
| | 360 | | } |
| | 361 | |
|
| 2 | 362 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.StartUpdate"); |
| 2 | 363 | | scope.Start(); |
| | 364 | | try |
| | 365 | | { |
| 2 | 366 | | var originalResponse = RestClient.Update(resourceGroupName, imageName, parameters, cancellationToken); |
| 2 | 367 | | return new ImagesUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateUpdateRequest(resourceG |
| | 368 | | } |
| 0 | 369 | | catch (Exception e) |
| | 370 | | { |
| 0 | 371 | | scope.Failed(e); |
| 0 | 372 | | throw; |
| | 373 | | } |
| 2 | 374 | | } |
| | 375 | |
|
| | 376 | | /// <summary> Deletes an Image. </summary> |
| | 377 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 378 | | /// <param name="imageName"> The name of the image. </param> |
| | 379 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 380 | | public virtual async Task<ImagesDeleteOperation> StartDeleteAsync(string resourceGroupName, string imageName, Ca |
| | 381 | | { |
| 4 | 382 | | if (resourceGroupName == null) |
| | 383 | | { |
| 0 | 384 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 385 | | } |
| 4 | 386 | | if (imageName == null) |
| | 387 | | { |
| 0 | 388 | | throw new ArgumentNullException(nameof(imageName)); |
| | 389 | | } |
| | 390 | |
|
| 4 | 391 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.StartDelete"); |
| 4 | 392 | | scope.Start(); |
| | 393 | | try |
| | 394 | | { |
| 4 | 395 | | var originalResponse = await RestClient.DeleteAsync(resourceGroupName, imageName, cancellationToken).Con |
| 4 | 396 | | return new ImagesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(resourceG |
| | 397 | | } |
| 0 | 398 | | catch (Exception e) |
| | 399 | | { |
| 0 | 400 | | scope.Failed(e); |
| 0 | 401 | | throw; |
| | 402 | | } |
| 4 | 403 | | } |
| | 404 | |
|
| | 405 | | /// <summary> Deletes an Image. </summary> |
| | 406 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 407 | | /// <param name="imageName"> The name of the image. </param> |
| | 408 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 409 | | public virtual ImagesDeleteOperation StartDelete(string resourceGroupName, string imageName, CancellationToken c |
| | 410 | | { |
| 4 | 411 | | if (resourceGroupName == null) |
| | 412 | | { |
| 0 | 413 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 414 | | } |
| 4 | 415 | | if (imageName == null) |
| | 416 | | { |
| 0 | 417 | | throw new ArgumentNullException(nameof(imageName)); |
| | 418 | | } |
| | 419 | |
|
| 4 | 420 | | using var scope = _clientDiagnostics.CreateScope("ImagesOperations.StartDelete"); |
| 4 | 421 | | scope.Start(); |
| | 422 | | try |
| | 423 | | { |
| 4 | 424 | | var originalResponse = RestClient.Delete(resourceGroupName, imageName, cancellationToken); |
| 4 | 425 | | return new ImagesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(resourceG |
| | 426 | | } |
| 0 | 427 | | catch (Exception e) |
| | 428 | | { |
| 0 | 429 | | scope.Failed(e); |
| 0 | 430 | | throw; |
| | 431 | | } |
| 4 | 432 | | } |
| | 433 | | } |
| | 434 | | } |