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

namespace Google\Cloud\Dataproc\V1\InstanceGroupConfig;

use UnexpectedValueException;

/**
 * Controls the use of
 * [preemptible instances]
 * (https://cloud.google.com/compute/docs/instances/preemptible)
 * within the group.
 *
 * Protobuf type <code>google.cloud.dataproc.v1.InstanceGroupConfig.Preemptibility</code>
 */
class Preemptibility
{
    /**
     * Preemptibility is unspecified, the system will choose the
     * appropriate setting for each instance group.
     *
     * Generated from protobuf enum <code>PREEMPTIBILITY_UNSPECIFIED = 0;</code>
     */
    const PREEMPTIBILITY_UNSPECIFIED = 0;
    /**
     * Instances are non-preemptible.
     * This option is allowed for all instance groups and is the only valid
     * value for Master and Worker instance groups.
     *
     * Generated from protobuf enum <code>NON_PREEMPTIBLE = 1;</code>
     */
    const NON_PREEMPTIBLE = 1;
    /**
     * Instances are preemptible.
     * This option is allowed only for secondary worker groups.
     *
     * Generated from protobuf enum <code>PREEMPTIBLE = 2;</code>
     */
    const PREEMPTIBLE = 2;

    private static $valueToName = [
        self::PREEMPTIBILITY_UNSPECIFIED => 'PREEMPTIBILITY_UNSPECIFIED',
        self::NON_PREEMPTIBLE => 'NON_PREEMPTIBLE',
        self::PREEMPTIBLE => 'PREEMPTIBLE',
    ];

    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(Preemptibility::class, \Google\Cloud\Dataproc\V1\InstanceGroupConfig_Preemptibility::class);

