You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/04/09 14:08:27 UTC
[camel] branch master updated (34c1bc8 -> e888839)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.
from 34c1bc8 Regen
new df509d9 CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-ecs
new a57aa91 CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-ecs fixed CS
new 4ba9e85 CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-ecs fixed CS
new b4b4651 CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-ecs
new 11c5ab1 CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-ecs fixed CS
new e888839 Regen
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../aws2/ecs/ECS2ComponentConfigurer.java | 5 +
.../component/aws2/ecs/ECS2EndpointConfigurer.java | 5 +
.../apache/camel/component/aws2/ecs/aws2-ecs.json | 2 +
.../src/main/docs/aws2-ecs-component.adoc | 6 +-
.../component/aws2/ecs/ECS2Configuration.java | 13 ++
.../camel/component/aws2/ecs/ECS2Producer.java | 187 ++++++++++++++-------
.../component/aws2/ecs/ECS2ProducerSpringTest.java | 22 ++-
.../camel/component/aws2/ecs/ECS2ProducerTest.java | 23 ++-
.../aws2/ecs/ECSComponentSpringTest-context.xml | 5 +
.../dsl/Aws2EcsComponentBuilderFactory.java | 13 ++
.../src/generated/resources/metadata.json | 2 +-
.../endpoint/dsl/ECS2EndpointBuilderFactory.java | 24 +++
.../modules/ROOT/pages/aws2-ecs-component.adoc | 6 +-
13 files changed, 245 insertions(+), 68 deletions(-)
[camel] 02/06: CAMEL-14868 - Camel-AWS2-*: Where possible,
give the possiblity to the end user to pass an AWS Request pojo as
body, aws2-ecs fixed CS
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a57aa914ee460cbbf0ba7982449a78f69c047583
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Apr 9 15:54:08 2020 +0200
CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-ecs fixed CS
---
.../camel/component/aws2/ecs/ECS2Producer.java | 136 ++++++++++-----------
1 file changed, 68 insertions(+), 68 deletions(-)
diff --git a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
index 6bdef43..ca7da05 100644
--- a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
+++ b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
@@ -102,7 +102,7 @@ public class ECS2Producer extends DefaultProducer {
Object payload = exchange.getIn().getBody();
ListClustersResponse result;
try {
- ListClustersRequest request = (ListClustersRequest) payload;
+ ListClustersRequest request = (ListClustersRequest)payload;
result = ecsClient.listClusters(request);
} catch (AwsServiceException ase) {
LOG.trace("List Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
@@ -113,21 +113,21 @@ public class ECS2Producer extends DefaultProducer {
}
}
} else {
- Builder builder = ListClustersRequest.builder();
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.MAX_RESULTS))) {
- int maxRes = exchange.getIn().getHeader(ECS2Constants.MAX_RESULTS, Integer.class);
- builder.maxResults(maxRes);
- }
- ListClustersResponse result;
- try {
- ListClustersRequest request = builder.build();
- result = ecsClient.listClusters(request);
- } catch (AwsServiceException ase) {
- LOG.trace("List Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
- }
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
+ Builder builder = ListClustersRequest.builder();
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.MAX_RESULTS))) {
+ int maxRes = exchange.getIn().getHeader(ECS2Constants.MAX_RESULTS, Integer.class);
+ builder.maxResults(maxRes);
+ }
+ ListClustersResponse result;
+ try {
+ ListClustersRequest request = builder.build();
+ result = ecsClient.listClusters(request);
+ } catch (AwsServiceException ase) {
+ LOG.trace("List Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
}
}
@@ -137,7 +137,7 @@ public class ECS2Producer extends DefaultProducer {
Object payload = exchange.getIn().getBody();
CreateClusterResponse result;
try {
- CreateClusterRequest request = (CreateClusterRequest) payload;
+ CreateClusterRequest request = (CreateClusterRequest)payload;
result = ecsClient.createCluster(request);
} catch (AwsServiceException ase) {
LOG.trace("Create Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
@@ -146,23 +146,23 @@ public class ECS2Producer extends DefaultProducer {
Message message = getMessageForResponse(exchange);
message.setBody(result);
}
- } else {
- CreateClusterRequest.Builder builder = CreateClusterRequest.builder();
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
- String name = exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME, String.class);
- builder.clusterName(name);
- }
- CreateClusterResponse result;
- try {
- CreateClusterRequest request = builder.build();
- result = ecsClient.createCluster(request);
- } catch (AwsServiceException ase) {
- LOG.trace("Create Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
+ } else {
+ CreateClusterRequest.Builder builder = CreateClusterRequest.builder();
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
+ String name = exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME, String.class);
+ builder.clusterName(name);
+ }
+ CreateClusterResponse result;
+ try {
+ CreateClusterRequest request = builder.build();
+ result = ecsClient.createCluster(request);
+ } catch (AwsServiceException ase) {
+ LOG.trace("Create Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
}
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
- }
}
private void describeCluster(EcsClient ecsClient, Exchange exchange) {
@@ -171,7 +171,7 @@ public class ECS2Producer extends DefaultProducer {
Object payload = exchange.getIn().getBody();
DescribeClustersResponse result;
try {
- DescribeClustersRequest request = (DescribeClustersRequest) payload;
+ DescribeClustersRequest request = (DescribeClustersRequest)payload;
result = ecsClient.describeClusters(request);
} catch (AwsServiceException ase) {
LOG.trace("Describe Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
@@ -180,23 +180,23 @@ public class ECS2Producer extends DefaultProducer {
Message message = getMessageForResponse(exchange);
message.setBody(result);
}
- } else {
- DescribeClustersRequest.Builder builder = DescribeClustersRequest.builder();
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
- String clusterName = exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME, String.class);
- builder.clusters(clusterName);
- }
- DescribeClustersResponse result;
- try {
- DescribeClustersRequest request = builder.build();
- result = ecsClient.describeClusters(request);
- } catch (AwsServiceException ase) {
- LOG.trace("Describe Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
+ } else {
+ DescribeClustersRequest.Builder builder = DescribeClustersRequest.builder();
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
+ String clusterName = exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME, String.class);
+ builder.clusters(clusterName);
+ }
+ DescribeClustersResponse result;
+ try {
+ DescribeClustersRequest request = builder.build();
+ result = ecsClient.describeClusters(request);
+ } catch (AwsServiceException ase) {
+ LOG.trace("Describe Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
}
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
- }
}
private void deleteCluster(EcsClient ecsClient, Exchange exchange) {
@@ -205,7 +205,7 @@ public class ECS2Producer extends DefaultProducer {
Object payload = exchange.getIn().getBody();
DeleteClusterResponse result;
try {
- DeleteClusterRequest request = (DeleteClusterRequest) payload;
+ DeleteClusterRequest request = (DeleteClusterRequest)payload;
result = ecsClient.deleteCluster(request);
} catch (AwsServiceException ase) {
LOG.trace("Delete Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
@@ -214,25 +214,25 @@ public class ECS2Producer extends DefaultProducer {
Message message = getMessageForResponse(exchange);
message.setBody(result);
}
- } else {
- DeleteClusterRequest.Builder builder = DeleteClusterRequest.builder();
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
- String name = exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME, String.class);
- builder.cluster(name);
} else {
- throw new IllegalArgumentException("Cluster name must be specified");
- }
- DeleteClusterResponse result;
- try {
- DeleteClusterRequest request = builder.build();
- result = ecsClient.deleteCluster(request);
- } catch (AwsServiceException ase) {
- LOG.trace("Delete Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
+ DeleteClusterRequest.Builder builder = DeleteClusterRequest.builder();
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
+ String name = exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME, String.class);
+ builder.cluster(name);
+ } else {
+ throw new IllegalArgumentException("Cluster name must be specified");
+ }
+ DeleteClusterResponse result;
+ try {
+ DeleteClusterRequest request = builder.build();
+ result = ecsClient.deleteCluster(request);
+ } catch (AwsServiceException ase) {
+ LOG.trace("Delete Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
}
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
- }
}
public static Message getMessageForResponse(final Exchange exchange) {
[camel] 05/06: CAMEL-14868 - Camel-AWS2-*: Where possible,
give the possiblity to the end user to pass an AWS Request pojo as
body, aws2-ecs fixed CS
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 11c5ab1e964383103d364e64f0c381648ddd361e
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Apr 9 16:03:56 2020 +0200
CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-ecs fixed CS
---
.../camel/component/aws2/ecs/ECS2Producer.java | 28 +++++++++++-----------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
index 751143a..ad0fdbf 100644
--- a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
+++ b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
@@ -99,18 +99,18 @@ public class ECS2Producer extends DefaultProducer {
private void listClusters(EcsClient ecsClient, Exchange exchange) throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getIn().getMandatoryBody();
- if (payload instanceof ListClustersRequest) {
- ListClustersResponse result;
- try {
- ListClustersRequest request = (ListClustersRequest)payload;
- result = ecsClient.listClusters(request);
- } catch (AwsServiceException ase) {
- LOG.trace("List Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
- }
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
+ if (payload instanceof ListClustersRequest) {
+ ListClustersResponse result;
+ try {
+ ListClustersRequest request = (ListClustersRequest)payload;
+ result = ecsClient.listClusters(request);
+ } catch (AwsServiceException ase) {
+ LOG.trace("List Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
}
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
+ }
} else {
Builder builder = ListClustersRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.MAX_RESULTS))) {
@@ -144,7 +144,7 @@ public class ECS2Producer extends DefaultProducer {
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
- }
+ }
} else {
CreateClusterRequest.Builder builder = CreateClusterRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
@@ -178,7 +178,7 @@ public class ECS2Producer extends DefaultProducer {
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
- }
+ }
} else {
DescribeClustersRequest.Builder builder = DescribeClustersRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
@@ -212,7 +212,7 @@ public class ECS2Producer extends DefaultProducer {
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
- }
+ }
} else {
DeleteClusterRequest.Builder builder = DeleteClusterRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
[camel] 01/06: CAMEL-14868 - Camel-AWS2-*: Where possible,
give the possiblity to the end user to pass an AWS Request pojo as
body, aws2-ecs
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit df509d90f00ae9d84296cee45782f520ab7a7c2d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Apr 9 15:52:36 2020 +0200
CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-ecs
---
.../aws2/ecs/ECS2ComponentConfigurer.java | 5 ++
.../component/aws2/ecs/ECS2EndpointConfigurer.java | 5 ++
.../apache/camel/component/aws2/ecs/aws2-ecs.json | 2 +
.../src/main/docs/aws2-ecs-component.adoc | 6 +-
.../component/aws2/ecs/ECS2Configuration.java | 13 +++++
.../camel/component/aws2/ecs/ECS2Producer.java | 66 ++++++++++++++++++++++
.../dsl/Aws2EcsComponentBuilderFactory.java | 13 +++++
.../src/generated/resources/metadata.json | 2 +-
.../endpoint/dsl/ECS2EndpointBuilderFactory.java | 24 ++++++++
9 files changed, 133 insertions(+), 3 deletions(-)
diff --git a/components/camel-aws2-ecs/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurer.java b/components/camel-aws2-ecs/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurer.java
index b123a6b..eabba99 100644
--- a/components/camel-aws2-ecs/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurer.java
+++ b/components/camel-aws2-ecs/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurer.java
@@ -36,6 +36,8 @@ public class ECS2ComponentConfigurer extends PropertyConfigurerSupport implement
case "lazystartproducer":
case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
case "operation": getOrCreateConfiguration(target).setOperation(property(camelContext, org.apache.camel.component.aws2.ecs.ECS2Operations.class, value)); return true;
+ case "pojorequest":
+ case "pojoRequest": getOrCreateConfiguration(target).setPojoRequest(property(camelContext, boolean.class, value)); return true;
case "proxyhost":
case "proxyHost": getOrCreateConfiguration(target).setProxyHost(property(camelContext, java.lang.String.class, value)); return true;
case "proxyport":
@@ -58,6 +60,7 @@ public class ECS2ComponentConfigurer extends PropertyConfigurerSupport implement
answer.put("ecsClient", software.amazon.awssdk.services.ecs.EcsClient.class);
answer.put("lazyStartProducer", boolean.class);
answer.put("operation", org.apache.camel.component.aws2.ecs.ECS2Operations.class);
+ answer.put("pojoRequest", boolean.class);
answer.put("proxyHost", java.lang.String.class);
answer.put("proxyPort", java.lang.Integer.class);
answer.put("proxyProtocol", software.amazon.awssdk.core.Protocol.class);
@@ -80,6 +83,8 @@ public class ECS2ComponentConfigurer extends PropertyConfigurerSupport implement
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
case "operation": return getOrCreateConfiguration(target).getOperation();
+ case "pojorequest":
+ case "pojoRequest": return getOrCreateConfiguration(target).isPojoRequest();
case "proxyhost":
case "proxyHost": return getOrCreateConfiguration(target).getProxyHost();
case "proxyport":
diff --git a/components/camel-aws2-ecs/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2EndpointConfigurer.java b/components/camel-aws2-ecs/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2EndpointConfigurer.java
index 7c6d502..1f392b6 100644
--- a/components/camel-aws2-ecs/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2EndpointConfigurer.java
+++ b/components/camel-aws2-ecs/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2EndpointConfigurer.java
@@ -28,6 +28,8 @@ public class ECS2EndpointConfigurer extends PropertyConfigurerSupport implements
case "lazystartproducer":
case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
case "operation": target.getConfiguration().setOperation(property(camelContext, org.apache.camel.component.aws2.ecs.ECS2Operations.class, value)); return true;
+ case "pojorequest":
+ case "pojoRequest": target.getConfiguration().setPojoRequest(property(camelContext, boolean.class, value)); return true;
case "proxyhost":
case "proxyHost": target.getConfiguration().setProxyHost(property(camelContext, java.lang.String.class, value)); return true;
case "proxyport":
@@ -50,6 +52,7 @@ public class ECS2EndpointConfigurer extends PropertyConfigurerSupport implements
answer.put("ecsClient", software.amazon.awssdk.services.ecs.EcsClient.class);
answer.put("lazyStartProducer", boolean.class);
answer.put("operation", org.apache.camel.component.aws2.ecs.ECS2Operations.class);
+ answer.put("pojoRequest", boolean.class);
answer.put("proxyHost", java.lang.String.class);
answer.put("proxyPort", java.lang.Integer.class);
answer.put("proxyProtocol", software.amazon.awssdk.core.Protocol.class);
@@ -72,6 +75,8 @@ public class ECS2EndpointConfigurer extends PropertyConfigurerSupport implements
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
case "operation": return target.getConfiguration().getOperation();
+ case "pojorequest":
+ case "pojoRequest": return target.getConfiguration().isPojoRequest();
case "proxyhost":
case "proxyHost": return target.getConfiguration().getProxyHost();
case "proxyport":
diff --git a/components/camel-aws2-ecs/src/generated/resources/org/apache/camel/component/aws2/ecs/aws2-ecs.json b/components/camel-aws2-ecs/src/generated/resources/org/apache/camel/component/aws2/ecs/aws2-ecs.json
index 5e28d2f..536ac60 100644
--- a/components/camel-aws2-ecs/src/generated/resources/org/apache/camel/component/aws2/ecs/aws2-ecs.json
+++ b/components/camel-aws2-ecs/src/generated/resources/org/apache/camel/component/aws2/ecs/aws2-ecs.json
@@ -25,6 +25,7 @@
"ecsClient": { "kind": "property", "displayName": "Ecs Client", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.ecs.EcsClient", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ecs.ECS2Configuration", "configurationField": "configuration", "description": "To use a existing configured AWS ECS as client" },
"lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the r [...]
"operation": { "kind": "property", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.aws2.ecs.ECS2Operations", "enum": [ "listClusters", "describeCluster", "createCluster", "deleteCluster" ], "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.aws2.ecs.ECS2Configuration", "configurationField": "configuration", "description": "The operation [...]
+ "pojoRequest": { "kind": "property", "displayName": "Pojo Request", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.ecs.ECS2Configuration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" },
"proxyHost": { "kind": "property", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ecs.ECS2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the ECS client" },
"proxyPort": { "kind": "property", "displayName": "Proxy Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ecs.ECS2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the ECS client" },
"proxyProtocol": { "kind": "property", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.ecs.ECS2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the ECS client" },
@@ -38,6 +39,7 @@
"ecsClient": { "kind": "parameter", "displayName": "Ecs Client", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.ecs.EcsClient", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ecs.ECS2Configuration", "configurationField": "configuration", "description": "To use a existing configured AWS ECS as client" },
"lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the [...]
"operation": { "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.aws2.ecs.ECS2Operations", "enum": [ "listClusters", "describeCluster", "createCluster", "deleteCluster" ], "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.aws2.ecs.ECS2Configuration", "configurationField": "configuration", "description": "The operatio [...]
+ "pojoRequest": { "kind": "parameter", "displayName": "Pojo Request", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.ecs.ECS2Configuration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" },
"proxyHost": { "kind": "parameter", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ecs.ECS2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the ECS client" },
"proxyPort": { "kind": "parameter", "displayName": "Proxy Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.ecs.ECS2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the ECS client" },
"proxyProtocol": { "kind": "parameter", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.ecs.ECS2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the ECS client" },
diff --git a/components/camel-aws2-ecs/src/main/docs/aws2-ecs-component.adoc b/components/camel-aws2-ecs/src/main/docs/aws2-ecs-component.adoc
index 5720127..9351490 100644
--- a/components/camel-aws2-ecs/src/main/docs/aws2-ecs-component.adoc
+++ b/components/camel-aws2-ecs/src/main/docs/aws2-ecs-component.adoc
@@ -38,7 +38,7 @@ You can append query options to the URI in the following format,
// component options: START
-The AWS 2 ECS component supports 11 options, which are listed below.
+The AWS 2 ECS component supports 12 options, which are listed below.
@@ -49,6 +49,7 @@ The AWS 2 ECS component supports 11 options, which are listed below.
| *ecsClient* (producer) | To use a existing configured AWS ECS as client | | EcsClient
| *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
| *operation* (producer) | *Required* The operation to perform. The value can be one of: listClusters, describeCluster, createCluster, deleteCluster | | ECS2Operations
+| *pojoRequest* (producer) | If we want to use a POJO request as body or not | false | boolean
| *proxyHost* (producer) | To define a proxy host when instantiating the ECS client | | String
| *proxyPort* (producer) | To define a proxy port when instantiating the ECS client | | Integer
| *proxyProtocol* (producer) | To define a proxy protocol when instantiating the ECS client. The value can be one of: HTTP, HTTPS | HTTPS | Protocol
@@ -81,7 +82,7 @@ with the following path and query parameters:
|===
-=== Query Parameters (11 parameters):
+=== Query Parameters (12 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
@@ -90,6 +91,7 @@ with the following path and query parameters:
| *ecsClient* (producer) | To use a existing configured AWS ECS as client | | EcsClient
| *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
| *operation* (producer) | *Required* The operation to perform. The value can be one of: listClusters, describeCluster, createCluster, deleteCluster | | ECS2Operations
+| *pojoRequest* (producer) | If we want to use a POJO request as body or not | false | boolean
| *proxyHost* (producer) | To define a proxy host when instantiating the ECS client | | String
| *proxyPort* (producer) | To define a proxy port when instantiating the ECS client | | Integer
| *proxyProtocol* (producer) | To define a proxy protocol when instantiating the ECS client. The value can be one of: HTTP, HTTPS | HTTPS | Protocol
diff --git a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Configuration.java b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Configuration.java
index 895d138..f63e389 100644
--- a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Configuration.java
+++ b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Configuration.java
@@ -47,6 +47,8 @@ public class ECS2Configuration implements Cloneable {
private Integer proxyPort;
@UriParam
private String region;
+ @UriParam(defaultValue = "false")
+ private boolean pojoRequest;
public EcsClient getEcsClient() {
return ecsClient;
@@ -138,6 +140,17 @@ public class ECS2Configuration implements Cloneable {
public void setRegion(String region) {
this.region = region;
}
+
+ public boolean isPojoRequest() {
+ return pojoRequest;
+ }
+
+ /**
+ * If we want to use a POJO request as body or not
+ */
+ public void setPojoRequest(boolean pojoRequest) {
+ this.pojoRequest = pojoRequest;
+ }
// *************************************************
//
diff --git a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
index 3f5a706..6bdef43 100644
--- a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
+++ b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
@@ -96,6 +96,23 @@ public class ECS2Producer extends DefaultProducer {
}
private void listClusters(EcsClient ecsClient, Exchange exchange) {
+ if (getConfiguration().isPojoRequest()) {
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getBody())) {
+ if (exchange.getIn().getBody() instanceof ListClustersRequest) {
+ Object payload = exchange.getIn().getBody();
+ ListClustersResponse result;
+ try {
+ ListClustersRequest request = (ListClustersRequest) payload;
+ result = ecsClient.listClusters(request);
+ } catch (AwsServiceException ase) {
+ LOG.trace("List Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
+ }
+ }
+ } else {
Builder builder = ListClustersRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.MAX_RESULTS))) {
int maxRes = exchange.getIn().getHeader(ECS2Constants.MAX_RESULTS, Integer.class);
@@ -111,9 +128,25 @@ public class ECS2Producer extends DefaultProducer {
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
+ }
}
private void createCluster(EcsClient ecsClient, Exchange exchange) {
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getBody())) {
+ if (exchange.getIn().getBody() instanceof CreateClusterRequest) {
+ Object payload = exchange.getIn().getBody();
+ CreateClusterResponse result;
+ try {
+ CreateClusterRequest request = (CreateClusterRequest) payload;
+ result = ecsClient.createCluster(request);
+ } catch (AwsServiceException ase) {
+ LOG.trace("Create Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
+ }
+ } else {
CreateClusterRequest.Builder builder = CreateClusterRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
String name = exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME, String.class);
@@ -130,8 +163,24 @@ public class ECS2Producer extends DefaultProducer {
Message message = getMessageForResponse(exchange);
message.setBody(result);
}
+ }
private void describeCluster(EcsClient ecsClient, Exchange exchange) {
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getBody())) {
+ if (exchange.getIn().getBody() instanceof DescribeClustersRequest) {
+ Object payload = exchange.getIn().getBody();
+ DescribeClustersResponse result;
+ try {
+ DescribeClustersRequest request = (DescribeClustersRequest) payload;
+ result = ecsClient.describeClusters(request);
+ } catch (AwsServiceException ase) {
+ LOG.trace("Describe Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
+ }
+ } else {
DescribeClustersRequest.Builder builder = DescribeClustersRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
String clusterName = exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME, String.class);
@@ -148,8 +197,24 @@ public class ECS2Producer extends DefaultProducer {
Message message = getMessageForResponse(exchange);
message.setBody(result);
}
+ }
private void deleteCluster(EcsClient ecsClient, Exchange exchange) {
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getBody())) {
+ if (exchange.getIn().getBody() instanceof DeleteClusterRequest) {
+ Object payload = exchange.getIn().getBody();
+ DeleteClusterResponse result;
+ try {
+ DeleteClusterRequest request = (DeleteClusterRequest) payload;
+ result = ecsClient.deleteCluster(request);
+ } catch (AwsServiceException ase) {
+ LOG.trace("Delete Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
+ }
+ } else {
DeleteClusterRequest.Builder builder = DeleteClusterRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
String name = exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME, String.class);
@@ -168,6 +233,7 @@ public class ECS2Producer extends DefaultProducer {
Message message = getMessageForResponse(exchange);
message.setBody(result);
}
+ }
public static Message getMessageForResponse(final Exchange exchange) {
return exchange.getMessage();
diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EcsComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EcsComponentBuilderFactory.java
index b43e1ef..0689830 100644
--- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EcsComponentBuilderFactory.java
+++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2EcsComponentBuilderFactory.java
@@ -108,6 +108,18 @@ public interface Aws2EcsComponentBuilderFactory {
return this;
}
/**
+ * If we want to use a POJO request as body or not.
+ *
+ * The option is a: <code>boolean</code> type.
+ *
+ * Default: false
+ * Group: producer
+ */
+ default Aws2EcsComponentBuilder pojoRequest(boolean pojoRequest) {
+ doSetProperty("pojoRequest", pojoRequest);
+ return this;
+ }
+ /**
* To define a proxy host when instantiating the ECS client.
*
* The option is a: <code>java.lang.String</code> type.
@@ -221,6 +233,7 @@ public interface Aws2EcsComponentBuilderFactory {
case "ecsClient": getOrCreateConfiguration((ECS2Component) component).setEcsClient((software.amazon.awssdk.services.ecs.EcsClient) value); return true;
case "lazyStartProducer": ((ECS2Component) component).setLazyStartProducer((boolean) value); return true;
case "operation": getOrCreateConfiguration((ECS2Component) component).setOperation((org.apache.camel.component.aws2.ecs.ECS2Operations) value); return true;
+ case "pojoRequest": getOrCreateConfiguration((ECS2Component) component).setPojoRequest((boolean) value); return true;
case "proxyHost": getOrCreateConfiguration((ECS2Component) component).setProxyHost((java.lang.String) value); return true;
case "proxyPort": getOrCreateConfiguration((ECS2Component) component).setProxyPort((java.lang.Integer) value); return true;
case "proxyProtocol": getOrCreateConfiguration((ECS2Component) component).setProxyProtocol((software.amazon.awssdk.core.Protocol) value); return true;
diff --git a/core/camel-componentdsl/src/generated/resources/metadata.json b/core/camel-componentdsl/src/generated/resources/metadata.json
index 8b42e4c..798576f 100644
--- a/core/camel-componentdsl/src/generated/resources/metadata.json
+++ b/core/camel-componentdsl/src/generated/resources/metadata.json
@@ -502,7 +502,6 @@
"lenientProperties": false,
"javaType": "org.apache.camel.component.aws2.ecs.ECS2Component",
"firstVersion": "3.1.0",
- "supportLevel": "Stable",
"groupId": "org.apache.camel",
"artifactId": "camel-aws2-ecs",
"version": "3.3.0-SNAPSHOT"
@@ -7599,6 +7598,7 @@
"lenientProperties": false,
"javaType": "org.apache.camel.component.zookeeper.ZooKeeperComponent",
"firstVersion": "2.9.0",
+ "supportLevel": "Stable",
"groupId": "org.apache.camel",
"artifactId": "camel-zookeeper",
"version": "3.3.0-SNAPSHOT"
diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ECS2EndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ECS2EndpointBuilderFactory.java
index 682971a..c8c1b77 100644
--- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ECS2EndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ECS2EndpointBuilderFactory.java
@@ -128,6 +128,30 @@ public interface ECS2EndpointBuilderFactory {
return this;
}
/**
+ * If we want to use a POJO request as body or not.
+ *
+ * The option is a: <code>boolean</code> type.
+ *
+ * Default: false
+ * Group: producer
+ */
+ default ECS2EndpointBuilder pojoRequest(boolean pojoRequest) {
+ doSetProperty("pojoRequest", pojoRequest);
+ return this;
+ }
+ /**
+ * If we want to use a POJO request as body or not.
+ *
+ * The option will be converted to a <code>boolean</code> type.
+ *
+ * Default: false
+ * Group: producer
+ */
+ default ECS2EndpointBuilder pojoRequest(String pojoRequest) {
+ doSetProperty("pojoRequest", pojoRequest);
+ return this;
+ }
+ /**
* To define a proxy host when instantiating the ECS client.
*
* The option is a: <code>java.lang.String</code> type.
[camel] 03/06: CAMEL-14868 - Camel-AWS2-*: Where possible,
give the possiblity to the end user to pass an AWS Request pojo as
body, aws2-ecs fixed CS
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 4ba9e8544f04299d1557bc44d4e50d207adca2af
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Apr 9 15:58:14 2020 +0200
CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-ecs fixed CS
---
.../component/aws2/ecs/ECS2ProducerSpringTest.java | 22 ++++++++++++++++++++-
.../camel/component/aws2/ecs/ECS2ProducerTest.java | 23 +++++++++++++++++++++-
.../aws2/ecs/ECSComponentSpringTest-context.xml | 5 +++++
3 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerSpringTest.java b/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerSpringTest.java
index 286f9d7..b5d7858 100644
--- a/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerSpringTest.java
+++ b/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerSpringTest.java
@@ -26,6 +26,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import software.amazon.awssdk.services.ecs.model.CreateClusterResponse;
import software.amazon.awssdk.services.ecs.model.DeleteClusterResponse;
import software.amazon.awssdk.services.ecs.model.DescribeClustersResponse;
+import software.amazon.awssdk.services.ecs.model.ListClustersRequest;
import software.amazon.awssdk.services.ecs.model.ListClustersResponse;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -36,7 +37,7 @@ public class ECS2ProducerSpringTest extends CamelSpringTestSupport {
private MockEndpoint mock;
@Test
- public void kmsListClustersTest() throws Exception {
+ public void ecsListClustersTest() throws Exception {
mock.expectedMessageCount(1);
Exchange exchange = template.request("direct:listClusters", new Processor() {
@@ -52,6 +53,25 @@ public class ECS2ProducerSpringTest extends CamelSpringTestSupport {
assertEquals(1, resultGet.clusterArns().size());
assertEquals("Test", resultGet.clusterArns().get(0));
}
+
+ @Test
+ public void ecsListClustersPojoTest() throws Exception {
+
+ mock.expectedMessageCount(1);
+ Exchange exchange = template.request("direct:listClustersPojo", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.listClusters);
+ exchange.getIn().setBody(ListClustersRequest.builder().maxResults(10).build());
+ }
+ });
+
+ assertMockEndpointsSatisfied();
+
+ ListClustersResponse resultGet = (ListClustersResponse)exchange.getIn().getBody();
+ assertEquals(1, resultGet.clusterArns().size());
+ assertEquals("Test", resultGet.clusterArns().get(0));
+ }
@Test
public void ecsCreateClusterTest() throws Exception {
diff --git a/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerTest.java b/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerTest.java
index b687e28..142ecab 100644
--- a/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerTest.java
+++ b/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerTest.java
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test;
import software.amazon.awssdk.services.ecs.model.CreateClusterResponse;
import software.amazon.awssdk.services.ecs.model.DeleteClusterResponse;
import software.amazon.awssdk.services.ecs.model.DescribeClustersResponse;
+import software.amazon.awssdk.services.ecs.model.ListClustersRequest;
import software.amazon.awssdk.services.ecs.model.ListClustersResponse;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -40,7 +41,7 @@ public class ECS2ProducerTest extends CamelTestSupport {
private MockEndpoint mock;
@Test
- public void kmsListClustersTest() throws Exception {
+ public void ecsListClustersTest() throws Exception {
mock.expectedMessageCount(1);
Exchange exchange = template.request("direct:listClusters", new Processor() {
@@ -56,6 +57,25 @@ public class ECS2ProducerTest extends CamelTestSupport {
assertEquals(1, resultGet.clusterArns().size());
assertEquals("Test", resultGet.clusterArns().get(0));
}
+
+ @Test
+ public void ecsListClustersPojoTest() throws Exception {
+
+ mock.expectedMessageCount(1);
+ Exchange exchange = template.request("direct:listClustersPojo", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.listClusters);
+ exchange.getIn().setBody(ListClustersRequest.builder().maxResults(10).build());
+ }
+ });
+
+ assertMockEndpointsSatisfied();
+
+ ListClustersResponse resultGet = (ListClustersResponse)exchange.getIn().getBody();
+ assertEquals(1, resultGet.clusterArns().size());
+ assertEquals("Test", resultGet.clusterArns().get(0));
+ }
@Test
public void ecsCreateClusterTest() throws Exception {
@@ -117,6 +137,7 @@ public class ECS2ProducerTest extends CamelTestSupport {
@Override
public void configure() throws Exception {
from("direct:listClusters").to("aws2-ecs://test?ecsClient=#amazonEcsClient&operation=listClusters").to("mock:result");
+ from("direct:listClustersPojo").to("aws2-ecs://test?ecsClient=#amazonEcsClient&operation=listClusters&pojoRequest=true").to("mock:result");
from("direct:createCluster").to("aws2-ecs://test?ecsClient=#amazonEcsClient&operation=createCluster").to("mock:result");
from("direct:deleteCluster").to("aws2-ecs://test?ecsClient=#amazonEcsClient&operation=deleteCluster").to("mock:result");
from("direct:describeCluster").to("aws2-ecs://test?ecsClient=#amazonEcsClient&operation=describeCluster").to("mock:result");
diff --git a/components/camel-aws2-ecs/src/test/resources/org/apache/camel/component/aws2/ecs/ECSComponentSpringTest-context.xml b/components/camel-aws2-ecs/src/test/resources/org/apache/camel/component/aws2/ecs/ECSComponentSpringTest-context.xml
index fe4ab20..8b3c72e 100644
--- a/components/camel-aws2-ecs/src/test/resources/org/apache/camel/component/aws2/ecs/ECSComponentSpringTest-context.xml
+++ b/components/camel-aws2-ecs/src/test/resources/org/apache/camel/component/aws2/ecs/ECSComponentSpringTest-context.xml
@@ -30,6 +30,11 @@
<to uri="mock:result"/>
</route>
<route>
+ <from uri="direct:listClustersPojo"/>
+ <to uri="aws2-ecs://test?ecsClient=#amazonEcsClient&operation=listClusters&pojoRequest=true"/>
+ <to uri="mock:result"/>
+ </route>
+ <route>
<from uri="direct:createCluster"/>
<to uri="aws2-ecs://test?ecsClient=#amazonEcsClient&operation=createCluster"/>
<to uri="mock:result"/>
[camel] 04/06: CAMEL-14868 - Camel-AWS2-*: Where possible,
give the possiblity to the end user to pass an AWS Request pojo as
body, aws2-ecs
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit b4b4651de4fd4f792950c6977e72e49e89ae134f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Apr 9 16:02:51 2020 +0200
CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-ecs
---
.../camel/component/aws2/ecs/ECS2Producer.java | 39 +++++++++++-----------
1 file changed, 19 insertions(+), 20 deletions(-)
diff --git a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
index ca7da05..751143a 100644
--- a/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
+++ b/components/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Producer.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.aws2.ecs;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
import org.apache.camel.Message;
import org.apache.camel.support.DefaultProducer;
import org.apache.camel.util.ObjectHelper;
@@ -95,11 +96,10 @@ public class ECS2Producer extends DefaultProducer {
return (ECS2Endpoint)super.getEndpoint();
}
- private void listClusters(EcsClient ecsClient, Exchange exchange) {
+ private void listClusters(EcsClient ecsClient, Exchange exchange) throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
- if (ObjectHelper.isNotEmpty(exchange.getIn().getBody())) {
- if (exchange.getIn().getBody() instanceof ListClustersRequest) {
- Object payload = exchange.getIn().getBody();
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof ListClustersRequest) {
ListClustersResponse result;
try {
ListClustersRequest request = (ListClustersRequest)payload;
@@ -111,7 +111,6 @@ public class ECS2Producer extends DefaultProducer {
Message message = getMessageForResponse(exchange);
message.setBody(result);
}
- }
} else {
Builder builder = ListClustersRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.MAX_RESULTS))) {
@@ -131,10 +130,10 @@ public class ECS2Producer extends DefaultProducer {
}
}
- private void createCluster(EcsClient ecsClient, Exchange exchange) {
- if (ObjectHelper.isNotEmpty(exchange.getIn().getBody())) {
- if (exchange.getIn().getBody() instanceof CreateClusterRequest) {
- Object payload = exchange.getIn().getBody();
+ private void createCluster(EcsClient ecsClient, Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof CreateClusterRequest) {
CreateClusterResponse result;
try {
CreateClusterRequest request = (CreateClusterRequest)payload;
@@ -145,7 +144,7 @@ public class ECS2Producer extends DefaultProducer {
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
- }
+ }
} else {
CreateClusterRequest.Builder builder = CreateClusterRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
@@ -165,10 +164,10 @@ public class ECS2Producer extends DefaultProducer {
}
}
- private void describeCluster(EcsClient ecsClient, Exchange exchange) {
- if (ObjectHelper.isNotEmpty(exchange.getIn().getBody())) {
- if (exchange.getIn().getBody() instanceof DescribeClustersRequest) {
- Object payload = exchange.getIn().getBody();
+ private void describeCluster(EcsClient ecsClient, Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof DescribeClustersRequest) {
DescribeClustersResponse result;
try {
DescribeClustersRequest request = (DescribeClustersRequest)payload;
@@ -179,7 +178,7 @@ public class ECS2Producer extends DefaultProducer {
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
- }
+ }
} else {
DescribeClustersRequest.Builder builder = DescribeClustersRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
@@ -199,10 +198,10 @@ public class ECS2Producer extends DefaultProducer {
}
}
- private void deleteCluster(EcsClient ecsClient, Exchange exchange) {
- if (ObjectHelper.isNotEmpty(exchange.getIn().getBody())) {
- if (exchange.getIn().getBody() instanceof DeleteClusterRequest) {
- Object payload = exchange.getIn().getBody();
+ private void deleteCluster(EcsClient ecsClient, Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof DeleteClusterRequest) {
DeleteClusterResponse result;
try {
DeleteClusterRequest request = (DeleteClusterRequest)payload;
@@ -213,7 +212,7 @@ public class ECS2Producer extends DefaultProducer {
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
- }
+ }
} else {
DeleteClusterRequest.Builder builder = DeleteClusterRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
[camel] 06/06: Regen
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit e88883904c7c57878bb1d08775294c91bfaeb189
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Apr 9 16:07:46 2020 +0200
Regen
---
core/camel-componentdsl/src/generated/resources/metadata.json | 2 +-
docs/components/modules/ROOT/pages/aws2-ecs-component.adoc | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/core/camel-componentdsl/src/generated/resources/metadata.json b/core/camel-componentdsl/src/generated/resources/metadata.json
index 798576f..1e40d8d 100644
--- a/core/camel-componentdsl/src/generated/resources/metadata.json
+++ b/core/camel-componentdsl/src/generated/resources/metadata.json
@@ -502,6 +502,7 @@
"lenientProperties": false,
"javaType": "org.apache.camel.component.aws2.ecs.ECS2Component",
"firstVersion": "3.1.0",
+ "supportLevel": "Stable",
"groupId": "org.apache.camel",
"artifactId": "camel-aws2-ecs",
"version": "3.3.0-SNAPSHOT"
@@ -7377,7 +7378,6 @@
"lenientProperties": false,
"javaType": "org.apache.camel.component.xchange.XChangeComponent",
"firstVersion": "2.21.0",
- "supportLevel": "Stable",
"groupId": "org.apache.camel",
"artifactId": "camel-xchange",
"version": "3.3.0-SNAPSHOT"
diff --git a/docs/components/modules/ROOT/pages/aws2-ecs-component.adoc b/docs/components/modules/ROOT/pages/aws2-ecs-component.adoc
index 3e981a4..b9ce232 100644
--- a/docs/components/modules/ROOT/pages/aws2-ecs-component.adoc
+++ b/docs/components/modules/ROOT/pages/aws2-ecs-component.adoc
@@ -39,7 +39,7 @@ You can append query options to the URI in the following format,
// component options: START
-The AWS 2 ECS component supports 11 options, which are listed below.
+The AWS 2 ECS component supports 12 options, which are listed below.
@@ -50,6 +50,7 @@ The AWS 2 ECS component supports 11 options, which are listed below.
| *ecsClient* (producer) | To use a existing configured AWS ECS as client | | EcsClient
| *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
| *operation* (producer) | *Required* The operation to perform. The value can be one of: listClusters, describeCluster, createCluster, deleteCluster | | ECS2Operations
+| *pojoRequest* (producer) | If we want to use a POJO request as body or not | false | boolean
| *proxyHost* (producer) | To define a proxy host when instantiating the ECS client | | String
| *proxyPort* (producer) | To define a proxy port when instantiating the ECS client | | Integer
| *proxyProtocol* (producer) | To define a proxy protocol when instantiating the ECS client. The value can be one of: HTTP, HTTPS | HTTPS | Protocol
@@ -82,7 +83,7 @@ with the following path and query parameters:
|===
-=== Query Parameters (11 parameters):
+=== Query Parameters (12 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
@@ -91,6 +92,7 @@ with the following path and query parameters:
| *ecsClient* (producer) | To use a existing configured AWS ECS as client | | EcsClient
| *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
| *operation* (producer) | *Required* The operation to perform. The value can be one of: listClusters, describeCluster, createCluster, deleteCluster | | ECS2Operations
+| *pojoRequest* (producer) | If we want to use a POJO request as body or not | false | boolean
| *proxyHost* (producer) | To define a proxy host when instantiating the ECS client | | String
| *proxyPort* (producer) | To define a proxy port when instantiating the ECS client | | Integer
| *proxyProtocol* (producer) | To define a proxy protocol when instantiating the ECS client. The value can be one of: HTTP, HTTPS | HTTPS | Protocol