< Summary

Class:Azure.ResourceManager.Network.ExpressRouteCircuitAuthorizationsRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\ExpressRouteCircuitAuthorizationsRestOperations.cs
Covered lines:0
Uncovered lines:234
Coverable lines:234
Total lines:529
Line coverage:0% (0 of 234)
Covered branches:0
Total branches:104
Branch coverage:0% (0 of 104)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateDeleteRequest(...)-0%100%
DeleteAsync()-0%0%
Delete(...)-0%0%
CreateGetRequest(...)-0%100%
GetAsync()-0%0%
Get(...)-0%0%
CreateCreateOrUpdateRequest(...)-0%100%
CreateOrUpdateAsync()-0%0%
CreateOrUpdate(...)-0%0%
CreateListRequest(...)-0%100%
ListAsync()-0%0%
List(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\ExpressRouteCircuitAuthorizationsRestOperations.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.ResourceManager.Network.Models;
 16
 17namespace Azure.ResourceManager.Network
 18{
 19    internal partial class ExpressRouteCircuitAuthorizationsRestOperations
 20    {
 21        private string subscriptionId;
 22        private Uri endpoint;
 23        private ClientDiagnostics _clientDiagnostics;
 24        private HttpPipeline _pipeline;
 25
 26        /// <summary> Initializes a new instance of ExpressRouteCircuitAuthorizationsRestOperations. </summary>
 27        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 28        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 29        /// <param name="subscriptionId"> The subscription credentials which uniquely identify the Microsoft Azure subsc
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 032        public ExpressRouteCircuitAuthorizationsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipelin
 33        {
 034            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 038            endpoint ??= new Uri("https://management.azure.com");
 39
 040            this.subscriptionId = subscriptionId;
 041            this.endpoint = endpoint;
 042            _clientDiagnostics = clientDiagnostics;
 043            _pipeline = pipeline;
 044        }
 45
 46        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string circuitName, string authorizationName)
 47        {
 048            var message = _pipeline.CreateMessage();
 049            var request = message.Request;
 050            request.Method = RequestMethod.Delete;
 051            var uri = new RawRequestUriBuilder();
 052            uri.Reset(endpoint);
 053            uri.AppendPath("/subscriptions/", false);
 054            uri.AppendPath(subscriptionId, true);
 055            uri.AppendPath("/resourceGroups/", false);
 056            uri.AppendPath(resourceGroupName, true);
 057            uri.AppendPath("/providers/Microsoft.Network/expressRouteCircuits/", false);
 058            uri.AppendPath(circuitName, true);
 059            uri.AppendPath("/authorizations/", false);
 060            uri.AppendPath(authorizationName, true);
 061            uri.AppendQuery("api-version", "2020-04-01", true);
 062            request.Uri = uri;
 063            return message;
 64        }
 65
 66        /// <summary> Deletes the specified authorization from the specified express route circuit. </summary>
 67        /// <param name="resourceGroupName"> The name of the resource group. </param>
 68        /// <param name="circuitName"> The name of the express route circuit. </param>
 69        /// <param name="authorizationName"> The name of the authorization. </param>
 70        /// <param name="cancellationToken"> The cancellation token to use. </param>
 71        public async Task<Response> DeleteAsync(string resourceGroupName, string circuitName, string authorizationName, 
 72        {
 073            if (resourceGroupName == null)
 74            {
 075                throw new ArgumentNullException(nameof(resourceGroupName));
 76            }
 077            if (circuitName == null)
 78            {
 079                throw new ArgumentNullException(nameof(circuitName));
 80            }
 081            if (authorizationName == null)
 82            {
 083                throw new ArgumentNullException(nameof(authorizationName));
 84            }
 85
 086            using var message = CreateDeleteRequest(resourceGroupName, circuitName, authorizationName);
 087            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 088            switch (message.Response.Status)
 89            {
 90                case 200:
 91                case 202:
 92                case 204:
 093                    return message.Response;
 94                default:
 095                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 96            }
 097        }
 98
 99        /// <summary> Deletes the specified authorization from the specified express route circuit. </summary>
 100        /// <param name="resourceGroupName"> The name of the resource group. </param>
 101        /// <param name="circuitName"> The name of the express route circuit. </param>
 102        /// <param name="authorizationName"> The name of the authorization. </param>
 103        /// <param name="cancellationToken"> The cancellation token to use. </param>
 104        public Response Delete(string resourceGroupName, string circuitName, string authorizationName, CancellationToken
 105        {
 0106            if (resourceGroupName == null)
 107            {
 0108                throw new ArgumentNullException(nameof(resourceGroupName));
 109            }
 0110            if (circuitName == null)
 111            {
 0112                throw new ArgumentNullException(nameof(circuitName));
 113            }
 0114            if (authorizationName == null)
 115            {
 0116                throw new ArgumentNullException(nameof(authorizationName));
 117            }
 118
 0119            using var message = CreateDeleteRequest(resourceGroupName, circuitName, authorizationName);
 0120            _pipeline.Send(message, cancellationToken);
 0121            switch (message.Response.Status)
 122            {
 123                case 200:
 124                case 202:
 125                case 204:
 0126                    return message.Response;
 127                default:
 0128                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 129            }
 0130        }
 131
 132        internal HttpMessage CreateGetRequest(string resourceGroupName, string circuitName, string authorizationName)
 133        {
 0134            var message = _pipeline.CreateMessage();
 0135            var request = message.Request;
 0136            request.Method = RequestMethod.Get;
 0137            var uri = new RawRequestUriBuilder();
 0138            uri.Reset(endpoint);
 0139            uri.AppendPath("/subscriptions/", false);
 0140            uri.AppendPath(subscriptionId, true);
 0141            uri.AppendPath("/resourceGroups/", false);
 0142            uri.AppendPath(resourceGroupName, true);
 0143            uri.AppendPath("/providers/Microsoft.Network/expressRouteCircuits/", false);
 0144            uri.AppendPath(circuitName, true);
 0145            uri.AppendPath("/authorizations/", false);
 0146            uri.AppendPath(authorizationName, true);
 0147            uri.AppendQuery("api-version", "2020-04-01", true);
 0148            request.Uri = uri;
 0149            return message;
 150        }
 151
 152        /// <summary> Gets the specified authorization from the specified express route circuit. </summary>
 153        /// <param name="resourceGroupName"> The name of the resource group. </param>
 154        /// <param name="circuitName"> The name of the express route circuit. </param>
 155        /// <param name="authorizationName"> The name of the authorization. </param>
 156        /// <param name="cancellationToken"> The cancellation token to use. </param>
 157        public async Task<Response<ExpressRouteCircuitAuthorization>> GetAsync(string resourceGroupName, string circuitN
 158        {
 0159            if (resourceGroupName == null)
 160            {
 0161                throw new ArgumentNullException(nameof(resourceGroupName));
 162            }
 0163            if (circuitName == null)
 164            {
 0165                throw new ArgumentNullException(nameof(circuitName));
 166            }
 0167            if (authorizationName == null)
 168            {
 0169                throw new ArgumentNullException(nameof(authorizationName));
 170            }
 171
 0172            using var message = CreateGetRequest(resourceGroupName, circuitName, authorizationName);
 0173            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0174            switch (message.Response.Status)
 175            {
 176                case 200:
 177                    {
 0178                        ExpressRouteCircuitAuthorization value = default;
 0179                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0180                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 181                        {
 0182                            value = null;
 183                        }
 184                        else
 185                        {
 0186                            value = ExpressRouteCircuitAuthorization.DeserializeExpressRouteCircuitAuthorization(documen
 187                        }
 0188                        return Response.FromValue(value, message.Response);
 189                    }
 190                default:
 0191                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 192            }
 0193        }
 194
 195        /// <summary> Gets the specified authorization from the specified express route circuit. </summary>
 196        /// <param name="resourceGroupName"> The name of the resource group. </param>
 197        /// <param name="circuitName"> The name of the express route circuit. </param>
 198        /// <param name="authorizationName"> The name of the authorization. </param>
 199        /// <param name="cancellationToken"> The cancellation token to use. </param>
 200        public Response<ExpressRouteCircuitAuthorization> Get(string resourceGroupName, string circuitName, string autho
 201        {
 0202            if (resourceGroupName == null)
 203            {
 0204                throw new ArgumentNullException(nameof(resourceGroupName));
 205            }
 0206            if (circuitName == null)
 207            {
 0208                throw new ArgumentNullException(nameof(circuitName));
 209            }
 0210            if (authorizationName == null)
 211            {
 0212                throw new ArgumentNullException(nameof(authorizationName));
 213            }
 214
 0215            using var message = CreateGetRequest(resourceGroupName, circuitName, authorizationName);
 0216            _pipeline.Send(message, cancellationToken);
 0217            switch (message.Response.Status)
 218            {
 219                case 200:
 220                    {
 0221                        ExpressRouteCircuitAuthorization value = default;
 0222                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0223                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 224                        {
 0225                            value = null;
 226                        }
 227                        else
 228                        {
 0229                            value = ExpressRouteCircuitAuthorization.DeserializeExpressRouteCircuitAuthorization(documen
 230                        }
 0231                        return Response.FromValue(value, message.Response);
 232                    }
 233                default:
 0234                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 235            }
 0236        }
 237
 238        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string circuitName, string authorizat
 239        {
 0240            var message = _pipeline.CreateMessage();
 0241            var request = message.Request;
 0242            request.Method = RequestMethod.Put;
 0243            var uri = new RawRequestUriBuilder();
 0244            uri.Reset(endpoint);
 0245            uri.AppendPath("/subscriptions/", false);
 0246            uri.AppendPath(subscriptionId, true);
 0247            uri.AppendPath("/resourceGroups/", false);
 0248            uri.AppendPath(resourceGroupName, true);
 0249            uri.AppendPath("/providers/Microsoft.Network/expressRouteCircuits/", false);
 0250            uri.AppendPath(circuitName, true);
 0251            uri.AppendPath("/authorizations/", false);
 0252            uri.AppendPath(authorizationName, true);
 0253            uri.AppendQuery("api-version", "2020-04-01", true);
 0254            request.Uri = uri;
 0255            request.Headers.Add("Content-Type", "application/json");
 0256            var content = new Utf8JsonRequestContent();
 0257            content.JsonWriter.WriteObjectValue(authorizationParameters);
 0258            request.Content = content;
 0259            return message;
 260        }
 261
 262        /// <summary> Creates or updates an authorization in the specified express route circuit. </summary>
 263        /// <param name="resourceGroupName"> The name of the resource group. </param>
 264        /// <param name="circuitName"> The name of the express route circuit. </param>
 265        /// <param name="authorizationName"> The name of the authorization. </param>
 266        /// <param name="authorizationParameters"> Parameters supplied to the create or update express route circuit aut
 267        /// <param name="cancellationToken"> The cancellation token to use. </param>
 268        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string circuitName, string authorizati
 269        {
 0270            if (resourceGroupName == null)
 271            {
 0272                throw new ArgumentNullException(nameof(resourceGroupName));
 273            }
 0274            if (circuitName == null)
 275            {
 0276                throw new ArgumentNullException(nameof(circuitName));
 277            }
 0278            if (authorizationName == null)
 279            {
 0280                throw new ArgumentNullException(nameof(authorizationName));
 281            }
 0282            if (authorizationParameters == null)
 283            {
 0284                throw new ArgumentNullException(nameof(authorizationParameters));
 285            }
 286
 0287            using var message = CreateCreateOrUpdateRequest(resourceGroupName, circuitName, authorizationName, authoriza
 0288            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0289            switch (message.Response.Status)
 290            {
 291                case 200:
 292                case 201:
 0293                    return message.Response;
 294                default:
 0295                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 296            }
 0297        }
 298
 299        /// <summary> Creates or updates an authorization in the specified express route circuit. </summary>
 300        /// <param name="resourceGroupName"> The name of the resource group. </param>
 301        /// <param name="circuitName"> The name of the express route circuit. </param>
 302        /// <param name="authorizationName"> The name of the authorization. </param>
 303        /// <param name="authorizationParameters"> Parameters supplied to the create or update express route circuit aut
 304        /// <param name="cancellationToken"> The cancellation token to use. </param>
 305        public Response CreateOrUpdate(string resourceGroupName, string circuitName, string authorizationName, ExpressRo
 306        {
 0307            if (resourceGroupName == null)
 308            {
 0309                throw new ArgumentNullException(nameof(resourceGroupName));
 310            }
 0311            if (circuitName == null)
 312            {
 0313                throw new ArgumentNullException(nameof(circuitName));
 314            }
 0315            if (authorizationName == null)
 316            {
 0317                throw new ArgumentNullException(nameof(authorizationName));
 318            }
 0319            if (authorizationParameters == null)
 320            {
 0321                throw new ArgumentNullException(nameof(authorizationParameters));
 322            }
 323
 0324            using var message = CreateCreateOrUpdateRequest(resourceGroupName, circuitName, authorizationName, authoriza
 0325            _pipeline.Send(message, cancellationToken);
 0326            switch (message.Response.Status)
 327            {
 328                case 200:
 329                case 201:
 0330                    return message.Response;
 331                default:
 0332                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 333            }
 0334        }
 335
 336        internal HttpMessage CreateListRequest(string resourceGroupName, string circuitName)
 337        {
 0338            var message = _pipeline.CreateMessage();
 0339            var request = message.Request;
 0340            request.Method = RequestMethod.Get;
 0341            var uri = new RawRequestUriBuilder();
 0342            uri.Reset(endpoint);
 0343            uri.AppendPath("/subscriptions/", false);
 0344            uri.AppendPath(subscriptionId, true);
 0345            uri.AppendPath("/resourceGroups/", false);
 0346            uri.AppendPath(resourceGroupName, true);
 0347            uri.AppendPath("/providers/Microsoft.Network/expressRouteCircuits/", false);
 0348            uri.AppendPath(circuitName, true);
 0349            uri.AppendPath("/authorizations", false);
 0350            uri.AppendQuery("api-version", "2020-04-01", true);
 0351            request.Uri = uri;
 0352            return message;
 353        }
 354
 355        /// <summary> Gets all authorizations in an express route circuit. </summary>
 356        /// <param name="resourceGroupName"> The name of the resource group. </param>
 357        /// <param name="circuitName"> The name of the circuit. </param>
 358        /// <param name="cancellationToken"> The cancellation token to use. </param>
 359        public async Task<Response<AuthorizationListResult>> ListAsync(string resourceGroupName, string circuitName, Can
 360        {
 0361            if (resourceGroupName == null)
 362            {
 0363                throw new ArgumentNullException(nameof(resourceGroupName));
 364            }
 0365            if (circuitName == null)
 366            {
 0367                throw new ArgumentNullException(nameof(circuitName));
 368            }
 369
 0370            using var message = CreateListRequest(resourceGroupName, circuitName);
 0371            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0372            switch (message.Response.Status)
 373            {
 374                case 200:
 375                    {
 0376                        AuthorizationListResult value = default;
 0377                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0378                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 379                        {
 0380                            value = null;
 381                        }
 382                        else
 383                        {
 0384                            value = AuthorizationListResult.DeserializeAuthorizationListResult(document.RootElement);
 385                        }
 0386                        return Response.FromValue(value, message.Response);
 387                    }
 388                default:
 0389                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 390            }
 0391        }
 392
 393        /// <summary> Gets all authorizations in an express route circuit. </summary>
 394        /// <param name="resourceGroupName"> The name of the resource group. </param>
 395        /// <param name="circuitName"> The name of the circuit. </param>
 396        /// <param name="cancellationToken"> The cancellation token to use. </param>
 397        public Response<AuthorizationListResult> List(string resourceGroupName, string circuitName, CancellationToken ca
 398        {
 0399            if (resourceGroupName == null)
 400            {
 0401                throw new ArgumentNullException(nameof(resourceGroupName));
 402            }
 0403            if (circuitName == null)
 404            {
 0405                throw new ArgumentNullException(nameof(circuitName));
 406            }
 407
 0408            using var message = CreateListRequest(resourceGroupName, circuitName);
 0409            _pipeline.Send(message, cancellationToken);
 0410            switch (message.Response.Status)
 411            {
 412                case 200:
 413                    {
 0414                        AuthorizationListResult value = default;
 0415                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0416                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 417                        {
 0418                            value = null;
 419                        }
 420                        else
 421                        {
 0422                            value = AuthorizationListResult.DeserializeAuthorizationListResult(document.RootElement);
 423                        }
 0424                        return Response.FromValue(value, message.Response);
 425                    }
 426                default:
 0427                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 428            }
 0429        }
 430
 431        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string circuitName)
 432        {
 0433            var message = _pipeline.CreateMessage();
 0434            var request = message.Request;
 0435            request.Method = RequestMethod.Get;
 0436            var uri = new RawRequestUriBuilder();
 0437            uri.Reset(endpoint);
 0438            uri.AppendRawNextLink(nextLink, false);
 0439            request.Uri = uri;
 0440            return message;
 441        }
 442
 443        /// <summary> Gets all authorizations in an express route circuit. </summary>
 444        /// <param name="nextLink"> The URL to the next page of results. </param>
 445        /// <param name="resourceGroupName"> The name of the resource group. </param>
 446        /// <param name="circuitName"> The name of the circuit. </param>
 447        /// <param name="cancellationToken"> The cancellation token to use. </param>
 448        public async Task<Response<AuthorizationListResult>> ListNextPageAsync(string nextLink, string resourceGroupName
 449        {
 0450            if (nextLink == null)
 451            {
 0452                throw new ArgumentNullException(nameof(nextLink));
 453            }
 0454            if (resourceGroupName == null)
 455            {
 0456                throw new ArgumentNullException(nameof(resourceGroupName));
 457            }
 0458            if (circuitName == null)
 459            {
 0460                throw new ArgumentNullException(nameof(circuitName));
 461            }
 462
 0463            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, circuitName);
 0464            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0465            switch (message.Response.Status)
 466            {
 467                case 200:
 468                    {
 0469                        AuthorizationListResult value = default;
 0470                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0471                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 472                        {
 0473                            value = null;
 474                        }
 475                        else
 476                        {
 0477                            value = AuthorizationListResult.DeserializeAuthorizationListResult(document.RootElement);
 478                        }
 0479                        return Response.FromValue(value, message.Response);
 480                    }
 481                default:
 0482                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 483            }
 0484        }
 485
 486        /// <summary> Gets all authorizations in an express route circuit. </summary>
 487        /// <param name="nextLink"> The URL to the next page of results. </param>
 488        /// <param name="resourceGroupName"> The name of the resource group. </param>
 489        /// <param name="circuitName"> The name of the circuit. </param>
 490        /// <param name="cancellationToken"> The cancellation token to use. </param>
 491        public Response<AuthorizationListResult> ListNextPage(string nextLink, string resourceGroupName, string circuitN
 492        {
 0493            if (nextLink == null)
 494            {
 0495                throw new ArgumentNullException(nameof(nextLink));
 496            }
 0497            if (resourceGroupName == null)
 498            {
 0499                throw new ArgumentNullException(nameof(resourceGroupName));
 500            }
 0501            if (circuitName == null)
 502            {
 0503                throw new ArgumentNullException(nameof(circuitName));
 504            }
 505
 0506            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, circuitName);
 0507            _pipeline.Send(message, cancellationToken);
 0508            switch (message.Response.Status)
 509            {
 510                case 200:
 511                    {
 0512                        AuthorizationListResult value = default;
 0513                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0514                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 515                        {
 0516                            value = null;
 517                        }
 518                        else
 519                        {
 0520                            value = AuthorizationListResult.DeserializeAuthorizationListResult(document.RootElement);
 521                        }
 0522                        return Response.FromValue(value, message.Response);
 523                    }
 524                default:
 0525                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 526            }
 0527        }
 528    }
 529}