// 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  updateWaasPolicyDetails = {
		displayName: "EXAMPLE-displayName-Value",
		additionalDomains: ["EXAMPLE--Value"				],
		origins: {
			EXAMPLE_KEY_1v9hO :{
				uri: "EXAMPLE-uri-Value",
				httpPort: 62022,
				httpsPort: 43370,
				customHeaders: [{
						name: "EXAMPLE-name-Value",
						value: "EXAMPLE-value-Value",

						}
						],

				}

			},
		originGroups: {
			EXAMPLE_KEY_B7Mmp :{
				origins: [{
						origin: "EXAMPLE-origin-Value",
						weight: 4400,

						}
						],

				}

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

				}
,
			websocketPathPrefixes: ["EXAMPLE--Value"					],
			isSniEnabled: false,
			healthChecks: {
				isEnabled: false,
				method: waas.models.HealthCheck.Method.Head,
				path: "EXAMPLE-path-Value",
				headers: {
					EXAMPLE_KEY_ZbTHx :"EXAMPLE_VALUE_buqltC0F071ouRegq6ar"
					},
				expectedResponseCodeGroup: [waas.models.HealthCheck.ExpectedResponseCodeGroup._2Xx						],
				isResponseTextCheckEnabled: true,
				expectedResponseText: "EXAMPLE-expectedResponseText-Value",
				intervalInSeconds: 46,
				timeoutInSeconds: 20,
				healthyThreshold: 2,
				unhealthyThreshold: 8,

				}
,

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

							}
							],
					action: waas.models.AccessRule.Action.Block,
					blockAction: waas.models.AccessRule.BlockAction.ShowErrorPage,
					blockResponseCode: 605,
					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.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: true,
				allowedRatePerAddress: 3820,
				maxDelayedCountPerAddress: 729,
				blockResponseCode: 270,

				}
,
			captchas: [{
					url: "EXAMPLE-url-Value",
					sessionExpirationInSeconds: 399211,
					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: 353434,
				actionExpirationInSeconds: 317613,
				failureThresholdExpirationInSeconds: 205874,
				maxAddressCount: 152,
				maxAddressCountExpirationInSeconds: 155116,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowErrorPage,
					blockResponseCode: 239,
					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",

					}
,

				}
,
			goodBots: [{
					key: "EXAMPLE-key-Value",
					name: "EXAMPLE-name-Value",
					isEnabled: false,
					description: "EXAMPLE-description-Value",

					}
					],
			humanInteractionChallenge: {
				isEnabled: true,
				action: waas.models.HumanInteractionChallenge.Action.Block,
				failureThreshold: 644611,
				actionExpirationInSeconds: 309524,
				failureThresholdExpirationInSeconds: 195337,
				interactionThreshold: 82,
				recordingPeriodInSeconds: 9028,
				setHttpHeader: {
					name: "EXAMPLE-name-Value",
					value: "EXAMPLE-value-Value",

					}
,
				challengeSettings: {
					blockAction: waas.models.BlockChallengeSettings.BlockAction.ShowCaptcha,
					blockResponseCode: 314,
					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: true,

				}
,
			jsChallenge: {
				isEnabled: true,
				action: waas.models.JsChallenge.Action.Block,
				failureThreshold: 964692,
				actionExpirationInSeconds: 98058,
				setHttpHeader: {
					name: "EXAMPLE-name-Value",
					value: "EXAMPLE-value-Value",

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

						}
						],
				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: 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"					],
			protectionRules: [{
					key: "EXAMPLE-key-Value",
					modSecurityRuleIds: ["EXAMPLE--Value"							],
					name: "EXAMPLE-name-Value",
					description: "EXAMPLE-description-Value",
					action: waas.models.ProtectionRule.Action.Off,
					labels: ["EXAMPLE--Value"							],
					exclusions: [{
							target: waas.models.ProtectionRuleExclusion.Target.Args,
							exclusions: ["EXAMPLE--Value"									],

							}
							],

					}
					],
			protectionSettings: {
				blockAction: waas.models.ProtectionSettings.BlockAction.SetResponseCode,
				blockResponseCode: 831,
				blockErrorPageMessage: "EXAMPLE-blockErrorPageMessage-Value",
				blockErrorPageCode: "EXAMPLE-blockErrorPageCode-Value",
				blockErrorPageDescription: "EXAMPLE-blockErrorPageDescription-Value",
				maxArgumentCount: 5576,
				maxNameLengthPerArgument: 61082,
				maxTotalNameLengthOfArguments: 322836,
				recommendationsPeriodInDays: 71,
				isResponseInspected: false,
				maxResponseSizeInKiB: 258,
				allowedHttpMethods: [waas.models.ProtectionSettings.AllowedHttpMethods.Trace						],
				mediaTypes: ["EXAMPLE--Value"						],

				}
,
			threatFeeds: [{
					key: "EXAMPLE-key-Value",
					name: "EXAMPLE-name-Value",
					action: waas.models.ThreatFeed.Action.Off,
					description: "EXAMPLE-description-Value",

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

					}
					],

			}
,
		freeformTags: {
			EXAMPLE_KEY_ynNoK :"EXAMPLE_VALUE_bTSPHjc5h3FTgH4buCcK"
			},
		definedTags: {
			EXAMPLE_KEY_fsQeU :{
				EXAMPLE_KEY_0wlPC :"EXAMPLE--Value"
				}
			},

		}

	const updateWaasPolicyRequest: waas.requests.UpdateWaasPolicyRequest = { 
	waasPolicyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value",
	updateWaasPolicyDetails: updateWaasPolicyDetails,
	opcRequestId: "3PSRIBSTRMIFUCBBPQGV<unique_ID>",
	opcRetryToken: "EXAMPLE-opcRetryToken-Value",
	ifMatch: "EXAMPLE-ifMatch-Value",

		}; 


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