// This is an automatically generated code sample. 
// To make this code sample work in your Oracle Cloud tenancy, 
// please replace the values for any parameters whose current values do not fit
// your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and 
// boolean, number, and enum parameters with values not fitting your use case).

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oci.WafService;
using Oci.Common;
using Oci.Common.Auth;

namespace Oci.Sdk.DotNet.Example.Waf
{
    public class UpdateWebAppFirewallPolicyExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var updateWebAppFirewallPolicyDetails = new Oci.WafService.Models.UpdateWebAppFirewallPolicyDetails
			{
				DisplayName = "EXAMPLE-displayName-Value",
				Actions = new List<Oci.WafService.Models.Action>
				{
					new Oci.WafService.Models.CheckAction
					{
						Name = "EXAMPLE-name-Value"
					}
				},
				RequestAccessControl = new Oci.WafService.Models.RequestAccessControl
				{
					DefaultActionName = "EXAMPLE-defaultActionName-Value",
					Rules = new List<Oci.WafService.Models.AccessControlRule>
					{
						new Oci.WafService.Models.AccessControlRule
						{
							Name = "EXAMPLE-name-Value",
							ConditionLanguage = Oci.WafService.Models.WebAppFirewallPolicyRule.ConditionLanguageEnum.Jmespath,
							Condition = "EXAMPLE-condition-Value",
							ActionName = "EXAMPLE-actionName-Value"
						}
					}
				},
				RequestRateLimiting = new Oci.WafService.Models.RequestRateLimiting
				{
					Rules = new List<Oci.WafService.Models.RequestRateLimitingRule>
					{
						new Oci.WafService.Models.RequestRateLimitingRule
						{
							Configurations = new List<Oci.WafService.Models.RequestRateLimitingConfiguration>
							{
								new Oci.WafService.Models.RequestRateLimitingConfiguration
								{
									PeriodInSeconds = 6866,
									RequestsLimit = 747,
									ActionDurationInSeconds = 6015
								}
							},
							Name = "EXAMPLE-name-Value",
							ConditionLanguage = Oci.WafService.Models.WebAppFirewallPolicyRule.ConditionLanguageEnum.Jmespath,
							Condition = "EXAMPLE-condition-Value",
							ActionName = "EXAMPLE-actionName-Value"
						}
					}
				},
				RequestProtection = new Oci.WafService.Models.RequestProtection
				{
					Rules = new List<Oci.WafService.Models.ProtectionRule>
					{
						new Oci.WafService.Models.ProtectionRule
						{
							ProtectionCapabilities = new List<Oci.WafService.Models.ProtectionCapability>
							{
								new Oci.WafService.Models.ProtectionCapability
								{
									Key = "EXAMPLE-key-Value",
									Version = 804,
									Exclusions = new Oci.WafService.Models.ProtectionCapabilityExclusions
									{
										RequestCookies = new List<string>
										{
											"EXAMPLE--Value"
										},
										Args = new List<string>
										{
											"EXAMPLE--Value"
										}
									},
									ActionName = "EXAMPLE-actionName-Value",
									CollaborativeActionThreshold = 112,
									CollaborativeWeights = new List<Oci.WafService.Models.CollaborativeCapabilityWeightOverride>
									{
										new Oci.WafService.Models.CollaborativeCapabilityWeightOverride
										{
											Key = "EXAMPLE-key-Value",
											Weight = 81
										}
									}
								}
							},
							ProtectionCapabilitySettings = new Oci.WafService.Models.ProtectionCapabilitySettings
							{
								MaxNumberOfArguments = 8269,
								MaxSingleArgumentLength = 486748,
								MaxTotalArgumentLength = 13121813,
								MaxHttpRequestHeaders = 921,
								MaxHttpRequestHeaderLength = 453770,
								AllowedHttpMethods = new List<string>
								{
									"EXAMPLE--Value"
								}
							},
							IsBodyInspectionEnabled = true,
							Name = "EXAMPLE-name-Value",
							ConditionLanguage = Oci.WafService.Models.WebAppFirewallPolicyRule.ConditionLanguageEnum.Jmespath,
							Condition = "EXAMPLE-condition-Value",
							ActionName = "EXAMPLE-actionName-Value"
						}
					},
					BodyInspectionSizeLimitInBytes = 809,
					BodyInspectionSizeLimitExceededActionName = "EXAMPLE-bodyInspectionSizeLimitExceededActionName-Value"
				},
				ResponseAccessControl = new Oci.WafService.Models.ResponseAccessControl
				{
					Rules = new List<Oci.WafService.Models.AccessControlRule>
					{
						new Oci.WafService.Models.AccessControlRule
						{
							Name = "EXAMPLE-name-Value",
							ConditionLanguage = Oci.WafService.Models.WebAppFirewallPolicyRule.ConditionLanguageEnum.Jmespath,
							Condition = "EXAMPLE-condition-Value",
							ActionName = "EXAMPLE-actionName-Value"
						}
					}
				},
				ResponseProtection = new Oci.WafService.Models.ResponseProtection
				{
					Rules = new List<Oci.WafService.Models.ProtectionRule>
					{
						new Oci.WafService.Models.ProtectionRule
						{
							ProtectionCapabilities = new List<Oci.WafService.Models.ProtectionCapability>
							{
								new Oci.WafService.Models.ProtectionCapability
								{
									Key = "EXAMPLE-key-Value",
									Version = 911,
									Exclusions = new Oci.WafService.Models.ProtectionCapabilityExclusions
									{
										RequestCookies = new List<string>
										{
											"EXAMPLE--Value"
										},
										Args = new List<string>
										{
											"EXAMPLE--Value"
										}
									},
									ActionName = "EXAMPLE-actionName-Value",
									CollaborativeActionThreshold = 73,
									CollaborativeWeights = new List<Oci.WafService.Models.CollaborativeCapabilityWeightOverride>
									{
										new Oci.WafService.Models.CollaborativeCapabilityWeightOverride
										{
											Key = "EXAMPLE-key-Value",
											Weight = 993
										}
									}
								}
							},
							ProtectionCapabilitySettings = new Oci.WafService.Models.ProtectionCapabilitySettings
							{
								MaxNumberOfArguments = 1512,
								MaxSingleArgumentLength = 763479,
								MaxTotalArgumentLength = 17343146,
								MaxHttpRequestHeaders = 652,
								MaxHttpRequestHeaderLength = 547219,
								AllowedHttpMethods = new List<string>
								{
									"EXAMPLE--Value"
								}
							},
							IsBodyInspectionEnabled = true,
							Name = "EXAMPLE-name-Value",
							ConditionLanguage = Oci.WafService.Models.WebAppFirewallPolicyRule.ConditionLanguageEnum.Jmespath,
							Condition = "EXAMPLE-condition-Value",
							ActionName = "EXAMPLE-actionName-Value"
						}
					}
				},
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_RldQL", 
						"EXAMPLE_VALUE_lgawNANuIAPpLNdOrhe2"
					}
				},
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_QN3jX", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_d5Bue", 
								"EXAMPLE--Value"
							}
						}
					}
				},
				SystemTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_YYnWg", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_KGPeY", 
								"EXAMPLE--Value"
							}
						}
					}
				}
			};
			var updateWebAppFirewallPolicyRequest = new Oci.WafService.Requests.UpdateWebAppFirewallPolicyRequest
			{
				WebAppFirewallPolicyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-webAppFirewallPolicyId-Value",
				UpdateWebAppFirewallPolicyDetails = updateWebAppFirewallPolicyDetails,
				IfMatch = "EXAMPLE-ifMatch-Value",
				OpcRequestId = "R8J1ZFBWBKEW0CI4MDLS<unique_ID>"
			};

            // Create a default authentication provider that uses the DEFAULT
            // profile in the configuration file.
            // Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file. 
            var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
            try
            {
                // Create a service client and send the request.
				using (var client = new WafClient(provider, new ClientConfiguration()))
				{
					var response = await client.UpdateWebAppFirewallPolicy(updateWebAppFirewallPolicyRequest);
					// Retrieve value from the response.
					var versionValue = response.httpResponseMessage.Version;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"UpdateWebAppFirewallPolicy Failed with {e.Message}");
                throw e;
            }
        }

    }
}