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

namespace Google\Cloud\Compute\V1\TargetPool;

use UnexpectedValueException;

/**
 * Session affinity option, must be one of the following values:
 * NONE: Connections from the same client IP may go to any instance in the pool.
 * CLIENT_IP: Connections from the same client IP will go to the same instance in the pool while that instance remains healthy.
 * CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol will go to the same instance in the pool while that instance remains healthy.
 *
 * Protobuf type <code>google.cloud.compute.v1.TargetPool.SessionAffinity</code>
 */
class SessionAffinity
{
    /**
     * A value indicating that the enum field is not set.
     *
     * Generated from protobuf enum <code>UNDEFINED_SESSION_AFFINITY = 0;</code>
     */
    const UNDEFINED_SESSION_AFFINITY = 0;
    /**
     * Generated from protobuf enum <code>CLIENT_IP = 77229595;</code>
     */
    const CLIENT_IP = 77229595;
    /**
     * Generated from protobuf enum <code>CLIENT_IP_PORT_PROTO = 221722926;</code>
     */
    const CLIENT_IP_PORT_PROTO = 221722926;
    /**
     * Generated from protobuf enum <code>CLIENT_IP_PROTO = 25322148;</code>
     */
    const CLIENT_IP_PROTO = 25322148;
    /**
     * Generated from protobuf enum <code>GENERATED_COOKIE = 101885748;</code>
     */
    const GENERATED_COOKIE = 101885748;
    /**
     * Generated from protobuf enum <code>HEADER_FIELD = 200737960;</code>
     */
    const HEADER_FIELD = 200737960;
    /**
     * Generated from protobuf enum <code>HTTP_COOKIE = 226546171;</code>
     */
    const HTTP_COOKIE = 226546171;
    /**
     * Generated from protobuf enum <code>NONE = 2402104;</code>
     */
    const NONE = 2402104;

    private static $valueToName = [
        self::UNDEFINED_SESSION_AFFINITY => 'UNDEFINED_SESSION_AFFINITY',
        self::CLIENT_IP => 'CLIENT_IP',
        self::CLIENT_IP_PORT_PROTO => 'CLIENT_IP_PORT_PROTO',
        self::CLIENT_IP_PROTO => 'CLIENT_IP_PROTO',
        self::GENERATED_COOKIE => 'GENERATED_COOKIE',
        self::HEADER_FIELD => 'HEADER_FIELD',
        self::HTTP_COOKIE => 'HTTP_COOKIE',
        self::NONE => 'NONE',
    ];

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


