// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
using System;
using System.Collections.Generic;
using AWS.Deploy.Common.Recipes;
namespace AWS.Deploy.Common
{
///
/// Contains CloudFormation specific configurations
///
public class CloudApplication
{
private readonly Dictionary _resourceTypeMapping =
new()
{
{ CloudApplicationResourceType.CloudFormationStack, "CloudFormation Stack" },
{ CloudApplicationResourceType.BeanstalkEnvironment, "Elastic Beanstalk Environment" },
{ CloudApplicationResourceType.ElasticContainerRegistryImage, "ECR Repository" }
};
private readonly Dictionary _deploymentTypeMapping =
new()
{
{ CloudApplicationResourceType.CloudFormationStack, DeploymentTypes.CdkProject},
{ CloudApplicationResourceType.BeanstalkEnvironment, DeploymentTypes.BeanstalkEnvironment },
{ CloudApplicationResourceType.ElasticContainerRegistryImage, DeploymentTypes.ElasticContainerRegistryImage }
};
///
/// Name of the CloudApplication resource
///
public string Name { get; set; }
///
/// The unique Id to identify the CloudApplication.
/// The ID is set to the StackId if the CloudApplication is an existing Cloudformation stack.
/// The ID is set to the EnvironmentId if the CloudApplication is an existing Elastic Beanstalk environment.
/// The ID is set to string.Empty for new CloudApplications.
///
public string UniqueIdentifier { get; set; }
///
/// The id of the AWS .NET deployment tool recipe used to create or re-deploy the cloud application.
///
public string RecipeId { get; set; }
///
/// Indicates the type of the AWS resource which serves as the deployment target.
///
public CloudApplicationResourceType ResourceType { get; set; }
///
/// Last updated time of CloudFormation stack
///
public DateTime? LastUpdatedTime { get; set; }
///
/// Indicates whether the Cloud Application has been redeployed by the current user.
///
public bool UpdatedByCurrentUser { get; set; }
///
/// This name is shown to the user when the CloudApplication is presented as an existing re-deployment target.
///
public string DisplayName => $"{Name} ({_resourceTypeMapping[ResourceType]})";
///
/// Display the name of the Cloud Application
///
public override string ToString() => Name;
///
/// Gets the deployment type of the recommendation that was used to deploy the cloud application.
///
public DeploymentTypes DeploymentType => _deploymentTypeMapping[ResourceType];
public CloudApplication(string name, string uniqueIdentifier, CloudApplicationResourceType resourceType, string recipeId, DateTime? lastUpdatedTime = null)
{
Name = name;
UniqueIdentifier = uniqueIdentifier;
ResourceType = resourceType;
RecipeId = recipeId;
LastUpdatedTime = lastUpdatedTime;
}
}
}