// 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_6TYXX :{
				uri: "EXAMPLE-uri-Value",
				httpPort: 39065,
				httpsPort: 59968,
				customHeaders: [{
						name: "EXAMPLE-name-Value",
						value: "EXAMPLE-value-Value",

						}
						],

				}

			},
		originGroups: {
			EXAMPLE_KEY_0bKlY :{
				origins: [{
						origin: "EXAMPLE-origin-Value",
						weight: 9177,

						}
						],

				}

			},
		policyConfig: {
			certificateId: "ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value",
			isHttpsEnabled: false,
			isHttpsForced: true,
			tlsProtocols: [waas.models.PolicyConfig.TlsProtocols.TlsV12					],
			isOriginCompressionEnabled: true,
			isBehindCdn: true,
			clientAddressHeader: waas.models.PolicyConfig.ClientAddressHeader.ClientIp,
			isCacheControlRespected: false,
			isResponseBufferingEnabled: false,
			cipherGroup: waas.models.PolicyConfig.CipherGroup.Default,
			loadBalancingMethod: {
				method: "ROUND_ROBIN",
				}
,
			websocketPathPrefixes: ["EXAMPLE--Value"					],
			isSniEnabled: false,
			healthChecks: {
				isEnabled: true,
				method: waas.models.HealthCheck.Method.Get,
				path: "EXAMPLE-path-Value",
				headers: {
					EXAMPLE_KEY_7eEkc :"EXAMPLE_VALUE_wWGkoNk7GvGhQ2BybDwT"
					},
				expectedResponseCodeGroup: [waas.models.HealthCheck.ExpectedResponseCodeGroup._2Xx						],
				isResponseTextCheckEnabled: false,
				expectedResponseText: "EXAMPLE-expectedResponseText-Value",
				intervalInSeconds: 83,
				timeoutInSeconds: 104,
				healthyThreshold: 19,
				unhealthyThreshold: 11,

				}
,

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

							}
							],
					action: waas.models.AccessRule.Action.ShowCaptcha,
					blockAction: waas.models.AccessRule.BlockAction.SetResponseCode,
					blockResponseCode: 954,
					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: "REMOVE_HTTP_RESPONSE_HEADER",							header: "EXAMPLE-header-Value"

							}
							],

					}
					],
			addressRateLimiting: {
				isEnabled: false,
				allowedRatePerAddress: 1626,
				maxDelayedCountPerAddress: 4348,
				blockResponseCode: 835,

				}
,
			captchas: [{
					url: "EXAMPLE-url-Value",
					sessionExpirationInSeconds: 172966,
					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.Detect,
				failureThreshold: 84403,
				actionExpirationInSeconds: 44403,
				failureThresholdExpirationInSeconds: 99753,
				maxAddressCount: 5196,
				maxAddressCountExpirationInSeconds: 355329,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.SetResponseCode,
					blockResponseCode: 614,
					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: 204208,
				actionExpirationInSeconds: 191175,
				failureThresholdExpirationInSeconds: 311255,
				interactionThreshold: 32,
				recordingPeriodInSeconds: 8772,
				setHttpHeader: {
					name: "EXAMPLE-name-Value",
					value: "EXAMPLE-value-Value",

					}
,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.SetResponseCode,
					blockResponseCode: 202,
					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: true,
				action: waas.models.JsChallenge.Action.Block,
				failureThreshold: 792993,
				actionExpirationInSeconds: 230947,
				setHttpHeader: {
					name: "EXAMPLE-name-Value",
					value: "EXAMPLE-value-Value",

					}
,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowErrorPage,
					blockResponseCode: 477,
					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.CountryIsNot,
						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.Cache,
					cachingDuration: "EXAMPLE-cachingDuration-Value",
					isClientCachingEnabled: true,
					clientCachingDuration: "EXAMPLE-clientCachingDuration-Value",
					criteria: [{
							condition: waas.models.CachingRuleCriteria.Condition.UrlPartContains,
							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: 783,
				blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
				blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
				blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
				maxArgumentCount: 3169,
				maxNameLengthPerArgument: 49966,
				maxTotalNameLengthOfArguments: 261620,
				recommendationsPeriodInDays: 30,
				isResponseInspected: true,
				maxResponseSizeInKiB: 277,
				allowedHttpMethods: [waas.models.ProtectionSettings.AllowedHttpMethods.Connect						],
				mediaTypes: ["EXAMPLE--Value"						],

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

					}
					],

			}
,
		freeformTags: {
			EXAMPLE_KEY_xVsnd :"EXAMPLE_VALUE_V1BrMnaro9NppYnpUTjg"
			},
		definedTags: {
			EXAMPLE_KEY_xGxoY :{
				EXAMPLE_KEY_kIHbc :"EXAMPLE--Value"
				}
			},

		}

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