< Summary

Class:Azure.Security.KeyVault.Administration.RoleDefinitionsRestClient
Assembly:Azure.Security.KeyVault.Administration
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Administration\src\Generated\RoleDefinitionsRestClient.cs
Covered lines:36
Uncovered lines:44
Coverable lines:80
Total lines:215
Line coverage:45% (36 of 80)
Covered branches:8
Total branches:32
Branch coverage:25% (8 of 32)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-85.71%50%
CreateListRequest(...)-92.31%50%
ListAsync()-75%50%
List(...)-75%50%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Administration\src\Generated\RoleDefinitionsRestClient.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.Text.Json;
 10using System.Threading;
 11using System.Threading.Tasks;
 12using Azure;
 13using Azure.Core;
 14using Azure.Core.Pipeline;
 15using Azure.Security.KeyVault.Administration.Models;
 16
 17namespace 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>
 4230        public RoleDefinitionsRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string apiVersion =
 31        {
 4232            if (apiVersion == null)
 33            {
 034                throw new ArgumentNullException(nameof(apiVersion));
 35            }
 36
 4237            this.apiVersion = apiVersion;
 4238            _clientDiagnostics = clientDiagnostics;
 4239            _pipeline = pipeline;
 4240        }
 41
 42        internal HttpMessage CreateListRequest(string vaultBaseUrl, string scope, string filter)
 43        {
 3444            var message = _pipeline.CreateMessage();
 3445            var request = message.Request;
 3446            request.Method = RequestMethod.Get;
 3447            var uri = new RawRequestUriBuilder();
 3448            uri.AppendRaw(vaultBaseUrl, false);
 3449            uri.AppendPath("/", false);
 3450            uri.AppendPath(scope, false);
 3451            uri.AppendPath("/providers/Microsoft.Authorization/roleDefinitions", false);
 3452            if (filter != null)
 53            {
 054                uri.AppendQuery("$filter", filter, true);
 55            }
 3456            uri.AppendQuery("api-version", apiVersion, true);
 3457            request.Uri = uri;
 3458            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        {
 1669            if (vaultBaseUrl == null)
 70            {
 071                throw new ArgumentNullException(nameof(vaultBaseUrl));
 72            }
 1673            if (scope == null)
 74            {
 075                throw new ArgumentNullException(nameof(scope));
 76            }
 77
 1678            using var message = CreateListRequest(vaultBaseUrl, scope, filter);
 1679            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 1680            switch (message.Response.Status)
 81            {
 82                case 200:
 83                    {
 84                        RoleDefinitionListResult value = default;
 1685                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 1686                        value = RoleDefinitionListResult.DeserializeRoleDefinitionListResult(document.RootElement);
 1687                        return Response.FromValue(value, message.Response);
 88                    }
 89                default:
 090                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 91            }
 1692        }
 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        {
 18102            if (vaultBaseUrl == null)
 103            {
 0104                throw new ArgumentNullException(nameof(vaultBaseUrl));
 105            }
 18106            if (scope == null)
 107            {
 0108                throw new ArgumentNullException(nameof(scope));
 109            }
 110
 18111            using var message = CreateListRequest(vaultBaseUrl, scope, filter);
 18112            _pipeline.Send(message, cancellationToken);
 18113            switch (message.Response.Status)
 114            {
 115                case 200:
 116                    {
 117                        RoleDefinitionListResult value = default;
 18118                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 18119                        value = RoleDefinitionListResult.DeserializeRoleDefinitionListResult(document.RootElement);
 18120                        return Response.FromValue(value, message.Response);
 121                    }
 122                default:
 0123                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 124            }
 18125        }
 126
 127        internal HttpMessage CreateListNextPageRequest(string nextLink, string vaultBaseUrl, string scope, string filter
 128        {
 0129            var message = _pipeline.CreateMessage();
 0130            var request = message.Request;
 0131            request.Method = RequestMethod.Get;
 0132            var uri = new RawRequestUriBuilder();
 0133            uri.AppendRaw(vaultBaseUrl, false);
 0134            uri.AppendRawNextLink(nextLink, false);
 0135            request.Uri = uri;
 0136            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        {
 0148            if (nextLink == null)
 149            {
 0150                throw new ArgumentNullException(nameof(nextLink));
 151            }
 0152            if (vaultBaseUrl == null)
 153            {
 0154                throw new ArgumentNullException(nameof(vaultBaseUrl));
 155            }
 0156            if (scope == null)
 157            {
 0158                throw new ArgumentNullException(nameof(scope));
 159            }
 160
 0161            using var message = CreateListNextPageRequest(nextLink, vaultBaseUrl, scope, filter);
 0162            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0163            switch (message.Response.Status)
 164            {
 165                case 200:
 166                    {
 167                        RoleDefinitionListResult value = default;
 0168                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0169                        value = RoleDefinitionListResult.DeserializeRoleDefinitionListResult(document.RootElement);
 0170                        return Response.FromValue(value, message.Response);
 171                    }
 172                default:
 0173                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 174            }
 0175        }
 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        {
 0186            if (nextLink == null)
 187            {
 0188                throw new ArgumentNullException(nameof(nextLink));
 189            }
 0190            if (vaultBaseUrl == null)
 191            {
 0192                throw new ArgumentNullException(nameof(vaultBaseUrl));
 193            }
 0194            if (scope == null)
 195            {
 0196                throw new ArgumentNullException(nameof(scope));
 197            }
 198
 0199            using var message = CreateListNextPageRequest(nextLink, vaultBaseUrl, scope, filter);
 0200            _pipeline.Send(message, cancellationToken);
 0201            switch (message.Response.Status)
 202            {
 203                case 200:
 204                    {
 205                        RoleDefinitionListResult value = default;
 0206                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0207                        value = RoleDefinitionListResult.DeserializeRoleDefinitionListResult(document.RootElement);
 0208                        return Response.FromValue(value, message.Response);
 209                    }
 210                default:
 0211                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 212            }
 0213        }
 214    }
 215}