# 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 oci

# Create a default config using DEFAULT profile in default location
# Refer to
# https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File
# for more info
config = oci.config.from_file()


# Initialize service client with default config file
waas_client = oci.waas.WaasClient(config)


# Send the request to service, some parameters are not required, see API
# doc for more info
update_waas_policy_response = waas_client.update_waas_policy(
    waas_policy_id="ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value",
    update_waas_policy_details=oci.waas.models.UpdateWaasPolicyDetails(
        display_name="EXAMPLE-displayName-Value",
        additional_domains=["EXAMPLE--Value"],
        origins={
            'EXAMPLE_KEY_3OsSg': {
                'uri': 'EXAMPLE-uri-Value',
                'httpPort': 460,
                'httpsPort': 395,
                'customHeaders': [
                    {
                        'name': 'EXAMPLE-name-Value',
                        'value': 'EXAMPLE-value-Value'}]}},
        origin_groups={
            'EXAMPLE_KEY_LwhwX': {
                'origins': [
                    {
                        'origin': 'EXAMPLE-origin-Value',
                        'weight': 420}]}},
        policy_config=oci.waas.models.PolicyConfig(
            certificate_id="ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value",
            is_https_enabled=False,
            is_https_forced=False,
            tls_protocols=["TLS_V1_1"],
            is_origin_compression_enabled=True,
            is_behind_cdn=True,
            client_address_header="X_CLIENT_IP",
            is_cache_control_respected=True,
            is_response_buffering_enabled=False,
            cipher_group="DEFAULT",
            load_balancing_method=oci.waas.models.RoundRobinLoadBalancingMethod(
                method="ROUND_ROBIN"),
            websocket_path_prefixes=["EXAMPLE--Value"],
            is_sni_enabled=False,
            health_checks=oci.waas.models.HealthCheck(
                is_enabled=True,
                method="HEAD",
                path="EXAMPLE-path-Value",
                headers={
                    'EXAMPLE_KEY_I5kbA': 'EXAMPLE_VALUE_bQOCF8pjWudvbpABZQMB'},
                expected_response_code_group=["4XX"],
                is_response_text_check_enabled=False,
                expected_response_text="EXAMPLE-expectedResponseText-Value",
                interval_in_seconds=164,
                timeout_in_seconds=466,
                healthy_threshold=652,
                unhealthy_threshold=688)),
        waf_config=oci.waas.models.WafConfig(
            access_rules=[
                oci.waas.models.AccessRule(
                    name="EXAMPLE-name-Value",
                    criteria=[
                        oci.waas.models.AccessRuleCriteria(
                            condition="COUNTRY_IS_NOT",
                            value="EXAMPLE-value-Value",
                            is_case_sensitive=True)],
                    action="REDIRECT",
                    block_action="SHOW_ERROR_PAGE",
                    block_response_code=159,
                    block_error_page_message="EXAMPLE-blockErrorPageMessage-Value",
                    block_error_page_code="EXAMPLE-blockErrorPageCode-Value",
                    block_error_page_description="EXAMPLE-blockErrorPageDescription-Value",
                    bypass_challenges=["JS_CHALLENGE"],
                    redirect_url="EXAMPLE-redirectUrl-Value",
                    redirect_response_code="FOUND",
                    captcha_title="EXAMPLE-captchaTitle-Value",
                    captcha_header="EXAMPLE-captchaHeader-Value",
                    captcha_footer="EXAMPLE-captchaFooter-Value",
                    captcha_submit_label="EXAMPLE-captchaSubmitLabel-Value",
                    response_header_manipulation=[
                        oci.waas.models.AddHttpResponseHeaderAction(
                            action="ADD_HTTP_RESPONSE_HEADER",
                            header="EXAMPLE-header-Value",
                            value="EXAMPLE-value-Value")])],
            address_rate_limiting=oci.waas.models.AddressRateLimiting(
                is_enabled=False,
                allowed_rate_per_address=511,
                max_delayed_count_per_address=956,
                block_response_code=918),
            captchas=[
                oci.waas.models.Captcha(
                    url="EXAMPLE-url-Value",
                    session_expiration_in_seconds=31,
                    title="EXAMPLE-title-Value",
                    failure_message="EXAMPLE-failureMessage-Value",
                    submit_label="EXAMPLE-submitLabel-Value",
                    header_text="EXAMPLE-headerText-Value",
                    footer_text="EXAMPLE-footerText-Value")],
            device_fingerprint_challenge=oci.waas.models.DeviceFingerprintChallenge(
                is_enabled=True,
                action="DETECT",
                failure_threshold=313,
                action_expiration_in_seconds=724,
                failure_threshold_expiration_in_seconds=388,
                max_address_count=248,
                max_address_count_expiration_in_seconds=967,
                challenge_settings=oci.waas.models.BlockChallengeSettings(
                    block_action="SHOW_ERROR_PAGE",
                    block_response_code=645,
                    block_error_page_message="EXAMPLE-blockErrorPageMessage-Value",
                    block_error_page_description="EXAMPLE-blockErrorPageDescription-Value",
                    block_error_page_code="EXAMPLE-blockErrorPageCode-Value",
                    captcha_title="EXAMPLE-captchaTitle-Value",
                    captcha_header="EXAMPLE-captchaHeader-Value",
                    captcha_footer="EXAMPLE-captchaFooter-Value",
                    captcha_submit_label="EXAMPLE-captchaSubmitLabel-Value")),
            good_bots=[
                oci.waas.models.GoodBot(
                    key="EXAMPLE-key-Value",
                    is_enabled=False,
                    name="EXAMPLE-name-Value",
                    description="EXAMPLE-description-Value")],
            human_interaction_challenge=oci.waas.models.HumanInteractionChallenge(
                is_enabled=False,
                action="DETECT",
                failure_threshold=335,
                action_expiration_in_seconds=662,
                failure_threshold_expiration_in_seconds=862,
                interaction_threshold=360,
                recording_period_in_seconds=461,
                set_http_header=oci.waas.models.Header(
                    name="EXAMPLE-name-Value",
                    value="EXAMPLE-value-Value"),
                challenge_settings=oci.waas.models.BlockChallengeSettings(
                    block_action="SET_RESPONSE_CODE",
                    block_response_code=249,
                    block_error_page_message="EXAMPLE-blockErrorPageMessage-Value",
                    block_error_page_description="EXAMPLE-blockErrorPageDescription-Value",
                    block_error_page_code="EXAMPLE-blockErrorPageCode-Value",
                    captcha_title="EXAMPLE-captchaTitle-Value",
                    captcha_header="EXAMPLE-captchaHeader-Value",
                    captcha_footer="EXAMPLE-captchaFooter-Value",
                    captcha_submit_label="EXAMPLE-captchaSubmitLabel-Value"),
                is_nat_enabled=False),
            js_challenge=oci.waas.models.JsChallenge(
                is_enabled=True,
                action="BLOCK",
                failure_threshold=881,
                action_expiration_in_seconds=170,
                set_http_header=oci.waas.models.Header(
                    name="EXAMPLE-name-Value",
                    value="EXAMPLE-value-Value"),
                challenge_settings=oci.waas.models.BlockChallengeSettings(
                    block_action="SHOW_CAPTCHA",
                    block_response_code=476,
                    block_error_page_message="EXAMPLE-blockErrorPageMessage-Value",
                    block_error_page_description="EXAMPLE-blockErrorPageDescription-Value",
                    block_error_page_code="EXAMPLE-blockErrorPageCode-Value",
                    captcha_title="EXAMPLE-captchaTitle-Value",
                    captcha_header="EXAMPLE-captchaHeader-Value",
                    captcha_footer="EXAMPLE-captchaFooter-Value",
                    captcha_submit_label="EXAMPLE-captchaSubmitLabel-Value"),
                are_redirects_challenged=False,
                criteria=[
                    oci.waas.models.AccessRuleCriteria(
                        condition="URL_PART_ENDS_WITH",
                        value="EXAMPLE-value-Value",
                        is_case_sensitive=False)],
                is_nat_enabled=True),
            origin="EXAMPLE-origin-Value",
            caching_rules=[
                oci.waas.models.CachingRule(
                    name="EXAMPLE-name-Value",
                    action="CACHE",
                    criteria=[
                        oci.waas.models.CachingRuleCriteria(
                            condition="URL_PART_CONTAINS",
                            value="EXAMPLE-value-Value")],
                    key="EXAMPLE-key-Value",
                    caching_duration="EXAMPLE-cachingDuration-Value",
                    is_client_caching_enabled=False,
                    client_caching_duration="EXAMPLE-clientCachingDuration-Value")],
            custom_protection_rules=[
                oci.waas.models.CustomProtectionRuleSetting(
                    id="ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
                    action="DETECT",
                    exclusions=[
                        oci.waas.models.ProtectionRuleExclusion(
                            target="ARGS_NAMES",
                            exclusions=["EXAMPLE--Value"])])],
            origin_groups=["EXAMPLE--Value"],
            protection_rules=[
                oci.waas.models.ProtectionRule(
                    key="EXAMPLE-key-Value",
                    mod_security_rule_ids=["EXAMPLE--Value"],
                    name="EXAMPLE-name-Value",
                    description="EXAMPLE-description-Value",
                    action="OFF",
                    labels=["EXAMPLE--Value"],
                    exclusions=[
                        oci.waas.models.ProtectionRuleExclusion(
                            target="REQUEST_COOKIE_NAMES",
                            exclusions=["EXAMPLE--Value"])])],
            protection_settings=oci.waas.models.ProtectionSettings(
                block_action="SHOW_ERROR_PAGE",
                block_response_code=346,
                block_error_page_message="EXAMPLE-blockErrorPageMessage-Value",
                block_error_page_code="EXAMPLE-blockErrorPageCode-Value",
                block_error_page_description="EXAMPLE-blockErrorPageDescription-Value",
                max_argument_count=361,
                max_name_length_per_argument=209,
                max_total_name_length_of_arguments=951,
                recommendations_period_in_days=187,
                is_response_inspected=True,
                max_response_size_in_ki_b=641,
                allowed_http_methods=["TRACE"],
                media_types=["EXAMPLE--Value"]),
            threat_feeds=[
                oci.waas.models.ThreatFeed(
                    key="EXAMPLE-key-Value",
                    name="EXAMPLE-name-Value",
                    action="DETECT",
                    description="EXAMPLE-description-Value")],
            whitelists=[
                oci.waas.models.Whitelist(
                    name="EXAMPLE-name-Value",
                    addresses=["EXAMPLE--Value"],
                    address_lists=["EXAMPLE--Value"])]),
        freeform_tags={
            'EXAMPLE_KEY_LM5i1': 'EXAMPLE_VALUE_Zml9sneWEfHO11izwtZu'},
        defined_tags={
            'EXAMPLE_KEY_87k8o': {
                'EXAMPLE_KEY_Fw6DG': 'EXAMPLE--Value'}}),
    opc_request_id="W5PHR0DFOXXORZAEK35V/OpcRequestIdExample/<unique_ID>",
    opc_retry_token="EXAMPLE-opcRetryToken-Value",
    if_match="EXAMPLE-ifMatch-Value")

# Get the data from response
print(update_waas_policy_response.data)