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

namespace Google\Cloud\AppEngine\V1;

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

/**
 * URL pattern and description of how the URL should be handled. App Engine can
 * handle URLs by executing application code or by serving static files
 * uploaded with the version, such as images, CSS, or JavaScript.
 *
 * Generated from protobuf message <code>google.appengine.v1.UrlMap</code>
 */
class UrlMap extends \Google\Protobuf\Internal\Message
{
    /**
     * URL prefix. Uses regular expression syntax, which means regexp
     * special characters must be escaped, but should not contain groupings.
     * All URLs that begin with this prefix are handled by this handler, using the
     * portion of the URL after the prefix as part of the file path.
     *
     * Generated from protobuf field <code>string url_regex = 1;</code>
     */
    private $url_regex = '';
    /**
     * Security (HTTPS) enforcement for this URL.
     *
     * Generated from protobuf field <code>.google.appengine.v1.SecurityLevel security_level = 5;</code>
     */
    private $security_level = 0;
    /**
     * Level of login required to access this resource. Not supported for Node.js
     * in the App Engine standard environment.
     *
     * Generated from protobuf field <code>.google.appengine.v1.LoginRequirement login = 6;</code>
     */
    private $login = 0;
    /**
     * Action to take when users access resources that require
     * authentication. Defaults to `redirect`.
     *
     * Generated from protobuf field <code>.google.appengine.v1.AuthFailAction auth_fail_action = 7;</code>
     */
    private $auth_fail_action = 0;
    /**
     * `30x` code to use when performing redirects for the `secure` field.
     * Defaults to `302`.
     *
     * Generated from protobuf field <code>.google.appengine.v1.UrlMap.RedirectHttpResponseCode redirect_http_response_code = 8;</code>
     */
    private $redirect_http_response_code = 0;
    protected $handler_type;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $url_regex
     *           URL prefix. Uses regular expression syntax, which means regexp
     *           special characters must be escaped, but should not contain groupings.
     *           All URLs that begin with this prefix are handled by this handler, using the
     *           portion of the URL after the prefix as part of the file path.
     *     @type \Google\Cloud\AppEngine\V1\StaticFilesHandler $static_files
     *           Returns the contents of a file, such as an image, as the response.
     *     @type \Google\Cloud\AppEngine\V1\ScriptHandler $script
     *           Executes a script to handle the requests that match this URL
     *           pattern. Only the `auto` value is supported for Node.js in the
     *           App Engine standard environment, for example `"script": "auto"`.
     *     @type \Google\Cloud\AppEngine\V1\ApiEndpointHandler $api_endpoint
     *           Uses API Endpoints to handle requests.
     *     @type int $security_level
     *           Security (HTTPS) enforcement for this URL.
     *     @type int $login
     *           Level of login required to access this resource. Not supported for Node.js
     *           in the App Engine standard environment.
     *     @type int $auth_fail_action
     *           Action to take when users access resources that require
     *           authentication. Defaults to `redirect`.
     *     @type int $redirect_http_response_code
     *           `30x` code to use when performing redirects for the `secure` field.
     *           Defaults to `302`.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Appengine\V1\AppYaml::initOnce();
        parent::__construct($data);
    }

    /**
     * URL prefix. Uses regular expression syntax, which means regexp
     * special characters must be escaped, but should not contain groupings.
     * All URLs that begin with this prefix are handled by this handler, using the
     * portion of the URL after the prefix as part of the file path.
     *
     * Generated from protobuf field <code>string url_regex = 1;</code>
     * @return string
     */
    public function getUrlRegex()
    {
        return $this->url_regex;
    }

    /**
     * URL prefix. Uses regular expression syntax, which means regexp
     * special characters must be escaped, but should not contain groupings.
     * All URLs that begin with this prefix are handled by this handler, using the
     * portion of the URL after the prefix as part of the file path.
     *
     * Generated from protobuf field <code>string url_regex = 1;</code>
     * @param string $var
     * @return $this
     */
    public function setUrlRegex($var)
    {
        GPBUtil::checkString($var, True);
        $this->url_regex = $var;

        return $this;
    }

    /**
     * Returns the contents of a file, such as an image, as the response.
     *
     * Generated from protobuf field <code>.google.appengine.v1.StaticFilesHandler static_files = 2;</code>
     * @return \Google\Cloud\AppEngine\V1\StaticFilesHandler|null
     */
    public function getStaticFiles()
    {
        return $this->readOneof(2);
    }

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

    /**
     * Returns the contents of a file, such as an image, as the response.
     *
     * Generated from protobuf field <code>.google.appengine.v1.StaticFilesHandler static_files = 2;</code>
     * @param \Google\Cloud\AppEngine\V1\StaticFilesHandler $var
     * @return $this
     */
    public function setStaticFiles($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\AppEngine\V1\StaticFilesHandler::class);
        $this->writeOneof(2, $var);

        return $this;
    }

    /**
     * Executes a script to handle the requests that match this URL
     * pattern. Only the `auto` value is supported for Node.js in the
     * App Engine standard environment, for example `"script": "auto"`.
     *
     * Generated from protobuf field <code>.google.appengine.v1.ScriptHandler script = 3;</code>
     * @return \Google\Cloud\AppEngine\V1\ScriptHandler|null
     */
    public function getScript()
    {
        return $this->readOneof(3);
    }

    public function hasScript()
    {
        return $this->hasOneof(3);
    }

    /**
     * Executes a script to handle the requests that match this URL
     * pattern. Only the `auto` value is supported for Node.js in the
     * App Engine standard environment, for example `"script": "auto"`.
     *
     * Generated from protobuf field <code>.google.appengine.v1.ScriptHandler script = 3;</code>
     * @param \Google\Cloud\AppEngine\V1\ScriptHandler $var
     * @return $this
     */
    public function setScript($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\AppEngine\V1\ScriptHandler::class);
        $this->writeOneof(3, $var);

        return $this;
    }

    /**
     * Uses API Endpoints to handle requests.
     *
     * Generated from protobuf field <code>.google.appengine.v1.ApiEndpointHandler api_endpoint = 4;</code>
     * @return \Google\Cloud\AppEngine\V1\ApiEndpointHandler|null
     */
    public function getApiEndpoint()
    {
        return $this->readOneof(4);
    }

    public function hasApiEndpoint()
    {
        return $this->hasOneof(4);
    }

    /**
     * Uses API Endpoints to handle requests.
     *
     * Generated from protobuf field <code>.google.appengine.v1.ApiEndpointHandler api_endpoint = 4;</code>
     * @param \Google\Cloud\AppEngine\V1\ApiEndpointHandler $var
     * @return $this
     */
    public function setApiEndpoint($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\AppEngine\V1\ApiEndpointHandler::class);
        $this->writeOneof(4, $var);

        return $this;
    }

    /**
     * Security (HTTPS) enforcement for this URL.
     *
     * Generated from protobuf field <code>.google.appengine.v1.SecurityLevel security_level = 5;</code>
     * @return int
     */
    public function getSecurityLevel()
    {
        return $this->security_level;
    }

    /**
     * Security (HTTPS) enforcement for this URL.
     *
     * Generated from protobuf field <code>.google.appengine.v1.SecurityLevel security_level = 5;</code>
     * @param int $var
     * @return $this
     */
    public function setSecurityLevel($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\AppEngine\V1\SecurityLevel::class);
        $this->security_level = $var;

        return $this;
    }

    /**
     * Level of login required to access this resource. Not supported for Node.js
     * in the App Engine standard environment.
     *
     * Generated from protobuf field <code>.google.appengine.v1.LoginRequirement login = 6;</code>
     * @return int
     */
    public function getLogin()
    {
        return $this->login;
    }

    /**
     * Level of login required to access this resource. Not supported for Node.js
     * in the App Engine standard environment.
     *
     * Generated from protobuf field <code>.google.appengine.v1.LoginRequirement login = 6;</code>
     * @param int $var
     * @return $this
     */
    public function setLogin($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\AppEngine\V1\LoginRequirement::class);
        $this->login = $var;

        return $this;
    }

    /**
     * Action to take when users access resources that require
     * authentication. Defaults to `redirect`.
     *
     * Generated from protobuf field <code>.google.appengine.v1.AuthFailAction auth_fail_action = 7;</code>
     * @return int
     */
    public function getAuthFailAction()
    {
        return $this->auth_fail_action;
    }

    /**
     * Action to take when users access resources that require
     * authentication. Defaults to `redirect`.
     *
     * Generated from protobuf field <code>.google.appengine.v1.AuthFailAction auth_fail_action = 7;</code>
     * @param int $var
     * @return $this
     */
    public function setAuthFailAction($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\AppEngine\V1\AuthFailAction::class);
        $this->auth_fail_action = $var;

        return $this;
    }

    /**
     * `30x` code to use when performing redirects for the `secure` field.
     * Defaults to `302`.
     *
     * Generated from protobuf field <code>.google.appengine.v1.UrlMap.RedirectHttpResponseCode redirect_http_response_code = 8;</code>
     * @return int
     */
    public function getRedirectHttpResponseCode()
    {
        return $this->redirect_http_response_code;
    }

    /**
     * `30x` code to use when performing redirects for the `secure` field.
     * Defaults to `302`.
     *
     * Generated from protobuf field <code>.google.appengine.v1.UrlMap.RedirectHttpResponseCode redirect_http_response_code = 8;</code>
     * @param int $var
     * @return $this
     */
    public function setRedirectHttpResponseCode($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\AppEngine\V1\UrlMap\RedirectHttpResponseCode::class);
        $this->redirect_http_response_code = $var;

        return $this;
    }

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

}

