<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/spanner/admin/instance/v1/spanner_instance_admin.proto

namespace Google\Cloud\Spanner\Admin\Instance\V1\ReplicaInfo;

use UnexpectedValueException;

/**
 * Indicates the type of replica.  See the [replica types
 * documentation](https://cloud.google.com/spanner/docs/replication#replica_types)
 * for more details.
 *
 * Protobuf type <code>google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType</code>
 */
class ReplicaType
{
    /**
     * Not specified.
     *
     * Generated from protobuf enum <code>TYPE_UNSPECIFIED = 0;</code>
     */
    const TYPE_UNSPECIFIED = 0;
    /**
     * Read-write replicas support both reads and writes. These replicas:
     * * Maintain a full copy of your data.
     * * Serve reads.
     * * Can vote whether to commit a write.
     * * Participate in leadership election.
     * * Are eligible to become a leader.
     *
     * Generated from protobuf enum <code>READ_WRITE = 1;</code>
     */
    const READ_WRITE = 1;
    /**
     * Read-only replicas only support reads (not writes). Read-only replicas:
     * * Maintain a full copy of your data.
     * * Serve reads.
     * * Do not participate in voting to commit writes.
     * * Are not eligible to become a leader.
     *
     * Generated from protobuf enum <code>READ_ONLY = 2;</code>
     */
    const READ_ONLY = 2;
    /**
     * Witness replicas don't support reads but do participate in voting to
     * commit writes. Witness replicas:
     * * Do not maintain a full copy of data.
     * * Do not serve reads.
     * * Vote whether to commit writes.
     * * Participate in leader election but are not eligible to become leader.
     *
     * Generated from protobuf enum <code>WITNESS = 3;</code>
     */
    const WITNESS = 3;

    private static $valueToName = [
        self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED',
        self::READ_WRITE => 'READ_WRITE',
        self::READ_ONLY => 'READ_ONLY',
        self::WITNESS => 'WITNESS',
    ];

    public static function name($value)
    {
        if (!isset(self::$valueToName[$value])) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no name defined for value %s', __CLASS__, $value));
        }
        return self::$valueToName[$value];
    }


    public static function value($name)
    {
        $const = __CLASS__ . '::' . strtoupper($name);
        if (!defined($const)) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no value defined for name %s', __CLASS__, $name));
        }
        return constant($const);
    }
}

// Adding a class alias for backwards compatibility with the previous class name.
class_alias(ReplicaType::class, \Google\Cloud\Spanner\Admin\Instance\V1\ReplicaInfo_ReplicaType::class);

