# 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).

require '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::ConfigFileLoader.load_config

# Initialize service client with default config file
waas_client = OCI::Waas::WaasClient.new(config: 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(
    OCI::Waas::Models::CreateWaasPolicyDetails.new(
      compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
      domain: 'EXAMPLE-domain-Value',
      display_name: 'EXAMPLE-displayName-Value',
      additional_domains: %w[EXAMPLE--Value],
      origins: {
        'EXAMPLE_KEY_3glhF' => {
          'uri' => 'EXAMPLE-uri-Value',
          'httpPort' => 33_604,
          'httpsPort' => 1596,
          'customHeaders' => [
            { 'name' => 'EXAMPLE-name-Value', 'value' => 'EXAMPLE-value-Value' }
          ]
        }
      },
      origin_groups: {
        'EXAMPLE_KEY_NEmDa' => {
          'origins' => [
            { 'origin' => 'EXAMPLE-origin-Value', 'weight' => 4929 }
          ]
        }
      },
      policy_config:
        OCI::Waas::Models::PolicyConfig.new(
          certificate_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value',
          is_https_enabled: true,
          is_https_forced: true,
          tls_protocols: %w[TLS_V1_2],
          is_origin_compression_enabled: false,
          is_behind_cdn: true,
          client_address_header: 'X_CLIENT_IP',
          is_cache_control_respected: false,
          is_response_buffering_enabled: false,
          cipher_group: 'DEFAULT',
          load_balancing_method:
            OCI::Waas::Models::StickyCookieLoadBalancingMethod.new(
              method: 'STICKY_COOKIE',
              name: 'EXAMPLE-name-Value',
              domain: 'EXAMPLE-domain-Value',
              expiration_time_in_seconds: 1_159_134
            ),
          websocket_path_prefixes: %w[EXAMPLE--Value],
          is_sni_enabled: true,
          health_checks:
            OCI::Waas::Models::HealthCheck.new(
              is_enabled: true,
              method: 'HEAD',
              path: 'EXAMPLE-path-Value',
              headers: {
                'EXAMPLE_KEY_rbdC8' => 'EXAMPLE_VALUE_jLzCZFWL99ahw28QuzPD'
              },
              expected_response_code_group: %w[5XX],
              is_response_text_check_enabled: true,
              expected_response_text: 'EXAMPLE-expectedResponseText-Value',
              interval_in_seconds: 108,
              timeout_in_seconds: 40,
              healthy_threshold: 5,
              unhealthy_threshold: 17
            )
        ),
      waf_config:
        OCI::Waas::Models::WafConfigDetails.new(
          access_rules: [
            OCI::Waas::Models::AccessRule.new(
              name: 'EXAMPLE-name-Value',
              criteria: [
                OCI::Waas::Models::AccessRuleCriteria.new(
                  condition: 'HTTP_HEADER_CONTAINS',
                  value: 'EXAMPLE-value-Value',
                  is_case_sensitive: false
                )
              ],
              action: 'BLOCK',
              block_action: 'SET_RESPONSE_CODE',
              block_response_code: 433,
              block_error_page_message: 'EXAMPLE-blockErrorPageMessage-Value',
              block_error_page_code: 'EXAMPLE-blockErrorPageCode-Value',
              block_error_page_description:
                'EXAMPLE-blockErrorPageDescription-Value',
              bypass_challenges: %w[CAPTCHA],
              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.new(
                  action: 'EXTEND_HTTP_RESPONSE_HEADER',
                  header: 'EXAMPLE-header-Value',
                  value: 'EXAMPLE-value-Value'
                )
              ]
            )
          ],
          address_rate_limiting:
            OCI::Waas::Models::AddressRateLimiting.new(
              is_enabled: true,
              allowed_rate_per_address: 6754,
              max_delayed_count_per_address: 2637,
              block_response_code: 700
            ),
          captchas: [
            OCI::Waas::Models::Captcha.new(
              url: 'EXAMPLE-url-Value',
              session_expiration_in_seconds: 144_378,
              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.new(
              is_enabled: true,
              action: 'DETECT',
              failure_threshold: 42_949,
              action_expiration_in_seconds: 131_416,
              failure_threshold_expiration_in_seconds: 411_924,
              max_address_count: 3157,
              max_address_count_expiration_in_seconds: 267_002,
              challenge_settings:
                OCI::Waas::Models::BlockChallengeSettings.new(
                  block_action: 'SHOW_CAPTCHA',
                  block_response_code: 460,
                  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.new(
              is_enabled: false,
              action: 'DETECT',
              failure_threshold: 592_226,
              action_expiration_in_seconds: 164_313,
              failure_threshold_expiration_in_seconds: 9431,
              interaction_threshold: 71,
              recording_period_in_seconds: 1877,
              set_http_header:
                OCI::Waas::Models::Header.new(
                  name: 'EXAMPLE-name-Value', value: 'EXAMPLE-value-Value'
                ),
              challenge_settings:
                OCI::Waas::Models::BlockChallengeSettings.new(
                  block_action: 'SHOW_CAPTCHA',
                  block_response_code: 443,
                  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.new(
              is_enabled: true,
              action: 'DETECT',
              failure_threshold: 36_473,
              action_expiration_in_seconds: 319_332,
              set_http_header:
                OCI::Waas::Models::Header.new(
                  name: 'EXAMPLE-name-Value', value: 'EXAMPLE-value-Value'
                ),
              challenge_settings:
                OCI::Waas::Models::BlockChallengeSettings.new(
                  block_action: 'SET_RESPONSE_CODE',
                  block_response_code: 577,
                  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.new(
                  condition: 'URL_PART_ENDS_WITH',
                  value: 'EXAMPLE-value-Value',
                  is_case_sensitive: true
                )
              ],
              is_nat_enabled: false
            ),
          origin: 'EXAMPLE-origin-Value',
          caching_rules: [
            OCI::Waas::Models::CachingRule.new(
              name: 'EXAMPLE-name-Value',
              action: 'BYPASS_CACHE',
              criteria: [
                OCI::Waas::Models::CachingRuleCriteria.new(
                  condition: 'URL_STARTS_WITH', value: 'EXAMPLE-value-Value'
                )
              ],
              key: 'EXAMPLE-key-Value',
              caching_duration: 'EXAMPLE-cachingDuration-Value',
              is_client_caching_enabled: true,
              client_caching_duration: 'EXAMPLE-clientCachingDuration-Value'
            )
          ],
          custom_protection_rules: [
            OCI::Waas::Models::CustomProtectionRuleSetting.new(
              id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value',
              action: 'BLOCK',
              exclusions: [
                OCI::Waas::Models::ProtectionRuleExclusion.new(
                  target: 'REQUEST_COOKIES', exclusions: %w[EXAMPLE--Value]
                )
              ]
            )
          ],
          origin_groups: %w[EXAMPLE--Value],
          protection_settings:
            OCI::Waas::Models::ProtectionSettings.new(
              block_action: 'SET_RESPONSE_CODE',
              block_response_code: 621,
              block_error_page_message: 'EXAMPLE-blockErrorPageMessage-Value',
              block_error_page_code: 'EXAMPLE-blockErrorPageCode-Value',
              block_error_page_description:
                'EXAMPLE-blockErrorPageDescription-Value',
              max_argument_count: 268,
              max_name_length_per_argument: 94_431,
              max_total_name_length_of_arguments: 100_506,
              recommendations_period_in_days: 86,
              is_response_inspected: false,
              max_response_size_in_ki_b: 28,
              allowed_http_methods: %w[POST],
              media_types: %w[EXAMPLE--Value]
            ),
          whitelists: [
            OCI::Waas::Models::Whitelist.new(
              name: 'EXAMPLE-name-Value',
              addresses: %w[EXAMPLE--Value],
              address_lists: %w[EXAMPLE--Value]
            )
          ]
        ),
      freeform_tags: {
        'EXAMPLE_KEY_JBYcF' => 'EXAMPLE_VALUE_AMhSSCf9PDK13DANNNwe'
      },
      defined_tags: {
        'EXAMPLE_KEY_byVqx' => { 'EXAMPLE_KEY_vExoc' => 'EXAMPLE--Value' }
      }
    )
  )

# Get the data from response
puts "#{create_waas_policy_response.headers}"