// 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 waas from "oci-waas";
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 waas.WaasClient({ authenticationDetailsProvider: provider });

     // Create a request and dependent object(s).
	const  createWaasPolicyDetails = {
		compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
		displayName: "EXAMPLE-displayName-Value",
		domain: "EXAMPLE-domain-Value",
		additionalDomains: ["EXAMPLE--Value"				],
		origins: {
			EXAMPLE_KEY_zCZFW :{
				uri: "EXAMPLE-uri-Value",
				httpPort: 14434,
				httpsPort: 25077,
				customHeaders: [{
						name: "EXAMPLE-name-Value",
						value: "EXAMPLE-value-Value",

						}
						],

				}

			},
		originGroups: {
			EXAMPLE_KEY_99ahw :{
				origins: [{
						origin: "EXAMPLE-origin-Value",
						weight: 8688,

						}
						],

				}

			},
		policyConfig: {
			certificateId: "ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value",
			isHttpsEnabled: false,
			isHttpsForced: false,
			tlsProtocols: [waas.models.PolicyConfig.TlsProtocols.TlsV1					],
			isOriginCompressionEnabled: false,
			isBehindCdn: true,
			clientAddressHeader: waas.models.PolicyConfig.ClientAddressHeader.XRealIp,
			isCacheControlRespected: true,
			isResponseBufferingEnabled: true,
			cipherGroup: waas.models.PolicyConfig.CipherGroup.Default,
			loadBalancingMethod: {
				method: "STICKY_COOKIE",				name: "EXAMPLE-name-Value",
				domain: "EXAMPLE-domain-Value",
				expirationTimeInSeconds: 16555334

				}
,
			websocketPathPrefixes: ["EXAMPLE--Value"					],
			isSniEnabled: false,
			healthChecks: {
				isEnabled: true,
				method: waas.models.HealthCheck.Method.Post,
				path: "EXAMPLE-path-Value",
				headers: {
					EXAMPLE_KEY_b8vB4 :"EXAMPLE_VALUE_lt5BUSCbuDIt5iCbIYS0"
					},
				expectedResponseCodeGroup: [waas.models.HealthCheck.ExpectedResponseCodeGroup._4Xx						],
				isResponseTextCheckEnabled: false,
				expectedResponseText: "EXAMPLE-expectedResponseText-Value",
				intervalInSeconds: 20,
				timeoutInSeconds: 13,
				healthyThreshold: 2,
				unhealthyThreshold: 14,

				}
,

			}
,
		wafConfig: {
			accessRules: [{
					name: "EXAMPLE-name-Value",
					criteria: [{
							condition: waas.models.AccessRuleCriteria.Condition.UrlRegex,
							value: "EXAMPLE-value-Value",
							isCaseSensitive: true,

							}
							],
					action: waas.models.AccessRule.Action.Allow,
					blockAction: waas.models.AccessRule.BlockAction.ShowErrorPage,
					blockResponseCode: 956,
					blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
					blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
					blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
					bypassChallenges: [waas.models.AccessRule.BypassChallenges.Captcha							],
					redirectUrl: "EXAMPLE-redirectUrl-Value",
					redirectResponseCode: waas.models.AccessRule.RedirectResponseCode.MovedPermanently,
					captchaTitle: "EXAMPLE-captchaTitle-Value",
					captchaHeader: "EXAMPLE-captchaHeader-Value",
					captchaFooter: "EXAMPLE-captchaFooter-Value",
					captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",
					responseHeaderManipulation: [{
							action: "REMOVE_HTTP_RESPONSE_HEADER",							header: "EXAMPLE-header-Value"

							}
							],

					}
					],
			addressRateLimiting: {
				isEnabled: false,
				allowedRatePerAddress: 3871,
				maxDelayedCountPerAddress: 1426,
				blockResponseCode: 637,

				}
,
			captchas: [{
					url: "EXAMPLE-url-Value",
					sessionExpirationInSeconds: 301304,
					title: "EXAMPLE-title-Value",
					headerText: "EXAMPLE-headerText-Value",
					footerText: "EXAMPLE-footerText-Value",
					failureMessage: "EXAMPLE-failureMessage-Value",
					submitLabel: "EXAMPLE-submitLabel-Value",

					}
					],
			deviceFingerprintChallenge: {
				isEnabled: false,
				action: waas.models.DeviceFingerprintChallenge.Action.Block,
				failureThreshold: 318737,
				actionExpirationInSeconds: 164343,
				failureThresholdExpirationInSeconds: 291704,
				maxAddressCount: 2620,
				maxAddressCountExpirationInSeconds: 238632,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowErrorPage,
					blockResponseCode: 699,
					blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
					blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
					blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
					captchaTitle: "EXAMPLE-captchaTitle-Value",
					captchaHeader: "EXAMPLE-captchaHeader-Value",
					captchaFooter: "EXAMPLE-captchaFooter-Value",
					captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",

					}
,

				}
,
			humanInteractionChallenge: {
				isEnabled: false,
				action: waas.models.HumanInteractionChallenge.Action.Detect,
				failureThreshold: 71762,
				actionExpirationInSeconds: 207483,
				failureThresholdExpirationInSeconds: 72019,
				interactionThreshold: 96,
				recordingPeriodInSeconds: 1873,
				setHttpHeader: {
					name: "EXAMPLE-name-Value",
					value: "EXAMPLE-value-Value",

					}
,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowErrorPage,
					blockResponseCode: 293,
					blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
					blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
					blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
					captchaTitle: "EXAMPLE-captchaTitle-Value",
					captchaHeader: "EXAMPLE-captchaHeader-Value",
					captchaFooter: "EXAMPLE-captchaFooter-Value",
					captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",

					}
,
				isNatEnabled: false,

				}
