< Summary

Class:Azure.ResourceManager.Resources.ResourcesRestOperations
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\ResourcesRestOperations.cs
Covered lines:352
Uncovered lines:369
Coverable lines:721
Total lines:1600
Line coverage:48.8% (352 of 721)
Covered branches:120
Total branches:352
Branch coverage:34% (120 of 352)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateListByResourceGroupRequest(...)-94.74%83.33%
ListByResourceGroupAsync()-76.92%50%
ListByResourceGroup(...)-76.92%50%
CreateMoveResourcesRequest(...)-0%100%
MoveResourcesAsync()-0%0%
MoveResources(...)-0%0%
CreateValidateMoveResourcesRequest(...)-0%100%
ValidateMoveResourcesAsync()-0%0%
ValidateMoveResources(...)-0%0%
CreateListRequest(...)-82.35%50%
ListAsync()-81.82%50%
List(...)-81.82%50%
CreateCheckExistenceRequest(...)-100%100%
CheckExistenceAsync()-66.67%62.5%
CheckExistence(...)-66.67%62.5%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-61.11%50%
Delete(...)-61.11%50%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-60%50%
CreateOrUpdate(...)-60%50%
CreateUpdateRequest(...)-0%100%
UpdateAsync()-0%0%
Update(...)-0%0%
CreateGetRequest(...)-100%100%
GetAsync()-73.91%62.5%
Get(...)-73.91%62.5%
CreateCheckExistenceByIdRequest(...)-0%100%
CheckExistenceByIdAsync()-0%0%
CheckExistenceById(...)-0%0%
CreateDeleteByIdRequest(...)-100%100%
DeleteByIdAsync()-70%50%
DeleteById(...)-70%50%
CreateCreateOrUpdateByIdRequest(...)-100%100%
CreateOrUpdateByIdAsync()-66.67%50%
CreateOrUpdateById(...)-66.67%50%
CreateUpdateByIdRequest(...)-0%100%
UpdateByIdAsync()-0%0%
UpdateById(...)-0%0%
CreateGetByIdRequest(...)-100%100%
GetByIdAsync()-73.33%50%
GetById(...)-73.33%50%
CreateListByResourceGroupNextPageRequest(...)-0%100%
ListByResourceGroupNextPageAsync()-0%0%
ListByResourceGroupNextPage(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\ResourcesRestOperations.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 ResourcesRestOperations
 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 ResourcesRestOperations. </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
 33632        public ResourcesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId
 33        {
 33634            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 33638            endpoint ??= new Uri("https://management.azure.com");
 39
 33640            this.subscriptionId = subscriptionId;
 33641            this.endpoint = endpoint;
 33642            _clientDiagnostics = clientDiagnostics;
 33643            _pipeline = pipeline;
 33644        }
 45
 46        internal Core.HttpMessage CreateListByResourceGroupRequest(string resourceGroupName, string filter, string expan
 47        {
 3248            var message = _pipeline.CreateMessage();
 3249            var request = message.Request;
 3250            request.Method = RequestMethod.Get;
 3251            var uri = new RawRequestUriBuilder();
 3252            uri.Reset(endpoint);
 3253            uri.AppendPath("/subscriptions/", false);
 3254            uri.AppendPath(subscriptionId, true);
 3255            uri.AppendPath("/resourceGroups/", false);
 3256            uri.AppendPath(resourceGroupName, true);
 3257            uri.AppendPath("/resources", false);
 3258            if (filter != null)
 59            {
 1660                uri.AppendQuery("$filter", filter, true);
 61            }
 3262            if (expand != null)
 63            {
 064                uri.AppendQuery("$expand", expand, true);
 65            }
 3266            if (top != null)
 67            {
 468                uri.AppendQuery("$top", top.Value, true);
 69            }
 3270            uri.AppendQuery("api-version", "2019-10-01", true);
 3271            request.Uri = uri;
 3272            return message;
 73        }
 74
 75        /// <summary> Get all the resources for a resource group. </summary>
 76        /// <param name="resourceGroupName"> The resource group with the resources to get. </param>
 77        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;The properties you can use fo
 78        /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va
 79        /// <param name="top"> The number of results to return. If null is passed, returns all resources. </param>
 80        /// <param name="cancellationToken"> The cancellation token to use. </param>
 81        public async Task<Response<ResourceListResult>> ListByResourceGroupAsync(string resourceGroupName, string filter
 82        {
 1683            if (resourceGroupName == null)
 84            {
 085                throw new ArgumentNullException(nameof(resourceGroupName));
 86            }
 87
 1688            using var message = CreateListByResourceGroupRequest(resourceGroupName, filter, expand, top);
 1689            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 1690            switch (message.Response.Status)
 91            {
 92                case 200:
 93                    {
 1694                        ResourceListResult value = default;
 1695                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 1696                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 97                        {
 098                            value = null;
 99                        }
 100                        else
 101                        {
 16102                            value = ResourceListResult.DeserializeResourceListResult(document.RootElement);
 103                        }
 16104                        return Response.FromValue(value, message.Response);
 105                    }
 106                default:
 0107                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 108            }
 16109        }
 110
 111        /// <summary> Get all the resources for a resource group. </summary>
 112        /// <param name="resourceGroupName"> The resource group with the resources to get. </param>
 113        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;The properties you can use fo
 114        /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va
 115        /// <param name="top"> The number of results to return. If null is passed, returns all resources. </param>
 116        /// <param name="cancellationToken"> The cancellation token to use. </param>
 117        public Response<ResourceListResult> ListByResourceGroup(string resourceGroupName, string filter = null, string e
 118        {
 16119            if (resourceGroupName == null)
 120            {
 0121                throw new ArgumentNullException(nameof(resourceGroupName));
 122            }
 123
 16124            using var message = CreateListByResourceGroupRequest(resourceGroupName, filter, expand, top);
 16125            _pipeline.Send(message, cancellationToken);
 16126            switch (message.Response.Status)
 127            {
 128                case 200:
 129                    {
 16130                        ResourceListResult value = default;
 16131                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 16132                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 133                        {
 0134                            value = null;
 135                        }
 136                        else
 137                        {
 16138                            value = ResourceListResult.DeserializeResourceListResult(document.RootElement);
 139                        }
 16140                        return Response.FromValue(value, message.Response);
 141                    }
 142                default:
 0143                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 144            }
 16145        }
 146
 147        internal Core.HttpMessage CreateMoveResourcesRequest(string sourceResourceGroupName, ResourcesMoveInfo parameter
 148        {
 0149            var message = _pipeline.CreateMessage();
 0150            var request = message.Request;
 0151            request.Method = RequestMethod.Post;
 0152            var uri = new RawRequestUriBuilder();
 0153            uri.Reset(endpoint);
 0154            uri.AppendPath("/subscriptions/", false);
 0155            uri.AppendPath(subscriptionId, true);
 0156            uri.AppendPath("/resourceGroups/", false);
 0157            uri.AppendPath(sourceResourceGroupName, true);
 0158            uri.AppendPath("/moveResources", false);
 0159            uri.AppendQuery("api-version", "2019-10-01", true);
 0160            request.Uri = uri;
 0161            request.Headers.Add("Content-Type", "application/json");
 0162            var content = new Utf8JsonRequestContent();
 0163            content.JsonWriter.WriteObjectValue(parameters);
 0164            request.Content = content;
 0165            return message;
 166        }
 167
 168        /// <summary> The resources to move must be in the same source resource group. The target resource group may be 
 169        /// <param name="sourceResourceGroupName"> The name of the resource group containing the resources to move. </pa
 170        /// <param name="parameters"> Parameters for moving resources. </param>
 171        /// <param name="cancellationToken"> The cancellation token to use. </param>
 172        public async Task<Response> MoveResourcesAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, Can
 173        {
 0174            if (sourceResourceGroupName == null)
 175            {
 0176                throw new ArgumentNullException(nameof(sourceResourceGroupName));
 177            }
 0178            if (parameters == null)
 179            {
 0180                throw new ArgumentNullException(nameof(parameters));
 181            }
 182
 0183            using var message = CreateMoveResourcesRequest(sourceResourceGroupName, parameters);
 0184            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0185            switch (message.Response.Status)
 186            {
 187                case 202:
 188                case 204:
 0189                    return message.Response;
 190                default:
 0191                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 192            }
 0193        }
 194
 195        /// <summary> The resources to move must be in the same source resource group. The target resource group may be 
 196        /// <param name="sourceResourceGroupName"> The name of the resource group containing the resources to move. </pa
 197        /// <param name="parameters"> Parameters for moving resources. </param>
 198        /// <param name="cancellationToken"> The cancellation token to use. </param>
 199        public Response MoveResources(string sourceResourceGroupName, ResourcesMoveInfo parameters, CancellationToken ca
 200        {
 0201            if (sourceResourceGroupName == null)
 202            {
 0203                throw new ArgumentNullException(nameof(sourceResourceGroupName));
 204            }
 0205            if (parameters == null)
 206            {
 0207                throw new ArgumentNullException(nameof(parameters));
 208            }
 209
 0210            using var message = CreateMoveResourcesRequest(sourceResourceGroupName, parameters);
 0211            _pipeline.Send(message, cancellationToken);
 0212            switch (message.Response.Status)
 213            {
 214                case 202:
 215                case 204:
 0216                    return message.Response;
 217                default:
 0218                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 219            }
 0220        }
 221
 222        internal Core.HttpMessage CreateValidateMoveResourcesRequest(string sourceResourceGroupName, ResourcesMoveInfo p
 223        {
 0224            var message = _pipeline.CreateMessage();
 0225            var request = message.Request;
 0226            request.Method = RequestMethod.Post;
 0227            var uri = new RawRequestUriBuilder();
 0228            uri.Reset(endpoint);
 0229            uri.AppendPath("/subscriptions/", false);
 0230            uri.AppendPath(subscriptionId, true);
 0231            uri.AppendPath("/resourceGroups/", false);
 0232            uri.AppendPath(sourceResourceGroupName, true);
 0233            uri.AppendPath("/validateMoveResources", false);
 0234            uri.AppendQuery("api-version", "2019-10-01", true);
 0235            request.Uri = uri;
 0236            request.Headers.Add("Content-Type", "application/json");
 0237            var content = new Utf8JsonRequestContent();
 0238            content.JsonWriter.WriteObjectValue(parameters);
 0239            request.Content = content;
 0240            return message;
 241        }
 242
 243        /// <summary> This operation checks whether the specified resources can be moved to the target. The resources to
 244        /// <param name="sourceResourceGroupName"> The name of the resource group containing the resources to validate f
 245        /// <param name="parameters"> Parameters for moving resources. </param>
 246        /// <param name="cancellationToken"> The cancellation token to use. </param>
 247        public async Task<Response> ValidateMoveResourcesAsync(string sourceResourceGroupName, ResourcesMoveInfo paramet
 248        {
 0249            if (sourceResourceGroupName == null)
 250            {
 0251                throw new ArgumentNullException(nameof(sourceResourceGroupName));
 252            }
 0253            if (parameters == null)
 254            {
 0255                throw new ArgumentNullException(nameof(parameters));
 256            }
 257
 0258            using var message = CreateValidateMoveResourcesRequest(sourceResourceGroupName, parameters);
 0259            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0260            switch (message.Response.Status)
 261            {
 262                case 202:
 263                case 204:
 0264                    return message.Response;
 265                default:
 0266                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 267            }
 0268        }
 269
 270        /// <summary> This operation checks whether the specified resources can be moved to the target. The resources to
 271        /// <param name="sourceResourceGroupName"> The name of the resource group containing the resources to validate f
 272        /// <param name="parameters"> Parameters for moving resources. </param>
 273        /// <param name="cancellationToken"> The cancellation token to use. </param>
 274        public Response ValidateMoveResources(string sourceResourceGroupName, ResourcesMoveInfo parameters, Cancellation
 275        {
 0276            if (sourceResourceGroupName == null)
 277            {
 0278                throw new ArgumentNullException(nameof(sourceResourceGroupName));
 279            }
 0280            if (parameters == null)
 281            {
 0282                throw new ArgumentNullException(nameof(parameters));
 283            }
 284
 0285            using var message = CreateValidateMoveResourcesRequest(sourceResourceGroupName, parameters);
 0286            _pipeline.Send(message, cancellationToken);
 0287            switch (message.Response.Status)
 288            {
 289                case 202:
 290                case 204:
 0291                    return message.Response;
 292                default:
 0293                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 294            }
 0295        }
 296
 297        internal Core.HttpMessage CreateListRequest(string filter, string expand, int? top)
 298        {
 4299            var message = _pipeline.CreateMessage();
 4300            var request = message.Request;
 4301            request.Method = RequestMethod.Get;
 4302            var uri = new RawRequestUriBuilder();
 4303            uri.Reset(endpoint);
 4304            uri.AppendPath("/subscriptions/", false);
 4305            uri.AppendPath(subscriptionId, true);
 4306            uri.AppendPath("/resources", false);
 4307            if (filter != null)
 308            {
 0309                uri.AppendQuery("$filter", filter, true);
 310            }
 4311            if (expand != null)
 312            {
 0313                uri.AppendQuery("$expand", expand, true);
 314            }
 4315            if (top != null)
 316            {
 0317                uri.AppendQuery("$top", top.Value, true);
 318            }
 4319            uri.AppendQuery("api-version", "2019-10-01", true);
 4320            request.Uri = uri;
 4321            return message;
 322        }
 323
 324        /// <summary> Get all the resources in a subscription. </summary>
 325        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;The properties you can use fo
 326        /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va
 327        /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param>
 328        /// <param name="cancellationToken"> The cancellation token to use. </param>
 329        public async Task<Response<ResourceListResult>> ListAsync(string filter = null, string expand = null, int? top =
 330        {
 2331            using var message = CreateListRequest(filter, expand, top);
 2332            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2333            switch (message.Response.Status)
 334            {
 335                case 200:
 336                    {
 2337                        ResourceListResult value = default;
 2338                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2339                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 340                        {
 0341                            value = null;
 342                        }
 343                        else
 344                        {
 2345                            value = ResourceListResult.DeserializeResourceListResult(document.RootElement);
 346                        }
 2347                        return Response.FromValue(value, message.Response);
 348                    }
 349                default:
 0350                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 351            }
 2352        }
 353
 354        /// <summary> Get all the resources in a subscription. </summary>
 355        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;The properties you can use fo
 356        /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va
 357        /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param>
 358        /// <param name="cancellationToken"> The cancellation token to use. </param>
 359        public Response<ResourceListResult> List(string filter = null, string expand = null, int? top = null, Cancellati
 360        {
 2361            using var message = CreateListRequest(filter, expand, top);
 2362            _pipeline.Send(message, cancellationToken);
 2363            switch (message.Response.Status)
 364            {
 365                case 200:
 366                    {
 2367                        ResourceListResult value = default;
 2368                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2369                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 370                        {
 0371                            value = null;
 372                        }
 373                        else
 374                        {
 2375                            value = ResourceListResult.DeserializeResourceListResult(document.RootElement);
 376                        }
 2377                        return Response.FromValue(value, message.Response);
 378                    }
 379                default:
 0380                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 381            }
 2382        }
 383
 384        internal Core.HttpMessage CreateCheckExistenceRequest(string resourceGroupName, string resourceProviderNamespace
 385        {
 12386            var message = _pipeline.CreateMessage();
 12387            var request = message.Request;
 12388            request.Method = RequestMethod.Head;
 12389            var uri = new RawRequestUriBuilder();
 12390            uri.Reset(endpoint);
 12391            uri.AppendPath("/subscriptions/", false);
 12392            uri.AppendPath(subscriptionId, true);
 12393            uri.AppendPath("/resourcegroups/", false);
 12394            uri.AppendPath(resourceGroupName, true);
 12395            uri.AppendPath("/providers/", false);
 12396            uri.AppendPath(resourceProviderNamespace, true);
 12397            uri.AppendPath("/", false);
 12398            uri.AppendPath(parentResourcePath, false);
 12399            uri.AppendPath("/", false);
 12400            uri.AppendPath(resourceType, false);
 12401            uri.AppendPath("/", false);
 12402            uri.AppendPath(resourceName, true);
 12403            uri.AppendQuery("api-version", apiVersion, true);
 12404            request.Uri = uri;
 12405            return message;
 406        }
 407
 408        /// <summary> Checks whether a resource exists. </summary>
 409        /// <param name="resourceGroupName"> The name of the resource group containing the resource to check. The name i
 410        /// <param name="resourceProviderNamespace"> The resource provider of the resource to check. </param>
 411        /// <param name="parentResourcePath"> The parent resource identity. </param>
 412        /// <param name="resourceType"> The resource type. </param>
 413        /// <param name="resourceName"> The name of the resource to check whether it exists. </param>
 414        /// <param name="apiVersion"> The API version to use for the operation. </param>
 415        /// <param name="cancellationToken"> The cancellation token to use. </param>
 416        public async Task<Response> CheckExistenceAsync(string resourceGroupName, string resourceProviderNamespace, stri
 417        {
 8418            if (resourceGroupName == null)
 419            {
 0420                throw new ArgumentNullException(nameof(resourceGroupName));
 421            }
 8422            if (resourceProviderNamespace == null)
 423            {
 0424                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 425            }
 8426            if (parentResourcePath == null)
 427            {
 0428                throw new ArgumentNullException(nameof(parentResourcePath));
 429            }
 8430            if (resourceType == null)
 431            {
 0432                throw new ArgumentNullException(nameof(resourceType));
 433            }
 8434            if (resourceName == null)
 435            {
 0436                throw new ArgumentNullException(nameof(resourceName));
 437            }
 8438            if (apiVersion == null)
 439            {
 2440                throw new ArgumentNullException(nameof(apiVersion));
 441            }
 442
 6443            using var message = CreateCheckExistenceRequest(resourceGroupName, resourceProviderNamespace, parentResource
 6444            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 6445            switch (message.Response.Status)
 446            {
 447                case 204:
 448                case 404:
 6449                    return message.Response;
 450                default:
 0451                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 452            }
 6453        }
 454
 455        /// <summary> Checks whether a resource exists. </summary>
 456        /// <param name="resourceGroupName"> The name of the resource group containing the resource to check. The name i
 457        /// <param name="resourceProviderNamespace"> The resource provider of the resource to check. </param>
 458        /// <param name="parentResourcePath"> The parent resource identity. </param>
 459        /// <param name="resourceType"> The resource type. </param>
 460        /// <param name="resourceName"> The name of the resource to check whether it exists. </param>
 461        /// <param name="apiVersion"> The API version to use for the operation. </param>
 462        /// <param name="cancellationToken"> The cancellation token to use. </param>
 463        public Response CheckExistence(string resourceGroupName, string resourceProviderNamespace, string parentResource
 464        {
 8465            if (resourceGroupName == null)
 466            {
 0467                throw new ArgumentNullException(nameof(resourceGroupName));
 468            }
 8469            if (resourceProviderNamespace == null)
 470            {
 0471                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 472            }
 8473            if (parentResourcePath == null)
 474            {
 0475                throw new ArgumentNullException(nameof(parentResourcePath));
 476            }
 8477            if (resourceType == null)
 478            {
 0479                throw new ArgumentNullException(nameof(resourceType));
 480            }
 8481            if (resourceName == null)
 482            {
 0483                throw new ArgumentNullException(nameof(resourceName));
 484            }
 8485            if (apiVersion == null)
 486            {
 2487                throw new ArgumentNullException(nameof(apiVersion));
 488            }
 489
 6490            using var message = CreateCheckExistenceRequest(resourceGroupName, resourceProviderNamespace, parentResource
 6491            _pipeline.Send(message, cancellationToken);
 6492            switch (message.Response.Status)
 493            {
 494                case 204:
 495                case 404:
 6496                    return message.Response;
 497                default:
 0498                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 499            }
 6500        }
 501
 502        internal Core.HttpMessage CreateDeleteRequest(string resourceGroupName, string resourceProviderNamespace, string
 503        {
 24504            var message = _pipeline.CreateMessage();
 24505            var request = message.Request;
 24506            request.Method = RequestMethod.Delete;
 24507            var uri = new RawRequestUriBuilder();
 24508            uri.Reset(endpoint);
 24509            uri.AppendPath("/subscriptions/", false);
 24510            uri.AppendPath(subscriptionId, true);
 24511            uri.AppendPath("/resourcegroups/", false);
 24512            uri.AppendPath(resourceGroupName, true);
 24513            uri.AppendPath("/providers/", false);
 24514            uri.AppendPath(resourceProviderNamespace, true);
 24515            uri.AppendPath("/", false);
 24516            uri.AppendPath(parentResourcePath, false);
 24517            uri.AppendPath("/", false);
 24518            uri.AppendPath(resourceType, false);
 24519            uri.AppendPath("/", false);
 24520            uri.AppendPath(resourceName, true);
 24521            uri.AppendQuery("api-version", apiVersion, true);
 24522            request.Uri = uri;
 24523            return message;
 524        }
 525
 526        /// <summary> Deletes a resource. </summary>
 527        /// <param name="resourceGroupName"> The name of the resource group that contains the resource to delete. The na
 528        /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param>
 529        /// <param name="parentResourcePath"> The parent resource identity. </param>
 530        /// <param name="resourceType"> The resource type. </param>
 531        /// <param name="resourceName"> The name of the resource to delete. </param>
 532        /// <param name="apiVersion"> The API version to use for the operation. </param>
 533        /// <param name="cancellationToken"> The cancellation token to use. </param>
 534        public async Task<Response> DeleteAsync(string resourceGroupName, string resourceProviderNamespace, string paren
 535        {
 6536            if (resourceGroupName == null)
 537            {
 0538                throw new ArgumentNullException(nameof(resourceGroupName));
 539            }
 6540            if (resourceProviderNamespace == null)
 541            {
 0542                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 543            }
 6544            if (parentResourcePath == null)
 545            {
 0546                throw new ArgumentNullException(nameof(parentResourcePath));
 547            }
 6548            if (resourceType == null)
 549            {
 0550                throw new ArgumentNullException(nameof(resourceType));
 551            }
 6552            if (resourceName == null)
 553            {
 0554                throw new ArgumentNullException(nameof(resourceName));
 555            }
 6556            if (apiVersion == null)
 557            {
 0558                throw new ArgumentNullException(nameof(apiVersion));
 559            }
 560
 6561            using var message = CreateDeleteRequest(resourceGroupName, resourceProviderNamespace, parentResourcePath, re
 6562            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 6563            switch (message.Response.Status)
 564            {
 565                case 200:
 566                case 202:
 567                case 204:
 6568                    return message.Response;
 569                default:
 0570                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 571            }
 6572        }
 573
 574        /// <summary> Deletes a resource. </summary>
 575        /// <param name="resourceGroupName"> The name of the resource group that contains the resource to delete. The na
 576        /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param>
 577        /// <param name="parentResourcePath"> The parent resource identity. </param>
 578        /// <param name="resourceType"> The resource type. </param>
 579        /// <param name="resourceName"> The name of the resource to delete. </param>
 580        /// <param name="apiVersion"> The API version to use for the operation. </param>
 581        /// <param name="cancellationToken"> The cancellation token to use. </param>
 582        public Response Delete(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, st
 583        {
 6584            if (resourceGroupName == null)
 585            {
 0586                throw new ArgumentNullException(nameof(resourceGroupName));
 587            }
 6588            if (resourceProviderNamespace == null)
 589            {
 0590                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 591            }
 6592            if (parentResourcePath == null)
 593            {
 0594                throw new ArgumentNullException(nameof(parentResourcePath));
 595            }
 6596            if (resourceType == null)
 597            {
 0598                throw new ArgumentNullException(nameof(resourceType));
 599            }
 6600            if (resourceName == null)
 601            {
 0602                throw new ArgumentNullException(nameof(resourceName));
 603            }
 6604            if (apiVersion == null)
 605            {
 0606                throw new ArgumentNullException(nameof(apiVersion));
 607            }
 608
 6609            using var message = CreateDeleteRequest(resourceGroupName, resourceProviderNamespace, parentResourcePath, re
 6610            _pipeline.Send(message, cancellationToken);
 6611            switch (message.Response.Status)
 612            {
 613                case 200:
 614                case 202:
 615                case 204:
 6616                    return message.Response;
 617                default:
 0618                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 619            }
 6620        }
 621
 622        internal Core.HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string resourceProviderNamespace
 623        {
 96624            var message = _pipeline.CreateMessage();
 96625            var request = message.Request;
 96626            request.Method = RequestMethod.Put;
 96627            var uri = new RawRequestUriBuilder();
 96628            uri.Reset(endpoint);
 96629            uri.AppendPath("/subscriptions/", false);
 96630            uri.AppendPath(subscriptionId, true);
 96631            uri.AppendPath("/resourcegroups/", false);
 96632            uri.AppendPath(resourceGroupName, true);
 96633            uri.AppendPath("/providers/", false);
 96634            uri.AppendPath(resourceProviderNamespace, true);
 96635            uri.AppendPath("/", false);
 96636            uri.AppendPath(parentResourcePath, false);
 96637            uri.AppendPath("/", false);
 96638            uri.AppendPath(resourceType, false);
 96639            uri.AppendPath("/", false);
 96640            uri.AppendPath(resourceName, true);
 96641            uri.AppendQuery("api-version", apiVersion, true);
 96642            request.Uri = uri;
 96643            request.Headers.Add("Content-Type", "application/json");
 96644            var content = new Utf8JsonRequestContent();
 96645            content.JsonWriter.WriteObjectValue(parameters);
 96646            request.Content = content;
 96647            return message;
 648        }
 649
 650        /// <summary> Creates a resource. </summary>
 651        /// <param name="resourceGroupName"> The name of the resource group for the resource. The name is case insensiti
 652        /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param>
 653        /// <param name="parentResourcePath"> The parent resource identity. </param>
 654        /// <param name="resourceType"> The resource type of the resource to create. </param>
 655        /// <param name="resourceName"> The name of the resource to create. </param>
 656        /// <param name="apiVersion"> The API version to use for the operation. </param>
 657        /// <param name="parameters"> Parameters for creating or updating the resource. </param>
 658        /// <param name="cancellationToken"> The cancellation token to use. </param>
 659        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string resourceProviderNamespace, stri
 660        {
 24661            if (resourceGroupName == null)
 662            {
 0663                throw new ArgumentNullException(nameof(resourceGroupName));
 664            }
 24665            if (resourceProviderNamespace == null)
 666            {
 0667                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 668            }
 24669            if (parentResourcePath == null)
 670            {
 0671                throw new ArgumentNullException(nameof(parentResourcePath));
 672            }
 24673            if (resourceType == null)
 674            {
 0675                throw new ArgumentNullException(nameof(resourceType));
 676            }
 24677            if (resourceName == null)
 678            {
 0679                throw new ArgumentNullException(nameof(resourceName));
 680            }
 24681            if (apiVersion == null)
 682            {
 0683                throw new ArgumentNullException(nameof(apiVersion));
 684            }
 24685            if (parameters == null)
 686            {
 0687                throw new ArgumentNullException(nameof(parameters));
 688            }
 689
 24690            using var message = CreateCreateOrUpdateRequest(resourceGroupName, resourceProviderNamespace, parentResource
 24691            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 24692            switch (message.Response.Status)
 693            {
 694                case 200:
 695                case 201:
 696                case 202:
 24697                    return message.Response;
 698                default:
 0699                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 700            }
 24701        }
 702
 703        /// <summary> Creates a resource. </summary>
 704        /// <param name="resourceGroupName"> The name of the resource group for the resource. The name is case insensiti
 705        /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param>
 706        /// <param name="parentResourcePath"> The parent resource identity. </param>
 707        /// <param name="resourceType"> The resource type of the resource to create. </param>
 708        /// <param name="resourceName"> The name of the resource to create. </param>
 709        /// <param name="apiVersion"> The API version to use for the operation. </param>
 710        /// <param name="parameters"> Parameters for creating or updating the resource. </param>
 711        /// <param name="cancellationToken"> The cancellation token to use. </param>
 712        public Response CreateOrUpdate(string resourceGroupName, string resourceProviderNamespace, string parentResource
 713        {
 24714            if (resourceGroupName == null)
 715            {
 0716                throw new ArgumentNullException(nameof(resourceGroupName));
 717            }
 24718            if (resourceProviderNamespace == null)
 719            {
 0720                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 721            }
 24722            if (parentResourcePath == null)
 723            {
 0724                throw new ArgumentNullException(nameof(parentResourcePath));
 725            }
 24726            if (resourceType == null)
 727            {
 0728                throw new ArgumentNullException(nameof(resourceType));
 729            }
 24730            if (resourceName == null)
 731            {
 0732                throw new ArgumentNullException(nameof(resourceName));
 733            }
 24734            if (apiVersion == null)
 735            {
 0736                throw new ArgumentNullException(nameof(apiVersion));
 737            }
 24738            if (parameters == null)
 739            {
 0740                throw new ArgumentNullException(nameof(parameters));
 741            }
 742
 24743            using var message = CreateCreateOrUpdateRequest(resourceGroupName, resourceProviderNamespace, parentResource
 24744            _pipeline.Send(message, cancellationToken);
 24745            switch (message.Response.Status)
 746            {
 747                case 200:
 748                case 201:
 749                case 202:
 24750                    return message.Response;
 751                default:
 0752                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 753            }
 24754        }
 755
 756        internal Core.HttpMessage CreateUpdateRequest(string resourceGroupName, string resourceProviderNamespace, string
 757        {
 0758            var message = _pipeline.CreateMessage();
 0759            var request = message.Request;
 0760            request.Method = RequestMethod.Patch;
 0761            var uri = new RawRequestUriBuilder();
 0762            uri.Reset(endpoint);
 0763            uri.AppendPath("/subscriptions/", false);
 0764            uri.AppendPath(subscriptionId, true);
 0765            uri.AppendPath("/resourcegroups/", false);
 0766            uri.AppendPath(resourceGroupName, true);
 0767            uri.AppendPath("/providers/", false);
 0768            uri.AppendPath(resourceProviderNamespace, true);
 0769            uri.AppendPath("/", false);
 0770            uri.AppendPath(parentResourcePath, false);
 0771            uri.AppendPath("/", false);
 0772            uri.AppendPath(resourceType, false);
 0773            uri.AppendPath("/", false);
 0774            uri.AppendPath(resourceName, true);
 0775            uri.AppendQuery("api-version", apiVersion, true);
 0776            request.Uri = uri;
 0777            request.Headers.Add("Content-Type", "application/json");
 0778            var content = new Utf8JsonRequestContent();
 0779            content.JsonWriter.WriteObjectValue(parameters);
 0780            request.Content = content;
 0781            return message;
 782        }
 783
 784        /// <summary> Updates a resource. </summary>
 785        /// <param name="resourceGroupName"> The name of the resource group for the resource. The name is case insensiti
 786        /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param>
 787        /// <param name="parentResourcePath"> The parent resource identity. </param>
 788        /// <param name="resourceType"> The resource type of the resource to update. </param>
 789        /// <param name="resourceName"> The name of the resource to update. </param>
 790        /// <param name="apiVersion"> The API version to use for the operation. </param>
 791        /// <param name="parameters"> Parameters for updating the resource. </param>
 792        /// <param name="cancellationToken"> The cancellation token to use. </param>
 793        public async Task<Response> UpdateAsync(string resourceGroupName, string resourceProviderNamespace, string paren
 794        {
 0795            if (resourceGroupName == null)
 796            {
 0797                throw new ArgumentNullException(nameof(resourceGroupName));
 798            }
 0799            if (resourceProviderNamespace == null)
 800            {
 0801                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 802            }
 0803            if (parentResourcePath == null)
 804            {
 0805                throw new ArgumentNullException(nameof(parentResourcePath));
 806            }
 0807            if (resourceType == null)
 808            {
 0809                throw new ArgumentNullException(nameof(resourceType));
 810            }
 0811            if (resourceName == null)
 812            {
 0813                throw new ArgumentNullException(nameof(resourceName));
 814            }
 0815            if (apiVersion == null)
 816            {
 0817                throw new ArgumentNullException(nameof(apiVersion));
 818            }
 0819            if (parameters == null)
 820            {
 0821                throw new ArgumentNullException(nameof(parameters));
 822            }
 823
 0824            using var message = CreateUpdateRequest(resourceGroupName, resourceProviderNamespace, parentResourcePath, re
 0825            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0826            switch (message.Response.Status)
 827            {
 828                case 200:
 829                case 202:
 0830                    return message.Response;
 831                default:
 0832                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 833            }
 0834        }
 835
 836        /// <summary> Updates a resource. </summary>
 837        /// <param name="resourceGroupName"> The name of the resource group for the resource. The name is case insensiti
 838        /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param>
 839        /// <param name="parentResourcePath"> The parent resource identity. </param>
 840        /// <param name="resourceType"> The resource type of the resource to update. </param>
 841        /// <param name="resourceName"> The name of the resource to update. </param>
 842        /// <param name="apiVersion"> The API version to use for the operation. </param>
 843        /// <param name="parameters"> Parameters for updating the resource. </param>
 844        /// <param name="cancellationToken"> The cancellation token to use. </param>
 845        public Response Update(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, st
 846        {
 0847            if (resourceGroupName == null)
 848            {
 0849                throw new ArgumentNullException(nameof(resourceGroupName));
 850            }
 0851            if (resourceProviderNamespace == null)
 852            {
 0853                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 854            }
 0855            if (parentResourcePath == null)
 856            {
 0857                throw new ArgumentNullException(nameof(parentResourcePath));
 858            }
 0859            if (resourceType == null)
 860            {
 0861                throw new ArgumentNullException(nameof(resourceType));
 862            }
 0863            if (resourceName == null)
 864            {
 0865                throw new ArgumentNullException(nameof(resourceName));
 866            }
 0867            if (apiVersion == null)
 868            {
 0869                throw new ArgumentNullException(nameof(apiVersion));
 870            }
 0871            if (parameters == null)
 872            {
 0873                throw new ArgumentNullException(nameof(parameters));
 874            }
 875
 0876            using var message = CreateUpdateRequest(resourceGroupName, resourceProviderNamespace, parentResourcePath, re
 0877            _pipeline.Send(message, cancellationToken);
 0878            switch (message.Response.Status)
 879            {
 880                case 200:
 881                case 202:
 0882                    return message.Response;
 883                default:
 0884                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 885            }
 0886        }
 887
 888        internal Core.HttpMessage CreateGetRequest(string resourceGroupName, string resourceProviderNamespace, string pa
 889        {
 20890            var message = _pipeline.CreateMessage();
 20891            var request = message.Request;
 20892            request.Method = RequestMethod.Get;
 20893            var uri = new RawRequestUriBuilder();
 20894            uri.Reset(endpoint);
 20895            uri.AppendPath("/subscriptions/", false);
 20896            uri.AppendPath(subscriptionId, true);
 20897            uri.AppendPath("/resourcegroups/", false);
 20898            uri.AppendPath(resourceGroupName, true);
 20899            uri.AppendPath("/providers/", false);
 20900            uri.AppendPath(resourceProviderNamespace, true);
 20901            uri.AppendPath("/", false);
 20902            uri.AppendPath(parentResourcePath, false);
 20903            uri.AppendPath("/", false);
 20904            uri.AppendPath(resourceType, false);
 20905            uri.AppendPath("/", false);
 20906            uri.AppendPath(resourceName, true);
 20907            uri.AppendQuery("api-version", apiVersion, true);
 20908            request.Uri = uri;
 20909            return message;
 910        }
 911
 912        /// <summary> Gets a resource. </summary>
 913        /// <param name="resourceGroupName"> The name of the resource group containing the resource to get. The name is 
 914        /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param>
 915        /// <param name="parentResourcePath"> The parent resource identity. </param>
 916        /// <param name="resourceType"> The resource type of the resource. </param>
 917        /// <param name="resourceName"> The name of the resource to get. </param>
 918        /// <param name="apiVersion"> The API version to use for the operation. </param>
 919        /// <param name="cancellationToken"> The cancellation token to use. </param>
 920        public async Task<Response<GenericResource>> GetAsync(string resourceGroupName, string resourceProviderNamespace
 921        {
 14922            if (resourceGroupName == null)
 923            {
 2924                throw new ArgumentNullException(nameof(resourceGroupName));
 925            }
 12926            if (resourceProviderNamespace == null)
 927            {
 0928                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 929            }
 12930            if (parentResourcePath == null)
 931            {
 0932                throw new ArgumentNullException(nameof(parentResourcePath));
 933            }
 12934            if (resourceType == null)
 935            {
 0936                throw new ArgumentNullException(nameof(resourceType));
 937            }
 12938            if (resourceName == null)
 939            {
 0940                throw new ArgumentNullException(nameof(resourceName));
 941            }
 12942            if (apiVersion == null)
 943            {
 2944                throw new ArgumentNullException(nameof(apiVersion));
 945            }
 946
 10947            using var message = CreateGetRequest(resourceGroupName, resourceProviderNamespace, parentResourcePath, resou
 10948            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 10949            switch (message.Response.Status)
 950            {
 951                case 200:
 952                    {
 10953                        GenericResource value = default;
 10954                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 10955                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 956                        {
 0957                            value = null;
 958                        }
 959                        else
 960                        {
 10961                            value = GenericResource.DeserializeGenericResource(document.RootElement);
 962                        }
 10963                        return Response.FromValue(value, message.Response);
 964                    }
 965                default:
 0966                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 967            }
 10968        }
 969
 970        /// <summary> Gets a resource. </summary>
 971        /// <param name="resourceGroupName"> The name of the resource group containing the resource to get. The name is 
 972        /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param>
 973        /// <param name="parentResourcePath"> The parent resource identity. </param>
 974        /// <param name="resourceType"> The resource type of the resource. </param>
 975        /// <param name="resourceName"> The name of the resource to get. </param>
 976        /// <param name="apiVersion"> The API version to use for the operation. </param>
 977        /// <param name="cancellationToken"> The cancellation token to use. </param>
 978        public Response<GenericResource> Get(string resourceGroupName, string resourceProviderNamespace, string parentRe
 979        {
 14980            if (resourceGroupName == null)
 981            {
 2982                throw new ArgumentNullException(nameof(resourceGroupName));
 983            }
 12984            if (resourceProviderNamespace == null)
 985            {
 0986                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 987            }
 12988            if (parentResourcePath == null)
 989            {
 0990                throw new ArgumentNullException(nameof(parentResourcePath));
 991            }
 12992            if (resourceType == null)
 993            {
 0994                throw new ArgumentNullException(nameof(resourceType));
 995            }
 12996            if (resourceName == null)
 997            {
 0998                throw new ArgumentNullException(nameof(resourceName));
 999            }
 121000            if (apiVersion == null)
 1001            {
 21002                throw new ArgumentNullException(nameof(apiVersion));
 1003            }
 1004
 101005            using var message = CreateGetRequest(resourceGroupName, resourceProviderNamespace, parentResourcePath, resou
 101006            _pipeline.Send(message, cancellationToken);
 101007            switch (message.Response.Status)
 1008            {
 1009                case 200:
 1010                    {
 101011                        GenericResource value = default;
 101012                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 101013                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1014                        {
 01015                            value = null;
 1016                        }
 1017                        else
 1018                        {
 101019                            value = GenericResource.DeserializeGenericResource(document.RootElement);
 1020                        }
 101021                        return Response.FromValue(value, message.Response);
 1022                    }
 1023                default:
 01024                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1025            }
 101026        }
 1027
 1028        internal Core.HttpMessage CreateCheckExistenceByIdRequest(string resourceId, string apiVersion)
 1029        {
 01030            var message = _pipeline.CreateMessage();
 01031            var request = message.Request;
 01032            request.Method = RequestMethod.Head;
 01033            var uri = new RawRequestUriBuilder();
 01034            uri.Reset(endpoint);
 01035            uri.AppendPath("/", false);
 01036            uri.AppendPath(resourceId, false);
 01037            uri.AppendQuery("api-version", apiVersion, true);
 01038            request.Uri = uri;
 01039            return message;
 1040        }
 1041
 1042        /// <summary> Checks by ID whether a resource exists. </summary>
 1043        /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t
 1044        /// <param name="apiVersion"> The API version to use for the operation. </param>
 1045        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1046        public async Task<Response> CheckExistenceByIdAsync(string resourceId, string apiVersion, CancellationToken canc
 1047        {
 01048            if (resourceId == null)
 1049            {
 01050                throw new ArgumentNullException(nameof(resourceId));
 1051            }
 01052            if (apiVersion == null)
 1053            {
 01054                throw new ArgumentNullException(nameof(apiVersion));
 1055            }
 1056
 01057            using var message = CreateCheckExistenceByIdRequest(resourceId, apiVersion);
 01058            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01059            switch (message.Response.Status)
 1060            {
 1061                case 204:
 1062                case 404:
 01063                    return message.Response;
 1064                default:
 01065                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1066            }
 01067        }
 1068
 1069        /// <summary> Checks by ID whether a resource exists. </summary>
 1070        /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t
 1071        /// <param name="apiVersion"> The API version to use for the operation. </param>
 1072        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1073        public Response CheckExistenceById(string resourceId, string apiVersion, CancellationToken cancellationToken = d
 1074        {
 01075            if (resourceId == null)
 1076            {
 01077                throw new ArgumentNullException(nameof(resourceId));
 1078            }
 01079            if (apiVersion == null)
 1080            {
 01081                throw new ArgumentNullException(nameof(apiVersion));
 1082            }
 1083
 01084            using var message = CreateCheckExistenceByIdRequest(resourceId, apiVersion);
 01085            _pipeline.Send(message, cancellationToken);
 01086            switch (message.Response.Status)
 1087            {
 1088                case 204:
 1089                case 404:
 01090                    return message.Response;
 1091                default:
 01092                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1093            }
 01094        }
 1095
 1096        internal Core.HttpMessage CreateDeleteByIdRequest(string resourceId, string apiVersion)
 1097        {
 161098            var message = _pipeline.CreateMessage();
 161099            var request = message.Request;
 161100            request.Method = RequestMethod.Delete;
 161101            var uri = new RawRequestUriBuilder();
 161102            uri.Reset(endpoint);
 161103            uri.AppendPath("/", false);
 161104            uri.AppendPath(resourceId, false);
 161105            uri.AppendQuery("api-version", apiVersion, true);
 161106            request.Uri = uri;
 161107            return message;
 1108        }
 1109
 1110        /// <summary> Deletes a resource by ID. </summary>
 1111        /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t
 1112        /// <param name="apiVersion"> The API version to use for the operation. </param>
 1113        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1114        public async Task<Response> DeleteByIdAsync(string resourceId, string apiVersion, CancellationToken cancellation
 1115        {
 41116            if (resourceId == null)
 1117            {
 01118                throw new ArgumentNullException(nameof(resourceId));
 1119            }
 41120            if (apiVersion == null)
 1121            {
 01122                throw new ArgumentNullException(nameof(apiVersion));
 1123            }
 1124
 41125            using var message = CreateDeleteByIdRequest(resourceId, apiVersion);
 41126            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 41127            switch (message.Response.Status)
 1128            {
 1129                case 200:
 1130                case 202:
 1131                case 204:
 41132                    return message.Response;
 1133                default:
 01134                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1135            }
 41136        }
 1137
 1138        /// <summary> Deletes a resource by ID. </summary>
 1139        /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t
 1140        /// <param name="apiVersion"> The API version to use for the operation. </param>
 1141        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1142        public Response DeleteById(string resourceId, string apiVersion, CancellationToken cancellationToken = default)
 1143        {
 41144            if (resourceId == null)
 1145            {
 01146                throw new ArgumentNullException(nameof(resourceId));
 1147            }
 41148            if (apiVersion == null)
 1149            {
 01150                throw new ArgumentNullException(nameof(apiVersion));
 1151            }
 1152
 41153            using var message = CreateDeleteByIdRequest(resourceId, apiVersion);
 41154            _pipeline.Send(message, cancellationToken);
 41155            switch (message.Response.Status)
 1156            {
 1157                case 200:
 1158                case 202:
 1159                case 204:
 41160                    return message.Response;
 1161                default:
 01162                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1163            }
 41164        }
 1165
 1166        internal Core.HttpMessage CreateCreateOrUpdateByIdRequest(string resourceId, string apiVersion, GenericResource 
 1167        {
 161168            var message = _pipeline.CreateMessage();
 161169            var request = message.Request;
 161170            request.Method = RequestMethod.Put;
 161171            var uri = new RawRequestUriBuilder();
 161172            uri.Reset(endpoint);
 161173            uri.AppendPath("/", false);
 161174            uri.AppendPath(resourceId, false);
 161175            uri.AppendQuery("api-version", apiVersion, true);
 161176            request.Uri = uri;
 161177            request.Headers.Add("Content-Type", "application/json");
 161178            var content = new Utf8JsonRequestContent();
 161179            content.JsonWriter.WriteObjectValue(parameters);
 161180            request.Content = content;
 161181            return message;
 1182        }
 1183
 1184        /// <summary> Create a resource by ID. </summary>
 1185        /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t
 1186        /// <param name="apiVersion"> The API version to use for the operation. </param>
 1187        /// <param name="parameters"> Create or update resource parameters. </param>
 1188        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1189        public async Task<Response> CreateOrUpdateByIdAsync(string resourceId, string apiVersion, GenericResource parame
 1190        {
 41191            if (resourceId == null)
 1192            {
 01193                throw new ArgumentNullException(nameof(resourceId));
 1194            }
 41195            if (apiVersion == null)
 1196            {
 01197                throw new ArgumentNullException(nameof(apiVersion));
 1198            }
 41199            if (parameters == null)
 1200            {
 01201                throw new ArgumentNullException(nameof(parameters));
 1202            }
 1203
 41204            using var message = CreateCreateOrUpdateByIdRequest(resourceId, apiVersion, parameters);
 41205            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 41206            switch (message.Response.Status)
 1207            {
 1208                case 200:
 1209                case 201:
 1210                case 202:
 41211                    return message.Response;
 1212                default:
 01213                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1214            }
 41215        }
 1216
 1217        /// <summary> Create a resource by ID. </summary>
 1218        /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t
 1219        /// <param name="apiVersion"> The API version to use for the operation. </param>
 1220        /// <param name="parameters"> Create or update resource parameters. </param>
 1221        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1222        public Response CreateOrUpdateById(string resourceId, string apiVersion, GenericResource parameters, Cancellatio
 1223        {
 41224            if (resourceId == null)
 1225            {
 01226                throw new ArgumentNullException(nameof(resourceId));
 1227            }
 41228            if (apiVersion == null)
 1229            {
 01230                throw new ArgumentNullException(nameof(apiVersion));
 1231            }
 41232            if (parameters == null)
 1233            {
 01234                throw new ArgumentNullException(nameof(parameters));
 1235            }
 1236
 41237            using var message = CreateCreateOrUpdateByIdRequest(resourceId, apiVersion, parameters);
 41238            _pipeline.Send(message, cancellationToken);
 41239            switch (message.Response.Status)
 1240            {
 1241                case 200:
 1242                case 201:
 1243                case 202:
 41244                    return message.Response;
 1245                default:
 01246                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1247            }
 41248        }
 1249
 1250        internal Core.HttpMessage CreateUpdateByIdRequest(string resourceId, string apiVersion, GenericResource paramete
 1251        {
 01252            var message = _pipeline.CreateMessage();
 01253            var request = message.Request;
 01254            request.Method = RequestMethod.Patch;
 01255            var uri = new RawRequestUriBuilder();
 01256            uri.Reset(endpoint);
 01257            uri.AppendPath("/", false);
 01258            uri.AppendPath(resourceId, false);
 01259            uri.AppendQuery("api-version", apiVersion, true);
 01260            request.Uri = uri;
 01261            request.Headers.Add("Content-Type", "application/json");
 01262            var content = new Utf8JsonRequestContent();
 01263            content.JsonWriter.WriteObjectValue(parameters);
 01264            request.Content = content;
 01265            return message;
 1266        }
 1267
 1268        /// <summary> Updates a resource by ID. </summary>
 1269        /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t
 1270        /// <param name="apiVersion"> The API version to use for the operation. </param>
 1271        /// <param name="parameters"> Update resource parameters. </param>
 1272        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1273        public async Task<Response> UpdateByIdAsync(string resourceId, string apiVersion, GenericResource parameters, Ca
 1274        {
 01275            if (resourceId == null)
 1276            {
 01277                throw new ArgumentNullException(nameof(resourceId));
 1278            }
 01279            if (apiVersion == null)
 1280            {
 01281                throw new ArgumentNullException(nameof(apiVersion));
 1282            }
 01283            if (parameters == null)
 1284            {
 01285                throw new ArgumentNullException(nameof(parameters));
 1286            }
 1287
 01288            using var message = CreateUpdateByIdRequest(resourceId, apiVersion, parameters);
 01289            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01290            switch (message.Response.Status)
 1291            {
 1292                case 200:
 1293                case 202:
 01294                    return message.Response;
 1295                default:
 01296                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1297            }
 01298        }
 1299
 1300        /// <summary> Updates a resource by ID. </summary>
 1301        /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t
 1302        /// <param name="apiVersion"> The API version to use for the operation. </param>
 1303        /// <param name="parameters"> Update resource parameters. </param>
 1304        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1305        public Response UpdateById(string resourceId, string apiVersion, GenericResource parameters, CancellationToken c
 1306        {
 01307            if (resourceId == null)
 1308            {
 01309                throw new ArgumentNullException(nameof(resourceId));
 1310            }
 01311            if (apiVersion == null)
 1312            {
 01313                throw new ArgumentNullException(nameof(apiVersion));
 1314            }
 01315            if (parameters == null)
 1316            {
 01317                throw new ArgumentNullException(nameof(parameters));
 1318            }
 1319
 01320            using var message = CreateUpdateByIdRequest(resourceId, apiVersion, parameters);
 01321            _pipeline.Send(message, cancellationToken);
 01322            switch (message.Response.Status)
 1323            {
 1324                case 200:
 1325                case 202:
 01326                    return message.Response;
 1327                default:
 01328                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1329            }
 01330        }
 1331
 1332        internal Core.HttpMessage CreateGetByIdRequest(string resourceId, string apiVersion)
 1333        {
 41334            var message = _pipeline.CreateMessage();
 41335            var request = message.Request;
 41336            request.Method = RequestMethod.Get;
 41337            var uri = new RawRequestUriBuilder();
 41338            uri.Reset(endpoint);
 41339            uri.AppendPath("/", false);
 41340            uri.AppendPath(resourceId, false);
 41341            uri.AppendQuery("api-version", apiVersion, true);
 41342            request.Uri = uri;
 41343            return message;
 1344        }
 1345
 1346        /// <summary> Gets a resource by ID. </summary>
 1347        /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t
 1348        /// <param name="apiVersion"> The API version to use for the operation. </param>
 1349        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1350        public async Task<Response<GenericResource>> GetByIdAsync(string resourceId, string apiVersion, CancellationToke
 1351        {
 21352            if (resourceId == null)
 1353            {
 01354                throw new ArgumentNullException(nameof(resourceId));
 1355            }
 21356            if (apiVersion == null)
 1357            {
 01358                throw new ArgumentNullException(nameof(apiVersion));
 1359            }
 1360
 21361            using var message = CreateGetByIdRequest(resourceId, apiVersion);
 21362            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 21363            switch (message.Response.Status)
 1364            {
 1365                case 200:
 1366                    {
 21367                        GenericResource value = default;
 21368                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 21369                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1370                        {
 01371                            value = null;
 1372                        }
 1373                        else
 1374                        {
 21375                            value = GenericResource.DeserializeGenericResource(document.RootElement);
 1376                        }
 21377                        return Response.FromValue(value, message.Response);
 1378                    }
 1379                default:
 01380                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1381            }
 21382        }
 1383
 1384        /// <summary> Gets a resource by ID. </summary>
 1385        /// <param name="resourceId"> The fully qualified ID of the resource, including the resource name and resource t
 1386        /// <param name="apiVersion"> The API version to use for the operation. </param>
 1387        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1388        public Response<GenericResource> GetById(string resourceId, string apiVersion, CancellationToken cancellationTok
 1389        {
 21390            if (resourceId == null)
 1391            {
 01392                throw new ArgumentNullException(nameof(resourceId));
 1393            }
 21394            if (apiVersion == null)
 1395            {
 01396                throw new ArgumentNullException(nameof(apiVersion));
 1397            }
 1398
 21399            using var message = CreateGetByIdRequest(resourceId, apiVersion);
 21400            _pipeline.Send(message, cancellationToken);
 21401            switch (message.Response.Status)
 1402            {
 1403                case 200:
 1404                    {
 21405                        GenericResource value = default;
 21406                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 21407                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1408                        {
 01409                            value = null;
 1410                        }
 1411                        else
 1412                        {
 21413                            value = GenericResource.DeserializeGenericResource(document.RootElement);
 1414                        }
 21415                        return Response.FromValue(value, message.Response);
 1416                    }
 1417                default:
 01418                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1419            }
 21420        }
 1421
 1422        internal Core.HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string resourceGroupName, st
 1423        {
 01424            var message = _pipeline.CreateMessage();
 01425            var request = message.Request;
 01426            request.Method = RequestMethod.Get;
 01427            var uri = new RawRequestUriBuilder();
 01428            uri.Reset(endpoint);
 01429            uri.AppendRawNextLink(nextLink, false);
 01430            request.Uri = uri;
 01431            return message;
 1432        }
 1433
 1434        /// <summary> Get all the resources for a resource group. </summary>
 1435        /// <param name="nextLink"> The URL to the next page of results. </param>
 1436        /// <param name="resourceGroupName"> The resource group with the resources to get. </param>
 1437        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;The properties you can use fo
 1438        /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va
 1439        /// <param name="top"> The number of results to return. If null is passed, returns all resources. </param>
 1440        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1441        public async Task<Response<ResourceListResult>> ListByResourceGroupNextPageAsync(string nextLink, string resourc
 1442        {
 01443            if (nextLink == null)
 1444            {
 01445                throw new ArgumentNullException(nameof(nextLink));
 1446            }
 01447            if (resourceGroupName == null)
 1448            {
 01449                throw new ArgumentNullException(nameof(resourceGroupName));
 1450            }
 1451
 01452            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName, filter, expand, to
 01453            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01454            switch (message.Response.Status)
 1455            {
 1456                case 200:
 1457                    {
 01458                        ResourceListResult value = default;
 01459                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 01460                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1461                        {
 01462                            value = null;
 1463                        }
 1464                        else
 1465                        {
 01466                            value = ResourceListResult.DeserializeResourceListResult(document.RootElement);
 1467                        }
 01468                        return Response.FromValue(value, message.Response);
 1469                    }
 1470                default:
 01471                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1472            }
 01473        }
 1474
 1475        /// <summary> Get all the resources for a resource group. </summary>
 1476        /// <param name="nextLink"> The URL to the next page of results. </param>
 1477        /// <param name="resourceGroupName"> The resource group with the resources to get. </param>
 1478        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;The properties you can use fo
 1479        /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va
 1480        /// <param name="top"> The number of results to return. If null is passed, returns all resources. </param>
 1481        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1482        public Response<ResourceListResult> ListByResourceGroupNextPage(string nextLink, string resourceGroupName, strin
 1483        {
 01484            if (nextLink == null)
 1485            {
 01486                throw new ArgumentNullException(nameof(nextLink));
 1487            }
 01488            if (resourceGroupName == null)
 1489            {
 01490                throw new ArgumentNullException(nameof(resourceGroupName));
 1491            }
 1492
 01493            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName, filter, expand, to
 01494            _pipeline.Send(message, cancellationToken);
 01495            switch (message.Response.Status)
 1496            {
 1497                case 200:
 1498                    {
 01499                        ResourceListResult value = default;
 01500                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 01501                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1502                        {
 01503                            value = null;
 1504                        }
 1505                        else
 1506                        {
 01507                            value = ResourceListResult.DeserializeResourceListResult(document.RootElement);
 1508                        }
 01509                        return Response.FromValue(value, message.Response);
 1510                    }
 1511                default:
 01512                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1513            }
 01514        }
 1515
 1516        internal Core.HttpMessage CreateListNextPageRequest(string nextLink, string filter, string expand, int? top)
 1517        {
 01518            var message = _pipeline.CreateMessage();
 01519            var request = message.Request;
 01520            request.Method = RequestMethod.Get;
 01521            var uri = new RawRequestUriBuilder();
 01522            uri.Reset(endpoint);
 01523            uri.AppendRawNextLink(nextLink, false);
 01524            request.Uri = uri;
 01525            return message;
 1526        }
 1527
 1528        /// <summary> Get all the resources in a subscription. </summary>
 1529        /// <param name="nextLink"> The URL to the next page of results. </param>
 1530        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;The properties you can use fo
 1531        /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va
 1532        /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param>
 1533        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1534        public async Task<Response<ResourceListResult>> ListNextPageAsync(string nextLink, string filter = null, string 
 1535        {
 01536            if (nextLink == null)
 1537            {
 01538                throw new ArgumentNullException(nameof(nextLink));
 1539            }
 1540
 01541            using var message = CreateListNextPageRequest(nextLink, filter, expand, top);
 01542            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01543            switch (message.Response.Status)
 1544            {
 1545                case 200:
 1546                    {
 01547                        ResourceListResult value = default;
 01548                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 01549                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1550                        {
 01551                            value = null;
 1552                        }
 1553                        else
 1554                        {
 01555                            value = ResourceListResult.DeserializeResourceListResult(document.RootElement);
 1556                        }
 01557                        return Response.FromValue(value, message.Response);
 1558                    }
 1559                default:
 01560                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1561            }
 01562        }
 1563
 1564        /// <summary> Get all the resources in a subscription. </summary>
 1565        /// <param name="nextLink"> The URL to the next page of results. </param>
 1566        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;The properties you can use fo
 1567        /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid va
 1568        /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param>
 1569        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1570        public Response<ResourceListResult> ListNextPage(string nextLink, string filter = null, string expand = null, in
 1571        {
 01572            if (nextLink == null)
 1573            {
 01574                throw new ArgumentNullException(nameof(nextLink));
 1575            }
 1576
 01577            using var message = CreateListNextPageRequest(nextLink, filter, expand, top);
 01578            _pipeline.Send(message, cancellationToken);
 01579            switch (message.Response.Status)
 1580            {
 1581                case 200:
 1582                    {
 01583                        ResourceListResult value = default;
 01584                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 01585                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1586                        {
 01587                            value = null;
 1588                        }
 1589                        else
 1590                        {
 01591                            value = ResourceListResult.DeserializeResourceListResult(document.RootElement);
 1592                        }
 01593                        return Response.FromValue(value, message.Response);
 1594                    }
 1595                default:
 01596                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1597            }
 01598        }
 1599    }
 1600}