// 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).

import * as waf from "oci-waf";
import common = require("oci-common");

// 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.

const provider: common.ConfigFileAuthenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider();

(async () => {
    try {
     // Create a service client
     const client = new waf.WafClient({ authenticationDetailsProvider: provider });

     // Create a request and dependent object(s).
	const  updateWebAppFirewallPolicyDetails = {
		displayName: "EXAMPLE-displayName-Value",
		actions: [{
				type: "RETURN_HTTP_RESPONSE",				code: 443,
				headers: [{
						name: "EXAMPLE-name-Value",
						value: "EXAMPLE-value-Value",

						}
						],
				body: {
					type: "DYNAMIC",					template: "EXAMPLE-template-Value"

					}
,
				name: "EXAMPLE-name-Value"

				}
				],
		requestAccessControl: {
			defaultActionName: "EXAMPLE-defaultActionName-Value",
			rules: [{
					type: "ACCESS_CONTROL",					name: "EXAMPLE-name-Value",
					conditionLanguage: waf.models.WebAppFirewallPolicyRule.ConditionLanguage.Jmespath,
					condition: "EXAMPLE-condition-Value",
					actionName: "EXAMPLE-actionName-Value"

					}
					],

			}
,
		requestRateLimiting: {
			rules: [{
					type: "REQUEST_RATE_LIMITING",					configurations: [{
							periodInSeconds: 60107,
							requestsLimit: 158,
							actionDurationInSeconds: 13713,

							}
							],
					name: "EXAMPLE-name-Value",
					conditionLanguage: waf.models.WebAppFirewallPolicyRule.ConditionLanguage.Jmespath,
					condition: "EXAMPLE-condition-Value",
					actionName: "EXAMPLE-actionName-Value"

					}
					],

			}
,
		requestProtection: {
			rules: [{
					type: "PROTECTION",					protectionCapabilities: [{
							key: "EXAMPLE-key-Value",
							version: 466,
							exclusions: {
								requestCookies: ["EXAMPLE--Value"										],
								args: ["EXAMPLE--Value"										],

								}
,
							actionName: "EXAMPLE-actionName-Value",
							collaborativeActionThreshold: 324,
							collaborativeWeights: [{
									key: "EXAMPLE-key-Value",
									weight: 159,

									}
									],

							}
							],
					protectionCapabilitySettings: {
						maxNumberOfArguments: 5159,
						maxSingleArgumentLength: 271238,
						maxTotalArgumentLength: 21676530,
						maxHttpRequestHeaders: 211,
						maxHttpRequestHeaderLength: 923933,
						allowedHttpMethods: ["EXAMPLE--Value"								],

						}
,
					isBodyInspectionEnabled: false,
					name: "EXAMPLE-name-Value",
					conditionLanguage: waf.models.WebAppFirewallPolicyRule.ConditionLanguage.Jmespath,
					condition: "EXAMPLE-condition-Value",
					actionName: "EXAMPLE-actionName-Value"

					}
					],
			bodyInspectionSizeLimitInBytes: 933,
			bodyInspectionSizeLimitExceededActionName: "EXAMPLE-bodyInspectionSizeLimitExceededActionName-Value",

			}
,
		responseAccessControl: {
			rules: [{
					type: "ACCESS_CONTROL",					name: "EXAMPLE-name-Value",
					conditionLanguage: waf.models.WebAppFirewallPolicyRule.ConditionLanguage.Jmespath,
					condition: "EXAMPLE-condition-Value",
					actionName: "EXAMPLE-actionName-Value"

					}
					],

			}
,
		responseProtection: {
			rules: [{
					type: "PROTECTION",					protectionCapabilities: [{
							key: "EXAMPLE-key-Value",
							version: 551,
							exclusions: {
								requestCookies: ["EXAMPLE--Value"										],
								args: ["EXAMPLE--Value"										],

								}
,
							actionName: "EXAMPLE-actionName-Value",
							collaborativeActionThreshold: 302,
							collaborativeWeights: [{
									key: "EXAMPLE-key-Value",
									weight: 774,

									}
									],

							}
							],
					protectionCapabilitySettings: {
						maxNumberOfArguments: 7362,
						maxSingleArgumentLength: 834210,
						maxTotalArgumentLength: 23169087,
						maxHttpRequestHeaders: 238,
						maxHttpRequestHeaderLength: 664797,
						allowedHttpMethods: ["EXAMPLE--Value"								],

						}
,
					isBodyInspectionEnabled: true,
					name: "EXAMPLE-name-Value",
					conditionLanguage: waf.models.WebAppFirewallPolicyRule.ConditionLanguage.Jmespath,
					condition: "EXAMPLE-condition-Value",
					actionName: "EXAMPLE-actionName-Value"

					}
					],

			}
,
		freeformTags: {
			EXAMPLE_KEY_4APtq :"EXAMPLE_VALUE_4JR2hUANbC8bCOBGAfNe"
			},
		definedTags: {
			EXAMPLE_KEY_yCBl8 :{
				EXAMPLE_KEY_0xj8m :"EXAMPLE--Value"
				}
			},
		systemTags: {
			EXAMPLE_KEY_Kq15M :{
				EXAMPLE_KEY_ehFaV :"EXAMPLE--Value"
				}
			},

		}

	const updateWebAppFirewallPolicyRequest: waf.requests.UpdateWebAppFirewallPolicyRequest = { 
	webAppFirewallPolicyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-webAppFirewallPolicyId-Value",
	updateWebAppFirewallPolicyDetails: updateWebAppFirewallPolicyDetails,
	ifMatch: "EXAMPLE-ifMatch-Value",
	opcRequestId: "ERSGB5VTF7R9PIDU7FGE<unique_ID>",

		}; 


     // Send request to the Client.
     const updateWebAppFirewallPolicyResponse = await client.updateWebAppFirewallPolicy(updateWebAppFirewallPolicyRequest);
     }
     catch (error) {
         console.log("updateWebAppFirewallPolicy Failed with error  " + error);
     }
})();