// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package com.pulumi.gcp.compute.inputs;

import com.pulumi.core.Output;
import com.pulumi.core.annotations.Import;
import com.pulumi.gcp.compute.inputs.SecurityPolicyRuleHeaderActionArgs;
import com.pulumi.gcp.compute.inputs.SecurityPolicyRuleMatchArgs;
import com.pulumi.gcp.compute.inputs.SecurityPolicyRulePreconfiguredWafConfigArgs;
import com.pulumi.gcp.compute.inputs.SecurityPolicyRuleRateLimitOptionsArgs;
import com.pulumi.gcp.compute.inputs.SecurityPolicyRuleRedirectOptionsArgs;
import java.lang.Boolean;
import java.lang.Integer;
import java.lang.String;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.Nullable;


public final class SecurityPolicyRuleArgs extends com.pulumi.resources.ResourceArgs {

    public static final SecurityPolicyRuleArgs Empty = new SecurityPolicyRuleArgs();

    /**
     * Action to take when `match` matches the request. Valid values:
     * * allow: allow access to target.
     * * deny(): deny access to target, returns the HTTP response code specified (valid values are 403, 404, and 502).
     * * rate_based_ban: limit client traffic to the configured threshold and ban the client if the traffic exceeds the threshold. Configure parameters for this action in RateLimitOptions. Requires rateLimitOptions to be set.
     * * redirect: redirect to a different target. This can either be an internal reCAPTCHA redirect, or an external URL-based redirect via a 302 response. Parameters for this action can be configured via redirectOptions.
     * * throttle: limit client traffic to the configured threshold. Configure parameters for this action in rateLimitOptions. Requires rateLimitOptions to be set for this.
     * 
     */
    @Import(name="action", required=true)
    private Output<String> action;

    /**
     * @return Action to take when `match` matches the request. Valid values:
     * * allow: allow access to target.
     * * deny(): deny access to target, returns the HTTP response code specified (valid values are 403, 404, and 502).
     * * rate_based_ban: limit client traffic to the configured threshold and ban the client if the traffic exceeds the threshold. Configure parameters for this action in RateLimitOptions. Requires rateLimitOptions to be set.
     * * redirect: redirect to a different target. This can either be an internal reCAPTCHA redirect, or an external URL-based redirect via a 302 response. Parameters for this action can be configured via redirectOptions.
     * * throttle: limit client traffic to the configured threshold. Configure parameters for this action in rateLimitOptions. Requires rateLimitOptions to be set for this.
     * 
     */
    public Output<String> action() {
        return this.action;
    }

    /**
     * An optional description of this rule. Max size is 64.
     * 
     */
    @Import(name="description")
    private @Nullable Output<String> description;

    /**
     * @return An optional description of this rule. Max size is 64.
     * 
     */
    public Optional<Output<String>> description() {
        return Optional.ofNullable(this.description);
    }

    /**
     * Additional actions that are performed on headers. Structure is documented below.
     * 
     */
    @Import(name="headerAction")
    private @Nullable Output<SecurityPolicyRuleHeaderActionArgs> headerAction;

    /**
     * @return Additional actions that are performed on headers. Structure is documented below.
     * 
     */
    public Optional<Output<SecurityPolicyRuleHeaderActionArgs>> headerAction() {
        return Optional.ofNullable(this.headerAction);
    }

    /**
     * A match condition that incoming traffic is evaluated against.
     * If it evaluates to true, the corresponding `action` is enforced. Structure is documented below.
     * 
     */
    @Import(name="match", required=true)
    private Output<SecurityPolicyRuleMatchArgs> match;

    /**
     * @return A match condition that incoming traffic is evaluated against.
     * If it evaluates to true, the corresponding `action` is enforced. Structure is documented below.
     * 
     */
    public Output<SecurityPolicyRuleMatchArgs> match() {
        return this.match;
    }

