// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Amazon.EC2.Model;
using Amazon.ECS.Model;
using AWS.Deploy.CLI.Extensions;
using AWS.Deploy.CLI.TypeHintResponses;
using AWS.Deploy.Common;
using AWS.Deploy.Common.Data;
using AWS.Deploy.Common.Recipes;
using AWS.Deploy.Common.TypeHintData;
using AWS.Deploy.Orchestration;
using AWS.Deploy.Orchestration.Data;
using Newtonsoft.Json;
namespace AWS.Deploy.CLI.Commands.TypeHints
{
///
/// The type hint orchestrates the VPC object in Elastic Beanstalk environments.
///
public class ElasticBeanstalkVpcCommand : ITypeHintCommand
{
private readonly IAWSResourceQueryer _awsResourceQueryer;
private readonly IConsoleUtilities _consoleUtilities;
private readonly IToolInteractiveService _toolInteractiveService;
private readonly IOptionSettingHandler _optionSettingHandler;
public ElasticBeanstalkVpcCommand(IAWSResourceQueryer awsResourceQueryer, IConsoleUtilities consoleUtilities, IToolInteractiveService toolInteractiveService, IOptionSettingHandler optionSettingHandler)
{
_awsResourceQueryer = awsResourceQueryer;
_consoleUtilities = consoleUtilities;
_toolInteractiveService = toolInteractiveService;
_optionSettingHandler = optionSettingHandler;
}
private async Task> GetData()
{
return await _awsResourceQueryer.GetListOfVpcs();
}
public async Task GetResources(Recommendation recommendation, OptionSettingItem optionSetting)
{
var vpcs = await GetData();
var resourceTable = new TypeHintResourceTable();
resourceTable.Rows = vpcs.ToDictionary(x => x.VpcId, x => x.GetDisplayableVpc()).Select(x => new TypeHintResource(x.Key, x.Value)).ToList();
return resourceTable;
}
public async Task