| | 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 service client. </summary> |
| | 19 | | public partial class Operations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 4 | 23 | | internal RestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of Operations for mocking. </summary> |
| 396 | 25 | | protected Operations() |
| | 26 | | { |
| 396 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of Operations. </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="endpoint"> server parameter. </param> |
| 396 | 32 | | internal Operations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null) |
| | 33 | | { |
| 396 | 34 | | RestClient = new RestOperations(clientDiagnostics, pipeline, endpoint); |
| 396 | 35 | | _clientDiagnostics = clientDiagnostics; |
| 396 | 36 | | _pipeline = pipeline; |
| 396 | 37 | | } |
| | 38 | |
|
| | 39 | | /// <summary> Gets a list of compute operations. </summary> |
| | 40 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 41 | | public virtual AsyncPageable<ComputeOperationValue> ListAsync(CancellationToken cancellationToken = default) |
| | 42 | | { |
| | 43 | | async Task<Page<ComputeOperationValue>> FirstPageFunc(int? pageSizeHint) |
| | 44 | | { |
| 2 | 45 | | using var scope = _clientDiagnostics.CreateScope("Operations.List"); |
| 2 | 46 | | scope.Start(); |
| | 47 | | try |
| | 48 | | { |
| 2 | 49 | | var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false); |
| 2 | 50 | | return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); |
| | 51 | | } |
| 0 | 52 | | catch (Exception e) |
| | 53 | | { |
| 0 | 54 | | scope.Failed(e); |
| 0 | 55 | | throw; |
| | 56 | | } |
| 2 | 57 | | } |
| 2 | 58 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); |
| | 59 | | } |
| | 60 | |
|
| | 61 | | /// <summary> Gets a list of compute operations. </summary> |
| | 62 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 63 | | public virtual Pageable<ComputeOperationValue> List(CancellationToken cancellationToken = default) |
| | 64 | | { |
| | 65 | | Page<ComputeOperationValue> FirstPageFunc(int? pageSizeHint) |
| | 66 | | { |
| 2 | 67 | | using var scope = _clientDiagnostics.CreateScope("Operations.List"); |
| 2 | 68 | | scope.Start(); |
| | 69 | | try |
| | 70 | | { |
| 2 | 71 | | var response = RestClient.List(cancellationToken); |
| 2 | 72 | | return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); |
| | 73 | | } |
| 0 | 74 | | catch (Exception e) |
| | 75 | | { |
| 0 | 76 | | scope.Failed(e); |
| 0 | 77 | | throw; |
| | 78 | | } |
| 2 | 79 | | } |
| 2 | 80 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, null); |
| | 81 | | } |
| | 82 | | } |
| | 83 | | } |