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

namespace Google\Cloud\Memorystore\V1\CrossInstanceReplicationConfig;

use UnexpectedValueException;

/**
 * The role of the instance in cross instance replication.
 *
 * Protobuf type <code>google.cloud.memorystore.v1.CrossInstanceReplicationConfig.InstanceRole</code>
 */
class InstanceRole
{
    /**
     * instance role is not set.
     * The behavior is equivalent to NONE.
     *
     * Generated from protobuf enum <code>INSTANCE_ROLE_UNSPECIFIED = 0;</code>
     */
    const INSTANCE_ROLE_UNSPECIFIED = 0;
    /**
     * This instance does not participate in cross instance replication. It is
     * an independent instance and does not replicate to or from any other
     * instances.
     *
     * Generated from protobuf enum <code>NONE = 1;</code>
     */
    const NONE = 1;
    /**
     * A instance that allows both reads and writes. Any data written to this
     * instance is also replicated to the attached secondary instances.
     *
     * Generated from protobuf enum <code>PRIMARY = 2;</code>
     */
    const PRIMARY = 2;
    /**
     * A instance that allows only reads and replicates data from a primary
     * instance.
     *
     * Generated from protobuf enum <code>SECONDARY = 3;</code>
     */
    const SECONDARY = 3;

    private static $valueToName = [
        self::INSTANCE_ROLE_UNSPECIFIED => 'INSTANCE_ROLE_UNSPECIFIED',
        self::NONE => 'NONE',
        self::PRIMARY => 'PRIMARY',
        self::SECONDARY => 'SECONDARY',
    ];

    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);
    }
}


