< Summary

Class:Azure.Analytics.Synapse.AccessControl.AccessControlRestClient
Assembly:Azure.Analytics.Synapse.AccessControl
File(s):C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.AccessControl\src\Generated\AccessControlRestClient.cs
Covered lines:197
Uncovered lines:55
Coverable lines:252
Total lines:582
Line coverage:78.1% (197 of 252)
Covered branches:37
Total branches:74
Branch coverage:50% (37 of 74)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
CreateCreateRoleAssignmentRequest(...)-100%100%
CreateRoleAssignmentAsync()-80%50%
CreateRoleAssignment(...)-80%50%
CreateGetRoleAssignmentsRequest(...)-80%50%
GetRoleAssignmentsAsync()-91.67%75%
GetRoleAssignments(...)-91.67%75%
CreateGetRoleAssignmentByIdRequest(...)-100%100%
GetRoleAssignmentByIdAsync()-80%50%
GetRoleAssignmentById(...)-80%50%
CreateDeleteRoleAssignmentByIdRequest(...)-100%100%
DeleteRoleAssignmentByIdAsync()-75%50%
DeleteRoleAssignmentById(...)-75%50%
CreateGetCallerRoleAssignmentsRequest()-100%100%
GetCallerRoleAssignmentsAsync()-90.91%75%
GetCallerRoleAssignments(...)-90.91%75%
CreateGetRoleDefinitionsRequest()-100%100%
GetRoleDefinitionsAsync()-87.5%50%
GetRoleDefinitions(...)-87.5%50%
CreateGetRoleDefinitionByIdRequest(...)-100%100%
GetRoleDefinitionByIdAsync()-80%50%
GetRoleDefinitionById(...)-80%50%
CreateGetRoleDefinitionsNextPageRequest(...)-0%100%
GetRoleDefinitionsNextPageAsync()-0%0%
GetRoleDefinitionsNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.AccessControl\src\Generated\AccessControlRestClient.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Collections.Generic;
 10using System.Text.Json;
 11using System.Threading;
 12using System.Threading.Tasks;
 13using Azure;
 14using Azure.Analytics.Synapse.AccessControl.Models;
 15using Azure.Core;
 16using Azure.Core.Pipeline;
 17
 18namespace 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
 1633        public AccessControlRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, stri
 34        {
 1635            if (endpoint == null)
 36            {
 037                throw new ArgumentNullException(nameof(endpoint));
 38            }
 1639            if (apiVersion == null)
 40            {
 041                throw new ArgumentNullException(nameof(apiVersion));
 42            }
 43
 1644            this.endpoint = endpoint;
 1645            this.apiVersion = apiVersion;
 1646            _clientDiagnostics = clientDiagnostics;
 1647            _pipeline = pipeline;
 1648        }
 49
 50        internal HttpMessage CreateCreateRoleAssignmentRequest(RoleAssignmentOptions createRoleAssignmentOptions)
 51        {
 452            var message = _pipeline.CreateMessage();
 453            var request = message.Request;
 454            request.Method = RequestMethod.Post;
 455            var uri = new RawRequestUriBuilder();
 456            uri.AppendRaw(endpoint, false);
 457            uri.AppendPath("/rbac/roleAssignments", false);
 458            uri.AppendQuery("api-version", apiVersion, true);
 459            request.Uri = uri;
 460            request.Headers.Add("Content-Type", "application/json");
 461            var content = new Utf8JsonRequestContent();
 462            content.JsonWriter.WriteObjectValue(createRoleAssignmentOptions);
 463            request.Content = content;
 464            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        {
 273            if (createRoleAssignmentOptions == null)
 74            {
 075                throw new ArgumentNullException(nameof(createRoleAssignmentOptions));
 76            }
 77
 278            using var message = CreateCreateRoleAssignmentRequest(createRoleAssignmentOptions);
 279            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 280            switch (message.Response.Status)
 81            {
 82                case 200:
 83                    {
 84                        RoleAssignmentDetails value = default;
 285                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 286                        value = RoleAssignmentDetails.DeserializeRoleAssignmentDetails(document.RootElement);
 287                        return Response.FromValue(value, message.Response);
 88                    }
 89                default:
 090                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 91            }
 292        }
 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        {
 2100            if (createRoleAssignmentOptions == null)
 101            {
 0102                throw new ArgumentNullException(nameof(createRoleAssignmentOptions));
 103            }
 104
 2105            using var message = CreateCreateRoleAssignmentRequest(createRoleAssignmentOptions);
 2106            _pipeline.Send(message, cancellationToken);
 2107            switch (message.Response.Status)
 108            {
 109                case 200:
 110                    {
 111                        RoleAssignmentDetails value = default;
 2112                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2113                        value = RoleAssignmentDetails.DeserializeRoleAssignmentDetails(document.RootElement);
 2114                        return Response.FromValue(value, message.Response);
 115                    }
 116                default:
 0117                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 118            }
 2119        }
 120
 121        internal HttpMessage CreateGetRoleAssignmentsRequest(string roleId, string principalId, string continuationToken
 122        {
 8123            var message = _pipeline.CreateMessage();
 8124            var request = message.Request;
 8125            request.Method = RequestMethod.Get;
 8126            var uri = new RawRequestUriBuilder();
 8127            uri.AppendRaw(endpoint, false);
 8128            uri.AppendPath("/rbac/roleAssignments", false);
 8129            uri.AppendQuery("api-version", apiVersion, true);
 8130            if (roleId != null)
 131            {
 0132                uri.AppendQuery("roleId", roleId, true);
 133            }
 8134            if (principalId != null)
 135            {
 0136                uri.AppendQuery("principalId", principalId, true);
 137            }
 8138            request.Uri = uri;
 8139            if (continuationToken != null)
 140            {
 0141                request.Headers.Add("x-ms-continuation", continuationToken);
 142            }
 8143            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        {
 4153            using var message = CreateGetRoleAssignmentsRequest(roleId, principalId, continuationToken);
 4154            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4155            var headers = new AccessControlGetRoleAssignmentsHeaders(message.Response);
 4156            switch (message.Response.Status)
 157            {
 158                case 200:
 159                    {
 160                        IReadOnlyList<RoleAssignmentDetails> value = default;
 4161                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4162                        List<RoleAssignmentDetails> array = new List<RoleAssignmentDetails>();
 128163                        foreach (var item in document.RootElement.EnumerateArray())
 164                        {
 60165                            array.Add(RoleAssignmentDetails.DeserializeRoleAssignmentDetails(item));
 166                        }
 4167                        value = array;
 4168                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
 169                    }
 170                default:
 0171                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 172            }
 4173        }
 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        {
 4182            using var message = CreateGetRoleAssignmentsRequest(roleId, principalId, continuationToken);
 4183            _pipeline.Send(message, cancellationToken);
 4184            var headers = new AccessControlGetRoleAssignmentsHeaders(message.Response);
 4185            switch (message.Response.Status)
 186            {
 187                case 200:
 188                    {
 189                        IReadOnlyList<RoleAssignmentDetails> value = default;
 4190                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4191                        List<RoleAssignmentDetails> array = new List<RoleAssignmentDetails>();
 128192                        foreach (var item in document.RootElement.EnumerateArray())
 193                        {
 60194                            array.Add(RoleAssignmentDetails.DeserializeRoleAssignmentDetails(item));
 195                        }
 4196                        value = array;
 4197                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
 198                    }
 199                default:
 0200                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 201            }
 4202        }
 203
 204        internal HttpMessage CreateGetRoleAssignmentByIdRequest(string roleAssignmentId)
 205        {
 60206            var message = _pipeline.CreateMessage();
 60207            var request = message.Request;
 60208            request.Method = RequestMethod.Get;
 60209            var uri = new RawRequestUriBuilder();
 60210            uri.AppendRaw(endpoint, false);
 60211            uri.AppendPath("/rbac/roleAssignments/", false);
 60212            uri.AppendPath(roleAssignmentId, true);
 60213            uri.AppendQuery("api-version", apiVersion, true);
 60214            request.Uri = uri;
 60215            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        {
 30224            if (roleAssignmentId == null)
 225            {
 0226                throw new ArgumentNullException(nameof(roleAssignmentId));
 227            }
 228
 30229            using var message = CreateGetRoleAssignmentByIdRequest(roleAssignmentId);
 30230            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 30231            switch (message.Response.Status)
 232            {
 233                case 200:
 234                    {
 235                        RoleAssignmentDetails value = default;
 30236                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 30237                        value = RoleAssignmentDetails.DeserializeRoleAssignmentDetails(document.RootElement);
 30238                        return Response.FromValue(value, message.Response);
 239                    }
 240                default:
 0241                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 242            }
 30243        }
 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        {
 30251            if (roleAssignmentId == null)
 252            {
 0253                throw new ArgumentNullException(nameof(roleAssignmentId));
 254            }
 255
 30256            using var message = CreateGetRoleAssignmentByIdRequest(roleAssignmentId);
 30257            _pipeline.Send(message, cancellationToken);
 30258            switch (message.Response.Status)
 259            {
 260                case 200:
 261                    {
 262                        RoleAssignmentDetails value = default;
 30263                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 30264                        value = RoleAssignmentDetails.DeserializeRoleAssignmentDetails(document.RootElement);
 30265                        return Response.FromValue(value, message.Response);
 266                    }
 267                default:
 0268                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 269            }
 30270        }
 271
 272        internal HttpMessage CreateDeleteRoleAssignmentByIdRequest(string roleAssignmentId)
 273        {
 4274            var message = _pipeline.CreateMessage();
 4275            var request = message.Request;
 4276            request.Method = RequestMethod.Delete;
 4277            var uri = new RawRequestUriBuilder();
 4278            uri.AppendRaw(endpoint, false);
 4279            uri.AppendPath("/rbac/roleAssignments/", false);
 4280            uri.AppendPath(roleAssignmentId, true);
 4281            uri.AppendQuery("api-version", apiVersion, true);
 4282            request.Uri = uri;
 4283            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        {
 2292            if (roleAssignmentId == null)
 293            {
 0294                throw new ArgumentNullException(nameof(roleAssignmentId));
 295            }
 296
 2297            using var message = CreateDeleteRoleAssignmentByIdRequest(roleAssignmentId);
 2298            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2299            switch (message.Response.Status)
 300            {
 301                case 200:
 302                case 204:
 2303                    return message.Response;
 304                default:
 0305                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 306            }
 2307        }
 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        {
 2315            if (roleAssignmentId == null)
 316            {
 0317                throw new ArgumentNullException(nameof(roleAssignmentId));
 318            }
 319
 2320            using var message = CreateDeleteRoleAssignmentByIdRequest(roleAssignmentId);
 2321            _pipeline.Send(message, cancellationToken);
 2322            switch (message.Response.Status)
 323            {
 324                case 200:
 325                case 204:
 2326                    return message.Response;
 327                default:
 0328                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 329            }
 2330        }
 331
 332        internal HttpMessage CreateGetCallerRoleAssignmentsRequest()
 333        {
 4334            var message = _pipeline.CreateMessage();
 4335            var request = message.Request;
 4336            request.Method = RequestMethod.Post;
 4337            var uri = new RawRequestUriBuilder();
 4338            uri.AppendRaw(endpoint, false);
 4339            uri.AppendPath("/rbac/getMyAssignedRoles", false);
 4340            uri.AppendQuery("api-version", apiVersion, true);
 4341            request.Uri = uri;
 4342            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        {
 2349            using var message = CreateGetCallerRoleAssignmentsRequest();
 2350            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2351            switch (message.Response.Status)
 352            {
 353                case 200:
 354                    {
 355                        IReadOnlyList<string> value = default;
 2356                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2357                        List<string> array = new List<string>();
 16358                        foreach (var item in document.RootElement.EnumerateArray())
 359                        {
 6360                            array.Add(item.GetString());
 361                        }
 2362                        value = array;
 2363                        return Response.FromValue(value, message.Response);
 364                    }
 365                default:
 0366                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 367            }
 2368        }
 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        {
 2374            using var message = CreateGetCallerRoleAssignmentsRequest();
 2375            _pipeline.Send(message, cancellationToken);
 2376            switch (message.Response.Status)
 377            {
 378                case 200:
 379                    {
 380                        IReadOnlyList<string> value = default;
 2381                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2382                        List<string> array = new List<string>();
 16383                        foreach (var item in document.RootElement.EnumerateArray())
 384                        {
 6385                            array.Add(item.GetString());
 386                        }
 2387                        value = array;
 2388                        return Response.FromValue(value, message.Response);
 389                    }
 390                default:
 0391                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 392            }
 2393        }
 394
 395        internal HttpMessage CreateGetRoleDefinitionsRequest()
 396        {
 8397            var message = _pipeline.CreateMessage();
 8398            var request = message.Request;
 8399            request.Method = RequestMethod.Get;
 8400            var uri = new RawRequestUriBuilder();
 8401            uri.AppendRaw(endpoint, false);
 8402            uri.AppendPath("/rbac/roles", false);
 8403            uri.AppendQuery("api-version", apiVersion, true);
 8404            request.Uri = uri;
 8405            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        {
 4412            using var message = CreateGetRoleDefinitionsRequest();
 4413            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4414            switch (message.Response.Status)
 415            {
 416                case 200:
 417                    {
 418                        RolesListResponse value = default;
 4419                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4420                        value = RolesListResponse.DeserializeRolesListResponse(document.RootElement);
 4421                        return Response.FromValue(value, message.Response);
 422                    }
 423                default:
 0424                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 425            }
 4426        }
 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        {
 4432            using var message = CreateGetRoleDefinitionsRequest();
 4433            _pipeline.Send(message, cancellationToken);
 4434            switch (message.Response.Status)
 435            {
 436                case 200:
 437                    {
 438                        RolesListResponse value = default;
 4439                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4440                        value = RolesListResponse.DeserializeRolesListResponse(document.RootElement);
 4441                        return Response.FromValue(value, message.Response);
 442                    }
 443                default:
 0444                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 445            }
 4446        }
 447
 448        internal HttpMessage CreateGetRoleDefinitionByIdRequest(string roleId)
 449        {
 12450            var message = _pipeline.CreateMessage();
 12451            var request = message.Request;
 12452            request.Method = RequestMethod.Get;
 12453            var uri = new RawRequestUriBuilder();
 12454            uri.AppendRaw(endpoint, false);
 12455            uri.AppendPath("/rbac/roles/", false);
 12456            uri.AppendPath(roleId, true);
 12457            uri.AppendQuery("api-version", apiVersion, true);
 12458            request.Uri = uri;
 12459            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        {
 6468            if (roleId == null)
 469            {
 0470                throw new ArgumentNullException(nameof(roleId));
 471            }
 472
 6473            using var message = CreateGetRoleDefinitionByIdRequest(roleId);
 6474            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 6475            switch (message.Response.Status)
 476            {
 477                case 200:
 478                    {
 479                        SynapseRole value = default;
 6480                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 6481                        value = SynapseRole.DeserializeSynapseRole(document.RootElement);
 6482                        return Response.FromValue(value, message.Response);
 483                    }
 484                default:
 0485                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 486            }
 6487        }
 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        {
 6495            if (roleId == null)
 496            {
 0497                throw new ArgumentNullException(nameof(roleId));
 498            }
 499
 6500            using var message = CreateGetRoleDefinitionByIdRequest(roleId);
 6501            _pipeline.Send(message, cancellationToken);
 6502            switch (message.Response.Status)
 503            {
 504                case 200:
 505                    {
 506                        SynapseRole value = default;
 6507                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 6508                        value = SynapseRole.DeserializeSynapseRole(document.RootElement);
 6509                        return Response.FromValue(value, message.Response);
 510                    }
 511                default:
 0512                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 513            }
 6514        }
 515
 516        internal HttpMessage CreateGetRoleDefinitionsNextPageRequest(string nextLink)
 517        {
 0518            var message = _pipeline.CreateMessage();
 0519            var request = message.Request;
 0520            request.Method = RequestMethod.Get;
 0521            var uri = new RawRequestUriBuilder();
 0522            uri.AppendRaw(endpoint, false);
 0523            uri.AppendRawNextLink(nextLink, false);
 0524            request.Uri = uri;
 0525            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        {
 0534            if (nextLink == null)
 535            {
 0536                throw new ArgumentNullException(nameof(nextLink));
 537            }
 538
 0539            using var message = CreateGetRoleDefinitionsNextPageRequest(nextLink);
 0540            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0541            switch (message.Response.Status)
 542            {
 543                case 200:
 544                    {
 545                        RolesListResponse value = default;
 0546                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0547                        value = RolesListResponse.DeserializeRolesListResponse(document.RootElement);
 0548                        return Response.FromValue(value, message.Response);
 549                    }
 550                default:
 0551                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 552            }
 0553        }
 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        {
 0561            if (nextLink == null)
 562            {
 0563                throw new ArgumentNullException(nameof(nextLink));
 564            }
 565
 0566            using var message = CreateGetRoleDefinitionsNextPageRequest(nextLink);
 0567            _pipeline.Send(message, cancellationToken);
 0568            switch (message.Response.Status)
 569            {
 570                case 200:
 571                    {
 572                        RolesListResponse value = default;
 0573                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0574                        value = RolesListResponse.DeserializeRolesListResponse(document.RootElement);
 0575                        return Response.FromValue(value, message.Response);
 576                    }
 577                default:
 0578                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 579            }
 0580        }
 581    }
 582}