// 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_QbrtM :({
				uri: "EXAMPLE-uri-Value",
				httpPort: 1620,
				httpsPort: 7999,
				customHeaders: [({
						name: "EXAMPLE-name-Value",
						value: "EXAMPLE-value-Value",

						} as unknown as waas.models.Header)
						],

				} as unknown as waas.models.Origin)

			},
		originGroups: {
			EXAMPLE_KEY_pBuOC :({
				origins: [({
						origin: "EXAMPLE-origin-Value",
						weight: 8,

						} as unknown as waas.models.OriginGroupOrigins)
						],

				} as unknown as waas.models.OriginGroup)

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

				} as unknown as waas.models.RoundRobinLoadBalancingMethod)
,
			websocketPathPrefixes: ["EXAMPLE--Value"					],
			isSniEnabled: false,
			healthChecks: ({
				isEnabled: false,
				method: waas.models.HealthCheck.Method.Get,
				path: "EXAMPLE-path-Value",
				headers: {
					EXAMPLE_KEY_UCcbB :"EXAMPLE_VALUE_P2ymGzBxLN0rrXMFpK5L"
					},
				expectedResponseCodeGroup: [waas.models.HealthCheck.ExpectedResponseCodeGroup._2Xx						],
				isResponseTextCheckEnabled: false,
				expectedResponseText: "EXAMPLE-expectedResponseText-Value",
				intervalInSeconds: 82,
				timeoutInSeconds: 35,
				healthyThreshold: 13,
				unhealthyThreshold: 17,

				} as unknown as waas.models.HealthCheck)
,

			} as unknown as waas.models.PolicyConfig)
,
		wafConfig: ({
			accessRules: [({
					name: "EXAMPLE-name-Value",
					criteria: [({
							condition: waas.models.AccessRuleCriteria.Condition.HttpMethodIsNot,
							value: "EXAMPLE-value-Value",
							isCaseSensitive: false,

							} as unknown as waas.models.AccessRuleCriteria)
							],
					action: waas.models.AccessRule.Action.Allow,
					blockAction: waas.models.AccessRule.BlockAction.SetResponseCode,
					blockResponseCode: 541,
					blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
					blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
					blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
					bypassChallenges: [waas.models.AccessRule.BypassChallenges.JsChallenge							],
					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: "EXTEND_HTTP_RESPONSE_HEADER",
							header: "EXAMPLE-header-Value",
							value: "EXAMPLE-value-Value"

							} as unknown as waas.models.ExtendHttpResponseHeaderAction)
							],

					} as unknown as waas.models.AccessRule)
					],
			addressRateLimiting: ({
				isEnabled: false,
				allowedRatePerAddress: 5104,
				maxDelayedCountPerAddress: 696,
				blockResponseCode: 553,

				} as unknown as waas.models.AddressRateLimiting)
,
			captchas: [({
					url: "EXAMPLE-url-Value",
					sessionExpirationInSeconds: 27111,
					title: "EXAMPLE-title-Value",
					headerText: "EXAMPLE-headerText-Value",
					footerText: "EXAMPLE-footerText-Value",
					failureMessage: "EXAMPLE-failureMessage-Value",
					submitLabel: "EXAMPLE-submitLabel-Value",

					} as unknown as waas.models.Captcha)
					],
			deviceFingerprintChallenge: ({
				isEnabled: false,
				action: waas.models.DeviceFingerprintChallenge.Action.Block,
				failureThreshold: 778022,
				actionExpirationInSeconds: 58428,
				failureThresholdExpirationInSeconds: 30334,
				maxAddressCount: 1966,
				maxAddressCountExpirationInSeconds: 39032,
				challengeSettings: ({
					blockAction: waas.models.BlockChallengeSettings.BlockAction.SetResponseCode,
					blockResponseCode: 342,
					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",

					} as unknown as waas.models.BlockChallengeSettings)
,

				} as unknown as waas.models.DeviceFingerprintChallenge)
