< Summary

Class:Azure.ResourceManager.Network.DdosCustomPoliciesRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\DdosCustomPoliciesRestOperations.cs
Covered lines:0
Uncovered lines:181
Coverable lines:181
Total lines:408
Line coverage:0% (0 of 181)
Covered branches:0
Total branches:76
Branch coverage:0% (0 of 76)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateDeleteRequest(...)-0%100%
DeleteAsync()-0%0%
Delete(...)-0%0%
CreateGetRequest(...)-0%100%
GetAsync()-0%0%
Get(...)-0%0%
CreateCreateOrUpdateRequest(...)-0%100%
CreateOrUpdateAsync()-0%0%
CreateOrUpdate(...)-0%0%
CreateUpdateTagsRequest(...)-0%100%
UpdateTagsAsync()-0%0%
UpdateTags(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\DdosCustomPoliciesRestOperations.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Text.Json;
 10using System.Threading;
 11using System.Threading.Tasks;
 12using Azure;
 13using Azure.Core;
 14using Azure.Core.Pipeline;
 15using Azure.ResourceManager.Network.Models;
 16
 17namespace Azure.ResourceManager.Network
 18{
 19    internal partial class DdosCustomPoliciesRestOperations
 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 DdosCustomPoliciesRestOperations. </summary>
 27        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 28        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 29        /// <param name="subscriptionId"> The subscription credentials which uniquely identify the Microsoft Azure subsc
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 032        public DdosCustomPoliciesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subsc
 33        {
 034            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 038            endpoint ??= new Uri("https://management.azure.com");
 39
 040            this.subscriptionId = subscriptionId;
 041            this.endpoint = endpoint;
 042            _clientDiagnostics = clientDiagnostics;
 043            _pipeline = pipeline;
 044        }
 45
 46        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string ddosCustomPolicyName)
 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("/subscriptions/", false);
 054            uri.AppendPath(subscriptionId, true);
 055            uri.AppendPath("/resourceGroups/", false);
 056            uri.AppendPath(resourceGroupName, true);
 057            uri.AppendPath("/providers/Microsoft.Network/ddosCustomPolicies/", false);
 058            uri.AppendPath(ddosCustomPolicyName, true);
 059            uri.AppendQuery("api-version", "2020-04-01", true);
 060            request.Uri = uri;
 061            return message;
 62        }
 63
 64        /// <summary> Deletes the specified DDoS custom policy. </summary>
 65        /// <param name="resourceGroupName"> The name of the resource group. </param>
 66        /// <param name="ddosCustomPolicyName"> The name of the DDoS custom policy. </param>
 67        /// <param name="cancellationToken"> The cancellation token to use. </param>
 68        public async Task<Response> DeleteAsync(string resourceGroupName, string ddosCustomPolicyName, CancellationToken
 69        {
 070            if (resourceGroupName == null)
 71            {
 072                throw new ArgumentNullException(nameof(resourceGroupName));
 73            }
 074            if (ddosCustomPolicyName == null)
 75            {
 076                throw new ArgumentNullException(nameof(ddosCustomPolicyName));
 77            }
 78
 079            using var message = CreateDeleteRequest(resourceGroupName, ddosCustomPolicyName);
 080            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 081            switch (message.Response.Status)
 82            {
 83                case 200:
 84                case 202:
 85                case 204:
 086                    return message.Response;
 87                default:
 088                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 89            }
 090        }
 91
 92        /// <summary> Deletes the specified DDoS custom policy. </summary>
 93        /// <param name="resourceGroupName"> The name of the resource group. </param>
 94        /// <param name="ddosCustomPolicyName"> The name of the DDoS custom policy. </param>
 95        /// <param name="cancellationToken"> The cancellation token to use. </param>
 96        public Response Delete(string resourceGroupName, string ddosCustomPolicyName, CancellationToken cancellationToke
 97        {
 098            if (resourceGroupName == null)
 99            {
 0100                throw new ArgumentNullException(nameof(resourceGroupName));
 101            }
 0102            if (ddosCustomPolicyName == null)
 103            {
 0104                throw new ArgumentNullException(nameof(ddosCustomPolicyName));
 105            }
 106
 0107            using var message = CreateDeleteRequest(resourceGroupName, ddosCustomPolicyName);
 0108            _pipeline.Send(message, cancellationToken);
 0109            switch (message.Response.Status)
 110            {
 111                case 200:
 112                case 202:
 113                case 204:
 0114                    return message.Response;
 115                default:
 0116                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 117            }
 0118        }
 119
 120        internal HttpMessage CreateGetRequest(string resourceGroupName, string ddosCustomPolicyName)
 121        {
 0122            var message = _pipeline.CreateMessage();
 0123            var request = message.Request;
 0124            request.Method = RequestMethod.Get;
 0125            var uri = new RawRequestUriBuilder();
 0126            uri.Reset(endpoint);
 0127            uri.AppendPath("/subscriptions/", false);
 0128            uri.AppendPath(subscriptionId, true);
 0129            uri.AppendPath("/resourceGroups/", false);
 0130            uri.AppendPath(resourceGroupName, true);
 0131            uri.AppendPath("/providers/Microsoft.Network/ddosCustomPolicies/", false);
 0132            uri.AppendPath(ddosCustomPolicyName, true);
 0133            uri.AppendQuery("api-version", "2020-04-01", true);
 0134            request.Uri = uri;
 0135            return message;
 136        }
 137
 138        /// <summary> Gets information about the specified DDoS custom policy. </summary>
 139        /// <param name="resourceGroupName"> The name of the resource group. </param>
 140        /// <param name="ddosCustomPolicyName"> The name of the DDoS custom policy. </param>
 141        /// <param name="cancellationToken"> The cancellation token to use. </param>
 142        public async Task<Response<DdosCustomPolicy>> GetAsync(string resourceGroupName, string ddosCustomPolicyName, Ca
 143        {
 0144            if (resourceGroupName == null)
 145            {
 0146                throw new ArgumentNullException(nameof(resourceGroupName));
 147            }
 0148            if (ddosCustomPolicyName == null)
 149            {
 0150                throw new ArgumentNullException(nameof(ddosCustomPolicyName));
 151            }
 152
 0153            using var message = CreateGetRequest(resourceGroupName, ddosCustomPolicyName);
 0154            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0155            switch (message.Response.Status)
 156            {
 157                case 200:
 158                    {
 0159                        DdosCustomPolicy value = default;
 0160                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0161                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 162                        {
 0163                            value = null;
 164                        }
 165                        else
 166                        {
 0167                            value = DdosCustomPolicy.DeserializeDdosCustomPolicy(document.RootElement);
 168                        }
 0169                        return Response.FromValue(value, message.Response);
 170                    }
 171                default:
 0172                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 173            }
 0174        }
 175
 176        /// <summary> Gets information about the specified DDoS custom policy. </summary>
 177        /// <param name="resourceGroupName"> The name of the resource group. </param>
 178        /// <param name="ddosCustomPolicyName"> The name of the DDoS custom policy. </param>
 179        /// <param name="cancellationToken"> The cancellation token to use. </param>
 180        public Response<DdosCustomPolicy> Get(string resourceGroupName, string ddosCustomPolicyName, CancellationToken c
 181        {
 0182            if (resourceGroupName == null)
 183            {
 0184                throw new ArgumentNullException(nameof(resourceGroupName));
 185            }
 0186            if (ddosCustomPolicyName == null)
 187            {
 0188                throw new ArgumentNullException(nameof(ddosCustomPolicyName));
 189            }
 190
 0191            using var message = CreateGetRequest(resourceGroupName, ddosCustomPolicyName);
 0192            _pipeline.Send(message, cancellationToken);
 0193            switch (message.Response.Status)
 194            {
 195                case 200:
 196                    {
 0197                        DdosCustomPolicy value = default;
 0198                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0199                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 200                        {
 0201                            value = null;
 202                        }
 203                        else
 204                        {
 0205                            value = DdosCustomPolicy.DeserializeDdosCustomPolicy(document.RootElement);
 206                        }
 0207                        return Response.FromValue(value, message.Response);
 208                    }
 209                default:
 0210                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 211            }
 0212        }
 213
 214        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string ddosCustomPolicyName, DdosCust
 215        {
 0216            var message = _pipeline.CreateMessage();
 0217            var request = message.Request;
 0218            request.Method = RequestMethod.Put;
 0219            var uri = new RawRequestUriBuilder();
 0220            uri.Reset(endpoint);
 0221            uri.AppendPath("/subscriptions/", false);
 0222            uri.AppendPath(subscriptionId, true);
 0223            uri.AppendPath("/resourceGroups/", false);
 0224            uri.AppendPath(resourceGroupName, true);
 0225            uri.AppendPath("/providers/Microsoft.Network/ddosCustomPolicies/", false);
 0226            uri.AppendPath(ddosCustomPolicyName, true);
 0227            uri.AppendQuery("api-version", "2020-04-01", true);
 0228            request.Uri = uri;
 0229            request.Headers.Add("Content-Type", "application/json");
 0230            var content = new Utf8JsonRequestContent();
 0231            content.JsonWriter.WriteObjectValue(parameters);
 0232            request.Content = content;
 0233            return message;
 234        }
 235
 236        /// <summary> Creates or updates a DDoS custom policy. </summary>
 237        /// <param name="resourceGroupName"> The name of the resource group. </param>
 238        /// <param name="ddosCustomPolicyName"> The name of the DDoS custom policy. </param>
 239        /// <param name="parameters"> Parameters supplied to the create or update operation. </param>
 240        /// <param name="cancellationToken"> The cancellation token to use. </param>
 241        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string ddosCustomPolicyName, DdosCusto
 242        {
 0243            if (resourceGroupName == null)
 244            {
 0245                throw new ArgumentNullException(nameof(resourceGroupName));
 246            }
 0247            if (ddosCustomPolicyName == null)
 248            {
 0249                throw new ArgumentNullException(nameof(ddosCustomPolicyName));
 250            }
 0251            if (parameters == null)
 252            {
 0253                throw new ArgumentNullException(nameof(parameters));
 254            }
 255
 0256            using var message = CreateCreateOrUpdateRequest(resourceGroupName, ddosCustomPolicyName, parameters);
 0257            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0258            switch (message.Response.Status)
 259            {
 260                case 200:
 261                case 201:
 0262                    return message.Response;
 263                default:
 0264                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 265            }
 0266        }
 267
 268        /// <summary> Creates or updates a DDoS custom policy. </summary>
 269        /// <param name="resourceGroupName"> The name of the resource group. </param>
 270        /// <param name="ddosCustomPolicyName"> The name of the DDoS custom policy. </param>
 271        /// <param name="parameters"> Parameters supplied to the create or update operation. </param>
 272        /// <param name="cancellationToken"> The cancellation token to use. </param>
 273        public Response CreateOrUpdate(string resourceGroupName, string ddosCustomPolicyName, DdosCustomPolicy parameter
 274        {
 0275            if (resourceGroupName == null)
 276            {
 0277                throw new ArgumentNullException(nameof(resourceGroupName));
 278            }
 0279            if (ddosCustomPolicyName == null)
 280            {
 0281                throw new ArgumentNullException(nameof(ddosCustomPolicyName));
 282            }
 0283            if (parameters == null)
 284            {
 0285                throw new ArgumentNullException(nameof(parameters));
 286            }
 287
 0288            using var message = CreateCreateOrUpdateRequest(resourceGroupName, ddosCustomPolicyName, parameters);
 0289            _pipeline.Send(message, cancellationToken);
 0290            switch (message.Response.Status)
 291            {
 292                case 200:
 293                case 201:
 0294                    return message.Response;
 295                default:
 0296                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 297            }
 0298        }
 299
 300        internal HttpMessage CreateUpdateTagsRequest(string resourceGroupName, string ddosCustomPolicyName, TagsObject p
 301        {
 0302            var message = _pipeline.CreateMessage();
 0303            var request = message.Request;
 0304            request.Method = RequestMethod.Patch;
 0305            var uri = new RawRequestUriBuilder();
 0306            uri.Reset(endpoint);
 0307            uri.AppendPath("/subscriptions/", false);
 0308            uri.AppendPath(subscriptionId, true);
 0309            uri.AppendPath("/resourceGroups/", false);
 0310            uri.AppendPath(resourceGroupName, true);
 0311            uri.AppendPath("/providers/Microsoft.Network/ddosCustomPolicies/", false);
 0312            uri.AppendPath(ddosCustomPolicyName, true);
 0313            uri.AppendQuery("api-version", "2020-04-01", true);
 0314            request.Uri = uri;
 0315            request.Headers.Add("Content-Type", "application/json");
 0316            var content = new Utf8JsonRequestContent();
 0317            content.JsonWriter.WriteObjectValue(parameters);
 0318            request.Content = content;
 0319            return message;
 320        }
 321
 322        /// <summary> Update a DDoS custom policy tags. </summary>
 323        /// <param name="resourceGroupName"> The name of the resource group. </param>
 324        /// <param name="ddosCustomPolicyName"> The name of the DDoS custom policy. </param>
 325        /// <param name="parameters"> Parameters supplied to update DDoS custom policy resource tags. </param>
 326        /// <param name="cancellationToken"> The cancellation token to use. </param>
 327        public async Task<Response<DdosCustomPolicy>> UpdateTagsAsync(string resourceGroupName, string ddosCustomPolicyN
 328        {
 0329            if (resourceGroupName == null)
 330            {
 0331                throw new ArgumentNullException(nameof(resourceGroupName));
 332            }
 0333            if (ddosCustomPolicyName == null)
 334            {
 0335                throw new ArgumentNullException(nameof(ddosCustomPolicyName));
 336            }
 0337            if (parameters == null)
 338            {
 0339                throw new ArgumentNullException(nameof(parameters));
 340            }
 341
 0342            using var message = CreateUpdateTagsRequest(resourceGroupName, ddosCustomPolicyName, parameters);
 0343            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0344            switch (message.Response.Status)
 345            {
 346                case 200:
 347                    {
 0348                        DdosCustomPolicy value = default;
 0349                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0350                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 351                        {
 0352                            value = null;
 353                        }
 354                        else
 355                        {
 0356                            value = DdosCustomPolicy.DeserializeDdosCustomPolicy(document.RootElement);
 357                        }
 0358                        return Response.FromValue(value, message.Response);
 359                    }
 360                default:
 0361                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 362            }
 0363        }
 364
 365        /// <summary> Update a DDoS custom policy tags. </summary>
 366        /// <param name="resourceGroupName"> The name of the resource group. </param>
 367        /// <param name="ddosCustomPolicyName"> The name of the DDoS custom policy. </param>
 368        /// <param name="parameters"> Parameters supplied to update DDoS custom policy resource tags. </param>
 369        /// <param name="cancellationToken"> The cancellation token to use. </param>
 370        public Response<DdosCustomPolicy> UpdateTags(string resourceGroupName, string ddosCustomPolicyName, TagsObject p
 371        {
 0372            if (resourceGroupName == null)
 373            {
 0374                throw new ArgumentNullException(nameof(resourceGroupName));
 375            }
 0376            if (ddosCustomPolicyName == null)
 377            {
 0378                throw new ArgumentNullException(nameof(ddosCustomPolicyName));
 379            }
 0380            if (parameters == null)
 381            {
 0382                throw new ArgumentNullException(nameof(parameters));
 383            }
 384
 0385            using var message = CreateUpdateTagsRequest(resourceGroupName, ddosCustomPolicyName, parameters);
 0386            _pipeline.Send(message, cancellationToken);
 0387            switch (message.Response.Status)
 388            {
 389                case 200:
 390                    {
 0391                        DdosCustomPolicy value = default;
 0392                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0393                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 394                        {
 0395                            value = null;
 396                        }
 397                        else
 398                        {
 0399                            value = DdosCustomPolicy.DeserializeDdosCustomPolicy(document.RootElement);
 400                        }
 0401                        return Response.FromValue(value, message.Response);
 402                    }
 403                default:
 0404                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 405            }
 0406        }
 407    }
 408}