| | 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.Collections.Generic; |
| | 10 | | using System.Text.Json; |
| | 11 | | using System.Threading; |
| | 12 | | using System.Threading.Tasks; |
| | 13 | | using Azure; |
| | 14 | | using Azure.Analytics.Synapse.AccessControl.Models; |
| | 15 | | using Azure.Core; |
| | 16 | | using Azure.Core.Pipeline; |
| | 17 | |
|
| | 18 | | namespace Azure.Analytics.Synapse.AccessControl |
| | 19 | | { |
| | 20 | | internal partial class AccessControlRestClient |
| | 21 | | { |
| | 22 | | private string endpoint; |
| | 23 | | private string apiVersion; |
| | 24 | | private ClientDiagnostics _clientDiagnostics; |
| | 25 | | private HttpPipeline _pipeline; |
| | 26 | |
|
| | 27 | | /// <summary> Initializes a new instance of AccessControlRestClient. </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="endpoint"> The workspace development endpoint, for example https://myworkspace.dev.azuresynapse |
| | 31 | | /// <param name="apiVersion"> Api Version. </param> |
| | 32 | | /// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="apiVersion"/> is nul |
| 16 | 33 | | public AccessControlRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, stri |
| | 34 | | { |
| 16 | 35 | | if (endpoint == null) |
| | 36 | | { |
| 0 | 37 | | throw new ArgumentNullException(nameof(endpoint)); |
| | 38 | | } |
| 16 | 39 | | if (apiVersion == null) |
| | 40 | | { |
| 0 | 41 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 42 | | } |
| | 43 | |
|
| 16 | 44 | | this.endpoint = endpoint; |
| 16 | 45 | | this.apiVersion = apiVersion; |
| 16 | 46 | | _clientDiagnostics = clientDiagnostics; |
| 16 | 47 | | _pipeline = pipeline; |
| 16 | 48 | | } |
| | 49 | |
|
| | 50 | | internal HttpMessage CreateCreateRoleAssignmentRequest(RoleAssignmentOptions createRoleAssignmentOptions) |
| | 51 | | { |
| 4 | 52 | | var message = _pipeline.CreateMessage(); |
| 4 | 53 | | var request = message.Request; |
| 4 | 54 | | request.Method = RequestMethod.Post; |
| 4 | 55 | | var uri = new RawRequestUriBuilder(); |
| 4 | 56 | | uri.AppendRaw(endpoint, false); |
| 4 | 57 | | uri.AppendPath("/rbac/roleAssignments", false); |
| 4 | 58 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 59 | | request.Uri = uri; |
| 4 | 60 | | request.Headers.Add("Content-Type", "application/json"); |
| 4 | 61 | | var content = new Utf8JsonRequestContent(); |
| 4 | 62 | | content.JsonWriter.WriteObjectValue(createRoleAssignmentOptions); |
| 4 | 63 | | request.Content = content; |
| 4 | 64 | | return message; |
| | 65 | | } |
| | 66 | |
|
| | 67 | | /// <summary> Create role assignment. </summary> |
| | 68 | | /// <param name="createRoleAssignmentOptions"> Details of role id and object id. </param> |
| | 69 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 70 | | /// <exception cref="ArgumentNullException"> <paramref name="createRoleAssignmentOptions"/> is null. </exception |
| | 71 | | public async Task<Response<RoleAssignmentDetails>> CreateRoleAssignmentAsync(RoleAssignmentOptions createRoleAss |
| | 72 | | { |
| 2 | 73 | | if (createRoleAssignmentOptions == null) |
| | 74 | | { |
| 0 | 75 | | throw new ArgumentNullException(nameof(createRoleAssignmentOptions)); |
| | 76 | | } |
| | 77 | |
|
| 2 | 78 | | using var message = CreateCreateRoleAssignmentRequest(createRoleAssignmentOptions); |
| 2 | 79 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 80 | | switch (message.Response.Status) |
| | 81 | | { |
| | 82 | | case 200: |
| | 83 | | { |
| | 84 | | RoleAssignmentDetails value = default; |
| 2 | 85 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 86 | | value = RoleAssignmentDetails.DeserializeRoleAssignmentDetails(document.RootElement); |
| 2 | 87 | | return Response.FromValue(value, message.Response); |
| | 88 | | } |
| | 89 | | default: |
| 0 | 90 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 91 | | } |
| 2 | 92 | | } |
| | 93 | |
|
| | 94 | | /// <summary> Create role assignment. </summary> |
| | 95 | | /// <param name="createRoleAssignmentOptions"> Details of role id and object id. </param> |
| | 96 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 97 | | /// <exception cref="ArgumentNullException"> <paramref name="createRoleAssignmentOptions"/> is null. </exception |
| | 98 | | public Response<RoleAssignmentDetails> CreateRoleAssignment(RoleAssignmentOptions createRoleAssignmentOptions, C |
| | 99 | | { |
| 2 | 100 | | if (createRoleAssignmentOptions == null) |
| | 101 | | { |
| 0 | 102 | | throw new ArgumentNullException(nameof(createRoleAssignmentOptions)); |
| | 103 | | } |
| | 104 | |
|
| 2 | 105 | | using var message = CreateCreateRoleAssignmentRequest(createRoleAssignmentOptions); |
| 2 | 106 | | _pipeline.Send(message, cancellationToken); |
| 2 | 107 | | switch (message.Response.Status) |
| | 108 | | { |
| | 109 | | case 200: |
| | 110 | | { |
| | 111 | | RoleAssignmentDetails value = default; |
| 2 | 112 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 113 | | value = RoleAssignmentDetails.DeserializeRoleAssignmentDetails(document.RootElement); |
| 2 | 114 | | return Response.FromValue(value, message.Response); |
| | 115 | | } |
| | 116 | | default: |
| 0 | 117 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 118 | | } |
| 2 | 119 | | } |
| | 120 | |
|
| | 121 | | internal HttpMessage CreateGetRoleAssignmentsRequest(string roleId, string principalId, string continuationToken |
| | 122 | | { |
| 8 | 123 | | var message = _pipeline.CreateMessage(); |
| 8 | 124 | | var request = message.Request; |
| 8 | 125 | | request.Method = RequestMethod.Get; |
| 8 | 126 | | var uri = new RawRequestUriBuilder(); |
| 8 | 127 | | uri.AppendRaw(endpoint, false); |
| 8 | 128 | | uri.AppendPath("/rbac/roleAssignments", false); |
| 8 | 129 | | uri.AppendQuery("api-version", apiVersion, true); |
| 8 | 130 | | if (roleId != null) |
| | 131 | | { |
| 0 | 132 | | uri.AppendQuery("roleId", roleId, true); |
| | 133 | | } |
| 8 | 134 | | if (principalId != null) |
| | 135 | | { |
| 0 | 136 | | uri.AppendQuery("principalId", principalId, true); |
| | 137 | | } |
| 8 | 138 | | request.Uri = uri; |
| 8 | 139 | | if (continuationToken != null) |
| | 140 | | { |
| 0 | 141 | | request.Headers.Add("x-ms-continuation", continuationToken); |
| | 142 | | } |
| 8 | 143 | | return message; |
| | 144 | | } |
| | 145 | |
|
| | 146 | | /// <summary> List role assignments. </summary> |
| | 147 | | /// <param name="roleId"> Synapse Built-In Role Id. </param> |
| | 148 | | /// <param name="principalId"> Object ID of the AAD principal or security-group. </param> |
| | 149 | | /// <param name="continuationToken"> Continuation token. </param> |
| | 150 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 151 | | public async Task<ResponseWithHeaders<IReadOnlyList<RoleAssignmentDetails>, AccessControlGetRoleAssignmentsHeade |
| | 152 | | { |
| 4 | 153 | | using var message = CreateGetRoleAssignmentsRequest(roleId, principalId, continuationToken); |
| 4 | 154 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 155 | | var headers = new AccessControlGetRoleAssignmentsHeaders(message.Response); |
| 4 | 156 | | switch (message.Response.Status) |
| | 157 | | { |
| | 158 | | case 200: |
| | 159 | | { |
| | 160 | | IReadOnlyList<RoleAssignmentDetails> value = default; |
| 4 | 161 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 162 | | List<RoleAssignmentDetails> array = new List<RoleAssignmentDetails>(); |
| 128 | 163 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 164 | | { |
| 60 | 165 | | array.Add(RoleAssignmentDetails.DeserializeRoleAssignmentDetails(item)); |
| | 166 | | } |
| 4 | 167 | | value = array; |
| 4 | 168 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 169 | | } |
| | 170 | | default: |
| 0 | 171 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 172 | | } |
| 4 | 173 | | } |
| | 174 | |
|
| | 175 | | /// <summary> List role assignments. </summary> |
| | 176 | | /// <param name="roleId"> Synapse Built-In Role Id. </param> |
| | 177 | | /// <param name="principalId"> Object ID of the AAD principal or security-group. </param> |
| | 178 | | /// <param name="continuationToken"> Continuation token. </param> |
| | 179 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 180 | | public ResponseWithHeaders<IReadOnlyList<RoleAssignmentDetails>, AccessControlGetRoleAssignmentsHeaders> GetRole |
| | 181 | | { |
| 4 | 182 | | using var message = CreateGetRoleAssignmentsRequest(roleId, principalId, continuationToken); |
| 4 | 183 | | _pipeline.Send(message, cancellationToken); |
| 4 | 184 | | var headers = new AccessControlGetRoleAssignmentsHeaders(message.Response); |
| 4 | 185 | | switch (message.Response.Status) |
| | 186 | | { |
| | 187 | | case 200: |
| | 188 | | { |
| | 189 | | IReadOnlyList<RoleAssignmentDetails> value = default; |
| 4 | 190 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 191 | | List<RoleAssignmentDetails> array = new List<RoleAssignmentDetails>(); |
| 128 | 192 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 193 | | { |
| 60 | 194 | | array.Add(RoleAssignmentDetails.DeserializeRoleAssignmentDetails(item)); |
| | 195 | | } |
| 4 | 196 | | value = array; |
| 4 | 197 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 198 | | } |
| | 199 | | default: |
| 0 | 200 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 201 | | } |
| 4 | 202 | | } |
| | 203 | |
|
| | 204 | | internal HttpMessage CreateGetRoleAssignmentByIdRequest(string roleAssignmentId) |
| | 205 | | { |
| 60 | 206 | | var message = _pipeline.CreateMessage(); |
| 60 | 207 | | var request = message.Request; |
| 60 | 208 | | request.Method = RequestMethod.Get; |
| 60 | 209 | | var uri = new RawRequestUriBuilder(); |
| 60 | 210 | | uri.AppendRaw(endpoint, false); |
| 60 | 211 | | uri.AppendPath("/rbac/roleAssignments/", false); |
| 60 | 212 | | uri.AppendPath(roleAssignmentId, true); |
| 60 | 213 | | uri.AppendQuery("api-version", apiVersion, true); |
| 60 | 214 | | request.Uri = uri; |
| 60 | 215 | | return message; |
| | 216 | | } |
| | 217 | |
|
| | 218 | | /// <summary> Get role assignment by role assignment Id. </summary> |
| | 219 | | /// <param name="roleAssignmentId"> The ID of the role assignment. </param> |
| | 220 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 221 | | /// <exception cref="ArgumentNullException"> <paramref name="roleAssignmentId"/> is null. </exception> |
| | 222 | | public async Task<Response<RoleAssignmentDetails>> GetRoleAssignmentByIdAsync(string roleAssignmentId, Cancellat |
| | 223 | | { |
| 30 | 224 | | if (roleAssignmentId == null) |
| | 225 | | { |
| 0 | 226 | | throw new ArgumentNullException(nameof(roleAssignmentId)); |
| | 227 | | } |
| | 228 | |
|
| 30 | 229 | | using var message = CreateGetRoleAssignmentByIdRequest(roleAssignmentId); |
| 30 | 230 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 30 | 231 | | switch (message.Response.Status) |
| | 232 | | { |
| | 233 | | case 200: |
| | 234 | | { |
| | 235 | | RoleAssignmentDetails value = default; |
| 30 | 236 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 30 | 237 | | value = RoleAssignmentDetails.DeserializeRoleAssignmentDetails(document.RootElement); |
| 30 | 238 | | return Response.FromValue(value, message.Response); |
| | 239 | | } |
| | 240 | | default: |
| 0 | 241 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 242 | | } |
| 30 | 243 | | } |
| | 244 | |
|
| | 245 | | /// <summary> Get role assignment by role assignment Id. </summary> |
| | 246 | | /// <param name="roleAssignmentId"> The ID of the role assignment. </param> |
| | 247 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 248 | | /// <exception cref="ArgumentNullException"> <paramref name="roleAssignmentId"/> is null. </exception> |
| | 249 | | public Response<RoleAssignmentDetails> GetRoleAssignmentById(string roleAssignmentId, CancellationToken cancella |
| | 250 | | { |
| 30 | 251 | | if (roleAssignmentId == null) |
| | 252 | | { |
| 0 | 253 | | throw new ArgumentNullException(nameof(roleAssignmentId)); |
| | 254 | | } |
| | 255 | |
|
| 30 | 256 | | using var message = CreateGetRoleAssignmentByIdRequest(roleAssignmentId); |
| 30 | 257 | | _pipeline.Send(message, cancellationToken); |
| 30 | 258 | | switch (message.Response.Status) |
| | 259 | | { |
| | 260 | | case 200: |
| | 261 | | { |
| | 262 | | RoleAssignmentDetails value = default; |
| 30 | 263 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 30 | 264 | | value = RoleAssignmentDetails.DeserializeRoleAssignmentDetails(document.RootElement); |
| 30 | 265 | | return Response.FromValue(value, message.Response); |
| | 266 | | } |
| | 267 | | default: |
| 0 | 268 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 269 | | } |
| 30 | 270 | | } |
| | 271 | |
|
| | 272 | | internal HttpMessage CreateDeleteRoleAssignmentByIdRequest(string roleAssignmentId) |
| | 273 | | { |
| 4 | 274 | | var message = _pipeline.CreateMessage(); |
| 4 | 275 | | var request = message.Request; |
| 4 | 276 | | request.Method = RequestMethod.Delete; |
| 4 | 277 | | var uri = new RawRequestUriBuilder(); |
| 4 | 278 | | uri.AppendRaw(endpoint, false); |
| 4 | 279 | | uri.AppendPath("/rbac/roleAssignments/", false); |
| 4 | 280 | | uri.AppendPath(roleAssignmentId, true); |
| 4 | 281 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 282 | | request.Uri = uri; |
| 4 | 283 | | return message; |
| | 284 | | } |
| | 285 | |
|
| | 286 | | /// <summary> Delete role assignment by role assignment Id. </summary> |
| | 287 | | /// <param name="roleAssignmentId"> The ID of the role assignment. </param> |
| | 288 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 289 | | /// <exception cref="ArgumentNullException"> <paramref name="roleAssignmentId"/> is null. </exception> |
| | 290 | | public async Task<Response> DeleteRoleAssignmentByIdAsync(string roleAssignmentId, CancellationToken cancellatio |
| | 291 | | { |
| 2 | 292 | | if (roleAssignmentId == null) |
| | 293 | | { |
| 0 | 294 | | throw new ArgumentNullException(nameof(roleAssignmentId)); |
| | 295 | | } |
| | 296 | |
|
| 2 | 297 | | using var message = CreateDeleteRoleAssignmentByIdRequest(roleAssignmentId); |
| 2 | 298 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 299 | | switch (message.Response.Status) |
| | 300 | | { |
| | 301 | | case 200: |
| | 302 | | case 204: |
| 2 | 303 | | return message.Response; |
| | 304 | | default: |
| 0 | 305 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 306 | | } |
| 2 | 307 | | } |
| | 308 | |
|
| | 309 | | /// <summary> Delete role assignment by role assignment Id. </summary> |
| | 310 | | /// <param name="roleAssignmentId"> The ID of the role assignment. </param> |
| | 311 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 312 | | /// <exception cref="ArgumentNullException"> <paramref name="roleAssignmentId"/> is null. </exception> |
| | 313 | | public Response DeleteRoleAssignmentById(string roleAssignmentId, CancellationToken cancellationToken = default) |
| | 314 | | { |
| 2 | 315 | | if (roleAssignmentId == null) |
| | 316 | | { |
| 0 | 317 | | throw new ArgumentNullException(nameof(roleAssignmentId)); |
| | 318 | | } |
| | 319 | |
|
| 2 | 320 | | using var message = CreateDeleteRoleAssignmentByIdRequest(roleAssignmentId); |
| 2 | 321 | | _pipeline.Send(message, cancellationToken); |
| 2 | 322 | | switch (message.Response.Status) |
| | 323 | | { |
| | 324 | | case 200: |
| | 325 | | case 204: |
| 2 | 326 | | return message.Response; |
| | 327 | | default: |
| 0 | 328 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 329 | | } |
| 2 | 330 | | } |
| | 331 | |
|
| | 332 | | internal HttpMessage CreateGetCallerRoleAssignmentsRequest() |
| | 333 | | { |
| 4 | 334 | | var message = _pipeline.CreateMessage(); |
| 4 | 335 | | var request = message.Request; |
| 4 | 336 | | request.Method = RequestMethod.Post; |
| 4 | 337 | | var uri = new RawRequestUriBuilder(); |
| 4 | 338 | | uri.AppendRaw(endpoint, false); |
| 4 | 339 | | uri.AppendPath("/rbac/getMyAssignedRoles", false); |
| 4 | 340 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 341 | | request.Uri = uri; |
| 4 | 342 | | return message; |
| | 343 | | } |
| | 344 | |
|
| | 345 | | /// <summary> List role assignments of the caller. </summary> |
| | 346 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 347 | | public async Task<Response<IReadOnlyList<string>>> GetCallerRoleAssignmentsAsync(CancellationToken cancellationT |
| | 348 | | { |
| 2 | 349 | | using var message = CreateGetCallerRoleAssignmentsRequest(); |
| 2 | 350 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 351 | | switch (message.Response.Status) |
| | 352 | | { |
| | 353 | | case 200: |
| | 354 | | { |
| | 355 | | IReadOnlyList<string> value = default; |
| 2 | 356 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 357 | | List<string> array = new List<string>(); |
| 16 | 358 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 359 | | { |
| 6 | 360 | | array.Add(item.GetString()); |
| | 361 | | } |
| 2 | 362 | | value = array; |
| 2 | 363 | | return Response.FromValue(value, message.Response); |
| | 364 | | } |
| | 365 | | default: |
| 0 | 366 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 367 | | } |
| 2 | 368 | | } |
| | 369 | |
|
| | 370 | | /// <summary> List role assignments of the caller. </summary> |
| | 371 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 372 | | public Response<IReadOnlyList<string>> GetCallerRoleAssignments(CancellationToken cancellationToken = default) |
| | 373 | | { |
| 2 | 374 | | using var message = CreateGetCallerRoleAssignmentsRequest(); |
| 2 | 375 | | _pipeline.Send(message, cancellationToken); |
| 2 | 376 | | switch (message.Response.Status) |
| | 377 | | { |
| | 378 | | case 200: |
| | 379 | | { |
| | 380 | | IReadOnlyList<string> value = default; |
| 2 | 381 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 382 | | List<string> array = new List<string>(); |
| 16 | 383 | | foreach (var item in document.RootElement.EnumerateArray()) |
| | 384 | | { |
| 6 | 385 | | array.Add(item.GetString()); |
| | 386 | | } |
| 2 | 387 | | value = array; |
| 2 | 388 | | return Response.FromValue(value, message.Response); |
| | 389 | | } |
| | 390 | | default: |
| 0 | 391 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 392 | | } |
| 2 | 393 | | } |
| | 394 | |
|
| | 395 | | internal HttpMessage CreateGetRoleDefinitionsRequest() |
| | 396 | | { |
| 8 | 397 | | var message = _pipeline.CreateMessage(); |
| 8 | 398 | | var request = message.Request; |
| 8 | 399 | | request.Method = RequestMethod.Get; |
| 8 | 400 | | var uri = new RawRequestUriBuilder(); |
| 8 | 401 | | uri.AppendRaw(endpoint, false); |
| 8 | 402 | | uri.AppendPath("/rbac/roles", false); |
| 8 | 403 | | uri.AppendQuery("api-version", apiVersion, true); |
| 8 | 404 | | request.Uri = uri; |
| 8 | 405 | | return message; |
| | 406 | | } |
| | 407 | |
|
| | 408 | | /// <summary> List roles. </summary> |
| | 409 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 410 | | public async Task<Response<RolesListResponse>> GetRoleDefinitionsAsync(CancellationToken cancellationToken = def |
| | 411 | | { |
| 4 | 412 | | using var message = CreateGetRoleDefinitionsRequest(); |
| 4 | 413 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 414 | | switch (message.Response.Status) |
| | 415 | | { |
| | 416 | | case 200: |
| | 417 | | { |
| | 418 | | RolesListResponse value = default; |
| 4 | 419 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 420 | | value = RolesListResponse.DeserializeRolesListResponse(document.RootElement); |
| 4 | 421 | | return Response.FromValue(value, message.Response); |
| | 422 | | } |
| | 423 | | default: |
| 0 | 424 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 425 | | } |
| 4 | 426 | | } |
| | 427 | |
|
| | 428 | | /// <summary> List roles. </summary> |
| | 429 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 430 | | public Response<RolesListResponse> GetRoleDefinitions(CancellationToken cancellationToken = default) |
| | 431 | | { |
| 4 | 432 | | using var message = CreateGetRoleDefinitionsRequest(); |
| 4 | 433 | | _pipeline.Send(message, cancellationToken); |
| 4 | 434 | | switch (message.Response.Status) |
| | 435 | | { |
| | 436 | | case 200: |
| | 437 | | { |
| | 438 | | RolesListResponse value = default; |
| 4 | 439 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 440 | | value = RolesListResponse.DeserializeRolesListResponse(document.RootElement); |
| 4 | 441 | | return Response.FromValue(value, message.Response); |
| | 442 | | } |
| | 443 | | default: |
| 0 | 444 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 445 | | } |
| 4 | 446 | | } |
| | 447 | |
|
| | 448 | | internal HttpMessage CreateGetRoleDefinitionByIdRequest(string roleId) |
| | 449 | | { |
| 12 | 450 | | var message = _pipeline.CreateMessage(); |
| 12 | 451 | | var request = message.Request; |
| 12 | 452 | | request.Method = RequestMethod.Get; |
| 12 | 453 | | var uri = new RawRequestUriBuilder(); |
| 12 | 454 | | uri.AppendRaw(endpoint, false); |
| 12 | 455 | | uri.AppendPath("/rbac/roles/", false); |
| 12 | 456 | | uri.AppendPath(roleId, true); |
| 12 | 457 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 458 | | request.Uri = uri; |
| 12 | 459 | | return message; |
| | 460 | | } |
| | 461 | |
|
| | 462 | | /// <summary> Get role by role Id. </summary> |
| | 463 | | /// <param name="roleId"> Synapse Built-In Role Id. </param> |
| | 464 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 465 | | /// <exception cref="ArgumentNullException"> <paramref name="roleId"/> is null. </exception> |
| | 466 | | public async Task<Response<SynapseRole>> GetRoleDefinitionByIdAsync(string roleId, CancellationToken cancellatio |
| | 467 | | { |
| 6 | 468 | | if (roleId == null) |
| | 469 | | { |
| 0 | 470 | | throw new ArgumentNullException(nameof(roleId)); |
| | 471 | | } |
| | 472 | |
|
| 6 | 473 | | using var message = CreateGetRoleDefinitionByIdRequest(roleId); |
| 6 | 474 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 475 | | switch (message.Response.Status) |
| | 476 | | { |
| | 477 | | case 200: |
| | 478 | | { |
| | 479 | | SynapseRole value = default; |
| 6 | 480 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6 | 481 | | value = SynapseRole.DeserializeSynapseRole(document.RootElement); |
| 6 | 482 | | return Response.FromValue(value, message.Response); |
| | 483 | | } |
| | 484 | | default: |
| 0 | 485 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 486 | | } |
| 6 | 487 | | } |
| | 488 | |
|
| | 489 | | /// <summary> Get role by role Id. </summary> |
| | 490 | | /// <param name="roleId"> Synapse Built-In Role Id. </param> |
| | 491 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 492 | | /// <exception cref="ArgumentNullException"> <paramref name="roleId"/> is null. </exception> |
| | 493 | | public Response<SynapseRole> GetRoleDefinitionById(string roleId, CancellationToken cancellationToken = default) |
| | 494 | | { |
| 6 | 495 | | if (roleId == null) |
| | 496 | | { |
| 0 | 497 | | throw new ArgumentNullException(nameof(roleId)); |
| | 498 | | } |
| | 499 | |
|
| 6 | 500 | | using var message = CreateGetRoleDefinitionByIdRequest(roleId); |
| 6 | 501 | | _pipeline.Send(message, cancellationToken); |
| 6 | 502 | | switch (message.Response.Status) |
| | 503 | | { |
| | 504 | | case 200: |
| | 505 | | { |
| | 506 | | SynapseRole value = default; |
| 6 | 507 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6 | 508 | | value = SynapseRole.DeserializeSynapseRole(document.RootElement); |
| 6 | 509 | | return Response.FromValue(value, message.Response); |
| | 510 | | } |
| | 511 | | default: |
| 0 | 512 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 513 | | } |
| 6 | 514 | | } |
| | 515 | |
|
| | 516 | | internal HttpMessage CreateGetRoleDefinitionsNextPageRequest(string nextLink) |
| | 517 | | { |
| 0 | 518 | | var message = _pipeline.CreateMessage(); |
| 0 | 519 | | var request = message.Request; |
| 0 | 520 | | request.Method = RequestMethod.Get; |
| 0 | 521 | | var uri = new RawRequestUriBuilder(); |
| 0 | 522 | | uri.AppendRaw(endpoint, false); |
| 0 | 523 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 524 | | request.Uri = uri; |
| 0 | 525 | | return message; |
| | 526 | | } |
| | 527 | |
|
| | 528 | | /// <summary> List roles. </summary> |
| | 529 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 530 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 531 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception> |
| | 532 | | public async Task<Response<RolesListResponse>> GetRoleDefinitionsNextPageAsync(string nextLink, CancellationToke |
| | 533 | | { |
| 0 | 534 | | if (nextLink == null) |
| | 535 | | { |
| 0 | 536 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 537 | | } |
| | 538 | |
|
| 0 | 539 | | using var message = CreateGetRoleDefinitionsNextPageRequest(nextLink); |
| 0 | 540 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 541 | | switch (message.Response.Status) |
| | 542 | | { |
| | 543 | | case 200: |
| | 544 | | { |
| | 545 | | RolesListResponse value = default; |
| 0 | 546 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 547 | | value = RolesListResponse.DeserializeRolesListResponse(document.RootElement); |
| 0 | 548 | | return Response.FromValue(value, message.Response); |
| | 549 | | } |
| | 550 | | default: |
| 0 | 551 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 552 | | } |
| 0 | 553 | | } |
| | 554 | |
|
| | 555 | | /// <summary> List roles. </summary> |
| | 556 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 557 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 558 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception> |
| | 559 | | public Response<RolesListResponse> GetRoleDefinitionsNextPage(string nextLink, CancellationToken cancellationTok |
| | 560 | | { |
| 0 | 561 | | if (nextLink == null) |
| | 562 | | { |
| 0 | 563 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 564 | | } |
| | 565 | |
|
| 0 | 566 | | using var message = CreateGetRoleDefinitionsNextPageRequest(nextLink); |
| 0 | 567 | | _pipeline.Send(message, cancellationToken); |
| 0 | 568 | | switch (message.Response.Status) |
| | 569 | | { |
| | 570 | | case 200: |
| | 571 | | { |
| | 572 | | RolesListResponse value = default; |
| 0 | 573 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 574 | | value = RolesListResponse.DeserializeRolesListResponse(document.RootElement); |
| 0 | 575 | | return Response.FromValue(value, message.Response); |
| | 576 | | } |
| | 577 | | default: |
| 0 | 578 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 579 | | } |
| 0 | 580 | | } |
| | 581 | | } |
| | 582 | | } |