< Summary

Class:Azure.ResourceManager.Resources.DeploymentsRestOperations
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\DeploymentsRestOperations.cs
Covered lines:544
Uncovered lines:1226
Coverable lines:1770
Total lines:3861
Line coverage:30.7% (544 of 1770)
Covered branches:154
Total branches:720
Branch coverage:21.3% (154 of 720)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateDeleteAtScopeRequest(...)-0%100%
DeleteAtScopeAsync()-0%0%
DeleteAtScope(...)-0%0%
CreateCheckExistenceAtScopeRequest(...)-0%100%
CheckExistenceAtScopeAsync()-0%0%
CheckExistenceAtScope(...)-0%0%
CreateCreateOrUpdateAtScopeRequest(...)-100%100%
CreateOrUpdateAtScopeAsync()-66.67%50%
CreateOrUpdateAtScope(...)-66.67%50%
CreateGetAtScopeRequest(...)-100%100%
GetAtScopeAsync()-73.33%50%
GetAtScope(...)-73.33%50%
CreateCancelAtScopeRequest(...)-0%100%
CancelAtScopeAsync()-0%0%
CancelAtScope(...)-0%0%
CreateValidateAtScopeRequest(...)-100%100%
ValidateAtScopeAsync()-66.67%50%
ValidateAtScope(...)-66.67%50%
CreateExportTemplateAtScopeRequest(...)-0%100%
ExportTemplateAtScopeAsync()-0%0%
ExportTemplateAtScope(...)-0%0%
CreateListAtScopeRequest(...)-0%0%
ListAtScopeAsync()-0%0%
ListAtScope(...)-0%0%
CreateDeleteAtTenantScopeRequest(...)-0%100%
DeleteAtTenantScopeAsync()-0%0%
DeleteAtTenantScope(...)-0%0%
CreateCheckExistenceAtTenantScopeRequest(...)-0%100%
CheckExistenceAtTenantScopeAsync()-0%0%
CheckExistenceAtTenantScope(...)-0%0%
CreateCreateOrUpdateAtTenantScopeRequest(...)-0%100%
CreateOrUpdateAtTenantScopeAsync()-0%0%
CreateOrUpdateAtTenantScope(...)-0%0%
CreateGetAtTenantScopeRequest(...)-0%100%
GetAtTenantScopeAsync()-0%0%
GetAtTenantScope(...)-0%0%
CreateCancelAtTenantScopeRequest(...)-0%100%
CancelAtTenantScopeAsync()-0%0%
CancelAtTenantScope(...)-0%0%
CreateValidateAtTenantScopeRequest(...)-0%100%
ValidateAtTenantScopeAsync()-0%0%
ValidateAtTenantScope(...)-0%0%
CreateExportTemplateAtTenantScopeRequest(...)-0%100%
ExportTemplateAtTenantScopeAsync()-0%0%
ExportTemplateAtTenantScope(...)-0%0%
CreateListAtTenantScopeRequest(...)-0%0%
ListAtTenantScopeAsync()-0%0%
ListAtTenantScope(...)-0%0%
CreateDeleteAtManagementGroupScopeRequest(...)-0%100%
DeleteAtManagementGroupScopeAsync()-0%0%
DeleteAtManagementGroupScope(...)-0%0%
CreateCheckExistenceAtManagementGroupScopeRequest(...)-0%100%
CheckExistenceAtManagementGroupScopeAsync()-0%0%
CheckExistenceAtManagementGroupScope(...)-0%0%
CreateCreateOrUpdateAtManagementGroupScopeRequest(...)-100%100%
CreateOrUpdateAtManagementGroupScopeAsync()-66.67%50%
CreateOrUpdateAtManagementGroupScope(...)-66.67%50%
CreateGetAtManagementGroupScopeRequest(...)-100%100%
GetAtManagementGroupScopeAsync()-73.33%50%
GetAtManagementGroupScope(...)-73.33%50%
CreateCancelAtManagementGroupScopeRequest(...)-0%100%
CancelAtManagementGroupScopeAsync()-0%0%
CancelAtManagementGroupScope(...)-0%0%
CreateValidateAtManagementGroupScopeRequest(...)-100%100%
ValidateAtManagementGroupScopeAsync()-66.67%50%
ValidateAtManagementGroupScope(...)-66.67%50%
CreateExportTemplateAtManagementGroupScopeRequest(...)-0%100%
ExportTemplateAtManagementGroupScopeAsync()-0%0%
ExportTemplateAtManagementGroupScope(...)-0%0%
CreateListAtManagementGroupScopeRequest(...)-0%0%
ListAtManagementGroupScopeAsync()-0%0%
ListAtManagementGroupScope(...)-0%0%
CreateDeleteAtSubscriptionScopeRequest(...)-0%100%
DeleteAtSubscriptionScopeAsync()-0%0%
DeleteAtSubscriptionScope(...)-0%0%
CreateCheckExistenceAtSubscriptionScopeRequest(...)-0%100%
CheckExistenceAtSubscriptionScopeAsync()-0%0%
CheckExistenceAtSubscriptionScope(...)-0%0%
CreateCreateOrUpdateAtSubscriptionScopeRequest(...)-100%100%
CreateOrUpdateAtSubscriptionScopeAsync()-70%50%
CreateOrUpdateAtSubscriptionScope(...)-70%50%
CreateGetAtSubscriptionScopeRequest(...)-100%100%
GetAtSubscriptionScopeAsync()-76.92%50%
GetAtSubscriptionScope(...)-76.92%50%
CreateCancelAtSubscriptionScopeRequest(...)-0%100%
CancelAtSubscriptionScopeAsync()-0%0%
CancelAtSubscriptionScope(...)-0%0%
CreateValidateAtSubscriptionScopeRequest(...)-100%100%
ValidateAtSubscriptionScopeAsync()-70%50%
ValidateAtSubscriptionScope(...)-70%50%
CreateWhatIfAtSubscriptionScopeRequest(...)-100%100%
WhatIfAtSubscriptionScopeAsync()-72.73%62.5%
WhatIfAtSubscriptionScope(...)-72.73%62.5%
CreateExportTemplateAtSubscriptionScopeRequest(...)-0%100%
ExportTemplateAtSubscriptionScopeAsync()-0%0%
ExportTemplateAtSubscriptionScope(...)-0%0%
CreateListAtSubscriptionScopeRequest(...)-0%0%
ListAtSubscriptionScopeAsync()-0%0%
ListAtSubscriptionScope(...)-0%0%
CreateDeleteRequest(...)-0%100%
DeleteAsync()-0%0%
Delete(...)-0%0%
CreateCheckExistenceRequest(...)-0%100%
CheckExistenceAsync()-0%0%
CheckExistence(...)-0%0%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-66.67%50%
CreateOrUpdate(...)-66.67%50%
CreateGetRequest(...)-100%100%
GetAsync()-73.33%50%
Get(...)-73.33%50%
CreateCancelRequest(...)-100%100%
CancelAsync()-90%83.33%
Cancel(...)-90%83.33%
CreateValidateRequest(...)-100%100%
ValidateAsync()-66.67%66.67%
Validate(...)-66.67%66.67%
CreateWhatIfRequest(...)-100%100%
WhatIfAsync()-69.23%60%
WhatIf(...)-69.23%60%
CreateExportTemplateRequest(...)-0%100%
ExportTemplateAsync()-0%0%
ExportTemplate(...)-0%0%
CreateListByResourceGroupRequest(...)-100%100%
ListByResourceGroupAsync()-76.92%50%
ListByResourceGroup(...)-76.92%50%
CreateCalculateTemplateHashRequest(...)-0%100%
CalculateTemplateHashAsync()-0%0%
CalculateTemplateHash(...)-0%0%
CreateListAtScopeNextPageRequest(...)-0%100%
ListAtScopeNextPageAsync()-0%0%
ListAtScopeNextPage(...)-0%0%
CreateListAtTenantScopeNextPageRequest(...)-0%100%
ListAtTenantScopeNextPageAsync()-0%0%
ListAtTenantScopeNextPage(...)-0%0%
CreateListAtManagementGroupScopeNextPageRequest(...)-0%100%
ListAtManagementGroupScopeNextPageAsync()-0%0%
ListAtManagementGroupScopeNextPage(...)-0%0%
CreateListAtSubscriptionScopeNextPageRequest(...)-0%100%
ListAtSubscriptionScopeNextPageAsync()-0%0%
ListAtSubscriptionScopeNextPage(...)-0%0%
CreateListByResourceGroupNextPageRequest(...)-0%100%
ListByResourceGroupNextPageAsync()-0%0%
ListByResourceGroupNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\DeploymentsRestOperations.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 DeploymentsRestOperations
 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 DeploymentsRestOperations. </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
 35232        public DeploymentsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscription
 33        {
 35234            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 35238            endpoint ??= new Uri("https://management.azure.com");
 39
 35240            this.subscriptionId = subscriptionId;
 35241            this.endpoint = endpoint;
 35242            _clientDiagnostics = clientDiagnostics;
 35243            _pipeline = pipeline;
 35244        }
 45
 46        internal Core.HttpMessage CreateDeleteAtScopeRequest(string scope, string deploymentName)
 47        {
 048            var message = _pipeline.CreateMessage();
 049            var request = message.Request;
 050            request.Method = RequestMethod.Delete;
 051            var uri = new RawRequestUriBuilder();
 052            uri.Reset(endpoint);
 053            uri.AppendPath("/", false);
 054            uri.AppendPath(scope, false);
 055            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 056            uri.AppendPath(deploymentName, true);
 057            uri.AppendQuery("api-version", "2019-10-01", true);
 058            request.Uri = uri;
 059            return message;
 60        }
 61
 62        /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment 
 63        /// <param name="scope"> The resource scope. </param>
 64        /// <param name="deploymentName"> The name of the deployment. </param>
 65        /// <param name="cancellationToken"> The cancellation token to use. </param>
 66        public async Task<Response> DeleteAtScopeAsync(string scope, string deploymentName, CancellationToken cancellati
 67        {
 068            if (scope == null)
 69            {
 070                throw new ArgumentNullException(nameof(scope));
 71            }
 072            if (deploymentName == null)
 73            {
 074                throw new ArgumentNullException(nameof(deploymentName));
 75            }
 76
 077            using var message = CreateDeleteAtScopeRequest(scope, deploymentName);
 078            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 079            switch (message.Response.Status)
 80            {
 81                case 202:
 82                case 204:
 083                    return message.Response;
 84                default:
 085                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 86            }
 087        }
 88
 89        /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment 
 90        /// <param name="scope"> The resource scope. </param>
 91        /// <param name="deploymentName"> The name of the deployment. </param>
 92        /// <param name="cancellationToken"> The cancellation token to use. </param>
 93        public Response DeleteAtScope(string scope, string deploymentName, CancellationToken cancellationToken = default
 94        {
 095            if (scope == null)
 96            {
 097                throw new ArgumentNullException(nameof(scope));
 98            }
 099            if (deploymentName == null)
 100            {
 0101                throw new ArgumentNullException(nameof(deploymentName));
 102            }
 103
 0104            using var message = CreateDeleteAtScopeRequest(scope, deploymentName);
 0105            _pipeline.Send(message, cancellationToken);
 0106            switch (message.Response.Status)
 107            {
 108                case 202:
 109                case 204:
 0110                    return message.Response;
 111                default:
 0112                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 113            }
 0114        }
 115
 116        internal Core.HttpMessage CreateCheckExistenceAtScopeRequest(string scope, string deploymentName)
 117        {
 0118            var message = _pipeline.CreateMessage();
 0119            var request = message.Request;
 0120            request.Method = RequestMethod.Head;
 0121            var uri = new RawRequestUriBuilder();
 0122            uri.Reset(endpoint);
 0123            uri.AppendPath("/", false);
 0124            uri.AppendPath(scope, false);
 0125            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 0126            uri.AppendPath(deploymentName, true);
 0127            uri.AppendQuery("api-version", "2019-10-01", true);
 0128            request.Uri = uri;
 0129            return message;
 130        }
 131
 132        /// <summary> Checks whether the deployment exists. </summary>
 133        /// <param name="scope"> The resource scope. </param>
 134        /// <param name="deploymentName"> The name of the deployment. </param>
 135        /// <param name="cancellationToken"> The cancellation token to use. </param>
 136        public async Task<Response> CheckExistenceAtScopeAsync(string scope, string deploymentName, CancellationToken ca
 137        {
 0138            if (scope == null)
 139            {
 0140                throw new ArgumentNullException(nameof(scope));
 141            }
 0142            if (deploymentName == null)
 143            {
 0144                throw new ArgumentNullException(nameof(deploymentName));
 145            }
 146
 0147            using var message = CreateCheckExistenceAtScopeRequest(scope, deploymentName);
 0148            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0149            switch (message.Response.Status)
 150            {
 151                case 204:
 152                case 404:
 0153                    return message.Response;
 154                default:
 0155                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 156            }
 0157        }
 158
 159        /// <summary> Checks whether the deployment exists. </summary>
 160        /// <param name="scope"> The resource scope. </param>
 161        /// <param name="deploymentName"> The name of the deployment. </param>
 162        /// <param name="cancellationToken"> The cancellation token to use. </param>
 163        public Response CheckExistenceAtScope(string scope, string deploymentName, CancellationToken cancellationToken =
 164        {
 0165            if (scope == null)
 166            {
 0167                throw new ArgumentNullException(nameof(scope));
 168            }
 0169            if (deploymentName == null)
 170            {
 0171                throw new ArgumentNullException(nameof(deploymentName));
 172            }
 173
 0174            using var message = CreateCheckExistenceAtScopeRequest(scope, deploymentName);
 0175            _pipeline.Send(message, cancellationToken);
 0176            switch (message.Response.Status)
 177            {
 178                case 204:
 179                case 404:
 0180                    return message.Response;
 181                default:
 0182                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 183            }
 0184        }
 185
 186        internal Core.HttpMessage CreateCreateOrUpdateAtScopeRequest(string scope, string deploymentName, Deployment par
 187        {
 24188            var message = _pipeline.CreateMessage();
 24189            var request = message.Request;
 24190            request.Method = RequestMethod.Put;
 24191            var uri = new RawRequestUriBuilder();
 24192            uri.Reset(endpoint);
 24193            uri.AppendPath("/", false);
 24194            uri.AppendPath(scope, false);
 24195            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 24196            uri.AppendPath(deploymentName, true);
 24197            uri.AppendQuery("api-version", "2019-10-01", true);
 24198            request.Uri = uri;
 24199            request.Headers.Add("Content-Type", "application/json");
 24200            var content = new Utf8JsonRequestContent();
 24201            content.JsonWriter.WriteObjectValue(parameters);
 24202            request.Content = content;
 24203            return message;
 204        }
 205
 206        /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa
 207        /// <param name="scope"> The resource scope. </param>
 208        /// <param name="deploymentName"> The name of the deployment. </param>
 209        /// <param name="parameters"> Additional parameters supplied to the operation. </param>
 210        /// <param name="cancellationToken"> The cancellation token to use. </param>
 211        public async Task<Response> CreateOrUpdateAtScopeAsync(string scope, string deploymentName, Deployment parameter
 212        {
 6213            if (scope == null)
 214            {
 0215                throw new ArgumentNullException(nameof(scope));
 216            }
 6217            if (deploymentName == null)
 218            {
 0219                throw new ArgumentNullException(nameof(deploymentName));
 220            }
 6221            if (parameters == null)
 222            {
 0223                throw new ArgumentNullException(nameof(parameters));
 224            }
 225
 6226            using var message = CreateCreateOrUpdateAtScopeRequest(scope, deploymentName, parameters);
 6227            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 6228            switch (message.Response.Status)
 229            {
 230                case 200:
 231                case 201:
 6232                    return message.Response;
 233                default:
 0234                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 235            }
 6236        }
 237
 238        /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa
 239        /// <param name="scope"> The resource scope. </param>
 240        /// <param name="deploymentName"> The name of the deployment. </param>
 241        /// <param name="parameters"> Additional parameters supplied to the operation. </param>
 242        /// <param name="cancellationToken"> The cancellation token to use. </param>
 243        public Response CreateOrUpdateAtScope(string scope, string deploymentName, Deployment parameters, CancellationTo
 244        {
 6245            if (scope == null)
 246            {
 0247                throw new ArgumentNullException(nameof(scope));
 248            }
 6249            if (deploymentName == null)
 250            {
 0251                throw new ArgumentNullException(nameof(deploymentName));
 252            }
 6253            if (parameters == null)
 254            {
 0255                throw new ArgumentNullException(nameof(parameters));
 256            }
 257
 6258            using var message = CreateCreateOrUpdateAtScopeRequest(scope, deploymentName, parameters);
 6259            _pipeline.Send(message, cancellationToken);
 6260            switch (message.Response.Status)
 261            {
 262                case 200:
 263                case 201:
 6264                    return message.Response;
 265                default:
 0266                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 267            }
 6268        }
 269
 270        internal Core.HttpMessage CreateGetAtScopeRequest(string scope, string deploymentName)
 271        {
 12272            var message = _pipeline.CreateMessage();
 12273            var request = message.Request;
 12274            request.Method = RequestMethod.Get;
 12275            var uri = new RawRequestUriBuilder();
 12276            uri.Reset(endpoint);
 12277            uri.AppendPath("/", false);
 12278            uri.AppendPath(scope, false);
 12279            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 12280            uri.AppendPath(deploymentName, true);
 12281            uri.AppendQuery("api-version", "2019-10-01", true);
 12282            request.Uri = uri;
 12283            return message;
 284        }
 285
 286        /// <summary> Gets a deployment. </summary>
 287        /// <param name="scope"> The resource scope. </param>
 288        /// <param name="deploymentName"> The name of the deployment. </param>
 289        /// <param name="cancellationToken"> The cancellation token to use. </param>
 290        public async Task<Response<DeploymentExtended>> GetAtScopeAsync(string scope, string deploymentName, Cancellatio
 291        {
 6292            if (scope == null)
 293            {
 0294                throw new ArgumentNullException(nameof(scope));
 295            }
 6296            if (deploymentName == null)
 297            {
 0298                throw new ArgumentNullException(nameof(deploymentName));
 299            }
 300
 6301            using var message = CreateGetAtScopeRequest(scope, deploymentName);
 6302            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 6303            switch (message.Response.Status)
 304            {
 305                case 200:
 306                    {
 6307                        DeploymentExtended value = default;
 6308                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 6309                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 310                        {
 0311                            value = null;
 312                        }
 313                        else
 314                        {
 6315                            value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement);
 316                        }
 6317                        return Response.FromValue(value, message.Response);
 318                    }
 319                default:
 0320                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 321            }
 6322        }
 323
 324        /// <summary> Gets a deployment. </summary>
 325        /// <param name="scope"> The resource scope. </param>
 326        /// <param name="deploymentName"> The name of the deployment. </param>
 327        /// <param name="cancellationToken"> The cancellation token to use. </param>
 328        public Response<DeploymentExtended> GetAtScope(string scope, string deploymentName, CancellationToken cancellati
 329        {
 6330            if (scope == null)
 331            {
 0332                throw new ArgumentNullException(nameof(scope));
 333            }
 6334            if (deploymentName == null)
 335            {
 0336                throw new ArgumentNullException(nameof(deploymentName));
 337            }
 338
 6339            using var message = CreateGetAtScopeRequest(scope, deploymentName);
 6340            _pipeline.Send(message, cancellationToken);
 6341            switch (message.Response.Status)
 342            {
 343                case 200:
 344                    {
 6345                        DeploymentExtended value = default;
 6346                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 6347                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 348                        {
 0349                            value = null;
 350                        }
 351                        else
 352                        {
 6353                            value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement);
 354                        }
 6355                        return Response.FromValue(value, message.Response);
 356                    }
 357                default:
 0358                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 359            }
 6360        }
 361
 362        internal Core.HttpMessage CreateCancelAtScopeRequest(string scope, string deploymentName)
 363        {
 0364            var message = _pipeline.CreateMessage();
 0365            var request = message.Request;
 0366            request.Method = RequestMethod.Post;
 0367            var uri = new RawRequestUriBuilder();
 0368            uri.Reset(endpoint);
 0369            uri.AppendPath("/", false);
 0370            uri.AppendPath(scope, false);
 0371            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 0372            uri.AppendPath(deploymentName, true);
 0373            uri.AppendPath("/cancel", false);
 0374            uri.AppendQuery("api-version", "2019-10-01", true);
 0375            request.Uri = uri;
 0376            return message;
 377        }
 378
 379        /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy
 380        /// <param name="scope"> The resource scope. </param>
 381        /// <param name="deploymentName"> The name of the deployment. </param>
 382        /// <param name="cancellationToken"> The cancellation token to use. </param>
 383        public async Task<Response> CancelAtScopeAsync(string scope, string deploymentName, CancellationToken cancellati
 384        {
 0385            if (scope == null)
 386            {
 0387                throw new ArgumentNullException(nameof(scope));
 388            }
 0389            if (deploymentName == null)
 390            {
 0391                throw new ArgumentNullException(nameof(deploymentName));
 392            }
 393
 0394            using var message = CreateCancelAtScopeRequest(scope, deploymentName);
 0395            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0396            switch (message.Response.Status)
 397            {
 398                case 204:
 0399                    return message.Response;
 400                default:
 0401                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 402            }
 0403        }
 404
 405        /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy
 406        /// <param name="scope"> The resource scope. </param>
 407        /// <param name="deploymentName"> The name of the deployment. </param>
 408        /// <param name="cancellationToken"> The cancellation token to use. </param>
 409        public Response CancelAtScope(string scope, string deploymentName, CancellationToken cancellationToken = default
 410        {
 0411            if (scope == null)
 412            {
 0413                throw new ArgumentNullException(nameof(scope));
 414            }
 0415            if (deploymentName == null)
 416            {
 0417                throw new ArgumentNullException(nameof(deploymentName));
 418            }
 419
 0420            using var message = CreateCancelAtScopeRequest(scope, deploymentName);
 0421            _pipeline.Send(message, cancellationToken);
 0422            switch (message.Response.Status)
 423            {
 424                case 204:
 0425                    return message.Response;
 426                default:
 0427                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 428            }
 0429        }
 430
 431        internal Core.HttpMessage CreateValidateAtScopeRequest(string scope, string deploymentName, Deployment parameter
 432        {
 24433            var message = _pipeline.CreateMessage();
 24434            var request = message.Request;
 24435            request.Method = RequestMethod.Post;
 24436            var uri = new RawRequestUriBuilder();
 24437            uri.Reset(endpoint);
 24438            uri.AppendPath("/", false);
 24439            uri.AppendPath(scope, false);
 24440            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 24441            uri.AppendPath(deploymentName, true);
 24442            uri.AppendPath("/validate", false);
 24443            uri.AppendQuery("api-version", "2019-10-01", true);
 24444            request.Uri = uri;
 24445            request.Headers.Add("Content-Type", "application/json");
 24446            var content = new Utf8JsonRequestContent();
 24447            content.JsonWriter.WriteObjectValue(parameters);
 24448            request.Content = content;
 24449            return message;
 450        }
 451
 452        /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re
 453        /// <param name="scope"> The resource scope. </param>
 454        /// <param name="deploymentName"> The name of the deployment. </param>
 455        /// <param name="parameters"> Parameters to validate. </param>
 456        /// <param name="cancellationToken"> The cancellation token to use. </param>
 457        public async Task<Response> ValidateAtScopeAsync(string scope, string deploymentName, Deployment parameters, Can
 458        {
 6459            if (scope == null)
 460            {
 0461                throw new ArgumentNullException(nameof(scope));
 462            }
 6463            if (deploymentName == null)
 464            {
 0465                throw new ArgumentNullException(nameof(deploymentName));
 466            }
 6467            if (parameters == null)
 468            {
 0469                throw new ArgumentNullException(nameof(parameters));
 470            }
 471
 6472            using var message = CreateValidateAtScopeRequest(scope, deploymentName, parameters);
 6473            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 6474            switch (message.Response.Status)
 475            {
 476                case 200:
 477                case 202:
 478                case 400:
 6479                    return message.Response;
 480                default:
 0481                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 482            }
 6483        }
 484
 485        /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re
 486        /// <param name="scope"> The resource scope. </param>
 487        /// <param name="deploymentName"> The name of the deployment. </param>
 488        /// <param name="parameters"> Parameters to validate. </param>
 489        /// <param name="cancellationToken"> The cancellation token to use. </param>
 490        public Response ValidateAtScope(string scope, string deploymentName, Deployment parameters, CancellationToken ca
 491        {
 6492            if (scope == null)
 493            {
 0494                throw new ArgumentNullException(nameof(scope));
 495            }
 6496            if (deploymentName == null)
 497            {
 0498                throw new ArgumentNullException(nameof(deploymentName));
 499            }
 6500            if (parameters == null)
 501            {
 0502                throw new ArgumentNullException(nameof(parameters));
 503            }
 504
 6505            using var message = CreateValidateAtScopeRequest(scope, deploymentName, parameters);
 6506            _pipeline.Send(message, cancellationToken);
 6507            switch (message.Response.Status)
 508            {
 509                case 200:
 510                case 202:
 511                case 400:
 6512                    return message.Response;
 513                default:
 0514                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 515            }
 6516        }
 517
 518        internal Core.HttpMessage CreateExportTemplateAtScopeRequest(string scope, string deploymentName)
 519        {
 0520            var message = _pipeline.CreateMessage();
 0521            var request = message.Request;
 0522            request.Method = RequestMethod.Post;
 0523            var uri = new RawRequestUriBuilder();
 0524            uri.Reset(endpoint);
 0525            uri.AppendPath("/", false);
 0526            uri.AppendPath(scope, false);
 0527            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 0528            uri.AppendPath(deploymentName, true);
 0529            uri.AppendPath("/exportTemplate", false);
 0530            uri.AppendQuery("api-version", "2019-10-01", true);
 0531            request.Uri = uri;
 0532            return message;
 533        }
 534
 535        /// <summary> Exports the template used for specified deployment. </summary>
 536        /// <param name="scope"> The resource scope. </param>
 537        /// <param name="deploymentName"> The name of the deployment. </param>
 538        /// <param name="cancellationToken"> The cancellation token to use. </param>
 539        public async Task<Response<DeploymentExportResult>> ExportTemplateAtScopeAsync(string scope, string deploymentNa
 540        {
 0541            if (scope == null)
 542            {
 0543                throw new ArgumentNullException(nameof(scope));
 544            }
 0545            if (deploymentName == null)
 546            {
 0547                throw new ArgumentNullException(nameof(deploymentName));
 548            }
 549
 0550            using var message = CreateExportTemplateAtScopeRequest(scope, deploymentName);
 0551            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0552            switch (message.Response.Status)
 553            {
 554                case 200:
 555                    {
 0556                        DeploymentExportResult value = default;
 0557                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0558                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 559                        {
 0560                            value = null;
 561                        }
 562                        else
 563                        {
 0564                            value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement);
 565                        }
 0566                        return Response.FromValue(value, message.Response);
 567                    }
 568                default:
 0569                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 570            }
 0571        }
 572
 573        /// <summary> Exports the template used for specified deployment. </summary>
 574        /// <param name="scope"> The resource scope. </param>
 575        /// <param name="deploymentName"> The name of the deployment. </param>
 576        /// <param name="cancellationToken"> The cancellation token to use. </param>
 577        public Response<DeploymentExportResult> ExportTemplateAtScope(string scope, string deploymentName, CancellationT
 578        {
 0579            if (scope == null)
 580            {
 0581                throw new ArgumentNullException(nameof(scope));
 582            }
 0583            if (deploymentName == null)
 584            {
 0585                throw new ArgumentNullException(nameof(deploymentName));
 586            }
 587
 0588            using var message = CreateExportTemplateAtScopeRequest(scope, deploymentName);
 0589            _pipeline.Send(message, cancellationToken);
 0590            switch (message.Response.Status)
 591            {
 592                case 200:
 593                    {
 0594                        DeploymentExportResult value = default;
 0595                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0596                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 597                        {
 0598                            value = null;
 599                        }
 600                        else
 601                        {
 0602                            value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement);
 603                        }
 0604                        return Response.FromValue(value, message.Response);
 605                    }
 606                default:
 0607                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 608            }
 0609        }
 610
 611        internal Core.HttpMessage CreateListAtScopeRequest(string scope, string filter, int? top)
 612        {
 0613            var message = _pipeline.CreateMessage();
 0614            var request = message.Request;
 0615            request.Method = RequestMethod.Get;
 0616            var uri = new RawRequestUriBuilder();
 0617            uri.Reset(endpoint);
 0618            uri.AppendPath("/", false);
 0619            uri.AppendPath(scope, false);
 0620            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 0621            if (filter != null)
 622            {
 0623                uri.AppendQuery("$filter", filter, true);
 624            }
 0625            if (top != null)
 626            {
 0627                uri.AppendQuery("$top", top.Value, true);
 628            }
 0629            uri.AppendQuery("api-version", "2019-10-01", true);
 0630            request.Uri = uri;
 0631            return message;
 632        }
 633
 634        /// <summary> Get all the deployments at the given scope. </summary>
 635        /// <param name="scope"> The resource scope. </param>
 636        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 637        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 638        /// <param name="cancellationToken"> The cancellation token to use. </param>
 639        public async Task<Response<DeploymentListResult>> ListAtScopeAsync(string scope, string filter = null, int? top 
 640        {
 0641            if (scope == null)
 642            {
 0643                throw new ArgumentNullException(nameof(scope));
 644            }
 645
 0646            using var message = CreateListAtScopeRequest(scope, filter, top);
 0647            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0648            switch (message.Response.Status)
 649            {
 650                case 200:
 651                    {
 0652                        DeploymentListResult value = default;
 0653                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0654                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 655                        {
 0656                            value = null;
 657                        }
 658                        else
 659                        {
 0660                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 661                        }
 0662                        return Response.FromValue(value, message.Response);
 663                    }
 664                default:
 0665                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 666            }
 0667        }
 668
 669        /// <summary> Get all the deployments at the given scope. </summary>
 670        /// <param name="scope"> The resource scope. </param>
 671        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 672        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 673        /// <param name="cancellationToken"> The cancellation token to use. </param>
 674        public Response<DeploymentListResult> ListAtScope(string scope, string filter = null, int? top = null, Cancellat
 675        {
 0676            if (scope == null)
 677            {
 0678                throw new ArgumentNullException(nameof(scope));
 679            }
 680
 0681            using var message = CreateListAtScopeRequest(scope, filter, top);
 0682            _pipeline.Send(message, cancellationToken);
 0683            switch (message.Response.Status)
 684            {
 685                case 200:
 686                    {
 0687                        DeploymentListResult value = default;
 0688                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0689                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 690                        {
 0691                            value = null;
 692                        }
 693                        else
 694                        {
 0695                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 696                        }
 0697                        return Response.FromValue(value, message.Response);
 698                    }
 699                default:
 0700                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 701            }
 0702        }
 703
 704        internal Core.HttpMessage CreateDeleteAtTenantScopeRequest(string deploymentName)
 705        {
 0706            var message = _pipeline.CreateMessage();
 0707            var request = message.Request;
 0708            request.Method = RequestMethod.Delete;
 0709            var uri = new RawRequestUriBuilder();
 0710            uri.Reset(endpoint);
 0711            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 0712            uri.AppendPath(deploymentName, true);
 0713            uri.AppendQuery("api-version", "2019-10-01", true);
 0714            request.Uri = uri;
 0715            return message;
 716        }
 717
 718        /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment 
 719        /// <param name="deploymentName"> The name of the deployment. </param>
 720        /// <param name="cancellationToken"> The cancellation token to use. </param>
 721        public async Task<Response> DeleteAtTenantScopeAsync(string deploymentName, CancellationToken cancellationToken 
 722        {
 0723            if (deploymentName == null)
 724            {
 0725                throw new ArgumentNullException(nameof(deploymentName));
 726            }
 727
 0728            using var message = CreateDeleteAtTenantScopeRequest(deploymentName);
 0729            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0730            switch (message.Response.Status)
 731            {
 732                case 202:
 733                case 204:
 0734                    return message.Response;
 735                default:
 0736                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 737            }
 0738        }
 739
 740        /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment 
 741        /// <param name="deploymentName"> The name of the deployment. </param>
 742        /// <param name="cancellationToken"> The cancellation token to use. </param>
 743        public Response DeleteAtTenantScope(string deploymentName, CancellationToken cancellationToken = default)
 744        {
 0745            if (deploymentName == null)
 746            {
 0747                throw new ArgumentNullException(nameof(deploymentName));
 748            }
 749
 0750            using var message = CreateDeleteAtTenantScopeRequest(deploymentName);
 0751            _pipeline.Send(message, cancellationToken);
 0752            switch (message.Response.Status)
 753            {
 754                case 202:
 755                case 204:
 0756                    return message.Response;
 757                default:
 0758                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 759            }
 0760        }
 761
 762        internal Core.HttpMessage CreateCheckExistenceAtTenantScopeRequest(string deploymentName)
 763        {
 0764            var message = _pipeline.CreateMessage();
 0765            var request = message.Request;
 0766            request.Method = RequestMethod.Head;
 0767            var uri = new RawRequestUriBuilder();
 0768            uri.Reset(endpoint);
 0769            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 0770            uri.AppendPath(deploymentName, true);
 0771            uri.AppendQuery("api-version", "2019-10-01", true);
 0772            request.Uri = uri;
 0773            return message;
 774        }
 775
 776        /// <summary> Checks whether the deployment exists. </summary>
 777        /// <param name="deploymentName"> The name of the deployment. </param>
 778        /// <param name="cancellationToken"> The cancellation token to use. </param>
 779        public async Task<Response> CheckExistenceAtTenantScopeAsync(string deploymentName, CancellationToken cancellati
 780        {
 0781            if (deploymentName == null)
 782            {
 0783                throw new ArgumentNullException(nameof(deploymentName));
 784            }
 785
 0786            using var message = CreateCheckExistenceAtTenantScopeRequest(deploymentName);
 0787            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0788            switch (message.Response.Status)
 789            {
 790                case 204:
 791                case 404:
 0792                    return message.Response;
 793                default:
 0794                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 795            }
 0796        }
 797
 798        /// <summary> Checks whether the deployment exists. </summary>
 799        /// <param name="deploymentName"> The name of the deployment. </param>
 800        /// <param name="cancellationToken"> The cancellation token to use. </param>
 801        public Response CheckExistenceAtTenantScope(string deploymentName, CancellationToken cancellationToken = default
 802        {
 0803            if (deploymentName == null)
 804            {
 0805                throw new ArgumentNullException(nameof(deploymentName));
 806            }
 807
 0808            using var message = CreateCheckExistenceAtTenantScopeRequest(deploymentName);
 0809            _pipeline.Send(message, cancellationToken);
 0810            switch (message.Response.Status)
 811            {
 812                case 204:
 813                case 404:
 0814                    return message.Response;
 815                default:
 0816                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 817            }
 0818        }
 819
 820        internal Core.HttpMessage CreateCreateOrUpdateAtTenantScopeRequest(string deploymentName, ScopedDeployment param
 821        {
 0822            var message = _pipeline.CreateMessage();
 0823            var request = message.Request;
 0824            request.Method = RequestMethod.Put;
 0825            var uri = new RawRequestUriBuilder();
 0826            uri.Reset(endpoint);
 0827            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 0828            uri.AppendPath(deploymentName, true);
 0829            uri.AppendQuery("api-version", "2019-10-01", true);
 0830            request.Uri = uri;
 0831            request.Headers.Add("Content-Type", "application/json");
 0832            var content = new Utf8JsonRequestContent();
 0833            content.JsonWriter.WriteObjectValue(parameters);
 0834            request.Content = content;
 0835            return message;
 836        }
 837
 838        /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa
 839        /// <param name="deploymentName"> The name of the deployment. </param>
 840        /// <param name="parameters"> Additional parameters supplied to the operation. </param>
 841        /// <param name="cancellationToken"> The cancellation token to use. </param>
 842        public async Task<Response> CreateOrUpdateAtTenantScopeAsync(string deploymentName, ScopedDeployment parameters,
 843        {
 0844            if (deploymentName == null)
 845            {
 0846                throw new ArgumentNullException(nameof(deploymentName));
 847            }
 0848            if (parameters == null)
 849            {
 0850                throw new ArgumentNullException(nameof(parameters));
 851            }
 852
 0853            using var message = CreateCreateOrUpdateAtTenantScopeRequest(deploymentName, parameters);
 0854            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0855            switch (message.Response.Status)
 856            {
 857                case 200:
 858                case 201:
 0859                    return message.Response;
 860                default:
 0861                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 862            }
 0863        }
 864
 865        /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa
 866        /// <param name="deploymentName"> The name of the deployment. </param>
 867        /// <param name="parameters"> Additional parameters supplied to the operation. </param>
 868        /// <param name="cancellationToken"> The cancellation token to use. </param>
 869        public Response CreateOrUpdateAtTenantScope(string deploymentName, ScopedDeployment parameters, CancellationToke
 870        {
 0871            if (deploymentName == null)
 872            {
 0873                throw new ArgumentNullException(nameof(deploymentName));
 874            }
 0875            if (parameters == null)
 876            {
 0877                throw new ArgumentNullException(nameof(parameters));
 878            }
 879
 0880            using var message = CreateCreateOrUpdateAtTenantScopeRequest(deploymentName, parameters);
 0881            _pipeline.Send(message, cancellationToken);
 0882            switch (message.Response.Status)
 883            {
 884                case 200:
 885                case 201:
 0886                    return message.Response;
 887                default:
 0888                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 889            }
 0890        }
 891
 892        internal Core.HttpMessage CreateGetAtTenantScopeRequest(string deploymentName)
 893        {
 0894            var message = _pipeline.CreateMessage();
 0895            var request = message.Request;
 0896            request.Method = RequestMethod.Get;
 0897            var uri = new RawRequestUriBuilder();
 0898            uri.Reset(endpoint);
 0899            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 0900            uri.AppendPath(deploymentName, true);
 0901            uri.AppendQuery("api-version", "2019-10-01", true);
 0902            request.Uri = uri;
 0903            return message;
 904        }
 905
 906        /// <summary> Gets a deployment. </summary>
 907        /// <param name="deploymentName"> The name of the deployment. </param>
 908        /// <param name="cancellationToken"> The cancellation token to use. </param>
 909        public async Task<Response<DeploymentExtended>> GetAtTenantScopeAsync(string deploymentName, CancellationToken c
 910        {
 0911            if (deploymentName == null)
 912            {
 0913                throw new ArgumentNullException(nameof(deploymentName));
 914            }
 915
 0916            using var message = CreateGetAtTenantScopeRequest(deploymentName);
 0917            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0918            switch (message.Response.Status)
 919            {
 920                case 200:
 921                    {
 0922                        DeploymentExtended value = default;
 0923                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0924                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 925                        {
 0926                            value = null;
 927                        }
 928                        else
 929                        {
 0930                            value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement);
 931                        }
 0932                        return Response.FromValue(value, message.Response);
 933                    }
 934                default:
 0935                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 936            }
 0937        }
 938
 939        /// <summary> Gets a deployment. </summary>
 940        /// <param name="deploymentName"> The name of the deployment. </param>
 941        /// <param name="cancellationToken"> The cancellation token to use. </param>
 942        public Response<DeploymentExtended> GetAtTenantScope(string deploymentName, CancellationToken cancellationToken 
 943        {
 0944            if (deploymentName == null)
 945            {
 0946                throw new ArgumentNullException(nameof(deploymentName));
 947            }
 948
 0949            using var message = CreateGetAtTenantScopeRequest(deploymentName);
 0950            _pipeline.Send(message, cancellationToken);
 0951            switch (message.Response.Status)
 952            {
 953                case 200:
 954                    {
 0955                        DeploymentExtended value = default;
 0956                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0957                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 958                        {
 0959                            value = null;
 960                        }
 961                        else
 962                        {
 0963                            value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement);
 964                        }
 0965                        return Response.FromValue(value, message.Response);
 966                    }
 967                default:
 0968                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 969            }
 0970        }
 971
 972        internal Core.HttpMessage CreateCancelAtTenantScopeRequest(string deploymentName)
 973        {
 0974            var message = _pipeline.CreateMessage();
 0975            var request = message.Request;
 0976            request.Method = RequestMethod.Post;
 0977            var uri = new RawRequestUriBuilder();
 0978            uri.Reset(endpoint);
 0979            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 0980            uri.AppendPath(deploymentName, true);
 0981            uri.AppendPath("/cancel", false);
 0982            uri.AppendQuery("api-version", "2019-10-01", true);
 0983            request.Uri = uri;
 0984            return message;
 985        }
 986
 987        /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy
 988        /// <param name="deploymentName"> The name of the deployment. </param>
 989        /// <param name="cancellationToken"> The cancellation token to use. </param>
 990        public async Task<Response> CancelAtTenantScopeAsync(string deploymentName, CancellationToken cancellationToken 
 991        {
 0992            if (deploymentName == null)
 993            {
 0994                throw new ArgumentNullException(nameof(deploymentName));
 995            }
 996
 0997            using var message = CreateCancelAtTenantScopeRequest(deploymentName);
 0998            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0999            switch (message.Response.Status)
 1000            {
 1001                case 204:
 01002                    return message.Response;
 1003                default:
 01004                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1005            }
 01006        }
 1007
 1008        /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy
 1009        /// <param name="deploymentName"> The name of the deployment. </param>
 1010        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1011        public Response CancelAtTenantScope(string deploymentName, CancellationToken cancellationToken = default)
 1012        {
 01013            if (deploymentName == null)
 1014            {
 01015                throw new ArgumentNullException(nameof(deploymentName));
 1016            }
 1017
 01018            using var message = CreateCancelAtTenantScopeRequest(deploymentName);
 01019            _pipeline.Send(message, cancellationToken);
 01020            switch (message.Response.Status)
 1021            {
 1022                case 204:
 01023                    return message.Response;
 1024                default:
 01025                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1026            }
 01027        }
 1028
 1029        internal Core.HttpMessage CreateValidateAtTenantScopeRequest(string deploymentName, ScopedDeployment parameters)
 1030        {
 01031            var message = _pipeline.CreateMessage();
 01032            var request = message.Request;
 01033            request.Method = RequestMethod.Post;
 01034            var uri = new RawRequestUriBuilder();
 01035            uri.Reset(endpoint);
 01036            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 01037            uri.AppendPath(deploymentName, true);
 01038            uri.AppendPath("/validate", false);
 01039            uri.AppendQuery("api-version", "2019-10-01", true);
 01040            request.Uri = uri;
 01041            request.Headers.Add("Content-Type", "application/json");
 01042            var content = new Utf8JsonRequestContent();
 01043            content.JsonWriter.WriteObjectValue(parameters);
 01044            request.Content = content;
 01045            return message;
 1046        }
 1047
 1048        /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re
 1049        /// <param name="deploymentName"> The name of the deployment. </param>
 1050        /// <param name="parameters"> Parameters to validate. </param>
 1051        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1052        public async Task<Response> ValidateAtTenantScopeAsync(string deploymentName, ScopedDeployment parameters, Cance
 1053        {
 01054            if (deploymentName == null)
 1055            {
 01056                throw new ArgumentNullException(nameof(deploymentName));
 1057            }
 01058            if (parameters == null)
 1059            {
 01060                throw new ArgumentNullException(nameof(parameters));
 1061            }
 1062
 01063            using var message = CreateValidateAtTenantScopeRequest(deploymentName, parameters);
 01064            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01065            switch (message.Response.Status)
 1066            {
 1067                case 200:
 1068                case 202:
 1069                case 400:
 01070                    return message.Response;
 1071                default:
 01072                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1073            }
 01074        }
 1075
 1076        /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re
 1077        /// <param name="deploymentName"> The name of the deployment. </param>
 1078        /// <param name="parameters"> Parameters to validate. </param>
 1079        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1080        public Response ValidateAtTenantScope(string deploymentName, ScopedDeployment parameters, CancellationToken canc
 1081        {
 01082            if (deploymentName == null)
 1083            {
 01084                throw new ArgumentNullException(nameof(deploymentName));
 1085            }
 01086            if (parameters == null)
 1087            {
 01088                throw new ArgumentNullException(nameof(parameters));
 1089            }
 1090
 01091            using var message = CreateValidateAtTenantScopeRequest(deploymentName, parameters);
 01092            _pipeline.Send(message, cancellationToken);
 01093            switch (message.Response.Status)
 1094            {
 1095                case 200:
 1096                case 202:
 1097                case 400:
 01098                    return message.Response;
 1099                default:
 01100                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1101            }
 01102        }
 1103
 1104        internal Core.HttpMessage CreateExportTemplateAtTenantScopeRequest(string deploymentName)
 1105        {
 01106            var message = _pipeline.CreateMessage();
 01107            var request = message.Request;
 01108            request.Method = RequestMethod.Post;
 01109            var uri = new RawRequestUriBuilder();
 01110            uri.Reset(endpoint);
 01111            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 01112            uri.AppendPath(deploymentName, true);
 01113            uri.AppendPath("/exportTemplate", false);
 01114            uri.AppendQuery("api-version", "2019-10-01", true);
 01115            request.Uri = uri;
 01116            return message;
 1117        }
 1118
 1119        /// <summary> Exports the template used for specified deployment. </summary>
 1120        /// <param name="deploymentName"> The name of the deployment. </param>
 1121        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1122        public async Task<Response<DeploymentExportResult>> ExportTemplateAtTenantScopeAsync(string deploymentName, Canc
 1123        {
 01124            if (deploymentName == null)
 1125            {
 01126                throw new ArgumentNullException(nameof(deploymentName));
 1127            }
 1128
 01129            using var message = CreateExportTemplateAtTenantScopeRequest(deploymentName);
 01130            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01131            switch (message.Response.Status)
 1132            {
 1133                case 200:
 1134                    {
 01135                        DeploymentExportResult value = default;
 01136                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 01137                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1138                        {
 01139                            value = null;
 1140                        }
 1141                        else
 1142                        {
 01143                            value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement);
 1144                        }
 01145                        return Response.FromValue(value, message.Response);
 1146                    }
 1147                default:
 01148                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1149            }
 01150        }
 1151
 1152        /// <summary> Exports the template used for specified deployment. </summary>
 1153        /// <param name="deploymentName"> The name of the deployment. </param>
 1154        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1155        public Response<DeploymentExportResult> ExportTemplateAtTenantScope(string deploymentName, CancellationToken can
 1156        {
 01157            if (deploymentName == null)
 1158            {
 01159                throw new ArgumentNullException(nameof(deploymentName));
 1160            }
 1161
 01162            using var message = CreateExportTemplateAtTenantScopeRequest(deploymentName);
 01163            _pipeline.Send(message, cancellationToken);
 01164            switch (message.Response.Status)
 1165            {
 1166                case 200:
 1167                    {
 01168                        DeploymentExportResult value = default;
 01169                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 01170                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1171                        {
 01172                            value = null;
 1173                        }
 1174                        else
 1175                        {
 01176                            value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement);
 1177                        }
 01178                        return Response.FromValue(value, message.Response);
 1179                    }
 1180                default:
 01181                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1182            }
 01183        }
 1184
 1185        internal Core.HttpMessage CreateListAtTenantScopeRequest(string filter, int? top)
 1186        {
 01187            var message = _pipeline.CreateMessage();
 01188            var request = message.Request;
 01189            request.Method = RequestMethod.Get;
 01190            var uri = new RawRequestUriBuilder();
 01191            uri.Reset(endpoint);
 01192            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 01193            if (filter != null)
 1194            {
 01195                uri.AppendQuery("$filter", filter, true);
 1196            }
 01197            if (top != null)
 1198            {
 01199                uri.AppendQuery("$top", top.Value, true);
 1200            }
 01201            uri.AppendQuery("api-version", "2019-10-01", true);
 01202            request.Uri = uri;
 01203            return message;
 1204        }
 1205
 1206        /// <summary> Get all the deployments at the tenant scope. </summary>
 1207        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 1208        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 1209        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1210        public async Task<Response<DeploymentListResult>> ListAtTenantScopeAsync(string filter = null, int? top = null, 
 1211        {
 01212            using var message = CreateListAtTenantScopeRequest(filter, top);
 01213            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01214            switch (message.Response.Status)
 1215            {
 1216                case 200:
 1217                    {
 01218                        DeploymentListResult value = default;
 01219                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 01220                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1221                        {
 01222                            value = null;
 1223                        }
 1224                        else
 1225                        {
 01226                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 1227                        }
 01228                        return Response.FromValue(value, message.Response);
 1229                    }
 1230                default:
 01231                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1232            }
 01233        }
 1234
 1235        /// <summary> Get all the deployments at the tenant scope. </summary>
 1236        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 1237        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 1238        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1239        public Response<DeploymentListResult> ListAtTenantScope(string filter = null, int? top = null, CancellationToken
 1240        {
 01241            using var message = CreateListAtTenantScopeRequest(filter, top);
 01242            _pipeline.Send(message, cancellationToken);
 01243            switch (message.Response.Status)
 1244            {
 1245                case 200:
 1246                    {
 01247                        DeploymentListResult value = default;
 01248                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 01249                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1250                        {
 01251                            value = null;
 1252                        }
 1253                        else
 1254                        {
 01255                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 1256                        }
 01257                        return Response.FromValue(value, message.Response);
 1258                    }
 1259                default:
 01260                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1261            }
 01262        }
 1263
 1264        internal Core.HttpMessage CreateDeleteAtManagementGroupScopeRequest(string groupId, string deploymentName)
 1265        {
 01266            var message = _pipeline.CreateMessage();
 01267            var request = message.Request;
 01268            request.Method = RequestMethod.Delete;
 01269            var uri = new RawRequestUriBuilder();
 01270            uri.Reset(endpoint);
 01271            uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false);
 01272            uri.AppendPath(groupId, true);
 01273            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 01274            uri.AppendPath(deploymentName, true);
 01275            uri.AppendQuery("api-version", "2019-10-01", true);
 01276            request.Uri = uri;
 01277            return message;
 1278        }
 1279
 1280        /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment 
 1281        /// <param name="groupId"> The management group ID. </param>
 1282        /// <param name="deploymentName"> The name of the deployment. </param>
 1283        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1284        public async Task<Response> DeleteAtManagementGroupScopeAsync(string groupId, string deploymentName, Cancellatio
 1285        {
 01286            if (groupId == null)
 1287            {
 01288                throw new ArgumentNullException(nameof(groupId));
 1289            }
 01290            if (deploymentName == null)
 1291            {
 01292                throw new ArgumentNullException(nameof(deploymentName));
 1293            }
 1294
 01295            using var message = CreateDeleteAtManagementGroupScopeRequest(groupId, deploymentName);
 01296            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01297            switch (message.Response.Status)
 1298            {
 1299                case 202:
 1300                case 204:
 01301                    return message.Response;
 1302                default:
 01303                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1304            }
 01305        }
 1306
 1307        /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment 
 1308        /// <param name="groupId"> The management group ID. </param>
 1309        /// <param name="deploymentName"> The name of the deployment. </param>
 1310        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1311        public Response DeleteAtManagementGroupScope(string groupId, string deploymentName, CancellationToken cancellati
 1312        {
 01313            if (groupId == null)
 1314            {
 01315                throw new ArgumentNullException(nameof(groupId));
 1316            }
 01317            if (deploymentName == null)
 1318            {
 01319                throw new ArgumentNullException(nameof(deploymentName));
 1320            }
 1321
 01322            using var message = CreateDeleteAtManagementGroupScopeRequest(groupId, deploymentName);
 01323            _pipeline.Send(message, cancellationToken);
 01324            switch (message.Response.Status)
 1325            {
 1326                case 202:
 1327                case 204:
 01328                    return message.Response;
 1329                default:
 01330                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1331            }
 01332        }
 1333
 1334        internal Core.HttpMessage CreateCheckExistenceAtManagementGroupScopeRequest(string groupId, string deploymentNam
 1335        {
 01336            var message = _pipeline.CreateMessage();
 01337            var request = message.Request;
 01338            request.Method = RequestMethod.Head;
 01339            var uri = new RawRequestUriBuilder();
 01340            uri.Reset(endpoint);
 01341            uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false);
 01342            uri.AppendPath(groupId, true);
 01343            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 01344            uri.AppendPath(deploymentName, true);
 01345            uri.AppendQuery("api-version", "2019-10-01", true);
 01346            request.Uri = uri;
 01347            return message;
 1348        }
 1349
 1350        /// <summary> Checks whether the deployment exists. </summary>
 1351        /// <param name="groupId"> The management group ID. </param>
 1352        /// <param name="deploymentName"> The name of the deployment. </param>
 1353        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1354        public async Task<Response> CheckExistenceAtManagementGroupScopeAsync(string groupId, string deploymentName, Can
 1355        {
 01356            if (groupId == null)
 1357            {
 01358                throw new ArgumentNullException(nameof(groupId));
 1359            }
 01360            if (deploymentName == null)
 1361            {
 01362                throw new ArgumentNullException(nameof(deploymentName));
 1363            }
 1364
 01365            using var message = CreateCheckExistenceAtManagementGroupScopeRequest(groupId, deploymentName);
 01366            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01367            switch (message.Response.Status)
 1368            {
 1369                case 204:
 1370                case 404:
 01371                    return message.Response;
 1372                default:
 01373                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1374            }
 01375        }
 1376
 1377        /// <summary> Checks whether the deployment exists. </summary>
 1378        /// <param name="groupId"> The management group ID. </param>
 1379        /// <param name="deploymentName"> The name of the deployment. </param>
 1380        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1381        public Response CheckExistenceAtManagementGroupScope(string groupId, string deploymentName, CancellationToken ca
 1382        {
 01383            if (groupId == null)
 1384            {
 01385                throw new ArgumentNullException(nameof(groupId));
 1386            }
 01387            if (deploymentName == null)
 1388            {
 01389                throw new ArgumentNullException(nameof(deploymentName));
 1390            }
 1391
 01392            using var message = CreateCheckExistenceAtManagementGroupScopeRequest(groupId, deploymentName);
 01393            _pipeline.Send(message, cancellationToken);
 01394            switch (message.Response.Status)
 1395            {
 1396                case 204:
 1397                case 404:
 01398                    return message.Response;
 1399                default:
 01400                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1401            }
 01402        }
 1403
 1404        internal Core.HttpMessage CreateCreateOrUpdateAtManagementGroupScopeRequest(string groupId, string deploymentNam
 1405        {
 81406            var message = _pipeline.CreateMessage();
 81407            var request = message.Request;
 81408            request.Method = RequestMethod.Put;
 81409            var uri = new RawRequestUriBuilder();
 81410            uri.Reset(endpoint);
 81411            uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false);
 81412            uri.AppendPath(groupId, true);
 81413            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 81414            uri.AppendPath(deploymentName, true);
 81415            uri.AppendQuery("api-version", "2019-10-01", true);
 81416            request.Uri = uri;
 81417            request.Headers.Add("Content-Type", "application/json");
 81418            var content = new Utf8JsonRequestContent();
 81419            content.JsonWriter.WriteObjectValue(parameters);
 81420            request.Content = content;
 81421            return message;
 1422        }
 1423
 1424        /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa
 1425        /// <param name="groupId"> The management group ID. </param>
 1426        /// <param name="deploymentName"> The name of the deployment. </param>
 1427        /// <param name="parameters"> Additional parameters supplied to the operation. </param>
 1428        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1429        public async Task<Response> CreateOrUpdateAtManagementGroupScopeAsync(string groupId, string deploymentName, Sco
 1430        {
 21431            if (groupId == null)
 1432            {
 01433                throw new ArgumentNullException(nameof(groupId));
 1434            }
 21435            if (deploymentName == null)
 1436            {
 01437                throw new ArgumentNullException(nameof(deploymentName));
 1438            }
 21439            if (parameters == null)
 1440            {
 01441                throw new ArgumentNullException(nameof(parameters));
 1442            }
 1443
 21444            using var message = CreateCreateOrUpdateAtManagementGroupScopeRequest(groupId, deploymentName, parameters);
 21445            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 21446            switch (message.Response.Status)
 1447            {
 1448                case 200:
 1449                case 201:
 21450                    return message.Response;
 1451                default:
 01452                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1453            }
 21454        }
 1455
 1456        /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa
 1457        /// <param name="groupId"> The management group ID. </param>
 1458        /// <param name="deploymentName"> The name of the deployment. </param>
 1459        /// <param name="parameters"> Additional parameters supplied to the operation. </param>
 1460        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1461        public Response CreateOrUpdateAtManagementGroupScope(string groupId, string deploymentName, ScopedDeployment par
 1462        {
 21463            if (groupId == null)
 1464            {
 01465                throw new ArgumentNullException(nameof(groupId));
 1466            }
 21467            if (deploymentName == null)
 1468            {
 01469                throw new ArgumentNullException(nameof(deploymentName));
 1470            }
 21471            if (parameters == null)
 1472            {
 01473                throw new ArgumentNullException(nameof(parameters));
 1474            }
 1475
 21476            using var message = CreateCreateOrUpdateAtManagementGroupScopeRequest(groupId, deploymentName, parameters);
 21477            _pipeline.Send(message, cancellationToken);
 21478            switch (message.Response.Status)
 1479            {
 1480                case 200:
 1481                case 201:
 21482                    return message.Response;
 1483                default:
 01484                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1485            }
 21486        }
 1487
 1488        internal Core.HttpMessage CreateGetAtManagementGroupScopeRequest(string groupId, string deploymentName)
 1489        {
 41490            var message = _pipeline.CreateMessage();
 41491            var request = message.Request;
 41492            request.Method = RequestMethod.Get;
 41493            var uri = new RawRequestUriBuilder();
 41494            uri.Reset(endpoint);
 41495            uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false);
 41496            uri.AppendPath(groupId, true);
 41497            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 41498            uri.AppendPath(deploymentName, true);
 41499            uri.AppendQuery("api-version", "2019-10-01", true);
 41500            request.Uri = uri;
 41501            return message;
 1502        }
 1503
 1504        /// <summary> Gets a deployment. </summary>
 1505        /// <param name="groupId"> The management group ID. </param>
 1506        /// <param name="deploymentName"> The name of the deployment. </param>
 1507        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1508        public async Task<Response<DeploymentExtended>> GetAtManagementGroupScopeAsync(string groupId, string deployment
 1509        {
 21510            if (groupId == null)
 1511            {
 01512                throw new ArgumentNullException(nameof(groupId));
 1513            }
 21514            if (deploymentName == null)
 1515            {
 01516                throw new ArgumentNullException(nameof(deploymentName));
 1517            }
 1518
 21519            using var message = CreateGetAtManagementGroupScopeRequest(groupId, deploymentName);
 21520            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 21521            switch (message.Response.Status)
 1522            {
 1523                case 200:
 1524                    {
 21525                        DeploymentExtended value = default;
 21526                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 21527                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1528                        {
 01529                            value = null;
 1530                        }
 1531                        else
 1532                        {
 21533                            value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement);
 1534                        }
 21535                        return Response.FromValue(value, message.Response);
 1536                    }
 1537                default:
 01538                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1539            }
 21540        }
 1541
 1542        /// <summary> Gets a deployment. </summary>
 1543        /// <param name="groupId"> The management group ID. </param>
 1544        /// <param name="deploymentName"> The name of the deployment. </param>
 1545        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1546        public Response<DeploymentExtended> GetAtManagementGroupScope(string groupId, string deploymentName, Cancellatio
 1547        {
 21548            if (groupId == null)
 1549            {
 01550                throw new ArgumentNullException(nameof(groupId));
 1551            }
 21552            if (deploymentName == null)
 1553            {
 01554                throw new ArgumentNullException(nameof(deploymentName));
 1555            }
 1556
 21557            using var message = CreateGetAtManagementGroupScopeRequest(groupId, deploymentName);
 21558            _pipeline.Send(message, cancellationToken);
 21559            switch (message.Response.Status)
 1560            {
 1561                case 200:
 1562                    {
 21563                        DeploymentExtended value = default;
 21564                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 21565                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1566                        {
 01567                            value = null;
 1568                        }
 1569                        else
 1570                        {
 21571                            value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement);
 1572                        }
 21573                        return Response.FromValue(value, message.Response);
 1574                    }
 1575                default:
 01576                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1577            }
 21578        }
 1579
 1580        internal Core.HttpMessage CreateCancelAtManagementGroupScopeRequest(string groupId, string deploymentName)
 1581        {
 01582            var message = _pipeline.CreateMessage();
 01583            var request = message.Request;
 01584            request.Method = RequestMethod.Post;
 01585            var uri = new RawRequestUriBuilder();
 01586            uri.Reset(endpoint);
 01587            uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false);
 01588            uri.AppendPath(groupId, true);
 01589            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 01590            uri.AppendPath(deploymentName, true);
 01591            uri.AppendPath("/cancel", false);
 01592            uri.AppendQuery("api-version", "2019-10-01", true);
 01593            request.Uri = uri;
 01594            return message;
 1595        }
 1596
 1597        /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy
 1598        /// <param name="groupId"> The management group ID. </param>
 1599        /// <param name="deploymentName"> The name of the deployment. </param>
 1600        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1601        public async Task<Response> CancelAtManagementGroupScopeAsync(string groupId, string deploymentName, Cancellatio
 1602        {
 01603            if (groupId == null)
 1604            {
 01605                throw new ArgumentNullException(nameof(groupId));
 1606            }
 01607            if (deploymentName == null)
 1608            {
 01609                throw new ArgumentNullException(nameof(deploymentName));
 1610            }
 1611
 01612            using var message = CreateCancelAtManagementGroupScopeRequest(groupId, deploymentName);
 01613            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01614            switch (message.Response.Status)
 1615            {
 1616                case 204:
 01617                    return message.Response;
 1618                default:
 01619                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1620            }
 01621        }
 1622
 1623        /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy
 1624        /// <param name="groupId"> The management group ID. </param>
 1625        /// <param name="deploymentName"> The name of the deployment. </param>
 1626        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1627        public Response CancelAtManagementGroupScope(string groupId, string deploymentName, CancellationToken cancellati
 1628        {
 01629            if (groupId == null)
 1630            {
 01631                throw new ArgumentNullException(nameof(groupId));
 1632            }
 01633            if (deploymentName == null)
 1634            {
 01635                throw new ArgumentNullException(nameof(deploymentName));
 1636            }
 1637
 01638            using var message = CreateCancelAtManagementGroupScopeRequest(groupId, deploymentName);
 01639            _pipeline.Send(message, cancellationToken);
 01640            switch (message.Response.Status)
 1641            {
 1642                case 204:
 01643                    return message.Response;
 1644                default:
 01645                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1646            }
 01647        }
 1648
 1649        internal Core.HttpMessage CreateValidateAtManagementGroupScopeRequest(string groupId, string deploymentName, Sco
 1650        {
 81651            var message = _pipeline.CreateMessage();
 81652            var request = message.Request;
 81653            request.Method = RequestMethod.Post;
 81654            var uri = new RawRequestUriBuilder();
 81655            uri.Reset(endpoint);
 81656            uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false);
 81657            uri.AppendPath(groupId, true);
 81658            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 81659            uri.AppendPath(deploymentName, true);
 81660            uri.AppendPath("/validate", false);
 81661            uri.AppendQuery("api-version", "2019-10-01", true);
 81662            request.Uri = uri;
 81663            request.Headers.Add("Content-Type", "application/json");
 81664            var content = new Utf8JsonRequestContent();
 81665            content.JsonWriter.WriteObjectValue(parameters);
 81666            request.Content = content;
 81667            return message;
 1668        }
 1669
 1670        /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re
 1671        /// <param name="groupId"> The management group ID. </param>
 1672        /// <param name="deploymentName"> The name of the deployment. </param>
 1673        /// <param name="parameters"> Parameters to validate. </param>
 1674        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1675        public async Task<Response> ValidateAtManagementGroupScopeAsync(string groupId, string deploymentName, ScopedDep
 1676        {
 21677            if (groupId == null)
 1678            {
 01679                throw new ArgumentNullException(nameof(groupId));
 1680            }
 21681            if (deploymentName == null)
 1682            {
 01683                throw new ArgumentNullException(nameof(deploymentName));
 1684            }
 21685            if (parameters == null)
 1686            {
 01687                throw new ArgumentNullException(nameof(parameters));
 1688            }
 1689
 21690            using var message = CreateValidateAtManagementGroupScopeRequest(groupId, deploymentName, parameters);
 21691            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 21692            switch (message.Response.Status)
 1693            {
 1694                case 200:
 1695                case 202:
 1696                case 400:
 21697                    return message.Response;
 1698                default:
 01699                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1700            }
 21701        }
 1702
 1703        /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re
 1704        /// <param name="groupId"> The management group ID. </param>
 1705        /// <param name="deploymentName"> The name of the deployment. </param>
 1706        /// <param name="parameters"> Parameters to validate. </param>
 1707        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1708        public Response ValidateAtManagementGroupScope(string groupId, string deploymentName, ScopedDeployment parameter
 1709        {
 21710            if (groupId == null)
 1711            {
 01712                throw new ArgumentNullException(nameof(groupId));
 1713            }
 21714            if (deploymentName == null)
 1715            {
 01716                throw new ArgumentNullException(nameof(deploymentName));
 1717            }
 21718            if (parameters == null)
 1719            {
 01720                throw new ArgumentNullException(nameof(parameters));
 1721            }
 1722
 21723            using var message = CreateValidateAtManagementGroupScopeRequest(groupId, deploymentName, parameters);
 21724            _pipeline.Send(message, cancellationToken);
 21725            switch (message.Response.Status)
 1726            {
 1727                case 200:
 1728                case 202:
 1729                case 400:
 21730                    return message.Response;
 1731                default:
 01732                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1733            }
 21734        }
 1735
 1736        internal Core.HttpMessage CreateExportTemplateAtManagementGroupScopeRequest(string groupId, string deploymentNam
 1737        {
 01738            var message = _pipeline.CreateMessage();
 01739            var request = message.Request;
 01740            request.Method = RequestMethod.Post;
 01741            var uri = new RawRequestUriBuilder();
 01742            uri.Reset(endpoint);
 01743            uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false);
 01744            uri.AppendPath(groupId, true);
 01745            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 01746            uri.AppendPath(deploymentName, true);
 01747            uri.AppendPath("/exportTemplate", false);
 01748            uri.AppendQuery("api-version", "2019-10-01", true);
 01749            request.Uri = uri;
 01750            return message;
 1751        }
 1752
 1753        /// <summary> Exports the template used for specified deployment. </summary>
 1754        /// <param name="groupId"> The management group ID. </param>
 1755        /// <param name="deploymentName"> The name of the deployment. </param>
 1756        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1757        public async Task<Response<DeploymentExportResult>> ExportTemplateAtManagementGroupScopeAsync(string groupId, st
 1758        {
 01759            if (groupId == null)
 1760            {
 01761                throw new ArgumentNullException(nameof(groupId));
 1762            }
 01763            if (deploymentName == null)
 1764            {
 01765                throw new ArgumentNullException(nameof(deploymentName));
 1766            }
 1767
 01768            using var message = CreateExportTemplateAtManagementGroupScopeRequest(groupId, deploymentName);
 01769            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01770            switch (message.Response.Status)
 1771            {
 1772                case 200:
 1773                    {
 01774                        DeploymentExportResult value = default;
 01775                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 01776                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1777                        {
 01778                            value = null;
 1779                        }
 1780                        else
 1781                        {
 01782                            value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement);
 1783                        }
 01784                        return Response.FromValue(value, message.Response);
 1785                    }
 1786                default:
 01787                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1788            }
 01789        }
 1790
 1791        /// <summary> Exports the template used for specified deployment. </summary>
 1792        /// <param name="groupId"> The management group ID. </param>
 1793        /// <param name="deploymentName"> The name of the deployment. </param>
 1794        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1795        public Response<DeploymentExportResult> ExportTemplateAtManagementGroupScope(string groupId, string deploymentNa
 1796        {
 01797            if (groupId == null)
 1798            {
 01799                throw new ArgumentNullException(nameof(groupId));
 1800            }
 01801            if (deploymentName == null)
 1802            {
 01803                throw new ArgumentNullException(nameof(deploymentName));
 1804            }
 1805
 01806            using var message = CreateExportTemplateAtManagementGroupScopeRequest(groupId, deploymentName);
 01807            _pipeline.Send(message, cancellationToken);
 01808            switch (message.Response.Status)
 1809            {
 1810                case 200:
 1811                    {
 01812                        DeploymentExportResult value = default;
 01813                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 01814                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1815                        {
 01816                            value = null;
 1817                        }
 1818                        else
 1819                        {
 01820                            value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement);
 1821                        }
 01822                        return Response.FromValue(value, message.Response);
 1823                    }
 1824                default:
 01825                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1826            }
 01827        }
 1828
 1829        internal Core.HttpMessage CreateListAtManagementGroupScopeRequest(string groupId, string filter, int? top)
 1830        {
 01831            var message = _pipeline.CreateMessage();
 01832            var request = message.Request;
 01833            request.Method = RequestMethod.Get;
 01834            var uri = new RawRequestUriBuilder();
 01835            uri.Reset(endpoint);
 01836            uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false);
 01837            uri.AppendPath(groupId, true);
 01838            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 01839            if (filter != null)
 1840            {
 01841                uri.AppendQuery("$filter", filter, true);
 1842            }
 01843            if (top != null)
 1844            {
 01845                uri.AppendQuery("$top", top.Value, true);
 1846            }
 01847            uri.AppendQuery("api-version", "2019-10-01", true);
 01848            request.Uri = uri;
 01849            return message;
 1850        }
 1851
 1852        /// <summary> Get all the deployments for a management group. </summary>
 1853        /// <param name="groupId"> The management group ID. </param>
 1854        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 1855        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 1856        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1857        public async Task<Response<DeploymentListResult>> ListAtManagementGroupScopeAsync(string groupId, string filter 
 1858        {
 01859            if (groupId == null)
 1860            {
 01861                throw new ArgumentNullException(nameof(groupId));
 1862            }
 1863
 01864            using var message = CreateListAtManagementGroupScopeRequest(groupId, filter, top);
 01865            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01866            switch (message.Response.Status)
 1867            {
 1868                case 200:
 1869                    {
 01870                        DeploymentListResult value = default;
 01871                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 01872                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1873                        {
 01874                            value = null;
 1875                        }
 1876                        else
 1877                        {
 01878                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 1879                        }
 01880                        return Response.FromValue(value, message.Response);
 1881                    }
 1882                default:
 01883                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1884            }
 01885        }
 1886
 1887        /// <summary> Get all the deployments for a management group. </summary>
 1888        /// <param name="groupId"> The management group ID. </param>
 1889        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 1890        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 1891        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1892        public Response<DeploymentListResult> ListAtManagementGroupScope(string groupId, string filter = null, int? top 
 1893        {
 01894            if (groupId == null)
 1895            {
 01896                throw new ArgumentNullException(nameof(groupId));
 1897            }
 1898
 01899            using var message = CreateListAtManagementGroupScopeRequest(groupId, filter, top);
 01900            _pipeline.Send(message, cancellationToken);
 01901            switch (message.Response.Status)
 1902            {
 1903                case 200:
 1904                    {
 01905                        DeploymentListResult value = default;
 01906                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 01907                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1908                        {
 01909                            value = null;
 1910                        }
 1911                        else
 1912                        {
 01913                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 1914                        }
 01915                        return Response.FromValue(value, message.Response);
 1916                    }
 1917                default:
 01918                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1919            }
 01920        }
 1921
 1922        internal Core.HttpMessage CreateDeleteAtSubscriptionScopeRequest(string deploymentName)
 1923        {
 01924            var message = _pipeline.CreateMessage();
 01925            var request = message.Request;
 01926            request.Method = RequestMethod.Delete;
 01927            var uri = new RawRequestUriBuilder();
 01928            uri.Reset(endpoint);
 01929            uri.AppendPath("/subscriptions/", false);
 01930            uri.AppendPath(subscriptionId, true);
 01931            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 01932            uri.AppendPath(deploymentName, true);
 01933            uri.AppendQuery("api-version", "2019-10-01", true);
 01934            request.Uri = uri;
 01935            return message;
 1936        }
 1937
 1938        /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment 
 1939        /// <param name="deploymentName"> The name of the deployment. </param>
 1940        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1941        public async Task<Response> DeleteAtSubscriptionScopeAsync(string deploymentName, CancellationToken cancellation
 1942        {
 01943            if (deploymentName == null)
 1944            {
 01945                throw new ArgumentNullException(nameof(deploymentName));
 1946            }
 1947
 01948            using var message = CreateDeleteAtSubscriptionScopeRequest(deploymentName);
 01949            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01950            switch (message.Response.Status)
 1951            {
 1952                case 202:
 1953                case 204:
 01954                    return message.Response;
 1955                default:
 01956                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1957            }
 01958        }
 1959
 1960        /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment 
 1961        /// <param name="deploymentName"> The name of the deployment. </param>
 1962        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1963        public Response DeleteAtSubscriptionScope(string deploymentName, CancellationToken cancellationToken = default)
 1964        {
 01965            if (deploymentName == null)
 1966            {
 01967                throw new ArgumentNullException(nameof(deploymentName));
 1968            }
 1969
 01970            using var message = CreateDeleteAtSubscriptionScopeRequest(deploymentName);
 01971            _pipeline.Send(message, cancellationToken);
 01972            switch (message.Response.Status)
 1973            {
 1974                case 202:
 1975                case 204:
 01976                    return message.Response;
 1977                default:
 01978                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1979            }
 01980        }
 1981
 1982        internal Core.HttpMessage CreateCheckExistenceAtSubscriptionScopeRequest(string deploymentName)
 1983        {
 01984            var message = _pipeline.CreateMessage();
 01985            var request = message.Request;
 01986            request.Method = RequestMethod.Head;
 01987            var uri = new RawRequestUriBuilder();
 01988            uri.Reset(endpoint);
 01989            uri.AppendPath("/subscriptions/", false);
 01990            uri.AppendPath(subscriptionId, true);
 01991            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 01992            uri.AppendPath(deploymentName, true);
 01993            uri.AppendQuery("api-version", "2019-10-01", true);
 01994            request.Uri = uri;
 01995            return message;
 1996        }
 1997
 1998        /// <summary> Checks whether the deployment exists. </summary>
 1999        /// <param name="deploymentName"> The name of the deployment. </param>
 2000        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2001        public async Task<Response> CheckExistenceAtSubscriptionScopeAsync(string deploymentName, CancellationToken canc
 2002        {
 02003            if (deploymentName == null)
 2004            {
 02005                throw new ArgumentNullException(nameof(deploymentName));
 2006            }
 2007
 02008            using var message = CreateCheckExistenceAtSubscriptionScopeRequest(deploymentName);
 02009            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 02010            switch (message.Response.Status)
 2011            {
 2012                case 204:
 2013                case 404:
 02014                    return message.Response;
 2015                default:
 02016                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2017            }
 02018        }
 2019
 2020        /// <summary> Checks whether the deployment exists. </summary>
 2021        /// <param name="deploymentName"> The name of the deployment. </param>
 2022        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2023        public Response CheckExistenceAtSubscriptionScope(string deploymentName, CancellationToken cancellationToken = d
 2024        {
 02025            if (deploymentName == null)
 2026            {
 02027                throw new ArgumentNullException(nameof(deploymentName));
 2028            }
 2029
 02030            using var message = CreateCheckExistenceAtSubscriptionScopeRequest(deploymentName);
 02031            _pipeline.Send(message, cancellationToken);
 02032            switch (message.Response.Status)
 2033            {
 2034                case 204:
 2035                case 404:
 02036                    return message.Response;
 2037                default:
 02038                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2039            }
 02040        }
 2041
 2042        internal Core.HttpMessage CreateCreateOrUpdateAtSubscriptionScopeRequest(string deploymentName, Deployment param
 2043        {
 162044            var message = _pipeline.CreateMessage();
 162045            var request = message.Request;
 162046            request.Method = RequestMethod.Put;
 162047            var uri = new RawRequestUriBuilder();
 162048            uri.Reset(endpoint);
 162049            uri.AppendPath("/subscriptions/", false);
 162050            uri.AppendPath(subscriptionId, true);
 162051            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 162052            uri.AppendPath(deploymentName, true);
 162053            uri.AppendQuery("api-version", "2019-10-01", true);
 162054            request.Uri = uri;
 162055            request.Headers.Add("Content-Type", "application/json");
 162056            var content = new Utf8JsonRequestContent();
 162057            content.JsonWriter.WriteObjectValue(parameters);
 162058            request.Content = content;
 162059            return message;
 2060        }
 2061
 2062        /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa
 2063        /// <param name="deploymentName"> The name of the deployment. </param>
 2064        /// <param name="parameters"> Additional parameters supplied to the operation. </param>
 2065        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2066        public async Task<Response> CreateOrUpdateAtSubscriptionScopeAsync(string deploymentName, Deployment parameters,
 2067        {
 42068            if (deploymentName == null)
 2069            {
 02070                throw new ArgumentNullException(nameof(deploymentName));
 2071            }
 42072            if (parameters == null)
 2073            {
 02074                throw new ArgumentNullException(nameof(parameters));
 2075            }
 2076
 42077            using var message = CreateCreateOrUpdateAtSubscriptionScopeRequest(deploymentName, parameters);
 42078            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 42079            switch (message.Response.Status)
 2080            {
 2081                case 200:
 2082                case 201:
 42083                    return message.Response;
 2084                default:
 02085                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2086            }
 42087        }
 2088
 2089        /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa
 2090        /// <param name="deploymentName"> The name of the deployment. </param>
 2091        /// <param name="parameters"> Additional parameters supplied to the operation. </param>
 2092        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2093        public Response CreateOrUpdateAtSubscriptionScope(string deploymentName, Deployment parameters, CancellationToke
 2094        {
 42095            if (deploymentName == null)
 2096            {
 02097                throw new ArgumentNullException(nameof(deploymentName));
 2098            }
 42099            if (parameters == null)
 2100            {
 02101                throw new ArgumentNullException(nameof(parameters));
 2102            }
 2103
 42104            using var message = CreateCreateOrUpdateAtSubscriptionScopeRequest(deploymentName, parameters);
 42105            _pipeline.Send(message, cancellationToken);
 42106            switch (message.Response.Status)
 2107            {
 2108                case 200:
 2109                case 201:
 42110                    return message.Response;
 2111                default:
 02112                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2113            }
 42114        }
 2115
 2116        internal Core.HttpMessage CreateGetAtSubscriptionScopeRequest(string deploymentName)
 2117        {
 42118            var message = _pipeline.CreateMessage();
 42119            var request = message.Request;
 42120            request.Method = RequestMethod.Get;
 42121            var uri = new RawRequestUriBuilder();
 42122            uri.Reset(endpoint);
 42123            uri.AppendPath("/subscriptions/", false);
 42124            uri.AppendPath(subscriptionId, true);
 42125            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 42126            uri.AppendPath(deploymentName, true);
 42127            uri.AppendQuery("api-version", "2019-10-01", true);
 42128            request.Uri = uri;
 42129            return message;
 2130        }
 2131
 2132        /// <summary> Gets a deployment. </summary>
 2133        /// <param name="deploymentName"> The name of the deployment. </param>
 2134        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2135        public async Task<Response<DeploymentExtended>> GetAtSubscriptionScopeAsync(string deploymentName, CancellationT
 2136        {
 22137            if (deploymentName == null)
 2138            {
 02139                throw new ArgumentNullException(nameof(deploymentName));
 2140            }
 2141
 22142            using var message = CreateGetAtSubscriptionScopeRequest(deploymentName);
 22143            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 22144            switch (message.Response.Status)
 2145            {
 2146                case 200:
 2147                    {
 22148                        DeploymentExtended value = default;
 22149                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 22150                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 2151                        {
 02152                            value = null;
 2153                        }
 2154                        else
 2155                        {
 22156                            value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement);
 2157                        }
 22158                        return Response.FromValue(value, message.Response);
 2159                    }
 2160                default:
 02161                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2162            }
 22163        }
 2164
 2165        /// <summary> Gets a deployment. </summary>
 2166        /// <param name="deploymentName"> The name of the deployment. </param>
 2167        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2168        public Response<DeploymentExtended> GetAtSubscriptionScope(string deploymentName, CancellationToken cancellation
 2169        {
 22170            if (deploymentName == null)
 2171            {
 02172                throw new ArgumentNullException(nameof(deploymentName));
 2173            }
 2174
 22175            using var message = CreateGetAtSubscriptionScopeRequest(deploymentName);
 22176            _pipeline.Send(message, cancellationToken);
 22177            switch (message.Response.Status)
 2178            {
 2179                case 200:
 2180                    {
 22181                        DeploymentExtended value = default;
 22182                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 22183                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 2184                        {
 02185                            value = null;
 2186                        }
 2187                        else
 2188                        {
 22189                            value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement);
 2190                        }
 22191                        return Response.FromValue(value, message.Response);
 2192                    }
 2193                default:
 02194                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2195            }
 22196        }
 2197
 2198        internal Core.HttpMessage CreateCancelAtSubscriptionScopeRequest(string deploymentName)
 2199        {
 02200            var message = _pipeline.CreateMessage();
 02201            var request = message.Request;
 02202            request.Method = RequestMethod.Post;
 02203            var uri = new RawRequestUriBuilder();
 02204            uri.Reset(endpoint);
 02205            uri.AppendPath("/subscriptions/", false);
 02206            uri.AppendPath(subscriptionId, true);
 02207            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 02208            uri.AppendPath(deploymentName, true);
 02209            uri.AppendPath("/cancel", false);
 02210            uri.AppendQuery("api-version", "2019-10-01", true);
 02211            request.Uri = uri;
 02212            return message;
 2213        }
 2214
 2215        /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy
 2216        /// <param name="deploymentName"> The name of the deployment. </param>
 2217        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2218        public async Task<Response> CancelAtSubscriptionScopeAsync(string deploymentName, CancellationToken cancellation
 2219        {
 02220            if (deploymentName == null)
 2221            {
 02222                throw new ArgumentNullException(nameof(deploymentName));
 2223            }
 2224
 02225            using var message = CreateCancelAtSubscriptionScopeRequest(deploymentName);
 02226            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 02227            switch (message.Response.Status)
 2228            {
 2229                case 204:
 02230                    return message.Response;
 2231                default:
 02232                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2233            }
 02234        }
 2235
 2236        /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy
 2237        /// <param name="deploymentName"> The name of the deployment. </param>
 2238        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2239        public Response CancelAtSubscriptionScope(string deploymentName, CancellationToken cancellationToken = default)
 2240        {
 02241            if (deploymentName == null)
 2242            {
 02243                throw new ArgumentNullException(nameof(deploymentName));
 2244            }
 2245
 02246            using var message = CreateCancelAtSubscriptionScopeRequest(deploymentName);
 02247            _pipeline.Send(message, cancellationToken);
 02248            switch (message.Response.Status)
 2249            {
 2250                case 204:
 02251                    return message.Response;
 2252                default:
 02253                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2254            }
 02255        }
 2256
 2257        internal Core.HttpMessage CreateValidateAtSubscriptionScopeRequest(string deploymentName, Deployment parameters)
 2258        {
 82259            var message = _pipeline.CreateMessage();
 82260            var request = message.Request;
 82261            request.Method = RequestMethod.Post;
 82262            var uri = new RawRequestUriBuilder();
 82263            uri.Reset(endpoint);
 82264            uri.AppendPath("/subscriptions/", false);
 82265            uri.AppendPath(subscriptionId, true);
 82266            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 82267            uri.AppendPath(deploymentName, true);
 82268            uri.AppendPath("/validate", false);
 82269            uri.AppendQuery("api-version", "2019-10-01", true);
 82270            request.Uri = uri;
 82271            request.Headers.Add("Content-Type", "application/json");
 82272            var content = new Utf8JsonRequestContent();
 82273            content.JsonWriter.WriteObjectValue(parameters);
 82274            request.Content = content;
 82275            return message;
 2276        }
 2277
 2278        /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re
 2279        /// <param name="deploymentName"> The name of the deployment. </param>
 2280        /// <param name="parameters"> Parameters to validate. </param>
 2281        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2282        public async Task<Response> ValidateAtSubscriptionScopeAsync(string deploymentName, Deployment parameters, Cance
 2283        {
 22284            if (deploymentName == null)
 2285            {
 02286                throw new ArgumentNullException(nameof(deploymentName));
 2287            }
 22288            if (parameters == null)
 2289            {
 02290                throw new ArgumentNullException(nameof(parameters));
 2291            }
 2292
 22293            using var message = CreateValidateAtSubscriptionScopeRequest(deploymentName, parameters);
 22294            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 22295            switch (message.Response.Status)
 2296            {
 2297                case 200:
 2298                case 202:
 2299                case 400:
 22300                    return message.Response;
 2301                default:
 02302                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2303            }
 22304        }
 2305
 2306        /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re
 2307        /// <param name="deploymentName"> The name of the deployment. </param>
 2308        /// <param name="parameters"> Parameters to validate. </param>
 2309        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2310        public Response ValidateAtSubscriptionScope(string deploymentName, Deployment parameters, CancellationToken canc
 2311        {
 22312            if (deploymentName == null)
 2313            {
 02314                throw new ArgumentNullException(nameof(deploymentName));
 2315            }
 22316            if (parameters == null)
 2317            {
 02318                throw new ArgumentNullException(nameof(parameters));
 2319            }
 2320
 22321            using var message = CreateValidateAtSubscriptionScopeRequest(deploymentName, parameters);
 22322            _pipeline.Send(message, cancellationToken);
 22323            switch (message.Response.Status)
 2324            {
 2325                case 200:
 2326                case 202:
 2327                case 400:
 22328                    return message.Response;
 2329                default:
 02330                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2331            }
 22332        }
 2333
 2334        internal Core.HttpMessage CreateWhatIfAtSubscriptionScopeRequest(string deploymentName, DeploymentWhatIf paramet
 2335        {
 722336            var message = _pipeline.CreateMessage();
 722337            var request = message.Request;
 722338            request.Method = RequestMethod.Post;
 722339            var uri = new RawRequestUriBuilder();
 722340            uri.Reset(endpoint);
 722341            uri.AppendPath("/subscriptions/", false);
 722342            uri.AppendPath(subscriptionId, true);
 722343            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 722344            uri.AppendPath(deploymentName, true);
 722345            uri.AppendPath("/whatIf", false);
 722346            uri.AppendQuery("api-version", "2019-10-01", true);
 722347            request.Uri = uri;
 722348            request.Headers.Add("Content-Type", "application/json");
 722349            var content = new Utf8JsonRequestContent();
 722350            content.JsonWriter.WriteObjectValue(parameters);
 722351            request.Content = content;
 722352            return message;
 2353        }
 2354
 2355        /// <summary> Returns changes that will be made by the deployment if executed at the scope of the subscription. 
 2356        /// <param name="deploymentName"> The name of the deployment. </param>
 2357        /// <param name="parameters"> Parameters to What If. </param>
 2358        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2359        public async Task<ResponseWithHeaders<DeploymentsWhatIfAtSubscriptionScopeHeaders>> WhatIfAtSubscriptionScopeAsy
 2360        {
 182361            if (deploymentName == null)
 2362            {
 02363                throw new ArgumentNullException(nameof(deploymentName));
 2364            }
 182365            if (parameters == null)
 2366            {
 02367                throw new ArgumentNullException(nameof(parameters));
 2368            }
 2369
 182370            using var message = CreateWhatIfAtSubscriptionScopeRequest(deploymentName, parameters);
 182371            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 182372            var headers = new DeploymentsWhatIfAtSubscriptionScopeHeaders(message.Response);
 182373            switch (message.Response.Status)
 2374            {
 2375                case 200:
 2376                case 202:
 182377                    return ResponseWithHeaders.FromValue(headers, message.Response);
 2378                default:
 02379                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2380            }
 182381        }
 2382
 2383        /// <summary> Returns changes that will be made by the deployment if executed at the scope of the subscription. 
 2384        /// <param name="deploymentName"> The name of the deployment. </param>
 2385        /// <param name="parameters"> Parameters to What If. </param>
 2386        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2387        public ResponseWithHeaders<DeploymentsWhatIfAtSubscriptionScopeHeaders> WhatIfAtSubscriptionScope(string deploym
 2388        {
 182389            if (deploymentName == null)
 2390            {
 02391                throw new ArgumentNullException(nameof(deploymentName));
 2392            }
 182393            if (parameters == null)
 2394            {
 02395                throw new ArgumentNullException(nameof(parameters));
 2396            }
 2397
 182398            using var message = CreateWhatIfAtSubscriptionScopeRequest(deploymentName, parameters);
 182399            _pipeline.Send(message, cancellationToken);
 182400            var headers = new DeploymentsWhatIfAtSubscriptionScopeHeaders(message.Response);
 182401            switch (message.Response.Status)
 2402            {
 2403                case 200:
 2404                case 202:
 182405                    return ResponseWithHeaders.FromValue(headers, message.Response);
 2406                default:
 02407                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2408            }
 182409        }
 2410
 2411        internal Core.HttpMessage CreateExportTemplateAtSubscriptionScopeRequest(string deploymentName)
 2412        {
 02413            var message = _pipeline.CreateMessage();
 02414            var request = message.Request;
 02415            request.Method = RequestMethod.Post;
 02416            var uri = new RawRequestUriBuilder();
 02417            uri.Reset(endpoint);
 02418            uri.AppendPath("/subscriptions/", false);
 02419            uri.AppendPath(subscriptionId, true);
 02420            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 02421            uri.AppendPath(deploymentName, true);
 02422            uri.AppendPath("/exportTemplate", false);
 02423            uri.AppendQuery("api-version", "2019-10-01", true);
 02424            request.Uri = uri;
 02425            return message;
 2426        }
 2427
 2428        /// <summary> Exports the template used for specified deployment. </summary>
 2429        /// <param name="deploymentName"> The name of the deployment. </param>
 2430        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2431        public async Task<Response<DeploymentExportResult>> ExportTemplateAtSubscriptionScopeAsync(string deploymentName
 2432        {
 02433            if (deploymentName == null)
 2434            {
 02435                throw new ArgumentNullException(nameof(deploymentName));
 2436            }
 2437
 02438            using var message = CreateExportTemplateAtSubscriptionScopeRequest(deploymentName);
 02439            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 02440            switch (message.Response.Status)
 2441            {
 2442                case 200:
 2443                    {
 02444                        DeploymentExportResult value = default;
 02445                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 02446                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 2447                        {
 02448                            value = null;
 2449                        }
 2450                        else
 2451                        {
 02452                            value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement);
 2453                        }
 02454                        return Response.FromValue(value, message.Response);
 2455                    }
 2456                default:
 02457                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2458            }
 02459        }
 2460
 2461        /// <summary> Exports the template used for specified deployment. </summary>
 2462        /// <param name="deploymentName"> The name of the deployment. </param>
 2463        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2464        public Response<DeploymentExportResult> ExportTemplateAtSubscriptionScope(string deploymentName, CancellationTok
 2465        {
 02466            if (deploymentName == null)
 2467            {
 02468                throw new ArgumentNullException(nameof(deploymentName));
 2469            }
 2470
 02471            using var message = CreateExportTemplateAtSubscriptionScopeRequest(deploymentName);
 02472            _pipeline.Send(message, cancellationToken);
 02473            switch (message.Response.Status)
 2474            {
 2475                case 200:
 2476                    {
 02477                        DeploymentExportResult value = default;
 02478                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 02479                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 2480                        {
 02481                            value = null;
 2482                        }
 2483                        else
 2484                        {
 02485                            value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement);
 2486                        }
 02487                        return Response.FromValue(value, message.Response);
 2488                    }
 2489                default:
 02490                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2491            }
 02492        }
 2493
 2494        internal Core.HttpMessage CreateListAtSubscriptionScopeRequest(string filter, int? top)
 2495        {
 02496            var message = _pipeline.CreateMessage();
 02497            var request = message.Request;
 02498            request.Method = RequestMethod.Get;
 02499            var uri = new RawRequestUriBuilder();
 02500            uri.Reset(endpoint);
 02501            uri.AppendPath("/subscriptions/", false);
 02502            uri.AppendPath(subscriptionId, true);
 02503            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 02504            if (filter != null)
 2505            {
 02506                uri.AppendQuery("$filter", filter, true);
 2507            }
 02508            if (top != null)
 2509            {
 02510                uri.AppendQuery("$top", top.Value, true);
 2511            }
 02512            uri.AppendQuery("api-version", "2019-10-01", true);
 02513            request.Uri = uri;
 02514            return message;
 2515        }
 2516
 2517        /// <summary> Get all the deployments for a subscription. </summary>
 2518        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 2519        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 2520        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2521        public async Task<Response<DeploymentListResult>> ListAtSubscriptionScopeAsync(string filter = null, int? top = 
 2522        {
 02523            using var message = CreateListAtSubscriptionScopeRequest(filter, top);
 02524            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 02525            switch (message.Response.Status)
 2526            {
 2527                case 200:
 2528                    {
 02529                        DeploymentListResult value = default;
 02530                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 02531                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 2532                        {
 02533                            value = null;
 2534                        }
 2535                        else
 2536                        {
 02537                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 2538                        }
 02539                        return Response.FromValue(value, message.Response);
 2540                    }
 2541                default:
 02542                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2543            }
 02544        }
 2545
 2546        /// <summary> Get all the deployments for a subscription. </summary>
 2547        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 2548        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 2549        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2550        public Response<DeploymentListResult> ListAtSubscriptionScope(string filter = null, int? top = null, Cancellatio
 2551        {
 02552            using var message = CreateListAtSubscriptionScopeRequest(filter, top);
 02553            _pipeline.Send(message, cancellationToken);
 02554            switch (message.Response.Status)
 2555            {
 2556                case 200:
 2557                    {
 02558                        DeploymentListResult value = default;
 02559                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 02560                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 2561                        {
 02562                            value = null;
 2563                        }
 2564                        else
 2565                        {
 02566                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 2567                        }
 02568                        return Response.FromValue(value, message.Response);
 2569                    }
 2570                default:
 02571                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2572            }
 02573        }
 2574
 2575        internal Core.HttpMessage CreateDeleteRequest(string resourceGroupName, string deploymentName)
 2576        {
 02577            var message = _pipeline.CreateMessage();
 02578            var request = message.Request;
 02579            request.Method = RequestMethod.Delete;
 02580            var uri = new RawRequestUriBuilder();
 02581            uri.Reset(endpoint);
 02582            uri.AppendPath("/subscriptions/", false);
 02583            uri.AppendPath(subscriptionId, true);
 02584            uri.AppendPath("/resourcegroups/", false);
 02585            uri.AppendPath(resourceGroupName, true);
 02586            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 02587            uri.AppendPath(deploymentName, true);
 02588            uri.AppendQuery("api-version", "2019-10-01", true);
 02589            request.Uri = uri;
 02590            return message;
 2591        }
 2592
 2593        /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment 
 2594        /// <param name="resourceGroupName"> The name of the resource group with the deployment to delete. The name is c
 2595        /// <param name="deploymentName"> The name of the deployment. </param>
 2596        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2597        public async Task<Response> DeleteAsync(string resourceGroupName, string deploymentName, CancellationToken cance
 2598        {
 02599            if (resourceGroupName == null)
 2600            {
 02601                throw new ArgumentNullException(nameof(resourceGroupName));
 2602            }
 02603            if (deploymentName == null)
 2604            {
 02605                throw new ArgumentNullException(nameof(deploymentName));
 2606            }
 2607
 02608            using var message = CreateDeleteRequest(resourceGroupName, deploymentName);
 02609            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 02610            switch (message.Response.Status)
 2611            {
 2612                case 202:
 2613                case 204:
 02614                    return message.Response;
 2615                default:
 02616                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2617            }
 02618        }
 2619
 2620        /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment 
 2621        /// <param name="resourceGroupName"> The name of the resource group with the deployment to delete. The name is c
 2622        /// <param name="deploymentName"> The name of the deployment. </param>
 2623        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2624        public Response Delete(string resourceGroupName, string deploymentName, CancellationToken cancellationToken = de
 2625        {
 02626            if (resourceGroupName == null)
 2627            {
 02628                throw new ArgumentNullException(nameof(resourceGroupName));
 2629            }
 02630            if (deploymentName == null)
 2631            {
 02632                throw new ArgumentNullException(nameof(deploymentName));
 2633            }
 2634
 02635            using var message = CreateDeleteRequest(resourceGroupName, deploymentName);
 02636            _pipeline.Send(message, cancellationToken);
 02637            switch (message.Response.Status)
 2638            {
 2639                case 202:
 2640                case 204:
 02641                    return message.Response;
 2642                default:
 02643                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2644            }
 02645        }
 2646
 2647        internal Core.HttpMessage CreateCheckExistenceRequest(string resourceGroupName, string deploymentName)
 2648        {
 02649            var message = _pipeline.CreateMessage();
 02650            var request = message.Request;
 02651            request.Method = RequestMethod.Head;
 02652            var uri = new RawRequestUriBuilder();
 02653            uri.Reset(endpoint);
 02654            uri.AppendPath("/subscriptions/", false);
 02655            uri.AppendPath(subscriptionId, true);
 02656            uri.AppendPath("/resourcegroups/", false);
 02657            uri.AppendPath(resourceGroupName, true);
 02658            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 02659            uri.AppendPath(deploymentName, true);
 02660            uri.AppendQuery("api-version", "2019-10-01", true);
 02661            request.Uri = uri;
 02662            return message;
 2663        }
 2664
 2665        /// <summary> Checks whether the deployment exists. </summary>
 2666        /// <param name="resourceGroupName"> The name of the resource group with the deployment to check. The name is ca
 2667        /// <param name="deploymentName"> The name of the deployment. </param>
 2668        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2669        public async Task<Response> CheckExistenceAsync(string resourceGroupName, string deploymentName, CancellationTok
 2670        {
 02671            if (resourceGroupName == null)
 2672            {
 02673                throw new ArgumentNullException(nameof(resourceGroupName));
 2674            }
 02675            if (deploymentName == null)
 2676            {
 02677                throw new ArgumentNullException(nameof(deploymentName));
 2678            }
 2679
 02680            using var message = CreateCheckExistenceRequest(resourceGroupName, deploymentName);
 02681            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 02682            switch (message.Response.Status)
 2683            {
 2684                case 204:
 2685                case 404:
 02686                    return message.Response;
 2687                default:
 02688                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2689            }
 02690        }
 2691
 2692        /// <summary> Checks whether the deployment exists. </summary>
 2693        /// <param name="resourceGroupName"> The name of the resource group with the deployment to check. The name is ca
 2694        /// <param name="deploymentName"> The name of the deployment. </param>
 2695        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2696        public Response CheckExistence(string resourceGroupName, string deploymentName, CancellationToken cancellationTo
 2697        {
 02698            if (resourceGroupName == null)
 2699            {
 02700                throw new ArgumentNullException(nameof(resourceGroupName));
 2701            }
 02702            if (deploymentName == null)
 2703            {
 02704                throw new ArgumentNullException(nameof(deploymentName));
 2705            }
 2706
 02707            using var message = CreateCheckExistenceRequest(resourceGroupName, deploymentName);
 02708            _pipeline.Send(message, cancellationToken);
 02709            switch (message.Response.Status)
 2710            {
 2711                case 204:
 2712                case 404:
 02713                    return message.Response;
 2714                default:
 02715                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2716            }
 02717        }
 2718
 2719        internal Core.HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string deploymentName, Deploymen
 2720        {
 642721            var message = _pipeline.CreateMessage();
 642722            var request = message.Request;
 642723            request.Method = RequestMethod.Put;
 642724            var uri = new RawRequestUriBuilder();
 642725            uri.Reset(endpoint);
 642726            uri.AppendPath("/subscriptions/", false);
 642727            uri.AppendPath(subscriptionId, true);
 642728            uri.AppendPath("/resourcegroups/", false);
 642729            uri.AppendPath(resourceGroupName, true);
 642730            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 642731            uri.AppendPath(deploymentName, true);
 642732            uri.AppendQuery("api-version", "2019-10-01", true);
 642733            request.Uri = uri;
 642734            request.Headers.Add("Content-Type", "application/json");
 642735            var content = new Utf8JsonRequestContent();
 642736            content.JsonWriter.WriteObjectValue(parameters);
 642737            request.Content = content;
 642738            return message;
 2739        }
 2740
 2741        /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa
 2742        /// <param name="resourceGroupName"> The name of the resource group to deploy the resources to. The name is case
 2743        /// <param name="deploymentName"> The name of the deployment. </param>
 2744        /// <param name="parameters"> Additional parameters supplied to the operation. </param>
 2745        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2746        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string deploymentName, Deployment para
 2747        {
 162748            if (resourceGroupName == null)
 2749            {
 02750                throw new ArgumentNullException(nameof(resourceGroupName));
 2751            }
 162752            if (deploymentName == null)
 2753            {
 02754                throw new ArgumentNullException(nameof(deploymentName));
 2755            }
 162756            if (parameters == null)
 2757            {
 02758                throw new ArgumentNullException(nameof(parameters));
 2759            }
 2760
 162761            using var message = CreateCreateOrUpdateRequest(resourceGroupName, deploymentName, parameters);
 162762            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 162763            switch (message.Response.Status)
 2764            {
 2765                case 200:
 2766                case 201:
 162767                    return message.Response;
 2768                default:
 02769                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2770            }
 162771        }
 2772
 2773        /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa
 2774        /// <param name="resourceGroupName"> The name of the resource group to deploy the resources to. The name is case
 2775        /// <param name="deploymentName"> The name of the deployment. </param>
 2776        /// <param name="parameters"> Additional parameters supplied to the operation. </param>
 2777        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2778        public Response CreateOrUpdate(string resourceGroupName, string deploymentName, Deployment parameters, Cancellat
 2779        {
 162780            if (resourceGroupName == null)
 2781            {
 02782                throw new ArgumentNullException(nameof(resourceGroupName));
 2783            }
 162784            if (deploymentName == null)
 2785            {
 02786                throw new ArgumentNullException(nameof(deploymentName));
 2787            }
 162788            if (parameters == null)
 2789            {
 02790                throw new ArgumentNullException(nameof(parameters));
 2791            }
 2792
 162793            using var message = CreateCreateOrUpdateRequest(resourceGroupName, deploymentName, parameters);
 162794            _pipeline.Send(message, cancellationToken);
 162795            switch (message.Response.Status)
 2796            {
 2797                case 200:
 2798                case 201:
 162799                    return message.Response;
 2800                default:
 02801                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2802            }
 162803        }
 2804
 2805        internal Core.HttpMessage CreateGetRequest(string resourceGroupName, string deploymentName)
 2806        {
 122807            var message = _pipeline.CreateMessage();
 122808            var request = message.Request;
 122809            request.Method = RequestMethod.Get;
 122810            var uri = new RawRequestUriBuilder();
 122811            uri.Reset(endpoint);
 122812            uri.AppendPath("/subscriptions/", false);
 122813            uri.AppendPath(subscriptionId, true);
 122814            uri.AppendPath("/resourcegroups/", false);
 122815            uri.AppendPath(resourceGroupName, true);
 122816            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 122817            uri.AppendPath(deploymentName, true);
 122818            uri.AppendQuery("api-version", "2019-10-01", true);
 122819            request.Uri = uri;
 122820            return message;
 2821        }
 2822
 2823        /// <summary> Gets a deployment. </summary>
 2824        /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param>
 2825        /// <param name="deploymentName"> The name of the deployment. </param>
 2826        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2827        public async Task<Response<DeploymentExtended>> GetAsync(string resourceGroupName, string deploymentName, Cancel
 2828        {
 62829            if (resourceGroupName == null)
 2830            {
 02831                throw new ArgumentNullException(nameof(resourceGroupName));
 2832            }
 62833            if (deploymentName == null)
 2834            {
 02835                throw new ArgumentNullException(nameof(deploymentName));
 2836            }
 2837
 62838            using var message = CreateGetRequest(resourceGroupName, deploymentName);
 62839            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 62840            switch (message.Response.Status)
 2841            {
 2842                case 200:
 2843                    {
 62844                        DeploymentExtended value = default;
 62845                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 62846                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 2847                        {
 02848                            value = null;
 2849                        }
 2850                        else
 2851                        {
 62852                            value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement);
 2853                        }
 62854                        return Response.FromValue(value, message.Response);
 2855                    }
 2856                default:
 02857                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2858            }
 62859        }
 2860
 2861        /// <summary> Gets a deployment. </summary>
 2862        /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param>
 2863        /// <param name="deploymentName"> The name of the deployment. </param>
 2864        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2865        public Response<DeploymentExtended> Get(string resourceGroupName, string deploymentName, CancellationToken cance
 2866        {
 62867            if (resourceGroupName == null)
 2868            {
 02869                throw new ArgumentNullException(nameof(resourceGroupName));
 2870            }
 62871            if (deploymentName == null)
 2872            {
 02873                throw new ArgumentNullException(nameof(deploymentName));
 2874            }
 2875
 62876            using var message = CreateGetRequest(resourceGroupName, deploymentName);
 62877            _pipeline.Send(message, cancellationToken);
 62878            switch (message.Response.Status)
 2879            {
 2880                case 200:
 2881                    {
 62882                        DeploymentExtended value = default;
 62883                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 62884                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 2885                        {
 02886                            value = null;
 2887                        }
 2888                        else
 2889                        {
 62890                            value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement);
 2891                        }
 62892                        return Response.FromValue(value, message.Response);
 2893                    }
 2894                default:
 02895                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2896            }
 62897        }
 2898
 2899        internal Core.HttpMessage CreateCancelRequest(string resourceGroupName, string deploymentName)
 2900        {
 42901            var message = _pipeline.CreateMessage();
 42902            var request = message.Request;
 42903            request.Method = RequestMethod.Post;
 42904            var uri = new RawRequestUriBuilder();
 42905            uri.Reset(endpoint);
 42906            uri.AppendPath("/subscriptions/", false);
 42907            uri.AppendPath(subscriptionId, true);
 42908            uri.AppendPath("/resourcegroups/", false);
 42909            uri.AppendPath(resourceGroupName, true);
 42910            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 42911            uri.AppendPath(deploymentName, true);
 42912            uri.AppendPath("/cancel", false);
 42913            uri.AppendQuery("api-version", "2019-10-01", true);
 42914            request.Uri = uri;
 42915            return message;
 2916        }
 2917
 2918        /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy
 2919        /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param>
 2920        /// <param name="deploymentName"> The name of the deployment. </param>
 2921        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2922        public async Task<Response> CancelAsync(string resourceGroupName, string deploymentName, CancellationToken cance
 2923        {
 62924            if (resourceGroupName == null)
 2925            {
 22926                throw new ArgumentNullException(nameof(resourceGroupName));
 2927            }
 42928            if (deploymentName == null)
 2929            {
 22930                throw new ArgumentNullException(nameof(deploymentName));
 2931            }
 2932
 22933            using var message = CreateCancelRequest(resourceGroupName, deploymentName);
 22934            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 22935            switch (message.Response.Status)
 2936            {
 2937                case 204:
 22938                    return message.Response;
 2939                default:
 02940                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2941            }
 22942        }
 2943
 2944        /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy
 2945        /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param>
 2946        /// <param name="deploymentName"> The name of the deployment. </param>
 2947        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2948        public Response Cancel(string resourceGroupName, string deploymentName, CancellationToken cancellationToken = de
 2949        {
 62950            if (resourceGroupName == null)
 2951            {
 22952                throw new ArgumentNullException(nameof(resourceGroupName));
 2953            }
 42954            if (deploymentName == null)
 2955            {
 22956                throw new ArgumentNullException(nameof(deploymentName));
 2957            }
 2958
 22959            using var message = CreateCancelRequest(resourceGroupName, deploymentName);
 22960            _pipeline.Send(message, cancellationToken);
 22961            switch (message.Response.Status)
 2962            {
 2963                case 204:
 22964                    return message.Response;
 2965                default:
 02966                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2967            }
 22968        }
 2969
 2970        internal Core.HttpMessage CreateValidateRequest(string resourceGroupName, string deploymentName, Deployment para
 2971        {
 482972            var message = _pipeline.CreateMessage();
 482973            var request = message.Request;
 482974            request.Method = RequestMethod.Post;
 482975            var uri = new RawRequestUriBuilder();
 482976            uri.Reset(endpoint);
 482977            uri.AppendPath("/subscriptions/", false);
 482978            uri.AppendPath(subscriptionId, true);
 482979            uri.AppendPath("/resourcegroups/", false);
 482980            uri.AppendPath(resourceGroupName, true);
 482981            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 482982            uri.AppendPath(deploymentName, true);
 482983            uri.AppendPath("/validate", false);
 482984            uri.AppendQuery("api-version", "2019-10-01", true);
 482985            request.Uri = uri;
 482986            request.Headers.Add("Content-Type", "application/json");
 482987            var content = new Utf8JsonRequestContent();
 482988            content.JsonWriter.WriteObjectValue(parameters);
 482989            request.Content = content;
 482990            return message;
 2991        }
 2992
 2993        /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re
 2994        /// <param name="resourceGroupName"> The name of the resource group the template will be deployed to. The name i
 2995        /// <param name="deploymentName"> The name of the deployment. </param>
 2996        /// <param name="parameters"> Parameters to validate. </param>
 2997        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2998        public async Task<Response> ValidateAsync(string resourceGroupName, string deploymentName, Deployment parameters
 2999        {
 123000            if (resourceGroupName == null)
 3001            {
 03002                throw new ArgumentNullException(nameof(resourceGroupName));
 3003            }
 123004            if (deploymentName == null)
 3005            {
 03006                throw new ArgumentNullException(nameof(deploymentName));
 3007            }
 123008            if (parameters == null)
 3009            {
 03010                throw new ArgumentNullException(nameof(parameters));
 3011            }
 3012
 123013            using var message = CreateValidateRequest(resourceGroupName, deploymentName, parameters);
 123014            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 123015            switch (message.Response.Status)
 3016            {
 3017                case 200:
 3018                case 202:
 3019                case 400:
 123020                    return message.Response;
 3021                default:
 03022                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 3023            }
 123024        }
 3025
 3026        /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re
 3027        /// <param name="resourceGroupName"> The name of the resource group the template will be deployed to. The name i
 3028        /// <param name="deploymentName"> The name of the deployment. </param>
 3029        /// <param name="parameters"> Parameters to validate. </param>
 3030        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3031        public Response Validate(string resourceGroupName, string deploymentName, Deployment parameters, CancellationTok
 3032        {
 123033            if (resourceGroupName == null)
 3034            {
 03035                throw new ArgumentNullException(nameof(resourceGroupName));
 3036            }
 123037            if (deploymentName == null)
 3038            {
 03039                throw new ArgumentNullException(nameof(deploymentName));
 3040            }
 123041            if (parameters == null)
 3042            {
 03043                throw new ArgumentNullException(nameof(parameters));
 3044            }
 3045
 123046            using var message = CreateValidateRequest(resourceGroupName, deploymentName, parameters);
 123047            _pipeline.Send(message, cancellationToken);
 123048            switch (message.Response.Status)
 3049            {
 3050                case 200:
 3051                case 202:
 3052                case 400:
 123053                    return message.Response;
 3054                default:
 03055                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 3056            }
 123057        }
 3058
 3059        internal Core.HttpMessage CreateWhatIfRequest(string resourceGroupName, string deploymentName, DeploymentWhatIf 
 3060        {
 803061            var message = _pipeline.CreateMessage();
 803062            var request = message.Request;
 803063            request.Method = RequestMethod.Post;
 803064            var uri = new RawRequestUriBuilder();
 803065            uri.Reset(endpoint);
 803066            uri.AppendPath("/subscriptions/", false);
 803067            uri.AppendPath(subscriptionId, true);
 803068            uri.AppendPath("/resourcegroups/", false);
 803069            uri.AppendPath(resourceGroupName, true);
 803070            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 803071            uri.AppendPath(deploymentName, true);
 803072            uri.AppendPath("/whatIf", false);
 803073            uri.AppendQuery("api-version", "2019-10-01", true);
 803074            request.Uri = uri;
 803075            request.Headers.Add("Content-Type", "application/json");
 803076            var content = new Utf8JsonRequestContent();
 803077            content.JsonWriter.WriteObjectValue(parameters);
 803078            request.Content = content;
 803079            return message;
 3080        }
 3081
 3082        /// <summary> Returns changes that will be made by the deployment if executed at the scope of the resource group
 3083        /// <param name="resourceGroupName"> The name of the resource group the template will be deployed to. The name i
 3084        /// <param name="deploymentName"> The name of the deployment. </param>
 3085        /// <param name="parameters"> Parameters to validate. </param>
 3086        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3087        public async Task<ResponseWithHeaders<DeploymentsWhatIfHeaders>> WhatIfAsync(string resourceGroupName, string de
 3088        {
 203089            if (resourceGroupName == null)
 3090            {
 03091                throw new ArgumentNullException(nameof(resourceGroupName));
 3092            }
 203093            if (deploymentName == null)
 3094            {
 03095                throw new ArgumentNullException(nameof(deploymentName));
 3096            }
 203097            if (parameters == null)
 3098            {
 03099                throw new ArgumentNullException(nameof(parameters));
 3100            }
 3101
 203102            using var message = CreateWhatIfRequest(resourceGroupName, deploymentName, parameters);
 203103            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 203104            var headers = new DeploymentsWhatIfHeaders(message.Response);
 203105            switch (message.Response.Status)
 3106            {
 3107                case 200:
 3108                case 202:
 203109                    return ResponseWithHeaders.FromValue(headers, message.Response);
 3110                default:
 03111                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 3112            }
 203113        }
 3114
 3115        /// <summary> Returns changes that will be made by the deployment if executed at the scope of the resource group
 3116        /// <param name="resourceGroupName"> The name of the resource group the template will be deployed to. The name i
 3117        /// <param name="deploymentName"> The name of the deployment. </param>
 3118        /// <param name="parameters"> Parameters to validate. </param>
 3119        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3120        public ResponseWithHeaders<DeploymentsWhatIfHeaders> WhatIf(string resourceGroupName, string deploymentName, Dep
 3121        {
 203122            if (resourceGroupName == null)
 3123            {
 03124                throw new ArgumentNullException(nameof(resourceGroupName));
 3125            }
 203126            if (deploymentName == null)
 3127            {
 03128                throw new ArgumentNullException(nameof(deploymentName));
 3129            }
 203130            if (parameters == null)
 3131            {
 03132                throw new ArgumentNullException(nameof(parameters));
 3133            }
 3134
 203135            using var message = CreateWhatIfRequest(resourceGroupName, deploymentName, parameters);
 203136            _pipeline.Send(message, cancellationToken);
 203137            var headers = new DeploymentsWhatIfHeaders(message.Response);
 203138            switch (message.Response.Status)
 3139            {
 3140                case 200:
 3141                case 202:
 203142                    return ResponseWithHeaders.FromValue(headers, message.Response);
 3143                default:
 03144                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 3145            }
 203146        }
 3147
 3148        internal Core.HttpMessage CreateExportTemplateRequest(string resourceGroupName, string deploymentName)
 3149        {
 03150            var message = _pipeline.CreateMessage();
 03151            var request = message.Request;
 03152            request.Method = RequestMethod.Post;
 03153            var uri = new RawRequestUriBuilder();
 03154            uri.Reset(endpoint);
 03155            uri.AppendPath("/subscriptions/", false);
 03156            uri.AppendPath(subscriptionId, true);
 03157            uri.AppendPath("/resourcegroups/", false);
 03158            uri.AppendPath(resourceGroupName, true);
 03159            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 03160            uri.AppendPath(deploymentName, true);
 03161            uri.AppendPath("/exportTemplate", false);
 03162            uri.AppendQuery("api-version", "2019-10-01", true);
 03163            request.Uri = uri;
 03164            return message;
 3165        }
 3166
 3167        /// <summary> Exports the template used for specified deployment. </summary>
 3168        /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param>
 3169        /// <param name="deploymentName"> The name of the deployment. </param>
 3170        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3171        public async Task<Response<DeploymentExportResult>> ExportTemplateAsync(string resourceGroupName, string deploym
 3172        {
 03173            if (resourceGroupName == null)
 3174            {
 03175                throw new ArgumentNullException(nameof(resourceGroupName));
 3176            }
 03177            if (deploymentName == null)
 3178            {
 03179                throw new ArgumentNullException(nameof(deploymentName));
 3180            }
 3181
 03182            using var message = CreateExportTemplateRequest(resourceGroupName, deploymentName);
 03183            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 03184            switch (message.Response.Status)
 3185            {
 3186                case 200:
 3187                    {
 03188                        DeploymentExportResult value = default;
 03189                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 03190                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3191                        {
 03192                            value = null;
 3193                        }
 3194                        else
 3195                        {
 03196                            value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement);
 3197                        }
 03198                        return Response.FromValue(value, message.Response);
 3199                    }
 3200                default:
 03201                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 3202            }
 03203        }
 3204
 3205        /// <summary> Exports the template used for specified deployment. </summary>
 3206        /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param>
 3207        /// <param name="deploymentName"> The name of the deployment. </param>
 3208        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3209        public Response<DeploymentExportResult> ExportTemplate(string resourceGroupName, string deploymentName, Cancella
 3210        {
 03211            if (resourceGroupName == null)
 3212            {
 03213                throw new ArgumentNullException(nameof(resourceGroupName));
 3214            }
 03215            if (deploymentName == null)
 3216            {
 03217                throw new ArgumentNullException(nameof(deploymentName));
 3218            }
 3219
 03220            using var message = CreateExportTemplateRequest(resourceGroupName, deploymentName);
 03221            _pipeline.Send(message, cancellationToken);
 03222            switch (message.Response.Status)
 3223            {
 3224                case 200:
 3225                    {
 03226                        DeploymentExportResult value = default;
 03227                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 03228                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3229                        {
 03230                            value = null;
 3231                        }
 3232                        else
 3233                        {
 03234                            value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement);
 3235                        }
 03236                        return Response.FromValue(value, message.Response);
 3237                    }
 3238                default:
 03239                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 3240            }
 03241        }
 3242
 3243        internal Core.HttpMessage CreateListByResourceGroupRequest(string resourceGroupName, string filter, int? top)
 3244        {
 163245            var message = _pipeline.CreateMessage();
 163246            var request = message.Request;
 163247            request.Method = RequestMethod.Get;
 163248            var uri = new RawRequestUriBuilder();
 163249            uri.Reset(endpoint);
 163250            uri.AppendPath("/subscriptions/", false);
 163251            uri.AppendPath(subscriptionId, true);
 163252            uri.AppendPath("/resourcegroups/", false);
 163253            uri.AppendPath(resourceGroupName, true);
 163254            uri.AppendPath("/providers/Microsoft.Resources/deployments/", false);
 163255            if (filter != null)
 3256            {
 43257                uri.AppendQuery("$filter", filter, true);
 3258            }
 163259            if (top != null)
 3260            {
 43261                uri.AppendQuery("$top", top.Value, true);
 3262            }
 163263            uri.AppendQuery("api-version", "2019-10-01", true);
 163264            request.Uri = uri;
 163265            return message;
 3266        }
 3267
 3268        /// <summary> Get all the deployments for a resource group. </summary>
 3269        /// <param name="resourceGroupName"> The name of the resource group with the deployments to get. The name is cas
 3270        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 3271        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 3272        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3273        public async Task<Response<DeploymentListResult>> ListByResourceGroupAsync(string resourceGroupName, string filt
 3274        {
 83275            if (resourceGroupName == null)
 3276            {
 03277                throw new ArgumentNullException(nameof(resourceGroupName));
 3278            }
 3279
 83280            using var message = CreateListByResourceGroupRequest(resourceGroupName, filter, top);
 83281            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 83282            switch (message.Response.Status)
 3283            {
 3284                case 200:
 3285                    {
 83286                        DeploymentListResult value = default;
 83287                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 83288                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3289                        {
 03290                            value = null;
 3291                        }
 3292                        else
 3293                        {
 83294                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 3295                        }
 83296                        return Response.FromValue(value, message.Response);
 3297                    }
 3298                default:
 03299                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 3300            }
 83301        }
 3302
 3303        /// <summary> Get all the deployments for a resource group. </summary>
 3304        /// <param name="resourceGroupName"> The name of the resource group with the deployments to get. The name is cas
 3305        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 3306        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 3307        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3308        public Response<DeploymentListResult> ListByResourceGroup(string resourceGroupName, string filter = null, int? t
 3309        {
 83310            if (resourceGroupName == null)
 3311            {
 03312                throw new ArgumentNullException(nameof(resourceGroupName));
 3313            }
 3314
 83315            using var message = CreateListByResourceGroupRequest(resourceGroupName, filter, top);
 83316            _pipeline.Send(message, cancellationToken);
 83317            switch (message.Response.Status)
 3318            {
 3319                case 200:
 3320                    {
 83321                        DeploymentListResult value = default;
 83322                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 83323                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3324                        {
 03325                            value = null;
 3326                        }
 3327                        else
 3328                        {
 83329                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 3330                        }
 83331                        return Response.FromValue(value, message.Response);
 3332                    }
 3333                default:
 03334                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 3335            }
 83336        }
 3337
 3338        internal Core.HttpMessage CreateCalculateTemplateHashRequest(object template)
 3339        {
 03340            var message = _pipeline.CreateMessage();
 03341            var request = message.Request;
 03342            request.Method = RequestMethod.Post;
 03343            var uri = new RawRequestUriBuilder();
 03344            uri.Reset(endpoint);
 03345            uri.AppendPath("/providers/Microsoft.Resources/calculateTemplateHash", false);
 03346            uri.AppendQuery("api-version", "2019-10-01", true);
 03347            request.Uri = uri;
 03348            request.Headers.Add("Content-Type", "application/json");
 03349            var content = new Utf8JsonRequestContent();
 03350            content.JsonWriter.WriteObjectValue(template);
 03351            request.Content = content;
 03352            return message;
 3353        }
 3354
 3355        /// <summary> Calculate the hash of the given template. </summary>
 3356        /// <param name="template"> The template provided to calculate hash. </param>
 3357        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3358        public async Task<Response<TemplateHashResult>> CalculateTemplateHashAsync(object template, CancellationToken ca
 3359        {
 03360            if (template == null)
 3361            {
 03362                throw new ArgumentNullException(nameof(template));
 3363            }
 3364
 03365            using var message = CreateCalculateTemplateHashRequest(template);
 03366            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 03367            switch (message.Response.Status)
 3368            {
 3369                case 200:
 3370                    {
 03371                        TemplateHashResult value = default;
 03372                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 03373                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3374                        {
 03375                            value = null;
 3376                        }
 3377                        else
 3378                        {
 03379                            value = TemplateHashResult.DeserializeTemplateHashResult(document.RootElement);
 3380                        }
 03381                        return Response.FromValue(value, message.Response);
 3382                    }
 3383                default:
 03384                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 3385            }
 03386        }
 3387
 3388        /// <summary> Calculate the hash of the given template. </summary>
 3389        /// <param name="template"> The template provided to calculate hash. </param>
 3390        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3391        public Response<TemplateHashResult> CalculateTemplateHash(object template, CancellationToken cancellationToken =
 3392        {
 03393            if (template == null)
 3394            {
 03395                throw new ArgumentNullException(nameof(template));
 3396            }
 3397
 03398            using var message = CreateCalculateTemplateHashRequest(template);
 03399            _pipeline.Send(message, cancellationToken);
 03400            switch (message.Response.Status)
 3401            {
 3402                case 200:
 3403                    {
 03404                        TemplateHashResult value = default;
 03405                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 03406                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3407                        {
 03408                            value = null;
 3409                        }
 3410                        else
 3411                        {
 03412                            value = TemplateHashResult.DeserializeTemplateHashResult(document.RootElement);
 3413                        }
 03414                        return Response.FromValue(value, message.Response);
 3415                    }
 3416                default:
 03417                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 3418            }
 03419        }
 3420
 3421        internal Core.HttpMessage CreateListAtScopeNextPageRequest(string nextLink, string scope, string filter, int? to
 3422        {
 03423            var message = _pipeline.CreateMessage();
 03424            var request = message.Request;
 03425            request.Method = RequestMethod.Get;
 03426            var uri = new RawRequestUriBuilder();
 03427            uri.Reset(endpoint);
 03428            uri.AppendRawNextLink(nextLink, false);
 03429            request.Uri = uri;
 03430            return message;
 3431        }
 3432
 3433        /// <summary> Get all the deployments at the given scope. </summary>
 3434        /// <param name="nextLink"> The URL to the next page of results. </param>
 3435        /// <param name="scope"> The resource scope. </param>
 3436        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 3437        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 3438        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3439        public async Task<Response<DeploymentListResult>> ListAtScopeNextPageAsync(string nextLink, string scope, string
 3440        {
 03441            if (nextLink == null)
 3442            {
 03443                throw new ArgumentNullException(nameof(nextLink));
 3444            }
 03445            if (scope == null)
 3446            {
 03447                throw new ArgumentNullException(nameof(scope));
 3448            }
 3449
 03450            using var message = CreateListAtScopeNextPageRequest(nextLink, scope, filter, top);
 03451            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 03452            switch (message.Response.Status)
 3453            {
 3454                case 200:
 3455                    {
 03456                        DeploymentListResult value = default;
 03457                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 03458                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3459                        {
 03460                            value = null;
 3461                        }
 3462                        else
 3463                        {
 03464                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 3465                        }
 03466                        return Response.FromValue(value, message.Response);
 3467                    }
 3468                default:
 03469                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 3470            }
 03471        }
 3472
 3473        /// <summary> Get all the deployments at the given scope. </summary>
 3474        /// <param name="nextLink"> The URL to the next page of results. </param>
 3475        /// <param name="scope"> The resource scope. </param>
 3476        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 3477        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 3478        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3479        public Response<DeploymentListResult> ListAtScopeNextPage(string nextLink, string scope, string filter = null, i
 3480        {
 03481            if (nextLink == null)
 3482            {
 03483                throw new ArgumentNullException(nameof(nextLink));
 3484            }
 03485            if (scope == null)
 3486            {
 03487                throw new ArgumentNullException(nameof(scope));
 3488            }
 3489
 03490            using var message = CreateListAtScopeNextPageRequest(nextLink, scope, filter, top);
 03491            _pipeline.Send(message, cancellationToken);
 03492            switch (message.Response.Status)
 3493            {
 3494                case 200:
 3495                    {
 03496                        DeploymentListResult value = default;
 03497                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 03498                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3499                        {
 03500                            value = null;
 3501                        }
 3502                        else
 3503                        {
 03504                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 3505                        }
 03506                        return Response.FromValue(value, message.Response);
 3507                    }
 3508                default:
 03509                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 3510            }
 03511        }
 3512
 3513        internal Core.HttpMessage CreateListAtTenantScopeNextPageRequest(string nextLink, string filter, int? top)
 3514        {
 03515            var message = _pipeline.CreateMessage();
 03516            var request = message.Request;
 03517            request.Method = RequestMethod.Get;
 03518            var uri = new RawRequestUriBuilder();
 03519            uri.Reset(endpoint);
 03520            uri.AppendRawNextLink(nextLink, false);
 03521            request.Uri = uri;
 03522            return message;
 3523        }
 3524
 3525        /// <summary> Get all the deployments at the tenant scope. </summary>
 3526        /// <param name="nextLink"> The URL to the next page of results. </param>
 3527        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 3528        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 3529        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3530        public async Task<Response<DeploymentListResult>> ListAtTenantScopeNextPageAsync(string nextLink, string filter 
 3531        {
 03532            if (nextLink == null)
 3533            {
 03534                throw new ArgumentNullException(nameof(nextLink));
 3535            }
 3536
 03537            using var message = CreateListAtTenantScopeNextPageRequest(nextLink, filter, top);
 03538            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 03539            switch (message.Response.Status)
 3540            {
 3541                case 200:
 3542                    {
 03543                        DeploymentListResult value = default;
 03544                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 03545                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3546                        {
 03547                            value = null;
 3548                        }
 3549                        else
 3550                        {
 03551                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 3552                        }
 03553                        return Response.FromValue(value, message.Response);
 3554                    }
 3555                default:
 03556                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 3557            }
 03558        }
 3559
 3560        /// <summary> Get all the deployments at the tenant scope. </summary>
 3561        /// <param name="nextLink"> The URL to the next page of results. </param>
 3562        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 3563        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 3564        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3565        public Response<DeploymentListResult> ListAtTenantScopeNextPage(string nextLink, string filter = null, int? top 
 3566        {
 03567            if (nextLink == null)
 3568            {
 03569                throw new ArgumentNullException(nameof(nextLink));
 3570            }
 3571
 03572            using var message = CreateListAtTenantScopeNextPageRequest(nextLink, filter, top);
 03573            _pipeline.Send(message, cancellationToken);
 03574            switch (message.Response.Status)
 3575            {
 3576                case 200:
 3577                    {
 03578                        DeploymentListResult value = default;
 03579                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 03580                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3581                        {
 03582                            value = null;
 3583                        }
 3584                        else
 3585                        {
 03586                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 3587                        }
 03588                        return Response.FromValue(value, message.Response);
 3589                    }
 3590                default:
 03591                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 3592            }
 03593        }
 3594
 3595        internal Core.HttpMessage CreateListAtManagementGroupScopeNextPageRequest(string nextLink, string groupId, strin
 3596        {
 03597            var message = _pipeline.CreateMessage();
 03598            var request = message.Request;
 03599            request.Method = RequestMethod.Get;
 03600            var uri = new RawRequestUriBuilder();
 03601            uri.Reset(endpoint);
 03602            uri.AppendRawNextLink(nextLink, false);
 03603            request.Uri = uri;
 03604            return message;
 3605        }
 3606
 3607        /// <summary> Get all the deployments for a management group. </summary>
 3608        /// <param name="nextLink"> The URL to the next page of results. </param>
 3609        /// <param name="groupId"> The management group ID. </param>
 3610        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 3611        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 3612        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3613        public async Task<Response<DeploymentListResult>> ListAtManagementGroupScopeNextPageAsync(string nextLink, strin
 3614        {
 03615            if (nextLink == null)
 3616            {
 03617                throw new ArgumentNullException(nameof(nextLink));
 3618            }
 03619            if (groupId == null)
 3620            {
 03621                throw new ArgumentNullException(nameof(groupId));
 3622            }
 3623
 03624            using var message = CreateListAtManagementGroupScopeNextPageRequest(nextLink, groupId, filter, top);
 03625            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 03626            switch (message.Response.Status)
 3627            {
 3628                case 200:
 3629                    {
 03630                        DeploymentListResult value = default;
 03631                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 03632                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3633                        {
 03634                            value = null;
 3635                        }
 3636                        else
 3637                        {
 03638                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 3639                        }
 03640                        return Response.FromValue(value, message.Response);
 3641                    }
 3642                default:
 03643                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 3644            }
 03645        }
 3646
 3647        /// <summary> Get all the deployments for a management group. </summary>
 3648        /// <param name="nextLink"> The URL to the next page of results. </param>
 3649        /// <param name="groupId"> The management group ID. </param>
 3650        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 3651        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 3652        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3653        public Response<DeploymentListResult> ListAtManagementGroupScopeNextPage(string nextLink, string groupId, string
 3654        {
 03655            if (nextLink == null)
 3656            {
 03657                throw new ArgumentNullException(nameof(nextLink));
 3658            }
 03659            if (groupId == null)
 3660            {
 03661                throw new ArgumentNullException(nameof(groupId));
 3662            }
 3663
 03664            using var message = CreateListAtManagementGroupScopeNextPageRequest(nextLink, groupId, filter, top);
 03665            _pipeline.Send(message, cancellationToken);
 03666            switch (message.Response.Status)
 3667            {
 3668                case 200:
 3669                    {
 03670                        DeploymentListResult value = default;
 03671                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 03672                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3673                        {
 03674                            value = null;
 3675                        }
 3676                        else
 3677                        {
 03678                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 3679                        }
 03680                        return Response.FromValue(value, message.Response);
 3681                    }
 3682                default:
 03683                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 3684            }
 03685        }
 3686
 3687        internal Core.HttpMessage CreateListAtSubscriptionScopeNextPageRequest(string nextLink, string filter, int? top)
 3688        {
 03689            var message = _pipeline.CreateMessage();
 03690            var request = message.Request;
 03691            request.Method = RequestMethod.Get;
 03692            var uri = new RawRequestUriBuilder();
 03693            uri.Reset(endpoint);
 03694            uri.AppendRawNextLink(nextLink, false);
 03695            request.Uri = uri;
 03696            return message;
 3697        }
 3698
 3699        /// <summary> Get all the deployments for a subscription. </summary>
 3700        /// <param name="nextLink"> The URL to the next page of results. </param>
 3701        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 3702        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 3703        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3704        public async Task<Response<DeploymentListResult>> ListAtSubscriptionScopeNextPageAsync(string nextLink, string f
 3705        {
 03706            if (nextLink == null)
 3707            {
 03708                throw new ArgumentNullException(nameof(nextLink));
 3709            }
 3710
 03711            using var message = CreateListAtSubscriptionScopeNextPageRequest(nextLink, filter, top);
 03712            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 03713            switch (message.Response.Status)
 3714            {
 3715                case 200:
 3716                    {
 03717                        DeploymentListResult value = default;
 03718                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 03719                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3720                        {
 03721                            value = null;
 3722                        }
 3723                        else
 3724                        {
 03725                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 3726                        }
 03727                        return Response.FromValue(value, message.Response);
 3728                    }
 3729                default:
 03730                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 3731            }
 03732        }
 3733
 3734        /// <summary> Get all the deployments for a subscription. </summary>
 3735        /// <param name="nextLink"> The URL to the next page of results. </param>
 3736        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 3737        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 3738        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3739        public Response<DeploymentListResult> ListAtSubscriptionScopeNextPage(string nextLink, string filter = null, int
 3740        {
 03741            if (nextLink == null)
 3742            {
 03743                throw new ArgumentNullException(nameof(nextLink));
 3744            }
 3745
 03746            using var message = CreateListAtSubscriptionScopeNextPageRequest(nextLink, filter, top);
 03747            _pipeline.Send(message, cancellationToken);
 03748            switch (message.Response.Status)
 3749            {
 3750                case 200:
 3751                    {
 03752                        DeploymentListResult value = default;
 03753                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 03754                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3755                        {
 03756                            value = null;
 3757                        }
 3758                        else
 3759                        {
 03760                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 3761                        }
 03762                        return Response.FromValue(value, message.Response);
 3763                    }
 3764                default:
 03765                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 3766            }
 03767        }
 3768
 3769        internal Core.HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string resourceGroupName, st
 3770        {
 03771            var message = _pipeline.CreateMessage();
 03772            var request = message.Request;
 03773            request.Method = RequestMethod.Get;
 03774            var uri = new RawRequestUriBuilder();
 03775            uri.Reset(endpoint);
 03776            uri.AppendRawNextLink(nextLink, false);
 03777            request.Uri = uri;
 03778            return message;
 3779        }
 3780
 3781        /// <summary> Get all the deployments for a resource group. </summary>
 3782        /// <param name="nextLink"> The URL to the next page of results. </param>
 3783        /// <param name="resourceGroupName"> The name of the resource group with the deployments to get. The name is cas
 3784        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 3785        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 3786        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3787        public async Task<Response<DeploymentListResult>> ListByResourceGroupNextPageAsync(string nextLink, string resou
 3788        {
 03789            if (nextLink == null)
 3790            {
 03791                throw new ArgumentNullException(nameof(nextLink));
 3792            }
 03793            if (resourceGroupName == null)
 3794            {
 03795                throw new ArgumentNullException(nameof(resourceGroupName));
 3796            }
 3797
 03798            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName, filter, top);
 03799            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 03800            switch (message.Response.Status)
 3801            {
 3802                case 200:
 3803                    {
 03804                        DeploymentListResult value = default;
 03805                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 03806                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3807                        {
 03808                            value = null;
 3809                        }
 3810                        else
 3811                        {
 03812                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 3813                        }
 03814                        return Response.FromValue(value, message.Response);
 3815                    }
 3816                default:
 03817                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 3818            }
 03819        }
 3820
 3821        /// <summary> Get all the deployments for a resource group. </summary>
 3822        /// <param name="nextLink"> The URL to the next page of results. </param>
 3823        /// <param name="resourceGroupName"> The name of the resource group with the deployments to get. The name is cas
 3824        /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta
 3825        /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param>
 3826        /// <param name="cancellationToken"> The cancellation token to use. </param>
 3827        public Response<DeploymentListResult> ListByResourceGroupNextPage(string nextLink, string resourceGroupName, str
 3828        {
 03829            if (nextLink == null)
 3830            {
 03831                throw new ArgumentNullException(nameof(nextLink));
 3832            }
 03833            if (resourceGroupName == null)
 3834            {
 03835                throw new ArgumentNullException(nameof(resourceGroupName));
 3836            }
 3837
 03838            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName, filter, top);
 03839            _pipeline.Send(message, cancellationToken);
 03840            switch (message.Response.Status)
 3841            {
 3842                case 200:
 3843                    {
 03844                        DeploymentListResult value = default;
 03845                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 03846                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 3847                        {
 03848                            value = null;
 3849                        }
 3850                        else
 3851                        {
 03852                            value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement);
 3853                        }
 03854                        return Response.FromValue(value, message.Response);
 3855                    }
 3856                default:
 03857                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 3858            }
 03859        }
 3860    }
 3861}

Methods/Properties

.ctor(...)
CreateDeleteAtScopeRequest(...)
DeleteAtScopeAsync()
DeleteAtScope(...)
CreateCheckExistenceAtScopeRequest(...)
CheckExistenceAtScopeAsync()
CheckExistenceAtScope(...)
CreateCreateOrUpdateAtScopeRequest(...)
CreateOrUpdateAtScopeAsync()
CreateOrUpdateAtScope(...)
CreateGetAtScopeRequest(...)
GetAtScopeAsync()
GetAtScope(...)
CreateCancelAtScopeRequest(...)
CancelAtScopeAsync()
CancelAtScope(...)
CreateValidateAtScopeRequest(...)
ValidateAtScopeAsync()
ValidateAtScope(...)
CreateExportTemplateAtScopeRequest(...)
ExportTemplateAtScopeAsync()
ExportTemplateAtScope(...)
CreateListAtScopeRequest(...)
ListAtScopeAsync()
ListAtScope(...)
CreateDeleteAtTenantScopeRequest(...)
DeleteAtTenantScopeAsync()
DeleteAtTenantScope(...)
CreateCheckExistenceAtTenantScopeRequest(...)
CheckExistenceAtTenantScopeAsync()
CheckExistenceAtTenantScope(...)
CreateCreateOrUpdateAtTenantScopeRequest(...)
CreateOrUpdateAtTenantScopeAsync()
CreateOrUpdateAtTenantScope(...)
CreateGetAtTenantScopeRequest(...)
GetAtTenantScopeAsync()
GetAtTenantScope(...)
CreateCancelAtTenantScopeRequest(...)
CancelAtTenantScopeAsync()
CancelAtTenantScope(...)
CreateValidateAtTenantScopeRequest(...)
ValidateAtTenantScopeAsync()
ValidateAtTenantScope(...)
CreateExportTemplateAtTenantScopeRequest(...)
ExportTemplateAtTenantScopeAsync()
ExportTemplateAtTenantScope(...)
CreateListAtTenantScopeRequest(...)
ListAtTenantScopeAsync()
ListAtTenantScope(...)
CreateDeleteAtManagementGroupScopeRequest(...)
DeleteAtManagementGroupScopeAsync()
DeleteAtManagementGroupScope(...)
CreateCheckExistenceAtManagementGroupScopeRequest(...)
CheckExistenceAtManagementGroupScopeAsync()
CheckExistenceAtManagementGroupScope(...)
CreateCreateOrUpdateAtManagementGroupScopeRequest(...)
CreateOrUpdateAtManagementGroupScopeAsync()
CreateOrUpdateAtManagementGroupScope(...)
CreateGetAtManagementGroupScopeRequest(...)
GetAtManagementGroupScopeAsync()
GetAtManagementGroupScope(...)
CreateCancelAtManagementGroupScopeRequest(...)
CancelAtManagementGroupScopeAsync()
CancelAtManagementGroupScope(...)
CreateValidateAtManagementGroupScopeRequest(...)
ValidateAtManagementGroupScopeAsync()
ValidateAtManagementGroupScope(...)
CreateExportTemplateAtManagementGroupScopeRequest(...)
ExportTemplateAtManagementGroupScopeAsync()
ExportTemplateAtManagementGroupScope(...)
CreateListAtManagementGroupScopeRequest(...)
ListAtManagementGroupScopeAsync()
ListAtManagementGroupScope(...)
CreateDeleteAtSubscriptionScopeRequest(...)
DeleteAtSubscriptionScopeAsync()
DeleteAtSubscriptionScope(...)
CreateCheckExistenceAtSubscriptionScopeRequest(...)
CheckExistenceAtSubscriptionScopeAsync()
CheckExistenceAtSubscriptionScope(...)
CreateCreateOrUpdateAtSubscriptionScopeRequest(...)
CreateOrUpdateAtSubscriptionScopeAsync()
CreateOrUpdateAtSubscriptionScope(...)
CreateGetAtSubscriptionScopeRequest(...)
GetAtSubscriptionScopeAsync()
GetAtSubscriptionScope(...)
CreateCancelAtSubscriptionScopeRequest(...)
CancelAtSubscriptionScopeAsync()
CancelAtSubscriptionScope(...)
CreateValidateAtSubscriptionScopeRequest(...)
ValidateAtSubscriptionScopeAsync()
ValidateAtSubscriptionScope(...)
CreateWhatIfAtSubscriptionScopeRequest(...)
WhatIfAtSubscriptionScopeAsync()
WhatIfAtSubscriptionScope(...)
CreateExportTemplateAtSubscriptionScopeRequest(...)
ExportTemplateAtSubscriptionScopeAsync()
ExportTemplateAtSubscriptionScope(...)
CreateListAtSubscriptionScopeRequest(...)
ListAtSubscriptionScopeAsync()
ListAtSubscriptionScope(...)
CreateDeleteRequest(...)
DeleteAsync()
Delete(...)
CreateCheckExistenceRequest(...)
CheckExistenceAsync()
CheckExistence(...)
CreateCreateOrUpdateRequest(...)
CreateOrUpdateAsync()
CreateOrUpdate(...)
CreateGetRequest(...)
GetAsync()
Get(...)
CreateCancelRequest(...)
CancelAsync()
Cancel(...)
CreateValidateRequest(...)
ValidateAsync()
Validate(...)
CreateWhatIfRequest(...)
WhatIfAsync()
WhatIf(...)
CreateExportTemplateRequest(...)
ExportTemplateAsync()
ExportTemplate(...)
CreateListByResourceGroupRequest(...)
ListByResourceGroupAsync()
ListByResourceGroup(...)
CreateCalculateTemplateHashRequest(...)
CalculateTemplateHashAsync()
CalculateTemplateHash(...)
CreateListAtScopeNextPageRequest(...)
ListAtScopeNextPageAsync()
ListAtScopeNextPage(...)
CreateListAtTenantScopeNextPageRequest(...)
ListAtTenantScopeNextPageAsync()
ListAtTenantScopeNextPage(...)
CreateListAtManagementGroupScopeNextPageRequest(...)
ListAtManagementGroupScopeNextPageAsync()
ListAtManagementGroupScopeNextPage(...)
CreateListAtSubscriptionScopeNextPageRequest(...)
ListAtSubscriptionScopeNextPageAsync()
ListAtSubscriptionScopeNextPage(...)
CreateListByResourceGroupNextPageRequest(...)
ListByResourceGroupNextPageAsync()
ListByResourceGroupNextPage(...)