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/01/02 12:34:54 UTC

[camel] branch master updated (36d44c7 -> ca446ee)

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 36d44c7  Some small improvements of the grammar and style of the migration guides.
     new 68494c4  CAMEL-14348 - Camel-AWS Lambda: Add alias operations, createAlias operation
     new 358fd22  CAMEL-14348 - Fixed tests
     new 129a721  CAMEL-14348 - Camel-AWS Lambda: Add alias operations, createAlias operation Spring test
     new 77c09ab  CAMEL-14348 - Camel-AWS Lambda: Add alias operations, createAlias operation docs
     new ca446ee  CAMEL-14348 - Camel-AWS Lambda: Add alias operations, createAlias docs regen

The 5 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:
 .../src/main/docs/aws-lambda-component.adoc        |  7 ++++++
 .../component/aws/lambda/LambdaConstants.java      |  3 +++
 .../component/aws/lambda/LambdaOperations.java     |  1 +
 .../camel/component/aws/lambda/LambdaProducer.java | 27 ++++++++++++++++++++++
 .../aws/lambda/AmazonLambdaClientMock.java         |  6 ++++-
 .../aws/lambda/LambdaComponentSpringTest.java      | 21 +++++++++++++++++
 .../component/aws/lambda/LambdaOperationsTest.java |  4 +++-
 .../component/aws/lambda/LambdaProducerTest.java   | 23 ++++++++++++++++++
 .../lambda/LambdaComponentSpringTest-context.xml   |  5 ++++
 .../endpoint/dsl/LambdaEndpointBuilderFactory.java |  1 +
 .../modules/ROOT/pages/aws-lambda-component.adoc   |  7 ++++++
 11 files changed, 103 insertions(+), 2 deletions(-)


[camel] 01/05: CAMEL-14348 - Camel-AWS Lambda: Add alias operations, createAlias operation

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 68494c45144a4aa262ac95f0209348843279ce19
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jan 2 13:22:12 2020 +0100

    CAMEL-14348 - Camel-AWS Lambda: Add alias operations, createAlias operation
---
 .../component/aws/lambda/LambdaConstants.java      |  3 +++
 .../component/aws/lambda/LambdaOperations.java     |  1 +
 .../camel/component/aws/lambda/LambdaProducer.java | 27 ++++++++++++++++++++++
 .../aws/lambda/AmazonLambdaClientMock.java         |  6 ++++-
 .../component/aws/lambda/LambdaProducerTest.java   | 23 ++++++++++++++++++
 .../endpoint/dsl/LambdaEndpointBuilderFactory.java |  1 +
 6 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaConstants.java b/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaConstants.java
index 4eef137..bd038ba 100644
--- a/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaConstants.java
+++ b/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaConstants.java
@@ -51,4 +51,7 @@ public interface LambdaConstants {
     String RESOURCE_TAG_KEYS = "CamelAwsLambdaResourceTagKeys";
     String VERSION_DESCRIPTION = "CamelAwsLambdaVersionDescription";
     String VERSION_REVISION_ID = "CamelAwsLambdaVersionRevisionId";
+    String FUNCTION_VERSION = "CamelAwsLambdaFunctionVersion";
+    String FUNCTION_ALIAS_NAME = "CamelAwsLambdaAliasFunctionName";
+    String FUNCTION_ALIAS_DESCRIPTION = "CamelAwsLambdaAliasFunctionDescription";
 }
