| | 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 WebApplicationFirewallPoliciesRestOperations |
| | 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 WebApplicationFirewallPoliciesRestOperations. </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 WebApplicationFirewallPoliciesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, |
| | 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 CreateListRequest(string resourceGroupName) |
| | 47 | | { |
| 0 | 48 | | var message = _pipeline.CreateMessage(); |
| 0 | 49 | | var request = message.Request; |
| 0 | 50 | | request.Method = RequestMethod.Get; |
| 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/ApplicationGatewayWebApplicationFirewallPolicies", false); |
| 0 | 58 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 59 | | request.Uri = uri; |
| 0 | 60 | | return message; |
| | 61 | | } |
| | 62 | |
|
| | 63 | | /// <summary> Lists all of the protection policies within a resource group. </summary> |
| | 64 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 65 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 66 | | public async Task<Response<WebApplicationFirewallPolicyListResult>> ListAsync(string resourceGroupName, Cancella |
| | 67 | | { |
| 0 | 68 | | if (resourceGroupName == null) |
| | 69 | | { |
| 0 | 70 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 71 | | } |
| | 72 | |
|
| 0 | 73 | | using var message = CreateListRequest(resourceGroupName); |
| 0 | 74 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 75 | | switch (message.Response.Status) |
| | 76 | | { |
| | 77 | | case 200: |
| | 78 | | { |
| 0 | 79 | | WebApplicationFirewallPolicyListResult value = default; |
| 0 | 80 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 81 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 82 | | { |
| 0 | 83 | | value = null; |
| | 84 | | } |
| | 85 | | else |
| | 86 | | { |
| 0 | 87 | | value = WebApplicationFirewallPolicyListResult.DeserializeWebApplicationFirewallPolicyListRe |
| | 88 | | } |
| 0 | 89 | | return Response.FromValue(value, message.Response); |
| | 90 | | } |
| | 91 | | default: |
| 0 | 92 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 93 | | } |
| 0 | 94 | | } |
| | 95 | |
|
| | 96 | | /// <summary> Lists all of the protection policies within a resource group. </summary> |
| | 97 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 98 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 99 | | public Response<WebApplicationFirewallPolicyListResult> List(string resourceGroupName, CancellationToken cancell |
| | 100 | | { |
| 0 | 101 | | if (resourceGroupName == null) |
| | 102 | | { |
| 0 | 103 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 104 | | } |
| | 105 | |
|
| 0 | 106 | | using var message = CreateListRequest(resourceGroupName); |
| 0 | 107 | | _pipeline.Send(message, cancellationToken); |
| 0 | 108 | | switch (message.Response.Status) |
| | 109 | | { |
| | 110 | | case 200: |
| | 111 | | { |
| 0 | 112 | | WebApplicationFirewallPolicyListResult value = default; |
| 0 | 113 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 114 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 115 | | { |
| 0 | 116 | | value = null; |
| | 117 | | } |
| | 118 | | else |
| | 119 | | { |
| 0 | 120 | | value = WebApplicationFirewallPolicyListResult.DeserializeWebApplicationFirewallPolicyListRe |
| | 121 | | } |
| 0 | 122 | | return Response.FromValue(value, message.Response); |
| | 123 | | } |
| | 124 | | default: |
| 0 | 125 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 126 | | } |
| 0 | 127 | | } |
| | 128 | |
|
| | 129 | | internal HttpMessage CreateListAllRequest() |
| | 130 | | { |
| 0 | 131 | | var message = _pipeline.CreateMessage(); |
| 0 | 132 | | var request = message.Request; |
| 0 | 133 | | request.Method = RequestMethod.Get; |
| 0 | 134 | | var uri = new RawRequestUriBuilder(); |
| 0 | 135 | | uri.Reset(endpoint); |
| 0 | 136 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 137 | | uri.AppendPath(subscriptionId, true); |
| 0 | 138 | | uri.AppendPath("/providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies", false); |
| 0 | 139 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 140 | | request.Uri = uri; |
| 0 | 141 | | return message; |
| | 142 | | } |
| | 143 | |
|
| | 144 | | /// <summary> Gets all the WAF policies in a subscription. </summary> |
| | 145 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 146 | | public async Task<Response<WebApplicationFirewallPolicyListResult>> ListAllAsync(CancellationToken cancellationT |
| | 147 | | { |
| 0 | 148 | | using var message = CreateListAllRequest(); |
| 0 | 149 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 150 | | switch (message.Response.Status) |
| | 151 | | { |
| | 152 | | case 200: |
| | 153 | | { |
| 0 | 154 | | WebApplicationFirewallPolicyListResult value = default; |
| 0 | 155 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 156 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 157 | | { |
| 0 | 158 | | value = null; |
| | 159 | | } |
| | 160 | | else |
| | 161 | | { |
| 0 | 162 | | value = WebApplicationFirewallPolicyListResult.DeserializeWebApplicationFirewallPolicyListRe |
| | 163 | | } |
| 0 | 164 | | return Response.FromValue(value, message.Response); |
| | 165 | | } |
| | 166 | | default: |
| 0 | 167 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 168 | | } |
| 0 | 169 | | } |
| | 170 | |
|
| | 171 | | /// <summary> Gets all the WAF policies in a subscription. </summary> |
| | 172 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 173 | | public Response<WebApplicationFirewallPolicyListResult> ListAll(CancellationToken cancellationToken = default) |
| | 174 | | { |
| 0 | 175 | | using var message = CreateListAllRequest(); |
| 0 | 176 | | _pipeline.Send(message, cancellationToken); |
| 0 | 177 | | switch (message.Response.Status) |
| | 178 | | { |
| | 179 | | case 200: |
| | 180 | | { |
| 0 | 181 | | WebApplicationFirewallPolicyListResult value = default; |
| 0 | 182 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 183 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 184 | | { |
| 0 | 185 | | value = null; |
| | 186 | | } |
| | 187 | | else |
| | 188 | | { |
| 0 | 189 | | value = WebApplicationFirewallPolicyListResult.DeserializeWebApplicationFirewallPolicyListRe |
| | 190 | | } |
| 0 | 191 | | return Response.FromValue(value, message.Response); |
| | 192 | | } |
| | 193 | | default: |
| 0 | 194 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 195 | | } |
| 0 | 196 | | } |
| | 197 | |
|
| | 198 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string policyName) |
| | 199 | | { |
| 0 | 200 | | var message = _pipeline.CreateMessage(); |
| 0 | 201 | | var request = message.Request; |
| 0 | 202 | | request.Method = RequestMethod.Get; |
| 0 | 203 | | var uri = new RawRequestUriBuilder(); |
| 0 | 204 | | uri.Reset(endpoint); |
| 0 | 205 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 206 | | uri.AppendPath(subscriptionId, true); |
| 0 | 207 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 208 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 209 | | uri.AppendPath("/providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/", false); |
| 0 | 210 | | uri.AppendPath(policyName, true); |
| 0 | 211 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 212 | | request.Uri = uri; |
| 0 | 213 | | return message; |
| | 214 | | } |
| | 215 | |
|
| | 216 | | /// <summary> Retrieve protection policy with specified name within a resource group. </summary> |
| | 217 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 218 | | /// <param name="policyName"> The name of the policy. </param> |
| | 219 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 220 | | public async Task<Response<WebApplicationFirewallPolicy>> GetAsync(string resourceGroupName, string policyName, |
| | 221 | | { |
| 0 | 222 | | if (resourceGroupName == null) |
| | 223 | | { |
| 0 | 224 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 225 | | } |
| 0 | 226 | | if (policyName == null) |
| | 227 | | { |
| 0 | 228 | | throw new ArgumentNullException(nameof(policyName)); |
| | 229 | | } |
| | 230 | |
|
| 0 | 231 | | using var message = CreateGetRequest(resourceGroupName, policyName); |
| 0 | 232 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 233 | | switch (message.Response.Status) |
| | 234 | | { |
| | 235 | | case 200: |
| | 236 | | { |
| 0 | 237 | | WebApplicationFirewallPolicy value = default; |
| 0 | 238 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 239 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 240 | | { |
| 0 | 241 | | value = null; |
| | 242 | | } |
| | 243 | | else |
| | 244 | | { |
| 0 | 245 | | value = WebApplicationFirewallPolicy.DeserializeWebApplicationFirewallPolicy(document.RootEl |
| | 246 | | } |
| 0 | 247 | | return Response.FromValue(value, message.Response); |
| | 248 | | } |
| | 249 | | default: |
| 0 | 250 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 251 | | } |
| 0 | 252 | | } |
| | 253 | |
|
| | 254 | | /// <summary> Retrieve protection policy with specified name within a resource group. </summary> |
| | 255 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 256 | | /// <param name="policyName"> The name of the policy. </param> |
| | 257 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 258 | | public Response<WebApplicationFirewallPolicy> Get(string resourceGroupName, string policyName, CancellationToken |
| | 259 | | { |
| 0 | 260 | | if (resourceGroupName == null) |
| | 261 | | { |
| 0 | 262 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 263 | | } |
| 0 | 264 | | if (policyName == null) |
| | 265 | | { |
| 0 | 266 | | throw new ArgumentNullException(nameof(policyName)); |
| | 267 | | } |
| | 268 | |
|
| 0 | 269 | | using var message = CreateGetRequest(resourceGroupName, policyName); |
| 0 | 270 | | _pipeline.Send(message, cancellationToken); |
| 0 | 271 | | switch (message.Response.Status) |
| | 272 | | { |
| | 273 | | case 200: |
| | 274 | | { |
| 0 | 275 | | WebApplicationFirewallPolicy value = default; |
| 0 | 276 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 277 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 278 | | { |
| 0 | 279 | | value = null; |
| | 280 | | } |
| | 281 | | else |
| | 282 | | { |
| 0 | 283 | | value = WebApplicationFirewallPolicy.DeserializeWebApplicationFirewallPolicy(document.RootEl |
| | 284 | | } |
| 0 | 285 | | return Response.FromValue(value, message.Response); |
| | 286 | | } |
| | 287 | | default: |
| 0 | 288 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 289 | | } |
| 0 | 290 | | } |
| | 291 | |
|
| | 292 | | internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string policyName, WebApplicationFire |
| | 293 | | { |
| 0 | 294 | | var message = _pipeline.CreateMessage(); |
| 0 | 295 | | var request = message.Request; |
| 0 | 296 | | request.Method = RequestMethod.Put; |
| 0 | 297 | | var uri = new RawRequestUriBuilder(); |
| 0 | 298 | | uri.Reset(endpoint); |
| 0 | 299 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 300 | | uri.AppendPath(subscriptionId, true); |
| 0 | 301 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 302 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 303 | | uri.AppendPath("/providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/", false); |
| 0 | 304 | | uri.AppendPath(policyName, true); |
| 0 | 305 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 306 | | request.Uri = uri; |
| 0 | 307 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 308 | | var content = new Utf8JsonRequestContent(); |
| 0 | 309 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 310 | | request.Content = content; |
| 0 | 311 | | return message; |
| | 312 | | } |
| | 313 | |
|
| | 314 | | /// <summary> Creates or update policy with specified rule set name within a resource group. </summary> |
| | 315 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 316 | | /// <param name="policyName"> The name of the policy. </param> |
| | 317 | | /// <param name="parameters"> Policy to be created. </param> |
| | 318 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 319 | | public async Task<Response<WebApplicationFirewallPolicy>> CreateOrUpdateAsync(string resourceGroupName, string p |
| | 320 | | { |
| 0 | 321 | | if (resourceGroupName == null) |
| | 322 | | { |
| 0 | 323 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 324 | | } |
| 0 | 325 | | if (policyName == null) |
| | 326 | | { |
| 0 | 327 | | throw new ArgumentNullException(nameof(policyName)); |
| | 328 | | } |
| 0 | 329 | | if (parameters == null) |
| | 330 | | { |
| 0 | 331 | | throw new ArgumentNullException(nameof(parameters)); |
| | 332 | | } |
| | 333 | |
|
| 0 | 334 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, policyName, parameters); |
| 0 | 335 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 336 | | switch (message.Response.Status) |
| | 337 | | { |
| | 338 | | case 200: |
| | 339 | | case 201: |
| | 340 | | { |
| 0 | 341 | | WebApplicationFirewallPolicy value = default; |
| 0 | 342 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 343 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 344 | | { |
| 0 | 345 | | value = null; |
| | 346 | | } |
| | 347 | | else |
| | 348 | | { |
| 0 | 349 | | value = WebApplicationFirewallPolicy.DeserializeWebApplicationFirewallPolicy(document.RootEl |
| | 350 | | } |
| 0 | 351 | | return Response.FromValue(value, message.Response); |
| | 352 | | } |
| | 353 | | default: |
| 0 | 354 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 355 | | } |
| 0 | 356 | | } |
| | 357 | |
|
| | 358 | | /// <summary> Creates or update policy with specified rule set name within a resource group. </summary> |
| | 359 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 360 | | /// <param name="policyName"> The name of the policy. </param> |
| | 361 | | /// <param name="parameters"> Policy to be created. </param> |
| | 362 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 363 | | public Response<WebApplicationFirewallPolicy> CreateOrUpdate(string resourceGroupName, string policyName, WebApp |
| | 364 | | { |
| 0 | 365 | | if (resourceGroupName == null) |
| | 366 | | { |
| 0 | 367 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 368 | | } |
| 0 | 369 | | if (policyName == null) |
| | 370 | | { |
| 0 | 371 | | throw new ArgumentNullException(nameof(policyName)); |
| | 372 | | } |
| 0 | 373 | | if (parameters == null) |
| | 374 | | { |
| 0 | 375 | | throw new ArgumentNullException(nameof(parameters)); |
| | 376 | | } |
| | 377 | |
|
| 0 | 378 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, policyName, parameters); |
| 0 | 379 | | _pipeline.Send(message, cancellationToken); |
| 0 | 380 | | switch (message.Response.Status) |
| | 381 | | { |
| | 382 | | case 200: |
| | 383 | | case 201: |
| | 384 | | { |
| 0 | 385 | | WebApplicationFirewallPolicy value = default; |
| 0 | 386 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 387 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 388 | | { |
| 0 | 389 | | value = null; |
| | 390 | | } |
| | 391 | | else |
| | 392 | | { |
| 0 | 393 | | value = WebApplicationFirewallPolicy.DeserializeWebApplicationFirewallPolicy(document.RootEl |
| | 394 | | } |
| 0 | 395 | | return Response.FromValue(value, message.Response); |
| | 396 | | } |
| | 397 | | default: |
| 0 | 398 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 399 | | } |
| 0 | 400 | | } |
| | 401 | |
|
| | 402 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string policyName) |
| | 403 | | { |
| 0 | 404 | | var message = _pipeline.CreateMessage(); |
| 0 | 405 | | var request = message.Request; |
| 0 | 406 | | request.Method = RequestMethod.Delete; |
| 0 | 407 | | var uri = new RawRequestUriBuilder(); |
| 0 | 408 | | uri.Reset(endpoint); |
| 0 | 409 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 410 | | uri.AppendPath(subscriptionId, true); |
| 0 | 411 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 412 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 413 | | uri.AppendPath("/providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/", false); |
| 0 | 414 | | uri.AppendPath(policyName, true); |
| 0 | 415 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 416 | | request.Uri = uri; |
| 0 | 417 | | return message; |
| | 418 | | } |
| | 419 | |
|
| | 420 | | /// <summary> Deletes Policy. </summary> |
| | 421 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 422 | | /// <param name="policyName"> The name of the policy. </param> |
| | 423 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 424 | | public async Task<Response> DeleteAsync(string resourceGroupName, string policyName, CancellationToken cancellat |
| | 425 | | { |
| 0 | 426 | | if (resourceGroupName == null) |
| | 427 | | { |
| 0 | 428 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 429 | | } |
| 0 | 430 | | if (policyName == null) |
| | 431 | | { |
| 0 | 432 | | throw new ArgumentNullException(nameof(policyName)); |
| | 433 | | } |
| | 434 | |
|
| 0 | 435 | | using var message = CreateDeleteRequest(resourceGroupName, policyName); |
| 0 | 436 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 437 | | switch (message.Response.Status) |
| | 438 | | { |
| | 439 | | case 200: |
| | 440 | | case 202: |
| | 441 | | case 204: |
| 0 | 442 | | return message.Response; |
| | 443 | | default: |
| 0 | 444 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 445 | | } |
| 0 | 446 | | } |
| | 447 | |
|
| | 448 | | /// <summary> Deletes Policy. </summary> |
| | 449 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 450 | | /// <param name="policyName"> The name of the policy. </param> |
| | 451 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 452 | | public Response Delete(string resourceGroupName, string policyName, CancellationToken cancellationToken = defaul |
| | 453 | | { |
| 0 | 454 | | if (resourceGroupName == null) |
| | 455 | | { |
| 0 | 456 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 457 | | } |
| 0 | 458 | | if (policyName == null) |
| | 459 | | { |
| 0 | 460 | | throw new ArgumentNullException(nameof(policyName)); |
| | 461 | | } |
| | 462 | |
|
| 0 | 463 | | using var message = CreateDeleteRequest(resourceGroupName, policyName); |
| 0 | 464 | | _pipeline.Send(message, cancellationToken); |
| 0 | 465 | | switch (message.Response.Status) |
| | 466 | | { |
| | 467 | | case 200: |
| | 468 | | case 202: |
| | 469 | | case 204: |
| 0 | 470 | | return message.Response; |
| | 471 | | default: |
| 0 | 472 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 473 | | } |
| 0 | 474 | | } |
| | 475 | |
|
| | 476 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName) |
| | 477 | | { |
| 0 | 478 | | var message = _pipeline.CreateMessage(); |
| 0 | 479 | | var request = message.Request; |
| 0 | 480 | | request.Method = RequestMethod.Get; |
| 0 | 481 | | var uri = new RawRequestUriBuilder(); |
| 0 | 482 | | uri.Reset(endpoint); |
| 0 | 483 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 484 | | request.Uri = uri; |
| 0 | 485 | | return message; |
| | 486 | | } |
| | 487 | |
|
| | 488 | | /// <summary> Lists all of the protection policies within a resource group. </summary> |
| | 489 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 490 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 491 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 492 | | public async Task<Response<WebApplicationFirewallPolicyListResult>> ListNextPageAsync(string nextLink, string re |
| | 493 | | { |
| 0 | 494 | | if (nextLink == null) |
| | 495 | | { |
| 0 | 496 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 497 | | } |
| 0 | 498 | | if (resourceGroupName == null) |
| | 499 | | { |
| 0 | 500 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 501 | | } |
| | 502 | |
|
| 0 | 503 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName); |
| 0 | 504 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 505 | | switch (message.Response.Status) |
| | 506 | | { |
| | 507 | | case 200: |
| | 508 | | { |
| 0 | 509 | | WebApplicationFirewallPolicyListResult value = default; |
| 0 | 510 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 511 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 512 | | { |
| 0 | 513 | | value = null; |
| | 514 | | } |
| | 515 | | else |
| | 516 | | { |
| 0 | 517 | | value = WebApplicationFirewallPolicyListResult.DeserializeWebApplicationFirewallPolicyListRe |
| | 518 | | } |
| 0 | 519 | | return Response.FromValue(value, message.Response); |
| | 520 | | } |
| | 521 | | default: |
| 0 | 522 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 523 | | } |
| 0 | 524 | | } |
| | 525 | |
|
| | 526 | | /// <summary> Lists all of the protection policies within a resource group. </summary> |
| | 527 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 528 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 529 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 530 | | public Response<WebApplicationFirewallPolicyListResult> ListNextPage(string nextLink, string resourceGroupName, |
| | 531 | | { |
| 0 | 532 | | if (nextLink == null) |
| | 533 | | { |
| 0 | 534 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 535 | | } |
| 0 | 536 | | if (resourceGroupName == null) |
| | 537 | | { |
| 0 | 538 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 539 | | } |
| | 540 | |
|
| 0 | 541 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName); |
| 0 | 542 | | _pipeline.Send(message, cancellationToken); |
| 0 | 543 | | switch (message.Response.Status) |
| | 544 | | { |
| | 545 | | case 200: |
| | 546 | | { |
| 0 | 547 | | WebApplicationFirewallPolicyListResult value = default; |
| 0 | 548 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 549 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 550 | | { |
| 0 | 551 | | value = null; |
| | 552 | | } |
| | 553 | | else |
| | 554 | | { |
| 0 | 555 | | value = WebApplicationFirewallPolicyListResult.DeserializeWebApplicationFirewallPolicyListRe |
| | 556 | | } |
| 0 | 557 | | return Response.FromValue(value, message.Response); |
| | 558 | | } |
| | 559 | | default: |
| 0 | 560 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 561 | | } |
| 0 | 562 | | } |
| | 563 | |
|
| | 564 | | internal HttpMessage CreateListAllNextPageRequest(string nextLink) |
| | 565 | | { |
| 0 | 566 | | var message = _pipeline.CreateMessage(); |
| 0 | 567 | | var request = message.Request; |
| 0 | 568 | | request.Method = RequestMethod.Get; |
| 0 | 569 | | var uri = new RawRequestUriBuilder(); |
| 0 | 570 | | uri.Reset(endpoint); |
| 0 | 571 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 572 | | request.Uri = uri; |
| 0 | 573 | | return message; |
| | 574 | | } |
| | 575 | |
|
| | 576 | | /// <summary> Gets all the WAF policies in a subscription. </summary> |
| | 577 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 578 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 579 | | public async Task<Response<WebApplicationFirewallPolicyListResult>> ListAllNextPageAsync(string nextLink, Cancel |
| | 580 | | { |
| 0 | 581 | | if (nextLink == null) |
| | 582 | | { |
| 0 | 583 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 584 | | } |
| | 585 | |
|
| 0 | 586 | | using var message = CreateListAllNextPageRequest(nextLink); |
| 0 | 587 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 588 | | switch (message.Response.Status) |
| | 589 | | { |
| | 590 | | case 200: |
| | 591 | | { |
| 0 | 592 | | WebApplicationFirewallPolicyListResult value = default; |
| 0 | 593 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 594 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 595 | | { |
| 0 | 596 | | value = null; |
| | 597 | | } |
| | 598 | | else |
| | 599 | | { |
| 0 | 600 | | value = WebApplicationFirewallPolicyListResult.DeserializeWebApplicationFirewallPolicyListRe |
| | 601 | | } |
| 0 | 602 | | return Response.FromValue(value, message.Response); |
| | 603 | | } |
| | 604 | | default: |
| 0 | 605 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 606 | | } |
| 0 | 607 | | } |
| | 608 | |
|
| | 609 | | /// <summary> Gets all the WAF policies in a subscription. </summary> |
| | 610 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 611 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 612 | | public Response<WebApplicationFirewallPolicyListResult> ListAllNextPage(string nextLink, CancellationToken cance |
| | 613 | | { |
| 0 | 614 | | if (nextLink == null) |
| | 615 | | { |
| 0 | 616 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 617 | | } |
| | 618 | |
|
| 0 | 619 | | using var message = CreateListAllNextPageRequest(nextLink); |
| 0 | 620 | | _pipeline.Send(message, cancellationToken); |
| 0 | 621 | | switch (message.Response.Status) |
| | 622 | | { |
| | 623 | | case 200: |
| | 624 | | { |
| 0 | 625 | | WebApplicationFirewallPolicyListResult value = default; |
| 0 | 626 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 627 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 628 | | { |
| 0 | 629 | | value = null; |
| | 630 | | } |
| | 631 | | else |
| | 632 | | { |
| 0 | 633 | | value = WebApplicationFirewallPolicyListResult.DeserializeWebApplicationFirewallPolicyListRe |
| | 634 | | } |
| 0 | 635 | | return Response.FromValue(value, message.Response); |
| | 636 | | } |
| | 637 | | default: |
| 0 | 638 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 639 | | } |
| 0 | 640 | | } |
| | 641 | | } |
| | 642 | | } |