<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/api/apikeys/v2/resources.proto

namespace Google\Cloud\ApiKeys\V2;

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

/**
 * Describes the restrictions on the key.
 *
 * Generated from protobuf message <code>google.api.apikeys.v2.Restrictions</code>
 */
class Restrictions extends \Google\Protobuf\Internal\Message
{
    /**
     * A restriction for a specific service and optionally one or
     * more specific methods. Requests are allowed if they
     * match any of these restrictions. If no restrictions are
     * specified, all targets are allowed.
     *
     * Generated from protobuf field <code>repeated .google.api.apikeys.v2.ApiTarget api_targets = 5;</code>
     */
    private $api_targets;
    protected $client_restrictions;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type \Google\Cloud\ApiKeys\V2\BrowserKeyRestrictions $browser_key_restrictions
     *           The HTTP referrers (websites) that are allowed to use the key.
     *     @type \Google\Cloud\ApiKeys\V2\ServerKeyRestrictions $server_key_restrictions
     *           The IP addresses of callers that are allowed to use the key.
     *     @type \Google\Cloud\ApiKeys\V2\AndroidKeyRestrictions $android_key_restrictions
     *           The Android apps that are allowed to use the key.
     *     @type \Google\Cloud\ApiKeys\V2\IosKeyRestrictions $ios_key_restrictions
     *           The iOS apps that are allowed to use the key.
     *     @type array<\Google\Cloud\ApiKeys\V2\ApiTarget>|\Google\Protobuf\Internal\RepeatedField $api_targets
     *           A restriction for a specific service and optionally one or
     *           more specific methods. Requests are allowed if they
     *           match any of these restrictions. If no restrictions are
     *           specified, all targets are allowed.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Api\Apikeys\V2\Resources::initOnce();
        parent::__construct($data);
    }

    /**
     * The HTTP referrers (websites) that are allowed to use the key.
     *
     * Generated from protobuf field <code>.google.api.apikeys.v2.BrowserKeyRestrictions browser_key_restrictions = 1;</code>
     * @return \Google\Cloud\ApiKeys\V2\BrowserKeyRestrictions|null
     */
    public function getBrowserKeyRestrictions()
    {
        return $this->readOneof(1);
    }

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

    /**
     * The HTTP referrers (websites) that are allowed to use the key.
     *
     * Generated from protobuf field <code>.google.api.apikeys.v2.BrowserKeyRestrictions browser_key_restrictions = 1;</code>
     * @param \Google\Cloud\ApiKeys\V2\BrowserKeyRestrictions $var
     * @return $this
     */
    public function setBrowserKeyRestrictions($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\ApiKeys\V2\BrowserKeyRestrictions::class);
        $this->writeOneof(1, $var);

        return $this;
    }

    /**
     * The IP addresses of callers that are allowed to use the key.
     *
     * Generated from protobuf field <code>.google.api.apikeys.v2.ServerKeyRestrictions server_key_restrictions = 2;</code>
     * @return \Google\Cloud\ApiKeys\V2\ServerKeyRestrictions|null
     */
    public function getServerKeyRestrictions()
    {
        return $this->readOneof(2);
    }

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

    /**
     * The IP addresses of callers that are allowed to use the key.
     *
     * Generated from protobuf field <code>.google.api.apikeys.v2.ServerKeyRestrictions server_key_restrictions = 2;</code>
     * @param \Google\Cloud\ApiKeys\V2\ServerKeyRestrictions $var
     * @return $this
     */
    public function setServerKeyRestrictions($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\ApiKeys\V2\ServerKeyRestrictions::class);
        $this->writeOneof(2, $var);

        return $this;
    }

    /**
     * The Android apps that are allowed to use the key.
     *
     * Generated from protobuf field <code>.google.api.apikeys.v2.AndroidKeyRestrictions android_key_restrictions = 3;</code>
     * @return \Google\Cloud\ApiKeys\V2\AndroidKeyRestrictions|null
     */
    public function getAndroidKeyRestrictions()
    {
        return $this->readOneof(3);
    }

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

    /**
     * The Android apps that are allowed to use the key.
     *
     * Generated from protobuf field <code>.google.api.apikeys.v2.AndroidKeyRestrictions android_key_restrictions = 3;</code>
     * @param \Google\Cloud\ApiKeys\V2\AndroidKeyRestrictions $var
     * @return $this
     */
    public function setAndroidKeyRestrictions($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\ApiKeys\V2\AndroidKeyRestrictions::class);
        $this->writeOneof(3, $var);

        return $this;
    }

    /**
     * The iOS apps that are allowed to use the key.
     *
     * Generated from protobuf field <code>.google.api.apikeys.v2.IosKeyRestrictions ios_key_restrictions = 4;</code>
     * @return \Google\Cloud\ApiKeys\V2\IosKeyRestrictions|null
     */
    public function getIosKeyRestrictions()
    {
        return $this->readOneof(4);
    }

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

    /**
     * The iOS apps that are allowed to use the key.
     *
     * Generated from protobuf field <code>.google.api.apikeys.v2.IosKeyRestrictions ios_key_restrictions = 4;</code>
     * @param \Google\Cloud\ApiKeys\V2\IosKeyRestrictions $var
     * @return $this
     */
    public function setIosKeyRestrictions($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\ApiKeys\V2\IosKeyRestrictions::class);
        $this->writeOneof(4, $var);

        return $this;
    }

    /**
     * A restriction for a specific service and optionally one or
     * more specific methods. Requests are allowed if they
     * match any of these restrictions. If no restrictions are
     * specified, all targets are allowed.
     *
     * Generated from protobuf field <code>repeated .google.api.apikeys.v2.ApiTarget api_targets = 5;</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getApiTargets()
    {
        return $this->api_targets;
    }

    /**
     * A restriction for a specific service and optionally one or
     * more specific methods. Requests are allowed if they
     * match any of these restrictions. If no restrictions are
     * specified, all targets are allowed.
     *
     * Generated from protobuf field <code>repeated .google.api.apikeys.v2.ApiTarget api_targets = 5;</code>
     * @param array<\Google\Cloud\ApiKeys\V2\ApiTarget>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setApiTargets($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\ApiKeys\V2\ApiTarget::class);
        $this->api_targets = $arr;

        return $this;
    }

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

}