,
			jsChallenge: {
				isEnabled: false,
				action: waas.models.JsChallenge.Action.Block,
				failureThreshold: 379978,
				actionExpirationInSeconds: 274757,
				setHttpHeader: {
					name: "EXAMPLE-name-Value",
					value: "EXAMPLE-value-Value",

					}
,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowCaptcha,
					blockResponseCode: 215,
					blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
					blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
					blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
					captchaTitle: "EXAMPLE-captchaTitle-Value",
					captchaHeader: "EXAMPLE-captchaHeader-Value",
					captchaFooter: "EXAMPLE-captchaFooter-Value",
					captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",

					}
,
				areRedirectsChallenged: false,
				criteria: [{
						condition: waas.models.AccessRuleCriteria.Condition.UrlDoesNotStartWith,
						value: "EXAMPLE-value-Value",
						isCaseSensitive: true,

						}
						],
				isNatEnabled: false,

				}
,
			origin: "EXAMPLE-origin-Value",
			cachingRules: [{
					key: "EXAMPLE-key-Value",
					name: "EXAMPLE-name-Value",
					action: waas.models.CachingRule.Action.BypassCache,
					cachingDuration: "EXAMPLE-cachingDuration-Value",
					isClientCachingEnabled: false,
					clientCachingDuration: "EXAMPLE-clientCachingDuration-Value",
					criteria: [{
							condition: waas.models.CachingRuleCriteria.Condition.UrlPartEndsWith,
							value: "EXAMPLE-value-Value",

							}
							],

					}
					],
			customProtectionRules: [{
					id: "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
					action: waas.models.CustomProtectionRuleSetting.Action.Detect,
					exclusions: [{
							target: waas.models.ProtectionRuleExclusion.Target.RequestCookieNames,
							exclusions: ["EXAMPLE--Value"									],

							}
							],

					}
					],
			originGroups: ["EXAMPLE--Value"					],
			protectionSettings: {
				blockAction: waas.models.ProtectionSettings.BlockAction.SetResponseCode,
				blockResponseCode: 620,
				blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
				blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
				blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
				maxArgumentCount: 438,
				maxNameLengthPerArgument: 37816,
				maxTotalNameLengthOfArguments: 57959,
				recommendationsPeriodInDays: 86,
				isResponseInspected: true,
				maxResponseSizeInKiB: 1792,
				allowedHttpMethods: [waas.models.ProtectionSettings.AllowedHttpMethods.Put						],
				mediaTypes: ["EXAMPLE--Value"						],

				}
,
			whitelists: [{
					name: "EXAMPLE-name-Value",
					addresses: ["EXAMPLE--Value"							],
					addressLists: ["EXAMPLE--Value"							],

					}
					],

			}
,
		freeformTags: {
			EXAMPLE_KEY_d6Bmv :"EXAMPLE_VALUE_5U4uYcgqxnqjHZf4PPuf"
			},
		definedTags: {
			EXAMPLE_KEY_JF0W3 :{
				EXAMPLE_KEY_4t7fb :"EXAMPLE--Value"
				}
			},

		}

	const createWaasPolicyRequest: waas.requests.CreateWaasPolicyRequest = { 
	createWaasPolicyDetails: createWaasPolicyDetails,
	opcRequestId: "4W6C8MUKGCELCY4FILJC<unique_ID>",
	opcRetryToken: "EXAMPLE-opcRetryToken-Value",

		}; 


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