// 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_oYjvM :{
				uri: "EXAMPLE-uri-Value",
				httpPort: 30085,
				httpsPort: 10628,
				customHeaders: [{
						name: "EXAMPLE-name-Value",
						value: "EXAMPLE-value-Value",

						}
						],

				}

			},
		originGroups: {
			EXAMPLE_KEY_LSceh :{
				origins: [{
						origin: "EXAMPLE-origin-Value",
						weight: 8154,

						}
						],

				}

			},
		policyConfig: {
			certificateId: "ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value",
			isHttpsEnabled: false,
			isHttpsForced: false,
			tlsProtocols: [waas.models.PolicyConfig.TlsProtocols.TlsV13					],
			isOriginCompressionEnabled: true,
			isBehindCdn: false,
			clientAddressHeader: waas.models.PolicyConfig.ClientAddressHeader.XRealIp,
			isCacheControlRespected: true,
			isResponseBufferingEnabled: true,
			cipherGroup: waas.models.PolicyConfig.CipherGroup.Default,
			loadBalancingMethod: {
				method: "ROUND_ROBIN",
				}
,
			websocketPathPrefixes: ["EXAMPLE--Value"					],
			isSniEnabled: false,
			healthChecks: {
				isEnabled: false,
				method: waas.models.HealthCheck.Method.Get,
				path: "EXAMPLE-path-Value",
				headers: {
					EXAMPLE_KEY_73Bon :"EXAMPLE_VALUE_3UOkr59ivsvb3krWzVdo"
					},
				expectedResponseCodeGroup: [waas.models.HealthCheck.ExpectedResponseCodeGroup._2Xx						],
				isResponseTextCheckEnabled: true,
				expectedResponseText: "EXAMPLE-expectedResponseText-Value",
				intervalInSeconds: 28,
				timeoutInSeconds: 3,
				healthyThreshold: 17,
				unhealthyThreshold: 7,

				}
,

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

							}
							],
					action: waas.models.AccessRule.Action.Detect,
					blockAction: waas.models.AccessRule.BlockAction.SetResponseCode,
					blockResponseCode: 612,
					blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
					blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
					blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
					bypassChallenges: [waas.models.AccessRule.BypassChallenges.HumanInteractionChallenge							],
					redirectUrl: "EXAMPLE-redirectUrl-Value",
					redirectResponseCode: waas.models.AccessRule.RedirectResponseCode.Found,
					captchaTitle: "EXAMPLE-captchaTitle-Value",
					captchaHeader: "EXAMPLE-captchaHeader-Value",
					captchaFooter: "EXAMPLE-captchaFooter-Value",
					captchaSubmitLabel: "EXAMPLE-captchaSubmitLabel-Value",
					responseHeaderManipulation: [{
							action: "ADD_HTTP_RESPONSE_HEADER",							header: "EXAMPLE-header-Value",
							value: "EXAMPLE-value-Value"

							}
							],

					}
					],
			addressRateLimiting: {
				isEnabled: false,
				allowedRatePerAddress: 7015,
				maxDelayedCountPerAddress: 2840,
				blockResponseCode: 205,

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

					}
					],
			deviceFingerprintChallenge: {
				isEnabled: true,
				action: waas.models.DeviceFingerprintChallenge.Action.Block,
				failureThreshold: 28161,
				actionExpirationInSeconds: 62415,
				failureThresholdExpirationInSeconds: 239964,
				maxAddressCount: 6350,
				maxAddressCountExpirationInSeconds: 61491,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowCaptcha,
					blockResponseCode: 878,
					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: true,
				action: waas.models.HumanInteractionChallenge.Action.Detect,
				failureThreshold: 790768,
				actionExpirationInSeconds: 24291,
				failureThresholdExpirationInSeconds: 236941,
				interactionThreshold: 58,
				recordingPeriodInSeconds: 8953,
				setHttpHeader: {
					name: "EXAMPLE-name-Value",
					value: "EXAMPLE-value-Value",

					}
,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowCaptcha,
					blockResponseCode: 189,
					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.Detect,
				failureThreshold: 966080,
				actionExpirationInSeconds: 368790,
				setHttpHeader: {
					name: "EXAMPLE-name-Value",
					value: "EXAMPLE-value-Value",

					}
,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowErrorPage,
					blockResponseCode: 957,
					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.UrlPartDoesNotContain,
						value: "EXAMPLE-value-Value",
						isCaseSensitive: false,

						}
						],
				isNatEnabled: true,

				}
,
			origin: "EXAMPLE-origin-Value",
			cachingRules: [{
					key: "EXAMPLE-key-Value",
					name: "EXAMPLE-name-Value",
					action: waas.models.CachingRule.Action.Cache,
					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.ArgsNames,
							exclusions: ["EXAMPLE--Value"									],

							}
							],

					}
					],
			originGroups: ["EXAMPLE--Value"					],
			protectionSettings: {
				blockAction: waas.models.ProtectionSettings.BlockAction.ShowErrorPage,
				blockResponseCode: 860,
				blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
				blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
				blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
				maxArgumentCount: 9199,
				maxNameLengthPerArgument: 66172,
				maxTotalNameLengthOfArguments: 106114,
				recommendationsPeriodInDays: 74,
				isResponseInspected: true,
				maxResponseSizeInKiB: 1904,
				allowedHttpMethods: [waas.models.ProtectionSettings.AllowedHttpMethods.Post						],
				mediaTypes: ["EXAMPLE--Value"						],

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

					}
					],

			}
,
		freeformTags: {
			EXAMPLE_KEY_PYpzV :"EXAMPLE_VALUE_cJtzII3zcdiKfNeJsfa2"
			},
		definedTags: {
			EXAMPLE_KEY_ETyiT :{
				EXAMPLE_KEY_RYfCo :"EXAMPLE--Value"
				}
			},

		}

	const createWaasPolicyRequest: waas.requests.CreateWaasPolicyRequest = { 
	createWaasPolicyDetails: createWaasPolicyDetails,
	opcRequestId: "V2IRMYI0SEPX11V9HO7B<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);
     }
})();