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

namespace Google\Cloud\Functions\V2\PBFunction;

use UnexpectedValueException;

/**
 * Describes the current state of the function.
 *
 * Protobuf type <code>google.cloud.functions.v2.Function.State</code>
 */
class State
{
    /**
     * Not specified. Invalid state.
     *
     * Generated from protobuf enum <code>STATE_UNSPECIFIED = 0;</code>
     */
    const STATE_UNSPECIFIED = 0;
    /**
     * Function has been successfully deployed and is serving.
     *
     * Generated from protobuf enum <code>ACTIVE = 1;</code>
     */
    const ACTIVE = 1;
    /**
     * Function deployment failed and the function is not serving.
     *
     * Generated from protobuf enum <code>FAILED = 2;</code>
     */
    const FAILED = 2;
    /**
     * Function is being created or updated.
     *
     * Generated from protobuf enum <code>DEPLOYING = 3;</code>
     */
    const DEPLOYING = 3;
    /**
     * Function is being deleted.
     *
     * Generated from protobuf enum <code>DELETING = 4;</code>
     */
    const DELETING = 4;
    /**
     * Function deployment failed and the function serving state is undefined.
     * The function should be updated or deleted to move it out of this state.
     *
     * Generated from protobuf enum <code>UNKNOWN = 5;</code>
     */
    const UNKNOWN = 5;

    private static $valueToName = [
        self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED',
        self::ACTIVE => 'ACTIVE',
        self::FAILED => 'FAILED',
        self::DEPLOYING => 'DEPLOYING',
        self::DELETING => 'DELETING',
        self::UNKNOWN => 'UNKNOWN',
    ];

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


