< Summary

Class:Azure.Analytics.Synapse.AccessControl.AccessControlClient
Assembly:Azure.Analytics.Synapse.AccessControl
File(s):C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.AccessControl\src\Customization\AccessControlClient.cs
C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.AccessControl\src\Generated\AccessControlClient.cs
Covered lines:76
Uncovered lines:62
Coverable lines:138
Total lines:364
Line coverage:55% (76 of 138)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%100%
.ctor(...)-100%100%
.ctor(...)-0%100%
get_RestClient()-100%100%
.ctor(...)-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
CreateRoleAssignmentAsync()-57.14%100%
CreateRoleAssignment(...)-57.14%100%
GetRoleAssignmentsAsync()-57.14%100%
GetRoleAssignments(...)-57.14%100%
GetRoleAssignmentByIdAsync()-57.14%100%
GetRoleAssignmentById(...)-57.14%100%
DeleteRoleAssignmentByIdAsync()-57.14%100%
DeleteRoleAssignmentById(...)-57.14%100%
GetCallerRoleAssignmentsAsync()-57.14%100%
GetCallerRoleAssignments(...)-57.14%100%
GetRoleDefinitionByIdAsync()-57.14%100%
GetRoleDefinitionById(...)-57.14%100%
<GetRoleDefinitionsAsync()-62.5%100%
<GetRoleDefinitionsAsync()-0%100%
GetRoleDefinitionsAsync(...)-100%100%
GetRoleDefinitions(...)-100%100%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using Azure.Core;
 6using Azure.Core.Pipeline;
 7
 8namespace Azure.Analytics.Synapse.AccessControl
 9{
 10    public partial class AccessControlClient
 11    {
 12        /// <summary>
 13        /// Initializes a new instance of the <see cref="AccessControlClient"/>.
 14        /// </summary>
 15        public AccessControlClient(Uri endpoint, TokenCredential credential)
 016            : this(endpoint, credential, AccessControlClientOptions.Default)
 17        {
 018        }
 19
 20        /// <summary>
 21        /// Initializes a new instance of the <see cref="AccessControlClient"/>.
 22        /// </summary>
 23        public AccessControlClient(Uri endpoint, TokenCredential credential, AccessControlClientOptions options)
 824            : this(new ClientDiagnostics(options),
 825                  SynapseClientPipeline.Build(options, credential),
 826                  endpoint.ToString(),
 827                  options.VersionString)
 28        {
 829        }
 30    }
 31}

