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

namespace Google\Cloud\Compute\V1;

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

/**
 * The specification for allowing client-side cross-origin requests. For more information about the W3C recommendation for cross-origin resource sharing (CORS), see Fetch API Living Standard.
 *
 * Generated from protobuf message <code>google.cloud.compute.v1.CorsPolicy</code>
 */
class CorsPolicy extends \Google\Protobuf\Internal\Message
{
    /**
     * In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false.
     *
     * Generated from protobuf field <code>optional bool allow_credentials = 481263366;</code>
     */
    private $allow_credentials = null;
    /**
     * Specifies the content for the Access-Control-Allow-Headers header.
     *
     * Generated from protobuf field <code>repeated string allow_headers = 45179024;</code>
     */
    private $allow_headers;
    /**
     * Specifies the content for the Access-Control-Allow-Methods header.
     *
     * Generated from protobuf field <code>repeated string allow_methods = 205405372;</code>
     */
    private $allow_methods;
    /**
     * Specifies a regular expression that matches allowed origins. For more information about the regular expression syntax, see Syntax. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.
     *
     * Generated from protobuf field <code>repeated string allow_origin_regexes = 215385810;</code>
     */
    private $allow_origin_regexes;
    /**
     * Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.
     *
     * Generated from protobuf field <code>repeated string allow_origins = 194914071;</code>
     */
    private $allow_origins;
    /**
     * If true, the setting specifies the CORS policy is disabled. The default value of false, which indicates that the CORS policy is in effect.
     *
     * Generated from protobuf field <code>optional bool disabled = 270940796;</code>
     */
    private $disabled = null;
    /**
     * Specifies the content for the Access-Control-Expose-Headers header.
     *
     * Generated from protobuf field <code>repeated string expose_headers = 247604747;</code>
     */
    private $expose_headers;
    /**
     * Specifies how long results of a preflight request can be cached in seconds. This field translates to the Access-Control-Max-Age header.
     *
     * Generated from protobuf field <code>optional int32 max_age = 307559332;</code>
     */
    private $max_age = null;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type bool $allow_credentials
     *           In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false.
     *     @type array<string>|\Google\Protobuf\Internal\RepeatedField $allow_headers
     *           Specifies the content for the Access-Control-Allow-Headers header.
     *     @type array<string>|\Google\Protobuf\Internal\RepeatedField $allow_methods
     *           Specifies the content for the Access-Control-Allow-Methods header.
     *     @type array<string>|\Google\Protobuf\Internal\RepeatedField $allow_origin_regexes
     *           Specifies a regular expression that matches allowed origins. For more information about the regular expression syntax, see Syntax. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.
     *     @type array<string>|\Google\Protobuf\Internal\RepeatedField $allow_origins
     *           Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.
     *     @type bool $disabled
     *           If true, the setting specifies the CORS policy is disabled. The default value of false, which indicates that the CORS policy is in effect.
     *     @type array<string>|\Google\Protobuf\Internal\RepeatedField $expose_headers
     *           Specifies the content for the Access-Control-Expose-Headers header.
     *     @type int $max_age
     *           Specifies how long results of a preflight request can be cached in seconds. This field translates to the Access-Control-Max-Age header.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Compute\V1\Compute::initOnce();
        parent::__construct($data);
    }

    /**
     * In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false.
     *
     * Generated from protobuf field <code>optional bool allow_credentials = 481263366;</code>
     * @return bool
     */
    public function getAllowCredentials()
    {
        return isset($this->allow_credentials) ? $this->allow_credentials : false;
    }

    public function hasAllowCredentials()
    {
        return isset($this->allow_credentials);
    }

    public function clearAllowCredentials()
    {
        unset($this->allow_credentials);
    }

    /**
     * In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false.
     *
     * Generated from protobuf field <code>optional bool allow_credentials = 481263366;</code>
     * @param bool $var
     * @return $this
     */
    public function setAllowCredentials($var)
    {
        GPBUtil::checkBool($var);
        $this->allow_credentials = $var;

        return $this;
    }

    /**
     * Specifies the content for the Access-Control-Allow-Headers header.
     *
     * Generated from protobuf field <code>repeated string allow_headers = 45179024;</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getAllowHeaders()
    {
        return $this->allow_headers;
    }

    /**
     * Specifies the content for the Access-Control-Allow-Headers header.
     *
     * Generated from protobuf field <code>repeated string allow_headers = 45179024;</code>
     * @param array<string>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setAllowHeaders($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
        $this->allow_headers = $arr;

        return $this;
    }

    /**
     * Specifies the content for the Access-Control-Allow-Methods header.
     *
     * Generated from protobuf field <code>repeated string allow_methods = 205405372;</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getAllowMethods()
    {
        return $this->allow_methods;
    }

    /**
     * Specifies the content for the Access-Control-Allow-Methods header.
     *
     * Generated from protobuf field <code>repeated string allow_methods = 205405372;</code>
     * @param array<string>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setAllowMethods($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
        $this->allow_methods = $arr;

        return $this;
    }

    /**
     * Specifies a regular expression that matches allowed origins. For more information about the regular expression syntax, see Syntax. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.
     *
     * Generated from protobuf field <code>repeated string allow_origin_regexes = 215385810;</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getAllowOriginRegexes()
    {
        return $this->allow_origin_regexes;
    }

    /**
     * Specifies a regular expression that matches allowed origins. For more information about the regular expression syntax, see Syntax. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.
     *
     * Generated from protobuf field <code>repeated string allow_origin_regexes = 215385810;</code>
     * @param array<string>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setAllowOriginRegexes($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
        $this->allow_origin_regexes = $arr;

        return $this;
    }

    /**
     * Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.
     *
     * Generated from protobuf field <code>repeated string allow_origins = 194914071;</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getAllowOrigins()
    {
        return $this->allow_origins;
    }

    /**
     * Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.
     *
     * Generated from protobuf field <code>repeated string allow_origins = 194914071;</code>
     * @param array<string>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setAllowOrigins($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
        $this->allow_origins = $arr;

        return $this;
    }

    /**
     * If true, the setting specifies the CORS policy is disabled. The default value of false, which indicates that the CORS policy is in effect.
     *
     * Generated from protobuf field <code>optional bool disabled = 270940796;</code>
     * @return bool
     */
    public function getDisabled()
    {
        return isset($this->disabled) ? $this->disabled : false;
    }

    public function hasDisabled()
    {
        return isset($this->disabled);
    }

    public function clearDisabled()
    {
        unset($this->disabled);
    }

    /**
     * If true, the setting specifies the CORS policy is disabled. The default value of false, which indicates that the CORS policy is in effect.
     *
     * Generated from protobuf field <code>optional bool disabled = 270940796;</code>
     * @param bool $var
     * @return $this
     */
    public function setDisabled($var)
    {
        GPBUtil::checkBool($var);
        $this->disabled = $var;

        return $this;
    }

    /**
     * Specifies the content for the Access-Control-Expose-Headers header.
     *
     * Generated from protobuf field <code>repeated string expose_headers = 247604747;</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getExposeHeaders()
    {
        return $this->expose_headers;
    }

    /**
     * Specifies the content for the Access-Control-Expose-Headers header.
     *
     * Generated from protobuf field <code>repeated string expose_headers = 247604747;</code>
     * @param array<string>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setExposeHeaders($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
        $this->expose_headers = $arr;

        return $this;
    }

    /**
     * Specifies how long results of a preflight request can be cached in seconds. This field translates to the Access-Control-Max-Age header.
     *
     * Generated from protobuf field <code>optional int32 max_age = 307559332;</code>
     * @return int
     */
    public function getMaxAge()
    {
        return isset($this->max_age) ? $this->max_age : 0;
    }

    public function hasMaxAge()
    {
        return isset($this->max_age);
    }

    public function clearMaxAge()
    {
        unset($this->max_age);
    }

    /**
     * Specifies how long results of a preflight request can be cached in seconds. This field translates to the Access-Control-Max-Age header.
     *
     * Generated from protobuf field <code>optional int32 max_age = 307559332;</code>
     * @param int $var
     * @return $this
     */
    public function setMaxAge($var)
    {
        GPBUtil::checkInt32($var);
        $this->max_age = $var;

        return $this;
    }

}

