
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
//
// Changes to this file may cause incorrect behavior and will be lost when
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
namespace HathoraCloud.Models.Shared
{
    using Newtonsoft.Json;
    using System;
    using UnityEngine;
    
    /// <summary>
    /// A plan defines how much CPU and memory is required to run an instance of your game server.<br/>
    /// 
    /// <remarks>
    /// <br/>
    /// `tiny`: shared core, 1gb memory<br/>
    /// <br/>
    /// `small`: 1 core, 2gb memory<br/>
    /// <br/>
    /// `medium`: 2 core, 4gb memory<br/>
    /// <br/>
    /// `large`: 4 core, 8gb memory
    /// </remarks>
    /// </summary>
    public enum PlanName
    {
        [JsonProperty("tiny")]
        Tiny,
        [JsonProperty("small")]
        Small,
        [JsonProperty("medium")]
        Medium,
        [JsonProperty("large")]
        Large,
    }

    public static class PlanNameExtension
    {
        public static string Value(this PlanName value)
        {
            return ((JsonPropertyAttribute)value.GetType().GetMember(value.ToString())[0].GetCustomAttributes(typeof(JsonPropertyAttribute), false)[0]).PropertyName ?? value.ToString();
        }

        public static PlanName ToEnum(this string value)
        {
            foreach(var field in typeof(PlanName).GetFields())
            {
                var attributes = field.GetCustomAttributes(typeof(JsonPropertyAttribute), false);
                if (attributes.Length == 0)
                {
                    continue;
                }

                var attribute = attributes[0] as JsonPropertyAttribute;
                if (attribute != null && attribute.PropertyName == value)
                {
                    return (PlanName)field.GetValue(null);
                }
            }

            throw new Exception($"Unknown value {value} for enum PlanName");
        }
    }

}