C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.AccessControl\src\Generated\AccessControlClient.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.Threading;
 11using System.Threading.Tasks;
 12using Azure;
 13using Azure.Analytics.Synapse.AccessControl.Models;
 14using Azure.Core;
 15using Azure.Core.Pipeline;
 016
 17namespace Azure.Analytics.Synapse.AccessControl
 018{
 19    /// <summary> The AccessControl service client. </summary>
 20    public partial class AccessControlClient
 21    {
 22        private readonly ClientDiagnostics _clientDiagnostics;
 23        private readonly HttpPipeline _pipeline;
 10824        internal AccessControlRestClient RestClient { get; }
 825        /// <summary> Initializes a new instance of AccessControlClient for mocking. </summary>
 2426        protected AccessControlClient()
 827        {
 1628        }
 829        /// <summary> Initializes a new instance of AccessControlClient. </summary>
 30        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 31        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 32        /// <param name="endpoint"> The workspace development endpoint, for example https://myworkspace.dev.azuresynapse
 33        /// <param name="apiVersion"> Api Version. </param>
 1634        internal AccessControlClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string
 35        {
 1636            RestClient = new AccessControlRestClient(clientDiagnostics, pipeline, endpoint, apiVersion);
 1637            _clientDiagnostics = clientDiagnostics;
 1638            _pipeline = pipeline;
 1639        }
 40
 41        /// <summary> Create role assignment. </summary>
 42        /// <param name="createRoleAssignmentOptions"> Details of role id and object id. </param>
 43        /// <param name="cancellationToken"> The cancellation token to use. </param>
 44        public virtual async Task<Response<RoleAssignmentDetails>> CreateRoleAssignmentAsync(RoleAssignmentOptions creat
 45        {
 246            using var scope = _clientDiagnostics.CreateScope("AccessControlClient.CreateRoleAssignment");
 247            scope.Start();
 48            try
 49            {
 250                return await RestClient.CreateRoleAssignmentAsync(createRoleAssignmentOptions, cancellationToken).Config
 51            }
 052            catch (Exception e)
 53            {
 054                scope.Failed(e);
 055                throw;
 56            }
 257        }
 58
 59        /// <summary> Create role assignment. </summary>
 60        /// <param name="createRoleAssignmentOptions"> Details of role id and object id. </param>
 61        /// <param name="cancellationToken"> The cancellation token to use. </param>
 62        public virtual Response<RoleAssignmentDetails> CreateRoleAssignment(RoleAssignmentOptions createRoleAssignmentOp
 63        {
 264            using var scope = _clientDiagnostics.CreateScope("AccessControlClient.CreateRoleAssignment");
 265            scope.Start();
 66            try
 67            {
 268                return RestClient.CreateRoleAssignment(createRoleAssignmentOptions, cancellationToken);
 69            }
 070            catch (Exception e)
 71            {
 072                scope.Failed(e);
 073                throw;
 74            }
 275        }
 76
 77        /// <summary> List role assignments. </summary>
 78        /// <param name="roleId"> Synapse Built-In Role Id. </param>
 79        /// <param name="principalId"> Object ID of the AAD principal or security-group. </param>
 80        /// <param name="continuationToken"> Continuation token. </param>
 81        /// <param name="cancellationToken"> The cancellation token to use. </param>
 82        public virtual async Task<Response<IReadOnlyList<RoleAssignmentDetails>>> GetRoleAssignmentsAsync(string roleId 
 83        {
 484            using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleAssignments");
 485            scope.Start();
 86            try
 87            {
 488                return await RestClient.GetRoleAssignmentsAsync(roleId, principalId, continuationToken, cancellationToke
 89            }
 090            catch (Exception e)
 91            {
 092                scope.Failed(e);
 093                throw;
 94            }
 495        }
 96
 97        /// <summary> List role assignments. </summary>
 98        /// <param name="roleId"> Synapse Built-In Role Id. </param>
 99        /// <param name="principalId"> Object ID of the AAD principal or security-group. </param>
 100        /// <param name="continuationToken"> Continuation token. </param>
 101        /// <param name="cancellationToken"> The cancellation token to use. </param>
 102        public virtual Response<IReadOnlyList<RoleAssignmentDetails>> GetRoleAssignments(string roleId = null, string pr
 103        {
 4104            using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleAssignments");
 4105            scope.Start();
 106            try
 107            {
 4108                return RestClient.GetRoleAssignments(roleId, principalId, continuationToken, cancellationToken);
 109            }
 0110            catch (Exception e)
 111            {
 0112                scope.Failed(e);
 0113                throw;
 114            }
 4115        }
 116
 117        /// <summary> Get role assignment by role assignment Id. </summary>
 118        /// <param name="roleAssignmentId"> The ID of the role assignment. </param>
 119        /// <param name="cancellationToken"> The cancellation token to use. </param>
 120        public virtual async Task<Response<RoleAssignmentDetails>> GetRoleAssignmentByIdAsync(string roleAssignmentId, C
 121        {
 30122            using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleAssignmentById");
 30123            scope.Start();
 124            try
 125            {
 30126                return await RestClient.GetRoleAssignmentByIdAsync(roleAssignmentId, cancellationToken).ConfigureAwait(f
 127            }
 0128            catch (Exception e)
 129            {
 0130                scope.Failed(e);
 0131                throw;
 132            }
 30133        }
 134
 135        /// <summary> Get role assignment by role assignment Id. </summary>
 136        /// <param name="roleAssignmentId"> The ID of the role assignment. </param>
 137        /// <param name="cancellationToken"> The cancellation token to use. </param>
 138        public virtual Response<RoleAssignmentDetails> GetRoleAssignmentById(string roleAssignmentId, CancellationToken 
 139        {
 30140            using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleAssignmentById");
 30141            scope.Start();
 142            try
 143            {
 30144                return RestClient.GetRoleAssignmentById(roleAssignmentId, cancellationToken);
 145            }
 0146            catch (Exception e)
 147            {
 0148                scope.Failed(e);
 0149                throw;
 150            }
 30151        }
 152
 153        /// <summary> Delete role assignment by role assignment Id. </summary>
 154        /// <param name="roleAssignmentId"> The ID of the role assignment. </param>
 155        /// <param name="cancellationToken"> The cancellation token to use. </param>
 156        public virtual async Task<Response> DeleteRoleAssignmentByIdAsync(string roleAssignmentId, CancellationToken can
 157        {
 2158            using var scope = _clientDiagnostics.CreateScope("AccessControlClient.DeleteRoleAssignmentById");
 2159            scope.Start();
 160            try
 161            {
 2162                return await RestClient.DeleteRoleAssignmentByIdAsync(roleAssignmentId, cancellationToken).ConfigureAwai
 163            }
 0164            catch (Exception e)
 165            {
 0166                scope.Failed(e);
 0167                throw;
 168            }
 2169        }
 170
 171        /// <summary> Delete role assignment by role assignment Id. </summary>
 172        /// <param name="roleAssignmentId"> The ID of the role assignment. </param>
 173        /// <param name="cancellationToken"> The cancellation token to use. </param>
 174        public virtual Response DeleteRoleAssignmentById(string roleAssignmentId, CancellationToken cancellationToken = 
 175        {
 2176            using var scope = _clientDiagnostics.CreateScope("AccessControlClient.DeleteRoleAssignmentById");
 2177            scope.Start();
 178            try
 179            {
 2180                return RestClient.DeleteRoleAssignmentById(roleAssignmentId, cancellationToken);
 181            }
 0182            catch (Exception e)
 183            {
 0184                scope.Failed(e);
 0185                throw;
 186            }
 2187        }
 188
 189        /// <summary> List role assignments of the caller. </summary>
 190        /// <param name="cancellationToken"> The cancellation token to use. </param>
 191        public virtual async Task<Response<IReadOnlyList<string>>> GetCallerRoleAssignmentsAsync(CancellationToken cance
 192        {
 2193            using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetCallerRoleAssignments");
 2194            scope.Start();
 195            try
 196            {
 2197                return await RestClient.GetCallerRoleAssignmentsAsync(cancellationToken).ConfigureAwait(false);
 198            }
 0199            catch (Exception e)
 200            {
 0201                scope.Failed(e);
 0202                throw;
 203            }
 2204        }
 205
 206        /// <summary> List role assignments of the caller. </summary>
 207        /// <param name="cancellationToken"> The cancellation token to use. </param>
 208        public virtual Response<IReadOnlyList<string>> GetCallerRoleAssignments(CancellationToken cancellationToken = de
 209        {
 2210            using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetCallerRoleAssignments");
 2211            scope.Start();
 212            try
 213            {
 2214                return RestClient.GetCallerRoleAssignments(cancellationToken);
 215            }
 0216            catch (Exception e)
 217            {
 0218                scope.Failed(e);
 0219                throw;
 220            }
 2221        }
 222
 223        /// <summary> Get role by role Id. </summary>
 224        /// <param name="roleId"> Synapse Built-In Role Id. </param>
 225        /// <param name="cancellationToken"> The cancellation token to use. </param>
 226        public virtual async Task<Response<SynapseRole>> GetRoleDefinitionByIdAsync(string roleId, CancellationToken can
 227        {
 6228            using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleDefinitionById");
 6229            scope.Start();
 230            try
 231            {
 6232                return await RestClient.GetRoleDefinitionByIdAsync(roleId, cancellationToken).ConfigureAwait(false);
 233            }
 0234            catch (Exception e)
 235            {
 0236                scope.Failed(e);
 0237                throw;
 238            }
 6239        }
 240
 241        /// <summary> Get role by role Id. </summary>
 242        /// <param name="roleId"> Synapse Built-In Role Id. </param>
 243        /// <param name="cancellationToken"> The cancellation token to use. </param>
 244        public virtual Response<SynapseRole> GetRoleDefinitionById(string roleId, CancellationToken cancellationToken = 
 245        {
 6246            using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleDefinitionById");
 6247            scope.Start();
 248            try
 249            {
 6250                return RestClient.GetRoleDefinitionById(roleId, cancellationToken);
 251            }
 0252            catch (Exception e)
 253            {
 0254                scope.Failed(e);
 0255                throw;
 256            }
 6257        }
 258
 259        /// <summary> List roles. </summary>
 260        /// <param name="cancellationToken"> The cancellation token to use. </param>
 261        public virtual AsyncPageable<SynapseRole> GetRoleDefinitionsAsync(CancellationToken cancellationToken = default)
 262        {
 263            async Task<Page<SynapseRole>> FirstPageFunc(int? pageSizeHint)
 264            {
 4265                using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleDefinitions");
 4266                scope.Start();
 267                try
 268                {
 4269                    var response = await RestClient.GetRoleDefinitionsAsync(cancellationToken).ConfigureAwait(false);
 4270                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 271                }
 0272                catch (Exception e)
 273                {
 0274                    scope.Failed(e);
 0275                    throw;
 276                }
 4277            }
 278            async Task<Page<SynapseRole>> NextPageFunc(string nextLink, int? pageSizeHint)
 279            {
 0280                using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleDefinitions");
 0281                scope.Start();
 282                try
 283                {
 0284                    var response = await RestClient.GetRoleDefinitionsNextPageAsync(nextLink, cancellationToken).Configu
 0285                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 286                }
 0287                catch (Exception e)
 288                {
 0289                    scope.Failed(e);
 0290                    throw;
 291                }
 0292            }
 4293            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 294        }
 295
 296        /// <summary> List roles. </summary>
 297        /// <param name="cancellationToken"> The cancellation token to use. </param>
 298        public virtual Pageable<SynapseRole> GetRoleDefinitions(CancellationToken cancellationToken = default)
 299        {
 300            Page<SynapseRole> FirstPageFunc(int? pageSizeHint)
 301            {
 4302                using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleDefinitions");
 4303                scope.Start();
 304                try
 305                {
 4306                    var response = RestClient.GetRoleDefinitions(cancellationToken);
 4307                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 308                }
 0309                catch (Exception e)
 310                {
 0311                    scope.Failed(e);
 0312                    throw;
 313                }
 4314            }
 315            Page<SynapseRole> NextPageFunc(string nextLink, int? pageSizeHint)
 316            {
 0317                using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleDefinitions");
 0318                scope.Start();
 319                try
 320                {
 0321                    var response = RestClient.GetRoleDefinitionsNextPage(nextLink, cancellationToken);
 0322                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 323                }
 0324                catch (Exception e)
 325                {
 0326                    scope.Failed(e);
 0327                    throw;
 328                }
 0329            }
 4330            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 331        }
 332    }
 333}