< Summary

Class:Azure.ResourceManager.EventHubs.ConfigurationRestOperations
Assembly:Azure.ResourceManager.EventHubs
File(s):C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.ResourceManager.EventHubs\src\Generated\ConfigurationRestOperations.cs
Covered lines:0
Uncovered lines:109
Coverable lines:109
Total lines:256
Line coverage:0% (0 of 109)
Covered branches:0
Total branches:44
Branch coverage:0% (0 of 44)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreatePatchRequest(...)-0%100%
PatchAsync()-0%0%
Patch(...)-0%0%
CreateGetRequest(...)-0%100%
GetAsync()-0%0%
Get(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.ResourceManager.EventHubs\src\Generated\ConfigurationRestOperations.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.EventHubs.Models;
 16
 17namespace Azure.ResourceManager.EventHubs
 18{
 19    internal partial class ConfigurationRestOperations
 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 ConfigurationRestOperations. </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"> Subscription credentials that uniquely identify a Microsoft Azure subscription
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 032        public ConfigurationRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscripti
 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 CreatePatchRequest(string resourceGroupName, string clusterName, ClusterQuotaConfigurationP
 47        {
 048            var message = _pipeline.CreateMessage();
 049            var request = message.Request;
 050            request.Method = RequestMethod.Patch;
 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.EventHub/clusters/", false);
 058            uri.AppendPath(clusterName, true);
 059            uri.AppendPath("/quotaConfiguration/default", false);
 060            uri.AppendQuery("api-version", "2018-01-01-preview", true);
 061            request.Uri = uri;
 062            request.Headers.Add("Content-Type", "application/json");
 063            var content = new Utf8JsonRequestContent();
 064            content.JsonWriter.WriteObjectValue(parameters);
 065            request.Content = content;
 066            return message;
 67        }
 68
 69        /// <summary> Replace all specified Event Hubs Cluster settings with those contained in the request body. Leaves
 70        /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param>
 71        /// <param name="clusterName"> The name of the Event Hubs Cluster. </param>
 72        /// <param name="parameters"> Parameters for creating an Event Hubs Cluster resource. </param>
 73        /// <param name="cancellationToken"> The cancellation token to use. </param>
 74        public async Task<Response<ClusterQuotaConfigurationProperties>> PatchAsync(string resourceGroupName, string clu
 75        {
 076            if (resourceGroupName == null)
 77            {
 078                throw new ArgumentNullException(nameof(resourceGroupName));
 79            }
 080            if (clusterName == null)
 81            {
 082                throw new ArgumentNullException(nameof(clusterName));
 83            }
 084            if (parameters == null)
 85            {
 086                throw new ArgumentNullException(nameof(parameters));
 87            }
 88
 089            using var message = CreatePatchRequest(resourceGroupName, clusterName, parameters);
 090            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 091            switch (message.Response.Status)
 92            {
 93                case 200:
 94                case 201:
 95                    {
 096                        ClusterQuotaConfigurationProperties value = default;
 097                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 098                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 99                        {
 0100                            value = null;
 101                        }
 102                        else
 103                        {
 0104                            value = ClusterQuotaConfigurationProperties.DeserializeClusterQuotaConfigurationProperties(d
 105                        }
 0106                        return Response.FromValue(value, message.Response);
 107                    }
 108                case 202:
 0109                    return Response.FromValue<ClusterQuotaConfigurationProperties>(null, message.Response);
 110                default:
 0111                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 112            }
 0113        }
 114
 115        /// <summary> Replace all specified Event Hubs Cluster settings with those contained in the request body. Leaves
 116        /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param>
 117        /// <param name="clusterName"> The name of the Event Hubs Cluster. </param>
 118        /// <param name="parameters"> Parameters for creating an Event Hubs Cluster resource. </param>
 119        /// <param name="cancellationToken"> The cancellation token to use. </param>
 120        public Response<ClusterQuotaConfigurationProperties> Patch(string resourceGroupName, string clusterName, Cluster
 121        {
 0122            if (resourceGroupName == null)
 123            {
 0124                throw new ArgumentNullException(nameof(resourceGroupName));
 125            }
 0126            if (clusterName == null)
 127            {
 0128                throw new ArgumentNullException(nameof(clusterName));
 129            }
 0130            if (parameters == null)
 131            {
 0132                throw new ArgumentNullException(nameof(parameters));
 133            }
 134
 0135            using var message = CreatePatchRequest(resourceGroupName, clusterName, parameters);
 0136            _pipeline.Send(message, cancellationToken);
 0137            switch (message.Response.Status)
 138            {
 139                case 200:
 140                case 201:
 141                    {
 0142                        ClusterQuotaConfigurationProperties value = default;
 0143                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0144                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 145                        {
 0146                            value = null;
 147                        }
 148                        else
 149                        {
 0150                            value = ClusterQuotaConfigurationProperties.DeserializeClusterQuotaConfigurationProperties(d
 151                        }
 0152                        return Response.FromValue(value, message.Response);
 153                    }
 154                case 202:
 0155                    return Response.FromValue<ClusterQuotaConfigurationProperties>(null, message.Response);
 156                default:
 0157                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 158            }
 0159        }
 160
 161        internal HttpMessage CreateGetRequest(string resourceGroupName, string clusterName)
 162        {
 0163            var message = _pipeline.CreateMessage();
 0164            var request = message.Request;
 0165            request.Method = RequestMethod.Get;
 0166            var uri = new RawRequestUriBuilder();
 0167            uri.Reset(endpoint);
 0168            uri.AppendPath("/subscriptions/", false);
 0169            uri.AppendPath(subscriptionId, true);
 0170            uri.AppendPath("/resourceGroups/", false);
 0171            uri.AppendPath(resourceGroupName, true);
 0172            uri.AppendPath("/providers/Microsoft.EventHub/clusters/", false);
 0173            uri.AppendPath(clusterName, true);
 0174            uri.AppendPath("/quotaConfiguration/default", false);
 0175            uri.AppendQuery("api-version", "2018-01-01-preview", true);
 0176            request.Uri = uri;
 0177            return message;
 178        }
 179
 180        /// <summary> Get all Event Hubs Cluster settings - a collection of key/value pairs which represent the quotas a
 181        /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param>
 182        /// <param name="clusterName"> The name of the Event Hubs Cluster. </param>
 183        /// <param name="cancellationToken"> The cancellation token to use. </param>
 184        public async Task<Response<ClusterQuotaConfigurationProperties>> GetAsync(string resourceGroupName, string clust
 185        {
 0186            if (resourceGroupName == null)
 187            {
 0188                throw new ArgumentNullException(nameof(resourceGroupName));
 189            }
 0190            if (clusterName == null)
 191            {
 0192                throw new ArgumentNullException(nameof(clusterName));
 193            }
 194
 0195            using var message = CreateGetRequest(resourceGroupName, clusterName);
 0196            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0197            switch (message.Response.Status)
 198            {
 199                case 200:
 200                    {
 0201                        ClusterQuotaConfigurationProperties value = default;
 0202                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0203                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 204                        {
 0205                            value = null;
 206                        }
 207                        else
 208                        {
 0209                            value = ClusterQuotaConfigurationProperties.DeserializeClusterQuotaConfigurationProperties(d
 210                        }
 0211                        return Response.FromValue(value, message.Response);
 212                    }
 213                default:
 0214                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 215            }
 0216        }
 217
 218        /// <summary> Get all Event Hubs Cluster settings - a collection of key/value pairs which represent the quotas a
 219        /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param>
 220        /// <param name="clusterName"> The name of the Event Hubs Cluster. </param>
 221        /// <param name="cancellationToken"> The cancellation token to use. </param>
 222        public Response<ClusterQuotaConfigurationProperties> Get(string resourceGroupName, string clusterName, Cancellat
 223        {
 0224            if (resourceGroupName == null)
 225            {
 0226                throw new ArgumentNullException(nameof(resourceGroupName));
 227            }
 0228            if (clusterName == null)
 229            {
 0230                throw new ArgumentNullException(nameof(clusterName));
 231            }
 232
 0233            using var message = CreateGetRequest(resourceGroupName, clusterName);
 0234            _pipeline.Send(message, cancellationToken);
 0235            switch (message.Response.Status)
 236            {
 237                case 200:
 238                    {
 0239                        ClusterQuotaConfigurationProperties value = default;
 0240                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0241                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 242                        {
 0243                            value = null;
 244                        }
 245                        else
 246                        {
 0247                            value = ClusterQuotaConfigurationProperties.DeserializeClusterQuotaConfigurationProperties(d
 248                        }
 0249                        return Response.FromValue(value, message.Response);
 250                    }
 251                default:
 0252                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 253            }
 0254        }
 255    }
 256}