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/10 11:07:57 UTC
[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-eks more operations
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 e7afeeaa66ceb1306fe1982c606907e90c230e3d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Apr 10 12:55:05 2020 +0200
CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-eks more operations
---
.../camel/component/aws2/eks/EKS2Producer.java | 34 ++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Producer.java b/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Producer.java
index e2cd44f..69c3358 100644
--- a/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Producer.java
+++ b/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Producer.java
@@ -127,7 +127,21 @@ public class EKS2Producer extends DefaultProducer {
}
}
- private void createCluster(EksClient eksClient, Exchange exchange) {
+ private void createCluster(EksClient eksClient, Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof CreateClusterRequest) {
+ CreateClusterResponse result;
+ try {
+ result = eksClient.createCluster((CreateClusterRequest) payload);
+ } 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(EKS2Constants.CLUSTER_NAME))) {
String name = exchange.getIn().getHeader(EKS2Constants.CLUSTER_NAME, String.class);
@@ -150,9 +164,24 @@ public class EKS2Producer extends DefaultProducer {
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
+ }
}
- private void describeCluster(EksClient eksClient, Exchange exchange) {
+ private void describeCluster(EksClient eksClient, Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof DescribeClusterRequest) {
+ DescribeClusterResponse result;
+ try {
+ result = eksClient.describeCluster((DescribeClusterRequest) payload);
+ } catch (AwsServiceException ase) {
+ LOG.trace("Describe Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
+ }
+ } else {
DescribeClusterRequest.Builder builder = DescribeClusterRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EKS2Constants.CLUSTER_NAME))) {
String name = exchange.getIn().getHeader(EKS2Constants.CLUSTER_NAME, String.class);
@@ -169,6 +198,7 @@ public class EKS2Producer extends DefaultProducer {
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
+ }
}
private void deleteCluster(EksClient eksClient, Exchange exchange) {