using System; using System.Collections.Generic; using System.IO; using System.Text; using Amazon.Lambda.Tools.Commands; using ThirdParty.Json.LitJson; using YamlDotNet.RepresentationModel; namespace Amazon.Lambda.Tools.TemplateProcessor { public enum CodeUploadType { Zip, Image} /// /// Interface to iterate over the CloudFormation resources that can be updated. /// public interface ITemplateParser { /// /// Iterator for the updatable resources. /// /// IEnumerable UpdatableResources(); /// /// Get the new template after the resources have been updated. /// /// string GetUpdatedTemplate(); } /// /// Interface for a CloudFormation resource that can be updated. /// public interface IUpdatableResource { /// /// The CloudFormation name of the resource. /// string Name { get; } /// /// The CloudFormation resource type. /// string ResourceType { get; } /// /// If the resource is a AWS::Lambda::Function or AWS::Serverless::Function get the Lambda runtime for it. /// string LambdaRuntime { get; } /// /// If the resource is a AWS::Lambda::Function or AWS::Serverless::Function get the Lambda architecture for it. /// string LambdaArchitecture { get; } /// /// Gets the list of layers specified if this is a Lambda function. /// /// string[] LambdaLayers { get; } /// /// The list of fields that can be updated. /// IList Fields { get; } /// /// Sets an environment variable for the resource. /// /// /// void SetEnvironmentVariable(string key, string value); /// /// Indicates whether the code should be uploaded to S3 as a zip or built as an image and pushed to ECR. /// CodeUploadType UploadType { get; } } /// /// Interface for the field in the IUpdatableResource that can be updated. /// public interface IUpdateResourceField { /// /// Gets the name of the field. /// string Name { get; } /// /// True if the field should contain code like a Lambda package bundle. /// bool IsCode { get; } /// /// True if the field points to an Image already pushed in ECR. /// bool IsImagePushed { get; } /// /// Reference back to the containing updatable resource. /// IUpdatableResource Resource { get; } /// /// Gets the local path for the resource. If the value is referencing an object in S3 then this returns null. /// /// string GetLocalPath(); /// /// Updates the location the field is pointing to where the local path was uploaded to S3. /// /// /// void SetS3Location(string s3Bucket, string s3Key); /// /// Sets the image uri on the resource. /// /// void SetImageUri(string imageUri); /// /// Gets the name of the Dockerfile specified for an AWS::Serverless::Function /// /// string GetMetadataDockerfile(); /// /// Gets the Docker image tag specified for an AWS::Serverless::Function /// /// string GetMetadataDockerTag(); /// /// Gets the Docker build args specified for an AWS::Serverless::Function /// /// Dictionary GetMetadataDockerBuildArgs(); } /// /// Interface for the underlying datasource (JSON or YAML), /// public interface IUpdatableResourceDataSource { /// /// Gets value starting from the root document. /// /// /// string GetValueFromRoot(params string[] keyPath); /// /// Gets the values for a list starting from the root document. /// /// /// string[] GetValueListFromRoot(params string[] keyPath); /// /// Gets the value starting from the resource node. /// /// /// string GetValueFromResource(params string[] keyPath); /// /// Gets value in datasource. /// /// /// string GetValue(params string[] keyPath); /// /// Set value in datasource. /// /// /// void SetValue(string value, params string[] keyPath); /// /// Gets the values for a list property. /// /// /// string[] GetValueList(params string[] keyPath); Dictionary GetValueDictionaryFromResource(params string[] keyPath); } }