< Summary

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

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\RoutesRestOperations.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 RoutesRestOperations
 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 RoutesRestOperations. </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
 4432        public RoutesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, U
 33        {
 4434            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 4438            endpoint ??= new Uri("https://management.azure.com");
 39
 4440            this.subscriptionId = subscriptionId;
 4441            this.endpoint = endpoint;
 4442            _clientDiagnostics = clientDiagnostics;
 4443            _pipeline = pipeline;
 4444        }
 45
 46        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string routeTableName, string routeName)
 47        {
 1648            var message = _pipeline.CreateMessage();
 1649            var request = message.Request;
 1650            request.Method = RequestMethod.Delete;
 1651            var uri = new RawRequestUriBuilder();
 1652            uri.Reset(endpoint);
 1653            uri.AppendPath("/subscriptions/", false);
 1654            uri.AppendPath(subscriptionId, true);
 1655            uri.AppendPath("/resourceGroups/", false);
 1656            uri.AppendPath(resourceGroupName, true);
 1657            uri.AppendPath("/providers/Microsoft.Network/routeTables/", false);
 1658            uri.AppendPath(routeTableName, true);
 1659            uri.AppendPath("/routes/", false);
 1660            uri.AppendPath(routeName, true);
 1661            uri.AppendQuery("api-version", "2020-04-01", true);
 1662            request.Uri = uri;
 1663            return message;
 64        }
 65
 66        /// <summary> Deletes the specified route from a route table. </summary>
 67        /// <param name="resourceGroupName"> The name of the resource group. </param>
 68        /// <param name="routeTableName"> The name of the route table. </param>
 69        /// <param name="routeName"> The name of the route. </param>
 70        /// <param name="cancellationToken"> The cancellation token to use. </param>
 71        public async Task<Response> DeleteAsync(string resourceGroupName, string routeTableName, string routeName, Cance
 72        {
 473            if (resourceGroupName == null)
 74            {
 075                throw new ArgumentNullException(nameof(resourceGroupName));
 76            }
 477            if (routeTableName == null)
 78            {
 079                throw new ArgumentNullException(nameof(routeTableName));
 80            }
 481            if (routeName == null)
 82            {
 083                throw new ArgumentNullException(nameof(routeName));
 84            }
 85
 486            using var message = CreateDeleteRequest(resourceGroupName, routeTableName, routeName);
 487            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 488            switch (message.Response.Status)
 89            {
 90                case 200:
 91                case 202:
 92                case 204:
 493                    return message.Response;
 94                default:
 095                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 96            }
 497        }
 98
 99        /// <summary> Deletes the specified route from a route table. </summary>
 100        /// <param name="resourceGroupName"> The name of the resource group. </param>
 101        /// <param name="routeTableName"> The name of the route table. </param>
 102        /// <param name="routeName"> The name of the route. </param>
 103        /// <param name="cancellationToken"> The cancellation token to use. </param>
 104        public Response Delete(string resourceGroupName, string routeTableName, string routeName, CancellationToken canc
 105        {
 4106            if (resourceGroupName == null)
 107            {
 0108                throw new ArgumentNullException(nameof(resourceGroupName));
 109            }
 4110            if (routeTableName == null)
 111            {
 0112                throw new ArgumentNullException(nameof(routeTableName));
 113            }
 4114            if (routeName == null)
 115            {
 0116                throw new ArgumentNullException(nameof(routeName));
 117            }
 118
 4119            using var message = CreateDeleteRequest(resourceGroupName, routeTableName, routeName);
 4120            _pipeline.Send(message, cancellationToken);
 4121            switch (message.Response.Status)
 122            {
 123                case 200:
 124                case 202:
 125                case 204:
 4126                    return message.Response;
 127                default:
 0128                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 129            }
 4130        }
 131
 132        internal HttpMessage CreateGetRequest(string resourceGroupName, string routeTableName, string routeName)
 133        {
 8134            var message = _pipeline.CreateMessage();
 8135            var request = message.Request;
 8136            request.Method = RequestMethod.Get;
 8137            var uri = new RawRequestUriBuilder();
 8138            uri.Reset(endpoint);
 8139            uri.AppendPath("/subscriptions/", false);
 8140            uri.AppendPath(subscriptionId, true);
 8141            uri.AppendPath("/resourceGroups/", false);
 8142            uri.AppendPath(resourceGroupName, true);
 8143            uri.AppendPath("/providers/Microsoft.Network/routeTables/", false);
 8144            uri.AppendPath(routeTableName, true);
 8145            uri.AppendPath("/routes/", false);
 8146            uri.AppendPath(routeName, true);
 8147            uri.AppendQuery("api-version", "2020-04-01", true);
 8148            request.Uri = uri;
 8149            return message;
 150        }
 151
 152        /// <summary> Gets the specified route from a route table. </summary>
 153        /// <param name="resourceGroupName"> The name of the resource group. </param>
 154        /// <param name="routeTableName"> The name of the route table. </param>
 155        /// <param name="routeName"> The name of the route. </param>
 156        /// <param name="cancellationToken"> The cancellation token to use. </param>
 157        public async Task<Response<Route>> GetAsync(string resourceGroupName, string routeTableName, string routeName, C
 158        {
 4159            if (resourceGroupName == null)
 160            {
 0161                throw new ArgumentNullException(nameof(resourceGroupName));
 162            }
 4163            if (routeTableName == null)
 164            {
 0165                throw new ArgumentNullException(nameof(routeTableName));
 166            }
 4167            if (routeName == null)
 168            {
 0169                throw new ArgumentNullException(nameof(routeName));
 170            }
 171
 4172            using var message = CreateGetRequest(resourceGroupName, routeTableName, routeName);
 4173            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4174            switch (message.Response.Status)
 175            {
 176                case 200:
 177                    {
 4178                        Route value = default;
 4179                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4180                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 181                        {
 0182                            value = null;
 183                        }
 184                        else
 185                        {
 4186                            value = Route.DeserializeRoute(document.RootElement);
 187                        }
 4188                        return Response.FromValue(value, message.Response);
 189                    }
 190                default:
 0191                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 192            }
 4193        }
 194
 195        /// <summary> Gets the specified route from a route table. </summary>
 196        /// <param name="resourceGroupName"> The name of the resource group. </param>
 197        /// <param name="routeTableName"> The name of the route table. </param>
 198        /// <param name="routeName"> The name of the route. </param>
 199        /// <param name="cancellationToken"> The cancellation token to use. </param>
 200        public Response<Route> Get(string resourceGroupName, string routeTableName, string routeName, CancellationToken 
 201        {
 4202            if (resourceGroupName == null)
 203            {
 0204                throw new ArgumentNullException(nameof(resourceGroupName));
 205            }
 4206            if (routeTableName == null)
 207            {
 0208                throw new ArgumentNullException(nameof(routeTableName));
 209            }
 4210            if (routeName == null)
 211            {
 0212                throw new ArgumentNullException(nameof(routeName));
 213            }
 214
 4215            using var message = CreateGetRequest(resourceGroupName, routeTableName, routeName);
 4216            _pipeline.Send(message, cancellationToken);
 4217            switch (message.Response.Status)
 218            {
 219                case 200:
 220                    {
 4221                        Route value = default;
 4222                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4223                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 224                        {
 0225                            value = null;
 226                        }
 227                        else
 228                        {
 4229                            value = Route.DeserializeRoute(document.RootElement);
 230                        }
 4231                        return Response.FromValue(value, message.Response);
 232                    }
 233                default:
 0234                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 235            }
 4236        }
 237
 238        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string routeTableName, string routeNa
 239        {
 32240            var message = _pipeline.CreateMessage();
 32241            var request = message.Request;
 32242            request.Method = RequestMethod.Put;
 32243            var uri = new RawRequestUriBuilder();
 32244            uri.Reset(endpoint);
 32245            uri.AppendPath("/subscriptions/", false);
 32246            uri.AppendPath(subscriptionId, true);
 32247            uri.AppendPath("/resourceGroups/", false);
 32248            uri.AppendPath(resourceGroupName, true);
 32249            uri.AppendPath("/providers/Microsoft.Network/routeTables/", false);
 32250            uri.AppendPath(routeTableName, true);
 32251            uri.AppendPath("/routes/", false);
 32252            uri.AppendPath(routeName, true);
 32253            uri.AppendQuery("api-version", "2020-04-01", true);
 32254            request.Uri = uri;
 32255            request.Headers.Add("Content-Type", "application/json");
 32256            var content = new Utf8JsonRequestContent();
 32257            content.JsonWriter.WriteObjectValue(routeParameters);
 32258            request.Content = content;
 32259            return message;
 260        }
 261
 262        /// <summary> Creates or updates a route in the specified route table. </summary>
 263        /// <param name="resourceGroupName"> The name of the resource group. </param>
 264        /// <param name="routeTableName"> The name of the route table. </param>
 265        /// <param name="routeName"> The name of the route. </param>
 266        /// <param name="routeParameters"> Parameters supplied to the create or update route operation. </param>
 267        /// <param name="cancellationToken"> The cancellation token to use. </param>
 268        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string routeTableName, string routeNam
 269        {
 8270            if (resourceGroupName == null)
 271            {
 0272                throw new ArgumentNullException(nameof(resourceGroupName));
 273            }
 8274            if (routeTableName == null)
 275            {
 0276                throw new ArgumentNullException(nameof(routeTableName));
 277            }
 8278            if (routeName == null)
 279            {
 0280                throw new ArgumentNullException(nameof(routeName));
 281            }
 8282            if (routeParameters == null)
 283            {
 0284                throw new ArgumentNullException(nameof(routeParameters));
 285            }
 286
 8287            using var message = CreateCreateOrUpdateRequest(resourceGroupName, routeTableName, routeName, routeParameter
 8288            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 8289            switch (message.Response.Status)
 290            {
 291                case 200:
 292                case 201:
 8293                    return message.Response;
 294                default:
 0295                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 296            }
 8297        }
 298
 299        /// <summary> Creates or updates a route in the specified route table. </summary>
 300        /// <param name="resourceGroupName"> The name of the resource group. </param>
 301        /// <param name="routeTableName"> The name of the route table. </param>
 302        /// <param name="routeName"> The name of the route. </param>
 303        /// <param name="routeParameters"> Parameters supplied to the create or update route operation. </param>
 304        /// <param name="cancellationToken"> The cancellation token to use. </param>
 305        public Response CreateOrUpdate(string resourceGroupName, string routeTableName, string routeName, Route routePar
 306        {
 8307            if (resourceGroupName == null)
 308            {
 0309                throw new ArgumentNullException(nameof(resourceGroupName));
 310            }
 8311            if (routeTableName == null)
 312            {
 0313                throw new ArgumentNullException(nameof(routeTableName));
 314            }
 8315            if (routeName == null)
 316            {
 0317                throw new ArgumentNullException(nameof(routeName));
 318            }
 8319            if (routeParameters == null)
 320            {
 0321                throw new ArgumentNullException(nameof(routeParameters));
 322            }
 323
 8324            using var message = CreateCreateOrUpdateRequest(resourceGroupName, routeTableName, routeName, routeParameter
 8325            _pipeline.Send(message, cancellationToken);
 8326            switch (message.Response.Status)
 327            {
 328                case 200:
 329                case 201:
 8330                    return message.Response;
 331                default:
 0332                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 333            }
 8334        }
 335
 336        internal HttpMessage CreateListRequest(string resourceGroupName, string routeTableName)
 337        {
 12338            var message = _pipeline.CreateMessage();
 12339            var request = message.Request;
 12340            request.Method = RequestMethod.Get;
 12341            var uri = new RawRequestUriBuilder();
 12342            uri.Reset(endpoint);
 12343            uri.AppendPath("/subscriptions/", false);
 12344            uri.AppendPath(subscriptionId, true);
 12345            uri.AppendPath("/resourceGroups/", false);
 12346            uri.AppendPath(resourceGroupName, true);
 12347            uri.AppendPath("/providers/Microsoft.Network/routeTables/", false);
 12348            uri.AppendPath(routeTableName, true);
 12349            uri.AppendPath("/routes", false);
 12350            uri.AppendQuery("api-version", "2020-04-01", true);
 12351            request.Uri = uri;
 12352            return message;
 353        }
 354
 355        /// <summary> Gets all routes in a route table. </summary>
 356        /// <param name="resourceGroupName"> The name of the resource group. </param>
 357        /// <param name="routeTableName"> The name of the route table. </param>
 358        /// <param name="cancellationToken"> The cancellation token to use. </param>
 359        public async Task<Response<RouteListResult>> ListAsync(string resourceGroupName, string routeTableName, Cancella
 360        {
 6361            if (resourceGroupName == null)
 362            {
 0363                throw new ArgumentNullException(nameof(resourceGroupName));
 364            }
 6365            if (routeTableName == null)
 366            {
 0367                throw new ArgumentNullException(nameof(routeTableName));
 368            }
 369
 6370            using var message = CreateListRequest(resourceGroupName, routeTableName);
 6371            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 6372            switch (message.Response.Status)
 373            {
 374                case 200:
 375                    {
 6376                        RouteListResult value = default;
 6377                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 6378                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 379                        {
 0380                            value = null;
 381                        }
 382                        else
 383                        {
 6384                            value = RouteListResult.DeserializeRouteListResult(document.RootElement);
 385                        }
 6386                        return Response.FromValue(value, message.Response);
 387                    }
 388                default:
 0389                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 390            }
 6391        }
 392
 393        /// <summary> Gets all routes in a route table. </summary>
 394        /// <param name="resourceGroupName"> The name of the resource group. </param>
 395        /// <param name="routeTableName"> The name of the route table. </param>
 396        /// <param name="cancellationToken"> The cancellation token to use. </param>
 397        public Response<RouteListResult> List(string resourceGroupName, string routeTableName, CancellationToken cancell
 398        {
 6399            if (resourceGroupName == null)
 400            {
 0401                throw new ArgumentNullException(nameof(resourceGroupName));
 402            }
 6403            if (routeTableName == null)
 404            {
 0405                throw new ArgumentNullException(nameof(routeTableName));
 406            }
 407
 6408            using var message = CreateListRequest(resourceGroupName, routeTableName);
 6409            _pipeline.Send(message, cancellationToken);
 6410            switch (message.Response.Status)
 411            {
 412                case 200:
 413                    {
 6414                        RouteListResult value = default;
 6415                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 6416                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 417                        {
 0418                            value = null;
 419                        }
 420                        else
 421                        {
 6422                            value = RouteListResult.DeserializeRouteListResult(document.RootElement);
 423                        }
 6424                        return Response.FromValue(value, message.Response);
 425                    }
 426                default:
 0427                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 428            }
 6429        }
 430
 431        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string routeTableName)
 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 routes in a route table. </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="routeTableName"> The name of the route table. </param>
 447        /// <param name="cancellationToken"> The cancellation token to use. </param>
 448        public async Task<Response<RouteListResult>> ListNextPageAsync(string nextLink, string resourceGroupName, string
 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 (routeTableName == null)
 459            {
 0460                throw new ArgumentNullException(nameof(routeTableName));
 461            }
 462
 0463            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, routeTableName);
 0464            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0465            switch (message.Response.Status)
 466            {
 467                case 200:
 468                    {
 0469                        RouteListResult 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 = RouteListResult.DeserializeRouteListResult(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 routes in a route table. </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="routeTableName"> The name of the route table. </param>
 490        /// <param name="cancellationToken"> The cancellation token to use. </param>
 491        public Response<RouteListResult> ListNextPage(string nextLink, string resourceGroupName, string routeTableName, 
 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 (routeTableName == null)
 502            {
 0503                throw new ArgumentNullException(nameof(routeTableName));
 504            }
 505
 0506            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, routeTableName);
 0507            _pipeline.Send(message, cancellationToken);
 0508            switch (message.Response.Status)
 509            {
 510                case 200:
 511                    {
 0512                        RouteListResult 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 = RouteListResult.DeserializeRouteListResult(document.RootElement);
 521                        }
 0522                        return Response.FromValue(value, message.Response);
 523                    }
 524                default:
 0525                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 526            }
 0527        }
 528    }
 529}