diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index 004c70fa713b..12ed2ba12d0a 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: AWS SDK for Java Bundle-SymbolicName: com.amazonaws.sdk;singleton:=true -Bundle-Version: 1.3.17 +Bundle-Version: 1.3.18 Bundle-Vendor: Amazon Technologies, Inc Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: org.apache.commons.codec;bundle-version="1.3.0", diff --git a/pom.xml b/pom.xml index 31dc7461758c..39d34c446a5d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ aws-java-sdk jar AWS SDK for Java - 1.3.17 + 1.3.18 The Amazon Web Services SDK for Java provides Java APIs for building software on AWS’ cost-effective, scalable, and reliable infrastructure products. The AWS Java SDK allows developers to code against APIs for all of Amazon's infrastructure web services (Amazon S3, Amazon EC2, Amazon SQS, Amazon Relational Database Service, Amazon AutoScaling, etc). http://aws.amazon.com/sdkforjava diff --git a/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormation.java b/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormation.java index 35155f305dfb..ed68ccf37674 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormation.java +++ b/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormation.java @@ -21,30 +21,14 @@ /** * Interface for accessing AmazonCloudFormation. * AWS CloudFormation

- * This is the AWS CloudFormation API Reference. The major sections of this guide are described in the following table. - *

- * - * - *

- * This guide is for programmers who need detailed information about the CloudFormation APIs. You use AWS CloudFormation to create and manage AWS - * infrastructure deployments predictably and repeatedly. CloudFormation helps you leverage AWS products such as Amazon EC2, EBS, Amazon SNS, ELB, and - * Auto Scaling to build highly-reliable, highly scalable, cost effective applications without worrying about creating and configuring the underlying the - * AWS infrastructure. + * AWS CloudFormation enables you to create and manage AWS infrastructure deployments predictably and repeatedly. AWS CloudFormation helps you leverage + * AWS products such as Amazon EC2, EBS, Amazon SNS, ELB, and Auto Scaling to build highly-reliable, highly scalable, cost effective applications without + * worrying about creating and configuring the underlying the AWS infrastructure. *

*

- * Through the use of a template file you write, and a few AWS CloudFormation commands or API actions, AWS CloudFormation enables you to manage a - * collection of resources together as a single unit called a stack. AWS CloudFormation creates and deletes all member resources of the stack together - * and manages all dependencies between the resources for you. + * With AWS CloudFormation, you declare all of your resources and dependencies in a template file. The template defines a collection of resources as a + * single unit called a stack. AWS CloudFormation creates and deletes all member resources of the stack together and manages all dependencies between the + * resources for you. *

*