    /**
     * ) Preconfigured WAF configuration to be applied for the rule. If the rule does not evaluate preconfigured WAF rules, i.e., if evaluatePreconfiguredWaf() is not used, this field will have no effect. Structure is documented below.
     * 
     */
    @Import(name="preconfiguredWafConfig")
    private @Nullable Output<SecurityPolicyRulePreconfiguredWafConfigArgs> preconfiguredWafConfig;

    /**
     * @return ) Preconfigured WAF configuration to be applied for the rule. If the rule does not evaluate preconfigured WAF rules, i.e., if evaluatePreconfiguredWaf() is not used, this field will have no effect. Structure is documented below.
     * 
     */
    public Optional<Output<SecurityPolicyRulePreconfiguredWafConfigArgs>> preconfiguredWafConfig() {
        return Optional.ofNullable(this.preconfiguredWafConfig);
    }

    /**
     * When set to true, the `action` specified above is not enforced.
     * Stackdriver logs for requests that trigger a preview action are annotated as such.
     * 
     */
    @Import(name="preview")
    private @Nullable Output<Boolean> preview;

    /**
     * @return When set to true, the `action` specified above is not enforced.
     * Stackdriver logs for requests that trigger a preview action are annotated as such.
     * 
     */
    public Optional<Output<Boolean>> preview() {
        return Optional.ofNullable(this.preview);
    }

    /**
     * An unique positive integer indicating the priority of evaluation for a rule.
     * Rules are evaluated from highest priority (lowest numerically) to lowest priority (highest numerically) in order.
     * 
     */
    @Import(name="priority", required=true)
    private Output<Integer> priority;

    /**
     * @return An unique positive integer indicating the priority of evaluation for a rule.
     * Rules are evaluated from highest priority (lowest numerically) to lowest priority (highest numerically) in order.
     * 
     */
    public Output<Integer> priority() {
        return this.priority;
    }

    /**
     * Must be specified if the `action` is &#34;rate_based_ban&#34; or &#34;throttle&#34;. Cannot be specified for other actions. Structure is documented below.
     * 
     */
    @Import(name="rateLimitOptions")
    private @Nullable Output<SecurityPolicyRuleRateLimitOptionsArgs> rateLimitOptions;

    /**
     * @return Must be specified if the `action` is &#34;rate_based_ban&#34; or &#34;throttle&#34;. Cannot be specified for other actions. Structure is documented below.
     * 
     */
    public Optional<Output<SecurityPolicyRuleRateLimitOptionsArgs>> rateLimitOptions() {
        return Optional.ofNullable(this.rateLimitOptions);
    }

    /**
     * Can be specified if the `action` is &#34;redirect&#34;. Cannot be specified for other actions. Structure is documented below.
     * 
     */
    @Import(name="redirectOptions")
    private @Nullable Output<SecurityPolicyRuleRedirectOptionsArgs> redirectOptions;

    /**
     * @return Can be specified if the `action` is &#34;redirect&#34;. Cannot be specified for other actions. Structure is documented below.
     * 
     */
    public Optional<Output<SecurityPolicyRuleRedirectOptionsArgs>> redirectOptions() {
        return Optional.ofNullable(this.redirectOptions);
    }

    private SecurityPolicyRuleArgs() {}

    private SecurityPolicyRuleArgs(SecurityPolicyRuleArgs $) {
        this.action = $.action;
        this.description = $.description;
        this.headerAction = $.headerAction;
        this.match = $.match;
        this.preconfiguredWafConfig = $.preconfiguredWafConfig;
        this.preview = $.preview;
        this.priority = $.priority;
        this.rateLimitOptions = $.rateLimitOptions;
        this.redirectOptions = $.redirectOptions;
    }

    public static Builder builder() {
        return new Builder();
    }
    public static Builder builder(SecurityPolicyRuleArgs defaults) {
        return new Builder(defaults);
    }

    public static final class Builder {
        private SecurityPolicyRuleArgs $;