\ No newline at end of file
diff --git a/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaOperations.java b/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaOperations.java
index c6f9a6f..dfbf340 100644
--- a/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaOperations.java
+++ b/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaOperations.java
@@ -20,6 +20,7 @@ public enum LambdaOperations {
 
     listFunctions,
     getFunction,
+    createAlias,
     createFunction,
     deleteFunction,
     invokeFunction,
diff --git a/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java b/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java
index ed90cf1..ed66712 100644
--- a/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java
+++ b/components/camel-aws-lambda/src/main/java/org/apache/camel/component/aws/lambda/LambdaProducer.java
@@ -25,6 +25,8 @@ import java.util.Map;
 
 import com.amazonaws.AmazonServiceException;
 import com.amazonaws.services.lambda.AWSLambda;
+import com.amazonaws.services.lambda.model.CreateAliasRequest;
+import com.amazonaws.services.lambda.model.CreateAliasResult;
 import com.amazonaws.services.lambda.model.CreateEventSourceMappingRequest;
 import com.amazonaws.services.lambda.model.CreateEventSourceMappingResult;
 import com.amazonaws.services.lambda.model.CreateFunctionRequest;
@@ -120,6 +122,9 @@ public class LambdaProducer extends DefaultProducer {
         case listVersions:
             listVersions(getEndpoint().getAwsLambdaClient(), exchange);
             break;
+        case createAlias:
+            createAlias(getEndpoint().getAwsLambdaClient(), exchange);
+            break;
         default:
             throw new IllegalArgumentException("Unsupported operation");
         }
@@ -560,6 +565,28 @@ public class LambdaProducer extends DefaultProducer {
         message.setBody(result);
     }
     
+    private void createAlias(AWSLambda lambdaClient, Exchange exchange) {
+        CreateAliasResult result;
+        try {
+            CreateAliasRequest request = new CreateAliasRequest().withFunctionName(getEndpoint().getFunction());
+            String version = exchange.getIn().getHeader(LambdaConstants.FUNCTION_VERSION, String.class);
+            String aliasName = exchange.getIn().getHeader(LambdaConstants.FUNCTION_ALIAS_NAME, String.class);
+            if (ObjectHelper.isEmpty(version) || ObjectHelper.isEmpty(aliasName)) {
+                throw new IllegalArgumentException("Function Version and alias must be specified to create an alias");
+            }
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(LambdaConstants.FUNCTION_ALIAS_DESCRIPTION))) {
+                String aliasDescription = exchange.getIn().getHeader(LambdaConstants.FUNCTION_ALIAS_DESCRIPTION, String.class);
+                request.setDescription(aliasDescription);
+            } 
+            result = lambdaClient.createAlias(request);
+        } catch (AmazonServiceException ase) {
+            log.trace("createAlias command returned the error code {}", ase.getErrorCode());
+            throw ase;
+        }
+        Message message = getMessageForResponse(exchange);
+        message.setBody(result);
+    }
+    
     private LambdaOperations determineOperation(Exchange exchange) {
         LambdaOperations operation = exchange.getIn().getHeader(LambdaConstants.OPERATION, LambdaOperations.class);
         if (operation == null) {
diff --git a/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/AmazonLambdaClientMock.java b/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/AmazonLambdaClientMock.java
index 145f116..dfcddbe 100644
--- a/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/AmazonLambdaClientMock.java
+++ b/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/AmazonLambdaClientMock.java
@@ -107,7 +107,11 @@ public class AmazonLambdaClientMock extends AbstractAWSLambda {
 
     @Override
     public CreateAliasResult createAlias(CreateAliasRequest createAliasRequest) {
-        throw new UnsupportedOperationException();
+        CreateAliasResult result = new CreateAliasResult();
+        result.setFunctionVersion("1");
+        result.setName("alias");
+        result.setDescription("an alias");
+        return result;
     }
 
     @Override
diff --git a/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaProducerTest.java b/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaProducerTest.java
index b4a8a0b..503f86e 100644
--- a/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaProducerTest.java
+++ b/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaProducerTest.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.amazonaws.services.lambda.model.CreateAliasResult;
 import com.amazonaws.services.lambda.model.CreateEventSourceMappingResult;
 import com.amazonaws.services.lambda.model.CreateFunctionResult;
 import com.amazonaws.services.lambda.model.DeleteEventSourceMappingResult;
@@ -293,6 +294,26 @@ public class LambdaProducerTest extends CamelTestSupport {
         assertEquals("GetHelloWithName", result.getVersions().get(0).getFunctionName());
         assertEquals("1", result.getVersions().get(0).getVersion());
     }
+    
+    @Test
+    public void createAliasTest() throws Exception {
+
+        Exchange exchange = template.send("direct:createAlias", ExchangePattern.InOut, new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(LambdaConstants.FUNCTION_ALIAS_DESCRIPTION, "an alias");
+                exchange.getIn().setHeader(LambdaConstants.FUNCTION_ALIAS_NAME, "alias");
+                exchange.getIn().setHeader(LambdaConstants.FUNCTION_VERSION, "1");
+            }
+        });
+        assertMockEndpointsSatisfied();
+
+        CreateAliasResult result = (CreateAliasResult)exchange.getOut().getBody();
+        assertNotNull(result);
+        assertEquals("an alias", result.getDescription());
+        assertEquals("alias", result.getName());
+        assertEquals("1", result.getFunctionVersion());
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -326,6 +347,8 @@ public class LambdaProducerTest extends CamelTestSupport {
                 from("direct:deleteEventSourceMapping").to("aws-lambda://GetHelloWithName?awsLambdaClient=#awsLambdaClient&operation=deleteEventSourceMapping").to("mock:result");
                 
                 from("direct:listEventSourceMapping").to("aws-lambda://GetHelloWithName?awsLambdaClient=#awsLambdaClient&operation=listEventSourceMapping").to("mock:result");
+                
+                from("direct:createAlias").to("aws-lambda://GetHelloWithName?awsLambdaClient=#awsLambdaClient&operation=createAlias").to("mock:result");
             }
         };
     }
diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/LambdaEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/LambdaEndpointBuilderFactory.java
index daea93f..b647323 100644
--- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/LambdaEndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/LambdaEndpointBuilderFactory.java
@@ -293,6 +293,7 @@ public interface LambdaEndpointBuilderFactory {
     enum LambdaOperations {
         listFunctions,
         getFunction,
+        createAlias,
         createFunction,
         deleteFunction,
         invokeFunction,


[camel] 03/05: CAMEL-14348 - Camel-AWS Lambda: Add alias operations, createAlias operation Spring test

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 129a721388fe1d0f47deef9127ec8849e2810111
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jan 2 13:25:13 2020 +0100

    CAMEL-14348 - Camel-AWS Lambda: Add alias operations, createAlias operation Spring test
---
 .../aws/lambda/LambdaComponentSpringTest.java       | 21 +++++++++++++++++++++
 .../lambda/LambdaComponentSpringTest-context.xml    |  5 +++++
 2 files changed, 26 insertions(+)

diff --git a/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaComponentSpringTest.java b/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaComponentSpringTest.java
index 7d9bc23..0ffa06a 100644
--- a/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaComponentSpringTest.java
+++ b/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaComponentSpringTest.java
@@ -22,6 +22,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.amazonaws.services.lambda.model.CreateAliasResult;
 import com.amazonaws.services.lambda.model.CreateEventSourceMappingResult;
 import com.amazonaws.services.lambda.model.CreateFunctionResult;
 import com.amazonaws.services.lambda.model.DeleteEventSourceMappingResult;
@@ -251,6 +252,26 @@ public class LambdaComponentSpringTest extends CamelSpringTestSupport {
         assertEquals("GetHelloWithName", result.getVersions().get(0).getFunctionName());
         assertEquals("1", result.getVersions().get(0).getVersion());
     }
+    
+    @Test
+    public void createAliasTest() throws Exception {
+
+        Exchange exchange = template.send("direct:createAlias", ExchangePattern.InOut, new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(LambdaConstants.FUNCTION_ALIAS_DESCRIPTION, "an alias");
+                exchange.getIn().setHeader(LambdaConstants.FUNCTION_ALIAS_NAME, "alias");
+                exchange.getIn().setHeader(LambdaConstants.FUNCTION_VERSION, "1");
+            }
+        });
+        assertMockEndpointsSatisfied();
+
+        CreateAliasResult result = (CreateAliasResult)exchange.getOut().getBody();
+        assertNotNull(result);
+        assertEquals("an alias", result.getDescription());
+        assertEquals("alias", result.getName());
+        assertEquals("1", result.getFunctionVersion());
+    }
 
     @Override
     protected AbstractApplicationContext createApplicationContext() {
diff --git a/components/camel-aws-lambda/src/test/resources/org/apache/camel/component/aws/lambda/LambdaComponentSpringTest-context.xml b/components/camel-aws-lambda/src/test/resources/org/apache/camel/component/aws/lambda/LambdaComponentSpringTest-context.xml
index 0e5598c..49d9bf6 100644
--- a/components/camel-aws-lambda/src/test/resources/org/apache/camel/component/aws/lambda/LambdaComponentSpringTest-context.xml
+++ b/components/camel-aws-lambda/src/test/resources/org/apache/camel/component/aws/lambda/LambdaComponentSpringTest-context.xml
@@ -89,6 +89,11 @@
             <from uri="direct:listVersions"/>
             <to uri="aws-lambda://GetHelloWithName?awsLambdaClient=#awsLambdaClient&amp;operation=listVersions"/>
         </route>
+        
+        <route>
+            <from uri="direct:createAlias"/>
+            <to uri="aws-lambda://GetHelloWithName?awsLambdaClient=#awsLambdaClient&amp;operation=createAlias"/>
+        </route>
     </camelContext>
 
     <bean id="awsLambdaClient" class="org.apache.camel.component.aws.lambda.AmazonLambdaClientMock"/>


[camel] 02/05: CAMEL-14348 - Fixed tests

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 358fd221f78c7ef05b46a43a3f56e7525220f87d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jan 2 13:23:26 2020 +0100

    CAMEL-14348 - Fixed tests
---
 .../org/apache/camel/component/aws/lambda/LambdaOperationsTest.java   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaOperationsTest.java b/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaOperationsTest.java
index 197abc2..79873f1 100644
--- a/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaOperationsTest.java
+++ b/components/camel-aws-lambda/src/test/java/org/apache/camel/component/aws/lambda/LambdaOperationsTest.java
@@ -24,7 +24,7 @@ public class LambdaOperationsTest {
 
     @Test
     public void supportedOperationCount() {
-        assertEquals(14, LambdaOperations.values().length);
+        assertEquals(15, LambdaOperations.values().length);
     }
 
     @Test
@@ -43,6 +43,7 @@ public class LambdaOperationsTest {
         assertEquals(LambdaOperations.untagResource, LambdaOperations.valueOf("untagResource"));
         assertEquals(LambdaOperations.publishVersion, LambdaOperations.valueOf("publishVersion"));
         assertEquals(LambdaOperations.listVersions, LambdaOperations.valueOf("listVersions"));
+        assertEquals(LambdaOperations.createAlias, LambdaOperations.valueOf("createAlias"));
     }
 
     @Test
@@ -61,5 +62,6 @@ public class LambdaOperationsTest {
         assertEquals(LambdaOperations.untagResource.toString(), "untagResource");
         assertEquals(LambdaOperations.publishVersion.toString(), "publishVersion");
         assertEquals(LambdaOperations.listVersions.toString(), "listVersions");
+        assertEquals(LambdaOperations.createAlias.toString(), "createAlias");
     }
 }


[camel] 04/05: CAMEL-14348 - Camel-AWS Lambda: Add alias operations, createAlias operation docs

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 77c09ab3a25171088bfbf99322d9a66323655db3
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jan 2 13:27:51 2020 +0100

    CAMEL-14348 - Camel-AWS Lambda: Add alias operations, createAlias operation docs
---
 .../camel-aws-lambda/src/main/docs/aws-lambda-component.adoc       | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/components/camel-aws-lambda/src/main/docs/aws-lambda-component.adoc b/components/camel-aws-lambda/src/main/docs/aws-lambda-component.adoc
index 63a317e..5ce483b 100644
--- a/components/camel-aws-lambda/src/main/docs/aws-lambda-component.adoc
+++ b/components/camel-aws-lambda/src/main/docs/aws-lambda-component.adoc
@@ -204,6 +204,12 @@ The default is 3 seconds.|No
 
 |createFunction |`CamelAwsLambdaSubnetIds` |`List<String>` |If your Lambda function accesses resources in a VPC, a list of one or more subnet IDs in your VPC.|No
 
+|createAlias |`CamelAwsLambdaFunctionVersion` |`String` |The function version to set in the alias|Yes
+
+|createAlias |`CamelAwsLambdaAliasFunctionName` |`String` |The function name to set in the alias|Yes
+
+|createAlias |`CamelAwsLambdaAliasFunctionDescription` |`String` |The function description to set in the alias|No
+
 |=======================================================================
 
 == List of Avalaible Operations
@@ -222,6 +228,7 @@ The default is 3 seconds.|No
 - untagResource
 - publishVersion
 - listVersions
+- createAlias
 
 == Example
 


[camel] 05/05: CAMEL-14348 - Camel-AWS Lambda: Add alias operations, createAlias docs 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 ca446eebac9d234215a615fa1bb3f0627635bdb2
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jan 2 13:32:38 2020 +0100

    CAMEL-14348 - Camel-AWS Lambda: Add alias operations, createAlias docs regen
---
 docs/components/modules/ROOT/pages/aws-lambda-component.adoc | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/docs/components/modules/ROOT/pages/aws-lambda-component.adoc b/docs/components/modules/ROOT/pages/aws-lambda-component.adoc
index b4d3109..1d4ca0b 100644
--- a/docs/components/modules/ROOT/pages/aws-lambda-component.adoc
+++ b/docs/components/modules/ROOT/pages/aws-lambda-component.adoc
@@ -205,6 +205,12 @@ The default is 3 seconds.|No
 
 |createFunction |`CamelAwsLambdaSubnetIds` |`List<String>` |If your Lambda function accesses resources in a VPC, a list of one or more subnet IDs in your VPC.|No
 
+|createAlias |`CamelAwsLambdaFunctionVersion` |`String` |The function version to set in the alias|Yes
+
+|createAlias |`CamelAwsLambdaAliasFunctionName` |`String` |The function name to set in the alias|Yes
+
+|createAlias |`CamelAwsLambdaAliasFunctionDescription` |`String` |The function description to set in the alias|No
+
 |=======================================================================
 
 == List of Avalaible Operations
@@ -223,6 +229,7 @@ The default is 3 seconds.|No
 - untagResource
 - publishVersion
 - listVersions
+- createAlias
 
 == Example