| | 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.Storage.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.Storage |
| | 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"> This occurs when one of the required arguments 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.Storage/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 Storage 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 | | { |
| 0 | 69 | | OperationListResult value = default; |
| 0 | 70 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 71 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 72 | | { |
| 0 | 73 | | value = null; |
| | 74 | | } |
| | 75 | | else |
| | 76 | | { |
| 0 | 77 | | value = OperationListResult.DeserializeOperationListResult(document.RootElement); |
| | 78 | | } |
| 0 | 79 | | return Response.FromValue(value, message.Response); |
| | 80 | | } |
| | 81 | | default: |
| 0 | 82 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 83 | | } |
| 0 | 84 | | } |
| | 85 | |
|
| | 86 | | /// <summary> Lists all of the available Storage Rest API operations. </summary> |
| | 87 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 88 | | public Response<OperationListResult> List(CancellationToken cancellationToken = default) |
| | 89 | | { |
| 0 | 90 | | using var message = CreateListRequest(); |
| 0 | 91 | | _pipeline.Send(message, cancellationToken); |
| 0 | 92 | | switch (message.Response.Status) |
| | 93 | | { |
| | 94 | | case 200: |
| | 95 | | { |
| 0 | 96 | | OperationListResult value = default; |
| 0 | 97 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 98 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 99 | | { |
| 0 | 100 | | value = null; |
| | 101 | | } |
| | 102 | | else |
| | 103 | | { |
| 0 | 104 | | value = OperationListResult.DeserializeOperationListResult(document.RootElement); |
| | 105 | | } |
| 0 | 106 | | return Response.FromValue(value, message.Response); |
| | 107 | | } |
| | 108 | | default: |
| 0 | 109 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 110 | | } |
| 0 | 111 | | } |
| | 112 | | } |
| | 113 | | } |