,
			humanInteractionChallenge: ({
				isEnabled: true,
				action: waas.models.HumanInteractionChallenge.Action.Block,
				failureThreshold: 768541,
				actionExpirationInSeconds: 152944,
				failureThresholdExpirationInSeconds: 49346,
				interactionThreshold: 70,
				recordingPeriodInSeconds: 7507,
				setHttpHeader: ({
					name: "EXAMPLE-name-Value",
					value: "EXAMPLE-value-Value",

					} as unknown as waas.models.Header)
,
				challengeSettings: ({
					blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowErrorPage,
					blockResponseCode: 515,
					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",

					} as unknown as waas.models.BlockChallengeSettings)
,
				isNatEnabled: true,

				} as unknown as waas.models.HumanInteractionChallenge)
,
			jsChallenge: ({
				isEnabled: true,
				action: waas.models.JsChallenge.Action.Block,
				failureThreshold: 310035,
				actionExpirationInSeconds: 218853,
				setHttpHeader: ({
					name: "EXAMPLE-name-Value",
					value: "EXAMPLE-value-Value",

					} as unknown as waas.models.Header)
,
				challengeSettings: ({
					blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowCaptcha,
					blockResponseCode: 954,
					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",

					} as unknown as waas.models.BlockChallengeSettings)
,
				areRedirectsChallenged: false,
				criteria: [({
						condition: waas.models.AccessRuleCriteria.Condition.IpIsNot,
						value: "EXAMPLE-value-Value",
						isCaseSensitive: true,

						} as unknown as waas.models.AccessRuleCriteria)
						],
				isNatEnabled: false,

				} as unknown as waas.models.JsChallenge)
,
			origin: "EXAMPLE-origin-Value",
			cachingRules: [({
					key: "EXAMPLE-key-Value",
					name: "EXAMPLE-name-Value",
					action: waas.models.CachingRule.Action.BypassCache,
					cachingDuration: "EXAMPLE-cachingDuration-Value",
					isClientCachingEnabled: true,
					clientCachingDuration: "EXAMPLE-clientCachingDuration-Value",
					criteria: [({
							condition: waas.models.CachingRuleCriteria.Condition.UrlStartsWith,
							value: "EXAMPLE-value-Value",

							} as unknown as waas.models.CachingRuleCriteria)
							],

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

							} as unknown as waas.models.ProtectionRuleExclusion)
							],

					} as unknown as waas.models.CustomProtectionRuleSetting)
					],
			originGroups: ["EXAMPLE--Value"					],
			protectionSettings: ({
				blockAction: waas.models.ProtectionSettings.BlockAction.SetResponseCode,
				blockResponseCode: 881,
				blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
				blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
				blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
				maxArgumentCount: 4115,
				maxNameLengthPerArgument: 92380,
				maxTotalNameLengthOfArguments: 326628,
				recommendationsPeriodInDays: 50,
				isResponseInspected: false,
				maxResponseSizeInKiB: 1071,
				allowedHttpMethods: [waas.models.ProtectionSettings.AllowedHttpMethods.Head						],
				mediaTypes: ["EXAMPLE--Value"						],

				} as unknown as waas.models.ProtectionSettings)
,
			whitelists: [({
					name: "EXAMPLE-name-Value",
					addresses: ["EXAMPLE--Value"							],
					addressLists: ["EXAMPLE--Value"							],

					} as unknown as waas.models.Whitelist)
					],

			} as unknown as waas.models.WafConfigDetails)
,
		freeformTags: {
			EXAMPLE_KEY_Jzb4w :"EXAMPLE_VALUE_Ml22ywHiRW75SQK8lIZE"
			},
		definedTags: {
			EXAMPLE_KEY_krlFg :{
				EXAMPLE_KEY_GaNnO :"EXAMPLE--Value"
				}
			},

		} as unknown as waas.models.CreateWaasPolicyDetails)

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