<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/ads/googleads/v16/errors/database_error.proto

namespace Google\Ads\GoogleAds\V16\Errors\DatabaseErrorEnum;

use UnexpectedValueException;

/**
 * Enum describing possible database errors.
 *
 * Protobuf type <code>google.ads.googleads.v16.errors.DatabaseErrorEnum.DatabaseError</code>
 */
class DatabaseError
{
    /**
     * Enum unspecified.
     *
     * Generated from protobuf enum <code>UNSPECIFIED = 0;</code>
     */
    const UNSPECIFIED = 0;
    /**
     * The received error code is not known in this version.
     *
     * Generated from protobuf enum <code>UNKNOWN = 1;</code>
     */
    const UNKNOWN = 1;
    /**
     * Multiple requests were attempting to modify the same resource at once.
     * Retry the request.
     *
     * Generated from protobuf enum <code>CONCURRENT_MODIFICATION = 2;</code>
     */
    const CONCURRENT_MODIFICATION = 2;
    /**
     * The request conflicted with existing data. This error will usually be
     * replaced with a more specific error if the request is retried.
     *
     * Generated from protobuf enum <code>DATA_CONSTRAINT_VIOLATION = 3;</code>
     */
    const DATA_CONSTRAINT_VIOLATION = 3;
    /**
     * The data written is too large. Split the request into smaller
     * requests.
     *
     * Generated from protobuf enum <code>REQUEST_TOO_LARGE = 4;</code>
     */
    const REQUEST_TOO_LARGE = 4;

    private static $valueToName = [
        self::UNSPECIFIED => 'UNSPECIFIED',
        self::UNKNOWN => 'UNKNOWN',
        self::CONCURRENT_MODIFICATION => 'CONCURRENT_MODIFICATION',
        self::DATA_CONSTRAINT_VIOLATION => 'DATA_CONSTRAINT_VIOLATION',
        self::REQUEST_TOO_LARGE => 'REQUEST_TOO_LARGE',
    ];

    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(DatabaseError::class, \Google\Ads\GoogleAds\V16\Errors\DatabaseErrorEnum_DatabaseError::class);

