public GameServerManager(UnrealTournamentBuild.UnrealTournamentAppName InAppName, string InS3BucketName, string InBuildString, bool InDebug = false)
        {
            this.GameName       = "unrealtournament";
            this.GameNameShort  = "ut";
            this.AppName        = InAppName;
            this.S3BucketName   = InS3BucketName;
            this.BuildString    = InBuildString;
            this.Debug          = InDebug;
            this.InstallSumo    = "true";
            this.GameBinaryPath = "Engine/Binaries/Linux";
            this.GameLogPath    = "/UnrealTournament/Saved/Logs";
            this.GameSavedPath  = "/UnrealTournament/Saved";
            this.MaxMatchLength = 0;          /* value is in seconds. 0 disables ttl */
            this.TtlInterval    = 0;          /* idle server refresh time in seconds.  0 disables ttl*/
            this.GameBinary     = "UE4Server-Linux-Shipping";
            this.CpuBudget      = 33;
            this.RamBudget      = 55;

            FEngineVersionSupport ParsedVersion = FEngineVersionSupport.FromString(InBuildString, bAllowNoVersion: true);

            this.Changelist = ParsedVersion.Changelist;

            if (this.Debug)
            {
                this.D2BaseUri = "https://fleet-manager-ci.ol.epicgames.net:8080/v1/";
            }
            else if (AppName == UnrealTournamentBuild.UnrealTournamentAppName.UnrealTournamentDevStage ||
                     AppName == UnrealTournamentBuild.UnrealTournamentAppName.UnrealTournamentDevPlaytest ||
                     AppName == UnrealTournamentBuild.UnrealTournamentAppName.UnrealTournamentPublicTest)
            {
                this.D2BaseUri = "https://fleet-manager-stage.ol.epicgames.net:8080/v1/";
            }
            else
            {
                this.D2BaseUri = "https://fleet-manager.ol.epicgames.net:8080/v1/";
            }

            switch (AppName)
            {
            case UnrealTournamentBuild.UnrealTournamentAppName.UnrealTournamentDev:
            case UnrealTournamentBuild.UnrealTournamentAppName.UnrealTournamentPublicTest:
                this.GameBinary = "UE4Server-Linux-Shipping";
                break;

            case UnrealTournamentBuild.UnrealTournamentAppName.UnrealTournamentDevPlaytest:
                this.GameBinary = "UE4Server-Linux-Test";
                break;

            default:
                this.GameBinary = "UE4Server-Linux-Shipping";
                break;
            }

            Random rnd = new Random();

            this.AsyncId = rnd.Next();
        }
        private String GetTag(UnrealTournamentBuild.UnrealTournamentAppName InAppName, String InRegion, String InTag)
        {
            string AppEnvironment = InAppName.ToString().Substring(GameName.Length);

            string Tag = String.Format("{0}{1}{2}",
                                       AppEnvironment,
                                       InRegion,
                                       InTag
                                       );

            if (Debug == true)
            {
                Tag = Tag + "debug";
            }
            return(Tag);
        }
        private string Deployment2GceArgs(string tag                   = "",
                                          string MachineType           = "n1-standard-16",
                                          string Zone                  = "us-central1-a",
                                          string Region                = "NA",
                                          int InstanceSize             = 1,
                                          int InstanceSizeMin          = 1,
                                          int InstanceSizeMax          = 6,
                                          string AutoscalerId          = "default",
                                          string ExtraCliArgs          = "",
                                          string AppNameStringOverride = "",
                                          string HubServerName         = "")
        {
            int LocalCpuBudget = CpuBudget;

            UnrealTournamentBuild.UnrealTournamentAppName LocalAppName = AppName;
            if (!String.IsNullOrEmpty(AppNameStringOverride))
            {
                if (!Enum.IsDefined(typeof(UnrealTournamentBuild.UnrealTournamentAppName), AppNameStringOverride))
                {
                    throw new AutomationException("Trying to override AppName to non-existant type: " + AppNameStringOverride);
                }
                LocalAppName = (UnrealTournamentBuild.UnrealTournamentAppName)Enum.Parse(typeof(UnrealTournamentBuild.UnrealTournamentAppName), AppNameStringOverride);
                CommandUtils.Log("Overriding AppName from {0} to {1}", AppName, LocalAppName);
            }

            string NetworkId       = "default";
            string CredentialsFile = "GceUtDevCredentials.txt";

            /* This is very confusing. UnrealTournament's live lable is UnrealTournamentDev. */
            if (LocalAppName == UnrealTournamentBuild.UnrealTournamentAppName.UnrealTournamentDev)
            {
                NetworkId       = "unreal-tournament";
                CredentialsFile = "GceUtLiveCredentials.txt";
            }

            if (InstanceSize == 0)
            {
                InstanceSizeMin = 0;
                InstanceSizeMax = 0;
            }
            else if (InstanceSizeMin > InstanceSize)
            {
                InstanceSize = InstanceSizeMin;
            }

            string         CredentialsFilePath           = GetUtilitiesFilePath(CredentialsFile);
            string         CredentialsFileContentsBase64 = ReadFileContents(CredentialsFilePath);
            string         CredentialsFileContents       = ConvertFromBase64(CredentialsFileContentsBase64);
            GceCredentials gceCredentials = GceCredentialsFromJson(CredentialsFileContents);

            string HTTPCredentialsFilePath = GetUtilitiesFilePath("DeployerAuthBase64.txt");

            if (File.Exists(HTTPCredentialsFilePath))
            {
                string HTTPCredentialsFileContentsBase64 = ReadFileContents(HTTPCredentialsFilePath);
                HTTPAuthBase64 = HTTPCredentialsFileContentsBase64;
            }

            Byte[] CliArgBytes;
            if (HubServerName != "")
            {
                CliArgBytes    = System.Text.Encoding.UTF8.GetBytes("UnrealTournament ut-entry?game=lobby?ServerName=\"" + HubServerName + "\" -nocore -epicapp=" + LocalAppName.ToString() + " " + ExtraCliArgs);
                LocalCpuBudget = 32000;
            }
            else
            {
                CliArgBytes = System.Text.Encoding.UTF8.GetBytes("UnrealTournament ut-entry?game=empty?region=" + Region + " -epicapp=" + LocalAppName.ToString() + " " + ExtraCliArgs);
            }
            Byte[] BuildStringBytes = System.Text.Encoding.UTF8.GetBytes(BuildString);
            string CloudArgs        = "epic_game_name=" + GameNameShort + "&" +
                                      "epic_game_binary=" + this.GameBinary + "&" +
                                      "epic_game_binary_path=" + this.GameBinaryPath + "&" +
                                      "epic_game_log_path=" + this.GameLogPath + "&" +
                                      "epic_game_saved_path=" + this.GameSavedPath + "&" +
                                      "epic_game_max_match_length=" + this.MaxMatchLength.ToString() + "&" +
                                      "epic_game_ttl_interval=" + this.TtlInterval.ToString() + "&" +
                                      "epic_install_sumo=" + this.InstallSumo + "&" +
                                      "epic_game_tag=" + GetTag(LocalAppName, Region, tag) + "&" +
                                      "epic_game_version=" + Changelist.ToString() + "&" +
                                      "epic_game_region=" + Region + "&" +
                                      "epic_game_cpu_budget=" + LocalCpuBudget + "&" +
                                      "epic_game_ram_budget=" + RamBudget + "&" +
                                      "epic_game_buildstr_base64=" + System.Convert.ToBase64String(BuildStringBytes) + "&" +
                                      "epic_game_environment=" + LocalAppName.ToString() + "&" +
                                      "epic_instance_size=" + InstanceSize.ToString() + "&" +
                                      "epic_instance_min=" + InstanceSizeMin.ToString() + "&" +
                                      "epic_instance_max=" + InstanceSizeMax.ToString() + "&" +
                                      "epic_autoscaler_id=" + AutoscalerId + "&" +
                                      "epic_gce_project_id=" + gceCredentials.project_id + "&" +
                                      "epic_gce_base64_credentials=" + CredentialsFileContentsBase64 + "&" +
                                      "epic_gce_machine_type=" + MachineType + "&" +
                                      "epic_gce_network=" + NetworkId + "&" +
                                      "epic_gce_zone=" + Zone + "&" +
                                      "epic_game_base64_cli_args=" + System.Convert.ToBase64String(CliArgBytes);

            return(CloudArgs);
        }