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

namespace Google\Cloud\Datastore\Admin\V1\Index;

use UnexpectedValueException;

/**
 * The possible set of states of an index.
 *
 * Protobuf type <code>google.datastore.admin.v1.Index.State</code>
 */
class State
{
    /**
     * The state is unspecified.
     *
     * Generated from protobuf enum <code>STATE_UNSPECIFIED = 0;</code>
     */
    const STATE_UNSPECIFIED = 0;
    /**
     * The index is being created, and cannot be used by queries.
     * There is an active long-running operation for the index.
     * The index is updated when writing an entity.
     * Some index data may exist.
     *
     * Generated from protobuf enum <code>CREATING = 1;</code>
     */
    const CREATING = 1;
    /**
     * The index is ready to be used.
     * The index is updated when writing an entity.
     * The index is fully populated from all stored entities it applies to.
     *
     * Generated from protobuf enum <code>READY = 2;</code>
     */
    const READY = 2;
    /**
     * The index is being deleted, and cannot be used by queries.
     * There is an active long-running operation for the index.
     * The index is not updated when writing an entity.
     * Some index data may exist.
     *
     * Generated from protobuf enum <code>DELETING = 3;</code>
     */
    const DELETING = 3;
    /**
     * The index was being created or deleted, but something went wrong.
     * The index cannot by used by queries.
     * There is no active long-running operation for the index,
     * and the most recently finished long-running operation failed.
     * The index is not updated when writing an entity.
     * Some index data may exist.
     *
     * Generated from protobuf enum <code>ERROR = 4;</code>
     */
    const ERROR = 4;

    private static $valueToName = [
        self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED',
        self::CREATING => 'CREATING',
        self::READY => 'READY',
        self::DELETING => 'DELETING',
        self::ERROR => 'ERROR',
    ];

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

