< Summary

Class:Azure.ResourceManager.Network.HubRouteTablesRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\HubRouteTablesRestOperations.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%
CreateCreateOrUpdateRequest(...)-0%100%
CreateOrUpdateAsync()-0%0%
CreateOrUpdate(...)-0%0%
CreateGetRequest(...)-0%100%
GetAsync()-0%0%
Get(...)-0%0%
CreateDeleteRequest(...)-0%100%
DeleteAsync()-0%0%
Delete(...)-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\HubRouteTablesRestOperations.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 HubRouteTablesRestOperations
 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 HubRouteTablesRestOperations. </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 HubRouteTablesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscript
 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 CreateCreateOrUpdateRequest(string resourceGroupName, string virtualHubName, string routeTa
 47        {
 048            var message = _pipeline.CreateMessage();
 049            var request = message.Request;
 050            request.Method = RequestMethod.Put;
 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/virtualHubs/", false);
 058            uri.AppendPath(virtualHubName, true);
 059            uri.AppendPath("/hubRouteTables/", false);
 060            uri.AppendPath(routeTableName, true);
 061            uri.AppendQuery("api-version", "2020-04-01", true);
 062            request.Uri = uri;
 063            request.Headers.Add("Content-Type", "application/json");
 064            var content = new Utf8JsonRequestContent();
 065            content.JsonWriter.WriteObjectValue(routeTableParameters);
 066            request.Content = content;
 067            return message;
 68        }
 69
 70        /// <summary> Creates a RouteTable resource if it doesn&apos;t exist else updates the existing RouteTable. </sum
 71        /// <param name="resourceGroupName"> The resource group name of the VirtualHub. </param>
 72        /// <param name="virtualHubName"> The name of the VirtualHub. </param>
 73        /// <param name="routeTableName"> The name of the RouteTable. </param>
 74        /// <param name="routeTableParameters"> Parameters supplied to create or update RouteTable. </param>
 75        /// <param name="cancellationToken"> The cancellation token to use. </param>
 76        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string virtualHubName, string routeTab
 77        {
 078            if (resourceGroupName == null)
 79            {
 080                throw new ArgumentNullException(nameof(resourceGroupName));
 81            }
 082            if (virtualHubName == null)
 83            {
 084                throw new ArgumentNullException(nameof(virtualHubName));
 85            }
 086            if (routeTableName == null)
 87            {
 088                throw new ArgumentNullException(nameof(routeTableName));
 89            }
 090            if (routeTableParameters == null)
 91            {
 092                throw new ArgumentNullException(nameof(routeTableParameters));
 93            }
 94
 095            using var message = CreateCreateOrUpdateRequest(resourceGroupName, virtualHubName, routeTableName, routeTabl
 096            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 097            switch (message.Response.Status)
 98            {
 99                case 200:
 100                case 201:
 0101                    return message.Response;
 102                default:
 0103                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 104            }
 0105        }
 106
 107        /// <summary> Creates a RouteTable resource if it doesn&apos;t exist else updates the existing RouteTable. </sum
 108        /// <param name="resourceGroupName"> The resource group name of the VirtualHub. </param>
 109        /// <param name="virtualHubName"> The name of the VirtualHub. </param>
 110        /// <param name="routeTableName"> The name of the RouteTable. </param>
 111        /// <param name="routeTableParameters"> Parameters supplied to create or update RouteTable. </param>
 112        /// <param name="cancellationToken"> The cancellation token to use. </param>
 113        public Response CreateOrUpdate(string resourceGroupName, string virtualHubName, string routeTableName, HubRouteT
 114        {
 0115            if (resourceGroupName == null)
 116            {
 0117                throw new ArgumentNullException(nameof(resourceGroupName));
 118            }
 0119            if (virtualHubName == null)
 120            {
 0121                throw new ArgumentNullException(nameof(virtualHubName));
 122            }
 0123            if (routeTableName == null)
 124            {
 0125                throw new ArgumentNullException(nameof(routeTableName));
 126            }
 0127            if (routeTableParameters == null)
 128            {
 0129                throw new ArgumentNullException(nameof(routeTableParameters));
 130            }
 131
 0132            using var message = CreateCreateOrUpdateRequest(resourceGroupName, virtualHubName, routeTableName, routeTabl
 0133            _pipeline.Send(message, cancellationToken);
 0134            switch (message.Response.Status)
 135            {
 136                case 200:
 137                case 201:
 0138                    return message.Response;
 139                default:
 0140                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 141            }
 0142        }
 143
 144        internal HttpMessage CreateGetRequest(string resourceGroupName, string virtualHubName, string routeTableName)
 145        {
 0146            var message = _pipeline.CreateMessage();
 0147            var request = message.Request;
 0148            request.Method = RequestMethod.Get;
 0149            var uri = new RawRequestUriBuilder();
 0150            uri.Reset(endpoint);
 0151            uri.AppendPath("/subscriptions/", false);
 0152            uri.AppendPath(subscriptionId, true);
 0153            uri.AppendPath("/resourceGroups/", false);
 0154            uri.AppendPath(resourceGroupName, true);
 0155            uri.AppendPath("/providers/Microsoft.Network/virtualHubs/", false);
 0156            uri.AppendPath(virtualHubName, true);
 0157            uri.AppendPath("/hubRouteTables/", false);
 0158            uri.AppendPath(routeTableName, true);
 0159            uri.AppendQuery("api-version", "2020-04-01", true);
 0160            request.Uri = uri;
 0161            return message;
 162        }
 163
 164        /// <summary> Retrieves the details of a RouteTable. </summary>
 165        /// <param name="resourceGroupName"> The resource group name of the VirtualHub. </param>
 166        /// <param name="virtualHubName"> The name of the VirtualHub. </param>
 167        /// <param name="routeTableName"> The name of the RouteTable. </param>
 168        /// <param name="cancellationToken"> The cancellation token to use. </param>
 169        public async Task<Response<HubRouteTable>> GetAsync(string resourceGroupName, string virtualHubName, string rout
 170        {
 0171            if (resourceGroupName == null)
 172            {
 0173                throw new ArgumentNullException(nameof(resourceGroupName));
 174            }
 0175            if (virtualHubName == null)
 176            {
 0177                throw new ArgumentNullException(nameof(virtualHubName));
 178            }
 0179            if (routeTableName == null)
 180            {
 0181                throw new ArgumentNullException(nameof(routeTableName));
 182            }
 183
 0184            using var message = CreateGetRequest(resourceGroupName, virtualHubName, routeTableName);
 0185            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0186            switch (message.Response.Status)
 187            {
 188                case 200:
 189                    {
 0190                        HubRouteTable value = default;
 0191                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0192                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 193                        {
 0194                            value = null;
 195                        }
 196                        else
 197                        {
 0198                            value = HubRouteTable.DeserializeHubRouteTable(document.RootElement);
 199                        }
 0200                        return Response.FromValue(value, message.Response);
 201                    }
 202                default:
 0203                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 204            }
 0205        }
 206
 207        /// <summary> Retrieves the details of a RouteTable. </summary>
 208        /// <param name="resourceGroupName"> The resource group name of the VirtualHub. </param>
 209        /// <param name="virtualHubName"> The name of the VirtualHub. </param>
 210        /// <param name="routeTableName"> The name of the RouteTable. </param>
 211        /// <param name="cancellationToken"> The cancellation token to use. </param>
 212        public Response<HubRouteTable> Get(string resourceGroupName, string virtualHubName, string routeTableName, Cance
 213        {
 0214            if (resourceGroupName == null)
 215            {
 0216                throw new ArgumentNullException(nameof(resourceGroupName));
 217            }
 0218            if (virtualHubName == null)
 219            {
 0220                throw new ArgumentNullException(nameof(virtualHubName));
 221            }
 0222            if (routeTableName == null)
 223            {
 0224                throw new ArgumentNullException(nameof(routeTableName));
 225            }
 226
 0227            using var message = CreateGetRequest(resourceGroupName, virtualHubName, routeTableName);
 0228            _pipeline.Send(message, cancellationToken);
 0229            switch (message.Response.Status)
 230            {
 231                case 200:
 232                    {
 0233                        HubRouteTable value = default;
 0234                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0235                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 236                        {
 0237                            value = null;
 238                        }
 239                        else
 240                        {
 0241                            value = HubRouteTable.DeserializeHubRouteTable(document.RootElement);
 242                        }
 0243                        return Response.FromValue(value, message.Response);
 244                    }
 245                default:
 0246                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 247            }
 0248        }
 249
 250        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string virtualHubName, string routeTableName)
 251        {
 0252            var message = _pipeline.CreateMessage();
 0253            var request = message.Request;
 0254            request.Method = RequestMethod.Delete;
 0255            var uri = new RawRequestUriBuilder();
 0256            uri.Reset(endpoint);
 0257            uri.AppendPath("/subscriptions/", false);
 0258            uri.AppendPath(subscriptionId, true);
 0259            uri.AppendPath("/resourceGroups/", false);
 0260            uri.AppendPath(resourceGroupName, true);
 0261            uri.AppendPath("/providers/Microsoft.Network/virtualHubs/", false);
 0262            uri.AppendPath(virtualHubName, true);
 0263            uri.AppendPath("/hubRouteTables/", false);
 0264            uri.AppendPath(routeTableName, true);
 0265            uri.AppendQuery("api-version", "2020-04-01", true);
 0266            request.Uri = uri;
 0267            return message;
 268        }
 269
 270        /// <summary> Deletes a RouteTable. </summary>
 271        /// <param name="resourceGroupName"> The resource group name of the RouteTable. </param>
 272        /// <param name="virtualHubName"> The name of the VirtualHub. </param>
 273        /// <param name="routeTableName"> The name of the RouteTable. </param>
 274        /// <param name="cancellationToken"> The cancellation token to use. </param>
 275        public async Task<Response> DeleteAsync(string resourceGroupName, string virtualHubName, string routeTableName, 
 276        {
 0277            if (resourceGroupName == null)
 278            {
 0279                throw new ArgumentNullException(nameof(resourceGroupName));
 280            }
 0281            if (virtualHubName == null)
 282            {
 0283                throw new ArgumentNullException(nameof(virtualHubName));
 284            }
 0285            if (routeTableName == null)
 286            {
 0287                throw new ArgumentNullException(nameof(routeTableName));
 288            }
 289
 0290            using var message = CreateDeleteRequest(resourceGroupName, virtualHubName, routeTableName);
 0291            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0292            switch (message.Response.Status)
 293            {
 294                case 200:
 295                case 202:
 296                case 204:
 0297                    return message.Response;
 298                default:
 0299                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 300            }
 0301        }
 302
 303        /// <summary> Deletes a RouteTable. </summary>
 304        /// <param name="resourceGroupName"> The resource group name of the RouteTable. </param>
 305        /// <param name="virtualHubName"> The name of the VirtualHub. </param>
 306        /// <param name="routeTableName"> The name of the RouteTable. </param>
 307        /// <param name="cancellationToken"> The cancellation token to use. </param>
 308        public Response Delete(string resourceGroupName, string virtualHubName, string routeTableName, CancellationToken
 309        {
 0310            if (resourceGroupName == null)
 311            {
 0312                throw new ArgumentNullException(nameof(resourceGroupName));
 313            }
 0314            if (virtualHubName == null)
 315            {
 0316                throw new ArgumentNullException(nameof(virtualHubName));
 317            }
 0318            if (routeTableName == null)
 319            {
 0320                throw new ArgumentNullException(nameof(routeTableName));
 321            }
 322
 0323            using var message = CreateDeleteRequest(resourceGroupName, virtualHubName, routeTableName);
 0324            _pipeline.Send(message, cancellationToken);
 0325            switch (message.Response.Status)
 326            {
 327                case 200:
 328                case 202:
 329                case 204:
 0330                    return message.Response;
 331                default:
 0332                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 333            }
 0334        }
 335
 336        internal HttpMessage CreateListRequest(string resourceGroupName, string virtualHubName)
 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/virtualHubs/", false);
 0348            uri.AppendPath(virtualHubName, true);
 0349            uri.AppendPath("/hubRouteTables", false);
 0350            uri.AppendQuery("api-version", "2020-04-01", true);
 0351            request.Uri = uri;
 0352            return message;
 353        }
 354
 355        /// <summary> Retrieves the details of all RouteTables. </summary>
 356        /// <param name="resourceGroupName"> The resource group name of the VirtualHub. </param>
 357        /// <param name="virtualHubName"> The name of the VirtualHub. </param>
 358        /// <param name="cancellationToken"> The cancellation token to use. </param>
 359        public async Task<Response<ListHubRouteTablesResult>> ListAsync(string resourceGroupName, string virtualHubName,
 360        {
 0361            if (resourceGroupName == null)
 362            {
 0363                throw new ArgumentNullException(nameof(resourceGroupName));
 364            }
 0365            if (virtualHubName == null)
 366            {
 0367                throw new ArgumentNullException(nameof(virtualHubName));
 368            }
 369
 0370            using var message = CreateListRequest(resourceGroupName, virtualHubName);
 0371            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0372            switch (message.Response.Status)
 373            {
 374                case 200:
 375                    {
 0376                        ListHubRouteTablesResult 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 = ListHubRouteTablesResult.DeserializeListHubRouteTablesResult(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> Retrieves the details of all RouteTables. </summary>
 394        /// <param name="resourceGroupName"> The resource group name of the VirtualHub. </param>
 395        /// <param name="virtualHubName"> The name of the VirtualHub. </param>
 396        /// <param name="cancellationToken"> The cancellation token to use. </param>
 397        public Response<ListHubRouteTablesResult> List(string resourceGroupName, string virtualHubName, CancellationToke
 398        {
 0399            if (resourceGroupName == null)
 400            {
 0401                throw new ArgumentNullException(nameof(resourceGroupName));
 402            }
 0403            if (virtualHubName == null)
 404            {
 0405                throw new ArgumentNullException(nameof(virtualHubName));
 406            }
 407
 0408            using var message = CreateListRequest(resourceGroupName, virtualHubName);
 0409            _pipeline.Send(message, cancellationToken);
 0410            switch (message.Response.Status)
 411            {
 412                case 200:
 413                    {
 0414                        ListHubRouteTablesResult 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 = ListHubRouteTablesResult.DeserializeListHubRouteTablesResult(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 virtualHubName)
 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> Retrieves the details of all RouteTables. </summary>
 444        /// <param name="nextLink"> The URL to the next page of results. </param>
 445        /// <param name="resourceGroupName"> The resource group name of the VirtualHub. </param>
 446        /// <param name="virtualHubName"> The name of the VirtualHub. </param>
 447        /// <param name="cancellationToken"> The cancellation token to use. </param>
 448        public async Task<Response<ListHubRouteTablesResult>> ListNextPageAsync(string nextLink, string resourceGroupNam
 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 (virtualHubName == null)
 459            {
 0460                throw new ArgumentNullException(nameof(virtualHubName));
 461            }
 462
 0463            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, virtualHubName);
 0464            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0465            switch (message.Response.Status)
 466            {
 467                case 200:
 468                    {
 0469                        ListHubRouteTablesResult 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 = ListHubRouteTablesResult.DeserializeListHubRouteTablesResult(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> Retrieves the details of all RouteTables. </summary>
 487        /// <param name="nextLink"> The URL to the next page of results. </param>
 488        /// <param name="resourceGroupName"> The resource group name of the VirtualHub. </param>
 489        /// <param name="virtualHubName"> The name of the VirtualHub. </param>
 490        /// <param name="cancellationToken"> The cancellation token to use. </param>
 491        public Response<ListHubRouteTablesResult> ListNextPage(string nextLink, string resourceGroupName, string virtual
 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 (virtualHubName == null)
 502            {
 0503                throw new ArgumentNullException(nameof(virtualHubName));
 504            }
 505
 0506            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, virtualHubName);
 0507            _pipeline.Send(message, cancellationToken);
 0508            switch (message.Response.Status)
 509            {
 510                case 200:
 511                    {
 0512                        ListHubRouteTablesResult 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 = ListHubRouteTablesResult.DeserializeListHubRouteTablesResult(document.RootElement);
 521                        }
 0522                        return Response.FromValue(value, message.Response);
 523                    }
 524                default:
 0525                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 526            }
 0527        }
 528    }
 529}