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

namespace Google\Cloud\Compute\V1\NodeGroup;

use UnexpectedValueException;

/**
 * Specifies how to handle instances when a node in the group undergoes maintenance. Set to one of: DEFAULT, RESTART_IN_PLACE, or MIGRATE_WITHIN_NODE_GROUP. The default value is DEFAULT. For more information, see Maintenance policies.
 *
 * Protobuf type <code>google.cloud.compute.v1.NodeGroup.MaintenancePolicy</code>
 */
class MaintenancePolicy
{
    /**
     * A value indicating that the enum field is not set.
     *
     * Generated from protobuf enum <code>UNDEFINED_MAINTENANCE_POLICY = 0;</code>
     */
    const UNDEFINED_MAINTENANCE_POLICY = 0;
    /**
     * Allow the node and corresponding instances to retain default maintenance behavior.
     *
     * Generated from protobuf enum <code>DEFAULT = 115302945;</code>
     */
    const PBDEFAULT = 115302945;
    /**
     * Generated from protobuf enum <code>MAINTENANCE_POLICY_UNSPECIFIED = 72964182;</code>
     */
    const MAINTENANCE_POLICY_UNSPECIFIED = 72964182;
    /**
     * When maintenance must be done on a node, the instances on that node will be moved to other nodes in the group. Instances with onHostMaintenance = MIGRATE will live migrate to their destinations while instances with onHostMaintenance = TERMINATE will terminate and then restart on their destination nodes if automaticRestart = true.
     *
     * Generated from protobuf enum <code>MIGRATE_WITHIN_NODE_GROUP = 153483394;</code>
     */
    const MIGRATE_WITHIN_NODE_GROUP = 153483394;
    /**
     * Instances in this group will restart on the same node when maintenance has completed. Instances must have onHostMaintenance = TERMINATE, and they will only restart if automaticRestart = true.
     *
     * Generated from protobuf enum <code>RESTART_IN_PLACE = 228647325;</code>
     */
    const RESTART_IN_PLACE = 228647325;

    private static $valueToName = [
        self::UNDEFINED_MAINTENANCE_POLICY => 'UNDEFINED_MAINTENANCE_POLICY',
        self::PBDEFAULT => 'DEFAULT',
        self::MAINTENANCE_POLICY_UNSPECIFIED => 'MAINTENANCE_POLICY_UNSPECIFIED',
        self::MIGRATE_WITHIN_NODE_GROUP => 'MIGRATE_WITHIN_NODE_GROUP',
        self::RESTART_IN_PLACE => 'RESTART_IN_PLACE',
    ];

    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)) {
            $pbconst =  __CLASS__. '::PB' . strtoupper($name);
            if (!defined($pbconst)) {
                throw new UnexpectedValueException(sprintf(
                        'Enum %s has no value defined for name %s', __CLASS__, $name));
            }
            return constant($pbconst);
        }
        return constant($const);
    }
}


