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

namespace Google\Cloud\AppEngine\V1;

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

/**
 * Traffic routing configuration for versions within a single service. Traffic
 * splits define how traffic directed to the service is assigned to versions.
 *
 * Generated from protobuf message <code>google.appengine.v1.TrafficSplit</code>
 */
class TrafficSplit extends \Google\Protobuf\Internal\Message
{
    /**
     * Mechanism used to determine which version a request is sent to.
     * The traffic selection algorithm will
     * be stable for either type until allocations are changed.
     *
     * Generated from protobuf field <code>.google.appengine.v1.TrafficSplit.ShardBy shard_by = 1;</code>
     */
    private $shard_by = 0;
    /**
     * Mapping from version IDs within the service to fractional
     * (0.000, 1] allocations of traffic for that version. Each version can
     * be specified only once, but some versions in the service may not
     * have any traffic allocation. Services that have traffic allocated
     * cannot be deleted until either the service is deleted or
     * their traffic allocation is removed. Allocations must sum to 1.
     * Up to two decimal place precision is supported for IP-based splits and
     * up to three decimal places is supported for cookie-based splits.
     *
     * Generated from protobuf field <code>map<string, double> allocations = 2;</code>
     */
    private $allocations;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type int $shard_by
     *           Mechanism used to determine which version a request is sent to.
     *           The traffic selection algorithm will
     *           be stable for either type until allocations are changed.
     *     @type array|\Google\Protobuf\Internal\MapField $allocations
     *           Mapping from version IDs within the service to fractional
     *           (0.000, 1] allocations of traffic for that version. Each version can
     *           be specified only once, but some versions in the service may not
     *           have any traffic allocation. Services that have traffic allocated
     *           cannot be deleted until either the service is deleted or
     *           their traffic allocation is removed. Allocations must sum to 1.
     *           Up to two decimal place precision is supported for IP-based splits and
     *           up to three decimal places is supported for cookie-based splits.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Appengine\V1\Service::initOnce();
        parent::__construct($data);
    }

    /**
     * Mechanism used to determine which version a request is sent to.
     * The traffic selection algorithm will
     * be stable for either type until allocations are changed.
     *
     * Generated from protobuf field <code>.google.appengine.v1.TrafficSplit.ShardBy shard_by = 1;</code>
     * @return int
     */
    public function getShardBy()
    {
        return $this->shard_by;
    }

    /**
     * Mechanism used to determine which version a request is sent to.
     * The traffic selection algorithm will
     * be stable for either type until allocations are changed.
     *
     * Generated from protobuf field <code>.google.appengine.v1.TrafficSplit.ShardBy shard_by = 1;</code>
     * @param int $var
     * @return $this
     */
    public function setShardBy($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\AppEngine\V1\TrafficSplit\ShardBy::class);
        $this->shard_by = $var;

        return $this;
    }

    /**
     * Mapping from version IDs within the service to fractional
     * (0.000, 1] allocations of traffic for that version. Each version can
     * be specified only once, but some versions in the service may not
     * have any traffic allocation. Services that have traffic allocated
     * cannot be deleted until either the service is deleted or
     * their traffic allocation is removed. Allocations must sum to 1.
     * Up to two decimal place precision is supported for IP-based splits and
     * up to three decimal places is supported for cookie-based splits.
     *
     * Generated from protobuf field <code>map<string, double> allocations = 2;</code>
     * @return \Google\Protobuf\Internal\MapField
     */
    public function getAllocations()
    {
        return $this->allocations;
    }

    /**
     * Mapping from version IDs within the service to fractional
     * (0.000, 1] allocations of traffic for that version. Each version can
     * be specified only once, but some versions in the service may not
     * have any traffic allocation. Services that have traffic allocated
     * cannot be deleted until either the service is deleted or
     * their traffic allocation is removed. Allocations must sum to 1.
     * Up to two decimal place precision is supported for IP-based splits and
     * up to three decimal places is supported for cookie-based splits.
     *
     * Generated from protobuf field <code>map<string, double> allocations = 2;</code>
     * @param array|\Google\Protobuf\Internal\MapField $var
     * @return $this
     */
    public function setAllocations($var)
    {
        $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::DOUBLE);
        $this->allocations = $arr;

        return $this;
    }

}

