<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/ces/v1/guardrail.proto

namespace Google\Cloud\Ces\V1\Guardrail;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\GPBUtil;
use Google\Protobuf\RepeatedField;

/**
 * Guardrail that blocks the conversation if the input is considered unsafe
 * based on the LLM classification.
 *
 * Generated from protobuf message <code>google.cloud.ces.v1.Guardrail.LlmPromptSecurity</code>
 */
class LlmPromptSecurity extends \Google\Protobuf\Internal\Message
{
    /**
     * Optional. Determines the behavior when the guardrail encounters an LLM
     * error.
     * - If true: the guardrail is bypassed.
     * - If false (default): the guardrail triggers/blocks.
     * Note: If a custom policy is provided, this field is ignored in favor
     * of the policy's 'fail_open' configuration.
     *
     * Generated from protobuf field <code>bool fail_open = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     */
    protected $fail_open = false;
    protected $security_config;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type \Google\Cloud\Ces\V1\Guardrail\LlmPromptSecurity\DefaultSecuritySettings $default_settings
     *           Optional. Use the system's predefined default security settings.
     *           To select this mode, include an empty 'default_settings' message
     *           in the request. The 'default_prompt_template' field within
     *           will be populated by the server in the response.
     *     @type \Google\Cloud\Ces\V1\Guardrail\LlmPolicy $custom_policy
     *           Optional. Use a user-defined LlmPolicy to configure the security
     *           guardrail.
     *     @type bool $fail_open
     *           Optional. Determines the behavior when the guardrail encounters an LLM
     *           error.
     *           - If true: the guardrail is bypassed.
     *           - If false (default): the guardrail triggers/blocks.
     *           Note: If a custom policy is provided, this field is ignored in favor
     *           of the policy's 'fail_open' configuration.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Ces\V1\Guardrail::initOnce();
        parent::__construct($data);
    }

    /**
     * Optional. Use the system's predefined default security settings.
     * To select this mode, include an empty 'default_settings' message
     * in the request. The 'default_prompt_template' field within
     * will be populated by the server in the response.
     *
     * Generated from protobuf field <code>.google.cloud.ces.v1.Guardrail.LlmPromptSecurity.DefaultSecuritySettings default_settings = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return \Google\Cloud\Ces\V1\Guardrail\LlmPromptSecurity\DefaultSecuritySettings|null
     */
    public function getDefaultSettings()
    {
        return $this->readOneof(1);
    }

    public function hasDefaultSettings()
    {
        return $this->hasOneof(1);
    }

    /**
     * Optional. Use the system's predefined default security settings.
     * To select this mode, include an empty 'default_settings' message
     * in the request. The 'default_prompt_template' field within
     * will be populated by the server in the response.
     *
     * Generated from protobuf field <code>.google.cloud.ces.v1.Guardrail.LlmPromptSecurity.DefaultSecuritySettings default_settings = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param \Google\Cloud\Ces\V1\Guardrail\LlmPromptSecurity\DefaultSecuritySettings $var
     * @return $this
     */
    public function setDefaultSettings($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Ces\V1\Guardrail\LlmPromptSecurity\DefaultSecuritySettings::class);
        $this->writeOneof(1, $var);

        return $this;
    }

    /**
     * Optional. Use a user-defined LlmPolicy to configure the security
     * guardrail.
     *
     * Generated from protobuf field <code>.google.cloud.ces.v1.Guardrail.LlmPolicy custom_policy = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return \Google\Cloud\Ces\V1\Guardrail\LlmPolicy|null
     */
    public function getCustomPolicy()
    {
        return $this->readOneof(2);
    }

    public function hasCustomPolicy()
    {
        return $this->hasOneof(2);
    }

    /**
     * Optional. Use a user-defined LlmPolicy to configure the security
     * guardrail.
     *
     * Generated from protobuf field <code>.google.cloud.ces.v1.Guardrail.LlmPolicy custom_policy = 2 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param \Google\Cloud\Ces\V1\Guardrail\LlmPolicy $var
     * @return $this
     */
    public function setCustomPolicy($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Ces\V1\Guardrail\LlmPolicy::class);
        $this->writeOneof(2, $var);

        return $this;
    }

    /**
     * Optional. Determines the behavior when the guardrail encounters an LLM
     * error.
     * - If true: the guardrail is bypassed.
     * - If false (default): the guardrail triggers/blocks.
     * Note: If a custom policy is provided, this field is ignored in favor
     * of the policy's 'fail_open' configuration.
     *
     * Generated from protobuf field <code>bool fail_open = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @return bool
     */
    public function getFailOpen()
    {
        return $this->fail_open;
    }

    /**
     * Optional. Determines the behavior when the guardrail encounters an LLM
     * error.
     * - If true: the guardrail is bypassed.
     * - If false (default): the guardrail triggers/blocks.
     * Note: If a custom policy is provided, this field is ignored in favor
     * of the policy's 'fail_open' configuration.
     *
     * Generated from protobuf field <code>bool fail_open = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     * @param bool $var
     * @return $this
     */
    public function setFailOpen($var)
    {
        GPBUtil::checkBool($var);
        $this->fail_open = $var;

        return $this;
    }

    /**
     * @return string
     */
    public function getSecurityConfig()
    {
        return $this->whichOneof("security_config");
    }

}

