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

namespace Google\Cloud\Build\V1\BuildStatus;

use UnexpectedValueException;

/**
 * The end result of the Build.
 *
 * Protobuf type <code>google.devtools.build.v1.BuildStatus.Result</code>
 */
class Result
{
    /**
     * Unspecified or unknown.
     *
     * Generated from protobuf enum <code>UNKNOWN_STATUS = 0;</code>
     */
    const UNKNOWN_STATUS = 0;
    /**
     * Build was successful and tests (if requested) all pass.
     *
     * Generated from protobuf enum <code>COMMAND_SUCCEEDED = 1;</code>
     */
    const COMMAND_SUCCEEDED = 1;
    /**
     * Build error and/or test failure.
     *
     * Generated from protobuf enum <code>COMMAND_FAILED = 2;</code>
     */
    const COMMAND_FAILED = 2;
    /**
     * Unable to obtain a result due to input provided by the user.
     *
     * Generated from protobuf enum <code>USER_ERROR = 3;</code>
     */
    const USER_ERROR = 3;
    /**
     * Unable to obtain a result due to a failure within the build system.
     *
     * Generated from protobuf enum <code>SYSTEM_ERROR = 4;</code>
     */
    const SYSTEM_ERROR = 4;
    /**
     * Build required too many resources, such as build tool RAM.
     *
     * Generated from protobuf enum <code>RESOURCE_EXHAUSTED = 5;</code>
     */
    const RESOURCE_EXHAUSTED = 5;
    /**
     * An invocation attempt time exceeded its deadline.
     *
     * Generated from protobuf enum <code>INVOCATION_DEADLINE_EXCEEDED = 6;</code>
     */
    const INVOCATION_DEADLINE_EXCEEDED = 6;
    /**
     * Build request time exceeded the request_deadline
     *
     * Generated from protobuf enum <code>REQUEST_DEADLINE_EXCEEDED = 8;</code>
     */
    const REQUEST_DEADLINE_EXCEEDED = 8;
    /**
     * The build was cancelled by a call to CancelBuild.
     *
     * Generated from protobuf enum <code>CANCELLED = 7;</code>
     */
    const CANCELLED = 7;

    private static $valueToName = [
        self::UNKNOWN_STATUS => 'UNKNOWN_STATUS',
        self::COMMAND_SUCCEEDED => 'COMMAND_SUCCEEDED',
        self::COMMAND_FAILED => 'COMMAND_FAILED',
        self::USER_ERROR => 'USER_ERROR',
        self::SYSTEM_ERROR => 'SYSTEM_ERROR',
        self::RESOURCE_EXHAUSTED => 'RESOURCE_EXHAUSTED',
        self::INVOCATION_DEADLINE_EXCEEDED => 'INVOCATION_DEADLINE_EXCEEDED',
        self::REQUEST_DEADLINE_EXCEEDED => 'REQUEST_DEADLINE_EXCEEDED',
        self::CANCELLED => 'CANCELLED',
    ];

    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(Result::class, \Google\Cloud\Build\V1\BuildStatus_Result::class);

