| | 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.AppConfiguration.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.AppConfiguration |
| | 18 | | { |
| | 19 | | internal partial class RestOperations |
| | 20 | | { |
| | 21 | | private string subscriptionId; |
| | 22 | | private Uri endpoint; |
| | 23 | | private string apiVersion; |
| | 24 | | private ClientDiagnostics _clientDiagnostics; |
| | 25 | | private HttpPipeline _pipeline; |
| | 26 | |
|
| | 27 | | /// <summary> Initializes a new instance of RestOperations. </summary> |
| | 28 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 29 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 30 | | /// <param name="subscriptionId"> The Microsoft Azure subscription ID. </param> |
| | 31 | | /// <param name="endpoint"> server parameter. </param> |
| | 32 | | /// <param name="apiVersion"> Api Version. </param> |
| | 33 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 8 | 34 | | public RestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri end |
| | 35 | | { |
| 8 | 36 | | if (subscriptionId == null) |
| | 37 | | { |
| 0 | 38 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 39 | | } |
| 8 | 40 | | endpoint ??= new Uri("https://management.azure.com"); |
| 8 | 41 | | if (apiVersion == null) |
| | 42 | | { |
| 0 | 43 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 44 | | } |
| | 45 | |
|
| 8 | 46 | | this.subscriptionId = subscriptionId; |
| 8 | 47 | | this.endpoint = endpoint; |
| 8 | 48 | | this.apiVersion = apiVersion; |
| 8 | 49 | | _clientDiagnostics = clientDiagnostics; |
| 8 | 50 | | _pipeline = pipeline; |
| 8 | 51 | | } |
| | 52 | |
|
| | 53 | | internal HttpMessage CreateCheckNameAvailabilityRequest(CheckNameAvailabilityParameters checkNameAvailabilityPar |
| | 54 | | { |
| 4 | 55 | | var message = _pipeline.CreateMessage(); |
| 4 | 56 | | var request = message.Request; |
| 4 | 57 | | request.Method = RequestMethod.Post; |
| 4 | 58 | | var uri = new RawRequestUriBuilder(); |
| 4 | 59 | | uri.Reset(endpoint); |
| 4 | 60 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 61 | | uri.AppendPath(subscriptionId, true); |
| 4 | 62 | | uri.AppendPath("/providers/Microsoft.AppConfiguration/checkNameAvailability", false); |
| 4 | 63 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 64 | | request.Uri = uri; |
| 4 | 65 | | request.Headers.Add("Content-Type", "application/json"); |
| 4 | 66 | | var content = new Utf8JsonRequestContent(); |
| 4 | 67 | | content.JsonWriter.WriteObjectValue(checkNameAvailabilityParameters); |
| 4 | 68 | | request.Content = content; |
| 4 | 69 | | return message; |
| | 70 | | } |
| | 71 | |
|
| | 72 | | /// <summary> Checks whether the configuration store name is available for use. </summary> |
| | 73 | | /// <param name="checkNameAvailabilityParameters"> The object containing information for the availability reques |
| | 74 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 75 | | public async Task<Response<NameAvailabilityStatus>> CheckNameAvailabilityAsync(CheckNameAvailabilityParameters c |
| | 76 | | { |
| 2 | 77 | | if (checkNameAvailabilityParameters == null) |
| | 78 | | { |
| 0 | 79 | | throw new ArgumentNullException(nameof(checkNameAvailabilityParameters)); |
| | 80 | | } |
| | 81 | |
|
| 2 | 82 | | using var message = CreateCheckNameAvailabilityRequest(checkNameAvailabilityParameters); |
| 2 | 83 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 84 | | switch (message.Response.Status) |
| | 85 | | { |
| | 86 | | case 200: |
| | 87 | | { |
| 2 | 88 | | NameAvailabilityStatus value = default; |
| 2 | 89 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 90 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 91 | | { |
| 0 | 92 | | value = null; |
| | 93 | | } |
| | 94 | | else |
| | 95 | | { |
| 2 | 96 | | value = NameAvailabilityStatus.DeserializeNameAvailabilityStatus(document.RootElement); |
| | 97 | | } |
| 2 | 98 | | return Response.FromValue(value, message.Response); |
| | 99 | | } |
| | 100 | | default: |
| 0 | 101 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 102 | | } |
| 2 | 103 | | } |
| | 104 | |
|
| | 105 | | /// <summary> Checks whether the configuration store name is available for use. </summary> |
| | 106 | | /// <param name="checkNameAvailabilityParameters"> The object containing information for the availability reques |
| | 107 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 108 | | public Response<NameAvailabilityStatus> CheckNameAvailability(CheckNameAvailabilityParameters checkNameAvailabil |
| | 109 | | { |
| 2 | 110 | | if (checkNameAvailabilityParameters == null) |
| | 111 | | { |
| 0 | 112 | | throw new ArgumentNullException(nameof(checkNameAvailabilityParameters)); |
| | 113 | | } |
| | 114 | |
|
| 2 | 115 | | using var message = CreateCheckNameAvailabilityRequest(checkNameAvailabilityParameters); |
| 2 | 116 | | _pipeline.Send(message, cancellationToken); |
| 2 | 117 | | switch (message.Response.Status) |
| | 118 | | { |
| | 119 | | case 200: |
| | 120 | | { |
| 2 | 121 | | NameAvailabilityStatus value = default; |
| 2 | 122 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 123 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 124 | | { |
| 0 | 125 | | value = null; |
| | 126 | | } |
| | 127 | | else |
| | 128 | | { |
| 2 | 129 | | value = NameAvailabilityStatus.DeserializeNameAvailabilityStatus(document.RootElement); |
| | 130 | | } |
| 2 | 131 | | return Response.FromValue(value, message.Response); |
| | 132 | | } |
| | 133 | | default: |
| 0 | 134 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 135 | | } |
| 2 | 136 | | } |
| | 137 | |
|
| | 138 | | internal HttpMessage CreateListRequest(string skipToken) |
| | 139 | | { |
| 4 | 140 | | var message = _pipeline.CreateMessage(); |
| 4 | 141 | | var request = message.Request; |
| 4 | 142 | | request.Method = RequestMethod.Get; |
| 4 | 143 | | var uri = new RawRequestUriBuilder(); |
| 4 | 144 | | uri.Reset(endpoint); |
| 4 | 145 | | uri.AppendPath("/providers/Microsoft.AppConfiguration/operations", false); |
| 4 | 146 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 147 | | if (skipToken != null) |
| | 148 | | { |
| 0 | 149 | | uri.AppendQuery("$skipToken", skipToken, true); |
| | 150 | | } |
| 4 | 151 | | request.Uri = uri; |
| 4 | 152 | | return message; |
| | 153 | | } |
| | 154 | |
|
| | 155 | | /// <summary> Lists the operations available from this provider. </summary> |
| | 156 | | /// <param name="skipToken"> A skip token is used to continue retrieving items after an operation returns a part |
| | 157 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 158 | | public async Task<Response<OperationDefinitionListResult>> ListAsync(string skipToken = null, CancellationToken |
| | 159 | | { |
| 2 | 160 | | using var message = CreateListRequest(skipToken); |
| 2 | 161 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 162 | | switch (message.Response.Status) |
| | 163 | | { |
| | 164 | | case 200: |
| | 165 | | { |
| 2 | 166 | | OperationDefinitionListResult value = default; |
| 2 | 167 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 168 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 169 | | { |
| 0 | 170 | | value = null; |
| | 171 | | } |
| | 172 | | else |
| | 173 | | { |
| 2 | 174 | | value = OperationDefinitionListResult.DeserializeOperationDefinitionListResult(document.Root |
| | 175 | | } |
| 2 | 176 | | return Response.FromValue(value, message.Response); |
| | 177 | | } |
| | 178 | | default: |
| 0 | 179 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 180 | | } |
| 2 | 181 | | } |
| | 182 | |
|
| | 183 | | /// <summary> Lists the operations available from this provider. </summary> |
| | 184 | | /// <param name="skipToken"> A skip token is used to continue retrieving items after an operation returns a part |
| | 185 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 186 | | public Response<OperationDefinitionListResult> List(string skipToken = null, CancellationToken cancellationToken |
| | 187 | | { |
| 2 | 188 | | using var message = CreateListRequest(skipToken); |
| 2 | 189 | | _pipeline.Send(message, cancellationToken); |
| 2 | 190 | | switch (message.Response.Status) |
| | 191 | | { |
| | 192 | | case 200: |
| | 193 | | { |
| 2 | 194 | | OperationDefinitionListResult value = default; |
| 2 | 195 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 196 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 197 | | { |
| 0 | 198 | | value = null; |
| | 199 | | } |
| | 200 | | else |
| | 201 | | { |
| 2 | 202 | | value = OperationDefinitionListResult.DeserializeOperationDefinitionListResult(document.Root |
| | 203 | | } |
| 2 | 204 | | return Response.FromValue(value, message.Response); |
| | 205 | | } |
| | 206 | | default: |
| 0 | 207 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 208 | | } |
| 2 | 209 | | } |
| | 210 | |
|
| | 211 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string skipToken) |
| | 212 | | { |
| 0 | 213 | | var message = _pipeline.CreateMessage(); |
| 0 | 214 | | var request = message.Request; |
| 0 | 215 | | request.Method = RequestMethod.Get; |
| 0 | 216 | | var uri = new RawRequestUriBuilder(); |
| 0 | 217 | | uri.Reset(endpoint); |
| 0 | 218 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 219 | | request.Uri = uri; |
| 0 | 220 | | return message; |
| | 221 | | } |
| | 222 | |
|
| | 223 | | /// <summary> Lists the operations available from this provider. </summary> |
| | 224 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 225 | | /// <param name="skipToken"> A skip token is used to continue retrieving items after an operation returns a part |
| | 226 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 227 | | public async Task<Response<OperationDefinitionListResult>> ListNextPageAsync(string nextLink, string skipToken = |
| | 228 | | { |
| 0 | 229 | | if (nextLink == null) |
| | 230 | | { |
| 0 | 231 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 232 | | } |
| | 233 | |
|
| 0 | 234 | | using var message = CreateListNextPageRequest(nextLink, skipToken); |
| 0 | 235 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 236 | | switch (message.Response.Status) |
| | 237 | | { |
| | 238 | | case 200: |
| | 239 | | { |
| 0 | 240 | | OperationDefinitionListResult value = default; |
| 0 | 241 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 242 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 243 | | { |
| 0 | 244 | | value = null; |
| | 245 | | } |
| | 246 | | else |
| | 247 | | { |
| 0 | 248 | | value = OperationDefinitionListResult.DeserializeOperationDefinitionListResult(document.Root |
| | 249 | | } |
| 0 | 250 | | return Response.FromValue(value, message.Response); |
| | 251 | | } |
| | 252 | | default: |
| 0 | 253 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 254 | | } |
| 0 | 255 | | } |
| | 256 | |
|
| | 257 | | /// <summary> Lists the operations available from this provider. </summary> |
| | 258 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 259 | | /// <param name="skipToken"> A skip token is used to continue retrieving items after an operation returns a part |
| | 260 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 261 | | public Response<OperationDefinitionListResult> ListNextPage(string nextLink, string skipToken = null, Cancellati |
| | 262 | | { |
| 0 | 263 | | if (nextLink == null) |
| | 264 | | { |
| 0 | 265 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 266 | | } |
| | 267 | |
|
| 0 | 268 | | using var message = CreateListNextPageRequest(nextLink, skipToken); |
| 0 | 269 | | _pipeline.Send(message, cancellationToken); |
| 0 | 270 | | switch (message.Response.Status) |
| | 271 | | { |
| | 272 | | case 200: |
| | 273 | | { |
| 0 | 274 | | OperationDefinitionListResult value = default; |
| 0 | 275 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 276 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 277 | | { |
| 0 | 278 | | value = null; |
| | 279 | | } |
| | 280 | | else |
| | 281 | | { |
| 0 | 282 | | value = OperationDefinitionListResult.DeserializeOperationDefinitionListResult(document.Root |
| | 283 | | } |
| 0 | 284 | | return Response.FromValue(value, message.Response); |
| | 285 | | } |
| | 286 | | default: |
| 0 | 287 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 288 | | } |
| 0 | 289 | | } |
| | 290 | | } |
| | 291 | | } |