< Summary

Class:Azure.ResourceManager.Resources.PolicySetDefinitionsRestOperations
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\PolicySetDefinitionsRestOperations.cs
Covered lines:192
Uncovered lines:296
Coverable lines:488
Total lines:1097
Line coverage:39.3% (192 of 488)
Covered branches:42
Total branches:176
Branch coverage:23.8% (42 of 176)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-80%62.5%
CreateOrUpdate(...)-80%62.5%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-75%66.67%
Delete(...)-75%66.67%
CreateGetRequest(...)-100%100%
GetAsync()-84.62%66.67%
Get(...)-84.62%66.67%
CreateGetBuiltInRequest(...)-100%100%
GetBuiltInAsync()-76.92%50%
GetBuiltIn(...)-76.92%50%
CreateListRequest()-100%100%
ListAsync()-81.82%50%
List(...)-81.82%50%
CreateListBuiltInRequest()-100%100%
ListBuiltInAsync()-81.82%50%
ListBuiltIn(...)-81.82%50%
CreateCreateOrUpdateAtManagementGroupRequest(...)-0%100%
CreateOrUpdateAtManagementGroupAsync()-0%0%
CreateOrUpdateAtManagementGroup(...)-0%0%
CreateDeleteAtManagementGroupRequest(...)-0%100%
DeleteAtManagementGroupAsync()-0%0%
DeleteAtManagementGroup(...)-0%0%
CreateGetAtManagementGroupRequest(...)-0%100%
GetAtManagementGroupAsync()-0%0%
GetAtManagementGroup(...)-0%0%
CreateListByManagementGroupRequest(...)-0%100%
ListByManagementGroupAsync()-0%0%
ListByManagementGroup(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%
CreateListBuiltInNextPageRequest(...)-0%100%
ListBuiltInNextPageAsync()-0%0%
ListBuiltInNextPage(...)-0%0%
CreateListByManagementGroupNextPageRequest(...)-0%100%
ListByManagementGroupNextPageAsync()-0%0%
ListByManagementGroupNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\PolicySetDefinitionsRestOperations.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 PolicySetDefinitionsRestOperations
 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 PolicySetDefinitionsRestOperations. </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 PolicySetDefinitionsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string sub
 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 CreateCreateOrUpdateRequest(string policySetDefinitionName, PolicySetDefinition parame
 47        {
 3248            var message = _pipeline.CreateMessage();
 3249            var request = message.Request;
 3250            request.Method = RequestMethod.Put;
 3251            var uri = new RawRequestUriBuilder();
 3252            uri.Reset(endpoint);
 3253            uri.AppendPath("/subscriptions/", false);
 3254            uri.AppendPath(subscriptionId, true);
 3255            uri.AppendPath("/providers/Microsoft.Authorization/policySetDefinitions/", false);
 3256            uri.AppendPath(policySetDefinitionName, true);
 3257            uri.AppendQuery("api-version", "2019-09-01", true);
 3258            request.Uri = uri;
 3259            request.Headers.Add("Content-Type", "application/json");
 3260            var content = new Utf8JsonRequestContent();
 3261            content.JsonWriter.WriteObjectValue(parameters);
 3262            request.Content = content;
 3263            return message;
 64        }
 65
 66        /// <summary> This operation creates or updates a policy set definition in the given subscription with the given
 67        /// <param name="policySetDefinitionName"> The name of the policy set definition to create. </param>
 68        /// <param name="parameters"> The policy set definition properties. </param>
 69        /// <param name="cancellationToken"> The cancellation token to use. </param>
 70        public async Task<Response<PolicySetDefinition>> CreateOrUpdateAsync(string policySetDefinitionName, PolicySetDe
 71        {
 1672            if (policySetDefinitionName == null)
 73            {
 074                throw new ArgumentNullException(nameof(policySetDefinitionName));
 75            }
 1676            if (parameters == null)
 77            {
 078                throw new ArgumentNullException(nameof(parameters));
 79            }
 80
 1681            using var message = CreateCreateOrUpdateRequest(policySetDefinitionName, parameters);
 1682            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 1683            switch (message.Response.Status)
 84            {
 85                case 200:
 86                case 201:
 87                    {
 888                        PolicySetDefinition value = default;
 889                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 890                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 91                        {
 092                            value = null;
 93                        }
 94                        else
 95                        {
 896                            value = PolicySetDefinition.DeserializePolicySetDefinition(document.RootElement);
 97                        }
 898                        return Response.FromValue(value, message.Response);
 99                    }
 100                default:
 8101                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 102            }
 8103        }
 104
 105        /// <summary> This operation creates or updates a policy set definition in the given subscription with the given
 106        /// <param name="policySetDefinitionName"> The name of the policy set definition to create. </param>
 107        /// <param name="parameters"> The policy set definition properties. </param>
 108        /// <param name="cancellationToken"> The cancellation token to use. </param>
 109        public Response<PolicySetDefinition> CreateOrUpdate(string policySetDefinitionName, PolicySetDefinition paramete
 110        {
 16111            if (policySetDefinitionName == null)
 112            {
 0113                throw new ArgumentNullException(nameof(policySetDefinitionName));
 114            }
 16115            if (parameters == null)
 116            {
 0117                throw new ArgumentNullException(nameof(parameters));
 118            }
 119
 16120            using var message = CreateCreateOrUpdateRequest(policySetDefinitionName, parameters);
 16121            _pipeline.Send(message, cancellationToken);
 16122            switch (message.Response.Status)
 123            {
 124                case 200:
 125                case 201:
 126                    {
 8127                        PolicySetDefinition value = default;
 8128                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 8129                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 130                        {
 0131                            value = null;
 132                        }
 133                        else
 134                        {
 8135                            value = PolicySetDefinition.DeserializePolicySetDefinition(document.RootElement);
 136                        }
 8137                        return Response.FromValue(value, message.Response);
 138                    }
 139                default:
 8140                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 141            }
 8142        }
 143
 144        internal Core.HttpMessage CreateDeleteRequest(string policySetDefinitionName)
 145        {
 188146            var message = _pipeline.CreateMessage();
 188147            var request = message.Request;
 188148            request.Method = RequestMethod.Delete;
 188149            var uri = new RawRequestUriBuilder();
 188150            uri.Reset(endpoint);
 188151            uri.AppendPath("/subscriptions/", false);
 188152            uri.AppendPath(subscriptionId, true);
 188153            uri.AppendPath("/providers/Microsoft.Authorization/policySetDefinitions/", false);
 188154            uri.AppendPath(policySetDefinitionName, true);
 188155            uri.AppendQuery("api-version", "2019-09-01", true);
 188156            request.Uri = uri;
 188157            return message;
 158        }
 159
 160        /// <summary> This operation deletes the policy set definition in the given subscription with the given name. </
 161        /// <param name="policySetDefinitionName"> The name of the policy set definition to delete. </param>
 162        /// <param name="cancellationToken"> The cancellation token to use. </param>
 163        public async Task<Response> DeleteAsync(string policySetDefinitionName, CancellationToken cancellationToken = de
 164        {
 94165            if (policySetDefinitionName == null)
 166            {
 0167                throw new ArgumentNullException(nameof(policySetDefinitionName));
 168            }
 169
 94170            using var message = CreateDeleteRequest(policySetDefinitionName);
 94171            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 94172            switch (message.Response.Status)
 173            {
 174                case 200:
 175                case 204:
 94176                    return message.Response;
 177                default:
 0178                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 179            }
 94180        }
 181
 182        /// <summary> This operation deletes the policy set definition in the given subscription with the given name. </
 183        /// <param name="policySetDefinitionName"> The name of the policy set definition to delete. </param>
 184        /// <param name="cancellationToken"> The cancellation token to use. </param>
 185        public Response Delete(string policySetDefinitionName, CancellationToken cancellationToken = default)
 186        {
 94187            if (policySetDefinitionName == null)
 188            {
 0189                throw new ArgumentNullException(nameof(policySetDefinitionName));
 190            }
 191
 94192            using var message = CreateDeleteRequest(policySetDefinitionName);
 94193            _pipeline.Send(message, cancellationToken);
 94194            switch (message.Response.Status)
 195            {
 196                case 200:
 197                case 204:
 94198                    return message.Response;
 199                default:
 0200                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 201            }
 94202        }
 203
 204        internal Core.HttpMessage CreateGetRequest(string policySetDefinitionName)
 205        {
 28206            var message = _pipeline.CreateMessage();
 28207            var request = message.Request;
 28208            request.Method = RequestMethod.Get;
 28209            var uri = new RawRequestUriBuilder();
 28210            uri.Reset(endpoint);
 28211            uri.AppendPath("/subscriptions/", false);
 28212            uri.AppendPath(subscriptionId, true);
 28213            uri.AppendPath("/providers/Microsoft.Authorization/policySetDefinitions/", false);
 28214            uri.AppendPath(policySetDefinitionName, true);
 28215            uri.AppendQuery("api-version", "2019-09-01", true);
 28216            request.Uri = uri;
 28217            return message;
 218        }
 219
 220        /// <summary> This operation retrieves the policy set definition in the given subscription with the given name. 
 221        /// <param name="policySetDefinitionName"> The name of the policy set definition to get. </param>
 222        /// <param name="cancellationToken"> The cancellation token to use. </param>
 223        public async Task<Response<PolicySetDefinition>> GetAsync(string policySetDefinitionName, CancellationToken canc
 224        {
 14225            if (policySetDefinitionName == null)
 226            {
 0227                throw new ArgumentNullException(nameof(policySetDefinitionName));
 228            }
 229
 14230            using var message = CreateGetRequest(policySetDefinitionName);
 14231            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 14232            switch (message.Response.Status)
 233            {
 234                case 200:
 235                    {
 8236                        PolicySetDefinition value = default;
 8237                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 8238                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 239                        {
 0240                            value = null;
 241                        }
 242                        else
 243                        {
 8244                            value = PolicySetDefinition.DeserializePolicySetDefinition(document.RootElement);
 245                        }
 8246                        return Response.FromValue(value, message.Response);
 247                    }
 248                default:
 6249                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 250            }
 8251        }
 252
 253        /// <summary> This operation retrieves the policy set definition in the given subscription with the given name. 
 254        /// <param name="policySetDefinitionName"> The name of the policy set definition to get. </param>
 255        /// <param name="cancellationToken"> The cancellation token to use. </param>
 256        public Response<PolicySetDefinition> Get(string policySetDefinitionName, CancellationToken cancellationToken = d
 257        {
 14258            if (policySetDefinitionName == null)
 259            {
 0260                throw new ArgumentNullException(nameof(policySetDefinitionName));
 261            }
 262
 14263            using var message = CreateGetRequest(policySetDefinitionName);
 14264            _pipeline.Send(message, cancellationToken);
 14265            switch (message.Response.Status)
 266            {
 267                case 200:
 268                    {
 8269                        PolicySetDefinition value = default;
 8270                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 8271                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 272                        {
 0273                            value = null;
 274                        }
 275                        else
 276                        {
 8277                            value = PolicySetDefinition.DeserializePolicySetDefinition(document.RootElement);
 278                        }
 8279                        return Response.FromValue(value, message.Response);
 280                    }
 281                default:
 6282                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 283            }
 8284        }
 285
 286        internal Core.HttpMessage CreateGetBuiltInRequest(string policySetDefinitionName)
 287        {
 176288            var message = _pipeline.CreateMessage();
 176289            var request = message.Request;
 176290            request.Method = RequestMethod.Get;
 176291            var uri = new RawRequestUriBuilder();
 176292            uri.Reset(endpoint);
 176293            uri.AppendPath("/providers/Microsoft.Authorization/policySetDefinitions/", false);
 176294            uri.AppendPath(policySetDefinitionName, true);
 176295            uri.AppendQuery("api-version", "2019-09-01", true);
 176296            request.Uri = uri;
 176297            return message;
 298        }
 299
 300        /// <summary> This operation retrieves the built-in policy set definition with the given name. </summary>
 301        /// <param name="policySetDefinitionName"> The name of the policy set definition to get. </param>
 302        /// <param name="cancellationToken"> The cancellation token to use. </param>
 303        public async Task<Response<PolicySetDefinition>> GetBuiltInAsync(string policySetDefinitionName, CancellationTok
 304        {
 88305            if (policySetDefinitionName == null)
 306            {
 0307                throw new ArgumentNullException(nameof(policySetDefinitionName));
 308            }
 309
 88310            using var message = CreateGetBuiltInRequest(policySetDefinitionName);
 88311            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 88312            switch (message.Response.Status)
 313            {
 314                case 200:
 315                    {
 88316                        PolicySetDefinition value = default;
 88317                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 88318                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 319                        {
 0320                            value = null;
 321                        }
 322                        else
 323                        {
 88324                            value = PolicySetDefinition.DeserializePolicySetDefinition(document.RootElement);
 325                        }
 88326                        return Response.FromValue(value, message.Response);
 327                    }
 328                default:
 0329                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 330            }
 88331        }
 332
 333        /// <summary> This operation retrieves the built-in policy set definition with the given name. </summary>
 334        /// <param name="policySetDefinitionName"> The name of the policy set definition to get. </param>
 335        /// <param name="cancellationToken"> The cancellation token to use. </param>
 336        public Response<PolicySetDefinition> GetBuiltIn(string policySetDefinitionName, CancellationToken cancellationTo
 337        {
 88338            if (policySetDefinitionName == null)
 339            {
 0340                throw new ArgumentNullException(nameof(policySetDefinitionName));
 341            }
 342
 88343            using var message = CreateGetBuiltInRequest(policySetDefinitionName);
 88344            _pipeline.Send(message, cancellationToken);
 88345            switch (message.Response.Status)
 346            {
 347                case 200:
 348                    {
 88349                        PolicySetDefinition value = default;
 88350                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 88351                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 352                        {
 0353                            value = null;
 354                        }
 355                        else
 356                        {
 88357                            value = PolicySetDefinition.DeserializePolicySetDefinition(document.RootElement);
 358                        }
 88359                        return Response.FromValue(value, message.Response);
 360                    }
 361                default:
 0362                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 363            }
 88364        }
 365
 366        internal Core.HttpMessage CreateListRequest()
 367        {
 16368            var message = _pipeline.CreateMessage();
 16369            var request = message.Request;
 16370            request.Method = RequestMethod.Get;
 16371            var uri = new RawRequestUriBuilder();
 16372            uri.Reset(endpoint);
 16373            uri.AppendPath("/subscriptions/", false);
 16374            uri.AppendPath(subscriptionId, true);
 16375            uri.AppendPath("/providers/Microsoft.Authorization/policySetDefinitions", false);
 16376            uri.AppendQuery("api-version", "2019-09-01", true);
 16377            request.Uri = uri;
 16378            return message;
 379        }
 380
 381        /// <summary> This operation retrieves a list of all the policy set definitions in the given subscription. </sum
 382        /// <param name="cancellationToken"> The cancellation token to use. </param>
 383        public async Task<Response<PolicySetDefinitionListResult>> ListAsync(CancellationToken cancellationToken = defau
 384        {
 8385            using var message = CreateListRequest();
 8386            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 8387            switch (message.Response.Status)
 388            {
 389                case 200:
 390                    {
 8391                        PolicySetDefinitionListResult value = default;
 8392                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 8393                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 394                        {
 0395                            value = null;
 396                        }
 397                        else
 398                        {
 8399                            value = PolicySetDefinitionListResult.DeserializePolicySetDefinitionListResult(document.Root
 400                        }
 8401                        return Response.FromValue(value, message.Response);
 402                    }
 403                default:
 0404                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 405            }
 8406        }
 407
 408        /// <summary> This operation retrieves a list of all the policy set definitions in the given subscription. </sum
 409        /// <param name="cancellationToken"> The cancellation token to use. </param>
 410        public Response<PolicySetDefinitionListResult> List(CancellationToken cancellationToken = default)
 411        {
 8412            using var message = CreateListRequest();
 8413            _pipeline.Send(message, cancellationToken);
 8414            switch (message.Response.Status)
 415            {
 416                case 200:
 417                    {
 8418                        PolicySetDefinitionListResult value = default;
 8419                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 8420                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 421                        {
 0422                            value = null;
 423                        }
 424                        else
 425                        {
 8426                            value = PolicySetDefinitionListResult.DeserializePolicySetDefinitionListResult(document.Root
 427                        }
 8428                        return Response.FromValue(value, message.Response);
 429                    }
 430                default:
 0431                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 432            }
 8433        }
 434
 435        internal Core.HttpMessage CreateListBuiltInRequest()
 436        {
 12437            var message = _pipeline.CreateMessage();
 12438            var request = message.Request;
 12439            request.Method = RequestMethod.Get;
 12440            var uri = new RawRequestUriBuilder();
 12441            uri.Reset(endpoint);
 12442            uri.AppendPath("/providers/Microsoft.Authorization/policySetDefinitions", false);
 12443            uri.AppendQuery("api-version", "2019-09-01", true);
 12444            request.Uri = uri;
 12445            return message;
 446        }
 447
 448        /// <summary> This operation retrieves a list of all the built-in policy set definitions. </summary>
 449        /// <param name="cancellationToken"> The cancellation token to use. </param>
 450        public async Task<Response<PolicySetDefinitionListResult>> ListBuiltInAsync(CancellationToken cancellationToken 
 451        {
 6452            using var message = CreateListBuiltInRequest();
 6453            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 6454            switch (message.Response.Status)
 455            {
 456                case 200:
 457                    {
 6458                        PolicySetDefinitionListResult value = default;
 6459                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 6460                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 461                        {
 0462                            value = null;
 463                        }
 464                        else
 465                        {
 6466                            value = PolicySetDefinitionListResult.DeserializePolicySetDefinitionListResult(document.Root
 467                        }
 6468                        return Response.FromValue(value, message.Response);
 469                    }
 470                default:
 0471                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 472            }
 6473        }
 474
 475        /// <summary> This operation retrieves a list of all the built-in policy set definitions. </summary>
 476        /// <param name="cancellationToken"> The cancellation token to use. </param>
 477        public Response<PolicySetDefinitionListResult> ListBuiltIn(CancellationToken cancellationToken = default)
 478        {
 6479            using var message = CreateListBuiltInRequest();
 6480            _pipeline.Send(message, cancellationToken);
 6481            switch (message.Response.Status)
 482            {
 483                case 200:
 484                    {
 6485                        PolicySetDefinitionListResult value = default;
 6486                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 6487                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 488                        {
 0489                            value = null;
 490                        }
 491                        else
 492                        {
 6493                            value = PolicySetDefinitionListResult.DeserializePolicySetDefinitionListResult(document.Root
 494                        }
 6495                        return Response.FromValue(value, message.Response);
 496                    }
 497                default:
 0498                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 499            }
 6500        }
 501
 502        internal Core.HttpMessage CreateCreateOrUpdateAtManagementGroupRequest(string policySetDefinitionName, string ma
 503        {
 0504            var message = _pipeline.CreateMessage();
 0505            var request = message.Request;
 0506            request.Method = RequestMethod.Put;
 0507            var uri = new RawRequestUriBuilder();
 0508            uri.Reset(endpoint);
 0509            uri.AppendPath("/providers/Microsoft.Management/managementgroups/", false);
 0510            uri.AppendPath(managementGroupId, true);
 0511            uri.AppendPath("/providers/Microsoft.Authorization/policySetDefinitions/", false);
 0512            uri.AppendPath(policySetDefinitionName, true);
 0513            uri.AppendQuery("api-version", "2019-09-01", true);
 0514            request.Uri = uri;
 0515            request.Headers.Add("Content-Type", "application/json");
 0516            var content = new Utf8JsonRequestContent();
 0517            content.JsonWriter.WriteObjectValue(parameters);
 0518            request.Content = content;
 0519            return message;
 520        }
 521
 522        /// <summary> This operation creates or updates a policy set definition in the given management group with the g
 523        /// <param name="policySetDefinitionName"> The name of the policy set definition to create. </param>
 524        /// <param name="managementGroupId"> The ID of the management group. </param>
 525        /// <param name="parameters"> The policy set definition properties. </param>
 526        /// <param name="cancellationToken"> The cancellation token to use. </param>
 527        public async Task<Response<PolicySetDefinition>> CreateOrUpdateAtManagementGroupAsync(string policySetDefinition
 528        {
 0529            if (policySetDefinitionName == null)
 530            {
 0531                throw new ArgumentNullException(nameof(policySetDefinitionName));
 532            }
 0533            if (managementGroupId == null)
 534            {
 0535                throw new ArgumentNullException(nameof(managementGroupId));
 536            }
 0537            if (parameters == null)
 538            {
 0539                throw new ArgumentNullException(nameof(parameters));
 540            }
 541
 0542            using var message = CreateCreateOrUpdateAtManagementGroupRequest(policySetDefinitionName, managementGroupId,
 0543            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0544            switch (message.Response.Status)
 545            {
 546                case 200:
 547                case 201:
 548                    {
 0549                        PolicySetDefinition value = default;
 0550                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0551                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 552                        {
 0553                            value = null;
 554                        }
 555                        else
 556                        {
 0557                            value = PolicySetDefinition.DeserializePolicySetDefinition(document.RootElement);
 558                        }
 0559                        return Response.FromValue(value, message.Response);
 560                    }
 561                default:
 0562                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 563            }
 0564        }
 565
 566        /// <summary> This operation creates or updates a policy set definition in the given management group with the g
 567        /// <param name="policySetDefinitionName"> The name of the policy set definition to create. </param>
 568        /// <param name="managementGroupId"> The ID of the management group. </param>
 569        /// <param name="parameters"> The policy set definition properties. </param>
 570        /// <param name="cancellationToken"> The cancellation token to use. </param>
 571        public Response<PolicySetDefinition> CreateOrUpdateAtManagementGroup(string policySetDefinitionName, string mana
 572        {
 0573            if (policySetDefinitionName == null)
 574            {
 0575                throw new ArgumentNullException(nameof(policySetDefinitionName));
 576            }
 0577            if (managementGroupId == null)
 578            {
 0579                throw new ArgumentNullException(nameof(managementGroupId));
 580            }
 0581            if (parameters == null)
 582            {
 0583                throw new ArgumentNullException(nameof(parameters));
 584            }
 585
 0586            using var message = CreateCreateOrUpdateAtManagementGroupRequest(policySetDefinitionName, managementGroupId,
 0587            _pipeline.Send(message, cancellationToken);
 0588            switch (message.Response.Status)
 589            {
 590                case 200:
 591                case 201:
 592                    {
 0593                        PolicySetDefinition value = default;
 0594                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0595                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 596                        {
 0597                            value = null;
 598                        }
 599                        else
 600                        {
 0601                            value = PolicySetDefinition.DeserializePolicySetDefinition(document.RootElement);
 602                        }
 0603                        return Response.FromValue(value, message.Response);
 604                    }
 605                default:
 0606                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 607            }
 0608        }
 609
 610        internal Core.HttpMessage CreateDeleteAtManagementGroupRequest(string policySetDefinitionName, string management
 611        {
 0612            var message = _pipeline.CreateMessage();
 0613            var request = message.Request;
 0614            request.Method = RequestMethod.Delete;
 0615            var uri = new RawRequestUriBuilder();
 0616            uri.Reset(endpoint);
 0617            uri.AppendPath("/providers/Microsoft.Management/managementgroups/", false);
 0618            uri.AppendPath(managementGroupId, true);
 0619            uri.AppendPath("/providers/Microsoft.Authorization/policySetDefinitions/", false);
 0620            uri.AppendPath(policySetDefinitionName, true);
 0621            uri.AppendQuery("api-version", "2019-09-01", true);
 0622            request.Uri = uri;
 0623            return message;
 624        }
 625
 626        /// <summary> This operation deletes the policy set definition in the given management group with the given name
 627        /// <param name="policySetDefinitionName"> The name of the policy set definition to delete. </param>
 628        /// <param name="managementGroupId"> The ID of the management group. </param>
 629        /// <param name="cancellationToken"> The cancellation token to use. </param>
 630        public async Task<Response> DeleteAtManagementGroupAsync(string policySetDefinitionName, string managementGroupI
 631        {
 0632            if (policySetDefinitionName == null)
 633            {
 0634                throw new ArgumentNullException(nameof(policySetDefinitionName));
 635            }
 0636            if (managementGroupId == null)
 637            {
 0638                throw new ArgumentNullException(nameof(managementGroupId));
 639            }
 640
 0641            using var message = CreateDeleteAtManagementGroupRequest(policySetDefinitionName, managementGroupId);
 0642            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0643            switch (message.Response.Status)
 644            {
 645                case 200:
 646                case 204:
 0647                    return message.Response;
 648                default:
 0649                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 650            }
 0651        }
 652
 653        /// <summary> This operation deletes the policy set definition in the given management group with the given name
 654        /// <param name="policySetDefinitionName"> The name of the policy set definition to delete. </param>
 655        /// <param name="managementGroupId"> The ID of the management group. </param>
 656        /// <param name="cancellationToken"> The cancellation token to use. </param>
 657        public Response DeleteAtManagementGroup(string policySetDefinitionName, string managementGroupId, CancellationTo
 658        {
 0659            if (policySetDefinitionName == null)
 660            {
 0661                throw new ArgumentNullException(nameof(policySetDefinitionName));
 662            }
 0663            if (managementGroupId == null)
 664            {
 0665                throw new ArgumentNullException(nameof(managementGroupId));
 666            }
 667
 0668            using var message = CreateDeleteAtManagementGroupRequest(policySetDefinitionName, managementGroupId);
 0669            _pipeline.Send(message, cancellationToken);
 0670            switch (message.Response.Status)
 671            {
 672                case 200:
 673                case 204:
 0674                    return message.Response;
 675                default:
 0676                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 677            }
 0678        }
 679
 680        internal Core.HttpMessage CreateGetAtManagementGroupRequest(string policySetDefinitionName, string managementGro
 681        {
 0682            var message = _pipeline.CreateMessage();
 0683            var request = message.Request;
 0684            request.Method = RequestMethod.Get;
 0685            var uri = new RawRequestUriBuilder();
 0686            uri.Reset(endpoint);
 0687            uri.AppendPath("/providers/Microsoft.Management/managementgroups/", false);
 0688            uri.AppendPath(managementGroupId, true);
 0689            uri.AppendPath("/providers/Microsoft.Authorization/policySetDefinitions/", false);
 0690            uri.AppendPath(policySetDefinitionName, true);
 0691            uri.AppendQuery("api-version", "2019-09-01", true);
 0692            request.Uri = uri;
 0693            return message;
 694        }
 695
 696        /// <summary> This operation retrieves the policy set definition in the given management group with the given na
 697        /// <param name="policySetDefinitionName"> The name of the policy set definition to get. </param>
 698        /// <param name="managementGroupId"> The ID of the management group. </param>
 699        /// <param name="cancellationToken"> The cancellation token to use. </param>
 700        public async Task<Response<PolicySetDefinition>> GetAtManagementGroupAsync(string policySetDefinitionName, strin
 701        {
 0702            if (policySetDefinitionName == null)
 703            {
 0704                throw new ArgumentNullException(nameof(policySetDefinitionName));
 705            }
 0706            if (managementGroupId == null)
 707            {
 0708                throw new ArgumentNullException(nameof(managementGroupId));
 709            }
 710
 0711            using var message = CreateGetAtManagementGroupRequest(policySetDefinitionName, managementGroupId);
 0712            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0713            switch (message.Response.Status)
 714            {
 715                case 200:
 716                    {
 0717                        PolicySetDefinition value = default;
 0718                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0719                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 720                        {
 0721                            value = null;
 722                        }
 723                        else
 724                        {
 0725                            value = PolicySetDefinition.DeserializePolicySetDefinition(document.RootElement);
 726                        }
 0727                        return Response.FromValue(value, message.Response);
 728                    }
 729                default:
 0730                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 731            }
 0732        }
 733
 734        /// <summary> This operation retrieves the policy set definition in the given management group with the given na
 735        /// <param name="policySetDefinitionName"> The name of the policy set definition to get. </param>
 736        /// <param name="managementGroupId"> The ID of the management group. </param>
 737        /// <param name="cancellationToken"> The cancellation token to use. </param>
 738        public Response<PolicySetDefinition> GetAtManagementGroup(string policySetDefinitionName, string managementGroup
 739        {
 0740            if (policySetDefinitionName == null)
 741            {
 0742                throw new ArgumentNullException(nameof(policySetDefinitionName));
 743            }
 0744            if (managementGroupId == null)
 745            {
 0746                throw new ArgumentNullException(nameof(managementGroupId));
 747            }
 748
 0749            using var message = CreateGetAtManagementGroupRequest(policySetDefinitionName, managementGroupId);
 0750            _pipeline.Send(message, cancellationToken);
 0751            switch (message.Response.Status)
 752            {
 753                case 200:
 754                    {
 0755                        PolicySetDefinition value = default;
 0756                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0757                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 758                        {
 0759                            value = null;
 760                        }
 761                        else
 762                        {
 0763                            value = PolicySetDefinition.DeserializePolicySetDefinition(document.RootElement);
 764                        }
 0765                        return Response.FromValue(value, message.Response);
 766                    }
 767                default:
 0768                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 769            }
 0770        }
 771
 772        internal Core.HttpMessage CreateListByManagementGroupRequest(string managementGroupId)
 773        {
 0774            var message = _pipeline.CreateMessage();
 0775            var request = message.Request;
 0776            request.Method = RequestMethod.Get;
 0777            var uri = new RawRequestUriBuilder();
 0778            uri.Reset(endpoint);
 0779            uri.AppendPath("/providers/Microsoft.Management/managementgroups/", false);
 0780            uri.AppendPath(managementGroupId, true);
 0781            uri.AppendPath("/providers/Microsoft.Authorization/policySetDefinitions", false);
 0782            uri.AppendQuery("api-version", "2019-09-01", true);
 0783            request.Uri = uri;
 0784            return message;
 785        }
 786
 787        /// <summary> This operation retrieves a list of all the a policy set definition in the given management group. 
 788        /// <param name="managementGroupId"> The ID of the management group. </param>
 789        /// <param name="cancellationToken"> The cancellation token to use. </param>
 790        public async Task<Response<PolicySetDefinitionListResult>> ListByManagementGroupAsync(string managementGroupId, 
 791        {
 0792            if (managementGroupId == null)
 793            {
 0794                throw new ArgumentNullException(nameof(managementGroupId));
 795            }
 796
 0797            using var message = CreateListByManagementGroupRequest(managementGroupId);
 0798            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0799            switch (message.Response.Status)
 800            {
 801                case 200:
 802                    {
 0803                        PolicySetDefinitionListResult value = default;
 0804                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0805                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 806                        {
 0807                            value = null;
 808                        }
 809                        else
 810                        {
 0811                            value = PolicySetDefinitionListResult.DeserializePolicySetDefinitionListResult(document.Root
 812                        }
 0813                        return Response.FromValue(value, message.Response);
 814                    }
 815                default:
 0816                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 817            }
 0818        }
 819
 820        /// <summary> This operation retrieves a list of all the a policy set definition in the given management group. 
 821        /// <param name="managementGroupId"> The ID of the management group. </param>
 822        /// <param name="cancellationToken"> The cancellation token to use. </param>
 823        public Response<PolicySetDefinitionListResult> ListByManagementGroup(string managementGroupId, CancellationToken
 824        {
 0825            if (managementGroupId == null)
 826            {
 0827                throw new ArgumentNullException(nameof(managementGroupId));
 828            }
 829
 0830            using var message = CreateListByManagementGroupRequest(managementGroupId);
 0831            _pipeline.Send(message, cancellationToken);
 0832            switch (message.Response.Status)
 833            {
 834                case 200:
 835                    {
 0836                        PolicySetDefinitionListResult value = default;
 0837                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0838                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 839                        {
 0840                            value = null;
 841                        }
 842                        else
 843                        {
 0844                            value = PolicySetDefinitionListResult.DeserializePolicySetDefinitionListResult(document.Root
 845                        }
 0846                        return Response.FromValue(value, message.Response);
 847                    }
 848                default:
 0849                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 850            }
 0851        }
 852
 853        internal Core.HttpMessage CreateListNextPageRequest(string nextLink)
 854        {
 0855            var message = _pipeline.CreateMessage();
 0856            var request = message.Request;
 0857            request.Method = RequestMethod.Get;
 0858            var uri = new RawRequestUriBuilder();
 0859            uri.Reset(endpoint);
 0860            uri.AppendRawNextLink(nextLink, false);
 0861            request.Uri = uri;
 0862            return message;
 863        }
 864
 865        /// <summary> This operation retrieves a list of all the policy set definitions in the given subscription. </sum
 866        /// <param name="nextLink"> The URL to the next page of results. </param>
 867        /// <param name="cancellationToken"> The cancellation token to use. </param>
 868        public async Task<Response<PolicySetDefinitionListResult>> ListNextPageAsync(string nextLink, CancellationToken 
 869        {
 0870            if (nextLink == null)
 871            {
 0872                throw new ArgumentNullException(nameof(nextLink));
 873            }
 874
 0875            using var message = CreateListNextPageRequest(nextLink);
 0876            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0877            switch (message.Response.Status)
 878            {
 879                case 200:
 880                    {
 0881                        PolicySetDefinitionListResult value = default;
 0882                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0883                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 884                        {
 0885                            value = null;
 886                        }
 887                        else
 888                        {
 0889                            value = PolicySetDefinitionListResult.DeserializePolicySetDefinitionListResult(document.Root
 890                        }
 0891                        return Response.FromValue(value, message.Response);
 892                    }
 893                default:
 0894                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 895            }
 0896        }
 897
 898        /// <summary> This operation retrieves a list of all the policy set definitions in the given subscription. </sum
 899        /// <param name="nextLink"> The URL to the next page of results. </param>
 900        /// <param name="cancellationToken"> The cancellation token to use. </param>
 901        public Response<PolicySetDefinitionListResult> ListNextPage(string nextLink, CancellationToken cancellationToken
 902        {
 0903            if (nextLink == null)
 904            {
 0905                throw new ArgumentNullException(nameof(nextLink));
 906            }
 907
 0908            using var message = CreateListNextPageRequest(nextLink);
 0909            _pipeline.Send(message, cancellationToken);
 0910            switch (message.Response.Status)
 911            {
 912                case 200:
 913                    {
 0914                        PolicySetDefinitionListResult value = default;
 0915                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0916                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 917                        {
 0918                            value = null;
 919                        }
 920                        else
 921                        {
 0922                            value = PolicySetDefinitionListResult.DeserializePolicySetDefinitionListResult(document.Root
 923                        }
 0924                        return Response.FromValue(value, message.Response);
 925                    }
 926                default:
 0927                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 928            }
 0929        }
 930
 931        internal Core.HttpMessage CreateListBuiltInNextPageRequest(string nextLink)
 932        {
 0933            var message = _pipeline.CreateMessage();
 0934            var request = message.Request;
 0935            request.Method = RequestMethod.Get;
 0936            var uri = new RawRequestUriBuilder();
 0937            uri.Reset(endpoint);
 0938            uri.AppendRawNextLink(nextLink, false);
 0939            request.Uri = uri;
 0940            return message;
 941        }
 942
 943        /// <summary> This operation retrieves a list of all the built-in policy set definitions. </summary>
 944        /// <param name="nextLink"> The URL to the next page of results. </param>
 945        /// <param name="cancellationToken"> The cancellation token to use. </param>
 946        public async Task<Response<PolicySetDefinitionListResult>> ListBuiltInNextPageAsync(string nextLink, Cancellatio
 947        {
 0948            if (nextLink == null)
 949            {
 0950                throw new ArgumentNullException(nameof(nextLink));
 951            }
 952
 0953            using var message = CreateListBuiltInNextPageRequest(nextLink);
 0954            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0955            switch (message.Response.Status)
 956            {
 957                case 200:
 958                    {
 0959                        PolicySetDefinitionListResult value = default;
 0960                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0961                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 962                        {
 0963                            value = null;
 964                        }
 965                        else
 966                        {
 0967                            value = PolicySetDefinitionListResult.DeserializePolicySetDefinitionListResult(document.Root
 968                        }
 0969                        return Response.FromValue(value, message.Response);
 970                    }
 971                default:
 0972                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 973            }
 0974        }
 975
 976        /// <summary> This operation retrieves a list of all the built-in policy set definitions. </summary>
 977        /// <param name="nextLink"> The URL to the next page of results. </param>
 978        /// <param name="cancellationToken"> The cancellation token to use. </param>
 979        public Response<PolicySetDefinitionListResult> ListBuiltInNextPage(string nextLink, CancellationToken cancellati
 980        {
 0981            if (nextLink == null)
 982            {
 0983                throw new ArgumentNullException(nameof(nextLink));
 984            }
 985
 0986            using var message = CreateListBuiltInNextPageRequest(nextLink);
 0987            _pipeline.Send(message, cancellationToken);
 0988            switch (message.Response.Status)
 989            {
 990                case 200:
 991                    {
 0992                        PolicySetDefinitionListResult value = default;
 0993                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0994                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 995                        {
 0996                            value = null;
 997                        }
 998                        else
 999                        {
 01000                            value = PolicySetDefinitionListResult.DeserializePolicySetDefinitionListResult(document.Root
 1001                        }
 01002                        return Response.FromValue(value, message.Response);
 1003                    }
 1004                default:
 01005                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1006            }
 01007        }
 1008
 1009        internal Core.HttpMessage CreateListByManagementGroupNextPageRequest(string nextLink, string managementGroupId)
 1010        {
 01011            var message = _pipeline.CreateMessage();
 01012            var request = message.Request;
 01013            request.Method = RequestMethod.Get;
 01014            var uri = new RawRequestUriBuilder();
 01015            uri.Reset(endpoint);
 01016            uri.AppendRawNextLink(nextLink, false);
 01017            request.Uri = uri;
 01018            return message;
 1019        }
 1020
 1021        /// <summary> This operation retrieves a list of all the a policy set definition in the given management group. 
 1022        /// <param name="nextLink"> The URL to the next page of results. </param>
 1023        /// <param name="managementGroupId"> The ID of the management group. </param>
 1024        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1025        public async Task<Response<PolicySetDefinitionListResult>> ListByManagementGroupNextPageAsync(string nextLink, s
 1026        {
 01027            if (nextLink == null)
 1028            {
 01029                throw new ArgumentNullException(nameof(nextLink));
 1030            }
 01031            if (managementGroupId == null)
 1032            {
 01033                throw new ArgumentNullException(nameof(managementGroupId));
 1034            }
 1035
 01036            using var message = CreateListByManagementGroupNextPageRequest(nextLink, managementGroupId);
 01037            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01038            switch (message.Response.Status)
 1039            {
 1040                case 200:
 1041                    {
 01042                        PolicySetDefinitionListResult value = default;
 01043                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 01044                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1045                        {
 01046                            value = null;
 1047                        }
 1048                        else
 1049                        {
 01050                            value = PolicySetDefinitionListResult.DeserializePolicySetDefinitionListResult(document.Root
 1051                        }
 01052                        return Response.FromValue(value, message.Response);
 1053                    }
 1054                default:
 01055                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1056            }
 01057        }
 1058
 1059        /// <summary> This operation retrieves a list of all the a policy set definition in the given management group. 
 1060        /// <param name="nextLink"> The URL to the next page of results. </param>
 1061        /// <param name="managementGroupId"> The ID of the management group. </param>
 1062        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1063        public Response<PolicySetDefinitionListResult> ListByManagementGroupNextPage(string nextLink, string managementG
 1064        {
 01065            if (nextLink == null)
 1066            {
 01067                throw new ArgumentNullException(nameof(nextLink));
 1068            }
 01069            if (managementGroupId == null)
 1070            {
 01071                throw new ArgumentNullException(nameof(managementGroupId));
 1072            }
 1073
 01074            using var message = CreateListByManagementGroupNextPageRequest(nextLink, managementGroupId);
 01075            _pipeline.Send(message, cancellationToken);
 01076            switch (message.Response.Status)
 1077            {
 1078                case 200:
 1079                    {
 01080                        PolicySetDefinitionListResult value = default;
 01081                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 01082                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1083                        {
 01084                            value = null;
 1085                        }
 1086                        else
 1087                        {
 01088                            value = PolicySetDefinitionListResult.DeserializePolicySetDefinitionListResult(document.Root
 1089                        }
 01090                        return Response.FromValue(value, message.Response);
 1091                    }
 1092                default:
 01093                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1094            }
 01095        }
 1096    }
 1097}