public async Task <bool> Run() { Console.Write("Application name: "); var promptedApp = Console.ReadLine(); Console.WriteLine($"Environments for application {promptedApp}: "); var apps = await _client.ListApplicationsAsync(new ListApplicationsRequest()); var app = apps.Items.FirstOrDefault(x => x.Name == promptedApp); if (app == null) { Console.WriteLine($"Can't find application with name [{promptedApp}]"); return(false); } var envs = await _client.ListEnvironmentsAsync(new ListEnvironmentsRequest { ApplicationId = app.Id }); foreach (var env in envs.Items) { Console.WriteLine(env.Name); } return(false); }
public async Task <Environment> Get(string appId, string envName) { var envs = await _client.ListEnvironmentsAsync(new ListEnvironmentsRequest { ApplicationId = appId }); return(envs.Items.FirstOrDefault(x => x.Name == envName)); }
public async Task <Environment> AskEnvironment(Application application) { var envs = await _client.ListEnvironmentsAsync(new ListEnvironmentsRequest { ApplicationId = application.Id }); Console.Write($"Environment name (available, {string.Join(";", envs.Items.Select(x => $"[{x.Name}]"))}): "); var promptedEnv = Console.ReadLine(); var env = envs.Items.FirstOrDefault(x => x.Name == promptedEnv); if (env == null) { throw new Exception($"Can't find environment [{promptedEnv}] for application [{application.Name}]"); } return(env); }