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

namespace Google\Cloud\Audit\BigQueryAuditMetadata\TableDataChange;

use UnexpectedValueException;

/**
 * Describes how the table data was changed.
 *
 * Protobuf type <code>google.cloud.audit.BigQueryAuditMetadata.TableDataChange.Reason</code>
 */
class Reason
{
    /**
     * Unknown.
     *
     * Generated from protobuf enum <code>REASON_UNSPECIFIED = 0;</code>
     */
    const REASON_UNSPECIFIED = 0;
    /**
     * Table was used as a job destination table.
     *
     * Generated from protobuf enum <code>JOB = 1;</code>
     */
    const JOB = 1;
    /**
     * Table data was updated using a DML or DDL query.
     *
     * Generated from protobuf enum <code>QUERY = 2;</code>
     */
    const QUERY = 2;
    /**
     * Table data was updated during a materialized view refresh.
     *
     * Generated from protobuf enum <code>MATERIALIZED_VIEW_REFRESH = 3;</code>
     */
    const MATERIALIZED_VIEW_REFRESH = 3;
    /**
     * Table data was added using the Write API.
     *
     * Generated from protobuf enum <code>WRITE_API = 4;</code>
     */
    const WRITE_API = 4;

    private static $valueToName = [
        self::REASON_UNSPECIFIED => 'REASON_UNSPECIFIED',
        self::JOB => 'JOB',
        self::QUERY => 'QUERY',
        self::MATERIALIZED_VIEW_REFRESH => 'MATERIALIZED_VIEW_REFRESH',
        self::WRITE_API => 'WRITE_API',
    ];

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


