< Summary

Class:Azure.ResourceManager.Resources.TagsRestOperations
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\TagsRestOperations.cs
Covered lines:287
Uncovered lines:87
Coverable lines:374
Total lines:833
Line coverage:76.7% (287 of 374)
Covered branches:62
Total branches:132
Branch coverage:46.9% (62 of 132)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateDeleteValueRequest(...)-100%100%
DeleteValueAsync()-70%50%
DeleteValue(...)-70%50%
CreateCreateOrUpdateValueRequest(...)-100%100%
CreateOrUpdateValueAsync()-80%62.5%
CreateOrUpdateValue(...)-80%62.5%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-76.92%50%
CreateOrUpdate(...)-76.92%50%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-75%50%
Delete(...)-75%50%
CreateListRequest()-100%100%
ListAsync()-81.82%50%
List(...)-81.82%50%
CreateCreateOrUpdateAtScopeRequest(...)-100%100%
CreateOrUpdateAtScopeAsync()-73.33%50%
CreateOrUpdateAtScope(...)-73.33%50%
CreateUpdateAtScopeRequest(...)-100%100%
UpdateAtScopeAsync()-73.33%50%
UpdateAtScope(...)-73.33%50%
CreateGetAtScopeRequest(...)-100%100%
GetAtScopeAsync()-76.92%50%
GetAtScope(...)-76.92%50%
CreateDeleteAtScopeRequest(...)-100%100%
DeleteAtScopeAsync()-75%50%
DeleteAtScope(...)-75%50%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\TagsRestOperations.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.Resources.Models;
 16
 17namespace Azure.ResourceManager.Resources
 18{
 19    internal partial class TagsRestOperations
 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 TagsRestOperations. </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 ID of the target subscription. </param>
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 25632        public TagsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri
 33        {
 25634            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 25638            endpoint ??= new Uri("https://management.azure.com");
 39
 25640            this.subscriptionId = subscriptionId;
 25641            this.endpoint = endpoint;
 25642            _clientDiagnostics = clientDiagnostics;
 25643            _pipeline = pipeline;
 25644        }
 45
 46        internal Core.HttpMessage CreateDeleteValueRequest(string tagName, string tagValue)
 47        {
 448            var message = _pipeline.CreateMessage();
 449            var request = message.Request;
 450            request.Method = RequestMethod.Delete;
 451            var uri = new RawRequestUriBuilder();
 452            uri.Reset(endpoint);
 453            uri.AppendPath("/subscriptions/", false);
 454            uri.AppendPath(subscriptionId, true);
 455            uri.AppendPath("/tagNames/", false);
 456            uri.AppendPath(tagName, true);
 457            uri.AppendPath("/tagValues/", false);
 458            uri.AppendPath(tagValue, true);
 459            uri.AppendQuery("api-version", "2019-10-01", true);
 460            request.Uri = uri;
 461            return message;
 62        }
 63
 64        /// <summary> This operation allows deleting a value from the list of predefined values for an existing predefin
 65        /// <param name="tagName"> The name of the tag. </param>
 66        /// <param name="tagValue"> The value of the tag to delete. </param>
 67        /// <param name="cancellationToken"> The cancellation token to use. </param>
 68        public async Task<Response> DeleteValueAsync(string tagName, string tagValue, CancellationToken cancellationToke
 69        {
 270            if (tagName == null)
 71            {
 072                throw new ArgumentNullException(nameof(tagName));
 73            }
 274            if (tagValue == null)
 75            {
 076                throw new ArgumentNullException(nameof(tagValue));
 77            }
 78
 279            using var message = CreateDeleteValueRequest(tagName, tagValue);
 280            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 281            switch (message.Response.Status)
 82            {
 83                case 200:
 84                case 204:
 285                    return message.Response;
 86                default:
 087                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 88            }
 289        }
 90
 91        /// <summary> This operation allows deleting a value from the list of predefined values for an existing predefin
 92        /// <param name="tagName"> The name of the tag. </param>
 93        /// <param name="tagValue"> The value of the tag to delete. </param>
 94        /// <param name="cancellationToken"> The cancellation token to use. </param>
 95        public Response DeleteValue(string tagName, string tagValue, CancellationToken cancellationToken = default)
 96        {
 297            if (tagName == null)
 98            {
 099                throw new ArgumentNullException(nameof(tagName));
 100            }
 2101            if (tagValue == null)
 102            {
 0103                throw new ArgumentNullException(nameof(tagValue));
 104            }
 105
 2106            using var message = CreateDeleteValueRequest(tagName, tagValue);
 2107            _pipeline.Send(message, cancellationToken);
 2108            switch (message.Response.Status)
 109            {
 110                case 200:
 111                case 204:
 2112                    return message.Response;
 113                default:
 0114                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 115            }
 2116        }
 117
 118        internal Core.HttpMessage CreateCreateOrUpdateValueRequest(string tagName, string tagValue)
 119        {
 8120            var message = _pipeline.CreateMessage();
 8121            var request = message.Request;
 8122            request.Method = RequestMethod.Put;
 8123            var uri = new RawRequestUriBuilder();
 8124            uri.Reset(endpoint);
 8125            uri.AppendPath("/subscriptions/", false);
 8126            uri.AppendPath(subscriptionId, true);
 8127            uri.AppendPath("/tagNames/", false);
 8128            uri.AppendPath(tagName, true);
 8129            uri.AppendPath("/tagValues/", false);
 8130            uri.AppendPath(tagValue, true);
 8131            uri.AppendQuery("api-version", "2019-10-01", true);
 8132            request.Uri = uri;
 8133            return message;
 134        }
 135
 136        /// <summary> This operation allows adding a value to the list of predefined values for an existing predefined t
 137        /// <param name="tagName"> The name of the tag. </param>
 138        /// <param name="tagValue"> The value of the tag to create. </param>
 139        /// <param name="cancellationToken"> The cancellation token to use. </param>
 140        public async Task<Response<TagValue>> CreateOrUpdateValueAsync(string tagName, string tagValue, CancellationToke
 141        {
 4142            if (tagName == null)
 143            {
 0144                throw new ArgumentNullException(nameof(tagName));
 145            }
 4146            if (tagValue == null)
 147            {
 0148                throw new ArgumentNullException(nameof(tagValue));
 149            }
 150
 4151            using var message = CreateCreateOrUpdateValueRequest(tagName, tagValue);
 4152            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4153            switch (message.Response.Status)
 154            {
 155                case 200:
 156                case 201:
 157                    {
 2158                        TagValue value = default;
 2159                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2160                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 161                        {
 0162                            value = null;
 163                        }
 164                        else
 165                        {
 2166                            value = TagValue.DeserializeTagValue(document.RootElement);
 167                        }
 2168                        return Response.FromValue(value, message.Response);
 169                    }
 170                default:
 2171                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 172            }
 2173        }
 174
 175        /// <summary> This operation allows adding a value to the list of predefined values for an existing predefined t
 176        /// <param name="tagName"> The name of the tag. </param>
 177        /// <param name="tagValue"> The value of the tag to create. </param>
 178        /// <param name="cancellationToken"> The cancellation token to use. </param>
 179        public Response<TagValue> CreateOrUpdateValue(string tagName, string tagValue, CancellationToken cancellationTok
 180        {
 4181            if (tagName == null)
 182            {
 0183                throw new ArgumentNullException(nameof(tagName));
 184            }
 4185            if (tagValue == null)
 186            {
 0187                throw new ArgumentNullException(nameof(tagValue));
 188            }
 189
 4190            using var message = CreateCreateOrUpdateValueRequest(tagName, tagValue);
 4191            _pipeline.Send(message, cancellationToken);
 4192            switch (message.Response.Status)
 193            {
 194                case 200:
 195                case 201:
 196                    {
 2197                        TagValue value = default;
 2198                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2199                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 200                        {
 0201                            value = null;
 202                        }
 203                        else
 204                        {
 2205                            value = TagValue.DeserializeTagValue(document.RootElement);
 206                        }
 2207                        return Response.FromValue(value, message.Response);
 208                    }
 209                default:
 2210                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 211            }
 2212        }
 213
 214        internal Core.HttpMessage CreateCreateOrUpdateRequest(string tagName)
 215        {
 8216            var message = _pipeline.CreateMessage();
 8217            var request = message.Request;
 8218            request.Method = RequestMethod.Put;
 8219            var uri = new RawRequestUriBuilder();
 8220            uri.Reset(endpoint);
 8221            uri.AppendPath("/subscriptions/", false);
 8222            uri.AppendPath(subscriptionId, true);
 8223            uri.AppendPath("/tagNames/", false);
 8224            uri.AppendPath(tagName, true);
 8225            uri.AppendQuery("api-version", "2019-10-01", true);
 8226            request.Uri = uri;
 8227            return message;
 228        }
 229
 230        /// <summary> This operation allows adding a name to the list of predefined tag names for the given subscription
 231        /// <param name="tagName"> The name of the tag to create. </param>
 232        /// <param name="cancellationToken"> The cancellation token to use. </param>
 233        public async Task<Response<TagDetails>> CreateOrUpdateAsync(string tagName, CancellationToken cancellationToken 
 234        {
 4235            if (tagName == null)
 236            {
 0237                throw new ArgumentNullException(nameof(tagName));
 238            }
 239
 4240            using var message = CreateCreateOrUpdateRequest(tagName);
 4241            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4242            switch (message.Response.Status)
 243            {
 244                case 200:
 245                case 201:
 246                    {
 4247                        TagDetails value = default;
 4248                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4249                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 250                        {
 0251                            value = null;
 252                        }
 253                        else
 254                        {
 4255                            value = TagDetails.DeserializeTagDetails(document.RootElement);
 256                        }
 4257                        return Response.FromValue(value, message.Response);
 258                    }
 259                default:
 0260                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 261            }
 4262        }
 263
 264        /// <summary> This operation allows adding a name to the list of predefined tag names for the given subscription
 265        /// <param name="tagName"> The name of the tag to create. </param>
 266        /// <param name="cancellationToken"> The cancellation token to use. </param>
 267        public Response<TagDetails> CreateOrUpdate(string tagName, CancellationToken cancellationToken = default)
 268        {
 4269            if (tagName == null)
 270            {
 0271                throw new ArgumentNullException(nameof(tagName));
 272            }
 273
 4274            using var message = CreateCreateOrUpdateRequest(tagName);
 4275            _pipeline.Send(message, cancellationToken);
 4276            switch (message.Response.Status)
 277            {
 278                case 200:
 279                case 201:
 280                    {
 4281                        TagDetails value = default;
 4282                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4283                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 284                        {
 0285                            value = null;
 286                        }
 287                        else
 288                        {
 4289                            value = TagDetails.DeserializeTagDetails(document.RootElement);
 290                        }
 4291                        return Response.FromValue(value, message.Response);
 292                    }
 293                default:
 0294                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 295            }
 4296        }
 297
 298        internal Core.HttpMessage CreateDeleteRequest(string tagName)
 299        {
 8300            var message = _pipeline.CreateMessage();
 8301            var request = message.Request;
 8302            request.Method = RequestMethod.Delete;
 8303            var uri = new RawRequestUriBuilder();
 8304            uri.Reset(endpoint);
 8305            uri.AppendPath("/subscriptions/", false);
 8306            uri.AppendPath(subscriptionId, true);
 8307            uri.AppendPath("/tagNames/", false);
 8308            uri.AppendPath(tagName, true);
 8309            uri.AppendQuery("api-version", "2019-10-01", true);
 8310            request.Uri = uri;
 8311            return message;
 312        }
 313
 314        /// <summary> This operation allows deleting a name from the list of predefined tag names for the given subscrip
 315        /// <param name="tagName"> The name of the tag. </param>
 316        /// <param name="cancellationToken"> The cancellation token to use. </param>
 317        public async Task<Response> DeleteAsync(string tagName, CancellationToken cancellationToken = default)
 318        {
 4319            if (tagName == null)
 320            {
 0321                throw new ArgumentNullException(nameof(tagName));
 322            }
 323
 4324            using var message = CreateDeleteRequest(tagName);
 4325            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4326            switch (message.Response.Status)
 327            {
 328                case 200:
 329                case 204:
 4330                    return message.Response;
 331                default:
 0332                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 333            }
 4334        }
 335
 336        /// <summary> This operation allows deleting a name from the list of predefined tag names for the given subscrip
 337        /// <param name="tagName"> The name of the tag. </param>
 338        /// <param name="cancellationToken"> The cancellation token to use. </param>
 339        public Response Delete(string tagName, CancellationToken cancellationToken = default)
 340        {
 4341            if (tagName == null)
 342            {
 0343                throw new ArgumentNullException(nameof(tagName));
 344            }
 345
 4346            using var message = CreateDeleteRequest(tagName);
 4347            _pipeline.Send(message, cancellationToken);
 4348            switch (message.Response.Status)
 349            {
 350                case 200:
 351                case 204:
 4352                    return message.Response;
 353                default:
 0354                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 355            }
 4356        }
 357
 358        internal Core.HttpMessage CreateListRequest()
 359        {
 8360            var message = _pipeline.CreateMessage();
 8361            var request = message.Request;
 8362            request.Method = RequestMethod.Get;
 8363            var uri = new RawRequestUriBuilder();
 8364            uri.Reset(endpoint);
 8365            uri.AppendPath("/subscriptions/", false);
 8366            uri.AppendPath(subscriptionId, true);
 8367            uri.AppendPath("/tagNames", false);
 8368            uri.AppendQuery("api-version", "2019-10-01", true);
 8369            request.Uri = uri;
 8370            return message;
 371        }
 372
 373        /// <summary> This operation performs a union of predefined tags, resource tags, resource group tags and subscri
 374        /// <param name="cancellationToken"> The cancellation token to use. </param>
 375        public async Task<Response<TagsListResult>> ListAsync(CancellationToken cancellationToken = default)
 376        {
 4377            using var message = CreateListRequest();
 4378            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4379            switch (message.Response.Status)
 380            {
 381                case 200:
 382                    {
 4383                        TagsListResult value = default;
 4384                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4385                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 386                        {
 0387                            value = null;
 388                        }
 389                        else
 390                        {
 4391                            value = TagsListResult.DeserializeTagsListResult(document.RootElement);
 392                        }
 4393                        return Response.FromValue(value, message.Response);
 394                    }
 395                default:
 0396                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 397            }
 4398        }
 399
 400        /// <summary> This operation performs a union of predefined tags, resource tags, resource group tags and subscri
 401        /// <param name="cancellationToken"> The cancellation token to use. </param>
 402        public Response<TagsListResult> List(CancellationToken cancellationToken = default)
 403        {
 4404            using var message = CreateListRequest();
 4405            _pipeline.Send(message, cancellationToken);
 4406            switch (message.Response.Status)
 407            {
 408                case 200:
 409                    {
 4410                        TagsListResult value = default;
 4411                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4412                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 413                        {
 0414                            value = null;
 415                        }
 416                        else
 417                        {
 4418                            value = TagsListResult.DeserializeTagsListResult(document.RootElement);
 419                        }
 4420                        return Response.FromValue(value, message.Response);
 421                    }
 422                default:
 0423                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 424            }
 4425        }
 426
 427        internal Core.HttpMessage CreateCreateOrUpdateAtScopeRequest(string scope, TagsResource parameters)
 428        {
 32429            var message = _pipeline.CreateMessage();
 32430            var request = message.Request;
 32431            request.Method = RequestMethod.Put;
 32432            var uri = new RawRequestUriBuilder();
 32433            uri.Reset(endpoint);
 32434            uri.AppendPath("/", false);
 32435            uri.AppendPath(scope, false);
 32436            uri.AppendPath("/providers/Microsoft.Resources/tags/default", false);
 32437            uri.AppendQuery("api-version", "2019-10-01", true);
 32438            request.Uri = uri;
 32439            request.Headers.Add("Content-Type", "application/json");
 32440            var content = new Utf8JsonRequestContent();
 32441            content.JsonWriter.WriteObjectValue(parameters);
 32442            request.Content = content;
 32443            return message;
 444        }
 445
 446        /// <summary> This operation allows adding or replacing the entire set of tags on the specified resource or subs
 447        /// <param name="scope"> The resource scope. </param>
 448        /// <param name="parameters"> The TagsResource to use. </param>
 449        /// <param name="cancellationToken"> The cancellation token to use. </param>
 450        public async Task<Response<TagsResource>> CreateOrUpdateAtScopeAsync(string scope, TagsResource parameters, Canc
 451        {
 16452            if (scope == null)
 453            {
 0454                throw new ArgumentNullException(nameof(scope));
 455            }
 16456            if (parameters == null)
 457            {
 0458                throw new ArgumentNullException(nameof(parameters));
 459            }
 460
 16461            using var message = CreateCreateOrUpdateAtScopeRequest(scope, parameters);
 16462            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 16463            switch (message.Response.Status)
 464            {
 465                case 200:
 466                    {
 16467                        TagsResource value = default;
 16468                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 16469                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 470                        {
 0471                            value = null;
 472                        }
 473                        else
 474                        {
 16475                            value = TagsResource.DeserializeTagsResource(document.RootElement);
 476                        }
 16477                        return Response.FromValue(value, message.Response);
 478                    }
 479                default:
 0480                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 481            }
 16482        }
 483
 484        /// <summary> This operation allows adding or replacing the entire set of tags on the specified resource or subs
 485        /// <param name="scope"> The resource scope. </param>
 486        /// <param name="parameters"> The TagsResource to use. </param>
 487        /// <param name="cancellationToken"> The cancellation token to use. </param>
 488        public Response<TagsResource> CreateOrUpdateAtScope(string scope, TagsResource parameters, CancellationToken can
 489        {
 16490            if (scope == null)
 491            {
 0492                throw new ArgumentNullException(nameof(scope));
 493            }
 16494            if (parameters == null)
 495            {
 0496                throw new ArgumentNullException(nameof(parameters));
 497            }
 498
 16499            using var message = CreateCreateOrUpdateAtScopeRequest(scope, parameters);
 16500            _pipeline.Send(message, cancellationToken);
 16501            switch (message.Response.Status)
 502            {
 503                case 200:
 504                    {
 16505                        TagsResource value = default;
 16506                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 16507                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 508                        {
 0509                            value = null;
 510                        }
 511                        else
 512                        {
 16513                            value = TagsResource.DeserializeTagsResource(document.RootElement);
 514                        }
 16515                        return Response.FromValue(value, message.Response);
 516                    }
 517                default:
 0518                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 519            }
 16520        }
 521
 522        internal Core.HttpMessage CreateUpdateAtScopeRequest(string scope, TagsPatchResource parameters)
 523        {
 24524            var message = _pipeline.CreateMessage();
 24525            var request = message.Request;
 24526            request.Method = RequestMethod.Patch;
 24527            var uri = new RawRequestUriBuilder();
 24528            uri.Reset(endpoint);
 24529            uri.AppendPath("/", false);
 24530            uri.AppendPath(scope, false);
 24531            uri.AppendPath("/providers/Microsoft.Resources/tags/default", false);
 24532            uri.AppendQuery("api-version", "2019-10-01", true);
 24533            request.Uri = uri;
 24534            request.Headers.Add("Content-Type", "application/json");
 24535            var content = new Utf8JsonRequestContent();
 24536            content.JsonWriter.WriteObjectValue(parameters);
 24537            request.Content = content;
 24538            return message;
 539        }
 540
 541        /// <summary> This operation allows replacing, merging or selectively deleting tags on the specified resource or
 542        /// <param name="scope"> The resource scope. </param>
 543        /// <param name="parameters"> The TagsPatchResource to use. </param>
 544        /// <param name="cancellationToken"> The cancellation token to use. </param>
 545        public async Task<Response<TagsResource>> UpdateAtScopeAsync(string scope, TagsPatchResource parameters, Cancell
 546        {
 12547            if (scope == null)
 548            {
 0549                throw new ArgumentNullException(nameof(scope));
 550            }
 12551            if (parameters == null)
 552            {
 0553                throw new ArgumentNullException(nameof(parameters));
 554            }
 555
 12556            using var message = CreateUpdateAtScopeRequest(scope, parameters);
 12557            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 12558            switch (message.Response.Status)
 559            {
 560                case 200:
 561                    {
 12562                        TagsResource value = default;
 12563                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 12564                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 565                        {
 0566                            value = null;
 567                        }
 568                        else
 569                        {
 12570                            value = TagsResource.DeserializeTagsResource(document.RootElement);
 571                        }
 12572                        return Response.FromValue(value, message.Response);
 573                    }
 574                default:
 0575                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 576            }
 12577        }
 578
 579        /// <summary> This operation allows replacing, merging or selectively deleting tags on the specified resource or
 580        /// <param name="scope"> The resource scope. </param>
 581        /// <param name="parameters"> The TagsPatchResource to use. </param>
 582        /// <param name="cancellationToken"> The cancellation token to use. </param>
 583        public Response<TagsResource> UpdateAtScope(string scope, TagsPatchResource parameters, CancellationToken cancel
 584        {
 12585            if (scope == null)
 586            {
 0587                throw new ArgumentNullException(nameof(scope));
 588            }
 12589            if (parameters == null)
 590            {
 0591                throw new ArgumentNullException(nameof(parameters));
 592            }
 593
 12594            using var message = CreateUpdateAtScopeRequest(scope, parameters);
 12595            _pipeline.Send(message, cancellationToken);
 12596            switch (message.Response.Status)
 597            {
 598                case 200:
 599                    {
 12600                        TagsResource value = default;
 12601                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 12602                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 603                        {
 0604                            value = null;
 605                        }
 606                        else
 607                        {
 12608                            value = TagsResource.DeserializeTagsResource(document.RootElement);
 609                        }
 12610                        return Response.FromValue(value, message.Response);
 611                    }
 612                default:
 0613                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 614            }
 12615        }
 616
 617        internal Core.HttpMessage CreateGetAtScopeRequest(string scope)
 618        {
 16619            var message = _pipeline.CreateMessage();
 16620            var request = message.Request;
 16621            request.Method = RequestMethod.Get;
 16622            var uri = new RawRequestUriBuilder();
 16623            uri.Reset(endpoint);
 16624            uri.AppendPath("/", false);
 16625            uri.AppendPath(scope, false);
 16626            uri.AppendPath("/providers/Microsoft.Resources/tags/default", false);
 16627            uri.AppendQuery("api-version", "2019-10-01", true);
 16628            request.Uri = uri;
 16629            return message;
 630        }
 631
 632        /// <summary> Gets the entire set of tags on a resource or subscription. </summary>
 633        /// <param name="scope"> The resource scope. </param>
 634        /// <param name="cancellationToken"> The cancellation token to use. </param>
 635        public async Task<Response<TagsResource>> GetAtScopeAsync(string scope, CancellationToken cancellationToken = de
 636        {
 8637            if (scope == null)
 638            {
 0639                throw new ArgumentNullException(nameof(scope));
 640            }
 641
 8642            using var message = CreateGetAtScopeRequest(scope);
 8643            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 8644            switch (message.Response.Status)
 645            {
 646                case 200:
 647                    {
 8648                        TagsResource value = default;
 8649                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 8650                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 651                        {
 0652                            value = null;
 653                        }
 654                        else
 655                        {
 8656                            value = TagsResource.DeserializeTagsResource(document.RootElement);
 657                        }
 8658                        return Response.FromValue(value, message.Response);
 659                    }
 660                default:
 0661                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 662            }
 8663        }
 664
 665        /// <summary> Gets the entire set of tags on a resource or subscription. </summary>
 666        /// <param name="scope"> The resource scope. </param>
 667        /// <param name="cancellationToken"> The cancellation token to use. </param>
 668        public Response<TagsResource> GetAtScope(string scope, CancellationToken cancellationToken = default)
 669        {
 8670            if (scope == null)
 671            {
 0672                throw new ArgumentNullException(nameof(scope));
 673            }
 674
 8675            using var message = CreateGetAtScopeRequest(scope);
 8676            _pipeline.Send(message, cancellationToken);
 8677            switch (message.Response.Status)
 678            {
 679                case 200:
 680                    {
 8681                        TagsResource value = default;
 8682                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 8683                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 684                        {
 0685                            value = null;
 686                        }
 687                        else
 688                        {
 8689                            value = TagsResource.DeserializeTagsResource(document.RootElement);
 690                        }
 8691                        return Response.FromValue(value, message.Response);
 692                    }
 693                default:
 0694                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 695            }
 8696        }
 697
 698        internal Core.HttpMessage CreateDeleteAtScopeRequest(string scope)
 699        {
 8700            var message = _pipeline.CreateMessage();
 8701            var request = message.Request;
 8702            request.Method = RequestMethod.Delete;
 8703            var uri = new RawRequestUriBuilder();
 8704            uri.Reset(endpoint);
 8705            uri.AppendPath("/", false);
 8706            uri.AppendPath(scope, false);
 8707            uri.AppendPath("/providers/Microsoft.Resources/tags/default", false);
 8708            uri.AppendQuery("api-version", "2019-10-01", true);
 8709            request.Uri = uri;
 8710            return message;
 711        }
 712
 713        /// <summary> Deletes the entire set of tags on a resource or subscription. </summary>
 714        /// <param name="scope"> The resource scope. </param>
 715        /// <param name="cancellationToken"> The cancellation token to use. </param>
 716        public async Task<Response> DeleteAtScopeAsync(string scope, CancellationToken cancellationToken = default)
 717        {
 4718            if (scope == null)
 719            {
 0720                throw new ArgumentNullException(nameof(scope));
 721            }
 722
 4723            using var message = CreateDeleteAtScopeRequest(scope);
 4724            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4725            switch (message.Response.Status)
 726            {
 727                case 200:
 4728                    return message.Response;
 729                default:
 0730                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 731            }
 4732        }
 733
 734        /// <summary> Deletes the entire set of tags on a resource or subscription. </summary>
 735        /// <param name="scope"> The resource scope. </param>
 736        /// <param name="cancellationToken"> The cancellation token to use. </param>
 737        public Response DeleteAtScope(string scope, CancellationToken cancellationToken = default)
 738        {
 4739            if (scope == null)
 740            {
 0741                throw new ArgumentNullException(nameof(scope));
 742            }
 743
 4744            using var message = CreateDeleteAtScopeRequest(scope);
 4745            _pipeline.Send(message, cancellationToken);
 4746            switch (message.Response.Status)
 747            {
 748                case 200:
 4749                    return message.Response;
 750                default:
 0751                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 752            }
 4753        }
 754
 755        internal Core.HttpMessage CreateListNextPageRequest(string nextLink)
 756        {
 0757            var message = _pipeline.CreateMessage();
 0758            var request = message.Request;
 0759            request.Method = RequestMethod.Get;
 0760            var uri = new RawRequestUriBuilder();
 0761            uri.Reset(endpoint);
 0762            uri.AppendRawNextLink(nextLink, false);
 0763            request.Uri = uri;
 0764            return message;
 765        }
 766
 767        /// <summary> This operation performs a union of predefined tags, resource tags, resource group tags and subscri
 768        /// <param name="nextLink"> The URL to the next page of results. </param>
 769        /// <param name="cancellationToken"> The cancellation token to use. </param>
 770        public async Task<Response<TagsListResult>> ListNextPageAsync(string nextLink, CancellationToken cancellationTok
 771        {
 0772            if (nextLink == null)
 773            {
 0774                throw new ArgumentNullException(nameof(nextLink));
 775            }
 776
 0777            using var message = CreateListNextPageRequest(nextLink);
 0778            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0779            switch (message.Response.Status)
 780            {
 781                case 200:
 782                    {
 0783                        TagsListResult value = default;
 0784                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0785                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 786                        {
 0787                            value = null;
 788                        }
 789                        else
 790                        {
 0791                            value = TagsListResult.DeserializeTagsListResult(document.RootElement);
 792                        }
 0793                        return Response.FromValue(value, message.Response);
 794                    }
 795                default:
 0796                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 797            }
 0798        }
 799
 800        /// <summary> This operation performs a union of predefined tags, resource tags, resource group tags and subscri
 801        /// <param name="nextLink"> The URL to the next page of results. </param>
 802        /// <param name="cancellationToken"> The cancellation token to use. </param>
 803        public Response<TagsListResult> ListNextPage(string nextLink, CancellationToken cancellationToken = default)
 804        {
 0805            if (nextLink == null)
 806            {
 0807                throw new ArgumentNullException(nameof(nextLink));
 808            }
 809
 0810            using var message = CreateListNextPageRequest(nextLink);
 0811            _pipeline.Send(message, cancellationToken);
 0812            switch (message.Response.Status)
 813            {
 814                case 200:
 815                    {
 0816                        TagsListResult value = default;
 0817                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0818                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 819                        {
 0820                            value = null;
 821                        }
 822                        else
 823                        {
 0824                            value = TagsListResult.DeserializeTagsListResult(document.RootElement);
 825                        }
 0826                        return Response.FromValue(value, message.Response);
 827                    }
 828                default:
 0829                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 830            }
 0831        }
 832    }
 833}