| | | 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.Security.KeyVault.Administration.Models; |
| | | 16 | | |
| | | 17 | | namespace Azure.Security.KeyVault.Administration |
| | | 18 | | { |
| | | 19 | | internal partial class RoleDefinitionsRestClient |
| | | 20 | | { |
| | | 21 | | private string apiVersion; |
| | | 22 | | private ClientDiagnostics _clientDiagnostics; |
| | | 23 | | private HttpPipeline _pipeline; |
| | | 24 | | |
| | | 25 | | /// <summary> Initializes a new instance of RoleDefinitionsRestClient. </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="apiVersion"> Api Version. </param> |
| | | 29 | | /// <exception cref="ArgumentNullException"> <paramref name="apiVersion"/> is null. </exception> |
| | 42 | 30 | | public RoleDefinitionsRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string apiVersion = |
| | | 31 | | { |
| | 42 | 32 | | if (apiVersion == null) |
| | | 33 | | { |
| | 0 | 34 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | | 35 | | } |
| | | 36 | | |
| | 42 | 37 | | this.apiVersion = apiVersion; |
| | 42 | 38 | | _clientDiagnostics = clientDiagnostics; |
| | 42 | 39 | | _pipeline = pipeline; |
| | 42 | 40 | | } |
| | | 41 | | |
| | | 42 | | internal HttpMessage CreateListRequest(string vaultBaseUrl, string scope, string filter) |
| | | 43 | | { |
| | 34 | 44 | | var message = _pipeline.CreateMessage(); |
| | 34 | 45 | | var request = message.Request; |
| | 34 | 46 | | request.Method = RequestMethod.Get; |
| | 34 | 47 | | var uri = new RawRequestUriBuilder(); |
| | 34 | 48 | | uri.AppendRaw(vaultBaseUrl, false); |
| | 34 | 49 | | uri.AppendPath("/", false); |
| | 34 | 50 | | uri.AppendPath(scope, false); |
| | 34 | 51 | | uri.AppendPath("/providers/Microsoft.Authorization/roleDefinitions", false); |
| | 34 | 52 | | if (filter != null) |
| | | 53 | | { |
| | 0 | 54 | | uri.AppendQuery("$filter", filter, true); |
| | | 55 | | } |
| | 34 | 56 | | uri.AppendQuery("api-version", apiVersion, true); |
| | 34 | 57 | | request.Uri = uri; |
| | 34 | 58 | | return message; |
| | | 59 | | } |
| | | 60 | | |
| | | 61 | | /// <summary> Get all role definitions that are applicable at scope and above. </summary> |
| | | 62 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | | 63 | | /// <param name="scope"> The scope of the role definition. </param> |
| | | 64 | | /// <param name="filter"> The filter to apply on the operation. Use atScopeAndBelow filter to search below the g |
| | | 65 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 66 | | /// <exception cref="ArgumentNullException"> <paramref name="vaultBaseUrl"/> or <paramref name="scope"/> is null |
| | | 67 | | public async Task<Response<RoleDefinitionListResult>> ListAsync(string vaultBaseUrl, string scope, string filter |
| | | 68 | | { |
| | 16 | 69 | | if (vaultBaseUrl == null) |
| | | 70 | | { |
| | 0 | 71 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | | 72 | | } |
| | 16 | 73 | | if (scope == null) |
| | | 74 | | { |
| | 0 | 75 | | throw new ArgumentNullException(nameof(scope)); |
| | | 76 | | } |
| | | 77 | | |
| | 16 | 78 | | using var message = CreateListRequest(vaultBaseUrl, scope, filter); |
| | 16 | 79 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 16 | 80 | | switch (message.Response.Status) |
| | | 81 | | { |
| | | 82 | | case 200: |
| | | 83 | | { |
| | | 84 | | RoleDefinitionListResult value = default; |
| | 16 | 85 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 16 | 86 | | value = RoleDefinitionListResult.DeserializeRoleDefinitionListResult(document.RootElement); |
| | 16 | 87 | | return Response.FromValue(value, message.Response); |
| | | 88 | | } |
| | | 89 | | default: |
| | 0 | 90 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 91 | | } |
| | 16 | 92 | | } |
| | | 93 | | |
| | | 94 | | /// <summary> Get all role definitions that are applicable at scope and above. </summary> |
| | | 95 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | | 96 | | /// <param name="scope"> The scope of the role definition. </param> |
| | | 97 | | /// <param name="filter"> The filter to apply on the operation. Use atScopeAndBelow filter to search below the g |
| | | 98 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 99 | | /// <exception cref="ArgumentNullException"> <paramref name="vaultBaseUrl"/> or <paramref name="scope"/> is null |
| | | 100 | | public Response<RoleDefinitionListResult> List(string vaultBaseUrl, string scope, string filter = null, Cancella |
| | | 101 | | { |
| | 18 | 102 | | if (vaultBaseUrl == null) |
| | | 103 | | { |
| | 0 | 104 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | | 105 | | } |
| | 18 | 106 | | if (scope == null) |
| | | 107 | | { |
| | 0 | 108 | | throw new ArgumentNullException(nameof(scope)); |
| | | 109 | | } |
| | | 110 | | |
| | 18 | 111 | | using var message = CreateListRequest(vaultBaseUrl, scope, filter); |
| | 18 | 112 | | _pipeline.Send(message, cancellationToken); |
| | 18 | 113 | | switch (message.Response.Status) |
| | | 114 | | { |
| | | 115 | | case 200: |
| | | 116 | | { |
| | | 117 | | RoleDefinitionListResult value = default; |
| | 18 | 118 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 18 | 119 | | value = RoleDefinitionListResult.DeserializeRoleDefinitionListResult(document.RootElement); |
| | 18 | 120 | | return Response.FromValue(value, message.Response); |
| | | 121 | | } |
| | | 122 | | default: |
| | 0 | 123 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 124 | | } |
| | 18 | 125 | | } |
| | | 126 | | |
| | | 127 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string vaultBaseUrl, string scope, string filter |
| | | 128 | | { |
| | 0 | 129 | | var message = _pipeline.CreateMessage(); |
| | 0 | 130 | | var request = message.Request; |
| | 0 | 131 | | request.Method = RequestMethod.Get; |
| | 0 | 132 | | var uri = new RawRequestUriBuilder(); |
| | 0 | 133 | | uri.AppendRaw(vaultBaseUrl, false); |
| | 0 | 134 | | uri.AppendRawNextLink(nextLink, false); |
| | 0 | 135 | | request.Uri = uri; |
| | 0 | 136 | | return message; |
| | | 137 | | } |
| | | 138 | | |
| | | 139 | | /// <summary> Get all role definitions that are applicable at scope and above. </summary> |
| | | 140 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | | 141 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | | 142 | | /// <param name="scope"> The scope of the role definition. </param> |
| | | 143 | | /// <param name="filter"> The filter to apply on the operation. Use atScopeAndBelow filter to search below the g |
| | | 144 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 145 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/>, <paramref name="vaultBaseUrl"/>, or <p |
| | | 146 | | public async Task<Response<RoleDefinitionListResult>> ListNextPageAsync(string nextLink, string vaultBaseUrl, st |
| | | 147 | | { |
| | 0 | 148 | | if (nextLink == null) |
| | | 149 | | { |
| | 0 | 150 | | throw new ArgumentNullException(nameof(nextLink)); |
| | | 151 | | } |
| | 0 | 152 | | if (vaultBaseUrl == null) |
| | | 153 | | { |
| | 0 | 154 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | | 155 | | } |
| | 0 | 156 | | if (scope == null) |
| | | 157 | | { |
| | 0 | 158 | | throw new ArgumentNullException(nameof(scope)); |
| | | 159 | | } |
| | | 160 | | |
| | 0 | 161 | | using var message = CreateListNextPageRequest(nextLink, vaultBaseUrl, scope, filter); |
| | 0 | 162 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 0 | 163 | | switch (message.Response.Status) |
| | | 164 | | { |
| | | 165 | | case 200: |
| | | 166 | | { |
| | | 167 | | RoleDefinitionListResult value = default; |
| | 0 | 168 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 0 | 169 | | value = RoleDefinitionListResult.DeserializeRoleDefinitionListResult(document.RootElement); |
| | 0 | 170 | | return Response.FromValue(value, message.Response); |
| | | 171 | | } |
| | | 172 | | default: |
| | 0 | 173 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 174 | | } |
| | 0 | 175 | | } |
| | | 176 | | |
| | | 177 | | /// <summary> Get all role definitions that are applicable at scope and above. </summary> |
| | | 178 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | | 179 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | | 180 | | /// <param name="scope"> The scope of the role definition. </param> |
| | | 181 | | /// <param name="filter"> The filter to apply on the operation. Use atScopeAndBelow filter to search below the g |
| | | 182 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 183 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/>, <paramref name="vaultBaseUrl"/>, or <p |
| | | 184 | | public Response<RoleDefinitionListResult> ListNextPage(string nextLink, string vaultBaseUrl, string scope, strin |
| | | 185 | | { |
| | 0 | 186 | | if (nextLink == null) |
| | | 187 | | { |
| | 0 | 188 | | throw new ArgumentNullException(nameof(nextLink)); |
| | | 189 | | } |
| | 0 | 190 | | if (vaultBaseUrl == null) |
| | | 191 | | { |
| | 0 | 192 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | | 193 | | } |
| | 0 | 194 | | if (scope == null) |
| | | 195 | | { |
| | 0 | 196 | | throw new ArgumentNullException(nameof(scope)); |
| | | 197 | | } |
| | | 198 | | |
| | 0 | 199 | | using var message = CreateListNextPageRequest(nextLink, vaultBaseUrl, scope, filter); |
| | 0 | 200 | | _pipeline.Send(message, cancellationToken); |
| | 0 | 201 | | switch (message.Response.Status) |
| | | 202 | | { |
| | | 203 | | case 200: |
| | | 204 | | { |
| | | 205 | | RoleDefinitionListResult value = default; |
| | 0 | 206 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 0 | 207 | | value = RoleDefinitionListResult.DeserializeRoleDefinitionListResult(document.RootElement); |
| | 0 | 208 | | return Response.FromValue(value, message.Response); |
| | | 209 | | } |
| | | 210 | | default: |
| | 0 | 211 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 212 | | } |
| | 0 | 213 | | } |
| | | 214 | | } |
| | | 215 | | } |