// 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  createWebAppFirewallPolicyDetails = {
		displayName: "EXAMPLE-displayName-Value",
		compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
		actions: [{
				type: "RETURN_HTTP_RESPONSE",				code: 527,
				headers: [{
						name: "EXAMPLE-name-Value",
						value: "EXAMPLE-value-Value",

						}
						],
				body: {
					type: "STATIC_TEXT",					text: "EXAMPLE-text-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: 17147,
							requestsLimit: 137,
							actionDurationInSeconds: 31340,

							}
							],
					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: 218,
							exclusions: {
								requestCookies: ["EXAMPLE--Value"										],
								args: ["EXAMPLE--Value"										],

								}
,
							actionName: "EXAMPLE-actionName-Value",
							collaborativeActionThreshold: 620,
							collaborativeWeights: [{
									key: "EXAMPLE-key-Value",
									weight: 643,

									}
									],

							}
							],
					protectionCapabilitySettings: {
						maxNumberOfArguments: 455,
						maxSingleArgumentLength: 393334,
						maxTotalArgumentLength: 5505942,
						maxHttpRequestHeaders: 851,
						maxHttpRequestHeaderLength: 385195,
						allowedHttpMethods: ["EXAMPLE--Value"								],

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

					}
					],
			bodyInspectionSizeLimitInBytes: 497,
			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: 819,
							exclusions: {
								requestCookies: ["EXAMPLE--Value"										],
								args: ["EXAMPLE--Value"										],

								}
,
							actionName: "EXAMPLE-actionName-Value",
							collaborativeActionThreshold: 142,
							collaborativeWeights: [{
									key: "EXAMPLE-key-Value",
									weight: 738,

									}
									],

							}
							],
					protectionCapabilitySettings: {
						maxNumberOfArguments: 7146,
						maxSingleArgumentLength: 53535,
						maxTotalArgumentLength: 19741770,
						maxHttpRequestHeaders: 421,
						maxHttpRequestHeaderLength: 258529,
						allowedHttpMethods: ["EXAMPLE--Value"								],

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

					}
					],

			}
,
		freeformTags: {
			EXAMPLE_KEY_lyxb6 :"EXAMPLE_VALUE_TWArsyCXFw63eneO0hUk"
			},
		definedTags: {
			EXAMPLE_KEY_KHiYR :{
				EXAMPLE_KEY_5rAfY :"EXAMPLE--Value"
				}
			},
		systemTags: {
			EXAMPLE_KEY_RUnPP :{
				EXAMPLE_KEY_1lfWh :"EXAMPLE--Value"
				}
			},

		}

	const createWebAppFirewallPolicyRequest: waf.requests.CreateWebAppFirewallPolicyRequest = { 
	createWebAppFirewallPolicyDetails: createWebAppFirewallPolicyDetails,
	opcRetryToken: "EXAMPLE-opcRetryToken-Value",
	opcRequestId: "AFHVACCXOMSQ0OGRK7IQ<unique_ID>",

		}; 


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