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

namespace Google\Cloud\DatabaseCenter\V1beta;

use UnexpectedValueException;

/**
 * OperationErrorType is used to expose specific error type which can happen in
 * database resource while performing an operation. For example, an error can
 * happen while database resource being backed up.
 *
 * Protobuf type <code>google.cloud.databasecenter.v1beta.OperationErrorType</code>
 */
class OperationErrorType
{
    /**
     * UNSPECIFIED means operation error type is not known or available.
     *
     * Generated from protobuf enum <code>OPERATION_ERROR_TYPE_UNSPECIFIED = 0;</code>
     */
    const OPERATION_ERROR_TYPE_UNSPECIFIED = 0;
    /**
     * Key destroyed, expired, not found, unreachable or permission denied.
     *
     * Generated from protobuf enum <code>KMS_KEY_ERROR = 1;</code>
     */
    const KMS_KEY_ERROR = 1;
    /**
     * Database is not accessible.
     *
     * Generated from protobuf enum <code>DATABASE_ERROR = 2;</code>
     */
    const DATABASE_ERROR = 2;
    /**
     * The zone or region does not have sufficient resources to handle the request
     * at the moment.
     *
     * Generated from protobuf enum <code>STOCKOUT_ERROR = 3;</code>
     */
    const STOCKOUT_ERROR = 3;
    /**
     * User initiated cancellation.
     *
     * Generated from protobuf enum <code>CANCELLATION_ERROR = 4;</code>
     */
    const CANCELLATION_ERROR = 4;
    /**
     * SQL server specific error.
     *
     * Generated from protobuf enum <code>SQLSERVER_ERROR = 5;</code>
     */
    const SQLSERVER_ERROR = 5;
    /**
     * Any other internal error.
     *
     * Generated from protobuf enum <code>INTERNAL_ERROR = 6;</code>
     */
    const INTERNAL_ERROR = 6;

    private static $valueToName = [
        self::OPERATION_ERROR_TYPE_UNSPECIFIED => 'OPERATION_ERROR_TYPE_UNSPECIFIED',
        self::KMS_KEY_ERROR => 'KMS_KEY_ERROR',
        self::DATABASE_ERROR => 'DATABASE_ERROR',
        self::STOCKOUT_ERROR => 'STOCKOUT_ERROR',
        self::CANCELLATION_ERROR => 'CANCELLATION_ERROR',
        self::SQLSERVER_ERROR => 'SQLSERVER_ERROR',
        self::INTERNAL_ERROR => 'INTERNAL_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);
    }
}

