| | 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.Network.Models; |
| | 16 | |
|
| | 17 | | namespace 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 |
| 0 | 32 | | public DdosCustomPoliciesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subsc |
| | 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 CreateDeleteRequest(string resourceGroupName, string ddosCustomPolicyName) |
| | 47 | | { |
| 0 | 48 | | var message = _pipeline.CreateMessage(); |
| 0 | 49 | | var request = message.Request; |
| 0 | 50 | | request.Method = RequestMethod.Delete; |
| 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.Network/ddosCustomPolicies/", false); |
| 0 | 58 | | uri.AppendPath(ddosCustomPolicyName, true); |
| 0 | 59 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 60 | | request.Uri = uri; |
| 0 | 61 | | 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 | | { |
| 0 | 70 | | if (resourceGroupName == null) |
| | 71 | | { |
| 0 | 72 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 73 | | } |
| 0 | 74 | | if (ddosCustomPolicyName == null) |
| | 75 | | { |
| 0 | 76 | | throw new ArgumentNullException(nameof(ddosCustomPolicyName)); |
| | 77 | | } |
| | 78 | |
|
| 0 | 79 | | using var message = CreateDeleteRequest(resourceGroupName, ddosCustomPolicyName); |
| 0 | 80 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 81 | | switch (message.Response.Status) |
| | 82 | | { |
| | 83 | | case 200: |
| | 84 | | case 202: |
| | 85 | | case 204: |
| 0 | 86 | | return message.Response; |
| | 87 | | default: |
| 0 | 88 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 89 | | } |
| 0 | 90 | | } |
| | 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 | | { |
| 0 | 98 | | if (resourceGroupName == null) |
| | 99 | | { |
| 0 | 100 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 101 | | } |
| 0 | 102 | | if (ddosCustomPolicyName == null) |
| | 103 | | { |
| 0 | 104 | | throw new ArgumentNullException(nameof(ddosCustomPolicyName)); |
| | 105 | | } |
| | 106 | |
|
| 0 | 107 | | using var message = CreateDeleteRequest(resourceGroupName, ddosCustomPolicyName); |
| 0 | 108 | | _pipeline.Send(message, cancellationToken); |
| 0 | 109 | | switch (message.Response.Status) |
| | 110 | | { |
| | 111 | | case 200: |
| | 112 | | case 202: |
| | 113 | | case 204: |
| 0 | 114 | | return message.Response; |
| | 115 | | default: |
| 0 | 116 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 117 | | } |
| 0 | 118 | | } |
| | 119 | |
|
| | 120 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string ddosCustomPolicyName) |
| | 121 | | { |
| 0 | 122 | | var message = _pipeline.CreateMessage(); |
| 0 | 123 | | var request = message.Request; |
| 0 | 124 | | request.Method = RequestMethod.Get; |
| 0 | 125 | | var uri = new RawRequestUriBuilder(); |
| 0 | 126 | | uri.Reset(endpoint); |
| 0 | 127 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 128 | | uri.AppendPath(subscriptionId, true); |
| 0 | 129 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 130 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 131 | | uri.AppendPath("/providers/Microsoft.Network/ddosCustomPolicies/", false); |
| 0 | 132 | | uri.AppendPath(ddosCustomPolicyName, true); |
| 0 | 133 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 134 | | request.Uri = uri; |
| 0 | 135 | | 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 | | { |
| 0 | 144 | | if (resourceGroupName == null) |
| | 145 | | { |
| 0 | 146 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 147 | | } |
| 0 | 148 | | if (ddosCustomPolicyName == null) |
| | 149 | | { |
| 0 | 150 | | throw new ArgumentNullException(nameof(ddosCustomPolicyName)); |
| | 151 | | } |
| | 152 | |
|
| 0 | 153 | | using var message = CreateGetRequest(resourceGroupName, ddosCustomPolicyName); |
| 0 | 154 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 155 | | switch (message.Response.Status) |
| | 156 | | { |
| | 157 | | case 200: |
| | 158 | | { |
| 0 | 159 | | DdosCustomPolicy value = default; |
| 0 | 160 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 161 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 162 | | { |
| 0 | 163 | | value = null; |
| | 164 | | } |
| | 165 | | else |
| | 166 | | { |
| 0 | 167 | | value = DdosCustomPolicy.DeserializeDdosCustomPolicy(document.RootElement); |
| | 168 | | } |
| 0 | 169 | | return Response.FromValue(value, message.Response); |
| | 170 | | } |
| | 171 | | default: |
| 0 | 172 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 173 | | } |
| 0 | 174 | | } |
| | 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 | | { |
| 0 | 182 | | if (resourceGroupName == null) |
| | 183 | | { |
| 0 | 184 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 185 | | } |
| 0 | 186 | | if (ddosCustomPolicyName == null) |
| | 187 | | { |
| 0 | 188 | | throw new ArgumentNullException(nameof(ddosCustomPolicyName)); |
| | 189 | | } |
| | 190 | |
|
| 0 | 191 | | using var message = CreateGetRequest(resourceGroupName, ddosCustomPolicyName); |
| 0 | 192 | | _pipeline.Send(message, cancellationToken); |
| 0 | 193 | | switch (message.Response.Status) |
| | 194 | | { |
| | 195 | | case 200: |
| | 196 | | { |
| 0 | 197 | | DdosCustomPolicy value = default; |
| 0 | 198 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 199 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 200 | | { |
| 0 | 201 | | value = null; |
| | 202 | | } |
| | 203 | | else |
| | 204 | | { |
| 0 | 205 | | value = DdosCustomPolicy.DeserializeDdosCustomPolicy(document.RootElement); |
| | 206 | | } |
| 0 | 207 | | return Response.FromValue(value, message.Response); |
| | 208 | | } |
| | 209 | | default: |
| 0 | 210 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 211 | | } |
| 0 | 212 | | } |
| | 213 | |
|
| | 214 | | internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string ddosCustomPolicyName, DdosCust |
| | 215 | | { |
| 0 | 216 | | var message = _pipeline.CreateMessage(); |
| 0 | 217 | | var request = message.Request; |
| 0 | 218 | | request.Method = RequestMethod.Put; |
| 0 | 219 | | var uri = new RawRequestUriBuilder(); |
| 0 | 220 | | uri.Reset(endpoint); |
| 0 | 221 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 222 | | uri.AppendPath(subscriptionId, true); |
| 0 | 223 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 224 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 225 | | uri.AppendPath("/providers/Microsoft.Network/ddosCustomPolicies/", false); |
| 0 | 226 | | uri.AppendPath(ddosCustomPolicyName, true); |
| 0 | 227 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 228 | | request.Uri = uri; |
| 0 | 229 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 230 | | var content = new Utf8JsonRequestContent(); |
| 0 | 231 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 232 | | request.Content = content; |
| 0 | 233 | | 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 | | { |
| 0 | 243 | | if (resourceGroupName == null) |
| | 244 | | { |
| 0 | 245 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 246 | | } |
| 0 | 247 | | if (ddosCustomPolicyName == null) |
| | 248 | | { |
| 0 | 249 | | throw new ArgumentNullException(nameof(ddosCustomPolicyName)); |
| | 250 | | } |
| 0 | 251 | | if (parameters == null) |
| | 252 | | { |
| 0 | 253 | | throw new ArgumentNullException(nameof(parameters)); |
| | 254 | | } |
| | 255 | |
|
| 0 | 256 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, ddosCustomPolicyName, parameters); |
| 0 | 257 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 258 | | switch (message.Response.Status) |
| | 259 | | { |
| | 260 | | case 200: |
| | 261 | | case 201: |
| 0 | 262 | | return message.Response; |
| | 263 | | default: |
| 0 | 264 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 265 | | } |
| 0 | 266 | | } |
| | 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 | | { |
| 0 | 275 | | if (resourceGroupName == null) |
| | 276 | | { |
| 0 | 277 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 278 | | } |
| 0 | 279 | | if (ddosCustomPolicyName == null) |
| | 280 | | { |
| 0 | 281 | | throw new ArgumentNullException(nameof(ddosCustomPolicyName)); |
| | 282 | | } |
| 0 | 283 | | if (parameters == null) |
| | 284 | | { |
| 0 | 285 | | throw new ArgumentNullException(nameof(parameters)); |
| | 286 | | } |
| | 287 | |
|
| 0 | 288 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, ddosCustomPolicyName, parameters); |
| 0 | 289 | | _pipeline.Send(message, cancellationToken); |
| 0 | 290 | | switch (message.Response.Status) |
| | 291 | | { |
| | 292 | | case 200: |
| | 293 | | case 201: |
| 0 | 294 | | return message.Response; |
| | 295 | | default: |
| 0 | 296 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 297 | | } |
| 0 | 298 | | } |
| | 299 | |
|
| | 300 | | internal HttpMessage CreateUpdateTagsRequest(string resourceGroupName, string ddosCustomPolicyName, TagsObject p |
| | 301 | | { |
| 0 | 302 | | var message = _pipeline.CreateMessage(); |
| 0 | 303 | | var request = message.Request; |
| 0 | 304 | | request.Method = RequestMethod.Patch; |
| 0 | 305 | | var uri = new RawRequestUriBuilder(); |
| 0 | 306 | | uri.Reset(endpoint); |
| 0 | 307 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 308 | | uri.AppendPath(subscriptionId, true); |
| 0 | 309 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 310 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 311 | | uri.AppendPath("/providers/Microsoft.Network/ddosCustomPolicies/", false); |
| 0 | 312 | | uri.AppendPath(ddosCustomPolicyName, true); |
| 0 | 313 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 314 | | request.Uri = uri; |
| 0 | 315 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 316 | | var content = new Utf8JsonRequestContent(); |
| 0 | 317 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 318 | | request.Content = content; |
| 0 | 319 | | 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 | | { |
| 0 | 329 | | if (resourceGroupName == null) |
| | 330 | | { |
| 0 | 331 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 332 | | } |
| 0 | 333 | | if (ddosCustomPolicyName == null) |
| | 334 | | { |
| 0 | 335 | | throw new ArgumentNullException(nameof(ddosCustomPolicyName)); |
| | 336 | | } |
| 0 | 337 | | if (parameters == null) |
| | 338 | | { |
| 0 | 339 | | throw new ArgumentNullException(nameof(parameters)); |
| | 340 | | } |
| | 341 | |
|
| 0 | 342 | | using var message = CreateUpdateTagsRequest(resourceGroupName, ddosCustomPolicyName, parameters); |
| 0 | 343 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 344 | | switch (message.Response.Status) |
| | 345 | | { |
| | 346 | | case 200: |
| | 347 | | { |
| 0 | 348 | | DdosCustomPolicy value = default; |
| 0 | 349 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 350 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 351 | | { |
| 0 | 352 | | value = null; |
| | 353 | | } |
| | 354 | | else |
| | 355 | | { |
| 0 | 356 | | value = DdosCustomPolicy.DeserializeDdosCustomPolicy(document.RootElement); |
| | 357 | | } |
| 0 | 358 | | return Response.FromValue(value, message.Response); |
| | 359 | | } |
| | 360 | | default: |
| 0 | 361 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 362 | | } |
| 0 | 363 | | } |
| | 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 | | { |
| 0 | 372 | | if (resourceGroupName == null) |
| | 373 | | { |
| 0 | 374 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 375 | | } |
| 0 | 376 | | if (ddosCustomPolicyName == null) |
| | 377 | | { |
| 0 | 378 | | throw new ArgumentNullException(nameof(ddosCustomPolicyName)); |
| | 379 | | } |
| 0 | 380 | | if (parameters == null) |
| | 381 | | { |
| 0 | 382 | | throw new ArgumentNullException(nameof(parameters)); |
| | 383 | | } |
| | 384 | |
|
| 0 | 385 | | using var message = CreateUpdateTagsRequest(resourceGroupName, ddosCustomPolicyName, parameters); |
| 0 | 386 | | _pipeline.Send(message, cancellationToken); |
| 0 | 387 | | switch (message.Response.Status) |
| | 388 | | { |
| | 389 | | case 200: |
| | 390 | | { |
| 0 | 391 | | DdosCustomPolicy value = default; |
| 0 | 392 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 393 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 394 | | { |
| 0 | 395 | | value = null; |
| | 396 | | } |
| | 397 | | else |
| | 398 | | { |
| 0 | 399 | | value = DdosCustomPolicy.DeserializeDdosCustomPolicy(document.RootElement); |
| | 400 | | } |
| 0 | 401 | | return Response.FromValue(value, message.Response); |
| | 402 | | } |
| | 403 | | default: |
| 0 | 404 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 405 | | } |
| 0 | 406 | | } |
| | 407 | | } |
| | 408 | | } |