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

namespace Google\Cloud\Batch\V1\JobStatus;

use UnexpectedValueException;

/**
 * Valid Job states.
 *
 * Protobuf type <code>google.cloud.batch.v1.JobStatus.State</code>
 */
class State
{
    /**
     * Generated from protobuf enum <code>STATE_UNSPECIFIED = 0;</code>
     */
    const STATE_UNSPECIFIED = 0;
    /**
     * Job is admitted (validated and persisted) and waiting for resources.
     *
     * Generated from protobuf enum <code>QUEUED = 1;</code>
     */
    const QUEUED = 1;
    /**
     * Job is scheduled to run as soon as resource allocation is ready.
     * The resource allocation may happen at a later time but with a high
     * chance to succeed.
     *
     * Generated from protobuf enum <code>SCHEDULED = 2;</code>
     */
    const SCHEDULED = 2;
    /**
     * Resource allocation has been successful. At least one Task in the Job is
     * RUNNING.
     *
     * Generated from protobuf enum <code>RUNNING = 3;</code>
     */
    const RUNNING = 3;
    /**
     * All Tasks in the Job have finished successfully.
     *
     * Generated from protobuf enum <code>SUCCEEDED = 4;</code>
     */
    const SUCCEEDED = 4;
    /**
     * At least one Task in the Job has failed.
     *
     * Generated from protobuf enum <code>FAILED = 5;</code>
     */
    const FAILED = 5;
    /**
     * The Job will be deleted, but has not been deleted yet. Typically this is
     * because resources used by the Job are still being cleaned up.
     *
     * Generated from protobuf enum <code>DELETION_IN_PROGRESS = 6;</code>
     */
    const DELETION_IN_PROGRESS = 6;

    private static $valueToName = [
        self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED',
        self::QUEUED => 'QUEUED',
        self::SCHEDULED => 'SCHEDULED',
        self::RUNNING => 'RUNNING',
        self::SUCCEEDED => 'SUCCEEDED',
        self::FAILED => 'FAILED',
        self::DELETION_IN_PROGRESS => 'DELETION_IN_PROGRESS',
    ];

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