* For more information about this product, go to the CloudFormation Product Page . @@ -111,9 +95,9 @@ public ListStacksResult listStacks(ListStacksRequest listStacksRequest) /** *

- * Creates a stack as specified in the template. After the call - * completes successfully, the stack creation starts. You can check the - * status of the stack via the DescribeStacks API. + * Creates a stack as specified in the template. After the call completes + * successfully, the stack creation starts. You can check the status of + * the stack via the DescribeStacks API. *

*

* NOTE: Currently, the limit for stacks is 20 stacks per account @@ -168,7 +152,7 @@ public ValidateTemplateResult validateTemplate(ValidateTemplateRequest validateT /** *

* Returns the estimated monthly cost of a template. The return value is - * an AWS Simply Monthly Calculator URL with a query string that + * an AWS Simple Monthly Calculator URL with a query string that * describes the resources required to run the template. *

* @@ -312,9 +296,9 @@ public DescribeStackResourceResult describeStackResource(DescribeStackResourceRe /** *

- * Deletes a specified stack. Once the call completes successfully, - * stack deletion starts. Deleted stacks do not show up in the - * DescribeStacks API if the deletion has been completed successfully. + * Deletes a specified stack. Once the call completes successfully, stack + * deletion starts. Deleted stacks do not show up in the DescribeStacks + * API if the deletion has been completed successfully. *

* * @param deleteStackRequest Container for the necessary parameters to @@ -373,11 +357,21 @@ public ListStackResourcesResult listStackResources(ListStackResourcesRequest lis * information for up to 90 days after the stack has been deleted. *

*

- * You must specify StackName or - * PhysicalResourceId. In addition, you can specify - * LogicalResourceId to filter the returned result. For more - * information about resources, the LogicalResourceId and - * PhysicalResourceId , go to the + *

+ * NOTE: To list more than 100 resources use ListStackResources + * instead. + *

+ *

+ * You can specify either StackName or + * PhysicalResourceId. , but not both. In addition, you can + * specify LogicalResourceId to filter the returned result. + * For more information about resources, the + * LogicalResourceId and PhysicalResourceId , + * go to the * AWS CloudFormation User Guide . *

@@ -407,15 +401,20 @@ public DescribeStackResourcesResult describeStackResources(DescribeStackResource /** *

- * Updates a stack as specified in the template. After the call - * completes successfully, the stack update starts. You can check the - * status of the stack via the DescribeStacks action. + * Updates a stack as specified in the template. After the call completes + * successfully, the stack update starts. You can check the status of the + * stack via the DescribeStacks action. *

*

* To get a copy of the template for an existing stack, you can use the * GetTemplate action. *

*

+ * Tags that were associated with this stack during creation time will + * still be associated with the stack after an UpdateStack + * operation. + *

+ *

* For more information about creating an update template, updating a * stack, and monitoring the progress of the update, see @@ -468,7 +467,7 @@ public UpdateStackResult updateStack(UpdateStackRequest updateStackRequest) /** *

* Returns the estimated monthly cost of a template. The return value is - * an AWS Simply Monthly Calculator URL with a query string that + * an AWS Simple Monthly Calculator URL with a query string that * describes the resources required to run the template. *

* @@ -548,11 +547,21 @@ public UpdateStackResult updateStack(UpdateStackRequest updateStackRequest) * information for up to 90 days after the stack has been deleted. *

*

- * You must specify StackName or - * PhysicalResourceId. In addition, you can specify - * LogicalResourceId to filter the returned result. For more - * information about resources, the LogicalResourceId and - * PhysicalResourceId , go to the + *

+ * NOTE: To list more than 100 resources use ListStackResources + * instead. + *

+ *

+ * You can specify either StackName or + * PhysicalResourceId. , but not both. In addition, you can + * specify LogicalResourceId to filter the returned result. + * For more information about resources, the + * LogicalResourceId and PhysicalResourceId , + * go to the * AWS CloudFormation User Guide . *

diff --git a/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormationAsync.java b/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormationAsync.java index 85634c02498d..32745fb8cb41 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormationAsync.java +++ b/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormationAsync.java @@ -24,30 +24,14 @@ * Interface for accessing AmazonCloudFormation asynchronously, * using Java Futures. * AWS CloudFormation

- * This is the AWS CloudFormation API Reference. The major sections of this guide are described in the following table. + * AWS CloudFormation enables you to create and manage AWS infrastructure deployments predictably and repeatedly. AWS CloudFormation helps you leverage + * AWS products such as Amazon EC2, EBS, Amazon SNS, ELB, and Auto Scaling to build highly-reliable, highly scalable, cost effective applications without + * worrying about creating and configuring the underlying the AWS infrastructure. *

- * - * *

- * This guide is for programmers who need detailed information about the CloudFormation APIs. You use AWS CloudFormation to create and manage AWS - * infrastructure deployments predictably and repeatedly. CloudFormation helps you leverage AWS products such as Amazon EC2, EBS, Amazon SNS, ELB, and - * Auto Scaling to build highly-reliable, highly scalable, cost effective applications without worrying about creating and configuring the underlying the - * AWS infrastructure. - *

- *

- * Through the use of a template file you write, and a few AWS CloudFormation commands or API actions, AWS CloudFormation enables you to manage a - * collection of resources together as a single unit called a stack. AWS CloudFormation creates and deletes all member resources of the stack together - * and manages all dependencies between the resources for you. + * With AWS CloudFormation, you declare all of your resources and dependencies in a template file. The template defines a collection of resources as a + * single unit called a stack. AWS CloudFormation creates and deletes all member resources of the stack together and manages all dependencies between the + * resources for you. *

*

* For more information about this product, go to the CloudFormation Product Page . @@ -87,9 +71,9 @@ public Future listStacksAsync(ListStacksRequest listStacksRequ /** *

- * Creates a stack as specified in the template. After the call - * completes successfully, the stack creation starts. You can check the - * status of the stack via the DescribeStacks API. + * Creates a stack as specified in the template. After the call completes + * successfully, the stack creation starts. You can check the status of + * the stack via the DescribeStacks API. *

*

* NOTE: Currently, the limit for stacks is 20 stacks per account @@ -138,7 +122,7 @@ public Future validateTemplateAsync(ValidateTemplateRequ /** *

* Returns the estimated monthly cost of a template. The return value is - * an AWS Simply Monthly Calculator URL with a query string that + * an AWS Simple Monthly Calculator URL with a query string that * describes the resources required to run the template. *

* @@ -280,9 +264,9 @@ public Future describeStackResourceAsync(DescribeSt /** *

- * Deletes a specified stack. Once the call completes successfully, - * stack deletion starts. Deleted stacks do not show up in the - * DescribeStacks API if the deletion has been completed successfully. + * Deletes a specified stack. Once the call completes successfully, stack + * deletion starts. Deleted stacks do not show up in the DescribeStacks + * API if the deletion has been completed successfully. *

* * @param deleteStackRequest Container for the necessary parameters to @@ -343,11 +327,21 @@ public Future listStackResourcesAsync(ListStackResourc * information for up to 90 days after the stack has been deleted. *

*

- * You must specify StackName or - * PhysicalResourceId. In addition, you can specify - * LogicalResourceId to filter the returned result. For more - * information about resources, the LogicalResourceId and - * PhysicalResourceId , go to the + *

+ * NOTE: To list more than 100 resources use ListStackResources + * instead. + *

+ *

+ * You can specify either StackName or + * PhysicalResourceId. , but not both. In addition, you can + * specify LogicalResourceId to filter the returned result. + * For more information about resources, the + * LogicalResourceId and PhysicalResourceId , + * go to the * AWS CloudFormation User Guide . *

@@ -377,15 +371,20 @@ public Future describeStackResourcesAsync(Describe /** *

- * Updates a stack as specified in the template. After the call - * completes successfully, the stack update starts. You can check the - * status of the stack via the DescribeStacks action. + * Updates a stack as specified in the template. After the call completes + * successfully, the stack update starts. You can check the status of the + * stack via the DescribeStacks action. *

*

* To get a copy of the template for an existing stack, you can use the * GetTemplate action. *

*

+ * Tags that were associated with this stack during creation time will + * still be associated with the stack after an UpdateStack + * operation. + *

+ *

* For more information about creating an update template, updating a * stack, and monitoring the progress of the update, see diff --git a/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormationAsyncClient.java b/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormationAsyncClient.java index 7fa91dbced0f..b03656ae1beb 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormationAsyncClient.java +++ b/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormationAsyncClient.java @@ -35,30 +35,14 @@ * Callers must use the Future object to determine when the service call has actually * completed. * AWS CloudFormation

- * This is the AWS CloudFormation API Reference. The major sections of this guide are described in the following table. + * AWS CloudFormation enables you to create and manage AWS infrastructure deployments predictably and repeatedly. AWS CloudFormation helps you leverage + * AWS products such as Amazon EC2, EBS, Amazon SNS, ELB, and Auto Scaling to build highly-reliable, highly scalable, cost effective applications without + * worrying about creating and configuring the underlying the AWS infrastructure. *

- * - * *

- * This guide is for programmers who need detailed information about the CloudFormation APIs. You use AWS CloudFormation to create and manage AWS - * infrastructure deployments predictably and repeatedly. CloudFormation helps you leverage AWS products such as Amazon EC2, EBS, Amazon SNS, ELB, and - * Auto Scaling to build highly-reliable, highly scalable, cost effective applications without worrying about creating and configuring the underlying the - * AWS infrastructure. - *

- *

- * Through the use of a template file you write, and a few AWS CloudFormation commands or API actions, AWS CloudFormation enables you to manage a - * collection of resources together as a single unit called a stack. AWS CloudFormation creates and deletes all member resources of the stack together - * and manages all dependencies between the resources for you. + * With AWS CloudFormation, you declare all of your resources and dependencies in a template file. The template defines a collection of resources as a + * single unit called a stack. AWS CloudFormation creates and deletes all member resources of the stack together and manages all dependencies between the + * resources for you. *

*

* For more information about this product, go to the CloudFormation Product Page . @@ -312,9 +296,9 @@ public ListStacksResult call() throws Exception { /** *

- * Creates a stack as specified in the template. After the call - * completes successfully, the stack creation starts. You can check the - * status of the stack via the DescribeStacks API. + * Creates a stack as specified in the template. After the call completes + * successfully, the stack creation starts. You can check the status of + * the stack via the DescribeStacks API. *

*

* NOTE: Currently, the limit for stacks is 20 stacks per account @@ -375,7 +359,7 @@ public ValidateTemplateResult call() throws Exception { /** *

* Returns the estimated monthly cost of a template. The return value is - * an AWS Simply Monthly Calculator URL with a query string that + * an AWS Simple Monthly Calculator URL with a query string that * describes the resources required to run the template. *

* @@ -547,9 +531,9 @@ public DescribeStackResourceResult call() throws Exception { /** *

- * Deletes a specified stack. Once the call completes successfully, - * stack deletion starts. Deleted stacks do not show up in the - * DescribeStacks API if the deletion has been completed successfully. + * Deletes a specified stack. Once the call completes successfully, stack + * deletion starts. Deleted stacks do not show up in the DescribeStacks + * API if the deletion has been completed successfully. *

* * @param deleteStackRequest Container for the necessary parameters to @@ -623,11 +607,21 @@ public ListStackResourcesResult call() throws Exception { * information for up to 90 days after the stack has been deleted. *

*

- * You must specify StackName or - * PhysicalResourceId. In addition, you can specify - * LogicalResourceId to filter the returned result. For more - * information about resources, the LogicalResourceId and - * PhysicalResourceId , go to the + *

+ * NOTE: To list more than 100 resources use ListStackResources + * instead. + *

+ *

+ * You can specify either StackName or + * PhysicalResourceId. , but not both. In addition, you can + * specify LogicalResourceId to filter the returned result. + * For more information about resources, the + * LogicalResourceId and PhysicalResourceId , + * go to the * AWS CloudFormation User Guide . *

@@ -663,15 +657,20 @@ public DescribeStackResourcesResult call() throws Exception { /** *

- * Updates a stack as specified in the template. After the call - * completes successfully, the stack update starts. You can check the - * status of the stack via the DescribeStacks action. + * Updates a stack as specified in the template. After the call completes + * successfully, the stack update starts. You can check the status of the + * stack via the DescribeStacks action. *

*

* To get a copy of the template for an existing stack, you can use the * GetTemplate action. *

*

+ * Tags that were associated with this stack during creation time will + * still be associated with the stack after an UpdateStack + * operation. + *

+ *

* For more information about creating an update template, updating a * stack, and monitoring the progress of the update, see diff --git a/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormationClient.java b/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormationClient.java index 377c27616ef9..22f4790ff89c 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormationClient.java +++ b/src/main/java/com/amazonaws/services/cloudformation/AmazonCloudFormationClient.java @@ -43,30 +43,14 @@ * completes. *

* AWS CloudFormation

- * This is the AWS CloudFormation API Reference. The major sections of this guide are described in the following table. - *

- * - * - *

- * This guide is for programmers who need detailed information about the CloudFormation APIs. You use AWS CloudFormation to create and manage AWS - * infrastructure deployments predictably and repeatedly. CloudFormation helps you leverage AWS products such as Amazon EC2, EBS, Amazon SNS, ELB, and - * Auto Scaling to build highly-reliable, highly scalable, cost effective applications without worrying about creating and configuring the underlying the - * AWS infrastructure. + * AWS CloudFormation enables you to create and manage AWS infrastructure deployments predictably and repeatedly. AWS CloudFormation helps you leverage + * AWS products such as Amazon EC2, EBS, Amazon SNS, ELB, and Auto Scaling to build highly-reliable, highly scalable, cost effective applications without + * worrying about creating and configuring the underlying the AWS infrastructure. *

*

- * Through the use of a template file you write, and a few AWS CloudFormation commands or API actions, AWS CloudFormation enables you to manage a - * collection of resources together as a single unit called a stack. AWS CloudFormation creates and deletes all member resources of the stack together - * and manages all dependencies between the resources for you. + * With AWS CloudFormation, you declare all of your resources and dependencies in a template file. The template defines a collection of resources as a + * single unit called a stack. AWS CloudFormation creates and deletes all member resources of the stack together and manages all dependencies between the + * resources for you. *

*

* For more information about this product, go to the CloudFormation Product Page . @@ -262,9 +246,9 @@ public ListStacksResult listStacks(ListStacksRequest listStacksRequest) /** *

- * Creates a stack as specified in the template. After the call - * completes successfully, the stack creation starts. You can check the - * status of the stack via the DescribeStacks API. + * Creates a stack as specified in the template. After the call completes + * successfully, the stack creation starts. You can check the status of + * the stack via the DescribeStacks API. *

*

* NOTE: Currently, the limit for stacks is 20 stacks per account @@ -325,7 +309,7 @@ public ValidateTemplateResult validateTemplate(ValidateTemplateRequest validateT /** *

* Returns the estimated monthly cost of a template. The return value is - * an AWS Simply Monthly Calculator URL with a query string that + * an AWS Simple Monthly Calculator URL with a query string that * describes the resources required to run the template. *

* @@ -484,9 +468,9 @@ public DescribeStackResourceResult describeStackResource(DescribeStackResourceRe /** *

- * Deletes a specified stack. Once the call completes successfully, - * stack deletion starts. Deleted stacks do not show up in the - * DescribeStacks API if the deletion has been completed successfully. + * Deletes a specified stack. Once the call completes successfully, stack + * deletion starts. Deleted stacks do not show up in the DescribeStacks + * API if the deletion has been completed successfully. *

* * @param deleteStackRequest Container for the necessary parameters to @@ -551,11 +535,21 @@ public ListStackResourcesResult listStackResources(ListStackResourcesRequest lis * information for up to 90 days after the stack has been deleted. *

*

- * You must specify StackName or - * PhysicalResourceId. In addition, you can specify - * LogicalResourceId to filter the returned result. For more - * information about resources, the LogicalResourceId and - * PhysicalResourceId , go to the + *

+ * NOTE: To list more than 100 resources use ListStackResources + * instead. + *

+ *

+ * You can specify either StackName or + * PhysicalResourceId. , but not both. In addition, you can + * specify LogicalResourceId to filter the returned result. + * For more information about resources, the + * LogicalResourceId and PhysicalResourceId , + * go to the * AWS CloudFormation User Guide . *

@@ -588,15 +582,20 @@ public DescribeStackResourcesResult describeStackResources(DescribeStackResource /** *

- * Updates a stack as specified in the template. After the call - * completes successfully, the stack update starts. You can check the - * status of the stack via the DescribeStacks action. + * Updates a stack as specified in the template. After the call completes + * successfully, the stack update starts. You can check the status of the + * stack via the DescribeStacks action. *

*

* To get a copy of the template for an existing stack, you can use the * GetTemplate action. *

*

+ * Tags that were associated with this stack during creation time will + * still be associated with the stack after an UpdateStack + * operation. + *

+ *

* For more information about creating an update template, updating a * stack, and monitoring the progress of the update, see @@ -654,7 +653,7 @@ public ListStacksResult listStacks() throws AmazonServiceException, AmazonClient /** *

* Returns the estimated monthly cost of a template. The return value is - * an AWS Simply Monthly Calculator URL with a query string that + * an AWS Simple Monthly Calculator URL with a query string that * describes the resources required to run the template. *

* @@ -740,11 +739,21 @@ public DescribeStackEventsResult describeStackEvents() throws AmazonServiceExcep * information for up to 90 days after the stack has been deleted. *

*

- * You must specify StackName or - * PhysicalResourceId. In addition, you can specify - * LogicalResourceId to filter the returned result. For more - * information about resources, the LogicalResourceId and - * PhysicalResourceId , go to the + *

+ * NOTE: To list more than 100 resources use ListStackResources + * instead. + *

+ *

+ * You can specify either StackName or + * PhysicalResourceId. , but not both. In addition, you can + * specify LogicalResourceId to filter the returned result. + * For more information about resources, the + * LogicalResourceId and PhysicalResourceId , + * go to the * AWS CloudFormation User Guide . *

diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/CreateStackRequest.java b/src/main/java/com/amazonaws/services/cloudformation/model/CreateStackRequest.java index 62125c35b5e0..bdaedba1a7ff 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/CreateStackRequest.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/CreateStackRequest.java @@ -71,8 +71,10 @@ public class CreateStackRequest extends AmazonWebServiceRequest { private java.util.List parameters; /** - * Boolean to enable or disable rollback on stack creation - * failures.

Default: false + * Set to true to disable rollback of the stack if stack + * creation failed. You can specify either DisableRollback + * or OnFailure, but not both.

Default: + * false */ private Boolean disableRollback; @@ -114,6 +116,25 @@ public class CreateStackRequest extends AmazonWebServiceRequest { */ private java.util.List capabilities; + /** + * Determines what action will be taken if stack creation fails. This + * must be one of: DO_NOTHING, ROLLBACK, or DELETE. You can specify + * either OnFailure or DisableRollback, but not + * both.

Default: ROLLBACK + *

+ * Constraints:
+ * Allowed Values: DO_NOTHING, ROLLBACK, DELETE + */ + private String onFailure; + + /** + * A set of user-defined Tags to associate with this stack, + * represented by key/value pairs. Tags defined for the stack are + * propogated to EC2 resources that are created as part of the stack. A + * maximum number of 10 tags can be specified. + */ + private java.util.List tags; + /** * The name associated with the stack. The name must be unique within * your AWS account. Must contain only alphanumeric characters @@ -396,35 +417,47 @@ public CreateStackRequest withParameters(java.util.Collection paramet } /** - * Boolean to enable or disable rollback on stack creation - * failures.

Default: false + * Set to true to disable rollback of the stack if stack + * creation failed. You can specify either DisableRollback + * or OnFailure, but not both.

Default: + * false * - * @return Boolean to enable or disable rollback on stack creation - * failures.

Default: false + * @return Set to true to disable rollback of the stack if stack + * creation failed. You can specify either DisableRollback + * or OnFailure, but not both.

Default: + * false */ public Boolean isDisableRollback() { return disableRollback; } /** - * Boolean to enable or disable rollback on stack creation - * failures.

Default: false + * Set to true to disable rollback of the stack if stack + * creation failed. You can specify either DisableRollback + * or OnFailure, but not both.

Default: + * false * - * @param disableRollback Boolean to enable or disable rollback on stack creation - * failures.

Default: false + * @param disableRollback Set to true to disable rollback of the stack if stack + * creation failed. You can specify either DisableRollback + * or OnFailure, but not both.

Default: + * false */ public void setDisableRollback(Boolean disableRollback) { this.disableRollback = disableRollback; } /** - * Boolean to enable or disable rollback on stack creation - * failures.

Default: false + * Set to true to disable rollback of the stack if stack + * creation failed. You can specify either DisableRollback + * or OnFailure, but not both.

Default: + * false *

* Returns a reference to this object so that method calls can be chained together. * - * @param disableRollback Boolean to enable or disable rollback on stack creation - * failures.

Default: false + * @param disableRollback Set to true to disable rollback of the stack if stack + * creation failed. You can specify either DisableRollback + * or OnFailure, but not both.

Default: + * false * * @return A reference to this updated object so that method calls can be chained * together. @@ -436,11 +469,15 @@ public CreateStackRequest withDisableRollback(Boolean disableRollback) { /** - * Boolean to enable or disable rollback on stack creation - * failures.

Default: false + * Set to true to disable rollback of the stack if stack + * creation failed. You can specify either DisableRollback + * or OnFailure, but not both.

Default: + * false * - * @return Boolean to enable or disable rollback on stack creation - * failures.

Default: false + * @return Set to true to disable rollback of the stack if stack + * creation failed. You can specify either DisableRollback + * or OnFailure, but not both.

Default: + * false */ public Boolean getDisableRollback() { return disableRollback; @@ -771,6 +808,212 @@ public CreateStackRequest withCapabilities(java.util.Collection capabili return this; } + /** + * Determines what action will be taken if stack creation fails. This + * must be one of: DO_NOTHING, ROLLBACK, or DELETE. You can specify + * either OnFailure or DisableRollback, but not + * both.

Default: ROLLBACK + *

+ * Constraints:
+ * Allowed Values: DO_NOTHING, ROLLBACK, DELETE + * + * @return Determines what action will be taken if stack creation fails. This + * must be one of: DO_NOTHING, ROLLBACK, or DELETE. You can specify + * either OnFailure or DisableRollback, but not + * both.

Default: ROLLBACK + * + * @see OnFailure + */ + public String getOnFailure() { + return onFailure; + } + + /** + * Determines what action will be taken if stack creation fails. This + * must be one of: DO_NOTHING, ROLLBACK, or DELETE. You can specify + * either OnFailure or DisableRollback, but not + * both.

Default: ROLLBACK + *

+ * Constraints:
+ * Allowed Values: DO_NOTHING, ROLLBACK, DELETE + * + * @param onFailure Determines what action will be taken if stack creation fails. This + * must be one of: DO_NOTHING, ROLLBACK, or DELETE. You can specify + * either OnFailure or DisableRollback, but not + * both.

Default: ROLLBACK + * + * @see OnFailure + */ + public void setOnFailure(String onFailure) { + this.onFailure = onFailure; + } + + /** + * Determines what action will be taken if stack creation fails. This + * must be one of: DO_NOTHING, ROLLBACK, or DELETE. You can specify + * either OnFailure or DisableRollback, but not + * both.

Default: ROLLBACK + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: DO_NOTHING, ROLLBACK, DELETE + * + * @param onFailure Determines what action will be taken if stack creation fails. This + * must be one of: DO_NOTHING, ROLLBACK, or DELETE. You can specify + * either OnFailure or DisableRollback, but not + * both.

Default: ROLLBACK + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see OnFailure + */ + public CreateStackRequest withOnFailure(String onFailure) { + this.onFailure = onFailure; + return this; + } + + + /** + * Determines what action will be taken if stack creation fails. This + * must be one of: DO_NOTHING, ROLLBACK, or DELETE. You can specify + * either OnFailure or DisableRollback, but not + * both.

Default: ROLLBACK + *

+ * Constraints:
+ * Allowed Values: DO_NOTHING, ROLLBACK, DELETE + * + * @param onFailure Determines what action will be taken if stack creation fails. This + * must be one of: DO_NOTHING, ROLLBACK, or DELETE. You can specify + * either OnFailure or DisableRollback, but not + * both.

Default: ROLLBACK + * + * @see OnFailure + */ + public void setOnFailure(OnFailure onFailure) { + this.onFailure = onFailure.toString(); + } + + /** + * Determines what action will be taken if stack creation fails. This + * must be one of: DO_NOTHING, ROLLBACK, or DELETE. You can specify + * either OnFailure or DisableRollback, but not + * both.

Default: ROLLBACK + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: DO_NOTHING, ROLLBACK, DELETE + * + * @param onFailure Determines what action will be taken if stack creation fails. This + * must be one of: DO_NOTHING, ROLLBACK, or DELETE. You can specify + * either OnFailure or DisableRollback, but not + * both.

Default: ROLLBACK + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see OnFailure + */ + public CreateStackRequest withOnFailure(OnFailure onFailure) { + this.onFailure = onFailure.toString(); + return this; + } + + /** + * A set of user-defined Tags to associate with this stack, + * represented by key/value pairs. Tags defined for the stack are + * propogated to EC2 resources that are created as part of the stack. A + * maximum number of 10 tags can be specified. + * + * @return A set of user-defined Tags to associate with this stack, + * represented by key/value pairs. Tags defined for the stack are + * propogated to EC2 resources that are created as part of the stack. A + * maximum number of 10 tags can be specified. + */ + public java.util.List getTags() { + + if (tags == null) { + tags = new java.util.ArrayList(); + } + return tags; + } + + /** + * A set of user-defined Tags to associate with this stack, + * represented by key/value pairs. Tags defined for the stack are + * propogated to EC2 resources that are created as part of the stack. A + * maximum number of 10 tags can be specified. + * + * @param tags A set of user-defined Tags to associate with this stack, + * represented by key/value pairs. Tags defined for the stack are + * propogated to EC2 resources that are created as part of the stack. A + * maximum number of 10 tags can be specified. + */ + public void setTags(java.util.Collection tags) { + if (tags == null) { + this.tags = null; + return; + } + + java.util.List tagsCopy = new java.util.ArrayList(tags.size()); + tagsCopy.addAll(tags); + this.tags = tagsCopy; + } + + /** + * A set of user-defined Tags to associate with this stack, + * represented by key/value pairs. Tags defined for the stack are + * propogated to EC2 resources that are created as part of the stack. A + * maximum number of 10 tags can be specified. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param tags A set of user-defined Tags to associate with this stack, + * represented by key/value pairs. Tags defined for the stack are + * propogated to EC2 resources that are created as part of the stack. A + * maximum number of 10 tags can be specified. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CreateStackRequest withTags(Tag... tags) { + if (getTags() == null) setTags(new java.util.ArrayList(tags.length)); + for (Tag value : tags) { + getTags().add(value); + } + return this; + } + + /** + * A set of user-defined Tags to associate with this stack, + * represented by key/value pairs. Tags defined for the stack are + * propogated to EC2 resources that are created as part of the stack. A + * maximum number of 10 tags can be specified. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param tags A set of user-defined Tags to associate with this stack, + * represented by key/value pairs. Tags defined for the stack are + * propogated to EC2 resources that are created as part of the stack. A + * maximum number of 10 tags can be specified. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CreateStackRequest withTags(java.util.Collection tags) { + if (tags == null) { + this.tags = null; + } else { + java.util.List tagsCopy = new java.util.ArrayList(tags.size()); + tagsCopy.addAll(tags); + this.tags = tagsCopy; + } + + return this; + } + /** * Returns a string representation of this object; useful for testing and * debugging. @@ -791,6 +1034,8 @@ public String toString() { if (timeoutInMinutes != null) sb.append("TimeoutInMinutes: " + timeoutInMinutes + ", "); if (notificationARNs != null) sb.append("NotificationARNs: " + notificationARNs + ", "); if (capabilities != null) sb.append("Capabilities: " + capabilities + ", "); + if (onFailure != null) sb.append("OnFailure: " + onFailure + ", "); + if (tags != null) sb.append("Tags: " + tags + ", "); sb.append("}"); return sb.toString(); } @@ -808,6 +1053,8 @@ public int hashCode() { hashCode = prime * hashCode + ((getTimeoutInMinutes() == null) ? 0 : getTimeoutInMinutes().hashCode()); hashCode = prime * hashCode + ((getNotificationARNs() == null) ? 0 : getNotificationARNs().hashCode()); hashCode = prime * hashCode + ((getCapabilities() == null) ? 0 : getCapabilities().hashCode()); + hashCode = prime * hashCode + ((getOnFailure() == null) ? 0 : getOnFailure().hashCode()); + hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); return hashCode; } @@ -835,6 +1082,10 @@ public boolean equals(Object obj) { if (other.getNotificationARNs() != null && other.getNotificationARNs().equals(this.getNotificationARNs()) == false) return false; if (other.getCapabilities() == null ^ this.getCapabilities() == null) return false; if (other.getCapabilities() != null && other.getCapabilities().equals(this.getCapabilities()) == false) return false; + if (other.getOnFailure() == null ^ this.getOnFailure() == null) return false; + if (other.getOnFailure() != null && other.getOnFailure().equals(this.getOnFailure()) == false) return false; + if (other.getTags() == null ^ this.getTags() == null) return false; + if (other.getTags() != null && other.getTags().equals(this.getTags()) == false) return false; return true; } diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/DeleteStackRequest.java b/src/main/java/com/amazonaws/services/cloudformation/model/DeleteStackRequest.java index cefa2faac0ff..986d15ee3d7b 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/DeleteStackRequest.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/DeleteStackRequest.java @@ -18,8 +18,8 @@ /** * Container for the parameters to the {@link com.amazonaws.services.cloudformation.AmazonCloudFormation#deleteStack(DeleteStackRequest) DeleteStack operation}. *

- * Deletes a specified stack. Once the call completes successfully, stack deletion starts. Deleted stacks do not show up in the DescribeStacks API if - * the deletion has been completed successfully. + * Deletes a specified stack. Once the call completes successfully, stack deletion starts. Deleted stacks do not show up in the DescribeStacks API if the + * deletion has been completed successfully. *

* * @see com.amazonaws.services.cloudformation.AmazonCloudFormation#deleteStack(DeleteStackRequest) diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStackEventsRequest.java b/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStackEventsRequest.java index b76455d0a96f..62157477ef14 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStackEventsRequest.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStackEventsRequest.java @@ -31,14 +31,14 @@ public class DescribeStackEventsRequest extends AmazonWebServiceRequest { /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ private String stackName; /** * String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * is one.

Default: There is no default value. *

* Constraints:
* Length: 1 - 1024
@@ -46,35 +46,35 @@ public class DescribeStackEventsRequest extends AmazonWebServiceRequest { private String nextToken; /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. * - * @return The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @return The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ public String getStackName() { return stackName; } /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. * - * @param stackName The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @param stackName The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ public void setStackName(String stackName) { this.stackName = stackName; } /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. *

* Returns a reference to this object so that method calls can be chained together. * - * @param stackName The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @param stackName The name or the unique identifier associated with the stack. + *

Default: There is no default value. * * @return A reference to this updated object so that method calls can be chained * together. @@ -87,13 +87,13 @@ public DescribeStackEventsRequest withStackName(String stackName) { /** * String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * is one.

Default: There is no default value. *

* Constraints:
* Length: 1 - 1024
* * @return String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * is one.

Default: There is no default value. */ public String getNextToken() { return nextToken; @@ -101,13 +101,13 @@ public String getNextToken() { /** * String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * is one.

Default: There is no default value. *

* Constraints:
* Length: 1 - 1024
* * @param nextToken String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * is one.

Default: There is no default value. */ public void setNextToken(String nextToken) { this.nextToken = nextToken; @@ -115,7 +115,7 @@ public void setNextToken(String nextToken) { /** * String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * is one.

Default: There is no default value. *

* Returns a reference to this object so that method calls can be chained together. *

@@ -123,7 +123,7 @@ public void setNextToken(String nextToken) { * Length: 1 - 1024
* * @param nextToken String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * is one.

Default: There is no default value. * * @return A reference to this updated object so that method calls can be chained * together. diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStackResourceRequest.java b/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStackResourceRequest.java index 417bdea7b697..ec915c43b6c8 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStackResourceRequest.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStackResourceRequest.java @@ -29,47 +29,47 @@ public class DescribeStackResourceRequest extends AmazonWebServiceRequest { /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ private String stackName; /** - * The logical name of the resource as specified in the - * template.

Default: There is on default value. + * The logical name of the resource as specified in the template. + *

Default: There is no default value. */ private String logicalResourceId; /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. * - * @return The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @return The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ public String getStackName() { return stackName; } /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. * - * @param stackName The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @param stackName The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ public void setStackName(String stackName) { this.stackName = stackName; } /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. *

* Returns a reference to this object so that method calls can be chained together. * - * @param stackName The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @param stackName The name or the unique identifier associated with the stack. + *

Default: There is no default value. * * @return A reference to this updated object so that method calls can be chained * together. @@ -81,35 +81,35 @@ public DescribeStackResourceRequest withStackName(String stackName) { /** - * The logical name of the resource as specified in the - * template.

Default: There is on default value. + * The logical name of the resource as specified in the template. + *

Default: There is no default value. * - * @return The logical name of the resource as specified in the - * template.

Default: There is on default value. + * @return The logical name of the resource as specified in the template. + *

Default: There is no default value. */ public String getLogicalResourceId() { return logicalResourceId; } /** - * The logical name of the resource as specified in the - * template.

Default: There is on default value. + * The logical name of the resource as specified in the template. + *

Default: There is no default value. * - * @param logicalResourceId The logical name of the resource as specified in the - * template.

Default: There is on default value. + * @param logicalResourceId The logical name of the resource as specified in the template. + *

Default: There is no default value. */ public void setLogicalResourceId(String logicalResourceId) { this.logicalResourceId = logicalResourceId; } /** - * The logical name of the resource as specified in the - * template.

Default: There is on default value. + * The logical name of the resource as specified in the template. + *

Default: There is no default value. *

* Returns a reference to this object so that method calls can be chained together. * - * @param logicalResourceId The logical name of the resource as specified in the - * template.

Default: There is on default value. + * @param logicalResourceId The logical name of the resource as specified in the template. + *

Default: There is no default value. * * @return A reference to this updated object so that method calls can be chained * together. diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStackResourcesRequest.java b/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStackResourcesRequest.java index bed6e3a12388..7c8117717c51 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStackResourcesRequest.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStackResourcesRequest.java @@ -26,9 +26,16 @@ * For deleted stacks, DescribeStackResources returns resource information for up to 90 days after the stack has been deleted. *

*

- * You must specify StackName or PhysicalResourceId. In addition, you can specify LogicalResourceId to filter the - * returned result. For more information about resources, the LogicalResourceId and PhysicalResourceId , go to the AWS CloudFormation User Guide . + * If you do not provide either a stack or resource id, information for all stacks and resources will be returned, up to a limit of 100 records. + *

+ *

+ * NOTE: To list more than 100 resources use ListStackResources instead. + *

+ *

+ * You can specify either StackName or PhysicalResourceId. , but not both. In addition, you can specify + * LogicalResourceId to filter the returned result. For more information about resources, the LogicalResourceId and + * PhysicalResourceId , go to the AWS CloudFormation User + * Guide . *

*

* NOTE: A ValidationError is returned if you specify both StackName and PhysicalResourceId in the same request. @@ -39,59 +46,59 @@ public class DescribeStackResourcesRequest extends AmazonWebServiceRequest { /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ private String stackName; /** - * The logical name of the resource as specified in the - * template.

Default: There is on default value. + * The logical name of the resource as specified in the template. + *

Default: There is no default value. */ private String logicalResourceId; /** * The name or unique identifier that corresponds to a physical instance - * ID of a resource supported by AWS CloudFormation.

For example, for + * ID of a resource supported by AWS CloudFormation.

For example, for * an Amazon Elastic Compute Cloud (EC2) instance, * PhysicalResourceId corresponds to the * InstanceId. You can pass the EC2 InstanceId * to DescribeStackResources to find which stack the * instance belongs to and what other resources are part of the stack. - *

Default: There is no default value. + *

Default: There is no default value. */ private String physicalResourceId; /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. * - * @return The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @return The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ public String getStackName() { return stackName; } /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. * - * @param stackName The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @param stackName The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ public void setStackName(String stackName) { this.stackName = stackName; } /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. *

* Returns a reference to this object so that method calls can be chained together. * - * @param stackName The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @param stackName The name or the unique identifier associated with the stack. + *

Default: There is no default value. * * @return A reference to this updated object so that method calls can be chained * together. @@ -103,35 +110,35 @@ public DescribeStackResourcesRequest withStackName(String stackName) { /** - * The logical name of the resource as specified in the - * template.

Default: There is on default value. + * The logical name of the resource as specified in the template. + *

Default: There is no default value. * - * @return The logical name of the resource as specified in the - * template.

Default: There is on default value. + * @return The logical name of the resource as specified in the template. + *

Default: There is no default value. */ public String getLogicalResourceId() { return logicalResourceId; } /** - * The logical name of the resource as specified in the - * template.

Default: There is on default value. + * The logical name of the resource as specified in the template. + *

Default: There is no default value. * - * @param logicalResourceId The logical name of the resource as specified in the - * template.

Default: There is on default value. + * @param logicalResourceId The logical name of the resource as specified in the template. + *

Default: There is no default value. */ public void setLogicalResourceId(String logicalResourceId) { this.logicalResourceId = logicalResourceId; } /** - * The logical name of the resource as specified in the - * template.

Default: There is on default value. + * The logical name of the resource as specified in the template. + *

Default: There is no default value. *

* Returns a reference to this object so that method calls can be chained together. * - * @param logicalResourceId The logical name of the resource as specified in the - * template.

Default: There is on default value. + * @param logicalResourceId The logical name of the resource as specified in the template. + *

Default: There is no default value. * * @return A reference to this updated object so that method calls can be chained * together. @@ -144,22 +151,22 @@ public DescribeStackResourcesRequest withLogicalResourceId(String logicalResourc /** * The name or unique identifier that corresponds to a physical instance - * ID of a resource supported by AWS CloudFormation.

For example, for + * ID of a resource supported by AWS CloudFormation.

For example, for * an Amazon Elastic Compute Cloud (EC2) instance, * PhysicalResourceId corresponds to the * InstanceId. You can pass the EC2 InstanceId * to DescribeStackResources to find which stack the * instance belongs to and what other resources are part of the stack. - *

Default: There is no default value. + *

Default: There is no default value. * * @return The name or unique identifier that corresponds to a physical instance - * ID of a resource supported by AWS CloudFormation.

For example, for + * ID of a resource supported by AWS CloudFormation.

For example, for * an Amazon Elastic Compute Cloud (EC2) instance, * PhysicalResourceId corresponds to the * InstanceId. You can pass the EC2 InstanceId * to DescribeStackResources to find which stack the * instance belongs to and what other resources are part of the stack. - *

Default: There is no default value. + *

Default: There is no default value. */ public String getPhysicalResourceId() { return physicalResourceId; @@ -167,22 +174,22 @@ public String getPhysicalResourceId() { /** * The name or unique identifier that corresponds to a physical instance - * ID of a resource supported by AWS CloudFormation.

For example, for + * ID of a resource supported by AWS CloudFormation.

For example, for * an Amazon Elastic Compute Cloud (EC2) instance, * PhysicalResourceId corresponds to the * InstanceId. You can pass the EC2 InstanceId * to DescribeStackResources to find which stack the * instance belongs to and what other resources are part of the stack. - *

Default: There is no default value. + *

Default: There is no default value. * * @param physicalResourceId The name or unique identifier that corresponds to a physical instance - * ID of a resource supported by AWS CloudFormation.

For example, for + * ID of a resource supported by AWS CloudFormation.

For example, for * an Amazon Elastic Compute Cloud (EC2) instance, * PhysicalResourceId corresponds to the * InstanceId. You can pass the EC2 InstanceId * to DescribeStackResources to find which stack the * instance belongs to and what other resources are part of the stack. - *

Default: There is no default value. + *

Default: There is no default value. */ public void setPhysicalResourceId(String physicalResourceId) { this.physicalResourceId = physicalResourceId; @@ -190,24 +197,24 @@ public void setPhysicalResourceId(String physicalResourceId) { /** * The name or unique identifier that corresponds to a physical instance - * ID of a resource supported by AWS CloudFormation.

For example, for + * ID of a resource supported by AWS CloudFormation.

For example, for * an Amazon Elastic Compute Cloud (EC2) instance, * PhysicalResourceId corresponds to the * InstanceId. You can pass the EC2 InstanceId * to DescribeStackResources to find which stack the * instance belongs to and what other resources are part of the stack. - *

Default: There is no default value. + *

Default: There is no default value. *

* Returns a reference to this object so that method calls can be chained together. * * @param physicalResourceId The name or unique identifier that corresponds to a physical instance - * ID of a resource supported by AWS CloudFormation.

For example, for + * ID of a resource supported by AWS CloudFormation.

For example, for * an Amazon Elastic Compute Cloud (EC2) instance, * PhysicalResourceId corresponds to the * InstanceId. You can pass the EC2 InstanceId * to DescribeStackResources to find which stack the * instance belongs to and what other resources are part of the stack. - *

Default: There is no default value. + *

Default: There is no default value. * * @return A reference to this updated object so that method calls can be chained * together. diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStacksRequest.java b/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStacksRequest.java index 074cd0864601..7aaba83d6a7d 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStacksRequest.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStacksRequest.java @@ -26,41 +26,43 @@ public class DescribeStacksRequest extends AmazonWebServiceRequest { /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ private String stackName; + private String nextToken; + /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. * - * @return The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @return The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ public String getStackName() { return stackName; } /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. * - * @param stackName The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @param stackName The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ public void setStackName(String stackName) { this.stackName = stackName; } /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. *

* Returns a reference to this object so that method calls can be chained together. * - * @param stackName The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @param stackName The name or the unique identifier associated with the stack. + *

Default: There is no default value. * * @return A reference to this updated object so that method calls can be chained * together. @@ -71,6 +73,49 @@ public DescribeStacksRequest withStackName(String stackName) { } + /** + * Returns the value of the NextToken property for this object. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @return The value of the NextToken property for this object. + */ + public String getNextToken() { + return nextToken; + } + + /** + * Sets the value of the NextToken property for this object. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param nextToken The new value for the NextToken property for this object. + */ + public void setNextToken(String nextToken) { + this.nextToken = nextToken; + } + + /** + * Sets the value of the NextToken property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param nextToken The new value for the NextToken property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DescribeStacksRequest withNextToken(String nextToken) { + this.nextToken = nextToken; + return this; + } + + /** * Returns a string representation of this object; useful for testing and * debugging. @@ -84,6 +129,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (stackName != null) sb.append("StackName: " + stackName + ", "); + if (nextToken != null) sb.append("NextToken: " + nextToken + ", "); sb.append("}"); return sb.toString(); } @@ -94,6 +140,7 @@ public int hashCode() { int hashCode = 1; hashCode = prime * hashCode + ((getStackName() == null) ? 0 : getStackName().hashCode()); + hashCode = prime * hashCode + ((getNextToken() == null) ? 0 : getNextToken().hashCode()); return hashCode; } @@ -107,6 +154,8 @@ public boolean equals(Object obj) { if (other.getStackName() == null ^ this.getStackName() == null) return false; if (other.getStackName() != null && other.getStackName().equals(this.getStackName()) == false) return false; + if (other.getNextToken() == null ^ this.getNextToken() == null) return false; + if (other.getNextToken() != null && other.getNextToken().equals(this.getNextToken()) == false) return false; return true; } diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStacksResult.java b/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStacksResult.java index 48b0a47631bf..eee13f1622fa 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStacksResult.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/DescribeStacksResult.java @@ -26,6 +26,8 @@ public class DescribeStacksResult { */ private java.util.List stacks; + private String nextToken; + /** * A list of stack structures. * @@ -95,6 +97,49 @@ public DescribeStacksResult withStacks(java.util.Collection stacks) { return this; } + /** + * Returns the value of the NextToken property for this object. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @return The value of the NextToken property for this object. + */ + public String getNextToken() { + return nextToken; + } + + /** + * Sets the value of the NextToken property for this object. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param nextToken The new value for the NextToken property for this object. + */ + public void setNextToken(String nextToken) { + this.nextToken = nextToken; + } + + /** + * Sets the value of the NextToken property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param nextToken The new value for the NextToken property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DescribeStacksResult withNextToken(String nextToken) { + this.nextToken = nextToken; + return this; + } + + /** * Returns a string representation of this object; useful for testing and * debugging. @@ -108,6 +153,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (stacks != null) sb.append("Stacks: " + stacks + ", "); + if (nextToken != null) sb.append("NextToken: " + nextToken + ", "); sb.append("}"); return sb.toString(); } @@ -118,6 +164,7 @@ public int hashCode() { int hashCode = 1; hashCode = prime * hashCode + ((getStacks() == null) ? 0 : getStacks().hashCode()); + hashCode = prime * hashCode + ((getNextToken() == null) ? 0 : getNextToken().hashCode()); return hashCode; } @@ -131,6 +178,8 @@ public boolean equals(Object obj) { if (other.getStacks() == null ^ this.getStacks() == null) return false; if (other.getStacks() != null && other.getStacks().equals(this.getStacks()) == false) return false; + if (other.getNextToken() == null ^ this.getNextToken() == null) return false; + if (other.getNextToken() != null && other.getNextToken().equals(this.getNextToken()) == false) return false; return true; } diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/EstimateTemplateCostRequest.java b/src/main/java/com/amazonaws/services/cloudformation/model/EstimateTemplateCostRequest.java index f35d3ca9febb..e2f25a5b40c4 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/EstimateTemplateCostRequest.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/EstimateTemplateCostRequest.java @@ -18,7 +18,7 @@ /** * Container for the parameters to the {@link com.amazonaws.services.cloudformation.AmazonCloudFormation#estimateTemplateCost(EstimateTemplateCostRequest) EstimateTemplateCost operation}. *

- * Returns the estimated monthly cost of a template. The return value is an AWS Simply Monthly Calculator URL with a query string that describes the + * Returns the estimated monthly cost of a template. The return value is an AWS Simple Monthly Calculator URL with a query string that describes the * resources required to run the template. *

* diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/ListStackResourcesRequest.java b/src/main/java/com/amazonaws/services/cloudformation/model/ListStackResourcesRequest.java index 03de857d9e30..c7e7c08c3168 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/ListStackResourcesRequest.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/ListStackResourcesRequest.java @@ -29,14 +29,14 @@ public class ListStackResourcesRequest extends AmazonWebServiceRequest { /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ private String stackName; /** - * String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * String that identifies the start of the next list of stack resource + * summaries, if there is one.

Default: There is no default value. *

* Constraints:
* Length: 1 - 1024
@@ -44,35 +44,35 @@ public class ListStackResourcesRequest extends AmazonWebServiceRequest { private String nextToken; /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. * - * @return The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @return The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ public String getStackName() { return stackName; } /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. * - * @param stackName The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @param stackName The name or the unique identifier associated with the stack. + *

Default: There is no default value. */ public void setStackName(String stackName) { this.stackName = stackName; } /** - * The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * The name or the unique identifier associated with the stack. + *

Default: There is no default value. *

* Returns a reference to this object so that method calls can be chained together. * - * @param stackName The name or the unique identifier associated with the stack.

- * Default: There is no default value. + * @param stackName The name or the unique identifier associated with the stack. + *

Default: There is no default value. * * @return A reference to this updated object so that method calls can be chained * together. @@ -84,44 +84,44 @@ public ListStackResourcesRequest withStackName(String stackName) { /** - * String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * String that identifies the start of the next list of stack resource + * summaries, if there is one.

Default: There is no default value. *

* Constraints:
* Length: 1 - 1024
* - * @return String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * @return String that identifies the start of the next list of stack resource + * summaries, if there is one.

Default: There is no default value. */ public String getNextToken() { return nextToken; } /** - * String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * String that identifies the start of the next list of stack resource + * summaries, if there is one.

Default: There is no default value. *

* Constraints:
* Length: 1 - 1024
* - * @param nextToken String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * @param nextToken String that identifies the start of the next list of stack resource + * summaries, if there is one.

Default: There is no default value. */ public void setNextToken(String nextToken) { this.nextToken = nextToken; } /** - * String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * String that identifies the start of the next list of stack resource + * summaries, if there is one.

Default: There is no default value. *

* Returns a reference to this object so that method calls can be chained together. *

* Constraints:
* Length: 1 - 1024
* - * @param nextToken String that identifies the start of the next list of events, if there - * is one.

Default: There is no default value. + * @param nextToken String that identifies the start of the next list of stack resource + * summaries, if there is one.

Default: There is no default value. * * @return A reference to this updated object so that method calls can be chained * together. diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/ListStacksRequest.java b/src/main/java/com/amazonaws/services/cloudformation/model/ListStacksRequest.java index 2207e44dc793..03aef3e9654d 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/ListStacksRequest.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/ListStacksRequest.java @@ -18,52 +18,71 @@ /** * Container for the parameters to the {@link com.amazonaws.services.cloudformation.AmazonCloudFormation#listStacks(ListStacksRequest) ListStacks operation}. *

- * Returns the summary information for stacks whose status matches the specified StackStatusFilter. Summary information for stacks that have been - * deleted is kept for 90 days after the stack is deleted. If no StackStatusFilter is specified, summary information for all stacks is returned - * (including existing stacks and stacks that have been deleted). + * Returns the summary information for stacks whose status matches the specified StackStatusFilter. Summary information for stacks that have been deleted + * is kept for 90 days after the stack is deleted. If no StackStatusFilter is specified, summary information for all stacks is returned (including + * existing stacks and stacks that have been deleted). *

* * @see com.amazonaws.services.cloudformation.AmazonCloudFormation#listStacks(ListStacksRequest) */ public class ListStacksRequest extends AmazonWebServiceRequest { + /** + * String that identifies the start of the next list of stacks, if there + * is one.

Default: There is no default value. + *

+ * Constraints:
+ * Length: 1 - 1024
+ */ private String nextToken; + /** + * Stack status to use as a filter. Specify one or more stack status + * codes to list only stacks with the specified status codes. For a + * complete list of stack status codes, see the StackStatus + * parameter of the Stack data type. + */ private java.util.List stackStatusFilters; /** - * Returns the value of the NextToken property for this object. + * String that identifies the start of the next list of stacks, if there + * is one.

Default: There is no default value. *

* Constraints:
* Length: 1 - 1024
* - * @return The value of the NextToken property for this object. + * @return String that identifies the start of the next list of stacks, if there + * is one.

Default: There is no default value. */ public String getNextToken() { return nextToken; } /** - * Sets the value of the NextToken property for this object. + * String that identifies the start of the next list of stacks, if there + * is one.

Default: There is no default value. *

* Constraints:
* Length: 1 - 1024
* - * @param nextToken The new value for the NextToken property for this object. + * @param nextToken String that identifies the start of the next list of stacks, if there + * is one.

Default: There is no default value. */ public void setNextToken(String nextToken) { this.nextToken = nextToken; } /** - * Sets the value of the NextToken property for this object. + * String that identifies the start of the next list of stacks, if there + * is one.

Default: There is no default value. *

* Returns a reference to this object so that method calls can be chained together. *

* Constraints:
* Length: 1 - 1024
* - * @param nextToken The new value for the NextToken property for this object. + * @param nextToken String that identifies the start of the next list of stacks, if there + * is one.

Default: There is no default value. * * @return A reference to this updated object so that method calls can be chained * together. @@ -75,9 +94,15 @@ public ListStacksRequest withNextToken(String nextToken) { /** - * Returns the value of the StackStatusFilters property for this object. + * Stack status to use as a filter. Specify one or more stack status + * codes to list only stacks with the specified status codes. For a + * complete list of stack status codes, see the StackStatus + * parameter of the Stack data type. * - * @return The value of the StackStatusFilters property for this object. + * @return Stack status to use as a filter. Specify one or more stack status + * codes to list only stacks with the specified status codes. For a + * complete list of stack status codes, see the StackStatus + * parameter of the Stack data type. */ public java.util.List getStackStatusFilters() { @@ -88,9 +113,15 @@ public java.util.List getStackStatusFilters() { } /** - * Sets the value of the StackStatusFilters property for this object. + * Stack status to use as a filter. Specify one or more stack status + * codes to list only stacks with the specified status codes. For a + * complete list of stack status codes, see the StackStatus + * parameter of the Stack data type. * - * @param stackStatusFilters The new value for the StackStatusFilters property for this object. + * @param stackStatusFilters Stack status to use as a filter. Specify one or more stack status + * codes to list only stacks with the specified status codes. For a + * complete list of stack status codes, see the StackStatus + * parameter of the Stack data type. */ public void setStackStatusFilters(java.util.Collection stackStatusFilters) { if (stackStatusFilters == null) { @@ -104,11 +135,17 @@ public void setStackStatusFilters(java.util.Collection stackStatusFilter } /** - * Sets the value of the StackStatusFilters property for this object. + * Stack status to use as a filter. Specify one or more stack status + * codes to list only stacks with the specified status codes. For a + * complete list of stack status codes, see the StackStatus + * parameter of the Stack data type. *

* Returns a reference to this object so that method calls can be chained together. * - * @param stackStatusFilters The new value for the StackStatusFilters property for this object. + * @param stackStatusFilters Stack status to use as a filter. Specify one or more stack status + * codes to list only stacks with the specified status codes. For a + * complete list of stack status codes, see the StackStatus + * parameter of the Stack data type. * * @return A reference to this updated object so that method calls can be chained * together. @@ -122,11 +159,17 @@ public ListStacksRequest withStackStatusFilters(String... stackStatusFilters) { } /** - * Sets the value of the StackStatusFilters property for this object. + * Stack status to use as a filter. Specify one or more stack status + * codes to list only stacks with the specified status codes. For a + * complete list of stack status codes, see the StackStatus + * parameter of the Stack data type. *

* Returns a reference to this object so that method calls can be chained together. * - * @param stackStatusFilters The new value for the StackStatusFilters property for this object. + * @param stackStatusFilters Stack status to use as a filter. Specify one or more stack status + * codes to list only stacks with the specified status codes. For a + * complete list of stack status codes, see the StackStatus + * parameter of the Stack data type. * * @return A reference to this updated object so that method calls can be chained * together. diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/ListStacksResult.java b/src/main/java/com/amazonaws/services/cloudformation/model/ListStacksResult.java index 05cd4d150932..e7dfbf1a2ff0 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/ListStacksResult.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/ListStacksResult.java @@ -15,18 +15,33 @@ package com.amazonaws.services.cloudformation.model; /** - * List Stacks Result + *

+ * The output for ListStacks action. + *

*/ public class ListStacksResult { + /** + * A list of StackSummary structures containing information + * about the specified stacks. + */ private java.util.List stackSummaries; + /** + * String that identifies the start of the next list of stacks, if there + * is one. + *

+ * Constraints:
+ * Length: 1 - 1024
+ */ private String nextToken; /** - * Returns the value of the StackSummaries property for this object. + * A list of StackSummary structures containing information + * about the specified stacks. * - * @return The value of the StackSummaries property for this object. + * @return A list of StackSummary structures containing information + * about the specified stacks. */ public java.util.List getStackSummaries() { @@ -37,9 +52,11 @@ public java.util.List getStackSummaries() { } /** - * Sets the value of the StackSummaries property for this object. + * A list of StackSummary structures containing information + * about the specified stacks. * - * @param stackSummaries The new value for the StackSummaries property for this object. + * @param stackSummaries A list of StackSummary structures containing information + * about the specified stacks. */ public void setStackSummaries(java.util.Collection stackSummaries) { if (stackSummaries == null) { @@ -53,11 +70,13 @@ public void setStackSummaries(java.util.Collection stackSummaries) } /** - * Sets the value of the StackSummaries property for this object. + * A list of StackSummary structures containing information + * about the specified stacks. *

* Returns a reference to this object so that method calls can be chained together. * - * @param stackSummaries The new value for the StackSummaries property for this object. + * @param stackSummaries A list of StackSummary structures containing information + * about the specified stacks. * * @return A reference to this updated object so that method calls can be chained * together. @@ -71,11 +90,13 @@ public ListStacksResult withStackSummaries(StackSummary... stackSummaries) { } /** - * Sets the value of the StackSummaries property for this object. + * A list of StackSummary structures containing information + * about the specified stacks. *

* Returns a reference to this object so that method calls can be chained together. * - * @param stackSummaries The new value for the StackSummaries property for this object. + * @param stackSummaries A list of StackSummary structures containing information + * about the specified stacks. * * @return A reference to this updated object so that method calls can be chained * together. @@ -93,38 +114,44 @@ public ListStacksResult withStackSummaries(java.util.Collection st } /** - * Returns the value of the NextToken property for this object. + * String that identifies the start of the next list of stacks, if there + * is one. *

* Constraints:
* Length: 1 - 1024
* - * @return The value of the NextToken property for this object. + * @return String that identifies the start of the next list of stacks, if there + * is one. */ public String getNextToken() { return nextToken; } /** - * Sets the value of the NextToken property for this object. + * String that identifies the start of the next list of stacks, if there + * is one. *

* Constraints:
* Length: 1 - 1024
* - * @param nextToken The new value for the NextToken property for this object. + * @param nextToken String that identifies the start of the next list of stacks, if there + * is one. */ public void setNextToken(String nextToken) { this.nextToken = nextToken; } /** - * Sets the value of the NextToken property for this object. + * String that identifies the start of the next list of stacks, if there + * is one. *

* Returns a reference to this object so that method calls can be chained together. *

* Constraints:
* Length: 1 - 1024
* - * @param nextToken The new value for the NextToken property for this object. + * @param nextToken String that identifies the start of the next list of stacks, if there + * is one. * * @return A reference to this updated object so that method calls can be chained * together. diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/OnFailure.java b/src/main/java/com/amazonaws/services/cloudformation/model/OnFailure.java new file mode 100644 index 000000000000..5617e6d3179f --- /dev/null +++ b/src/main/java/com/amazonaws/services/cloudformation/model/OnFailure.java @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.cloudformation.model; + +/** + * On Failure + */ +public enum OnFailure { + + DO_NOTHING("DO_NOTHING"), + ROLLBACK("ROLLBACK"), + DELETE("DELETE"); + + private String value; + + private OnFailure(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return OnFailure corresponding to the value + */ + public static OnFailure fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("DO_NOTHING".equals(value)) { + return OnFailure.DO_NOTHING; + } else if ("ROLLBACK".equals(value)) { + return OnFailure.ROLLBACK; + } else if ("DELETE".equals(value)) { + return OnFailure.DELETE; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/Stack.java b/src/main/java/com/amazonaws/services/cloudformation/model/Stack.java index 42c2ad1fa355..39db021c3877 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/Stack.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/Stack.java @@ -46,6 +46,10 @@ public class Stack { */ private java.util.Date creationTime; + /** + * The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. + */ private java.util.Date lastUpdatedTime; /** @@ -94,6 +98,12 @@ public class Stack { */ private java.util.List outputs; + /** + * A list of Tags that specify cost allocation information + * for the stack. + */ + private java.util.List tags; + /** * Unique identifier of the stack. * @@ -300,29 +310,35 @@ public Stack withCreationTime(java.util.Date creationTime) { /** - * Returns the value of the LastUpdatedTime property for this object. + * The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. * - * @return The value of the LastUpdatedTime property for this object. + * @return The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. */ public java.util.Date getLastUpdatedTime() { return lastUpdatedTime; } /** - * Sets the value of the LastUpdatedTime property for this object. + * The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. * - * @param lastUpdatedTime The new value for the LastUpdatedTime property for this object. + * @param lastUpdatedTime The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. */ public void setLastUpdatedTime(java.util.Date lastUpdatedTime) { this.lastUpdatedTime = lastUpdatedTime; } /** - * Sets the value of the LastUpdatedTime property for this object. + * The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. *

* Returns a reference to this object so that method calls can be chained together. * - * @param lastUpdatedTime The new value for the LastUpdatedTime property for this object. + * @param lastUpdatedTime The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. * * @return A reference to this updated object so that method calls can be chained * together. @@ -771,6 +787,83 @@ public Stack withOutputs(java.util.Collection outputs) { return this; } + /** + * A list of Tags that specify cost allocation information + * for the stack. + * + * @return A list of Tags that specify cost allocation information + * for the stack. + */ + public java.util.List getTags() { + + if (tags == null) { + tags = new java.util.ArrayList(); + } + return tags; + } + + /** + * A list of Tags that specify cost allocation information + * for the stack. + * + * @param tags A list of Tags that specify cost allocation information + * for the stack. + */ + public void setTags(java.util.Collection tags) { + if (tags == null) { + this.tags = null; + return; + } + + java.util.List tagsCopy = new java.util.ArrayList(tags.size()); + tagsCopy.addAll(tags); + this.tags = tagsCopy; + } + + /** + * A list of Tags that specify cost allocation information + * for the stack. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param tags A list of Tags that specify cost allocation information + * for the stack. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Stack withTags(Tag... tags) { + if (getTags() == null) setTags(new java.util.ArrayList(tags.length)); + for (Tag value : tags) { + getTags().add(value); + } + return this; + } + + /** + * A list of Tags that specify cost allocation information + * for the stack. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param tags A list of Tags that specify cost allocation information + * for the stack. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Stack withTags(java.util.Collection tags) { + if (tags == null) { + this.tags = null; + } else { + java.util.List tagsCopy = new java.util.ArrayList(tags.size()); + tagsCopy.addAll(tags); + this.tags = tagsCopy; + } + + return this; + } + /** * Returns a string representation of this object; useful for testing and * debugging. @@ -796,6 +889,7 @@ public String toString() { if (timeoutInMinutes != null) sb.append("TimeoutInMinutes: " + timeoutInMinutes + ", "); if (capabilities != null) sb.append("Capabilities: " + capabilities + ", "); if (outputs != null) sb.append("Outputs: " + outputs + ", "); + if (tags != null) sb.append("Tags: " + tags + ", "); sb.append("}"); return sb.toString(); } @@ -818,6 +912,7 @@ public int hashCode() { hashCode = prime * hashCode + ((getTimeoutInMinutes() == null) ? 0 : getTimeoutInMinutes().hashCode()); hashCode = prime * hashCode + ((getCapabilities() == null) ? 0 : getCapabilities().hashCode()); hashCode = prime * hashCode + ((getOutputs() == null) ? 0 : getOutputs().hashCode()); + hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); return hashCode; } @@ -855,6 +950,8 @@ public boolean equals(Object obj) { if (other.getCapabilities() != null && other.getCapabilities().equals(this.getCapabilities()) == false) return false; if (other.getOutputs() == null ^ this.getOutputs() == null) return false; if (other.getOutputs() != null && other.getOutputs().equals(this.getOutputs()) == false) return false; + if (other.getTags() == null ^ this.getTags() == null) return false; + if (other.getTags() != null && other.getTags().equals(this.getTags()) == false) return false; return true; } diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/StackSummary.java b/src/main/java/com/amazonaws/services/cloudformation/model/StackSummary.java index ff22399cb58e..2b619132b86d 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/StackSummary.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/StackSummary.java @@ -41,6 +41,10 @@ public class StackSummary { */ private java.util.Date creationTime; + /** + * The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. + */ private java.util.Date lastUpdatedTime; /** @@ -49,13 +53,16 @@ public class StackSummary { private java.util.Date deletionTime; /** - * The status of the stack when it was deleted. + * The current status of the stack. *

* Constraints:
* Allowed Values: CREATE_IN_PROGRESS, CREATE_FAILED, CREATE_COMPLETE, ROLLBACK_IN_PROGRESS, ROLLBACK_FAILED, ROLLBACK_COMPLETE, DELETE_IN_PROGRESS, DELETE_FAILED, DELETE_COMPLETE, UPDATE_IN_PROGRESS, UPDATE_COMPLETE_CLEANUP_IN_PROGRESS, UPDATE_COMPLETE, UPDATE_ROLLBACK_IN_PROGRESS, UPDATE_ROLLBACK_FAILED, UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS, UPDATE_ROLLBACK_COMPLETE */ private String stackStatus; + /** + * Success/Failure message associated with the stack status. + */ private String stackStatusReason; /** @@ -195,29 +202,35 @@ public StackSummary withCreationTime(java.util.Date creationTime) { /** - * Returns the value of the LastUpdatedTime property for this object. + * The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. * - * @return The value of the LastUpdatedTime property for this object. + * @return The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. */ public java.util.Date getLastUpdatedTime() { return lastUpdatedTime; } /** - * Sets the value of the LastUpdatedTime property for this object. + * The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. * - * @param lastUpdatedTime The new value for the LastUpdatedTime property for this object. + * @param lastUpdatedTime The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. */ public void setLastUpdatedTime(java.util.Date lastUpdatedTime) { this.lastUpdatedTime = lastUpdatedTime; } /** - * Sets the value of the LastUpdatedTime property for this object. + * The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. *

* Returns a reference to this object so that method calls can be chained together. * - * @param lastUpdatedTime The new value for the LastUpdatedTime property for this object. + * @param lastUpdatedTime The time the stack was last updated. This field will only be returned + * if the stack has been updated at least once. * * @return A reference to this updated object so that method calls can be chained * together. @@ -263,12 +276,12 @@ public StackSummary withDeletionTime(java.util.Date deletionTime) { /** - * The status of the stack when it was deleted. + * The current status of the stack. *

* Constraints:
* Allowed Values: CREATE_IN_PROGRESS, CREATE_FAILED, CREATE_COMPLETE, ROLLBACK_IN_PROGRESS, ROLLBACK_FAILED, ROLLBACK_COMPLETE, DELETE_IN_PROGRESS, DELETE_FAILED, DELETE_COMPLETE, UPDATE_IN_PROGRESS, UPDATE_COMPLETE_CLEANUP_IN_PROGRESS, UPDATE_COMPLETE, UPDATE_ROLLBACK_IN_PROGRESS, UPDATE_ROLLBACK_FAILED, UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS, UPDATE_ROLLBACK_COMPLETE * - * @return The status of the stack when it was deleted. + * @return The current status of the stack. * * @see StackStatus */ @@ -277,12 +290,12 @@ public String getStackStatus() { } /** - * The status of the stack when it was deleted. + * The current status of the stack. *

* Constraints:
* Allowed Values: CREATE_IN_PROGRESS, CREATE_FAILED, CREATE_COMPLETE, ROLLBACK_IN_PROGRESS, ROLLBACK_FAILED, ROLLBACK_COMPLETE, DELETE_IN_PROGRESS, DELETE_FAILED, DELETE_COMPLETE, UPDATE_IN_PROGRESS, UPDATE_COMPLETE_CLEANUP_IN_PROGRESS, UPDATE_COMPLETE, UPDATE_ROLLBACK_IN_PROGRESS, UPDATE_ROLLBACK_FAILED, UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS, UPDATE_ROLLBACK_COMPLETE * - * @param stackStatus The status of the stack when it was deleted. + * @param stackStatus The current status of the stack. * * @see StackStatus */ @@ -291,14 +304,14 @@ public void setStackStatus(String stackStatus) { } /** - * The status of the stack when it was deleted. + * The current status of the stack. *

* Returns a reference to this object so that method calls can be chained together. *

* Constraints:
* Allowed Values: CREATE_IN_PROGRESS, CREATE_FAILED, CREATE_COMPLETE, ROLLBACK_IN_PROGRESS, ROLLBACK_FAILED, ROLLBACK_COMPLETE, DELETE_IN_PROGRESS, DELETE_FAILED, DELETE_COMPLETE, UPDATE_IN_PROGRESS, UPDATE_COMPLETE_CLEANUP_IN_PROGRESS, UPDATE_COMPLETE, UPDATE_ROLLBACK_IN_PROGRESS, UPDATE_ROLLBACK_FAILED, UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS, UPDATE_ROLLBACK_COMPLETE * - * @param stackStatus The status of the stack when it was deleted. + * @param stackStatus The current status of the stack. * * @return A reference to this updated object so that method calls can be chained * together. @@ -312,12 +325,12 @@ public StackSummary withStackStatus(String stackStatus) { /** - * The status of the stack when it was deleted. + * The current status of the stack. *

* Constraints:
* Allowed Values: CREATE_IN_PROGRESS, CREATE_FAILED, CREATE_COMPLETE, ROLLBACK_IN_PROGRESS, ROLLBACK_FAILED, ROLLBACK_COMPLETE, DELETE_IN_PROGRESS, DELETE_FAILED, DELETE_COMPLETE, UPDATE_IN_PROGRESS, UPDATE_COMPLETE_CLEANUP_IN_PROGRESS, UPDATE_COMPLETE, UPDATE_ROLLBACK_IN_PROGRESS, UPDATE_ROLLBACK_FAILED, UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS, UPDATE_ROLLBACK_COMPLETE * - * @param stackStatus The status of the stack when it was deleted. + * @param stackStatus The current status of the stack. * * @see StackStatus */ @@ -326,14 +339,14 @@ public void setStackStatus(StackStatus stackStatus) { } /** - * The status of the stack when it was deleted. + * The current status of the stack. *

* Returns a reference to this object so that method calls can be chained together. *

* Constraints:
* Allowed Values: CREATE_IN_PROGRESS, CREATE_FAILED, CREATE_COMPLETE, ROLLBACK_IN_PROGRESS, ROLLBACK_FAILED, ROLLBACK_COMPLETE, DELETE_IN_PROGRESS, DELETE_FAILED, DELETE_COMPLETE, UPDATE_IN_PROGRESS, UPDATE_COMPLETE_CLEANUP_IN_PROGRESS, UPDATE_COMPLETE, UPDATE_ROLLBACK_IN_PROGRESS, UPDATE_ROLLBACK_FAILED, UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS, UPDATE_ROLLBACK_COMPLETE * - * @param stackStatus The status of the stack when it was deleted. + * @param stackStatus The current status of the stack. * * @return A reference to this updated object so that method calls can be chained * together. @@ -346,29 +359,29 @@ public StackSummary withStackStatus(StackStatus stackStatus) { } /** - * Returns the value of the StackStatusReason property for this object. + * Success/Failure message associated with the stack status. * - * @return The value of the StackStatusReason property for this object. + * @return Success/Failure message associated with the stack status. */ public String getStackStatusReason() { return stackStatusReason; } /** - * Sets the value of the StackStatusReason property for this object. + * Success/Failure message associated with the stack status. * - * @param stackStatusReason The new value for the StackStatusReason property for this object. + * @param stackStatusReason Success/Failure message associated with the stack status. */ public void setStackStatusReason(String stackStatusReason) { this.stackStatusReason = stackStatusReason; } /** - * Sets the value of the StackStatusReason property for this object. + * Success/Failure message associated with the stack status. *

* Returns a reference to this object so that method calls can be chained together. * - * @param stackStatusReason The new value for the StackStatusReason property for this object. + * @param stackStatusReason Success/Failure message associated with the stack status. * * @return A reference to this updated object so that method calls can be chained * together. diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/Tag.java b/src/main/java/com/amazonaws/services/cloudformation/model/Tag.java new file mode 100644 index 000000000000..dda117c312c1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/cloudformation/model/Tag.java @@ -0,0 +1,168 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.cloudformation.model; + +/** + *

+ * The Tag type is used by CreateStack in the Tags parameter. It allows you to specify a key/value pair that can be used to + * store information related to cost allocation for an AWS CloudFormation stack. + *

+ */ +public class Tag { + + /** + * Required. A string used to identify this tag. You can specify a + * maximum of 128 characters for a tag key. Tags owned by Amazon Web + * Services (AWS) have the reserved prefix: aws:. + */ + private String key; + + /** + * Required. A string containing the value for this tag. You can + * specify a maximum of 256 characters for a tag value. + */ + private String value; + + /** + * Required. A string used to identify this tag. You can specify a + * maximum of 128 characters for a tag key. Tags owned by Amazon Web + * Services (AWS) have the reserved prefix: aws:. + * + * @return Required. A string used to identify this tag. You can specify a + * maximum of 128 characters for a tag key. Tags owned by Amazon Web + * Services (AWS) have the reserved prefix: aws:. + */ + public String getKey() { + return key; + } + + /** + * Required. A string used to identify this tag. You can specify a + * maximum of 128 characters for a tag key. Tags owned by Amazon Web + * Services (AWS) have the reserved prefix: aws:. + * + * @param key Required. A string used to identify this tag. You can specify a + * maximum of 128 characters for a tag key. Tags owned by Amazon Web + * Services (AWS) have the reserved prefix: aws:. + */ + public void setKey(String key) { + this.key = key; + } + + /** + * Required. A string used to identify this tag. You can specify a + * maximum of 128 characters for a tag key. Tags owned by Amazon Web + * Services (AWS) have the reserved prefix: aws:. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param key Required. A string used to identify this tag. You can specify a + * maximum of 128 characters for a tag key. Tags owned by Amazon Web + * Services (AWS) have the reserved prefix: aws:. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Tag withKey(String key) { + this.key = key; + return this; + } + + + /** + * Required. A string containing the value for this tag. You can + * specify a maximum of 256 characters for a tag value. + * + * @return Required. A string containing the value for this tag. You can + * specify a maximum of 256 characters for a tag value. + */ + public String getValue() { + return value; + } + + /** + * Required. A string containing the value for this tag. You can + * specify a maximum of 256 characters for a tag value. + * + * @param value Required. A string containing the value for this tag. You can + * specify a maximum of 256 characters for a tag value. + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Required. A string containing the value for this tag. You can + * specify a maximum of 256 characters for a tag value. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param value Required. A string containing the value for this tag. You can + * specify a maximum of 256 characters for a tag value. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Tag withValue(String value) { + this.value = value; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (key != null) sb.append("Key: " + key + ", "); + if (value != null) sb.append("Value: " + value + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getKey() == null) ? 0 : getKey().hashCode()); + hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof Tag == false) return false; + Tag other = (Tag)obj; + + if (other.getKey() == null ^ this.getKey() == null) return false; + if (other.getKey() != null && other.getKey().equals(this.getKey()) == false) return false; + if (other.getValue() == null ^ this.getValue() == null) return false; + if (other.getValue() != null && other.getValue().equals(this.getValue()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/UpdateStackRequest.java b/src/main/java/com/amazonaws/services/cloudformation/model/UpdateStackRequest.java index 621fd31ca590..974f5f7b5bac 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/UpdateStackRequest.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/UpdateStackRequest.java @@ -25,6 +25,9 @@ * To get a copy of the template for an existing stack, you can use the GetTemplate action. *

*

+ * Tags that were associated with this stack during creation time will still be associated with the stack after an UpdateStack operation. + *

+ *

* For more information about creating an update template, updating a stack, and monitoring the progress of the update, see Updating a Stack . *

diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/transform/CreateStackRequestMarshaller.java b/src/main/java/com/amazonaws/services/cloudformation/model/transform/CreateStackRequestMarshaller.java index 3e045c084ef4..656f2b498424 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/transform/CreateStackRequestMarshaller.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/transform/CreateStackRequestMarshaller.java @@ -94,6 +94,26 @@ public Request marshall(CreateStackRequest createStackReques capabilitiesListIndex++; } + if (createStackRequest.getOnFailure() != null) { + request.addParameter("OnFailure", StringUtils.fromString(createStackRequest.getOnFailure())); + } + + java.util.List tagsList = createStackRequest.getTags(); + int tagsListIndex = 1; + + for (Tag tagsListValue : tagsList) { + Tag tagMember = tagsListValue; + if (tagMember != null) { + if (tagMember.getKey() != null) { + request.addParameter("Tags.member." + tagsListIndex + ".Key", StringUtils.fromString(tagMember.getKey())); + } + if (tagMember.getValue() != null) { + request.addParameter("Tags.member." + tagsListIndex + ".Value", StringUtils.fromString(tagMember.getValue())); + } + } + + tagsListIndex++; + } return request; diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/transform/DescribeStacksRequestMarshaller.java b/src/main/java/com/amazonaws/services/cloudformation/model/transform/DescribeStacksRequestMarshaller.java index 64c8d4f3a90b..be0208a2e355 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/transform/DescribeStacksRequestMarshaller.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/transform/DescribeStacksRequestMarshaller.java @@ -43,6 +43,9 @@ public Request marshall(DescribeStacksRequest describeSta if (describeStacksRequest.getStackName() != null) { request.addParameter("StackName", StringUtils.fromString(describeStacksRequest.getStackName())); } + if (describeStacksRequest.getNextToken() != null) { + request.addParameter("NextToken", StringUtils.fromString(describeStacksRequest.getNextToken())); + } return request; diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/transform/DescribeStacksResultStaxUnmarshaller.java b/src/main/java/com/amazonaws/services/cloudformation/model/transform/DescribeStacksResultStaxUnmarshaller.java index a76507d120a2..4f5dc327667a 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/transform/DescribeStacksResultStaxUnmarshaller.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/transform/DescribeStacksResultStaxUnmarshaller.java @@ -50,6 +50,10 @@ public DescribeStacksResult unmarshall(StaxUnmarshallerContext context) throws E describeStacksResult.getStacks().add(StackStaxUnmarshaller.getInstance().unmarshall(context)); continue; } + if (context.testExpression("NextToken", targetDepth)) { + describeStacksResult.setNextToken(StringStaxUnmarshaller.getInstance().unmarshall(context)); + continue; + } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return describeStacksResult; diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/transform/StackStaxUnmarshaller.java b/src/main/java/com/amazonaws/services/cloudformation/model/transform/StackStaxUnmarshaller.java index b84db067d38b..91b7aef8bbe6 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/model/transform/StackStaxUnmarshaller.java +++ b/src/main/java/com/amazonaws/services/cloudformation/model/transform/StackStaxUnmarshaller.java @@ -98,6 +98,10 @@ public Stack unmarshall(StaxUnmarshallerContext context) throws Exception { stack.getOutputs().add(OutputStaxUnmarshaller.getInstance().unmarshall(context)); continue; } + if (context.testExpression("Tags/member", targetDepth)) { + stack.getTags().add(TagStaxUnmarshaller.getInstance().unmarshall(context)); + continue; + } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return stack; diff --git a/src/main/java/com/amazonaws/services/cloudformation/model/transform/TagStaxUnmarshaller.java b/src/main/java/com/amazonaws/services/cloudformation/model/transform/TagStaxUnmarshaller.java new file mode 100644 index 000000000000..7be6c9c64106 --- /dev/null +++ b/src/main/java/com/amazonaws/services/cloudformation/model/transform/TagStaxUnmarshaller.java @@ -0,0 +1,71 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.cloudformation.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import javax.xml.stream.events.XMLEvent; + +import com.amazonaws.services.cloudformation.model.*; +import com.amazonaws.transform.Unmarshaller; +import com.amazonaws.transform.MapEntry; +import com.amazonaws.transform.StaxUnmarshallerContext; +import com.amazonaws.transform.SimpleTypeStaxUnmarshallers.*; + + +/** + * Tag StAX Unmarshaller + */ +public class TagStaxUnmarshaller implements Unmarshaller { + + public Tag unmarshall(StaxUnmarshallerContext context) throws Exception { + Tag tag = new Tag(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + + if (context.isStartOfDocument()) targetDepth += 2; + + + while (true) { + XMLEvent xmlEvent = context.nextEvent(); + if (xmlEvent.isEndDocument()) return tag; + + if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { + if (context.testExpression("Key", targetDepth)) { + tag.setKey(StringStaxUnmarshaller.getInstance().unmarshall(context)); + continue; + } + if (context.testExpression("Value", targetDepth)) { + tag.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); + continue; + } + } else if (xmlEvent.isEndElement()) { + if (context.getCurrentDepth() < originalDepth) { + return tag; + } + } + } + } + + private static TagStaxUnmarshaller instance; + public static TagStaxUnmarshaller getInstance() { + if (instance == null) instance = new TagStaxUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/cloudformation/package-info.java b/src/main/java/com/amazonaws/services/cloudformation/package-info.java index 170d72db8e96..d91744e12cf0 100644 --- a/src/main/java/com/amazonaws/services/cloudformation/package-info.java +++ b/src/main/java/com/amazonaws/services/cloudformation/package-info.java @@ -3,30 +3,14 @@ * Synchronous and asynchronous client classes for accessing AmazonCloudFormation. * * AWS CloudFormation

- * This is the AWS CloudFormation API Reference. The major sections of this guide are described in the following table. + * AWS CloudFormation enables you to create and manage AWS infrastructure deployments predictably and repeatedly. AWS CloudFormation helps you leverage + * AWS products such as Amazon EC2, EBS, Amazon SNS, ELB, and Auto Scaling to build highly-reliable, highly scalable, cost effective applications without + * worrying about creating and configuring the underlying the AWS infrastructure. *

- * - *
    - *
  • Actions : Alphabetical list of - * CloudFormation actions
  • - *
  • Data Types : Alphabetical list of - * CloudFormation data types
  • - *
  • Common Parameters : Parameters - * that all Query actions can use
  • - *
  • Common Errors : Client and server - * errors that all actions can return
  • - * - *
*

- * This guide is for programmers who need detailed information about the CloudFormation APIs. You use AWS CloudFormation to create and manage AWS - * infrastructure deployments predictably and repeatedly. CloudFormation helps you leverage AWS products such as Amazon EC2, EBS, Amazon SNS, ELB, and - * Auto Scaling to build highly-reliable, highly scalable, cost effective applications without worrying about creating and configuring the underlying the - * AWS infrastructure. - *

- *

- * Through the use of a template file you write, and a few AWS CloudFormation commands or API actions, AWS CloudFormation enables you to manage a - * collection of resources together as a single unit called a stack. AWS CloudFormation creates and deletes all member resources of the stack together - * and manages all dependencies between the resources for you. + * With AWS CloudFormation, you declare all of your resources and dependencies in a template file. The template defines a collection of resources as a + * single unit called a stack. AWS CloudFormation creates and deletes all member resources of the stack together and manages all dependencies between the + * resources for you. *

*

* For more information about this product, go to the CloudFormation Product Page . diff --git a/src/main/java/com/amazonaws/services/glacier/transfer/ArchiveTransferManager.java b/src/main/java/com/amazonaws/services/glacier/transfer/ArchiveTransferManager.java index c4fbbc846804..0128b34897e0 100644 --- a/src/main/java/com/amazonaws/services/glacier/transfer/ArchiveTransferManager.java +++ b/src/main/java/com/amazonaws/services/glacier/transfer/ArchiveTransferManager.java @@ -51,6 +51,8 @@ import com.amazonaws.services.glacier.model.UploadMultipartPartRequest; import com.amazonaws.services.s3.internal.InputSubstream; import com.amazonaws.services.s3.internal.RepeatableFileInputStream; +import com.amazonaws.services.sns.AmazonSNSClient; +import com.amazonaws.services.sqs.AmazonSQSClient; import com.amazonaws.util.BinaryUtils; /** @@ -74,6 +76,10 @@ public class ArchiveTransferManager { private final ClientConfiguration clientConfiguration; + private final AmazonSQSClient sqs; + + private final AmazonSNSClient sns; + /** * Constructs a new ArchiveTransferManager, using the specified AWS * credentials to authenticate requests. @@ -140,6 +146,35 @@ public ArchiveTransferManager(AmazonGlacierClient glacier, AWSCredentialsProvide this.credentialsProvider = credentialsProvider; this.clientConfiguration = clientConfiguration; this.glacier = glacier; + this.sns = null; + this.sqs = null; + } + + /** + * Constructs a new ArchiveTransferManager, using the specified Amazon + * Glacier client, and the specified Amazon SQS and Amazon SNS clients for + * polling download job status. + *

+ * This constructor form can be used to work with ArchiveTransferManager in + * any AWS region where Amazon Glacier is supported. Just make sure to set + * the correct endpoint on each individual client object so that they all + * operate in the same region. + * + * @param glacier + * The client for working with Amazon Glacier. + * @param sqs + * The client for working with Amazon SQS when polling archive + * retrieval job status. + * @param sns + * The client for working with Amazon SNS when polling archive + * retrieval job status. + */ + public ArchiveTransferManager(AmazonGlacierClient glacier, AmazonSQSClient sqs, AmazonSNSClient sns) { + this.credentialsProvider = null; + this.clientConfiguration = null; + this.glacier = glacier; + this.sqs = sqs; + this.sns = sns; } /** @@ -281,7 +316,11 @@ public void download(final String accountId, final String vaultName, final Strin JobStatusMonitor jobStatusMonitor = null; GetJobOutputResult jobOutputResult = null; try { - jobStatusMonitor = new JobStatusMonitor(credentialsProvider, clientConfiguration); + if (credentialsProvider != null && clientConfiguration != null) { + jobStatusMonitor = new JobStatusMonitor(credentialsProvider, clientConfiguration); + } else { + jobStatusMonitor = new JobStatusMonitor(sqs, sns); + } JobParameters jobParameters = new JobParameters() .withArchiveId(archiveId) diff --git a/src/main/java/com/amazonaws/services/glacier/transfer/JobStatusMonitor.java b/src/main/java/com/amazonaws/services/glacier/transfer/JobStatusMonitor.java index 28d8323a0add..af028af71732 100644 --- a/src/main/java/com/amazonaws/services/glacier/transfer/JobStatusMonitor.java +++ b/src/main/java/com/amazonaws/services/glacier/transfer/JobStatusMonitor.java @@ -18,7 +18,6 @@ import java.util.List; import java.util.Map; -import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -58,26 +57,43 @@ public class JobStatusMonitor { private AmazonSNSClient sns; private String queueUrl; private String topicArn; - + private static final Log log = LogFactory.getLog(JobStatusMonitor.class); - + public JobStatusMonitor(AWSCredentialsProvider credentialsProvider, ClientConfiguration clientConfiguration) { sqs = new AmazonSQSClient(credentialsProvider, clientConfiguration); sns = new AmazonSNSClient(credentialsProvider, clientConfiguration); setupQueueAndTopic(); } - + + /** + * Constructs a JobStatusMonitor that will use the specified clients for + * polling archive download job status. + * + * @param sqs + * The client for working with Amazon SQS when polling archive + * retrieval job status. + * @param sns + * The client for working with Amazon SNS when polling archive + * retrieval job status. + */ + public JobStatusMonitor(AmazonSQSClient sqs, AmazonSNSClient sns) { + this.sqs = sqs; + this.sns = sns; + setupQueueAndTopic(); + } + public String getTopicArn() { return topicArn; } - + public void shutdown() { try { sqs.deleteQueue(new DeleteQueueRequest(queueUrl)); } catch (Exception e) { log.warn("Unable to delete queue: " + queueUrl, e); } - + try { sns.deleteTopic(new DeleteTopicRequest(topicArn)); } catch (Exception e) { @@ -91,23 +107,23 @@ public void waitForJobToComplete(String jobId) { List messages = sqs.receiveMessage(new ReceiveMessageRequest(queueUrl)).getMessages(); for (Message message : messages) { sleep(1000 * 30); - + String messageBody = message.getBody(); if (!messageBody.startsWith("{")) { - messageBody = new String(BinaryUtils.fromBase64(messageBody)); + messageBody = new String(BinaryUtils.fromBase64(messageBody)); } - + try { JSONObject json = new JSONObject(messageBody); String jsonMessage = json.getString("Message").replace("\\\"", "\""); - + json = new JSONObject(jsonMessage); String messageJobId = json.getString("JobId"); String messageStatus = json.getString("StatusMessage"); - // Don't process this message if it wasn't the job we were looking for + // Don't process this message if it wasn't the job we were looking for if (!jobId.equals(messageJobId)) continue; - + try { if (StatusCode.Succeeded.toString().equals(messageStatus)) return; if (StatusCode.Failed.toString().equals(messageStatus)) { @@ -117,7 +133,7 @@ public void waitForJobToComplete(String jobId) { deleteMessage(message); } } catch (JSONException e) { - throw new AmazonClientException("Unable to parse status message: " + messageBody, e); + throw new AmazonClientException("Unable to parse status message: " + messageBody, e); } } } @@ -130,21 +146,21 @@ private void sleep(long milliseconds) { throw new AmazonClientException("Archive download interrupted", ie); } } - + private void deleteMessage(Message message) { try { sqs.deleteMessage(new DeleteMessageRequest(queueUrl, message.getReceiptHandle())); } catch (Exception e) {} } - + private void setupQueueAndTopic() { - String queueName = "glacier-archive-transfer-" + System.currentTimeMillis(); - String topicName = "glacier-archive-transfer-" + System.currentTimeMillis(); - + String queueName = "glacier-archive-transfer-" + System.currentTimeMillis(); + String topicName = "glacier-archive-transfer-" + System.currentTimeMillis(); + queueUrl = sqs.createQueue(new CreateQueueRequest(queueName)).getQueueUrl(); topicArn = sns.createTopic(new CreateTopicRequest(topicName)).getTopicArn(); String queueARN = sqs.getQueueAttributes(new GetQueueAttributesRequest(queueUrl).withAttributeNames("QueueArn")).getAttributes().get("QueueArn"); - + Policy sqsPolicy = new Policy().withStatements( new Statement(Effect.Allow) @@ -152,22 +168,22 @@ private void setupQueueAndTopic() { .withActions(SQSActions.SendMessage) .withResources(new Resource(queueARN)) .withConditions(ConditionFactory.newSourceArnCondition(topicArn))); - sqs.setQueueAttributes(new SetQueueAttributesRequest(queueUrl, newAttributes("Policy", sqsPolicy.toJson()))); - + sqs.setQueueAttributes(new SetQueueAttributesRequest(queueUrl, newAttributes("Policy", sqsPolicy.toJson()))); + sns.subscribe(new SubscribeRequest(topicArn, "sqs", queueARN)); } - + private Map newAttributes(String... keyValuePairs) { - if (keyValuePairs.length % 2 != 0) + if (keyValuePairs.length % 2 != 0) throw new IllegalArgumentException("Incorrect number of arguments passed. Input must be specified as: key, value, key, value, ..."); - + Map map = new HashMap(); for (int i = 0; i < keyValuePairs.length; i += 2) { String key = keyValuePairs[i]; String value = keyValuePairs[i+1]; map.put(key, value); } - + return map; } diff --git a/src/main/java/com/amazonaws/services/s3/AmazonS3.java b/src/main/java/com/amazonaws/services/s3/AmazonS3.java index 62f2af569430..17447888925e 100644 --- a/src/main/java/com/amazonaws/services/s3/AmazonS3.java +++ b/src/main/java/com/amazonaws/services/s3/AmazonS3.java @@ -32,6 +32,7 @@ import com.amazonaws.services.s3.model.BucketLoggingConfiguration; import com.amazonaws.services.s3.model.BucketNotificationConfiguration; import com.amazonaws.services.s3.model.BucketPolicy; +import com.amazonaws.services.s3.model.BucketTaggingConfiguration; import com.amazonaws.services.s3.model.BucketVersioningConfiguration; import com.amazonaws.services.s3.model.BucketWebsiteConfiguration; import com.amazonaws.services.s3.model.CannedAccessControlList; @@ -2651,6 +2652,37 @@ public void setBucketVersioningConfiguration(SetBucketVersioningConfigurationReq */ public void deleteBucketLifecycleConfiguration(String bucketName); + /** + * Gets the tagging configuration for the specified bucket, or null if no + * configuration has been established. + * + * @param bucketName + * The name of the bucket for which to retrieve tagging + * configuration. + */ + public BucketTaggingConfiguration getBucketTaggingConfiguration(String bucketName); + + /** + * Sets the tagging configuration for the specified bucket. + * + * @param bucketName + * The name of the bucket for which to set the tagging + * configuration. + * @param bucketTaggingConfiguration + * The new tagging configuration for this bucket, which + * completely replaces any existing configuration. + */ + public void setBucketTaggingConfiguration(String bucketName, BucketTaggingConfiguration bucketTaggingConfiguration); + + /** + * Removes the Tagging configuration for the bucket specified. + * + * @param bucketName + * The name of the bucket for which to remove the tagging + * configuration. + */ + public void deleteBucketTaggingConfiguration(String bucketName); + /** * Gets the notification configuration for the specified bucket. *

diff --git a/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java b/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java index 77ffdc36910f..4ae6720ad19a 100644 --- a/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java +++ b/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java @@ -89,6 +89,7 @@ import com.amazonaws.services.s3.model.BucketLoggingConfiguration; import com.amazonaws.services.s3.model.BucketNotificationConfiguration; import com.amazonaws.services.s3.model.BucketPolicy; +import com.amazonaws.services.s3.model.BucketTaggingConfiguration; import com.amazonaws.services.s3.model.BucketVersioningConfiguration; import com.amazonaws.services.s3.model.BucketWebsiteConfiguration; import com.amazonaws.services.s3.model.CannedAccessControlList; @@ -1593,8 +1594,7 @@ public void setBucketLifecycleConfiguration(String bucketName, BucketLifecycleCo invoke(request, voidResponseHandler, bucketName, null); } - - + /* (non-Javadoc) * @see com.amazonaws.services.s3.AmazonS3#deleteBucketLifecycleConfiguration(java.lang.String) */ @@ -1604,6 +1604,57 @@ public void deleteBucketLifecycleConfiguration(String bucketName) { invoke(request, voidResponseHandler, bucketName, null); } + + /* (non-Javadoc) + * @see com.amazonaws.services.s3.AmazonS3#getBucketTaggingConfiguration(java.lang.String) + */ + public BucketTaggingConfiguration getBucketTaggingConfiguration(String bucketName) { + Request request = createRequest(bucketName, null, new GenericBucketRequest(bucketName), HttpMethodName.GET); + request.addParameter("tagging", null); + + try { + return invoke(request, new Unmarshallers.BucketTaggingConfigurationUnmarshaller(), bucketName, null); + } catch (AmazonServiceException ase) { + switch (ase.getStatusCode()) { + case 404: + return null; + default: + throw ase; + } + } + } + + /* (non-Javadoc) + * @see com.amazonaws.services.s3.AmazonS3#setBucketTaggingConfiguration(java.lang.String, com.amazonaws.services.s3.model.BucketLifecycleConfiguration) + */ + public void setBucketTaggingConfiguration(String bucketName, BucketTaggingConfiguration bucketTaggingConfiguration) { + Request request = createRequest(bucketName, null, new GenericBucketRequest(bucketName), HttpMethodName.PUT); + request.addParameter("tagging", null); + + byte[] content = new BucketConfigurationXmlFactory().convertToXmlByteArray(bucketTaggingConfiguration); + request.addHeader("Content-Length", String.valueOf(content.length)); + request.addHeader("Content-Type", "application/xml"); + request.setContent(new ByteArrayInputStream(content)); + try { + byte[] md5 = Md5Utils.computeMD5Hash(content); + String md5Base64 = BinaryUtils.toBase64(md5); + request.addHeader("Content-MD5", md5Base64); + } catch ( Exception e ) { + throw new AmazonClientException("Couldn't compute md5 sum", e); + } + + invoke(request, voidResponseHandler, bucketName, null); + } + + /* (non-Javadoc) + * @see com.amazonaws.services.s3.AmazonS3#deleteBucketTaggingConfiguration(java.lang.String) + */ + public void deleteBucketTaggingConfiguration(String bucketName) { + Request request = createRequest(bucketName, null, new GenericBucketRequest(bucketName), HttpMethodName.DELETE); + request.addParameter("tagging", null); + + invoke(request, voidResponseHandler, bucketName, null); + } /* (non-Javadoc) * @see com.amazonaws.services.s3.AmazonS3#setBucketWebsiteConfiguration(java.lang.String, com.amazonaws.services.s3.model.BucketWebsiteConfiguration) diff --git a/src/main/java/com/amazonaws/services/s3/internal/RestUtils.java b/src/main/java/com/amazonaws/services/s3/internal/RestUtils.java index 638363ea4ac6..09d1e08e1c26 100644 --- a/src/main/java/com/amazonaws/services/s3/internal/RestUtils.java +++ b/src/main/java/com/amazonaws/services/s3/internal/RestUtils.java @@ -40,7 +40,7 @@ public class RestUtils { private static final List SIGNED_PARAMETERS = Arrays.asList(new String[] { "acl", "torrent", "logging", "location", "policy", "requestPayment", "versioning", "versions", "versionId", "notification", "uploadId", "uploads", "partNumber", "website", - "delete", "lifecycle", + "delete", "lifecycle", "tagging", ResponseHeaderOverrides.RESPONSE_HEADER_CACHE_CONTROL, ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_DISPOSITION, ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_ENCODING, diff --git a/src/main/java/com/amazonaws/services/s3/model/BucketTaggingConfiguration.java b/src/main/java/com/amazonaws/services/s3/model/BucketTaggingConfiguration.java new file mode 100644 index 000000000000..9d46b7e88673 --- /dev/null +++ b/src/main/java/com/amazonaws/services/s3/model/BucketTaggingConfiguration.java @@ -0,0 +1,160 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Portions copyright 2006-2009 James Murty. Please see LICENSE.txt + * for applicable license terms and NOTICE.txt for applicable notices. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.s3.model; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import com.amazonaws.services.s3.AmazonS3; + +public class BucketTaggingConfiguration { + + private List tagSets = null; + + /** + *

+ * Creates a new bucket tagging configuration. + * By default, the newly created configuration is empty. + *

+ *

+ * Passing the new configuration directly to + * {@link AmazonS3#setBucketTaggingConfiguration(String,BucketTaggingConfiguration)} + * will remove any existing bucket tagging configuration. + *

+ * + * @see BucketTaggingConfiguration#BucketTaggingConfiguration(Collection) + */ + public BucketTaggingConfiguration() { + this.tagSets = new ArrayList( 1 ); + } + + /** + *

+ * Creates a new bucket Tagging configuration containing the specified + * TopicConfigurations. + *

+ *

+ * Passing the new configuration directly to + * {@link AmazonS3#setBucketTaggingConfiguration(String,BucketTaggingConfiguration)} + * will set the bucket's Tagging configuration and overwrite any existing configuration. + *

+ * + * @see BucketTaggingConfiguration#BucketTaggingConfiguration() + */ + public BucketTaggingConfiguration( Collection tagSets ) { + this.tagSets = new ArrayList( 1 ); + this.tagSets.addAll( tagSets ); + } + + /** + *

+ * Sets the {@link TagSet} + * TagSets and returns this object, + * enabling additional method calls to be chained together. + *

+ *

+ * Calling this method will overwrite any + * previously set TagSets for this object. + *

+ * + * @param tagSets + * A set of TagSet objects. + * + * @return The updated {@link BucketTaggingConfiguration} object, + * enabling additional method calls to be chained together. + * + * @see BucketTaggingConfiguration#setTagSets(Collection) + */ + public BucketTaggingConfiguration withTagSets( TagSet... tagSets ) { + this.tagSets.clear(); + + for ( int index = 0; index < tagSets.length; index++ ) { + this.tagSets.add( tagSets[ index ] ); + } + + return this; + } + + /** + *

+ * Sets the {@link TagSet}. + *

+ *

+ * Calling this method will overwrite any + * previously set TagSets for this object. + *

+ * + * @param tagSets + * A collection of TagSet objects. + * + * @see BucketTaggingConfiguration#withTopicConfigurations(TopicConfiguration) + */ + public void setTagSets( Collection tagSets ) { + this.tagSets.clear(); + this.tagSets.addAll( tagSets ); + } + + /** + *

+ * Gets the list of {@link TagSet} objects + * contained in this object. This method may return an empty list if no TagSet + * objects are present. + *

+ * + * @return The list of TagSet objects contained in this object. + * May return an empty list. + */ + public List getAllTagSets() { + return this.tagSets; + } + + /** + *

+ * Gets the first {@link TagSet} object contained in this object. This method may return null + * list if no TagSet objects are present. + *

+ * @return The first TagSet object contained in the object + */ + public TagSet getTagSet() { + return this.tagSets.get( 0 ); + } + + /** + *

+ * Gets the {@link TagSet} object at the specified index contained in this object. + *

+ * + * @param index + * The index of the TagSet object to return + * + * @return The TagSet object contained in the object + */ + public TagSet getTagSetAtIndex( int index ) { + return this.tagSets.get( index ); + } + + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append("{"); + sb.append("TagSets: " + this.getAllTagSets() ); + sb.append("}"); + return sb.toString(); + } + +} diff --git a/src/main/java/com/amazonaws/services/s3/model/TagSet.java b/src/main/java/com/amazonaws/services/s3/model/TagSet.java new file mode 100644 index 000000000000..dd87194bc75e --- /dev/null +++ b/src/main/java/com/amazonaws/services/s3/model/TagSet.java @@ -0,0 +1,96 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Portions copyright 2006-2009 James Murty. Please see LICENSE.txt + * for applicable license terms and NOTICE.txt for applicable notices. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.s3.model; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import com.amazonaws.services.s3.AmazonS3; + +public class TagSet { + private Map tags; + + /** + *

+ * Creates a new empty TagSet. + *

+ * + * @see TagSet#TagSet(Map) + */ + public TagSet() { + this.tags = new HashMap( 1 ); + } + + /** + *

+ * Creates a new TagSet with the set of tags defined. + *

+ * @param tags + * A key/value mapping of tags to store in this TagSet + */ + public TagSet( Map tags ) { + this.tags = new HashMap( 1 ); + this.tags.putAll( tags ); + } + + /** + *

+ * Get the value of the tag with the given key. + *

+ * @param key + * The key of the tag to return + * @return The value of the given tag. Will return null if no tag by the + * given key exists. + */ + public String getTag( String key ) { + return tags.get( key ); + } + + /** + *

+ * Sets the value of the tag for a given key. Will overwrite existing value. + *

+ * @param key + * The key for the tag + * @param value + * The value for the tag + */ + public void setTag( String key, String value ) { + tags.put( key, value ); + } + + /** + *

+ * Get all the tags for this TagSet + *

+ * @return A map of key/value for all tags + */ + public Map getAllTags() { + return tags; + } + + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append("{"); + sb.append("Tags: " + this.getAllTags() ); + sb.append("}"); + return sb.toString(); + } +} diff --git a/src/main/java/com/amazonaws/services/s3/model/transform/BucketConfigurationXmlFactory.java b/src/main/java/com/amazonaws/services/s3/model/transform/BucketConfigurationXmlFactory.java index f8455ab83f07..c94cd4dcfb18 100644 --- a/src/main/java/com/amazonaws/services/s3/model/transform/BucketConfigurationXmlFactory.java +++ b/src/main/java/com/amazonaws/services/s3/model/transform/BucketConfigurationXmlFactory.java @@ -21,11 +21,13 @@ import com.amazonaws.services.s3.internal.XmlWriter; import com.amazonaws.services.s3.model.BucketLifecycleConfiguration; import com.amazonaws.services.s3.model.BucketLoggingConfiguration; +import com.amazonaws.services.s3.model.BucketTaggingConfiguration; import com.amazonaws.services.s3.model.BucketVersioningConfiguration; import com.amazonaws.services.s3.model.BucketNotificationConfiguration; import com.amazonaws.services.s3.model.BucketLifecycleConfiguration.Rule; import com.amazonaws.services.s3.model.BucketNotificationConfiguration.TopicConfiguration; import com.amazonaws.services.s3.model.BucketWebsiteConfiguration; +import com.amazonaws.services.s3.model.TagSet; /** * Converts bucket configuration objects into XML byte arrays. @@ -194,5 +196,51 @@ private void writeRule(XmlWriter xml, Rule rule) { xml.end(); // xml.end(); // } + + /** + * Converts the specified {@link BucketTaggingConfiguration} object to an XML fragment that + * can be sent to Amazon S3. + * + * @param config + * The {@link BucketTaggingConfiguration} + */ + /* + * + + + Project + Foo + + + User + nschnarr + + + + */ + public byte[] convertToXmlByteArray(BucketTaggingConfiguration config) throws AmazonClientException { + + XmlWriter xml = new XmlWriter(); + xml.start("Tagging"); + + for (TagSet tagset : config.getAllTagSets()) { + writeRule(xml, tagset); + } + + xml.end(); + + return xml.getBytes(); + } + + private void writeRule(XmlWriter xml, TagSet tagset) { + xml.start("TagSet"); + for ( String key : tagset.getAllTags().keySet() ) { + xml.start("Tag"); + xml.start("Key").value(key).end(); + xml.start("Value").value(tagset.getTag(key)).end(); + xml.end(); //
+ } + xml.end(); // + } } diff --git a/src/main/java/com/amazonaws/services/s3/model/transform/Unmarshallers.java b/src/main/java/com/amazonaws/services/s3/model/transform/Unmarshallers.java index c33ceed48f7d..5c1c0ef4a70a 100644 --- a/src/main/java/com/amazonaws/services/s3/model/transform/Unmarshallers.java +++ b/src/main/java/com/amazonaws/services/s3/model/transform/Unmarshallers.java @@ -23,6 +23,7 @@ import com.amazonaws.services.s3.model.BucketLifecycleConfiguration; import com.amazonaws.services.s3.model.BucketLoggingConfiguration; import com.amazonaws.services.s3.model.BucketNotificationConfiguration; +import com.amazonaws.services.s3.model.BucketTaggingConfiguration; import com.amazonaws.services.s3.model.BucketVersioningConfiguration; import com.amazonaws.services.s3.model.BucketWebsiteConfiguration; import com.amazonaws.services.s3.model.InitiateMultipartUploadResult; @@ -158,6 +159,17 @@ public BucketNotificationConfiguration unmarshall(InputStream in) throws Excepti .parseNotificationConfigurationResponse(in).getConfiguration(); } } + + /** + * Unmarshaller for the BucketTaggingConfiguration XML response. + */ + public static final class BucketTaggingConfigurationUnmarshaller implements + Unmarshaller { + public BucketTaggingConfiguration unmarshall(InputStream in) throws Exception { + return new XmlResponsesSaxParser() + .parseTaggingConfigurationResponse(in).getConfiguration(); + } + } /** * Unmarshaller for the a direct InputStream response. diff --git a/src/main/java/com/amazonaws/services/s3/model/transform/XmlResponsesSaxParser.java b/src/main/java/com/amazonaws/services/s3/model/transform/XmlResponsesSaxParser.java index ae3126bb8d01..13a299fcbfa9 100644 --- a/src/main/java/com/amazonaws/services/s3/model/transform/XmlResponsesSaxParser.java +++ b/src/main/java/com/amazonaws/services/s3/model/transform/XmlResponsesSaxParser.java @@ -25,9 +25,11 @@ import java.text.ParseException; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Locale; +import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -52,6 +54,7 @@ import com.amazonaws.services.s3.model.BucketLoggingConfiguration; import com.amazonaws.services.s3.model.BucketNotificationConfiguration; import com.amazonaws.services.s3.model.BucketNotificationConfiguration.TopicConfiguration; +import com.amazonaws.services.s3.model.BucketTaggingConfiguration; import com.amazonaws.services.s3.model.BucketVersioningConfiguration; import com.amazonaws.services.s3.model.BucketWebsiteConfiguration; import com.amazonaws.services.s3.model.CanonicalGrantee; @@ -74,6 +77,7 @@ import com.amazonaws.services.s3.model.S3Object; import com.amazonaws.services.s3.model.S3ObjectSummary; import com.amazonaws.services.s3.model.S3VersionSummary; +import com.amazonaws.services.s3.model.TagSet; import com.amazonaws.services.s3.model.VersionListing; /** @@ -381,6 +385,14 @@ public BucketNotificationConfigurationHandler parseNotificationConfigurationResp parseXmlInputStream(handler, inputStream); return handler; } + + public BucketTaggingConfigurationHandler parseTaggingConfigurationResponse(InputStream inputStream) + throws AmazonClientException + { + BucketTaggingConfigurationHandler handler = new BucketTaggingConfigurationHandler(); + parseXmlInputStream(handler, inputStream); + return handler; + } public DeleteObjectsHandler parseDeletedObjectsResult(InputStream inputStream) { DeleteObjectsHandler handler = new DeleteObjectsHandler(); @@ -1940,6 +1952,63 @@ public void characters(char ch[], int start, int length) { this.text.append(ch, start, length); } } + + public class BucketTaggingConfigurationHandler extends DefaultHandler { + private BucketTaggingConfiguration configuration = new BucketTaggingConfiguration(); + private StringBuilder text; + private List tagSets; + private Map tags; + private String tagKey; + private String tagValue; + + public BucketTaggingConfiguration getConfiguration() { return configuration; } + + @Override + public void startDocument() { + text = new StringBuilder(); + } + + @Override + public void startElement(String uri, String name, String qName, Attributes attrs) { + if (name.equals("Tagging")) { + tagSets = new ArrayList(1); + } else if (name.equals("TagSet")) { + tags = new HashMap( 1 ); + } else if (name.equals("Tag")) { + tagKey = null; + tagValue = null; + } else if (name.equals("Key")) { + text.setLength(0); + } else if (name.equals("Value")) { + text.setLength(0); + } else { + log.warn("Ignoring unexpected tag <"+name+">"); + } + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + if (name.equals("Key")) { + tagKey = text.toString(); + } else if (name.equals("Value")) { + tagValue = text.toString(); + } else if (name.equals("Tag")) { + if (tagKey != null && tagValue != null) { + tags.put(tagKey, tagValue); + } + } else if (name.equals("TagSet")) { + tagSets.add(new TagSet(tags)); + } else if (name.equals("Tagging")) { + configuration.setTagSets(tagSets); + } + text.setLength(0); + } + + @Override + public void characters(char ch[], int start, int length) { + this.text.append(ch, start, length); + } + } /* HTTP/1.1 200 OK diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspect.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspect.java index 809c6d119a6f..a096536fc51f 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspect.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspect.java @@ -31,10 +31,6 @@ import com.amazonaws.services.simpleworkflow.flow.core.AndPromise; import com.amazonaws.services.simpleworkflow.flow.core.Promise; -/** - * This class is for internal use only and may be changed or removed without prior notice. - * - */ @Aspect public class AsynchronousAspect { diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspectTask.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspectTask.java index c13fb8652fc3..aeeb4105c67c 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspectTask.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspectTask.java @@ -20,10 +20,6 @@ import com.amazonaws.services.simpleworkflow.flow.core.Settable; import com.amazonaws.services.simpleworkflow.flow.core.Task; -/** - * This class is for internal use only and may be changed or removed without prior notice. - * - */ class AsynchronousAspectTask extends Task { ProceedingJoinPoint pjp; diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/ExponentialRetryAspect.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/ExponentialRetryAspect.java index 05fce7841d81..e0d3996f9385 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/ExponentialRetryAspect.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/ExponentialRetryAspect.java @@ -32,10 +32,6 @@ import com.amazonaws.services.simpleworkflow.flow.interceptors.AsyncRunnable; import com.amazonaws.services.simpleworkflow.flow.interceptors.ExponentialRetryPolicy; -/** - * This class is for internal use only and may be changed or removed without prior notice. - * - */ @Aspect public class ExponentialRetryAspect { diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowHelpers.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowHelpers.java index d12cb8e0094a..388c05929efa 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowHelpers.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowHelpers.java @@ -19,10 +19,6 @@ import com.amazonaws.services.simpleworkflow.model.PredefinedDuration; -/** - * This class is for internal use only and may be changed or removed without prior notice. - * - */ public final class FlowHelpers { public static String secondsToDuration(Long seconds) { diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowValueConstraint.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowValueConstraint.java index 02802bc97e17..73c13358950f 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowValueConstraint.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowValueConstraint.java @@ -15,10 +15,6 @@ package com.amazonaws.services.simpleworkflow.flow.common; -/** - * This enum is for internal use only and may be changed or removed without prior notice. - * - */ public enum FlowValueConstraint { FAILURE_REASON("FAILURE_REASON", 0, 256), diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartChildWorkflowReply.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartChildWorkflowReply.java index 865b32c27b8c..356f43613f7b 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartChildWorkflowReply.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartChildWorkflowReply.java @@ -17,10 +17,6 @@ import com.amazonaws.services.simpleworkflow.flow.core.Promise; -/** - * This interface is for internal use only and may be changed or removed without prior notice. - * - */ public interface StartChildWorkflowReply { public String getRunId(); diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryPolicyBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryPolicyBase.java index 9e0e162dd17d..690553bbdcc2 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryPolicyBase.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryPolicyBase.java @@ -21,10 +21,6 @@ import com.amazonaws.services.simpleworkflow.flow.DecisionException; -/** - * This class is for internal use only and may be changed or removed without prior notice. - * - */ public abstract class RetryPolicyBase implements RetryPolicy { private List> exceptionsToRetry; diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/SpringTestPOJOWorkflowImplementationGenericWorkflowClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/SpringTestPOJOWorkflowImplementationGenericWorkflowClient.java index b2970a7db2a4..cf177ff0dd02 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/SpringTestPOJOWorkflowImplementationGenericWorkflowClient.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/SpringTestPOJOWorkflowImplementationGenericWorkflowClient.java @@ -34,10 +34,6 @@ import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; import com.amazonaws.services.simpleworkflow.model.WorkflowType; -/** - * This class is for internal use only and may be changed or removed without prior notice. - * - */ public class SpringTestPOJOWorkflowImplementationGenericWorkflowClient implements GenericWorkflowClient { private final TestGenericWorkflowClient genericClient; diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTaskPoller.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTaskPoller.java index 027257d10991..72568b2882f6 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTaskPoller.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTaskPoller.java @@ -28,10 +28,6 @@ import com.amazonaws.services.simpleworkflow.model.ActivityTask; import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; -/** - * This class is for internal use only and may be changed or removed without prior notice. - * - */ public class ActivityTaskPoller extends SynchronousActivityTaskPoller { private static final Log log = LogFactory.getLog(ActivityTaskPoller.class); diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/AsyncDecisionTaskHandler.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/AsyncDecisionTaskHandler.java index 0c1309848ad5..8f8fc9bbb0eb 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/AsyncDecisionTaskHandler.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/AsyncDecisionTaskHandler.java @@ -30,10 +30,6 @@ import com.amazonaws.services.simpleworkflow.model.RespondDecisionTaskCompletedRequest; import com.amazonaws.services.simpleworkflow.model.WorkflowType; -/** - * This class is for internal use only and may be changed or removed without prior notice. - * - */ public class AsyncDecisionTaskHandler extends DecisionTaskHandler { private static final Log log = LogFactory.getLog(AsyncDecisionTaskHandler.class); diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/BackoffThrottler.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/BackoffThrottler.java index b85d9e163f22..5796b49e26a3 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/BackoffThrottler.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/BackoffThrottler.java @@ -17,8 +17,6 @@ import java.util.concurrent.atomic.AtomicLong; /** - * This class is for internal use only and may be changed or removed without prior notice. - * * Used to throttle code execution in presence of failures using exponential * backoff logic. The formula used to calculate the next sleep interval is: * diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CompleteWorkflowStateMachine.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CompleteWorkflowStateMachine.java index 32a56b4dcce3..2f9285a541e0 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CompleteWorkflowStateMachine.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CompleteWorkflowStateMachine.java @@ -18,10 +18,6 @@ import com.amazonaws.services.simpleworkflow.model.HistoryEvent; -/** - * This class is for internal use only and may be changed or removed without prior notice. - * - */ public class CompleteWorkflowStateMachine implements DecisionStateMachine { private Decision decision; diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskHandler.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskHandler.java index 2cbd85595dd5..b51dbb05ac7a 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskHandler.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskHandler.java @@ -24,12 +24,13 @@ import com.amazonaws.services.simpleworkflow.model.RespondDecisionTaskCompletedRequest; /** - * This class is for internal use only and may be changed or removed without prior notice. - * - * Base class for workflow task handlers. + * Base class for workflow task handlers. Extend this class to implement custom + * deciders that can be executed using a + * {@link WorkflowTaskPollingExecutorService}. * * @author fateev, suskin * + * @see WorkflowTaskPollingExecutorService */ public abstract class DecisionTaskHandler { diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskPoller.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskPoller.java index 06b36b5603f1..b2cdc565dd1e 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskPoller.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskPoller.java @@ -28,10 +28,6 @@ import com.amazonaws.services.simpleworkflow.model.RespondDecisionTaskCompletedRequest; import com.amazonaws.services.simpleworkflow.model.TaskList; -/** - * This class is for internal use only and may be changed or removed without prior notice. - * - */ public class DecisionTaskPoller implements TaskPoller { private static final Log log = LogFactory.getLog(DecisionTaskPoller.class); diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousActivityTaskPoller.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousActivityTaskPoller.java index af5a8aedaf89..6ec4f141ecd9 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousActivityTaskPoller.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousActivityTaskPoller.java @@ -38,10 +38,6 @@ import com.amazonaws.services.simpleworkflow.model.TaskList; import com.amazonaws.services.simpleworkflow.model.UnknownResourceException; -/** - * This class is for internal use only and may be changed or removed without prior notice. - * - */ public class SynchronousActivityTaskPoller implements TaskPoller { private static final Log log = LogFactory.getLog(SynchronousActivityTaskPoller.class); diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousRetrier.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousRetrier.java index 484d81af5234..ae3f5f1c2a26 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousRetrier.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousRetrier.java @@ -17,10 +17,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -/** - * This class is for internal use only and may be changed or removed without prior notice. - * - */ public class SynchronousRetrier { private static final Log log = LogFactory.getLog(SynchronousRetrier.class); diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/TaskPoller.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/TaskPoller.java index 2c3aef3e6922..d17dbdf1f2c1 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/TaskPoller.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/TaskPoller.java @@ -17,10 +17,6 @@ import java.util.concurrent.TimeUnit; -/** - * This interface is for internal use only and may be changed or removed without prior notice. - * - */ public interface TaskPoller { boolean pollAndProcessSingleTask() throws Exception; diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/Throttler.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/Throttler.java index dfefe9538e1a..0e6987216fd9 100644 --- a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/Throttler.java +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/Throttler.java @@ -17,10 +17,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -/** - * This class is for internal use only and may be changed or removed without prior notice. - * - */ public class Throttler { private static final Log log = LogFactory.getLog(Throttler.class); diff --git a/src/main/resources/com/amazonaws/sdk/versionInfo.properties b/src/main/resources/com/amazonaws/sdk/versionInfo.properties index 45df2dc862e2..2521d447363f 100644 --- a/src/main/resources/com/amazonaws/sdk/versionInfo.properties +++ b/src/main/resources/com/amazonaws/sdk/versionInfo.properties @@ -1,2 +1,2 @@ -version = 1.3.17 +version = 1.3.18 platform = java diff --git a/src/samples/AwsFlowFramework/README.html b/src/samples/AwsFlowFramework/README.html index fa7c64ee650f..420930d83103 100644 --- a/src/samples/AwsFlowFramework/README.html +++ b/src/samples/AwsFlowFramework/README.html @@ -213,7 +213,7 @@

Running the Samples

The sample has three executables. You should run each in a separate terminal/console. From the samples folder,
Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.cronwithretry.ActivityHost" run
Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.cronwithretry.WorkflowHost" run
-Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.cronwithretry.CronWorkflowExecutionStarter" -Dmain-args="\"*/10 * * * * *\" PST 60" run
+Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.cronwithretry.CronWithRetryWorkflowExecutionStarter" -Dmain-args="\"*/10 * * * * *\" PST 60" run
The workflow starter takes 3 command line arguments that must be specified:
    diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorklfowTest.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorklfowTest.java index 4dc6b040260b..9ebab419fb26 100644 --- a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorklfowTest.java +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorklfowTest.java @@ -41,7 +41,7 @@ public class BookingWorklfowTest { @Before public void setUp() throws Exception { trace = new ArrayList(); - // Register activity implementaion to be used during test run + // Register activity implementation to be used during test run // In real life some mocking framework to be used BookingActivities activities = new BookingActivities() { diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/ConfigHelper.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/ConfigHelper.java index 5094002028c6..cdf9751b5fc3 100644 --- a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/ConfigHelper.java +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/ConfigHelper.java @@ -24,7 +24,6 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; -import com.amazonaws.ClientConfiguration; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.services.s3.AmazonS3; @@ -108,9 +107,8 @@ else if (envVariableExists) { } public AmazonSimpleWorkflow createSWFClient() { - ClientConfiguration config = new ClientConfiguration().withSocketTimeout(70 * 1000); AWSCredentials awsCredentials = new BasicAWSCredentials(this.swfAccessId, this.swfSecretKey); - AmazonSimpleWorkflow client = new AmazonSimpleWorkflowClient(awsCredentials, config); + AmazonSimpleWorkflow client = new AmazonSimpleWorkflowClient(awsCredentials); client.setEndpoint(this.swfServiceUrl); return client; } diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/ActivityHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/ActivityHost.java new file mode 100644 index 000000000000..ddbb968c5eb1 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/ActivityHost.java @@ -0,0 +1,73 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cron; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.ActivityWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +/** + * This is the process which hosts all Activities in this sample + */ +public class ActivityHost { + + private static final String ACTIVITIES_TASK_LIST = "Periodic"; + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + final ActivityWorker worker = new ActivityWorker(swfService, domain, ACTIVITIES_TASK_LIST); + + // Create activity implementations + CronExampleActivities periodicActivitiesImpl = new CronExampleActivitiesImpl(); + worker.addActivitiesImplementation(periodicActivitiesImpl); + + worker.start(); + + System.out.println("Activity Worker Started for Task List: " + worker.getTaskListToPoll()); + + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + worker.shutdownAndAwaitTermination(1, TimeUnit.MINUTES); + System.out.println("Activity Worker Exited."); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + System.out.println("Please press any key to terminate service."); + + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + System.exit(0); + + } + +} + + diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronExampleActivities.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronExampleActivities.java new file mode 100644 index 000000000000..ca466da2ecc2 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronExampleActivities.java @@ -0,0 +1,28 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cron; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Activities; +import com.amazonaws.services.simpleworkflow.flow.annotations.ActivityRegistrationOptions; + +@Activities(version="1.0") +@ActivityRegistrationOptions( + defaultTaskScheduleToStartTimeoutSeconds = 100, + defaultTaskStartToCloseTimeoutSeconds = 10) +public interface CronExampleActivities { + + void doSomeWork(String parameter); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronExampleActivitiesImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronExampleActivitiesImpl.java new file mode 100644 index 000000000000..3c1b138ff8e3 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronExampleActivitiesImpl.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cron; + +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProviderImpl; +import com.amazonaws.services.simpleworkflow.model.ActivityTask; + +public class CronExampleActivitiesImpl implements CronExampleActivities { + + final ActivityExecutionContextProvider contextProvider; + + public CronExampleActivitiesImpl() { + this(new ActivityExecutionContextProviderImpl()); + } + + /** + * Useful for unit testing activities. + */ + public CronExampleActivitiesImpl(ActivityExecutionContextProvider contextProvider) { + this.contextProvider = contextProvider; + } + + /** + * + */ + @Override + public void doSomeWork(String parameter) { + ActivityExecutionContext context = contextProvider.getActivityExecutionContext(); + ActivityTask task = context.getTask(); + String taskid = task.getActivityId(); + System.out.println("Processed activity task with id: " + taskid); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflow.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflow.java new file mode 100644 index 000000000000..4b417b8d545e --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflow.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cron; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Execute; +import com.amazonaws.services.simpleworkflow.flow.annotations.Workflow; +import com.amazonaws.services.simpleworkflow.flow.annotations.WorkflowRegistrationOptions; + +@Workflow +@WorkflowRegistrationOptions(defaultExecutionStartToCloseTimeoutSeconds = 300, defaultTaskStartToCloseTimeoutSeconds = 10) +public interface CronWorkflow { + + /** + * Start workflow that executes activity according to options. + */ + @Execute(name = "CronWorkflow", version = "1.0") + void startCron(CronWorkflowOptions options); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflowExecutionStarter.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflowExecutionStarter.java new file mode 100644 index 000000000000..cf71c0a317c5 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflowExecutionStarter.java @@ -0,0 +1,88 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cron; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; +import com.amazonaws.services.simpleworkflow.model.ActivityType; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecutionAlreadyStartedException; + +public class CronWorkflowExecutionStarter { + + private static AmazonSimpleWorkflow swfService; + + private static String domain; + + public static void main(String[] args) throws Exception { + + if (args.length != 3) { + System.err.println("Usage:\njava com.amazonaws.services.simpleworkflow.flow.examples.cron.CronWorkflowExecutionStarter CRON_PATTERN TIME_ZONE CONTINUE_AS_NEW_AFTER_SECONDS"); + System.exit(1); + } + String cronPattern = args[0]; + String timeZone = args[1]; + int continueAsNewAfterSeconds = 0; + try { + continueAsNewAfterSeconds = Integer.parseInt(args[2]); + } + catch (NumberFormatException e) { + System.err.println("Value of CONTINUE_AS_NEW_AFTER_SECONDS is not int: " + args[2]); + System.exit(1); + } + // Load configuration + ConfigHelper configHelper = ConfigHelper.createConfig(); + + // Create the client for Simple Workflow Service + swfService = configHelper.createSWFClient(); + domain = configHelper.getDomain(); + + // Name and versions are hardcoded here but they can be passed as args or loaded from configuration file. + ActivityType activity = new ActivityType(); + activity.setName("CronExampleActivities.doSomeWork"); + activity.setVersion("1.0"); + Object[] arguments = new Object[] { "parameter1" }; + + // Start Workflow execution + CronWorkflowClientExternalFactory clientFactory = new CronWorkflowClientExternalFactoryImpl(swfService, domain); + + // Use Activity + cronPattern as instance id to ensure that only one workflow per pattern for a given activity is active at a time. + CronWorkflowClientExternal workflow = clientFactory.getClient(activity.getName() + ": " + cronPattern); + + + + try { + CronWorkflowOptions cronOptions = new CronWorkflowOptions(); + cronOptions.setActivity(activity); + cronOptions.setActivityArguments(arguments); + cronOptions.setContinueAsNewAfterSeconds(continueAsNewAfterSeconds); + cronOptions.setTimeZone(timeZone); + + // Every 10 seconds + cronOptions.setCronExpression(cronPattern); + workflow.startCron(cronOptions); + // WorkflowExecution is available after workflow creation + WorkflowExecution workflowExecution = workflow.getWorkflowExecution(); + System.out.println("Started Cron workflow with workflowId=\"" + workflowExecution.getWorkflowId() + "\" and runId=\"" + + workflowExecution.getRunId() + "\" with cron pattern=" + cronPattern); + } + catch (WorkflowExecutionAlreadyStartedException e) { + // It is expected to get this exception if start is called before workflow run is completed. + System.out.println("Cron workflow with workflowId=\"" + workflow.getWorkflowExecution().getWorkflowId() + + " is already running for the pattern=" + cronPattern); + } + System.exit(0); + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflowImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflowImpl.java new file mode 100644 index 000000000000..e8a46ac4eb6a --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflowImpl.java @@ -0,0 +1,84 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cron; + +import java.util.Date; +import java.util.TimeZone; + +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProviderImpl; +import com.amazonaws.services.simpleworkflow.flow.DynamicActivitiesClient; +import com.amazonaws.services.simpleworkflow.flow.DynamicActivitiesClientImpl; +import com.amazonaws.services.simpleworkflow.flow.WorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.spring.CronDecorator; + +/** + * Demonstrates how to create workflow that executes an activity on schedule + * specified as a "cron" string. Activity name and version are passed as input + * arguments of the workflow. In case of activity failures it is retried + * according to retry options passed as arguments of the workflow. + * + * @author fateev + */ +public class CronWorkflowImpl implements CronWorkflow { + + private static final int SECOND = 1000; + + /** + * This is needed to keep the decider logic deterministic as using + * System.currentTimeMillis() in your decider logic is not. + * WorkflowClock.currentTimeMillis() should be used instead. + */ + private final WorkflowClock clock; + + private final DynamicActivitiesClient activities; + + /** + * Used to create new run of the Cron workflow to reset history. This allows + * "infinite" workflows. + */ + private final CronWorkflowSelfClient selfClient; + + + public CronWorkflowImpl() { + this(new DecisionContextProviderImpl().getDecisionContext().getWorkflowClock(), new DynamicActivitiesClientImpl(), + new CronWorkflowSelfClientImpl()); + } + + /** + * Constructor used for unit testing or configuration through IOC container + */ + public CronWorkflowImpl(WorkflowClock clock, DynamicActivitiesClient activities, CronWorkflowSelfClient selfClient) { + this.clock = clock; + this.activities = activities; + this.selfClient = selfClient; + } + + @Override + public void startCron(final CronWorkflowOptions options) { + long startTime = clock.currentTimeMillis(); + Date expiration = new Date(startTime + options.getContinueAsNewAfterSeconds() * SECOND); + TimeZone tz = TimeZone.getTimeZone(options.getTimeZone()); + CronDecorator cronDecorator = new CronDecorator(options.getCronExpression(), expiration, tz, clock); + DynamicActivitiesClient cronDecoratedActivities = cronDecorator.decorate(DynamicActivitiesClient.class, activities); + + cronDecoratedActivities.scheduleActivity(options.getActivity(), options.getActivityArguments(), null, Void.class); + + // Start new workflow run as soon as cron decorator exits due to expiration. + // The call to self client indicates the desire to start the new run. + // It is started only after all other tasks in the given run are completed. + selfClient.startCron(options); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflowOptions.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflowOptions.java new file mode 100644 index 000000000000..884745945894 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflowOptions.java @@ -0,0 +1,77 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cron; + +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +/** + * See {@link ExponentialRetryPolicy} for description of retry related + * properties. + * + * @author fateev + */ +public class CronWorkflowOptions { + + private ActivityType activity; + + private Object[] activityArguments; + + private String cronExpression; + + private String timeZone; + + private int continueAsNewAfterSeconds; + + public ActivityType getActivity() { + return activity; + } + + public void setActivity(ActivityType activity) { + this.activity = activity; + } + + public Object[] getActivityArguments() { + return activityArguments; + } + + public void setActivityArguments(Object[] activityArguments) { + this.activityArguments = activityArguments; + } + + public String getCronExpression() { + return cronExpression; + } + + public void setCronExpression(String cronExpression) { + this.cronExpression = cronExpression; + } + + public String getTimeZone() { + return timeZone; + } + + public void setTimeZone(String timeZone) { + this.timeZone = timeZone; + } + + public int getContinueAsNewAfterSeconds() { + return continueAsNewAfterSeconds; + } + + public void setContinueAsNewAfterSeconds(int continueAsNewAfterSeconds) { + this.continueAsNewAfterSeconds = continueAsNewAfterSeconds; + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflowTest.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflowTest.java new file mode 100644 index 000000000000..72d94f83284f --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/CronWorkflowTest.java @@ -0,0 +1,141 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cron; + +import java.util.concurrent.CancellationException; + +import junit.framework.Assert; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProviderImpl; +import com.amazonaws.services.simpleworkflow.flow.WorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally; +import com.amazonaws.services.simpleworkflow.flow.junit.FlowBlockJUnit4ClassRunner; +import com.amazonaws.services.simpleworkflow.flow.junit.WorkflowTest; +import com.amazonaws.services.simpleworkflow.model.ActivityType; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +@RunWith(FlowBlockJUnit4ClassRunner.class) +public class CronWorkflowTest { + + private static final int SECONDS_HOUR = 3600; + + private final class TestCronWorkflowActivities implements CronExampleActivities { + + private final ActivityExecutionContextProvider contextProvider = new ActivityExecutionContextProviderImpl(); + + private int workCount; + + private int runCount; + + private String runId; + + @Override + public void doSomeWork(String parameter) { + // Reset counter on the new run which changes when workflow continues as new + ActivityExecutionContext activityExecutionContext = contextProvider.getActivityExecutionContext(); + WorkflowExecution workflowExecution = activityExecutionContext.getWorkflowExecution(); + String runId = workflowExecution.getRunId(); + if (this.runId == null || !runId.equals(this.runId)) { + runCount++; + } + this.runId = runId; + workCount++; + } + + public int getWorkCount() { + return workCount; + } + + public int getRunCount() { + return runCount; + } + } + + @Rule + public WorkflowTest workflowTest = new WorkflowTest(); + + private CronWorkflowClientFactory workflowClientFactory = new CronWorkflowClientFactoryImpl(); + + private TestCronWorkflowActivities cronActivitiesImplementation; + + @Before + public void setUp() throws Exception { + cronActivitiesImplementation = new TestCronWorkflowActivities(); + workflowTest.addActivitiesImplementation(cronActivitiesImplementation); + workflowTest.addWorkflowImplementationType(CronWorkflowImpl.class); + workflowTest.setDisableOutstandingTasksCheck(true); + } + + @After + public void tearDown() throws Exception { + } + + @Test(timeout = 2000) + public void testCron() { + workflowTest.setClockAccelerationCoefficient(SECONDS_HOUR * 24 * 7 * 2); + final CronWorkflowClient workflow = workflowClientFactory.getClient(); + + final ActivityType activityType = new ActivityType(); + activityType.setName("CronExampleActivities.doSomeWork"); + activityType.setVersion("1.0"); + final Object[] activityArguments = new Object[] { "parameter1" }; + + final CronWorkflowOptions cronOptions = new CronWorkflowOptions(); + cronOptions.setActivity(activityType); + cronOptions.setActivityArguments(activityArguments); + cronOptions.setContinueAsNewAfterSeconds(SECONDS_HOUR * 24 + 300); + cronOptions.setTimeZone("PST"); + final String cronExpression = "0 0 * * * *"; + cronOptions.setCronExpression(cronExpression); + + WorkflowClock clock = workflowTest.getDecisionContext().getWorkflowClock(); + clock.createTimer(SECONDS_HOUR * 24 * 7 + 1000); + // true constructor argument makes TryCatchFinally a daemon which causes it get cancelled after above timer firing + new TryCatchFinally(true) { + + Throwable failure; + + @Override + protected void doTry() throws Throwable { + workflow.startCron(cronOptions); + } + + @Override + protected void doCatch(Throwable e) throws Throwable { + failure = e; + throw e; + } + + @Override + protected void doFinally() throws Throwable { + // Skip assertions as their failure masks original exception + if (failure == null || failure instanceof CancellationException) { + Assert.assertEquals(24 * 7, cronActivitiesImplementation.getWorkCount()); + Assert.assertEquals(7, cronActivitiesImplementation.getRunCount()); + } + } + + }; + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/WorkflowHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/WorkflowHost.java new file mode 100644 index 000000000000..0b7f37bb5aff --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cron/WorkflowHost.java @@ -0,0 +1,66 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cron; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.WorkflowWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +public class WorkflowHost { + + public static final String DECISION_TASK_LIST = "PeriodicWorkflow"; + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + final WorkflowWorker worker = new WorkflowWorker(swfService, domain, DECISION_TASK_LIST); + worker.addWorkflowImplementationType(CronWorkflowImpl.class); + worker.setRegisterDomain(true); + worker.setDomainRetentionPeriodInDays(1); + worker.start(); + + System.out.println("Workflow Host Service Started..."); + + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + worker.shutdownAndAwaitTermination(1, TimeUnit.MINUTES); + System.out.println("Workflow Host Service Terminated..."); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + System.out.println("Please press any key to terminate service."); + + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + + System.exit(0); + + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/ActivityHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/ActivityHost.java new file mode 100644 index 000000000000..17001647fad6 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/ActivityHost.java @@ -0,0 +1,73 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cronwithretry; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.ActivityWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +/** + * This is the process which hosts all Activities in this sample + */ +public class ActivityHost { + + private static final String ACTIVITIES_TASK_LIST = "Periodic"; + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + final ActivityWorker worker = new ActivityWorker(swfService, domain, ACTIVITIES_TASK_LIST); + + // Create activity implementations + CronWithRetryExampleActivities periodicActivitiesImpl = new CronExampleActivitiesImpl(); + worker.addActivitiesImplementation(periodicActivitiesImpl); + + worker.start(); + + System.out.println("Activity Worker Started for Task List: " + worker.getTaskListToPoll()); + + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + worker.shutdownAndAwaitTermination(1, TimeUnit.MINUTES); + System.out.println("Activity Worker Exited."); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + System.out.println("Please press any key to terminate service."); + + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + System.exit(0); + + } + +} + + diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronExampleActivitiesImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronExampleActivitiesImpl.java new file mode 100644 index 000000000000..1165f3b6c5dd --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronExampleActivitiesImpl.java @@ -0,0 +1,54 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cronwithretry; + +import java.util.Random; + +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProviderImpl; +import com.amazonaws.services.simpleworkflow.model.ActivityTask; + +public class CronExampleActivitiesImpl implements CronWithRetryExampleActivities { + + final ActivityExecutionContextProvider contextProvider; + + public CronExampleActivitiesImpl() { + this(new ActivityExecutionContextProviderImpl()); + } + + /** + * Useful for unit testing activities. + */ + public CronExampleActivitiesImpl(ActivityExecutionContextProvider contextProvider) { + this.contextProvider = contextProvider; + } + + /** + * Fail in 20% of invocations to demonstrate retry logic + */ + @Override + public void doSomeWork(String parameter) { + Random r = new Random(); + if (r.nextInt(100) < 20) { + throw new RuntimeException("simulated exception to force retry"); + } + ActivityExecutionContext context = contextProvider.getActivityExecutionContext(); + ActivityTask task = context.getTask(); + String taskid = task.getActivityId(); + System.out.println("Processed activity task with id: " + taskid); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryExampleActivities.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryExampleActivities.java new file mode 100644 index 000000000000..a1f43db486a7 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryExampleActivities.java @@ -0,0 +1,28 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cronwithretry; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Activities; +import com.amazonaws.services.simpleworkflow.flow.annotations.ActivityRegistrationOptions; + +@Activities(version="1.0") +@ActivityRegistrationOptions( + defaultTaskScheduleToStartTimeoutSeconds = 100, + defaultTaskStartToCloseTimeoutSeconds = 10) +public interface CronWithRetryExampleActivities { + + void doSomeWork(String parameter); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflow.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflow.java new file mode 100644 index 000000000000..e23cf9c166b2 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflow.java @@ -0,0 +1,44 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cronwithretry; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Execute; +import com.amazonaws.services.simpleworkflow.flow.annotations.GetState; +import com.amazonaws.services.simpleworkflow.flow.annotations.Workflow; +import com.amazonaws.services.simpleworkflow.flow.annotations.WorkflowRegistrationOptions; + +@Workflow +@WorkflowRegistrationOptions(defaultExecutionStartToCloseTimeoutSeconds = 300, defaultTaskStartToCloseTimeoutSeconds = 10) +public interface CronWithRetryWorkflow { + + /** + * Start workflow that executes activity according to options. + * + * @param activity + * activity type to execute + * @param activityArguments + * arguments passed to activity + * @param cronExpression + * time pattern in unix cron format. + * @param continueAsNewAfterSeconds + * frequency of a new workflow run creation + */ + @Execute(name = "CronWorkflow", version = "1.1") + void startCron(CronWithRetryWorkflowOptions options); + + @GetState + String getInvocationHistory(); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflowExecutionStarter.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflowExecutionStarter.java new file mode 100644 index 000000000000..0db1b3778853 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflowExecutionStarter.java @@ -0,0 +1,100 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cronwithretry; + +import java.util.ArrayList; +import java.util.List; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; +import com.amazonaws.services.simpleworkflow.model.ActivityType; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecutionAlreadyStartedException; + +public class CronWithRetryWorkflowExecutionStarter { + + private static AmazonSimpleWorkflow swfService; + + private static String domain; + + public static void main(String[] args) throws Exception { + + if (args.length != 3) { + System.err.println("Usage:\njava com.amazonaws.services.simpleworkflow.flow.examples.cron.CronWithRetryWorkflowExecutionStarter CRON_PATTERN TIME_ZONE CONTINUE_AS_NEW_AFTER_SECONDS"); + System.exit(1); + } + String cronPattern = args[0]; + String timeZone = args[1]; + int continueAsNewAfterSeconds = 0; + try { + continueAsNewAfterSeconds = Integer.parseInt(args[2]); + } + catch (NumberFormatException e) { + System.err.println("Value of CONTINUE_AS_NEW_AFTER_SECONDS is not int: " + args[2]); + System.exit(1); + } + // Load configuration + ConfigHelper configHelper = ConfigHelper.createConfig(); + + // Create the client for Simple Workflow Service + swfService = configHelper.createSWFClient(); + domain = configHelper.getDomain(); + + // Name and versions are hardcoded here but they can be passed as args or loaded from configuration file. + ActivityType activity = new ActivityType(); + activity.setName("CronWithRetryExampleActivities.doSomeWork"); + activity.setVersion("1.0"); + Object[] arguments = new Object[] { "parameter1" }; + + // Start Workflow execution + CronWithRetryWorkflowClientExternalFactory clientFactory = new CronWithRetryWorkflowClientExternalFactoryImpl(swfService, + domain); + + // Use Activity + cronPattern as instance id to ensure that only one workflow per pattern for a given activity is active at a time. + CronWithRetryWorkflowClientExternal workflow = clientFactory.getClient(activity.getName() + ": " + cronPattern); + + try { + CronWithRetryWorkflowOptions cronOptions = new CronWithRetryWorkflowOptions(); + cronOptions.setActivity(activity); + cronOptions.setActivityArguments(arguments); + cronOptions.setContinueAsNewAfterSeconds(continueAsNewAfterSeconds); + cronOptions.setTimeZone(timeZone); + cronOptions.setInitialRetryIntervalSeconds(1); + cronOptions.setMaximumRetryIntervalSeconds(60); + cronOptions.setRetryExpirationIntervalSeconds(300); + List exceptionsToRetry = new ArrayList(); + exceptionsToRetry.add(Throwable.class.getName()); + cronOptions.setExceptionsToRetry(exceptionsToRetry); + + // Every 10 seconds + cronOptions.setCronExpression(cronPattern); + workflow.startCron(cronOptions); + // WorkflowExecution is available after workflow creation + WorkflowExecution workflowExecution = workflow.getWorkflowExecution(); + System.out.println("Started Cron workflow with workflowId=\"" + workflowExecution.getWorkflowId() + "\" and runId=\"" + + workflowExecution.getRunId() + "\" with cron pattern=" + cronPattern); + } + catch (WorkflowExecutionAlreadyStartedException e) { + // It is expected to get this exception if start is called before workflow run is completed. + System.out.println("Cron workflow with workflowId=\"" + workflow.getWorkflowExecution().getWorkflowId() + + " is already running for the pattern=" + cronPattern); + } + // This is to demonstrate the @GetState annotated method getInvocationHistory + System.out.println("Sleeping for 60 seconds..."); + Thread.sleep(60000); + System.out.println("Invocation history after 60 seconds: \n" + workflow.getInvocationHistory()); + System.exit(0); + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflowImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflowImpl.java new file mode 100644 index 000000000000..817318930242 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflowImpl.java @@ -0,0 +1,186 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cronwithretry; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.TimeZone; + +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProviderImpl; +import com.amazonaws.services.simpleworkflow.flow.DynamicActivitiesClient; +import com.amazonaws.services.simpleworkflow.flow.DynamicActivitiesClientImpl; +import com.amazonaws.services.simpleworkflow.flow.WorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally; +import com.amazonaws.services.simpleworkflow.flow.interceptors.AsyncRetryingExecutor; +import com.amazonaws.services.simpleworkflow.flow.interceptors.AsyncRunnable; +import com.amazonaws.services.simpleworkflow.flow.interceptors.AsyncScheduledExecutor; +import com.amazonaws.services.simpleworkflow.flow.interceptors.ExponentialRetryPolicy; +import com.amazonaws.services.simpleworkflow.flow.spring.CronInvocationSchedule; + +/** + * Demonstrates how to create workflow that executes an activity on schedule + * specified as a "cron" string. Activity name and version are passed as input + * arguments of the workflow. In case of activity failures it is retried + * according to retry options passed as arguments of the workflow. + * + * @author fateev + */ +public class CronWithRetryWorkflowImpl implements CronWithRetryWorkflow { + + private static final int SECOND = 1000; + + /** + * This is needed to keep the decider logic deterministic as using + * System.currentTimeMillis() in your decider logic is not. + * WorkflowClock.currentTimeMillis() should be used instead. + */ + private final WorkflowClock clock; + + private final DynamicActivitiesClient activities; + + /** + * Used to create new run of the Cron workflow to reset history. This allows + * "infinite" workflows. + */ + private final CronWithRetryWorkflowSelfClient selfClient; + + private final StringBuilder invocationHistory = new StringBuilder(); + + private TimeZone tz; + + public CronWithRetryWorkflowImpl() { + this(new DecisionContextProviderImpl().getDecisionContext().getWorkflowClock(), new DynamicActivitiesClientImpl(), + new CronWithRetryWorkflowSelfClientImpl()); + } + + /** + * Constructor used for unit testing or configuration through IOC container + */ + public CronWithRetryWorkflowImpl(WorkflowClock clock, DynamicActivitiesClient activities, + CronWithRetryWorkflowSelfClient selfClient) { + this.clock = clock; + this.activities = activities; + this.selfClient = selfClient; + } + + @Override + public void startCron(final CronWithRetryWorkflowOptions options) { + Date expiration = new Date(clock.currentTimeMillis() + options.getContinueAsNewAfterSeconds() * SECOND); + tz = TimeZone.getTimeZone(options.getTimeZone()); + + // Activities client could be decorated directly using CronDecorator and RetryDecorator. + // But executors are used instead to enable updates to invocationHistory. + CronInvocationSchedule cronSchedule = new CronInvocationSchedule(options.getCronExpression(), expiration, tz); + AsyncScheduledExecutor scheduledExecutor = new AsyncScheduledExecutor(cronSchedule, clock); + ExponentialRetryPolicy retryPolicy = createRetryPolicyFromOptions(options); + final AsyncRetryingExecutor retryExecutor = new AsyncRetryingExecutor(retryPolicy, clock); + + scheduledExecutor.execute(new AsyncRunnable() { + + @Override + public void run() throws Throwable { + retryExecutor.execute(new AsyncRunnable() { + + @Override + public void run() throws Throwable { + executeActivityUpdatingInvocationHistory(options); + } + }); + } + }); + + // Start new workflow run as soon as cron decorator exits due to expiration. + // The call to self client indicates the desire to start the new run. + // It is started only after all other tasks in the given run are completed. + selfClient.startCron(options); + } + + @Override + public String getInvocationHistory() { + return invocationHistory.toString(); + } + + private void appendToInvocationHistory(String entry) { + if (invocationHistory.length() > 0) { + invocationHistory.append('\n'); + } + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + dateFormat.setTimeZone(tz); + invocationHistory.append(dateFormat.format(new Date(clock.currentTimeMillis()))); + invocationHistory.append(" "); + invocationHistory.append(entry); + } + + private void executeActivityUpdatingInvocationHistory(final CronWithRetryWorkflowOptions options) { + new TryCatchFinally() { + + boolean failed; + + @Override + protected void doTry() throws Throwable { + appendToInvocationHistory("starting"); + activities.scheduleActivity(options.getActivity(), options.getActivityArguments(), null, Void.class); + } + + @Override + protected void doCatch(Throwable e) throws Throwable { + failed = true; + appendToInvocationHistory("failure:" + e.getMessage()); + throw e; + } + + @Override + protected void doFinally() throws Throwable { + if (!failed) { + appendToInvocationHistory("completed"); + } + } + }; + } + + @SuppressWarnings("unchecked") + private ExponentialRetryPolicy createRetryPolicyFromOptions(CronWithRetryWorkflowOptions options) { + ExponentialRetryPolicy retryPolicy = new ExponentialRetryPolicy(options.getInitialRetryIntervalSeconds()); + retryPolicy.setBackoffCoefficient(options.getBackoffCoefficient()); + try { + List exceptionsToRetryClasses = options.getExceptionsToRetry(); + if (exceptionsToRetryClasses != null) { + List> exceptionsToRetry = new ArrayList>(); + for (String exceptionType : exceptionsToRetryClasses) { + exceptionsToRetry.add((Class) Class.forName(exceptionType)); + } + retryPolicy.setExceptionsToRetry(exceptionsToRetry); + } + List exceptionsToExcludeClasses = options.getExceptionsToExclude(); + if (exceptionsToExcludeClasses != null) { + List> exceptionsToExclude = new ArrayList>(); + for (String exceptionType : exceptionsToExcludeClasses) { + exceptionsToExclude.add((Class) Class.forName(exceptionType)); + } + retryPolicy.setExceptionsToExclude(exceptionsToExclude); + } + } + catch (ClassNotFoundException e) { + throw new IllegalArgumentException("Invalid options: " + options, e); + } + retryPolicy.setMaximumAttempts(options.getMaximumAttempts()); + retryPolicy.setMaximumRetryIntervalSeconds(options.getMaximumRetryIntervalSeconds()); + retryPolicy.setRetryExpirationIntervalSeconds(options.getRetryExpirationIntervalSeconds()); + return retryPolicy; + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflowOptions.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflowOptions.java new file mode 100644 index 000000000000..df78298698fa --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflowOptions.java @@ -0,0 +1,151 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cronwithretry; + +import java.util.List; + +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; +import com.amazonaws.services.simpleworkflow.flow.interceptors.ExponentialRetryPolicy; +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +/** + * See {@link ExponentialRetryPolicy} for description of retry related + * properties. + * + * @author fateev + */ +public class CronWithRetryWorkflowOptions { + + private ActivityType activity; + + private Object[] activityArguments; + + private String cronExpression; + + private String timeZone; + + private int continueAsNewAfterSeconds; + + private List exceptionsToRetry; + + private List exceptionsToExclude; + + private long initialRetryIntervalSeconds = 60; + + private long maximumRetryIntervalSeconds = 3600; + + private long retryExpirationIntervalSeconds = FlowConstants.NONE; + + private double backoffCoefficient = 2.0; + + private int maximumAttempts = FlowConstants.NONE; + + public ActivityType getActivity() { + return activity; + } + + public void setActivity(ActivityType activity) { + this.activity = activity; + } + + public Object[] getActivityArguments() { + return activityArguments; + } + + public void setActivityArguments(Object[] activityArguments) { + this.activityArguments = activityArguments; + } + + public String getCronExpression() { + return cronExpression; + } + + public void setCronExpression(String cronExpression) { + this.cronExpression = cronExpression; + } + + public String getTimeZone() { + return timeZone; + } + + public void setTimeZone(String timeZone) { + this.timeZone = timeZone; + } + + public int getContinueAsNewAfterSeconds() { + return continueAsNewAfterSeconds; + } + + public void setContinueAsNewAfterSeconds(int continueAsNewAfterSeconds) { + this.continueAsNewAfterSeconds = continueAsNewAfterSeconds; + } + + public List getExceptionsToRetry() { + return exceptionsToRetry; + } + + public void setExceptionsToRetry(List exceptionsToRetry) { + this.exceptionsToRetry = exceptionsToRetry; + } + + public List getExceptionsToExclude() { + return exceptionsToExclude; + } + + public void setExceptionsToExclude(List exceptionsToExclude) { + this.exceptionsToExclude = exceptionsToExclude; + } + + public long getInitialRetryIntervalSeconds() { + return initialRetryIntervalSeconds; + } + + public void setInitialRetryIntervalSeconds(long initialRetryIntervalSeconds) { + this.initialRetryIntervalSeconds = initialRetryIntervalSeconds; + } + + public long getMaximumRetryIntervalSeconds() { + return maximumRetryIntervalSeconds; + } + + public void setMaximumRetryIntervalSeconds(long maximumRetryIntervalSeconds) { + this.maximumRetryIntervalSeconds = maximumRetryIntervalSeconds; + } + + public long getRetryExpirationIntervalSeconds() { + return retryExpirationIntervalSeconds; + } + + public void setRetryExpirationIntervalSeconds(long retryExpirationIntervalSeconds) { + this.retryExpirationIntervalSeconds = retryExpirationIntervalSeconds; + } + + public double getBackoffCoefficient() { + return backoffCoefficient; + } + + public void setBackoffCoefficient(double backoffCoefficient) { + this.backoffCoefficient = backoffCoefficient; + } + + public int getMaximumAttempts() { + return maximumAttempts; + } + + public void setMaximumAttempts(int maximumAttempts) { + this.maximumAttempts = maximumAttempts; + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflowTest.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflowTest.java new file mode 100644 index 000000000000..3076d9ac6a3c --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/CronWithRetryWorkflowTest.java @@ -0,0 +1,149 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cronwithretry; + +import java.util.concurrent.CancellationException; + +import junit.framework.Assert; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProviderImpl; +import com.amazonaws.services.simpleworkflow.flow.WorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally; +import com.amazonaws.services.simpleworkflow.flow.junit.FlowBlockJUnit4ClassRunner; +import com.amazonaws.services.simpleworkflow.flow.junit.WorkflowTest; +import com.amazonaws.services.simpleworkflow.model.ActivityType; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +@RunWith(FlowBlockJUnit4ClassRunner.class) +public class CronWithRetryWorkflowTest { + + private final class TestCronWithRetryWorkflowActivities implements CronWithRetryExampleActivities { + + private final ActivityExecutionContextProvider contextProvider = new ActivityExecutionContextProviderImpl(); + + private int workCount; + + private int runCount; + + private String runId; + + @Override + public void doSomeWork(String parameter) { + // Reset counter on the new run which changes when workflow continues as new + ActivityExecutionContext activityExecutionContext = contextProvider.getActivityExecutionContext(); + WorkflowExecution workflowExecution = activityExecutionContext.getWorkflowExecution(); + String runId = workflowExecution.getRunId(); + if (this.runId == null || !runId.equals(this.runId)) { + runCount++; + } + this.runId = runId; + workCount++; + if (workCount % 2 != 0) { + throw new RuntimeException("simulated failure to cause retry"); + } + } + + public int getWorkCount() { + return workCount; + } + + public int getRunCount() { + return runCount; + } + } + + private static final int SECONDS_HOUR = 3600; + + @Rule + public WorkflowTest workflowTest = new WorkflowTest(); + + private CronWithRetryWorkflowClientFactory workflowClientFactory = new CronWithRetryWorkflowClientFactoryImpl(); + + private TestCronWithRetryWorkflowActivities cronActivitiesImplementation; + + @Before + public void setUp() throws Exception { + cronActivitiesImplementation = new TestCronWithRetryWorkflowActivities(); + workflowTest.addActivitiesImplementation(cronActivitiesImplementation); + workflowTest.addWorkflowImplementationType(CronWithRetryWorkflowImpl.class); + workflowTest.setDisableOutstandingTasksCheck(true); + } + + @After + public void tearDown() throws Exception { + } + + @Test(timeout = 2000) + public void testCronWithFailures() { + workflowTest.setClockAccelerationCoefficient(SECONDS_HOUR * 24 * 7 * 2); + final CronWithRetryWorkflowClient workflow = workflowClientFactory.getClient(); + + final ActivityType activityType = new ActivityType(); + activityType.setName("CronWithRetryExampleActivities.doSomeWork"); + activityType.setVersion("1.0"); + final Object[] activityArguments = new Object[] { "parameter1" }; + + final CronWithRetryWorkflowOptions cronOptions = new CronWithRetryWorkflowOptions(); + cronOptions.setActivity(activityType); + cronOptions.setActivityArguments(activityArguments); + cronOptions.setContinueAsNewAfterSeconds(SECONDS_HOUR * 24 + 300); + cronOptions.setTimeZone("PST"); + cronOptions.setInitialRetryIntervalSeconds(30); + cronOptions.setMaximumRetryIntervalSeconds(600); + cronOptions.setRetryExpirationIntervalSeconds(3500); + final String cronExpression = "0 0 * * * *"; + cronOptions.setCronExpression(cronExpression); + + WorkflowClock clock = workflowTest.getDecisionContext().getWorkflowClock(); + clock.createTimer(SECONDS_HOUR * 24 * 7 + 1000); + // true constructor argument makes TryCatchFinally a daemon which causes it get cancelled after above timer firing + new TryCatchFinally(true) { + + Throwable failure; + + @Override + protected void doTry() throws Throwable { + workflow.startCron(cronOptions); + } + + @Override + protected void doCatch(Throwable e) throws Throwable { + failure = e; + throw e; + } + + @Override + protected void doFinally() throws Throwable { + // Skip assertions as their failure masks original exception + if (failure == null || failure instanceof CancellationException) { + // Note the 2 activity invocations for each cron invocation as half of the + // invocations failed and were retried. + Assert.assertEquals(24 * 7 * 2, cronActivitiesImplementation.getWorkCount()); + Assert.assertEquals(7, cronActivitiesImplementation.getRunCount()); + } + } + + }; + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/WorkflowHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/WorkflowHost.java new file mode 100644 index 000000000000..ed6f67f72e8b --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/cronwithretry/WorkflowHost.java @@ -0,0 +1,66 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.cronwithretry; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.WorkflowWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +public class WorkflowHost { + + public static final String DECISION_TASK_LIST = "PeriodicWorkflow"; + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + final WorkflowWorker worker = new WorkflowWorker(swfService, domain, DECISION_TASK_LIST); + worker.addWorkflowImplementationType(CronWithRetryWorkflowImpl.class); + worker.setRegisterDomain(true); + worker.setDomainRetentionPeriodInDays(1); + worker.start(); + + System.out.println("Workflow Host Service Started..."); + + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + worker.shutdownAndAwaitTermination(1, TimeUnit.MINUTES); + System.out.println("Workflow Host Service Terminated..."); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + System.out.println("Please press any key to terminate service."); + + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + + System.exit(0); + + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentCommon-context.xml b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentCommon-context.xml index e259ce1db0bc..014732b71392 100644 --- a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentCommon-context.xml +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentCommon-context.xml @@ -1,4 +1,18 @@ + + + +