Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch events #328

Merged
merged 4 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Libraries/Libraries.sln
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellTests", "test\Pow
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellScriptsAsFunctions", "test\TestPowerShellFunctions\PowerShellScriptsAsFunctions\PowerShellScriptsAsFunctions.csproj", "{0AD1E5D6-AC23-47C1-97BF-227007021B6F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.Lambda.CloudWatchEvents", "src\Amazon.Lambda.CloudWatchEvents\Amazon.Lambda.CloudWatchEvents.csproj", "{AD96AA48-2E1A-4BBB-9329-E1E484172FE3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -203,6 +205,10 @@ Global
{0AD1E5D6-AC23-47C1-97BF-227007021B6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0AD1E5D6-AC23-47C1-97BF-227007021B6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0AD1E5D6-AC23-47C1-97BF-227007021B6F}.Release|Any CPU.Build.0 = Release|Any CPU
{AD96AA48-2E1A-4BBB-9329-E1E484172FE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD96AA48-2E1A-4BBB-9329-E1E484172FE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD96AA48-2E1A-4BBB-9329-E1E484172FE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD96AA48-2E1A-4BBB-9329-E1E484172FE3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -240,6 +246,7 @@ Global
{ADEC039D-0C34-4DA7-802B-6204FFE3F1F5} = {1DE4EE60-45BA-4EF7-BE00-B9EB861E4C69}
{997B1047-4361-4E6D-9850-F130EC188141} = {1DE4EE60-45BA-4EF7-BE00-B9EB861E4C69}
{0AD1E5D6-AC23-47C1-97BF-227007021B6F} = {ADEC039D-0C34-4DA7-802B-6204FFE3F1F5}
{AD96AA48-2E1A-4BBB-9329-E1E484172FE3} = {AAB54E74-20B1-42ED-BC3D-CE9F7BC7FD12}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {503678A4-B8D1-4486-8915-405A3E9CF0EB}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\..\..\buildtools\common.props" />

<PropertyGroup>
<TargetFramework>netstandard1.3</TargetFramework>
<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
<Description>Amazon Lambda .NET Core support - CloudWatchEvents package.</Description>
<AssemblyTitle>Amazon.Lambda.CloudWatchEvents</AssemblyTitle>
<VersionPrefix>1.0.0</VersionPrefix>
<AssemblyName>Amazon.Lambda.CloudWatchEvents</AssemblyName>
<PackageId>Amazon.Lambda.CloudWatchEvents</PackageId>
<PackageTags>AWS;Amazon;Lambda</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Runtime" Version="4.1.0" />
</ItemGroup>

<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\newtonsoft.json\10.0.1\lib\netstandard1.3\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections.Generic;

namespace Amazon.Lambda.CloudWatchEvents.BatchEvents
{
/// <summary>
/// An object representing the array properties of a job.
/// https://docs.aws.amazon.com/batch/latest/APIReference/API_ArrayPropertiesDetail.html
/// </summary>
public class ArrayPropertiesDetail
{
/// <summary>
/// The job index within the array that is associated with this job.
/// This parameter is returned for array job children.
/// </summary>
public int Index { get; set; }

/// <summary>
/// The size of the array job. This parameter is returned for parent array jobs.
/// </summary>
public int Size { get; set; }

/// <summary>
/// A summary of the number of array job children in each available job status.
/// This parameter is returned for parent array jobs.
/// </summary>
public Dictionary<string, int> StatusSummary { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Amazon.Lambda.CloudWatchEvents.BatchEvents
{
/// <summary>
/// An object representing the details of a container that is part of a job attempt.
/// https://docs.aws.amazon.com/batch/latest/APIReference/API_AttemptContainerDetail.html
/// </summary>
public class AttemptContainerDetail
{
/// <summary>
/// The Amazon Resource Name (ARN) of the Amazon ECS container instance that hosts the job attempt.
/// </summary>
public string ContainerInstanceArn { get; set; }

/// <summary>
/// The exit code for the job attempt. A non-zero exit code is considered a failure.
/// </summary>
public int ExitCode { get; set; }

/// <summary>
/// The name of the CloudWatch Logs log stream associated with the container. The log group for
/// AWS Batch jobs is /aws/batch/job. Each container attempt receives a log stream name when
/// they reach the RUNNING status.
/// </summary>
public string LogStreamName { get; set; }

/// <summary>
/// A short (255 max characters) human-readable string to provide additional
/// details about a running or stopped container.
/// </summary>
public string Reason { get; set; }

/// <summary>
/// The Amazon Resource Name (ARN) of the Amazon ECS task that is associated with the job attempt.
/// Each container attempt receives a task ARN when they reach the STARTING status.
/// </summary>
public string TaskArn { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace Amazon.Lambda.CloudWatchEvents.BatchEvents
{
/// <summary>
/// An object representing a job attempt.
/// https://docs.aws.amazon.com/batch/latest/APIReference/API_AttemptDetail.html
/// </summary>
public class AttemptDetail
{
/// <summary>
/// Details about the container in this job attempt.
/// </summary>
public AttemptContainerDetail Container { get; set; }

/// <summary>
/// The Unix time stamp (in seconds and milliseconds) for when the attempt was started
/// (when the attempt transitioned from the STARTING state to the RUNNING state).
/// </summary>
public long StartedAt { get; set; }

/// <summary>
/// A short, human-readable string to provide additional details about the current status of the job attempt.
/// </summary>
public string StatusReason { get; set; }

/// <summary>
/// The Unix time stamp (in seconds and milliseconds) for when the attempt was stopped
/// (when the attempt transitioned from the RUNNING state to a terminal state, such as SUCCEEDED or FAILED).
/// </summary>
public long StoppedAt { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Amazon.Lambda.CloudWatchEvents.BatchEvents
{
/// <summary>
/// AWS Batch Event
/// https://docs.aws.amazon.com/batch/latest/userguide/batch_cwe_events.html
/// </summary>
public class BatchJobStateChangeEvent : CloudWatchEvent<Job>
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
using System.Collections.Generic;

namespace Amazon.Lambda.CloudWatchEvents.BatchEvents
{
/// <summary>
/// An object representing the details of a container that is part of a job.
/// https://docs.aws.amazon.com/batch/latest/APIReference/API_ContainerDetail.html
/// </summary>
public class ContainerDetail
{
/// <summary>
/// The command that is passed to the container.
/// </summary>
public List<string> Command { get; set; }

/// <summary>
/// The Amazon Resource Name (ARN) of the container instance on which the container is running.
/// </summary>
public string ContainerInstanceArn { get; set; }

/// <summary>
/// The environment variables to pass to a container.
/// Note: Environment variables must not start with AWS_BATCH; this naming convention is reserved
/// for variables that are set by the AWS Batch service.
/// </summary>
public List<KeyValuePair<string, string>> Environment { get; set; }

/// <summary>
/// The exit code to return upon completion.
/// </summary>
public int ExitCode { get; set; }

/// <summary>
/// The image used to start the container.
/// </summary>
public string Image { get; set; }

/// <summary>
/// The Amazon Resource Name (ARN) associated with the job upon execution.
/// </summary>
public string JobRoleArn { get; set; }

/// <summary>
/// The name of the CloudWatch Logs log stream associated with the container.
/// The log group for AWS Batch jobs is /aws/batch/job. Each container attempt receives a
/// log stream name when they reach the RUNNING status.
/// </summary>
public string LogStreamName { get; set; }

/// <summary>
/// The number of MiB of memory reserved for the job.
/// </summary>
public int Memory { get; set; }

/// <summary>
/// The mount points for data volumes in your container.
/// </summary>
public List<MountPoint> MountPoints { get; set; }

/// <summary>
/// When this parameter is true, the container is given elevated privileges on the
/// host container instance (similar to the root user).
/// </summary>
public bool Privileged { get; set; }

/// <summary>
/// When this parameter is true, the container is given read-only access to its root file system.
/// </summary>
public bool ReadonlyRootFilesystem { get; set; }

/// <summary>
/// A short (255 max characters) human-readable string to provide additional
/// details about a running or stopped container.
/// </summary>
public string Reason { get; set; }

/// <summary>
/// The Amazon Resource Name (ARN) of the Amazon ECS task that is associated with the container job.
/// Each container attempt receives a task ARN when they reach the STARTING status.
/// </summary>
public string TaskArn { get; set; }

/// <summary>
/// A list of ulimit values to set in the container.
/// </summary>
public List<Ulimit> Ulimits { get; set; }

/// <summary>
/// The user name to use inside the container.
/// </summary>
public string User { get; set; }

/// <summary>
/// The number of VCPUs allocated for the job.
/// </summary>
public int Vcpus { get; set; }

/// <summary>
/// A list of volumes associated with the job.
/// </summary>
public List<Volume> Volumes { get; set; }
}
}
21 changes: 21 additions & 0 deletions Libraries/src/Amazon.Lambda.CloudWatchEvents/BatchEvents/Host.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace Amazon.Lambda.CloudWatchEvents.BatchEvents
{
/// <summary>
/// The contents of the host parameter determine whether your data volume persists on the host container
/// instance and where it is stored. If the host parameter is empty, then the Docker daemon assigns a host
/// path for your data volume, but the data is not guaranteed to persist after the containers associated with
/// it stop running.
/// https://docs.aws.amazon.com/batch/latest/APIReference/API_Host.html
/// </summary>
public class Host
{
/// <summary>
/// The path on the host container instance that is presented to the container. If this parameter is empty,
/// then the Docker daemon has assigned a host path for you. If the host parameter contains a sourcePath file
/// location, then the data volume persists at the specified location on the host container instance until you
/// delete it manually. If the sourcePath value does not exist on the host container instance, the Docker
/// daemon creates it. If the location does exist, the contents of the source path folder are exported.
/// </summary>
public string SourcePath { get; set; }
}
}
99 changes: 99 additions & 0 deletions Libraries/src/Amazon.Lambda.CloudWatchEvents/BatchEvents/Job.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using System.Collections.Generic;

namespace Amazon.Lambda.CloudWatchEvents.BatchEvents
{
/// <summary>
/// https://docs.aws.amazon.com/batch/latest/userguide/batch_cwe_events.html
/// https://docs.aws.amazon.com/batch/latest/APIReference/API_JobDetail.html
/// https://docs.aws.amazon.com/batch/latest/APIReference/API_DescribeJobs.html
/// </summary>
public class Job
{
/// <summary>
/// The array properties of the job, if it is an array job.
/// </summary>
public ArrayPropertiesDetail ArrayProperties { get; set; }

/// <summary>
/// A list of job attempts associated with this job.
/// </summary>
public List<AttemptDetail> Attempts { get; set; }

/// <summary>
/// An object representing the details of the container that is associated with the job.
/// </summary>
public ContainerDetail Container { get; set; }

/// <summary>
/// The Unix time stamp (in seconds and milliseconds) for when the job was created. For non-array
/// jobs and parent array jobs, this is when the job entered the SUBMITTED state
/// (at the time SubmitJob was called). For array child jobs, this is when the child job was
/// spawned by its parent and entered the PENDING state.
/// </summary>
public long CreatedAt { get; set; }

/// <summary>
/// A list of job names or IDs on which this job depends.
/// </summary>
public List<JobDependency> DependsOn { get; set; }

/// <summary>
/// The job definition that is used by this job.
/// </summary>
public string JobDefinition { get; set; }

/// <summary>
/// The ID for the job.
/// </summary>
public string JobId { get; set; }

/// <summary>
/// The name of the job.
/// </summary>
public string JobName { get; set; }

/// <summary>
/// The Amazon Resource Name (ARN) of the job queue with which the job is associated.
/// </summary>
public string JobQueue { get; set; }

/// <summary>
/// Additional parameters passed to the job that replace parameter substitution placeholders or
/// override any corresponding parameter defaults from the job definition.
/// </summary>
public Dictionary<string, string> Parameters { get; set; }

/// <summary>
/// The retry strategy to use for this job if an attempt fails.
/// </summary>
public RetryStrategy RetryStrategy { get; set; }

/// <summary>
/// The Unix time stamp (in seconds and milliseconds) for when the job was started (when the job
/// transitioned from the STARTING state to the RUNNING state).
/// </summary>
public long StartedAt { get; set; }

/// <summary>
/// The current status for the job. Note: If your jobs do not progress to STARTING, see Jobs Stuck
/// in RUNNABLE Status in the troubleshooting section of the AWS Batch User Guide.
/// </summary>
public string Status { get; set; }

/// <summary>
/// A short, human-readable string to provide additional details about the current status of the job.
/// </summary>
public string StatusReason { get; set; }

/// <summary>
/// The Unix time stamp (in seconds and milliseconds) for when the job was stopped (when the
/// job transitioned from the RUNNING state to a terminal state, such as SUCCEEDED or FAILED).
/// </summary>
public long StoppedAt { get; set; }

/// <summary>
/// The timeout configuration for the job.
/// </summary>
public JobTimeout Timeout { get; set; }
}
}
Loading