        public Builder() {
            $ = new SecurityPolicyRuleArgs();
        }

        public Builder(SecurityPolicyRuleArgs defaults) {
            $ = new SecurityPolicyRuleArgs(Objects.requireNonNull(defaults));
        }

        /**
         * @param action Action to take when `match` matches the request. Valid values:
         * * allow: allow access to target.
         * * deny(): deny access to target, returns the HTTP response code specified (valid values are 403, 404, and 502).
         * * rate_based_ban: limit client traffic to the configured threshold and ban the client if the traffic exceeds the threshold. Configure parameters for this action in RateLimitOptions. Requires rateLimitOptions to be set.
         * * redirect: redirect to a different target. This can either be an internal reCAPTCHA redirect, or an external URL-based redirect via a 302 response. Parameters for this action can be configured via redirectOptions.
         * * throttle: limit client traffic to the configured threshold. Configure parameters for this action in rateLimitOptions. Requires rateLimitOptions to be set for this.
         * 
         * @return builder
         * 
         */
        public Builder action(Output<String> action) {
            $.action = action;
            return this;
        }

        /**
         * @param action Action to take when `match` matches the request. Valid values:
         * * allow: allow access to target.
         * * deny(): deny access to target, returns the HTTP response code specified (valid values are 403, 404, and 502).
         * * rate_based_ban: limit client traffic to the configured threshold and ban the client if the traffic exceeds the threshold. Configure parameters for this action in RateLimitOptions. Requires rateLimitOptions to be set.
         * * redirect: redirect to a different target. This can either be an internal reCAPTCHA redirect, or an external URL-based redirect via a 302 response. Parameters for this action can be configured via redirectOptions.
         * * throttle: limit client traffic to the configured threshold. Configure parameters for this action in rateLimitOptions. Requires rateLimitOptions to be set for this.
         * 
         * @return builder
         * 
         */
        public Builder action(String action) {
            return action(Output.of(action));
        }

        /**
         * @param description An optional description of this rule. Max size is 64.
         * 
         * @return builder
         * 
         */
        public Builder description(@Nullable Output<String> description) {
            $.description = description;
            return this;
        }

        /**
         * @param description An optional description of this rule. Max size is 64.
         * 
         * @return builder
         * 
         */
        public Builder description(String description) {
            return description(Output.of(description));
        }

        /**
         * @param headerAction Additional actions that are performed on headers. Structure is documented below.
         * 
         * @return builder
         * 
         */
        public Builder headerAction(@Nullable Output<SecurityPolicyRuleHeaderActionArgs> headerAction) {
            $.headerAction = headerAction;
            return this;
        }

        /**
         * @param headerAction Additional actions that are performed on headers. Structure is documented below.
         * 
         * @return builder
         * 
         */
        public Builder headerAction(SecurityPolicyRuleHeaderActionArgs headerAction) {
            return headerAction(Output.of(headerAction));
        }

        /**
         * @param match A match condition that incoming traffic is evaluated against.
         * If it evaluates to true, the corresponding `action` is enforced. Structure is documented below.
         * 
         * @return builder
         * 
         */
        public Builder match(Output<SecurityPolicyRuleMatchArgs> match) {
            $.match = match;
            return this;
        }

        /**
         * @param match A match condition that incoming traffic is evaluated against.
         * If it evaluates to true, the corresponding `action` is enforced. Structure is documented below.
         * 
         * @return builder
         * 
         */
        public Builder match(SecurityPolicyRuleMatchArgs match) {
            return match(Output.of(match));
        }

        /**
         * @param preconfiguredWafConfig ) Preconfigured WAF configuration to be applied for the rule. If the rule does not evaluate preconfigured WAF rules, i.e., if evaluatePreconfiguredWaf() is not used, this field will have no effect. Structure is documented below.
         * 
         * @return builder
         * 
         */
        public Builder preconfiguredWafConfig(@Nullable Output<SecurityPolicyRulePreconfiguredWafConfigArgs> preconfiguredWafConfig) {
            $.preconfiguredWafConfig = preconfiguredWafConfig;
            return this;
        }

