| | 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.KeyVault.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.KeyVault |
| | 18 | | { |
| | 19 | | internal partial class RestOperations |
| | 20 | | { |
| | 21 | | private Uri endpoint; |
| | 22 | | private string apiVersion; |
| | 23 | | private ClientDiagnostics _clientDiagnostics; |
| | 24 | | private HttpPipeline _pipeline; |
| | 25 | |
|
| | 26 | | /// <summary> Initializes a new instance of RestOperations. </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="endpoint"> server parameter. </param> |
| | 30 | | /// <param name="apiVersion"> Api Version. </param> |
| | 31 | | /// <exception cref="ArgumentNullException"> <paramref name="apiVersion"/> is null. </exception> |
| 0 | 32 | | public RestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null, string ap |
| | 33 | | { |
| 0 | 34 | | endpoint ??= new Uri("https://management.azure.com"); |
| 0 | 35 | | if (apiVersion == null) |
| | 36 | | { |
| 0 | 37 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 38 | | } |
| | 39 | |
|
| 0 | 40 | | this.endpoint = endpoint; |
| 0 | 41 | | this.apiVersion = apiVersion; |
| 0 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 43 | | _pipeline = pipeline; |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateListRequest() |
| | 47 | | { |
| 0 | 48 | | var message = _pipeline.CreateMessage(); |
| 0 | 49 | | var request = message.Request; |
| 0 | 50 | | request.Method = RequestMethod.Get; |
| 0 | 51 | | var uri = new RawRequestUriBuilder(); |
| 0 | 52 | | uri.Reset(endpoint); |
| 0 | 53 | | uri.AppendPath("/providers/Microsoft.KeyVault/operations", false); |
| 0 | 54 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 55 | | request.Uri = uri; |
| 0 | 56 | | return message; |
| | 57 | | } |
| | 58 | |
|
| | 59 | | /// <summary> Lists all of the available Key Vault Rest API operations. </summary> |
| | 60 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 61 | | public async Task<Response<OperationListResult>> ListAsync(CancellationToken cancellationToken = default) |
| | 62 | | { |
| 0 | 63 | | using var message = CreateListRequest(); |
| 0 | 64 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 65 | | switch (message.Response.Status) |
| | 66 | | { |
| | 67 | | case 200: |
| | 68 | | { |
| | 69 | | OperationListResult value = default; |
| 0 | 70 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 71 | | value = OperationListResult.DeserializeOperationListResult(document.RootElement); |
| 0 | 72 | | return Response.FromValue(value, message.Response); |
| | 73 | | } |
| | 74 | | default: |
| 0 | 75 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 76 | | } |
| 0 | 77 | | } |
| | 78 | |
|
| | 79 | | /// <summary> Lists all of the available Key Vault Rest API operations. </summary> |
| | 80 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 81 | | public Response<OperationListResult> List(CancellationToken cancellationToken = default) |
| | 82 | | { |
| 0 | 83 | | using var message = CreateListRequest(); |
| 0 | 84 | | _pipeline.Send(message, cancellationToken); |
| 0 | 85 | | switch (message.Response.Status) |
| | 86 | | { |
| | 87 | | case 200: |
| | 88 | | { |
| | 89 | | OperationListResult value = default; |
| 0 | 90 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 91 | | value = OperationListResult.DeserializeOperationListResult(document.RootElement); |
| 0 | 92 | | return Response.FromValue(value, message.Response); |
| | 93 | | } |
| | 94 | | default: |
| 0 | 95 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 96 | | } |
| 0 | 97 | | } |
| | 98 | |
|
| | 99 | | internal HttpMessage CreateListNextPageRequest(string nextLink) |
| | 100 | | { |
| 0 | 101 | | var message = _pipeline.CreateMessage(); |
| 0 | 102 | | var request = message.Request; |
| 0 | 103 | | request.Method = RequestMethod.Get; |
| 0 | 104 | | var uri = new RawRequestUriBuilder(); |
| 0 | 105 | | uri.Reset(endpoint); |
| 0 | 106 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 107 | | request.Uri = uri; |
| 0 | 108 | | return message; |
| | 109 | | } |
| | 110 | |
|
| | 111 | | /// <summary> Lists all of the available Key Vault Rest API operations. </summary> |
| | 112 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 113 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 114 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception> |
| | 115 | | public async Task<Response<OperationListResult>> ListNextPageAsync(string nextLink, CancellationToken cancellati |
| | 116 | | { |
| 0 | 117 | | if (nextLink == null) |
| | 118 | | { |
| 0 | 119 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 120 | | } |
| | 121 | |
|
| 0 | 122 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 123 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 124 | | switch (message.Response.Status) |
| | 125 | | { |
| | 126 | | case 200: |
| | 127 | | { |
| | 128 | | OperationListResult value = default; |
| 0 | 129 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 130 | | value = OperationListResult.DeserializeOperationListResult(document.RootElement); |
| 0 | 131 | | return Response.FromValue(value, message.Response); |
| | 132 | | } |
| | 133 | | default: |
| 0 | 134 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 135 | | } |
| 0 | 136 | | } |
| | 137 | |
|
| | 138 | | /// <summary> Lists all of the available Key Vault Rest API operations. </summary> |
| | 139 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 140 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 141 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception> |
| | 142 | | public Response<OperationListResult> ListNextPage(string nextLink, CancellationToken cancellationToken = default |
| | 143 | | { |
| 0 | 144 | | if (nextLink == null) |
| | 145 | | { |
| 0 | 146 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 147 | | } |
| | 148 | |
|
| 0 | 149 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 150 | | _pipeline.Send(message, cancellationToken); |
| 0 | 151 | | switch (message.Response.Status) |
| | 152 | | { |
| | 153 | | case 200: |
| | 154 | | { |
| | 155 | | OperationListResult value = default; |
| 0 | 156 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 157 | | value = OperationListResult.DeserializeOperationListResult(document.RootElement); |
| 0 | 158 | | return Response.FromValue(value, message.Response); |
| | 159 | | } |
| | 160 | | default: |
| 0 | 161 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 162 | | } |
| 0 | 163 | | } |
| | 164 | | } |
| | 165 | | } |