# 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
create_waas_policy_response = waas_client.create_waas_policy(
    create_waas_policy_details=oci.waas.models.CreateWaasPolicyDetails(
        compartment_id="ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
        domain="EXAMPLE-domain-Value",
        display_name="EXAMPLE-displayName-Value",
        additional_domains=["EXAMPLE--Value"],
        origins={
            'EXAMPLE_KEY_5sgBQ': {
                'uri': 'EXAMPLE-uri-Value',
                'httpPort': 34368,
                'httpsPort': 40721,
                'customHeaders': [
                    {
                        'name': 'EXAMPLE-name-Value',
                        'value': 'EXAMPLE-value-Value'}]}},
        origin_groups={
            'EXAMPLE_KEY_3EVjU': {
                'origins': [
                    {
                        'origin': 'EXAMPLE-origin-Value',
                        'weight': 56}]}},
        policy_config=oci.waas.models.PolicyConfig(
            certificate_id="ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value",
            is_https_enabled=True,
            is_https_forced=False,
            tls_protocols=["TLS_V1_1"],
            is_origin_compression_enabled=False,
            is_behind_cdn=False,
            client_address_header="X_FORWARDED_FOR",
            is_cache_control_respected=True,
            is_response_buffering_enabled=True,
            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_g0YOj': 'EXAMPLE_VALUE_VWQcfoc1MdppbZGEMQbr'},
                expected_response_code_group=["5XX"],
                is_response_text_check_enabled=False,
                expected_response_text="EXAMPLE-expectedResponseText-Value",
                interval_in_seconds=110,
                timeout_in_seconds=25,
                healthy_threshold=8,
                unhealthy_threshold=13)),
        waf_config=oci.waas.models.WafConfigDetails(
            access_rules=[
                oci.waas.models.AccessRule(
                    name="EXAMPLE-name-Value",
                    criteria=[
                        oci.waas.models.AccessRuleCriteria(
                            condition="HTTP_HEADER_CONTAINS",
                            value="EXAMPLE-value-Value",
                            is_case_sensitive=False)],
                    action="DETECT",
                    block_action="SET_RESPONSE_CODE",
                    block_response_code=629,
                    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="MOVED_PERMANENTLY",
                    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.ExtendHttpResponseHeaderAction(
                            action="EXTEND_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=7416,
                max_delayed_count_per_address=6567,
                block_response_code=498),
            captchas=[
                oci.waas.models.Captcha(
                    url="EXAMPLE-url-Value",
                    session_expiration_in_seconds=139779,
                    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=795727,
                action_expiration_in_seconds=396270,
                failure_threshold_expiration_in_seconds=67956,
                max_address_count=262,
                max_address_count_expiration_in_seconds=382367,
                challenge_settings=oci.waas.models.BlockChallengeSettings(
                    block_action="SHOW_ERROR_PAGE",
                    block_response_code=319,
                    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")),
            human_interaction_challenge=oci.waas.models.HumanInteractionChallenge(
                is_enabled=False,
                action="DETECT",
                failure_threshold=903395,
                action_expiration_in_seconds=322927,
                failure_threshold_expiration_in_seconds=30354,
                interaction_threshold=57,
                recording_period_in_seconds=10079,
                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=247,
                    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=True),
            js_challenge=oci.waas.models.JsChallenge(
                is_enabled=True,
                action="BLOCK",
                failure_threshold=323628,
                action_expiration_in_seconds=383215,
                set_http_header=oci.waas.models.Header(
                    name="EXAMPLE-name-Value",
                    value="EXAMPLE-value-Value"),
                challenge_settings=oci.waas.models.BlockChallengeSettings(
                    block_action="SHOW_ERROR_PAGE",
                    block_response_code=580,
                    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=True,
                criteria=[
                    oci.waas.models.AccessRuleCriteria(
                        condition="USER_AGENT_IS_NOT",
                        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="BYPASS_CACHE",
                    criteria=[
                        oci.waas.models.CachingRuleCriteria(
                            condition="URL_IS",
                            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="BLOCK",
                    exclusions=[
                        oci.waas.models.ProtectionRuleExclusion(
                            target="REQUEST_COOKIE_NAMES",
                            exclusions=["EXAMPLE--Value"])])],
            origin_groups=["EXAMPLE--Value"],
            protection_settings=oci.waas.models.ProtectionSettings(
                block_action="SHOW_ERROR_PAGE",
                block_response_code=734,
                block_error_page_message="EXAMPLE-blockErrorPageMessage-Value",
                block_error_page_code="EXAMPLE-blockErrorPageCode-Value",
                block_error_page_description="EXAMPLE-blockErrorPageDescription-Value",
                max_argument_count=692,
                max_name_length_per_argument=119708,
                max_total_name_length_of_arguments=122108,
                recommendations_period_in_days=59,
                is_response_inspected=False,
                max_response_size_in_ki_b=1669,
                allowed_http_methods=["DELETE"],
                media_types=["EXAMPLE--Value"]),
            whitelists=[
                oci.waas.models.Whitelist(
                    name="EXAMPLE-name-Value",
                    addresses=["EXAMPLE--Value"],
                    address_lists=["EXAMPLE--Value"])]),
        freeform_tags={
            'EXAMPLE_KEY_YMS5C': 'EXAMPLE_VALUE_TZa1Nk4XsdY8WLlkm0zO'},
        defined_tags={
            'EXAMPLE_KEY_rG6c6': {
                'EXAMPLE_KEY_TAIb7': 'EXAMPLE--Value'}}),
    opc_request_id="TGEZKZ8QOGGN3AISP9OJ<unique_ID>",
    opc_retry_token="EXAMPLE-opcRetryToken-Value")

# Get the data from response
print(create_waas_policy_response.headers)