        /**
         * @param preconfiguredWafConfig ) Preconfigured WAF configuration to be applied for the rule. If the rule does not evaluate preconfigured WAF rules, i.e., if evaluatePreconfiguredWaf() is not used, this field will have no effect. Structure is documented below.
         * 
         * @return builder
         * 
         */
        public Builder preconfiguredWafConfig(SecurityPolicyRulePreconfiguredWafConfigArgs preconfiguredWafConfig) {
            return preconfiguredWafConfig(Output.of(preconfiguredWafConfig));
        }

        /**
         * @param preview When set to true, the `action` specified above is not enforced.
         * Stackdriver logs for requests that trigger a preview action are annotated as such.
         * 
         * @return builder
         * 
         */
        public Builder preview(@Nullable Output<Boolean> preview) {
            $.preview = preview;
            return this;
        }

        /**
         * @param preview When set to true, the `action` specified above is not enforced.
         * Stackdriver logs for requests that trigger a preview action are annotated as such.
         * 
         * @return builder
         * 
         */
        public Builder preview(Boolean preview) {
            return preview(Output.of(preview));
        }

        /**
         * @param priority An unique positive integer indicating the priority of evaluation for a rule.
         * Rules are evaluated from highest priority (lowest numerically) to lowest priority (highest numerically) in order.
         * 
         * @return builder
         * 
         */
        public Builder priority(Output<Integer> priority) {
            $.priority = priority;
            return this;
        }

        /**
         * @param priority An unique positive integer indicating the priority of evaluation for a rule.
         * Rules are evaluated from highest priority (lowest numerically) to lowest priority (highest numerically) in order.
         * 
         * @return builder
         * 
         */
        public Builder priority(Integer priority) {
            return priority(Output.of(priority));
        }

        /**
         * @param rateLimitOptions Must be specified if the `action` is &#34;rate_based_ban&#34; or &#34;throttle&#34;. Cannot be specified for other actions. Structure is documented below.
         * 
         * @return builder
         * 
         */
        public Builder rateLimitOptions(@Nullable Output<SecurityPolicyRuleRateLimitOptionsArgs> rateLimitOptions) {
            $.rateLimitOptions = rateLimitOptions;
            return this;
        }

        /**
         * @param rateLimitOptions Must be specified if the `action` is &#34;rate_based_ban&#34; or &#34;throttle&#34;. Cannot be specified for other actions. Structure is documented below.
         * 
         * @return builder
         * 
         */
        public Builder rateLimitOptions(SecurityPolicyRuleRateLimitOptionsArgs rateLimitOptions) {
            return rateLimitOptions(Output.of(rateLimitOptions));
        }

        /**
         * @param redirectOptions Can be specified if the `action` is &#34;redirect&#34;. Cannot be specified for other actions. Structure is documented below.
         * 
         * @return builder
         * 
         */
        public Builder redirectOptions(@Nullable Output<SecurityPolicyRuleRedirectOptionsArgs> redirectOptions) {
            $.redirectOptions = redirectOptions;
            return this;
        }

        /**
         * @param redirectOptions Can be specified if the `action` is &#34;redirect&#34;. Cannot be specified for other actions. Structure is documented below.
         * 
         * @return builder
         * 
         */
        public Builder redirectOptions(SecurityPolicyRuleRedirectOptionsArgs redirectOptions) {
            return redirectOptions(Output.of(redirectOptions));
        }

        public SecurityPolicyRuleArgs build() {
            $.action = Objects.requireNonNull($.action, "expected parameter 'action' to be non-null");
            $.match = Objects.requireNonNull($.match, "expected parameter 'match' to be non-null");
            $.priority = Objects.requireNonNull($.priority, "expected parameter 'priority' to be non-null");
            return $;
        }
    }

}
