| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.ResourceManager.EventHubs.Models; |
| | 16 | |
|
| | 17 | | namespace 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 |
| 0 | 32 | | public ConfigurationRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscripti |
| | 33 | | { |
| 0 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 0 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 0 | 40 | | this.subscriptionId = subscriptionId; |
| 0 | 41 | | this.endpoint = endpoint; |
| 0 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 43 | | _pipeline = pipeline; |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreatePatchRequest(string resourceGroupName, string clusterName, ClusterQuotaConfigurationP |
| | 47 | | { |
| 0 | 48 | | var message = _pipeline.CreateMessage(); |
| 0 | 49 | | var request = message.Request; |
| 0 | 50 | | request.Method = RequestMethod.Patch; |
| 0 | 51 | | var uri = new RawRequestUriBuilder(); |
| 0 | 52 | | uri.Reset(endpoint); |
| 0 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 54 | | uri.AppendPath(subscriptionId, true); |
| 0 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 57 | | uri.AppendPath("/providers/Microsoft.EventHub/clusters/", false); |
| 0 | 58 | | uri.AppendPath(clusterName, true); |
| 0 | 59 | | uri.AppendPath("/quotaConfiguration/default", false); |
| 0 | 60 | | uri.AppendQuery("api-version", "2018-01-01-preview", true); |
| 0 | 61 | | request.Uri = uri; |
| 0 | 62 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 63 | | var content = new Utf8JsonRequestContent(); |
| 0 | 64 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 65 | | request.Content = content; |
| 0 | 66 | | 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 | | { |
| 0 | 76 | | if (resourceGroupName == null) |
| | 77 | | { |
| 0 | 78 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 79 | | } |
| 0 | 80 | | if (clusterName == null) |
| | 81 | | { |
| 0 | 82 | | throw new ArgumentNullException(nameof(clusterName)); |
| | 83 | | } |
| 0 | 84 | | if (parameters == null) |
| | 85 | | { |
| 0 | 86 | | throw new ArgumentNullException(nameof(parameters)); |
| | 87 | | } |
| | 88 | |
|
| 0 | 89 | | using var message = CreatePatchRequest(resourceGroupName, clusterName, parameters); |
| 0 | 90 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 91 | | switch (message.Response.Status) |
| | 92 | | { |
| | 93 | | case 200: |
| | 94 | | case 201: |
| | 95 | | { |
| 0 | 96 | | ClusterQuotaConfigurationProperties value = default; |
| 0 | 97 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 98 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 99 | | { |
| 0 | 100 | | value = null; |
| | 101 | | } |
| | 102 | | else |
| | 103 | | { |
| 0 | 104 | | value = ClusterQuotaConfigurationProperties.DeserializeClusterQuotaConfigurationProperties(d |
| | 105 | | } |
| 0 | 106 | | return Response.FromValue(value, message.Response); |
| | 107 | | } |
| | 108 | | case 202: |
| 0 | 109 | | return Response.FromValue<ClusterQuotaConfigurationProperties>(null, message.Response); |
| | 110 | | default: |
| 0 | 111 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 112 | | } |
| 0 | 113 | | } |
| | 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 | | { |
| 0 | 122 | | if (resourceGroupName == null) |
| | 123 | | { |
| 0 | 124 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 125 | | } |
| 0 | 126 | | if (clusterName == null) |
| | 127 | | { |
| 0 | 128 | | throw new ArgumentNullException(nameof(clusterName)); |
| | 129 | | } |
| 0 | 130 | | if (parameters == null) |
| | 131 | | { |
| 0 | 132 | | throw new ArgumentNullException(nameof(parameters)); |
| | 133 | | } |
| | 134 | |
|
| 0 | 135 | | using var message = CreatePatchRequest(resourceGroupName, clusterName, parameters); |
| 0 | 136 | | _pipeline.Send(message, cancellationToken); |
| 0 | 137 | | switch (message.Response.Status) |
| | 138 | | { |
| | 139 | | case 200: |
| | 140 | | case 201: |
| | 141 | | { |
| 0 | 142 | | ClusterQuotaConfigurationProperties value = default; |
| 0 | 143 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 144 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 145 | | { |
| 0 | 146 | | value = null; |
| | 147 | | } |
| | 148 | | else |
| | 149 | | { |
| 0 | 150 | | value = ClusterQuotaConfigurationProperties.DeserializeClusterQuotaConfigurationProperties(d |
| | 151 | | } |
| 0 | 152 | | return Response.FromValue(value, message.Response); |
| | 153 | | } |
| | 154 | | case 202: |
| 0 | 155 | | return Response.FromValue<ClusterQuotaConfigurationProperties>(null, message.Response); |
| | 156 | | default: |
| 0 | 157 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 158 | | } |
| 0 | 159 | | } |
| | 160 | |
|
| | 161 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string clusterName) |
| | 162 | | { |
| 0 | 163 | | var message = _pipeline.CreateMessage(); |
| 0 | 164 | | var request = message.Request; |
| 0 | 165 | | request.Method = RequestMethod.Get; |
| 0 | 166 | | var uri = new RawRequestUriBuilder(); |
| 0 | 167 | | uri.Reset(endpoint); |
| 0 | 168 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 169 | | uri.AppendPath(subscriptionId, true); |
| 0 | 170 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 171 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 172 | | uri.AppendPath("/providers/Microsoft.EventHub/clusters/", false); |
| 0 | 173 | | uri.AppendPath(clusterName, true); |
| 0 | 174 | | uri.AppendPath("/quotaConfiguration/default", false); |
| 0 | 175 | | uri.AppendQuery("api-version", "2018-01-01-preview", true); |
| 0 | 176 | | request.Uri = uri; |
| 0 | 177 | | 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 | | { |
| 0 | 186 | | if (resourceGroupName == null) |
| | 187 | | { |
| 0 | 188 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 189 | | } |
| 0 | 190 | | if (clusterName == null) |
| | 191 | | { |
| 0 | 192 | | throw new ArgumentNullException(nameof(clusterName)); |
| | 193 | | } |
| | 194 | |
|
| 0 | 195 | | using var message = CreateGetRequest(resourceGroupName, clusterName); |
| 0 | 196 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 197 | | switch (message.Response.Status) |
| | 198 | | { |
| | 199 | | case 200: |
| | 200 | | { |
| 0 | 201 | | ClusterQuotaConfigurationProperties value = default; |
| 0 | 202 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 203 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 204 | | { |
| 0 | 205 | | value = null; |
| | 206 | | } |
| | 207 | | else |
| | 208 | | { |
| 0 | 209 | | value = ClusterQuotaConfigurationProperties.DeserializeClusterQuotaConfigurationProperties(d |
| | 210 | | } |
| 0 | 211 | | return Response.FromValue(value, message.Response); |
| | 212 | | } |
| | 213 | | default: |
| 0 | 214 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 215 | | } |
| 0 | 216 | | } |
| | 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 | | { |
| 0 | 224 | | if (resourceGroupName == null) |
| | 225 | | { |
| 0 | 226 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 227 | | } |
| 0 | 228 | | if (clusterName == null) |
| | 229 | | { |
| 0 | 230 | | throw new ArgumentNullException(nameof(clusterName)); |
| | 231 | | } |
| | 232 | |
|
| 0 | 233 | | using var message = CreateGetRequest(resourceGroupName, clusterName); |
| 0 | 234 | | _pipeline.Send(message, cancellationToken); |
| 0 | 235 | | switch (message.Response.Status) |
| | 236 | | { |
| | 237 | | case 200: |
| | 238 | | { |
| 0 | 239 | | ClusterQuotaConfigurationProperties value = default; |
| 0 | 240 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 241 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 242 | | { |
| 0 | 243 | | value = null; |
| | 244 | | } |
| | 245 | | else |
| | 246 | | { |
| 0 | 247 | | value = ClusterQuotaConfigurationProperties.DeserializeClusterQuotaConfigurationProperties(d |
| | 248 | | } |
| 0 | 249 | | return Response.FromValue(value, message.Response); |
| | 250 | | } |
| | 251 | | default: |
| 0 | 252 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 253 | | } |
| 0 | 254 | | } |
| | 255 | | } |
| | 256 | | } |