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