// 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_HRcT2 :{
				uri: "EXAMPLE-uri-Value",
				httpPort: 27245,
				httpsPort: 49142,
				customHeaders: [{
						name: "EXAMPLE-name-Value",
						value: "EXAMPLE-value-Value",

						}
						],

				}

			},
		originGroups: {
			EXAMPLE_KEY_Ud3S0 :{
				origins: [{
						origin: "EXAMPLE-origin-Value",
						weight: 8061,

						}
						],

				}

			},
		policyConfig: {
			certificateId: "ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value",
			isHttpsEnabled: true,
			isHttpsForced: false,
			tlsProtocols: [waas.models.PolicyConfig.TlsProtocols.TlsV1					],
			isOriginCompressionEnabled: true,
			isBehindCdn: true,
			clientAddressHeader: waas.models.PolicyConfig.ClientAddressHeader.TrueClientIp,
			isCacheControlRespected: true,
			isResponseBufferingEnabled: false,
			cipherGroup: waas.models.PolicyConfig.CipherGroup.Default,
			loadBalancingMethod: {
				method: "ROUND_ROBIN",
				}
,
			websocketPathPrefixes: ["EXAMPLE--Value"					],
			isSniEnabled: false,
			healthChecks: {
				isEnabled: false,
				method: waas.models.HealthCheck.Method.Head,
				path: "EXAMPLE-path-Value",
				headers: {
					EXAMPLE_KEY_uGfmY :"EXAMPLE_VALUE_Nn7GzubsWxq904QkeynN"
					},
				expectedResponseCodeGroup: [waas.models.HealthCheck.ExpectedResponseCodeGroup._5Xx						],
				isResponseTextCheckEnabled: true,
				expectedResponseText: "EXAMPLE-expectedResponseText-Value",
				intervalInSeconds: 19,
				timeoutInSeconds: 24,
				healthyThreshold: 18,
				unhealthyThreshold: 4,

				}
,

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

							}
							],
					action: waas.models.AccessRule.Action.Bypass,
					blockAction: waas.models.AccessRule.BlockAction.ShowErrorPage,
					blockResponseCode: 596,
					blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
					blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
					blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
					bypassChallenges: [waas.models.AccessRule.BypassChallenges.DeviceFingerprintChallenge							],
					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: 6785,
				maxDelayedCountPerAddress: 2117,
				blockResponseCode: 660,

				}
,
			captchas: [{
					url: "EXAMPLE-url-Value",
					sessionExpirationInSeconds: 397316,
					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: 95460,
				actionExpirationInSeconds: 322365,
				failureThresholdExpirationInSeconds: 140610,
				maxAddressCount: 1229,
				maxAddressCountExpirationInSeconds: 308418,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowCaptcha,
					blockResponseCode: 735,
					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: 271888,
				actionExpirationInSeconds: 203986,
				failureThresholdExpirationInSeconds: 262842,
				interactionThreshold: 59,
				recordingPeriodInSeconds: 11625,
				setHttpHeader: {
					name: "EXAMPLE-name-Value",
					value: "EXAMPLE-value-Value",

					}
,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowCaptcha,
					blockResponseCode: 262,
					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: 135808,
				actionExpirationInSeconds: 367367,
				setHttpHeader: {
					name: "EXAMPLE-name-Value",
					value: "EXAMPLE-value-Value",

					}
,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.SetResponseCode,
					blockResponseCode: 659,
					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: true,
				criteria: [{
						condition: waas.models.AccessRuleCriteria.Condition.CountryIs,
						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.UrlStartsWith,
							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.Args,
							exclusions: ["EXAMPLE--Value"									],

							}
							],

					}
					],
			originGroups: ["EXAMPLE--Value"					],
			protectionSettings: {
				blockAction: waas.models.ProtectionSettings.BlockAction.SetResponseCode,
				blockResponseCode: 284,
				blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
				blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
				blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
				maxArgumentCount: 4731,
				maxNameLengthPerArgument: 29811,
				maxTotalNameLengthOfArguments: 163188,
				recommendationsPeriodInDays: 78,
				isResponseInspected: false,
				maxResponseSizeInKiB: 1839,
				allowedHttpMethods: [waas.models.ProtectionSettings.AllowedHttpMethods.Post						],
				mediaTypes: ["EXAMPLE--Value"						],

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

					}
					],

			}
,
		freeformTags: {
			EXAMPLE_KEY_qbFhD :"EXAMPLE_VALUE_DXDbRTXcGJeLniGb5Wej"
			},
		definedTags: {
			EXAMPLE_KEY_TYOwi :{
				EXAMPLE_KEY_YHS0u :"EXAMPLE--Value"
				}
			},

		}

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