| | 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.KeyVault.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.KeyVault |
| | 17 | | { |
| | 18 | | /// <summary> The service client. </summary> |
| | 19 | | public partial class Operations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 0 | 23 | | internal RestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of Operations for mocking. </summary> |
| 0 | 25 | | protected Operations() |
| | 26 | | { |
| 0 | 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> |
| | 32 | | /// <param name="apiVersion"> Api Version. </param> |
| 0 | 33 | | internal Operations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null, string apiV |
| | 34 | | { |
| 0 | 35 | | RestClient = new RestOperations(clientDiagnostics, pipeline, endpoint, apiVersion); |
| 0 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 37 | | _pipeline = pipeline; |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> Lists all of the available Key Vault Rest API operations. </summary> |
| | 41 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 42 | | public virtual AsyncPageable<Operation> ListAsync(CancellationToken cancellationToken = default) |
| | 43 | | { |
| | 44 | | async Task<Page<Operation>> FirstPageFunc(int? pageSizeHint) |
| | 45 | | { |
| 0 | 46 | | using var scope = _clientDiagnostics.CreateScope("Operations.List"); |
| 0 | 47 | | scope.Start(); |
| | 48 | | try |
| | 49 | | { |
| 0 | 50 | | var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false); |
| 0 | 51 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 52 | | } |
| 0 | 53 | | catch (Exception e) |
| | 54 | | { |
| 0 | 55 | | scope.Failed(e); |
| 0 | 56 | | throw; |
| | 57 | | } |
| 0 | 58 | | } |
| | 59 | | async Task<Page<Operation>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 60 | | { |
| 0 | 61 | | using var scope = _clientDiagnostics.CreateScope("Operations.List"); |
| 0 | 62 | | scope.Start(); |
| | 63 | | try |
| | 64 | | { |
| 0 | 65 | | var response = await RestClient.ListNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false) |
| 0 | 66 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 67 | | } |
| 0 | 68 | | catch (Exception e) |
| | 69 | | { |
| 0 | 70 | | scope.Failed(e); |
| 0 | 71 | | throw; |
| | 72 | | } |
| 0 | 73 | | } |
| 0 | 74 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 75 | | } |
| | 76 | |
|
| | 77 | | /// <summary> Lists all of the available Key Vault Rest API operations. </summary> |
| | 78 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 79 | | public virtual Pageable<Operation> List(CancellationToken cancellationToken = default) |
| | 80 | | { |
| | 81 | | Page<Operation> FirstPageFunc(int? pageSizeHint) |
| | 82 | | { |
| 0 | 83 | | using var scope = _clientDiagnostics.CreateScope("Operations.List"); |
| 0 | 84 | | scope.Start(); |
| | 85 | | try |
| | 86 | | { |
| 0 | 87 | | var response = RestClient.List(cancellationToken); |
| 0 | 88 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 89 | | } |
| 0 | 90 | | catch (Exception e) |
| | 91 | | { |
| 0 | 92 | | scope.Failed(e); |
| 0 | 93 | | throw; |
| | 94 | | } |
| 0 | 95 | | } |
| | 96 | | Page<Operation> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 97 | | { |
| 0 | 98 | | using var scope = _clientDiagnostics.CreateScope("Operations.List"); |
| 0 | 99 | | scope.Start(); |
| | 100 | | try |
| | 101 | | { |
| 0 | 102 | | var response = RestClient.ListNextPage(nextLink, cancellationToken); |
| 0 | 103 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 104 | | } |
| 0 | 105 | | catch (Exception e) |
| | 106 | | { |
| 0 | 107 | | scope.Failed(e); |
| 0 | 108 | | throw; |
| | 109 | | } |
| 0 | 110 | | } |
| 0 | 111 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 112 | | } |
| | 113 | | } |
| | 114 | | } |