diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c752065 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM oracle/graalvm-ce:19.0.2 +RUN gu install native-image +WORKDIR /app diff --git a/README.md b/README.md index a357f13..1b78741 100644 --- a/README.md +++ b/README.md @@ -21,36 +21,10 @@ Make sure you have the following installed on your build machine before getting $ ./mvnw package ``` -#### Create the Lambda Custom Runtime Entry Point - -AWS Lambda Custom Runtimes require an executable file in the root directory named simply ```bootstrap```. This can be any executable file, for our case we're going to just use -a shell script to call our launcher that we created in the step above. This script will do nothing more than invoke our Java Runtime from the dist folder. - -##### Create the bootstrap script -``` -$ touch boostrap -``` -##### Call our Java Runtime from Bash - -Add the following commands to the ```bootstrap``` -```$bash -#!/bin/sh -/opt/target/lambda -``` - -Note that the path we're using in our shell script is ```/opt```. When you create a Lambda Layer, as we'll do shortly, AWS Lambda copies all the runtime files to the ```/opt``` directory. This directory is effectively the home directory for our custom runtime. - -##### Make bootstrap executable -``` -$ chmod +x bootstrap -``` - -##### Create a deployment package - -In the root of the folder containing our ```bootstrap``` and ```target/lambda``` files, create a zip archive containing the artifacts. +If your system cannot build working images (say to mismatch of library versions), you can build under docker: ``` -$ zip -r function.zip bootstrap target/lambda +docker run --rm -it -v ${PWD}:/app:z builder /bin/bash ``` ### Deploying to AWS Lambda @@ -86,7 +60,7 @@ Where the file `/tmp/trust-policy.json` contains: ``` aws lambda publish-layer-version \ --layer-name vertx-native-example \ - --zip-file fileb://function.zip + --zip-file fileb://target/lambda-0.0.1-SNAPSHOT-function.zip ``` #### Create a function @@ -95,14 +69,14 @@ aws lambda publish-layer-version \ aws lambda delete-function --function-name vertxNativeTester aws lambda create-function --function-name vertxNativeTester \ - --zip-file fileb://function.zip --handler lambda.EchoLambda --runtime provided \ + --zip-file fileb://target/lambda-0.0.1-SNAPSHOT-function.zip --handler lambda.ApplicationLoadBalancerLambda --runtime provided \ --role arn:aws:iam::985727241951:role/service-role/lambda-role ``` #### Link the layer to the function ``` -aws lambda update-function-configuration --function-name vertxNativeTester --layers arn:aws:lambda:eu-central-1:985727241951:layer:vertx-native-example:8 +aws lambda update-function-configuration --function-name vertxNativeTester --layers arn:aws:lambda:eu-central-1:985727241951:layer:vertx-native-example:1 ``` #### Test it diff --git a/boilerplate/pom.xml b/boilerplate/pom.xml new file mode 100644 index 0000000..09a64fa --- /dev/null +++ b/boilerplate/pom.xml @@ -0,0 +1,146 @@ + + + + 4.0.0 + + + org.sonatype.oss + oss-parent + 9 + + + xyz.jetdrone + vertx.lambda.aws + 0.0.2 + + vertx-lambda-aws + Boilerplate for a native vert.x AWS lambda + https://github.com/pmlopes/aws-lambda-native-vertx + + + + + Apache License, Version 2.0 + repo + http://www.apache.org/licenses/LICENSE-2.0.html + + + + + + https://github.com/pmlopes/aws-lambda-native-vertx/issues + GitHub Issues + + + + https://github.com/pmlopes/aws-lambda-native-vertx + scm:git:git://github.com/pmlopes/aws-lambda-native-vertx.git + scm:git:git@github.com:pmlopes/aws-lambda-native-vertx.git + + + + + pmlopes + Paulo Lopes + pmlopes@gmail.com + + + + + https://travis-ci.org/pmlopes/aws-lambda-native-vertx + Travis CI + + + + + + website + https://github.com/pmlopes/aws-lambda-native-vertx + + + + + UTF-8 + 19.0.0 + 3.7.1 + + + + + + io.vertx + vertx-stack-depchain + ${vertx.version} + pom + import + + + + + + + com.oracle.substratevm + svm-driver + ${graal.version} + provided + + + io.vertx + vertx-core + + + io.vertx + vertx-codegen + provided + true + + + io.vertx + vertx-web-client + + + io.vertx + vertx-unit + test + + + junit + junit + 4.12 + test + + + + + + + + + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + 1.8 + 1.8 + ${project.build.sourceEncoding} + + + + default-compile + + + io.vertx.codegen.CodeGenProcessor + + + -Acodegen.output=${project.basedir}/src/main + + + + + + + + + diff --git a/boilerplate/src/main/asciidoc/dataobjects.adoc b/boilerplate/src/main/asciidoc/dataobjects.adoc new file mode 100644 index 0000000..bcd4aff --- /dev/null +++ b/boilerplate/src/main/asciidoc/dataobjects.adoc @@ -0,0 +1,1013 @@ += Cheatsheets + +[[APIGatewayCustomAuthorizerPolicy]] +== APIGatewayCustomAuthorizerPolicy + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[statement]]`@statement`|`Array of link:dataobjects.html#IAMPolicyStatement[IAMPolicyStatement]`|+++ +(Required) ++++ +|[[version]]`@version`|`String`|+++ +(Required) ++++ +|=== + +[[APIGatewayCustomAuthorizerRequest]] +== APIGatewayCustomAuthorizerRequest + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[authorizationToken]]`@authorizationToken`|`String`|+++ +(Required) ++++ +|[[methodArn]]`@methodArn`|`String`|+++ +(Required) ++++ +|[[type]]`@type`|`String`|+++ +(Required) ++++ +|=== + +[[APIGatewayCustomAuthorizerResponse]] +== APIGatewayCustomAuthorizerResponse + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[context]]`@context`|`Json object`|- +|[[policyDocument]]`@policyDocument`|`link:dataobjects.html#APIGatewayCustomAuthorizerPolicy[APIGatewayCustomAuthorizerPolicy]`|+++ +(Required) ++++ +|[[principalId]]`@principalId`|`String`|+++ +(Required) ++++ +|[[usageIdentifierKey]]`@usageIdentifierKey`|`String`|- +|=== + +[[APIGatewayProxyRequest]] +== APIGatewayProxyRequest + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[body]]`@body`|`String`|+++ +(Required) ++++ +|[[headers]]`@headers`|`Json object`|+++ +(Required) ++++ +|[[httpMethod]]`@httpMethod`|`String`|+++ +(Required) ++++ +|[[isBase64Encoded]]`@isBase64Encoded`|`Boolean`|- +|[[path]]`@path`|`String`|+++ +(Required) ++++ +|[[pathParameters]]`@pathParameters`|`Json object`|+++ +(Required) ++++ +|[[queryStringParameters]]`@queryStringParameters`|`Json object`|+++ +(Required) ++++ +|[[requestContext]]`@requestContext`|`link:dataobjects.html#APIGatewayProxyRequestContext[APIGatewayProxyRequestContext]`|+++ +(Required) ++++ +|[[resource]]`@resource`|`String`|+++ +(Required) ++++ +|[[stageVariables]]`@stageVariables`|`Json object`|+++ +(Required) ++++ +|=== + +[[APIGatewayProxyRequestContext]] +== APIGatewayProxyRequestContext + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[accountId]]`@accountId`|`String`|+++ +(Required) ++++ +|[[apiId]]`@apiId`|`String`|+++ +(Required) ++++ +|[[authorizer]]`@authorizer`|`Json object`|+++ +(Required) ++++ +|[[httpMethod]]`@httpMethod`|`String`|+++ +(Required) ++++ +|[[identity]]`@identity`|`link:dataobjects.html#APIGatewayRequestIdentity[APIGatewayRequestIdentity]`|+++ +(Required) ++++ +|[[requestId]]`@requestId`|`String`|+++ +(Required) ++++ +|[[resourceId]]`@resourceId`|`String`|+++ +(Required) ++++ +|[[resourcePath]]`@resourcePath`|`String`|+++ +(Required) ++++ +|[[stage]]`@stage`|`String`|+++ +(Required) ++++ +|=== + +[[APIGatewayProxyResponse]] +== APIGatewayProxyResponse + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[body]]`@body`|`String`|+++ +(Required) ++++ +|[[headers]]`@headers`|`Json object`|+++ +(Required) ++++ +|[[isBase64Encoded]]`@isBase64Encoded`|`Boolean`|- +|[[statusCode]]`@statusCode`|`Number (Integer)`|+++ +(Required) ++++ +|=== + +[[APIGatewayRequestIdentity]] +== APIGatewayRequestIdentity + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[accountId]]`@accountId`|`String`|+++ +(Required) ++++ +|[[apiKey]]`@apiKey`|`String`|+++ +(Required) ++++ +|[[caller]]`@caller`|`String`|+++ +(Required) ++++ +|[[cognitoAuthenticationProvider]]`@cognitoAuthenticationProvider`|`String`|+++ +(Required) ++++ +|[[cognitoAuthenticationType]]`@cognitoAuthenticationType`|`String`|+++ +(Required) ++++ +|[[cognitoIdentityId]]`@cognitoIdentityId`|`String`|+++ +(Required) ++++ +|[[cognitoIdentityPoolId]]`@cognitoIdentityPoolId`|`String`|+++ +(Required) ++++ +|[[sourceIp]]`@sourceIp`|`String`|+++ +(Required) ++++ +|[[user]]`@user`|`String`|+++ +(Required) ++++ +|[[userAgent]]`@userAgent`|`String`|+++ +(Required) ++++ +|[[userArn]]`@userArn`|`String`|+++ +(Required) ++++ +|=== + +[[Attachment]] +== Attachment + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[attachmentLinkUrl]]`@attachmentLinkUrl`|`String`|- +|[[buttons]]`@buttons`|`Json array`|- +|[[imageUrl]]`@imageUrl`|`String`|- +|[[subTitle]]`@subTitle`|`String`|- +|[[title]]`@title`|`String`|- +|=== + +[[CloudWatchEvent]] +== CloudWatchEvent + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[account]]`@account`|`String`|+++ +(Required) ++++ +|[[detail]]`@detail`|`Array of Number (Integer)`|+++ +(Required) ++++ +|[[detailType]]`@detailType`|`String`|+++ +(Required) ++++ +|[[id]]`@id`|`String`|+++ +(Required) ++++ +|[[region]]`@region`|`String`|+++ +(Required) ++++ +|[[resources]]`@resources`|`Array of String`|+++ +(Required) ++++ +|[[source]]`@source`|`String`|+++ +(Required) ++++ +|[[version]]`@version`|`String`|+++ +(Required) ++++ +|=== + +[[CloudwatchLogsEvent]] +== CloudwatchLogsEvent + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[awslogs]]`@awslogs`|`link:dataobjects.html#CloudwatchLogsRawData[CloudwatchLogsRawData]`|+++ +(Required) ++++ +|=== + +[[CloudwatchLogsRawData]] +== CloudwatchLogsRawData + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[data]]`@data`|`String`|+++ +(Required) ++++ +|=== + +[[ConfigEvent]] +== ConfigEvent + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[accountId]]`@accountId`|`String`|+++ +(Required) ++++ +|[[configRuleArn]]`@configRuleArn`|`String`|+++ +(Required) ++++ +|[[configRuleId]]`@configRuleId`|`String`|+++ +(Required) ++++ +|[[configRuleName]]`@configRuleName`|`String`|+++ +(Required) ++++ +|[[eventLeftScope]]`@eventLeftScope`|`Boolean`|+++ +(Required) ++++ +|[[executionRoleArn]]`@executionRoleArn`|`String`|+++ +(Required) ++++ +|[[invokingEvent]]`@invokingEvent`|`String`|+++ +(Required) ++++ +|[[resultToken]]`@resultToken`|`String`|+++ +(Required) ++++ +|[[ruleParameters]]`@ruleParameters`|`String`|+++ +(Required) ++++ +|[[version]]`@version`|`String`|+++ +(Required) ++++ +|=== + +[[IAMPolicyStatement]] +== IAMPolicyStatement + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[action]]`@action`|`Array of String`|+++ +(Required) ++++ +|[[effect]]`@effect`|`String`|+++ +(Required) ++++ +|[[resource]]`@resource`|`Array of String`|+++ +(Required) ++++ +|=== + +[[IoTButtonEvent]] +== IoTButtonEvent + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[batteryVoltage]]`@batteryVoltage`|`String`|+++ +(Required) ++++ +|[[clickType]]`@clickType`|`String`|+++ +(Required) ++++ +|[[serialNumber]]`@serialNumber`|`String`|+++ +(Required) ++++ +|=== + +[[KinesisEvent]] +== KinesisEvent + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[records]]`@records`|`Array of link:dataobjects.html#KinesisEventRecord[KinesisEventRecord]`|+++ +(Required) ++++ +|=== + +[[KinesisEventRecord]] +== KinesisEventRecord + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[awsRegion]]`@awsRegion`|`String`|+++ +(Required) ++++ +|[[eventID]]`@eventID`|`String`|+++ +(Required) ++++ +|[[eventName]]`@eventName`|`String`|+++ +(Required) ++++ +|[[eventSource]]`@eventSource`|`String`|+++ +(Required) ++++ +|[[eventSourceARN]]`@eventSourceARN`|`String`|+++ +(Required) ++++ +|[[eventVersion]]`@eventVersion`|`String`|+++ +(Required) ++++ +|[[invokeIdentityArn]]`@invokeIdentityArn`|`String`|+++ +(Required) ++++ +|[[kinesis]]`@kinesis`|`link:dataobjects.html#KinesisRecord[KinesisRecord]`|+++ +(Required) ++++ +|=== + +[[KinesisFirehoseEvent]] +== KinesisFirehoseEvent + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[deliveryStreamArn]]`@deliveryStreamArn`|`String`|+++ +(Required) ++++ +|[[invocationId]]`@invocationId`|`String`|+++ +(Required) ++++ +|[[records]]`@records`|`Array of link:dataobjects.html#KinesisFirehoseEventRecord[KinesisFirehoseEventRecord]`|+++ +(Required) ++++ +|[[region]]`@region`|`String`|+++ +(Required) ++++ +|=== + +[[KinesisFirehoseEventRecord]] +== KinesisFirehoseEventRecord + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[approximateArrivalTimestamp]]`@approximateArrivalTimestamp`|`link:dataobjects.html#MilliSecondsEpochTime[MilliSecondsEpochTime]`|+++ +(Required) ++++ +|[[data]]`@data`|`Buffer`|+++ +(Required) ++++ +|[[recordId]]`@recordId`|`String`|+++ +(Required) ++++ +|=== + +[[KinesisRecord]] +== KinesisRecord + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[approximateArrivalTimestamp]]`@approximateArrivalTimestamp`|`link:dataobjects.html#SecondsEpochTime[SecondsEpochTime]`|+++ +(Required) ++++ +|[[data]]`@data`|`Buffer`|+++ +(Required) ++++ +|[[encryptionType]]`@encryptionType`|`String`|- +|[[kinesisSchemaVersion]]`@kinesisSchemaVersion`|`String`|+++ +(Required) ++++ +|[[partitionKey]]`@partitionKey`|`String`|+++ +(Required) ++++ +|[[sequenceNumber]]`@sequenceNumber`|`String`|+++ +(Required) ++++ +|=== + +[[LexBot]] +== LexBot + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[alias]]`@alias`|`String`|- +|[[name]]`@name`|`String`|- +|[[version]]`@version`|`String`|- +|=== + +[[LexCurrentIntent]] +== LexCurrentIntent + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[confirmationStatus]]`@confirmationStatus`|`String`|- +|[[name]]`@name`|`String`|- +|[[slotDetails]]`@slotDetails`|`Json object`|- +|[[slots]]`@slots`|`Json object`|- +|=== + +[[LexDialogAction]] +== LexDialogAction + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[fulfillmentState]]`@fulfillmentState`|`String`|- +|[[intentName]]`@intentName`|`String`|- +|[[message]]`@message`|`Json object`|- +|[[responseCard]]`@responseCard`|`link:dataobjects.html#LexResponseCard[LexResponseCard]`|- +|[[slotToElicit]]`@slotToElicit`|`String`|- +|[[slots]]`@slots`|`Json object`|- +|[[type]]`@type`|`String`|- +|=== + +[[LexEvent]] +== LexEvent + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[bot]]`@bot`|`link:dataobjects.html#LexBot[LexBot]`|- +|[[currentIntent]]`@currentIntent`|`link:dataobjects.html#LexCurrentIntent[LexCurrentIntent]`|- +|[[dialogAction]]`@dialogAction`|`link:dataobjects.html#LexDialogAction[LexDialogAction]`|- +|[[inputTranscript]]`@inputTranscript`|`String`|- +|[[invocationSource]]`@invocationSource`|`String`|- +|[[messageVersion]]`@messageVersion`|`String`|- +|[[outputDialogMode]]`@outputDialogMode`|`String`|- +|[[requestAttributes]]`@requestAttributes`|`Json object`|- +|[[sessionAttributes]]`@sessionAttributes`|`Json object`|- +|[[userId]]`@userId`|`String`|- +|=== + +[[LexResponseCard]] +== LexResponseCard + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[contentType]]`@contentType`|`String`|- +|[[genericAttachments]]`@genericAttachments`|`Array of link:dataobjects.html#Attachment[Attachment]`|- +|[[version]]`@version`|`Number (Integer)`|- +|=== + +[[MilliSecondsEpochTime]] +== MilliSecondsEpochTime + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|=== + +[[S3Bucket]] +== S3Bucket + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[arn]]`@arn`|`String`|+++ +(Required) ++++ +|[[name]]`@name`|`String`|+++ +(Required) ++++ +|[[ownerIdentity]]`@ownerIdentity`|`link:dataobjects.html#S3UserIdentity[S3UserIdentity]`|+++ +(Required) ++++ +|=== + +[[S3Entity]] +== S3Entity + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[bucket]]`@bucket`|`link:dataobjects.html#S3Bucket[S3Bucket]`|+++ +(Required) ++++ +|[[configurationId]]`@configurationId`|`String`|+++ +(Required) ++++ +|[[object]]`@object`|`link:dataobjects.html#S3Object[S3Object]`|+++ +(Required) ++++ +|[[s3SchemaVersion]]`@s3SchemaVersion`|`String`|+++ +(Required) ++++ +|=== + +[[S3Event]] +== S3Event + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[records]]`@records`|`Array of link:dataobjects.html#S3EventRecord[S3EventRecord]`|+++ +(Required) ++++ +|=== + +[[S3EventRecord]] +== S3EventRecord + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[awsRegion]]`@awsRegion`|`String`|+++ +(Required) ++++ +|[[eventName]]`@eventName`|`String`|+++ +(Required) ++++ +|[[eventSource]]`@eventSource`|`String`|+++ +(Required) ++++ +|[[eventVersion]]`@eventVersion`|`String`|+++ +(Required) ++++ +|[[requestParameters]]`@requestParameters`|`link:dataobjects.html#S3RequestParameters[S3RequestParameters]`|+++ +(Required) ++++ +|[[responseElements]]`@responseElements`|`Json object`|+++ +(Required) ++++ +|[[s3]]`@s3`|`link:dataobjects.html#S3Entity[S3Entity]`|+++ +(Required) ++++ +|[[userIdentity]]`@userIdentity`|`link:dataobjects.html#S3UserIdentity[S3UserIdentity]`|+++ +(Required) ++++ +|=== + +[[S3Object]] +== S3Object + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[key]]`@key`|`String`|+++ +(Required) ++++ +|[[sequencer]]`@sequencer`|`String`|+++ +(Required) ++++ +|[[size]]`@size`|`Number (Integer)`|+++ +(Required) ++++ +|[[urlDecodedKey]]`@urlDecodedKey`|`String`|+++ +(Required) ++++ +|[[versionId]]`@versionId`|`String`|+++ +(Required) ++++ +|=== + +[[S3RequestParameters]] +== S3RequestParameters + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[sourceIPAddress]]`@sourceIPAddress`|`String`|+++ +(Required) ++++ +|=== + +[[S3UserIdentity]] +== S3UserIdentity + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[principalId]]`@principalId`|`String`|+++ +(Required) ++++ +|=== + +[[SNSEntity]] +== SNSEntity + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[message]]`@message`|`String`|+++ +(Required) ++++ +|[[messageAttributes]]`@messageAttributes`|`Json object`|+++ +(Required) ++++ +|[[messageId]]`@messageId`|`String`|+++ +(Required) ++++ +|[[signature]]`@signature`|`String`|+++ +(Required) ++++ +|[[signatureVersion]]`@signatureVersion`|`String`|+++ +(Required) ++++ +|[[signingCertUrl]]`@signingCertUrl`|`String`|+++ +(Required) ++++ +|[[subject]]`@subject`|`String`|+++ +(Required) ++++ +|[[topicArn]]`@topicArn`|`String`|+++ +(Required) ++++ +|[[type]]`@type`|`String`|+++ +(Required) ++++ +|[[unsubscribeUrl]]`@unsubscribeUrl`|`String`|+++ +(Required) ++++ +|=== + +[[SNSEvent]] +== SNSEvent + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[records]]`@records`|`Array of link:dataobjects.html#SNSEventRecord[SNSEventRecord]`|+++ +(Required) ++++ +|=== + +[[SNSEventRecord]] +== SNSEventRecord + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[eventSource]]`@eventSource`|`String`|+++ +(Required) ++++ +|[[eventSubscriptionArn]]`@eventSubscriptionArn`|`String`|+++ +(Required) ++++ +|[[eventVersion]]`@eventVersion`|`String`|+++ +(Required) ++++ +|[[sns]]`@sns`|`link:dataobjects.html#SNSEntity[SNSEntity]`|+++ +(Required) ++++ +|=== + +[[SQSEvent]] +== SQSEvent + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[records]]`@records`|`Array of link:dataobjects.html#SQSMessage[SQSMessage]`|+++ +(Required) ++++ +|=== + +[[SQSMessage]] +== SQSMessage + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[attributes]]`@attributes`|`Json object`|+++ +(Required) ++++ +|[[awsRegion]]`@awsRegion`|`String`|+++ +(Required) ++++ +|[[body]]`@body`|`String`|+++ +(Required) ++++ +|[[eventSource]]`@eventSource`|`String`|+++ +(Required) ++++ +|[[eventSourceARN]]`@eventSourceARN`|`String`|+++ +(Required) ++++ +|[[md5OfBody]]`@md5OfBody`|`String`|+++ +(Required) ++++ +|[[md5OfMessageAttributes]]`@md5OfMessageAttributes`|`String`|+++ +(Required) ++++ +|[[messageAttributes]]`@messageAttributes`|`Json object`|+++ +(Required) ++++ +|[[messageId]]`@messageId`|`String`|+++ +(Required) ++++ +|[[receiptHandle]]`@receiptHandle`|`String`|+++ +(Required) ++++ +|=== + +[[SecondsEpochTime]] +== SecondsEpochTime + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|=== + +[[SimpleEmailCommonHeaders]] +== SimpleEmailCommonHeaders + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[date]]`@date`|`String`|+++ +(Required) ++++ +|[[from]]`@from`|`Array of String`|+++ +(Required) ++++ +|[[messageId]]`@messageId`|`String`|+++ +(Required) ++++ +|[[returnPath]]`@returnPath`|`String`|+++ +(Required) ++++ +|[[subject]]`@subject`|`String`|+++ +(Required) ++++ +|[[to]]`@to`|`Array of String`|+++ +(Required) ++++ +|=== + +[[SimpleEmailEvent]] +== SimpleEmailEvent + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[records]]`@records`|`Array of link:dataobjects.html#SimpleEmailRecord[SimpleEmailRecord]`|+++ +(Required) ++++ +|=== + +[[SimpleEmailHeader]] +== SimpleEmailHeader + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[name]]`@name`|`String`|+++ +(Required) ++++ +|[[value]]`@value`|`String`|+++ +(Required) ++++ +|=== + +[[SimpleEmailMessage]] +== SimpleEmailMessage + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[commonHeaders]]`@commonHeaders`|`link:dataobjects.html#SimpleEmailCommonHeaders[SimpleEmailCommonHeaders]`|+++ +(Required) ++++ +|[[destination]]`@destination`|`Array of String`|+++ +(Required) ++++ +|[[headers]]`@headers`|`Array of link:dataobjects.html#SimpleEmailHeader[SimpleEmailHeader]`|+++ +(Required) ++++ +|[[headersTruncated]]`@headersTruncated`|`Boolean`|+++ +(Required) ++++ +|[[messageId]]`@messageId`|`String`|+++ +(Required) ++++ +|[[source]]`@source`|`String`|+++ +(Required) ++++ +|=== + +[[SimpleEmailReceipt]] +== SimpleEmailReceipt + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[action]]`@action`|`link:dataobjects.html#SimpleEmailReceiptAction[SimpleEmailReceiptAction]`|+++ +(Required) ++++ +|[[dkimVerdict]]`@dkimVerdict`|`link:dataobjects.html#SimpleEmailVerdict[SimpleEmailVerdict]`|+++ +(Required) ++++ +|[[dmarcPolicy]]`@dmarcPolicy`|`link:dataobjects.html#SimpleEmailVerdict[SimpleEmailVerdict]`|+++ +(Required) ++++ +|[[dmarcVerdict]]`@dmarcVerdict`|`link:dataobjects.html#SimpleEmailVerdict[SimpleEmailVerdict]`|+++ +(Required) ++++ +|[[processingTimeMillis]]`@processingTimeMillis`|`Number (Integer)`|+++ +(Required) ++++ +|[[recipients]]`@recipients`|`Array of String`|+++ +(Required) ++++ +|[[spamVerdict]]`@spamVerdict`|`link:dataobjects.html#SimpleEmailVerdict[SimpleEmailVerdict]`|+++ +(Required) ++++ +|[[spfVerdict]]`@spfVerdict`|`link:dataobjects.html#SimpleEmailVerdict[SimpleEmailVerdict]`|+++ +(Required) ++++ +|[[virusVerdict]]`@virusVerdict`|`link:dataobjects.html#SimpleEmailVerdict[SimpleEmailVerdict]`|+++ +(Required) ++++ +|=== + +[[SimpleEmailReceiptAction]] +== SimpleEmailReceiptAction + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[functionArn]]`@functionArn`|`String`|+++ +(Required) ++++ +|[[invocationType]]`@invocationType`|`String`|+++ +(Required) ++++ +|[[type]]`@type`|`String`|+++ +(Required) ++++ +|=== + +[[SimpleEmailRecord]] +== SimpleEmailRecord + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[eventSource]]`@eventSource`|`String`|+++ +(Required) ++++ +|[[eventVersion]]`@eventVersion`|`String`|+++ +(Required) ++++ +|[[ses]]`@ses`|`link:dataobjects.html#SimpleEmailService[SimpleEmailService]`|+++ +(Required) ++++ +|=== + +[[SimpleEmailService]] +== SimpleEmailService + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[mail]]`@mail`|`link:dataobjects.html#SimpleEmailMessage[SimpleEmailMessage]`|+++ +(Required) ++++ +|[[receipt]]`@receipt`|`link:dataobjects.html#SimpleEmailReceipt[SimpleEmailReceipt]`|+++ +(Required) ++++ +|=== + +[[SimpleEmailVerdict]] +== SimpleEmailVerdict + + +[cols=">25%,25%,50%"] +[frame="topbot"] +|=== +^|Name | Type ^| Description +|[[status]]`@status`|`String`|+++ +(Required) ++++ +|=== + diff --git a/src/main/java/SVMSubstitutions.java b/boilerplate/src/main/java/SVMSubstitutions.java similarity index 78% rename from src/main/java/SVMSubstitutions.java rename to boilerplate/src/main/java/SVMSubstitutions.java index e8e912a..1eb67ef 100644 --- a/src/main/java/SVMSubstitutions.java +++ b/boilerplate/src/main/java/SVMSubstitutions.java @@ -1,3 +1,21 @@ +/* + * Copyright 2019 Paulo Lopes. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Apache License v2.0 which accompanies this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * The Apache License v2.0 is available at + * http://www.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + */ + +/// TODO: remove me when netty 4.1.36 is the default on vertx-core + import com.oracle.svm.core.annotate.*; import org.graalvm.nativeimage.*; diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/Bootstrap.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/Bootstrap.java new file mode 100644 index 0000000..41d258a --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/Bootstrap.java @@ -0,0 +1,264 @@ +/* + * Copyright 2019 Paulo Lopes. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Apache License v2.0 which accompanies this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * The Apache License v2.0 is available at + * http://www.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + */ +package xyz.jetdrone.vertx.lambda.aws; + +import io.vertx.core.*; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.eventbus.DeliveryOptions; +import io.vertx.core.eventbus.EventBus; +import io.vertx.core.json.DecodeException; +import io.vertx.core.json.EncodeException; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.web.client.HttpRequest; +import io.vertx.ext.web.client.HttpResponse; +import io.vertx.ext.web.client.WebClient; +import io.vertx.ext.web.client.WebClientOptions; + +import static io.vertx.core.http.HttpHeaders.CONTENT_TYPE; +import static java.lang.System.getenv; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.text.MessageFormat; +import java.util.ServiceLoader; + +/** + * Main entrypoint for the application. + */ +public class Bootstrap extends AbstractVerticle { + + private static final String LAMBDA_VERSION_DATE = "2018-06-01"; + + private static final String LAMBDA_RUNTIME_TEMPLATE = "/{0}/runtime/invocation/next"; + private static final String LAMBDA_INVOCATION_TEMPLATE = "/{0}/runtime/invocation/{1}/response"; + private static final String LAMBDA_INIT_ERROR_TEMPLATE = "/{0}/runtime/init/error"; + private static final String LAMBDA_ERROR_TEMPLATE = "/{0}/runtime/invocation/{1}/error"; + + public static void main(String[] args) { + try { + final VertxOptions vertxOptions = new VertxOptions().setEventLoopPoolSize(1); + final JsonObject config = new JsonObject(); + final DeploymentOptions deploymentOptions = new DeploymentOptions().setConfig(config); + + String runtimeApi = getenv("AWS_LAMBDA_RUNTIME_API"); + + int sep = runtimeApi.indexOf(':'); + if (sep != -1) { + config.put("host", runtimeApi.substring(0, sep)); + config.put("port", Integer.parseInt(runtimeApi.substring(sep + 1))); + } else { + config.put("host", runtimeApi); + } + config.put("runtimeUrl", MessageFormat.format(LAMBDA_RUNTIME_TEMPLATE, LAMBDA_VERSION_DATE)); + + Vertx.vertx(vertxOptions).deployVerticle(new Bootstrap(), deploymentOptions, deploy -> { + if (deploy.failed()) { + System.err.println(deploy.cause().getMessage()); + // the whole startup failed + System.exit(1); + } + }); + } catch (RuntimeException e) { + e.printStackTrace(); + System.exit(1); + } + } + + private WebClient client; + private String fn; + + @Override + public void start() { + final JsonObject config = context.config(); + final EventBus eb = vertx.eventBus(); + + // register all lambda's into the eventbus + for (Lambda fn : ServiceLoader.load(Lambda.class)) { + fn.init(vertx); + eb.localConsumer(fn.getClass().getName(), fn); + } + + // create an WebClient + this.client = WebClient.create(vertx, new WebClientOptions() + .setDefaultPort(config.getInteger("port", 80)) + .setDefaultHost(config.getString("host"))); + + // Get the handler class and method name from the Lambda Configuration in the format of + fn = getenv("_HANDLER"); + + if (fn == null) { + // Not much else to do handler can't be found. + fail(MessageFormat.format(LAMBDA_INIT_ERROR_TEMPLATE, LAMBDA_VERSION_DATE), "Could not find handler method [" + fn + "]"); + } else { + processEvents(); + } + } + + private void processEvents() { + final EventBus eb = vertx.eventBus(); + final JsonObject config = context.config(); + + client.get(config.getString("runtimeUrl")).send(getAbs -> { + if (getAbs.succeeded()) { + HttpResponse response = getAbs.result(); + + switch (response.statusCode()) { + case 200: + break; + case 404: + System.exit(0); + default: + System.err.println("ERR: HTTP status code <" + response.statusCode() + ">"); + System.exit(1); + } + + String requestId = response.getHeader(Lambda.LAMBDA_RUNTIME_AWS_REQUEST_ID); + Object event; + + // parse body + if (response.headers() != null && "application/json".equals(response.headers().get(CONTENT_TYPE))) { + try { + event = new JsonObject(response.body()); + } catch (DecodeException e) { + fail(MessageFormat.format(LAMBDA_ERROR_TEMPLATE, LAMBDA_VERSION_DATE, requestId), e); + return; + } + } else { + event = response.body(); + } + + // Invoke Handler Method + eb.send(fn, event, new DeliveryOptions().setHeaders(response.headers()), msg -> { + if (msg.failed()) { + fail(MessageFormat.format(LAMBDA_ERROR_TEMPLATE, LAMBDA_VERSION_DATE, requestId), msg.cause()); + } else { + // Post the results of Handler Invocation + final String invocationUrl = MessageFormat.format(LAMBDA_INVOCATION_TEMPLATE, LAMBDA_VERSION_DATE, requestId); + final MultiMap fnHeaders = msg.result().headers(); + Object fnResult = msg.result().body(); + + if (fnResult instanceof JsonObject) { + try { + success(invocationUrl, (JsonObject) fnResult, fnHeaders, this::next); + } catch (EncodeException e) { + fail(MessageFormat.format(LAMBDA_ERROR_TEMPLATE, LAMBDA_VERSION_DATE, requestId), e); + } + return; + } + + if (fnResult instanceof Buffer) { + success(invocationUrl, (Buffer) fnResult, fnHeaders, this::next); + return; + } + + fail(MessageFormat.format(LAMBDA_ERROR_TEMPLATE, LAMBDA_VERSION_DATE, requestId), "Response is not Buffer of JSON"); + } + }); + } else { + getAbs.cause().printStackTrace(); + System.exit(1); + } + }); + } + + private void next(AsyncResult ack) { + if (ack.failed()) { + ack.cause().printStackTrace(); + // terminate the process + System.exit(1); + } else { + // process the next call + // run on context to avoid large stacks + vertx.runOnContext(v -> processEvents()); + } + } + + private void success(String requestURI, Buffer result, MultiMap header, Handler> handler) { + client.post(requestURI) + .putHeaders(header) + .sendBuffer(result, ar -> { + if (ar.succeeded()) { + // we don't really care about the response + handler.handle(Future.succeededFuture()); + } else { + handler.handle(Future.failedFuture(ar.cause())); + } + }); + } + + private void success(String requestURI, JsonObject result, MultiMap headers, Handler> handler) { + final HttpRequest request = client.post(requestURI); + + if (headers != null) { + request.putHeaders(headers); + } + + request.sendJson(result, ar -> { + if (ar.succeeded()) { + // we don't really care about the response + handler.handle(Future.succeededFuture()); + } else { + handler.handle(Future.failedFuture(ar.cause())); + } + }); + } + + private void fail(String requestURI, String errType, String errMsg, String errTrace) { + System.err.println("ERR: " + errMsg); + + final JsonObject error = new JsonObject() + .put("errorType", errType) + .put("errorMessage", errMsg); + + if (errTrace != null) { + final JsonArray trace = new JsonArray(); + error.put("trace", trace); + + for (String line : errTrace.split("\r?\n")) { + trace.add(line); + } + } + + client.post(requestURI) + .sendJson(error, ar -> { + if (ar.failed()) { + ar.cause().printStackTrace(); + } + // terminate the process + System.exit(1); + }); + } + + private void fail(String requestURI, String errMsg) { + fail(requestURI, "RuntimeError", errMsg, null); + } + + private void fail(String requestURI, Throwable throwable) { + try (StringWriter sw = new StringWriter()) { + PrintWriter pw = new PrintWriter(sw); + // print the thrown to String + throwable.printStackTrace(pw); + + fail(requestURI, throwable.getClass().getSimpleName(), throwable.getMessage(), sw.toString()); + } catch (IOException e) { + e.printStackTrace(); + // terminate the process + System.exit(1); + } + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/Lambda.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/Lambda.java new file mode 100644 index 0000000..24b01cf --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/Lambda.java @@ -0,0 +1,68 @@ +/* + * Copyright 2019 Paulo Lopes. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Apache License v2.0 which accompanies this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * The Apache License v2.0 is available at + * http://www.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + */ +package xyz.jetdrone.vertx.lambda.aws; + +import io.vertx.core.Handler; +import io.vertx.core.Vertx; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.eventbus.Message; +import io.vertx.core.json.JsonObject; + +/** + * Your Lambda function's handler is the method that Lambda calls when your function is invoked. + * + * In the following example, the class MyFunction implements a lambda handler. The handler takes + * one object as input and returns a JSON document. + * + * + * (msg) -> { + * System.out.println(msg.body()); + * msg.reply(new JsonObject().put("hello", "world")); + * } + * + * + * The message body is an object that contains the payload that's provided by the invoker. If the payload is a JSON + * document, the event object is a {@link JsonObject}. Otherwise, it's a {@link Buffer}. The {@link Message} object has + * methods and properties that provide information about the invocation, the headers, and the execution environment. + * + * The handler is executed every time your Lambda function is invoked. Static code outside of the handler or the + * {@link Lambda#init(Vertx)} method is executed once per instance of the function. If your handler uses resources like + * SDK clients and database connections, you can create them outside of the handler method to reuse them for multiple + * invocations. + * + * Each instance of your lambda can process multiple invocation events, but it only processes one event at a time. + * The number of instances processing an event at any given time is your function's concurrency. For more information + * about the Lambda execution context, see AWS Lambda Execution Context. + */ +@FunctionalInterface +public interface Lambda extends Handler> { + + String LAMBDA_RUNTIME_AWS_REQUEST_ID = "Lambda-Runtime-Aws-Request-Id"; + String LAMBDA_RUNTIME_DEADLINE_MS = "Lambda-Runtime-Deadline-Ms"; + String LAMBDA_RUNTIME_INVOKE_FUNCTION_ARN = "Lambda-Runtime-Invoke-Function-Arn"; + String LAMBDA_RUNTIME_TRACE_ID = "Lambda-Runtime-Trace-Id"; + String LAMBDA_RUNTIME_CLIENT_CONTEXT = "Lambda-Runtime-Client-Context"; + String LAMBDA_RUNTIME_COGNITO_IDENTITY = "Lambda-Runtime-Cognito-Identity"; + + /** + * Default initialization. It can be used if a function needs to access vertx or the eventbus. + * + * @param vertx the current vertx instance. + */ + default void init(Vertx vertx) { + // NO-OP! + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayCustomAuthorizerPolicy.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayCustomAuthorizerPolicy.java new file mode 100644 index 0000000..9b462ac --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayCustomAuthorizerPolicy.java @@ -0,0 +1,68 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +@DataObject(generateConverter = true) +public class APIGatewayCustomAuthorizerPolicy { + + public APIGatewayCustomAuthorizerPolicy() {} + + public APIGatewayCustomAuthorizerPolicy(JsonObject json) { + APIGatewayCustomAuthorizerPolicyConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + APIGatewayCustomAuthorizerPolicyConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private List statement = new ArrayList(); + /** + * (Required) + */ + private String version; + + /** + * (Required) + */ + public List getStatement() { + return statement; + } + + /** + * (Required) + */ + public APIGatewayCustomAuthorizerPolicy setStatement(List statement) { + this.statement = statement; + return this; + } + + /** + * (Required) + */ + public String getVersion() { + return version; + } + + /** + * (Required) + */ + public APIGatewayCustomAuthorizerPolicy setVersion(String version) { + this.version = version; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayCustomAuthorizerRequest.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayCustomAuthorizerRequest.java new file mode 100644 index 0000000..f3238b7 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayCustomAuthorizerRequest.java @@ -0,0 +1,85 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class APIGatewayCustomAuthorizerRequest { + + public APIGatewayCustomAuthorizerRequest() {} + + public APIGatewayCustomAuthorizerRequest(JsonObject json) { + APIGatewayCustomAuthorizerRequestConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + APIGatewayCustomAuthorizerRequestConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String authorizationToken; + /** + * (Required) + */ + private String methodArn; + /** + * (Required) + */ + private String type; + + /** + * (Required) + */ + public String getAuthorizationToken() { + return authorizationToken; + } + + /** + * (Required) + */ + public APIGatewayCustomAuthorizerRequest setAuthorizationToken(String authorizationToken) { + this.authorizationToken = authorizationToken; + return this; + } + + /** + * (Required) + */ + public String getMethodArn() { + return methodArn; + } + + /** + * (Required) + */ + public APIGatewayCustomAuthorizerRequest setMethodArn(String methodArn) { + this.methodArn = methodArn; + return this; + } + + /** + * (Required) + */ + public String getType() { + return type; + } + + /** + * (Required) + */ + public APIGatewayCustomAuthorizerRequest setType(String type) { + this.type = type; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayCustomAuthorizerResponse.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayCustomAuthorizerResponse.java new file mode 100644 index 0000000..65ca63e --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayCustomAuthorizerResponse.java @@ -0,0 +1,86 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class APIGatewayCustomAuthorizerResponse { + + public APIGatewayCustomAuthorizerResponse() {} + + public APIGatewayCustomAuthorizerResponse(JsonObject json) { + APIGatewayCustomAuthorizerResponseConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + APIGatewayCustomAuthorizerResponseConverter.toJson(this, json); + return json; + } + + private JsonObject context; + /** + * (Required) + */ + private APIGatewayCustomAuthorizerPolicy policyDocument; + /** + * (Required) + */ + private String principalId; + private String usageIdentifierKey; + + public JsonObject getContext() { + return context; + } + + public APIGatewayCustomAuthorizerResponse setContext(JsonObject context) { + this.context = context; + return this; + } + + /** + * (Required) + */ + public APIGatewayCustomAuthorizerPolicy getPolicyDocument() { + return policyDocument; + } + + /** + * (Required) + */ + public APIGatewayCustomAuthorizerResponse setPolicyDocument(APIGatewayCustomAuthorizerPolicy policyDocument) { + this.policyDocument = policyDocument; + return this; + } + + /** + * (Required) + */ + public String getPrincipalId() { + return principalId; + } + + /** + * (Required) + */ + public APIGatewayCustomAuthorizerResponse setPrincipalId(String principalId) { + this.principalId = principalId; + return this; + } + + public String getUsageIdentifierKey() { + return usageIdentifierKey; + } + + public APIGatewayCustomAuthorizerResponse setUsageIdentifierKey(String usageIdentifierKey) { + this.usageIdentifierKey = usageIdentifierKey; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayProxyRequest.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayProxyRequest.java new file mode 100644 index 0000000..28b9220 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayProxyRequest.java @@ -0,0 +1,208 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class APIGatewayProxyRequest { + + public APIGatewayProxyRequest() {} + + public APIGatewayProxyRequest(JsonObject json) { + APIGatewayProxyRequestConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + APIGatewayProxyRequestConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String body; + /** + * (Required) + */ + private JsonObject headers; + /** + * (Required) + */ + private String httpMethod; + private Boolean isBase64Encoded; + /** + * (Required) + */ + private String path; + /** + * (Required) + */ + private JsonObject pathParameters; + /** + * (Required) + */ + private JsonObject queryStringParameters; + /** + * (Required) + */ + private APIGatewayProxyRequestContext requestContext; + /** + * (Required) + */ + private String resource; + /** + * (Required) + */ + private JsonObject stageVariables; + + /** + * (Required) + */ + public String getBody() { + return body; + } + + /** + * (Required) + */ + public APIGatewayProxyRequest setBody(String body) { + this.body = body; + return this; + } + + /** + * (Required) + */ + public JsonObject getHeaders() { + return headers; + } + + /** + * (Required) + */ + public APIGatewayProxyRequest setHeaders(JsonObject headers) { + this.headers = headers; + return this; + } + + /** + * (Required) + */ + public String getHttpMethod() { + return httpMethod; + } + + /** + * (Required) + */ + public APIGatewayProxyRequest setHttpMethod(String httpMethod) { + this.httpMethod = httpMethod; + return this; + } + + public Boolean getIsBase64Encoded() { + return isBase64Encoded; + } + + public APIGatewayProxyRequest setIsBase64Encoded(Boolean isBase64Encoded) { + this.isBase64Encoded = isBase64Encoded; + return this; + } + + /** + * (Required) + */ + public String getPath() { + return path; + } + + /** + * (Required) + */ + public APIGatewayProxyRequest setPath(String path) { + this.path = path; + return this; + } + + /** + * (Required) + */ + public JsonObject getPathParameters() { + return pathParameters; + } + + /** + * (Required) + */ + public APIGatewayProxyRequest setPathParameters(JsonObject pathParameters) { + this.pathParameters = pathParameters; + return this; + } + + /** + * (Required) + */ + public JsonObject getQueryStringParameters() { + return queryStringParameters; + } + + /** + * (Required) + */ + public APIGatewayProxyRequest setQueryStringParameters(JsonObject queryStringParameters) { + this.queryStringParameters = queryStringParameters; + return this; + } + + /** + * (Required) + */ + public APIGatewayProxyRequestContext getRequestContext() { + return requestContext; + } + + /** + * (Required) + */ + public APIGatewayProxyRequest setRequestContext(APIGatewayProxyRequestContext requestContext) { + this.requestContext = requestContext; + return this; + } + + /** + * (Required) + */ + public String getResource() { + return resource; + } + + /** + * (Required) + */ + public APIGatewayProxyRequest setResource(String resource) { + this.resource = resource; + return this; + } + + /** + * (Required) + */ + public JsonObject getStageVariables() { + return stageVariables; + } + + /** + * (Required) + */ + public APIGatewayProxyRequest setStageVariables(JsonObject stageVariables) { + this.stageVariables = stageVariables; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayProxyRequestContext.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayProxyRequestContext.java new file mode 100644 index 0000000..a8783a7 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayProxyRequestContext.java @@ -0,0 +1,198 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class APIGatewayProxyRequestContext { + + public APIGatewayProxyRequestContext() {} + + public APIGatewayProxyRequestContext(JsonObject json) { + APIGatewayProxyRequestContextConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + APIGatewayProxyRequestContextConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String accountId; + /** + * (Required) + */ + private String apiId; + /** + * (Required) + */ + private JsonObject authorizer; + /** + * (Required) + */ + private String httpMethod; + /** + * (Required) + */ + private APIGatewayRequestIdentity identity; + /** + * (Required) + */ + private String requestId; + /** + * (Required) + */ + private String resourceId; + /** + * (Required) + */ + private String resourcePath; + /** + * (Required) + */ + private String stage; + + /** + * (Required) + */ + public String getAccountId() { + return accountId; + } + + /** + * (Required) + */ + public APIGatewayProxyRequestContext setAccountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * (Required) + */ + public String getApiId() { + return apiId; + } + + /** + * (Required) + */ + public APIGatewayProxyRequestContext setApiId(String apiId) { + this.apiId = apiId; + return this; + } + + /** + * (Required) + */ + public JsonObject getAuthorizer() { + return authorizer; + } + + /** + * (Required) + */ + public APIGatewayProxyRequestContext setAuthorizer(JsonObject authorizer) { + this.authorizer = authorizer; + return this; + } + + /** + * (Required) + */ + public String getHttpMethod() { + return httpMethod; + } + + /** + * (Required) + */ + public APIGatewayProxyRequestContext setHttpMethod(String httpMethod) { + this.httpMethod = httpMethod; + return this; + } + + /** + * (Required) + */ + public APIGatewayRequestIdentity getIdentity() { + return identity; + } + + /** + * (Required) + */ + public APIGatewayProxyRequestContext setIdentity(APIGatewayRequestIdentity identity) { + this.identity = identity; + return this; + } + + /** + * (Required) + */ + public String getRequestId() { + return requestId; + } + + /** + * (Required) + */ + public APIGatewayProxyRequestContext setRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + /** + * (Required) + */ + public String getResourceId() { + return resourceId; + } + + /** + * (Required) + */ + public APIGatewayProxyRequestContext setResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * (Required) + */ + public String getResourcePath() { + return resourcePath; + } + + /** + * (Required) + */ + public APIGatewayProxyRequestContext setResourcePath(String resourcePath) { + this.resourcePath = resourcePath; + return this; + } + + /** + * (Required) + */ + public String getStage() { + return stage; + } + + /** + * (Required) + */ + public APIGatewayProxyRequestContext setStage(String stage) { + this.stage = stage; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayProxyResponse.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayProxyResponse.java new file mode 100644 index 0000000..a274e90 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayProxyResponse.java @@ -0,0 +1,94 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class APIGatewayProxyResponse { + + public APIGatewayProxyResponse() {} + + public APIGatewayProxyResponse(JsonObject json) { + APIGatewayProxyResponseConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + APIGatewayProxyResponseConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String body; + /** + * (Required) + */ + private JsonObject headers; + private Boolean isBase64Encoded; + /** + * (Required) + */ + private Integer statusCode; + + /** + * (Required) + */ + public String getBody() { + return body; + } + + /** + * (Required) + */ + public APIGatewayProxyResponse setBody(String body) { + this.body = body; + return this; + } + + /** + * (Required) + */ + public JsonObject getHeaders() { + return headers; + } + + /** + * (Required) + */ + public APIGatewayProxyResponse setHeaders(JsonObject headers) { + this.headers = headers; + return this; + } + + public Boolean getIsBase64Encoded() { + return isBase64Encoded; + } + + public APIGatewayProxyResponse setIsBase64Encoded(Boolean isBase64Encoded) { + this.isBase64Encoded = isBase64Encoded; + return this; + } + + /** + * (Required) + */ + public Integer getStatusCode() { + return statusCode; + } + + /** + * (Required) + */ + public APIGatewayProxyResponse setStatusCode(Integer statusCode) { + this.statusCode = statusCode; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayRequestIdentity.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayRequestIdentity.java new file mode 100644 index 0000000..980f01a --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/APIGatewayRequestIdentity.java @@ -0,0 +1,236 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class APIGatewayRequestIdentity { + + public APIGatewayRequestIdentity() {} + + public APIGatewayRequestIdentity(JsonObject json) { + APIGatewayRequestIdentityConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + APIGatewayRequestIdentityConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String accountId; + /** + * (Required) + */ + private String apiKey; + /** + * (Required) + */ + private String caller; + /** + * (Required) + */ + private String cognitoAuthenticationProvider; + /** + * (Required) + */ + private String cognitoAuthenticationType; + /** + * (Required) + */ + private String cognitoIdentityId; + /** + * (Required) + */ + private String cognitoIdentityPoolId; + /** + * (Required) + */ + private String sourceIp; + /** + * (Required) + */ + private String user; + /** + * (Required) + */ + private String userAgent; + /** + * (Required) + */ + private String userArn; + + /** + * (Required) + */ + public String getAccountId() { + return accountId; + } + + /** + * (Required) + */ + public APIGatewayRequestIdentity setAccountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * (Required) + */ + public String getApiKey() { + return apiKey; + } + + /** + * (Required) + */ + public APIGatewayRequestIdentity setApiKey(String apiKey) { + this.apiKey = apiKey; + return this; + } + + /** + * (Required) + */ + public String getCaller() { + return caller; + } + + /** + * (Required) + */ + public APIGatewayRequestIdentity setCaller(String caller) { + this.caller = caller; + return this; + } + + /** + * (Required) + */ + public String getCognitoAuthenticationProvider() { + return cognitoAuthenticationProvider; + } + + /** + * (Required) + */ + public APIGatewayRequestIdentity setCognitoAuthenticationProvider(String cognitoAuthenticationProvider) { + this.cognitoAuthenticationProvider = cognitoAuthenticationProvider; + return this; + } + + /** + * (Required) + */ + public String getCognitoAuthenticationType() { + return cognitoAuthenticationType; + } + + /** + * (Required) + */ + public APIGatewayRequestIdentity setCognitoAuthenticationType(String cognitoAuthenticationType) { + this.cognitoAuthenticationType = cognitoAuthenticationType; + return this; + } + + /** + * (Required) + */ + public String getCognitoIdentityId() { + return cognitoIdentityId; + } + + /** + * (Required) + */ + public APIGatewayRequestIdentity setCognitoIdentityId(String cognitoIdentityId) { + this.cognitoIdentityId = cognitoIdentityId; + return this; + } + + /** + * (Required) + */ + public String getCognitoIdentityPoolId() { + return cognitoIdentityPoolId; + } + + /** + * (Required) + */ + public APIGatewayRequestIdentity setCognitoIdentityPoolId(String cognitoIdentityPoolId) { + this.cognitoIdentityPoolId = cognitoIdentityPoolId; + return this; + } + + /** + * (Required) + */ + public String getSourceIp() { + return sourceIp; + } + + /** + * (Required) + */ + public APIGatewayRequestIdentity setSourceIp(String sourceIp) { + this.sourceIp = sourceIp; + return this; + } + + /** + * (Required) + */ + public String getUser() { + return user; + } + + /** + * (Required) + */ + public APIGatewayRequestIdentity setUser(String user) { + this.user = user; + return this; + } + + /** + * (Required) + */ + public String getUserAgent() { + return userAgent; + } + + /** + * (Required) + */ + public APIGatewayRequestIdentity setUserAgent(String userAgent) { + this.userAgent = userAgent; + return this; + } + + /** + * (Required) + */ + public String getUserArn() { + return userArn; + } + + /** + * (Required) + */ + public APIGatewayRequestIdentity setUserArn(String userArn) { + this.userArn = userArn; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/Attachment.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/Attachment.java new file mode 100644 index 0000000..b8a9d2a --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/Attachment.java @@ -0,0 +1,78 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class Attachment { + + public Attachment() {} + + public Attachment(JsonObject json) { + AttachmentConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + AttachmentConverter.toJson(this, json); + return json; + } + + private String attachmentLinkUrl; + private JsonArray buttons = new JsonArray(); + private String imageUrl; + private String subTitle; + private String title; + + public String getAttachmentLinkUrl() { + return attachmentLinkUrl; + } + + public Attachment setAttachmentLinkUrl(String attachmentLinkUrl) { + this.attachmentLinkUrl = attachmentLinkUrl; + return this; + } + + public JsonArray getButtons() { + return buttons; + } + + public Attachment setButtons(JsonArray buttons) { + this.buttons = buttons; + return this; + } + + public String getImageUrl() { + return imageUrl; + } + + public Attachment setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + return this; + } + + public String getSubTitle() { + return subTitle; + } + + public Attachment setSubTitle(String subTitle) { + this.subTitle = subTitle; + return this; + } + + public String getTitle() { + return title; + } + + public Attachment setTitle(String title) { + this.title = title; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/CloudWatchEvent.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/CloudWatchEvent.java new file mode 100644 index 0000000..235eb87 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/CloudWatchEvent.java @@ -0,0 +1,202 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@DataObject(generateConverter = true) +public class CloudWatchEvent { + + public CloudWatchEvent() {} + + public CloudWatchEvent(JsonObject json) { + CloudWatchEventConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + CloudWatchEventConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String account; + /** + * (Required) + */ + private List detail = new ArrayList(); + /** + * (Required) + */ + private String detailType; + /** + * (Required) + */ + private String id; + /** + * (Required) + */ + private String region; + /** + * (Required) + */ + private List resources = new ArrayList(); + /** + * (Required) + */ + private String source; + /** + * (Required) + */ + private Date time; + /** + * (Required) + */ + private String version; + + /** + * (Required) + */ + public String getAccount() { + return account; + } + + /** + * (Required) + */ + public CloudWatchEvent setAccount(String account) { + this.account = account; + return this; + } + + /** + * (Required) + */ + public List getDetail() { + return detail; + } + + /** + * (Required) + */ + public CloudWatchEvent setDetail(List detail) { + this.detail = detail; + return this; + } + + /** + * (Required) + */ + public String getDetailType() { + return detailType; + } + + /** + * (Required) + */ + public CloudWatchEvent setDetailType(String detailType) { + this.detailType = detailType; + return this; + } + + /** + * (Required) + */ + public String getId() { + return id; + } + + /** + * (Required) + */ + public CloudWatchEvent setId(String id) { + this.id = id; + return this; + } + + /** + * (Required) + */ + public String getRegion() { + return region; + } + + /** + * (Required) + */ + public CloudWatchEvent setRegion(String region) { + this.region = region; + return this; + } + + /** + * (Required) + */ + public List getResources() { + return resources; + } + + /** + * (Required) + */ + public CloudWatchEvent setResources(List resources) { + this.resources = resources; + return this; + } + + /** + * (Required) + */ + public String getSource() { + return source; + } + + /** + * (Required) + */ + public CloudWatchEvent setSource(String source) { + this.source = source; + return this; + } + + /** + * (Required) + */ + public Date getTime() { + return time; + } + + /** + * (Required) + */ + public CloudWatchEvent setTime(Date time) { + this.time = time; + return this; + } + + /** + * (Required) + */ + public String getVersion() { + return version; + } + + /** + * (Required) + */ + public CloudWatchEvent setVersion(String version) { + this.version = version; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/CloudwatchLogsEvent.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/CloudwatchLogsEvent.java new file mode 100644 index 0000000..a0f4e11 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/CloudwatchLogsEvent.java @@ -0,0 +1,46 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class CloudwatchLogsEvent { + + public CloudwatchLogsEvent() {} + + public CloudwatchLogsEvent(JsonObject json) { + CloudwatchLogsEventConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + CloudwatchLogsEventConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private CloudwatchLogsRawData awslogs; + + /** + * (Required) + */ + public CloudwatchLogsRawData getAwslogs() { + return awslogs; + } + + /** + * (Required) + */ + public CloudwatchLogsEvent setAwslogs(CloudwatchLogsRawData awslogs) { + this.awslogs = awslogs; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/CloudwatchLogsRawData.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/CloudwatchLogsRawData.java new file mode 100644 index 0000000..4ca0377 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/CloudwatchLogsRawData.java @@ -0,0 +1,46 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class CloudwatchLogsRawData { + + public CloudwatchLogsRawData() {} + + public CloudwatchLogsRawData(JsonObject json) { + CloudwatchLogsRawDataConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + CloudwatchLogsRawDataConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String data; + + /** + * (Required) + */ + public String getData() { + return data; + } + + /** + * (Required) + */ + public CloudwatchLogsRawData setData(String data) { + this.data = data; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/ConfigEvent.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/ConfigEvent.java new file mode 100644 index 0000000..fb7f5d9 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/ConfigEvent.java @@ -0,0 +1,217 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class ConfigEvent { + + public ConfigEvent() {} + + public ConfigEvent(JsonObject json) { + ConfigEventConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + ConfigEventConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String accountId; + /** + * (Required) + */ + private String configRuleArn; + /** + * (Required) + */ + private String configRuleId; + /** + * (Required) + */ + private String configRuleName; + /** + * (Required) + */ + private Boolean eventLeftScope; + /** + * (Required) + */ + private String executionRoleArn; + /** + * (Required) + */ + private String invokingEvent; + /** + * (Required) + */ + private String resultToken; + /** + * (Required) + */ + private String ruleParameters; + /** + * (Required) + */ + private String version; + + /** + * (Required) + */ + public String getAccountId() { + return accountId; + } + + /** + * (Required) + */ + public ConfigEvent setAccountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * (Required) + */ + public String getConfigRuleArn() { + return configRuleArn; + } + + /** + * (Required) + */ + public ConfigEvent setConfigRuleArn(String configRuleArn) { + this.configRuleArn = configRuleArn; + return this; + } + + /** + * (Required) + */ + public String getConfigRuleId() { + return configRuleId; + } + + /** + * (Required) + */ + public ConfigEvent setConfigRuleId(String configRuleId) { + this.configRuleId = configRuleId; + return this; + } + + /** + * (Required) + */ + public String getConfigRuleName() { + return configRuleName; + } + + /** + * (Required) + */ + public ConfigEvent setConfigRuleName(String configRuleName) { + this.configRuleName = configRuleName; + return this; + } + + /** + * (Required) + */ + public Boolean getEventLeftScope() { + return eventLeftScope; + } + + /** + * (Required) + */ + public ConfigEvent setEventLeftScope(Boolean eventLeftScope) { + this.eventLeftScope = eventLeftScope; + return this; + } + + /** + * (Required) + */ + public String getExecutionRoleArn() { + return executionRoleArn; + } + + /** + * (Required) + */ + public ConfigEvent setExecutionRoleArn(String executionRoleArn) { + this.executionRoleArn = executionRoleArn; + return this; + } + + /** + * (Required) + */ + public String getInvokingEvent() { + return invokingEvent; + } + + /** + * (Required) + */ + public ConfigEvent setInvokingEvent(String invokingEvent) { + this.invokingEvent = invokingEvent; + return this; + } + + /** + * (Required) + */ + public String getResultToken() { + return resultToken; + } + + /** + * (Required) + */ + public ConfigEvent setResultToken(String resultToken) { + this.resultToken = resultToken; + return this; + } + + /** + * (Required) + */ + public String getRuleParameters() { + return ruleParameters; + } + + /** + * (Required) + */ + public ConfigEvent setRuleParameters(String ruleParameters) { + this.ruleParameters = ruleParameters; + return this; + } + + /** + * (Required) + */ + public String getVersion() { + return version; + } + + /** + * (Required) + */ + public ConfigEvent setVersion(String version) { + this.version = version; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/IAMPolicyStatement.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/IAMPolicyStatement.java new file mode 100644 index 0000000..3601c0a --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/IAMPolicyStatement.java @@ -0,0 +1,87 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +@DataObject(generateConverter = true) +public class IAMPolicyStatement { + + public IAMPolicyStatement() {} + + public IAMPolicyStatement(JsonObject json) { + IAMPolicyStatementConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + IAMPolicyStatementConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private List action = new ArrayList(); + /** + * (Required) + */ + private String effect; + /** + * (Required) + */ + private List resource = new ArrayList(); + + /** + * (Required) + */ + public List getAction() { + return action; + } + + /** + * (Required) + */ + public IAMPolicyStatement setAction(List action) { + this.action = action; + return this; + } + + /** + * (Required) + */ + public String getEffect() { + return effect; + } + + /** + * (Required) + */ + public IAMPolicyStatement setEffect(String effect) { + this.effect = effect; + return this; + } + + /** + * (Required) + */ + public List getResource() { + return resource; + } + + /** + * (Required) + */ + public IAMPolicyStatement setResource(List resource) { + this.resource = resource; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/IoTButtonEvent.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/IoTButtonEvent.java new file mode 100644 index 0000000..621539a --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/IoTButtonEvent.java @@ -0,0 +1,85 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class IoTButtonEvent { + + public IoTButtonEvent() {} + + public IoTButtonEvent(JsonObject json) { + IoTButtonEventConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + IoTButtonEventConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String batteryVoltage; + /** + * (Required) + */ + private String clickType; + /** + * (Required) + */ + private String serialNumber; + + /** + * (Required) + */ + public String getBatteryVoltage() { + return batteryVoltage; + } + + /** + * (Required) + */ + public IoTButtonEvent setBatteryVoltage(String batteryVoltage) { + this.batteryVoltage = batteryVoltage; + return this; + } + + /** + * (Required) + */ + public String getClickType() { + return clickType; + } + + /** + * (Required) + */ + public IoTButtonEvent setClickType(String clickType) { + this.clickType = clickType; + return this; + } + + /** + * (Required) + */ + public String getSerialNumber() { + return serialNumber; + } + + /** + * (Required) + */ + public IoTButtonEvent setSerialNumber(String serialNumber) { + this.serialNumber = serialNumber; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisEvent.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisEvent.java new file mode 100644 index 0000000..5adee92 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisEvent.java @@ -0,0 +1,49 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +@DataObject(generateConverter = true) +public class KinesisEvent { + + public KinesisEvent() {} + + public KinesisEvent(JsonObject json) { + KinesisEventConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + KinesisEventConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private List records = new ArrayList(); + + /** + * (Required) + */ + public List getRecords() { + return records; + } + + /** + * (Required) + */ + public KinesisEvent setRecords(List records) { + this.records = records; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisEventRecord.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisEventRecord.java new file mode 100644 index 0000000..cd16d54 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisEventRecord.java @@ -0,0 +1,180 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class KinesisEventRecord { + + public KinesisEventRecord() {} + + public KinesisEventRecord(JsonObject json) { + KinesisEventRecordConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + KinesisEventRecordConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String awsRegion; + /** + * (Required) + */ + private String eventID; + /** + * (Required) + */ + private String eventName; + /** + * (Required) + */ + private String eventSource; + /** + * (Required) + */ + private String eventSourceARN; + /** + * (Required) + */ + private String eventVersion; + /** + * (Required) + */ + private String invokeIdentityArn; + /** + * (Required) + */ + private KinesisRecord kinesis; + + /** + * (Required) + */ + public String getAwsRegion() { + return awsRegion; + } + + /** + * (Required) + */ + public KinesisEventRecord setAwsRegion(String awsRegion) { + this.awsRegion = awsRegion; + return this; + } + + /** + * (Required) + */ + public String getEventID() { + return eventID; + } + + /** + * (Required) + */ + public KinesisEventRecord setEventID(String eventID) { + this.eventID = eventID; + return this; + } + + /** + * (Required) + */ + public String getEventName() { + return eventName; + } + + /** + * (Required) + */ + public KinesisEventRecord setEventName(String eventName) { + this.eventName = eventName; + return this; + } + + /** + * (Required) + */ + public String getEventSource() { + return eventSource; + } + + /** + * (Required) + */ + public KinesisEventRecord setEventSource(String eventSource) { + this.eventSource = eventSource; + return this; + } + + /** + * (Required) + */ + public String getEventSourceARN() { + return eventSourceARN; + } + + /** + * (Required) + */ + public KinesisEventRecord setEventSourceARN(String eventSourceARN) { + this.eventSourceARN = eventSourceARN; + return this; + } + + /** + * (Required) + */ + public String getEventVersion() { + return eventVersion; + } + + /** + * (Required) + */ + public KinesisEventRecord setEventVersion(String eventVersion) { + this.eventVersion = eventVersion; + return this; + } + + /** + * (Required) + */ + public String getInvokeIdentityArn() { + return invokeIdentityArn; + } + + /** + * (Required) + */ + public KinesisEventRecord setInvokeIdentityArn(String invokeIdentityArn) { + this.invokeIdentityArn = invokeIdentityArn; + return this; + } + + /** + * (Required) + */ + public KinesisRecord getKinesis() { + return kinesis; + } + + /** + * (Required) + */ + public KinesisEventRecord setKinesis(KinesisRecord kinesis) { + this.kinesis = kinesis; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisFirehoseEvent.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisFirehoseEvent.java new file mode 100644 index 0000000..779864f --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisFirehoseEvent.java @@ -0,0 +1,106 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +@DataObject(generateConverter = true) +public class KinesisFirehoseEvent { + + public KinesisFirehoseEvent() {} + + public KinesisFirehoseEvent(JsonObject json) { + KinesisFirehoseEventConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + KinesisFirehoseEventConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String deliveryStreamArn; + /** + * (Required) + */ + private String invocationId; + /** + * (Required) + */ + private List records = new ArrayList(); + /** + * (Required) + */ + private String region; + + /** + * (Required) + */ + public String getDeliveryStreamArn() { + return deliveryStreamArn; + } + + /** + * (Required) + */ + public KinesisFirehoseEvent setDeliveryStreamArn(String deliveryStreamArn) { + this.deliveryStreamArn = deliveryStreamArn; + return this; + } + + /** + * (Required) + */ + public String getInvocationId() { + return invocationId; + } + + /** + * (Required) + */ + public KinesisFirehoseEvent setInvocationId(String invocationId) { + this.invocationId = invocationId; + return this; + } + + /** + * (Required) + */ + public List getRecords() { + return records; + } + + /** + * (Required) + */ + public KinesisFirehoseEvent setRecords(List records) { + this.records = records; + return this; + } + + /** + * (Required) + */ + public String getRegion() { + return region; + } + + /** + * (Required) + */ + public KinesisFirehoseEvent setRegion(String region) { + this.region = region; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisFirehoseEventRecord.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisFirehoseEventRecord.java new file mode 100644 index 0000000..24f1587 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisFirehoseEventRecord.java @@ -0,0 +1,85 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class KinesisFirehoseEventRecord { + + public KinesisFirehoseEventRecord() {} + + public KinesisFirehoseEventRecord(JsonObject json) { + KinesisFirehoseEventRecordConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + KinesisFirehoseEventRecordConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private MilliSecondsEpochTime approximateArrivalTimestamp; + /** + * (Required) + */ + private Buffer data; + /** + * (Required) + */ + private String recordId; + + /** + * (Required) + */ + public MilliSecondsEpochTime getApproximateArrivalTimestamp() { + return approximateArrivalTimestamp; + } + + /** + * (Required) + */ + public KinesisFirehoseEventRecord setApproximateArrivalTimestamp(MilliSecondsEpochTime approximateArrivalTimestamp) { + this.approximateArrivalTimestamp = approximateArrivalTimestamp; + return this; + } + + /** + * (Required) + */ + public Buffer getData() { + return data; + } + + /** + * (Required) + */ + public KinesisFirehoseEventRecord setData(Buffer data) { + this.data = data; + return this; + } + + /** + * (Required) + */ + public String getRecordId() { + return recordId; + } + + /** + * (Required) + */ + public KinesisFirehoseEventRecord setRecordId(String recordId) { + this.recordId = recordId; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisRecord.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisRecord.java new file mode 100644 index 0000000..3f56298 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/KinesisRecord.java @@ -0,0 +1,133 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class KinesisRecord { + + public KinesisRecord() {} + + public KinesisRecord(JsonObject json) { + KinesisRecordConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + KinesisRecordConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private SecondsEpochTime approximateArrivalTimestamp; + /** + * (Required) + */ + private Buffer data; + private String encryptionType; + /** + * (Required) + */ + private String kinesisSchemaVersion; + /** + * (Required) + */ + private String partitionKey; + /** + * (Required) + */ + private String sequenceNumber; + + /** + * (Required) + */ + public SecondsEpochTime getApproximateArrivalTimestamp() { + return approximateArrivalTimestamp; + } + + /** + * (Required) + */ + public KinesisRecord setApproximateArrivalTimestamp(SecondsEpochTime approximateArrivalTimestamp) { + this.approximateArrivalTimestamp = approximateArrivalTimestamp; + return this; + } + + /** + * (Required) + */ + public Buffer getData() { + return data; + } + + /** + * (Required) + */ + public KinesisRecord setData(Buffer data) { + this.data = data; + return this; + } + + public String getEncryptionType() { + return encryptionType; + } + + public KinesisRecord setEncryptionType(String encryptionType) { + this.encryptionType = encryptionType; + return this; + } + + /** + * (Required) + */ + public String getKinesisSchemaVersion() { + return kinesisSchemaVersion; + } + + /** + * (Required) + */ + public KinesisRecord setKinesisSchemaVersion(String kinesisSchemaVersion) { + this.kinesisSchemaVersion = kinesisSchemaVersion; + return this; + } + + /** + * (Required) + */ + public String getPartitionKey() { + return partitionKey; + } + + /** + * (Required) + */ + public KinesisRecord setPartitionKey(String partitionKey) { + this.partitionKey = partitionKey; + return this; + } + + /** + * (Required) + */ + public String getSequenceNumber() { + return sequenceNumber; + } + + /** + * (Required) + */ + public KinesisRecord setSequenceNumber(String sequenceNumber) { + this.sequenceNumber = sequenceNumber; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexBot.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexBot.java new file mode 100644 index 0000000..86d265a --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexBot.java @@ -0,0 +1,58 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class LexBot { + + public LexBot() {} + + public LexBot(JsonObject json) { + LexBotConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + LexBotConverter.toJson(this, json); + return json; + } + + private String alias; + private String name; + private String version; + + public String getAlias() { + return alias; + } + + public LexBot setAlias(String alias) { + this.alias = alias; + return this; + } + + public String getName() { + return name; + } + + public LexBot setName(String name) { + this.name = name; + return this; + } + + public String getVersion() { + return version; + } + + public LexBot setVersion(String version) { + this.version = version; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexCurrentIntent.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexCurrentIntent.java new file mode 100644 index 0000000..69b15ed --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexCurrentIntent.java @@ -0,0 +1,68 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class LexCurrentIntent { + + public LexCurrentIntent() {} + + public LexCurrentIntent(JsonObject json) { + LexCurrentIntentConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + LexCurrentIntentConverter.toJson(this, json); + return json; + } + + private String confirmationStatus; + private String name; + private JsonObject slotDetails; + private JsonObject slots; + + public String getConfirmationStatus() { + return confirmationStatus; + } + + public LexCurrentIntent setConfirmationStatus(String confirmationStatus) { + this.confirmationStatus = confirmationStatus; + return this; + } + + public String getName() { + return name; + } + + public LexCurrentIntent setName(String name) { + this.name = name; + return this; + } + + public JsonObject getSlotDetails() { + return slotDetails; + } + + public LexCurrentIntent setSlotDetails(JsonObject slotDetails) { + this.slotDetails = slotDetails; + return this; + } + + public JsonObject getSlots() { + return slots; + } + + public LexCurrentIntent setSlots(JsonObject slots) { + this.slots = slots; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexDialogAction.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexDialogAction.java new file mode 100644 index 0000000..6a3c81f --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexDialogAction.java @@ -0,0 +1,98 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class LexDialogAction { + + public LexDialogAction() {} + + public LexDialogAction(JsonObject json) { + LexDialogActionConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + LexDialogActionConverter.toJson(this, json); + return json; + } + + private String fulfillmentState; + private String intentName; + private JsonObject message; + private LexResponseCard responseCard; + private String slotToElicit; + private JsonObject slots; + private String type; + + public String getFulfillmentState() { + return fulfillmentState; + } + + public LexDialogAction setFulfillmentState(String fulfillmentState) { + this.fulfillmentState = fulfillmentState; + return this; + } + + public String getIntentName() { + return intentName; + } + + public LexDialogAction setIntentName(String intentName) { + this.intentName = intentName; + return this; + } + + public JsonObject getMessage() { + return message; + } + + public LexDialogAction setMessage(JsonObject message) { + this.message = message; + return this; + } + + public LexResponseCard getResponseCard() { + return responseCard; + } + + public LexDialogAction setResponseCard(LexResponseCard responseCard) { + this.responseCard = responseCard; + return this; + } + + public String getSlotToElicit() { + return slotToElicit; + } + + public LexDialogAction setSlotToElicit(String slotToElicit) { + this.slotToElicit = slotToElicit; + return this; + } + + public JsonObject getSlots() { + return slots; + } + + public LexDialogAction setSlots(JsonObject slots) { + this.slots = slots; + return this; + } + + public String getType() { + return type; + } + + public LexDialogAction setType(String type) { + this.type = type; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexEvent.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexEvent.java new file mode 100644 index 0000000..871b8dc --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexEvent.java @@ -0,0 +1,128 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class LexEvent { + + public LexEvent() {} + + public LexEvent(JsonObject json) { + LexEventConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + LexEventConverter.toJson(this, json); + return json; + } + + private LexBot bot; + private LexCurrentIntent currentIntent; + private LexDialogAction dialogAction; + private String inputTranscript; + private String invocationSource; + private String messageVersion; + private String outputDialogMode; + private JsonObject requestAttributes; + private JsonObject sessionAttributes; + private String userId; + + public LexBot getBot() { + return bot; + } + + public LexEvent setBot(LexBot bot) { + this.bot = bot; + return this; + } + + public LexCurrentIntent getCurrentIntent() { + return currentIntent; + } + + public LexEvent setCurrentIntent(LexCurrentIntent currentIntent) { + this.currentIntent = currentIntent; + return this; + } + + public LexDialogAction getDialogAction() { + return dialogAction; + } + + public LexEvent setDialogAction(LexDialogAction dialogAction) { + this.dialogAction = dialogAction; + return this; + } + + public String getInputTranscript() { + return inputTranscript; + } + + public LexEvent setInputTranscript(String inputTranscript) { + this.inputTranscript = inputTranscript; + return this; + } + + public String getInvocationSource() { + return invocationSource; + } + + public LexEvent setInvocationSource(String invocationSource) { + this.invocationSource = invocationSource; + return this; + } + + public String getMessageVersion() { + return messageVersion; + } + + public LexEvent setMessageVersion(String messageVersion) { + this.messageVersion = messageVersion; + return this; + } + + public String getOutputDialogMode() { + return outputDialogMode; + } + + public LexEvent setOutputDialogMode(String outputDialogMode) { + this.outputDialogMode = outputDialogMode; + return this; + } + + public JsonObject getRequestAttributes() { + return requestAttributes; + } + + public LexEvent setRequestAttributes(JsonObject requestAttributes) { + this.requestAttributes = requestAttributes; + return this; + } + + public JsonObject getSessionAttributes() { + return sessionAttributes; + } + + public LexEvent setSessionAttributes(JsonObject sessionAttributes) { + this.sessionAttributes = sessionAttributes; + return this; + } + + public String getUserId() { + return userId; + } + + public LexEvent setUserId(String userId) { + this.userId = userId; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexResponseCard.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexResponseCard.java new file mode 100644 index 0000000..2b41831 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/LexResponseCard.java @@ -0,0 +1,60 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +@DataObject(generateConverter = true) +public class LexResponseCard { + + public LexResponseCard() {} + + public LexResponseCard(JsonObject json) { + LexResponseCardConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + LexResponseCardConverter.toJson(this, json); + return json; + } + + private String contentType; + private List genericAttachments = new ArrayList(); + private Integer version; + + public String getContentType() { + return contentType; + } + + public LexResponseCard setContentType(String contentType) { + this.contentType = contentType; + return this; + } + + public List getGenericAttachments() { + return genericAttachments; + } + + public LexResponseCard setGenericAttachments(List genericAttachments) { + this.genericAttachments = genericAttachments; + return this; + } + + public Integer getVersion() { + return version; + } + + public LexResponseCard setVersion(Integer version) { + this.version = version; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/MilliSecondsEpochTime.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/MilliSecondsEpochTime.java new file mode 100644 index 0000000..294807d --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/MilliSecondsEpochTime.java @@ -0,0 +1,27 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class MilliSecondsEpochTime { + + public MilliSecondsEpochTime() {} + + public MilliSecondsEpochTime(JsonObject json) { + MilliSecondsEpochTimeConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + MilliSecondsEpochTimeConverter.toJson(this, json); + return json; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3Bucket.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3Bucket.java new file mode 100644 index 0000000..c102d78 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3Bucket.java @@ -0,0 +1,85 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class S3Bucket { + + public S3Bucket() {} + + public S3Bucket(JsonObject json) { + S3BucketConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + S3BucketConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String arn; + /** + * (Required) + */ + private String name; + /** + * (Required) + */ + private S3UserIdentity ownerIdentity; + + /** + * (Required) + */ + public String getArn() { + return arn; + } + + /** + * (Required) + */ + public S3Bucket setArn(String arn) { + this.arn = arn; + return this; + } + + /** + * (Required) + */ + public String getName() { + return name; + } + + /** + * (Required) + */ + public S3Bucket setName(String name) { + this.name = name; + return this; + } + + /** + * (Required) + */ + public S3UserIdentity getOwnerIdentity() { + return ownerIdentity; + } + + /** + * (Required) + */ + public S3Bucket setOwnerIdentity(S3UserIdentity ownerIdentity) { + this.ownerIdentity = ownerIdentity; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3Entity.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3Entity.java new file mode 100644 index 0000000..1eb8b9b --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3Entity.java @@ -0,0 +1,104 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class S3Entity { + + public S3Entity() {} + + public S3Entity(JsonObject json) { + S3EntityConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + S3EntityConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private S3Bucket bucket; + /** + * (Required) + */ + private String configurationId; + /** + * (Required) + */ + private S3Object object; + /** + * (Required) + */ + private String s3SchemaVersion; + + /** + * (Required) + */ + public S3Bucket getBucket() { + return bucket; + } + + /** + * (Required) + */ + public S3Entity setBucket(S3Bucket bucket) { + this.bucket = bucket; + return this; + } + + /** + * (Required) + */ + public String getConfigurationId() { + return configurationId; + } + + /** + * (Required) + */ + public S3Entity setConfigurationId(String configurationId) { + this.configurationId = configurationId; + return this; + } + + /** + * (Required) + */ + public S3Object getObject() { + return object; + } + + /** + * (Required) + */ + public S3Entity setObject(S3Object object) { + this.object = object; + return this; + } + + /** + * (Required) + */ + public String getS3SchemaVersion() { + return s3SchemaVersion; + } + + /** + * (Required) + */ + public S3Entity setS3SchemaVersion(String s3SchemaVersion) { + this.s3SchemaVersion = s3SchemaVersion; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3Event.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3Event.java new file mode 100644 index 0000000..7000e80 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3Event.java @@ -0,0 +1,49 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +@DataObject(generateConverter = true) +public class S3Event { + + public S3Event() {} + + public S3Event(JsonObject json) { + S3EventConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + S3EventConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private List records = new ArrayList(); + + /** + * (Required) + */ + public List getRecords() { + return records; + } + + /** + * (Required) + */ + public S3Event setRecords(List records) { + this.records = records; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3EventRecord.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3EventRecord.java new file mode 100644 index 0000000..f80b253 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3EventRecord.java @@ -0,0 +1,200 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.Date; + +@DataObject(generateConverter = true) +public class S3EventRecord { + + public S3EventRecord() {} + + public S3EventRecord(JsonObject json) { + S3EventRecordConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + S3EventRecordConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String awsRegion; + /** + * (Required) + */ + private String eventName; + /** + * (Required) + */ + private String eventSource; + /** + * (Required) + */ + private Date eventTime; + /** + * (Required) + */ + private String eventVersion; + /** + * (Required) + */ + private S3RequestParameters requestParameters; + /** + * (Required) + */ + private JsonObject responseElements; + /** + * (Required) + */ + private S3Entity s3; + /** + * (Required) + */ + private S3UserIdentity userIdentity; + + /** + * (Required) + */ + public String getAwsRegion() { + return awsRegion; + } + + /** + * (Required) + */ + public S3EventRecord setAwsRegion(String awsRegion) { + this.awsRegion = awsRegion; + return this; + } + + /** + * (Required) + */ + public String getEventName() { + return eventName; + } + + /** + * (Required) + */ + public S3EventRecord setEventName(String eventName) { + this.eventName = eventName; + return this; + } + + /** + * (Required) + */ + public String getEventSource() { + return eventSource; + } + + /** + * (Required) + */ + public S3EventRecord setEventSource(String eventSource) { + this.eventSource = eventSource; + return this; + } + + /** + * (Required) + */ + public Date getEventTime() { + return eventTime; + } + + /** + * (Required) + */ + public S3EventRecord setEventTime(Date eventTime) { + this.eventTime = eventTime; + return this; + } + + /** + * (Required) + */ + public String getEventVersion() { + return eventVersion; + } + + /** + * (Required) + */ + public S3EventRecord setEventVersion(String eventVersion) { + this.eventVersion = eventVersion; + return this; + } + + /** + * (Required) + */ + public S3RequestParameters getRequestParameters() { + return requestParameters; + } + + /** + * (Required) + */ + public S3EventRecord setRequestParameters(S3RequestParameters requestParameters) { + this.requestParameters = requestParameters; + return this; + } + + /** + * (Required) + */ + public JsonObject getResponseElements() { + return responseElements; + } + + /** + * (Required) + */ + public S3EventRecord setResponseElements(JsonObject responseElements) { + this.responseElements = responseElements; + return this; + } + + /** + * (Required) + */ + public S3Entity getS3() { + return s3; + } + + /** + * (Required) + */ + public S3EventRecord setS3(S3Entity s3) { + this.s3 = s3; + return this; + } + + /** + * (Required) + */ + public S3UserIdentity getUserIdentity() { + return userIdentity; + } + + /** + * (Required) + */ + public S3EventRecord setUserIdentity(S3UserIdentity userIdentity) { + this.userIdentity = userIdentity; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3Object.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3Object.java new file mode 100644 index 0000000..2c89e75 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3Object.java @@ -0,0 +1,142 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class S3Object { + + public S3Object() {} + + public S3Object(JsonObject json) { + S3ObjectConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + S3ObjectConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String eTag; + /** + * (Required) + */ + private String key; + /** + * (Required) + */ + private String sequencer; + /** + * (Required) + */ + private Integer size; + /** + * (Required) + */ + private String urlDecodedKey; + /** + * (Required) + */ + private String versionId; + + /** + * (Required) + */ + public String geteTag() { + return eTag; + } + + /** + * (Required) + */ + public S3Object seteTag(String eTag) { + this.eTag = eTag; + return this; + } + + /** + * (Required) + */ + public String getKey() { + return key; + } + + /** + * (Required) + */ + public S3Object setKey(String key) { + this.key = key; + return this; + } + + /** + * (Required) + */ + public String getSequencer() { + return sequencer; + } + + /** + * (Required) + */ + public S3Object setSequencer(String sequencer) { + this.sequencer = sequencer; + return this; + } + + /** + * (Required) + */ + public Integer getSize() { + return size; + } + + /** + * (Required) + */ + public S3Object setSize(Integer size) { + this.size = size; + return this; + } + + /** + * (Required) + */ + public String getUrlDecodedKey() { + return urlDecodedKey; + } + + /** + * (Required) + */ + public S3Object setUrlDecodedKey(String urlDecodedKey) { + this.urlDecodedKey = urlDecodedKey; + return this; + } + + /** + * (Required) + */ + public String getVersionId() { + return versionId; + } + + /** + * (Required) + */ + public S3Object setVersionId(String versionId) { + this.versionId = versionId; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3RequestParameters.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3RequestParameters.java new file mode 100644 index 0000000..a61d999 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3RequestParameters.java @@ -0,0 +1,47 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class S3RequestParameters { + + public S3RequestParameters() {} + + public S3RequestParameters(JsonObject json) { + S3RequestParametersConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + S3RequestParametersConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String sourceIPAddress; + + /** + * (Required) + */ + public String getSourceIPAddress() { + return sourceIPAddress; + } + + /** + * (Required) + */ + public S3RequestParameters setSourceIPAddress(String sourceIPAddress) { + this.sourceIPAddress = sourceIPAddress; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3UserIdentity.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3UserIdentity.java new file mode 100644 index 0000000..a08ede5 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/S3UserIdentity.java @@ -0,0 +1,47 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class S3UserIdentity { + + public S3UserIdentity() {} + + public S3UserIdentity(JsonObject json) { + S3UserIdentityConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + S3UserIdentityConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String principalId; + + /** + * (Required) + */ + public String getPrincipalId() { + return principalId; + } + + /** + * (Required) + */ + public S3UserIdentity setPrincipalId(String principalId) { + this.principalId = principalId; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SNSEntity.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SNSEntity.java new file mode 100644 index 0000000..52b6e17 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SNSEntity.java @@ -0,0 +1,238 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.Date; + +@DataObject(generateConverter = true) +public class SNSEntity { + + public SNSEntity() {} + + public SNSEntity(JsonObject json) { + SNSEntityConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SNSEntityConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String message; + /** + * (Required) + */ + private JsonObject messageAttributes; + /** + * (Required) + */ + private String messageId; + /** + * (Required) + */ + private String signature; + /** + * (Required) + */ + private String signatureVersion; + /** + * (Required) + */ + private String signingCertUrl; + /** + * (Required) + */ + private String subject; + /** + * (Required) + */ + private Date timestamp; + /** + * (Required) + */ + private String topicArn; + /** + * (Required) + */ + private String type; + /** + * (Required) + */ + private String unsubscribeUrl; + + /** + * (Required) + */ + public String getMessage() { + return message; + } + + /** + * (Required) + */ + public SNSEntity setMessage(String message) { + this.message = message; + return this; + } + + /** + * (Required) + */ + public JsonObject getMessageAttributes() { + return messageAttributes; + } + + /** + * (Required) + */ + public SNSEntity setMessageAttributes(JsonObject messageAttributes) { + this.messageAttributes = messageAttributes; + return this; + } + + /** + * (Required) + */ + public String getMessageId() { + return messageId; + } + + /** + * (Required) + */ + public SNSEntity setMessageId(String messageId) { + this.messageId = messageId; + return this; + } + + /** + * (Required) + */ + public String getSignature() { + return signature; + } + + /** + * (Required) + */ + public SNSEntity setSignature(String signature) { + this.signature = signature; + return this; + } + + /** + * (Required) + */ + public String getSignatureVersion() { + return signatureVersion; + } + + /** + * (Required) + */ + public SNSEntity setSignatureVersion(String signatureVersion) { + this.signatureVersion = signatureVersion; + return this; + } + + /** + * (Required) + */ + public String getSigningCertUrl() { + return signingCertUrl; + } + + /** + * (Required) + */ + public SNSEntity setSigningCertUrl(String signingCertUrl) { + this.signingCertUrl = signingCertUrl; + return this; + } + + /** + * (Required) + */ + public String getSubject() { + return subject; + } + + /** + * (Required) + */ + public SNSEntity setSubject(String subject) { + this.subject = subject; + return this; + } + + /** + * (Required) + */ + public Date getTimestamp() { + return timestamp; + } + + /** + * (Required) + */ + public SNSEntity setTimestamp(Date timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * (Required) + */ + public String getTopicArn() { + return topicArn; + } + + /** + * (Required) + */ + public SNSEntity setTopicArn(String topicArn) { + this.topicArn = topicArn; + return this; + } + + /** + * (Required) + */ + public String getType() { + return type; + } + + /** + * (Required) + */ + public SNSEntity setType(String type) { + this.type = type; + return this; + } + + /** + * (Required) + */ + public String getUnsubscribeUrl() { + return unsubscribeUrl; + } + + /** + * (Required) + */ + public SNSEntity setUnsubscribeUrl(String unsubscribeUrl) { + this.unsubscribeUrl = unsubscribeUrl; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SNSEvent.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SNSEvent.java new file mode 100644 index 0000000..309eb3f --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SNSEvent.java @@ -0,0 +1,49 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +@DataObject(generateConverter = true) +public class SNSEvent { + + public SNSEvent() {} + + public SNSEvent(JsonObject json) { + SNSEventConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SNSEventConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private List records = new ArrayList(); + + /** + * (Required) + */ + public List getRecords() { + return records; + } + + /** + * (Required) + */ + public SNSEvent setRecords(List records) { + this.records = records; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SNSEventRecord.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SNSEventRecord.java new file mode 100644 index 0000000..91726ec --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SNSEventRecord.java @@ -0,0 +1,104 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class SNSEventRecord { + + public SNSEventRecord() {} + + public SNSEventRecord(JsonObject json) { + SNSEventRecordConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SNSEventRecordConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String eventSource; + /** + * (Required) + */ + private String eventSubscriptionArn; + /** + * (Required) + */ + private String eventVersion; + /** + * (Required) + */ + private SNSEntity sns; + + /** + * (Required) + */ + public String getEventSource() { + return eventSource; + } + + /** + * (Required) + */ + public SNSEventRecord setEventSource(String eventSource) { + this.eventSource = eventSource; + return this; + } + + /** + * (Required) + */ + public String getEventSubscriptionArn() { + return eventSubscriptionArn; + } + + /** + * (Required) + */ + public SNSEventRecord setEventSubscriptionArn(String eventSubscriptionArn) { + this.eventSubscriptionArn = eventSubscriptionArn; + return this; + } + + /** + * (Required) + */ + public String getEventVersion() { + return eventVersion; + } + + /** + * (Required) + */ + public SNSEventRecord setEventVersion(String eventVersion) { + this.eventVersion = eventVersion; + return this; + } + + /** + * (Required) + */ + public SNSEntity getSns() { + return sns; + } + + /** + * (Required) + */ + public SNSEventRecord setSns(SNSEntity sns) { + this.sns = sns; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SQSEvent.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SQSEvent.java new file mode 100644 index 0000000..48578ac --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SQSEvent.java @@ -0,0 +1,49 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +@DataObject(generateConverter = true) +public class SQSEvent { + + public SQSEvent() {} + + public SQSEvent(JsonObject json) { + SQSEventConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SQSEventConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private List records = new ArrayList(); + + /** + * (Required) + */ + public List getRecords() { + return records; + } + + /** + * (Required) + */ + public SQSEvent setRecords(List records) { + this.records = records; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SQSMessage.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SQSMessage.java new file mode 100644 index 0000000..e70c833 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SQSMessage.java @@ -0,0 +1,218 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class SQSMessage { + + public SQSMessage() {} + + public SQSMessage(JsonObject json) { + SQSMessageConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SQSMessageConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private JsonObject attributes; + /** + * (Required) + */ + private String awsRegion; + /** + * (Required) + */ + private String body; + /** + * (Required) + */ + private String eventSource; + /** + * (Required) + */ + private String eventSourceARN; + /** + * (Required) + */ + private String md5OfBody; + /** + * (Required) + */ + private String md5OfMessageAttributes; + /** + * (Required) + */ + private JsonObject messageAttributes; + /** + * (Required) + */ + private String messageId; + /** + * (Required) + */ + private String receiptHandle; + + /** + * (Required) + */ + public JsonObject getAttributes() { + return attributes; + } + + /** + * (Required) + */ + public SQSMessage setAttributes(JsonObject attributes) { + this.attributes = attributes; + return this; + } + + /** + * (Required) + */ + public String getAwsRegion() { + return awsRegion; + } + + /** + * (Required) + */ + public SQSMessage setAwsRegion(String awsRegion) { + this.awsRegion = awsRegion; + return this; + } + + /** + * (Required) + */ + public String getBody() { + return body; + } + + /** + * (Required) + */ + public SQSMessage setBody(String body) { + this.body = body; + return this; + } + + /** + * (Required) + */ + public String getEventSource() { + return eventSource; + } + + /** + * (Required) + */ + public SQSMessage setEventSource(String eventSource) { + this.eventSource = eventSource; + return this; + } + + /** + * (Required) + */ + public String getEventSourceARN() { + return eventSourceARN; + } + + /** + * (Required) + */ + public SQSMessage setEventSourceARN(String eventSourceARN) { + this.eventSourceARN = eventSourceARN; + return this; + } + + /** + * (Required) + */ + public String getMd5OfBody() { + return md5OfBody; + } + + /** + * (Required) + */ + public SQSMessage setMd5OfBody(String md5OfBody) { + this.md5OfBody = md5OfBody; + return this; + } + + /** + * (Required) + */ + public String getMd5OfMessageAttributes() { + return md5OfMessageAttributes; + } + + /** + * (Required) + */ + public SQSMessage setMd5OfMessageAttributes(String md5OfMessageAttributes) { + this.md5OfMessageAttributes = md5OfMessageAttributes; + return this; + } + + /** + * (Required) + */ + public JsonObject getMessageAttributes() { + return messageAttributes; + } + + /** + * (Required) + */ + public SQSMessage setMessageAttributes(JsonObject messageAttributes) { + this.messageAttributes = messageAttributes; + return this; + } + + /** + * (Required) + */ + public String getMessageId() { + return messageId; + } + + /** + * (Required) + */ + public SQSMessage setMessageId(String messageId) { + this.messageId = messageId; + return this; + } + + /** + * (Required) + */ + public String getReceiptHandle() { + return receiptHandle; + } + + /** + * (Required) + */ + public SQSMessage setReceiptHandle(String receiptHandle) { + this.receiptHandle = receiptHandle; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SecondsEpochTime.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SecondsEpochTime.java new file mode 100644 index 0000000..cf9cc73 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SecondsEpochTime.java @@ -0,0 +1,27 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class SecondsEpochTime { + + public SecondsEpochTime() {} + + public SecondsEpochTime(JsonObject json) { + SecondsEpochTimeConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SecondsEpochTimeConverter.toJson(this, json); + return json; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailCommonHeaders.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailCommonHeaders.java new file mode 100644 index 0000000..80a2689 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailCommonHeaders.java @@ -0,0 +1,144 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +@DataObject(generateConverter = true) +public class SimpleEmailCommonHeaders { + + public SimpleEmailCommonHeaders() {} + + public SimpleEmailCommonHeaders(JsonObject json) { + SimpleEmailCommonHeadersConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SimpleEmailCommonHeadersConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String date; + /** + * (Required) + */ + private List from = new ArrayList(); + /** + * (Required) + */ + private String messageId; + /** + * (Required) + */ + private String returnPath; + /** + * (Required) + */ + private String subject; + /** + * (Required) + */ + private List to = new ArrayList(); + + /** + * (Required) + */ + public String getDate() { + return date; + } + + /** + * (Required) + */ + public SimpleEmailCommonHeaders setDate(String date) { + this.date = date; + return this; + } + + /** + * (Required) + */ + public List getFrom() { + return from; + } + + /** + * (Required) + */ + public SimpleEmailCommonHeaders setFrom(List from) { + this.from = from; + return this; + } + + /** + * (Required) + */ + public String getMessageId() { + return messageId; + } + + /** + * (Required) + */ + public SimpleEmailCommonHeaders setMessageId(String messageId) { + this.messageId = messageId; + return this; + } + + /** + * (Required) + */ + public String getReturnPath() { + return returnPath; + } + + /** + * (Required) + */ + public SimpleEmailCommonHeaders setReturnPath(String returnPath) { + this.returnPath = returnPath; + return this; + } + + /** + * (Required) + */ + public String getSubject() { + return subject; + } + + /** + * (Required) + */ + public SimpleEmailCommonHeaders setSubject(String subject) { + this.subject = subject; + return this; + } + + /** + * (Required) + */ + public List getTo() { + return to; + } + + /** + * (Required) + */ + public SimpleEmailCommonHeaders setTo(List to) { + this.to = to; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailEvent.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailEvent.java new file mode 100644 index 0000000..d7dc1e7 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailEvent.java @@ -0,0 +1,49 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +@DataObject(generateConverter = true) +public class SimpleEmailEvent { + + public SimpleEmailEvent() {} + + public SimpleEmailEvent(JsonObject json) { + SimpleEmailEventConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SimpleEmailEventConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private List records = new ArrayList(); + + /** + * (Required) + */ + public List getRecords() { + return records; + } + + /** + * (Required) + */ + public SimpleEmailEvent setRecords(List records) { + this.records = records; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailHeader.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailHeader.java new file mode 100644 index 0000000..e2b9954 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailHeader.java @@ -0,0 +1,66 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class SimpleEmailHeader { + + public SimpleEmailHeader() {} + + public SimpleEmailHeader(JsonObject json) { + SimpleEmailHeaderConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SimpleEmailHeaderConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String name; + /** + * (Required) + */ + private String value; + + /** + * (Required) + */ + public String getName() { + return name; + } + + /** + * (Required) + */ + public SimpleEmailHeader setName(String name) { + this.name = name; + return this; + } + + /** + * (Required) + */ + public String getValue() { + return value; + } + + /** + * (Required) + */ + public SimpleEmailHeader setValue(String value) { + this.value = value; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailMessage.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailMessage.java new file mode 100644 index 0000000..3acd312 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailMessage.java @@ -0,0 +1,164 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@DataObject(generateConverter = true) +public class SimpleEmailMessage { + + public SimpleEmailMessage() {} + + public SimpleEmailMessage(JsonObject json) { + SimpleEmailMessageConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SimpleEmailMessageConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private SimpleEmailCommonHeaders commonHeaders; + /** + * (Required) + */ + private List destination = new ArrayList(); + /** + * (Required) + */ + private List headers = new ArrayList(); + /** + * (Required) + */ + private Boolean headersTruncated; + /** + * (Required) + */ + private String messageId; + /** + * (Required) + */ + private String source; + /** + * (Required) + */ + private Date timestamp; + + /** + * (Required) + */ + public SimpleEmailCommonHeaders getCommonHeaders() { + return commonHeaders; + } + + /** + * (Required) + */ + public SimpleEmailMessage setCommonHeaders(SimpleEmailCommonHeaders commonHeaders) { + this.commonHeaders = commonHeaders; + return this; + } + + /** + * (Required) + */ + public List getDestination() { + return destination; + } + + /** + * (Required) + */ + public SimpleEmailMessage setDestination(List destination) { + this.destination = destination; + return this; + } + + /** + * (Required) + */ + public List getHeaders() { + return headers; + } + + /** + * (Required) + */ + public SimpleEmailMessage setHeaders(List headers) { + this.headers = headers; + return this; + } + + /** + * (Required) + */ + public Boolean getHeadersTruncated() { + return headersTruncated; + } + + /** + * (Required) + */ + public SimpleEmailMessage setHeadersTruncated(Boolean headersTruncated) { + this.headersTruncated = headersTruncated; + return this; + } + + /** + * (Required) + */ + public String getMessageId() { + return messageId; + } + + /** + * (Required) + */ + public SimpleEmailMessage setMessageId(String messageId) { + this.messageId = messageId; + return this; + } + + /** + * (Required) + */ + public String getSource() { + return source; + } + + /** + * (Required) + */ + public SimpleEmailMessage setSource(String source) { + this.source = source; + return this; + } + + /** + * (Required) + */ + public Date getTimestamp() { + return timestamp; + } + + /** + * (Required) + */ + public SimpleEmailMessage setTimestamp(Date timestamp) { + this.timestamp = timestamp; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailReceipt.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailReceipt.java new file mode 100644 index 0000000..afc3e90 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailReceipt.java @@ -0,0 +1,221 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@DataObject(generateConverter = true) +public class SimpleEmailReceipt { + + public SimpleEmailReceipt() {} + + public SimpleEmailReceipt(JsonObject json) { + SimpleEmailReceiptConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SimpleEmailReceiptConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private SimpleEmailReceiptAction action; + /** + * (Required) + */ + private SimpleEmailVerdict dkimVerdict; + /** + * (Required) + */ + private SimpleEmailVerdict dmarcPolicy; + /** + * (Required) + */ + private SimpleEmailVerdict dmarcVerdict; + /** + * (Required) + */ + private Integer processingTimeMillis; + /** + * (Required) + */ + private List recipients = new ArrayList(); + /** + * (Required) + */ + private SimpleEmailVerdict spamVerdict; + /** + * (Required) + */ + private SimpleEmailVerdict spfVerdict; + /** + * (Required) + */ + private Date timestamp; + /** + * (Required) + */ + private SimpleEmailVerdict virusVerdict; + + /** + * (Required) + */ + public SimpleEmailReceiptAction getAction() { + return action; + } + + /** + * (Required) + */ + public SimpleEmailReceipt setAction(SimpleEmailReceiptAction action) { + this.action = action; + return this; + } + + /** + * (Required) + */ + public SimpleEmailVerdict getDkimVerdict() { + return dkimVerdict; + } + + /** + * (Required) + */ + public SimpleEmailReceipt setDkimVerdict(SimpleEmailVerdict dkimVerdict) { + this.dkimVerdict = dkimVerdict; + return this; + } + + /** + * (Required) + */ + public SimpleEmailVerdict getDmarcPolicy() { + return dmarcPolicy; + } + + /** + * (Required) + */ + public SimpleEmailReceipt setDmarcPolicy(SimpleEmailVerdict dmarcPolicy) { + this.dmarcPolicy = dmarcPolicy; + return this; + } + + /** + * (Required) + */ + public SimpleEmailVerdict getDmarcVerdict() { + return dmarcVerdict; + } + + /** + * (Required) + */ + public SimpleEmailReceipt setDmarcVerdict(SimpleEmailVerdict dmarcVerdict) { + this.dmarcVerdict = dmarcVerdict; + return this; + } + + /** + * (Required) + */ + public Integer getProcessingTimeMillis() { + return processingTimeMillis; + } + + /** + * (Required) + */ + public SimpleEmailReceipt setProcessingTimeMillis(Integer processingTimeMillis) { + this.processingTimeMillis = processingTimeMillis; + return this; + } + + /** + * (Required) + */ + public List getRecipients() { + return recipients; + } + + /** + * (Required) + */ + public SimpleEmailReceipt setRecipients(List recipients) { + this.recipients = recipients; + return this; + } + + /** + * (Required) + */ + public SimpleEmailVerdict getSpamVerdict() { + return spamVerdict; + } + + /** + * (Required) + */ + public SimpleEmailReceipt setSpamVerdict(SimpleEmailVerdict spamVerdict) { + this.spamVerdict = spamVerdict; + return this; + } + + /** + * (Required) + */ + public SimpleEmailVerdict getSpfVerdict() { + return spfVerdict; + } + + /** + * (Required) + */ + public SimpleEmailReceipt setSpfVerdict(SimpleEmailVerdict spfVerdict) { + this.spfVerdict = spfVerdict; + return this; + } + + /** + * (Required) + */ + public Date getTimestamp() { + return timestamp; + } + + /** + * (Required) + */ + public SimpleEmailReceipt setTimestamp(Date timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * (Required) + */ + public SimpleEmailVerdict getVirusVerdict() { + return virusVerdict; + } + + /** + * (Required) + */ + public SimpleEmailReceipt setVirusVerdict(SimpleEmailVerdict virusVerdict) { + this.virusVerdict = virusVerdict; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailReceiptAction.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailReceiptAction.java new file mode 100644 index 0000000..7cf033a --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailReceiptAction.java @@ -0,0 +1,85 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class SimpleEmailReceiptAction { + + public SimpleEmailReceiptAction() {} + + public SimpleEmailReceiptAction(JsonObject json) { + SimpleEmailReceiptActionConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SimpleEmailReceiptActionConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String functionArn; + /** + * (Required) + */ + private String invocationType; + /** + * (Required) + */ + private String type; + + /** + * (Required) + */ + public String getFunctionArn() { + return functionArn; + } + + /** + * (Required) + */ + public SimpleEmailReceiptAction setFunctionArn(String functionArn) { + this.functionArn = functionArn; + return this; + } + + /** + * (Required) + */ + public String getInvocationType() { + return invocationType; + } + + /** + * (Required) + */ + public SimpleEmailReceiptAction setInvocationType(String invocationType) { + this.invocationType = invocationType; + return this; + } + + /** + * (Required) + */ + public String getType() { + return type; + } + + /** + * (Required) + */ + public SimpleEmailReceiptAction setType(String type) { + this.type = type; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailRecord.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailRecord.java new file mode 100644 index 0000000..f96a162 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailRecord.java @@ -0,0 +1,85 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class SimpleEmailRecord { + + public SimpleEmailRecord() {} + + public SimpleEmailRecord(JsonObject json) { + SimpleEmailRecordConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SimpleEmailRecordConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String eventSource; + /** + * (Required) + */ + private String eventVersion; + /** + * (Required) + */ + private SimpleEmailService ses; + + /** + * (Required) + */ + public String getEventSource() { + return eventSource; + } + + /** + * (Required) + */ + public SimpleEmailRecord setEventSource(String eventSource) { + this.eventSource = eventSource; + return this; + } + + /** + * (Required) + */ + public String getEventVersion() { + return eventVersion; + } + + /** + * (Required) + */ + public SimpleEmailRecord setEventVersion(String eventVersion) { + this.eventVersion = eventVersion; + return this; + } + + /** + * (Required) + */ + public SimpleEmailService getSes() { + return ses; + } + + /** + * (Required) + */ + public SimpleEmailRecord setSes(SimpleEmailService ses) { + this.ses = ses; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailService.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailService.java new file mode 100644 index 0000000..9295db0 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailService.java @@ -0,0 +1,66 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class SimpleEmailService { + + public SimpleEmailService() {} + + public SimpleEmailService(JsonObject json) { + SimpleEmailServiceConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SimpleEmailServiceConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private SimpleEmailMessage mail; + /** + * (Required) + */ + private SimpleEmailReceipt receipt; + + /** + * (Required) + */ + public SimpleEmailMessage getMail() { + return mail; + } + + /** + * (Required) + */ + public SimpleEmailService setMail(SimpleEmailMessage mail) { + this.mail = mail; + return this; + } + + /** + * (Required) + */ + public SimpleEmailReceipt getReceipt() { + return receipt; + } + + /** + * (Required) + */ + public SimpleEmailService setReceipt(SimpleEmailReceipt receipt) { + this.receipt = receipt; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailVerdict.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailVerdict.java new file mode 100644 index 0000000..2e50c3a --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/event/SimpleEmailVerdict.java @@ -0,0 +1,47 @@ + +package xyz.jetdrone.vertx.lambda.aws.event; + + +import io.vertx.codegen.annotations.DataObject; +import io.vertx.core.json.JsonObject; + +@DataObject(generateConverter = true) +public class SimpleEmailVerdict { + + public SimpleEmailVerdict() {} + + public SimpleEmailVerdict(JsonObject json) { + SimpleEmailVerdictConverter.fromJson(json, this); + } + + public JsonObject toJson() { + JsonObject json = new JsonObject(); + SimpleEmailVerdictConverter.toJson(this, json); + return json; + } + + /** + * (Required) + */ + private String status; + + /** + * (Required) + */ + public String getStatus() { + return status; + } + + /** + * (Required) + */ + public SimpleEmailVerdict setStatus(String status) { + this.status = status; + return this; + } + + @Override + public String toString() { + return toJson().encodePrettily(); + } +} diff --git a/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/package-info.java b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/package-info.java new file mode 100644 index 0000000..47b1e86 --- /dev/null +++ b/boilerplate/src/main/java/xyz/jetdrone/vertx/lambda/aws/package-info.java @@ -0,0 +1,5 @@ +@ModuleGen(name = "vertx-lambda-aws", groupPackage = "xyz.jetdrone.vertx.lambda.aws") +package xyz.jetdrone.vertx.lambda.aws; + +import io.vertx.codegen.annotations.ModuleGen; + diff --git a/boilerplate/src/main/resources/META-INF/native-image/xyz.jetdrone/vertx.lambda.aws/native-image.properties b/boilerplate/src/main/resources/META-INF/native-image/xyz.jetdrone/vertx.lambda.aws/native-image.properties new file mode 100644 index 0000000..4bc69f0 --- /dev/null +++ b/boilerplate/src/main/resources/META-INF/native-image/xyz.jetdrone/vertx.lambda.aws/native-image.properties @@ -0,0 +1,7 @@ +Args = --initialize-at-build-time=javax,io.netty,io.vertx,com.fasterxml.jackson,xyz.jetdrone \ + --initialize-at-run-time=io.netty.util.internal.logging.Log4JLogger,io.netty.handler.codec.http.HttpObjectEncoder,io.netty.handler.codec.http.websocketx.WebSocket00FrameEncoder,io.netty.handler.codec.http2.Http2CodecUtil,io.netty.handler.codec.http2.DefaultHttp2FrameWriter,io.netty.handler.ssl.ReferenceCountedOpenSslServerContext,io.netty.handler.ssl.JdkNpnApplicationProtocolNegotiator,io.netty.handler.ssl.ReferenceCountedOpenSslEngine,io.netty.handler.ssl.ConscryptAlpnSslEngine,io.netty.handler.ssl.JettyNpnSslEngine,io.netty.handler.ssl.ReferenceCountedOpenSslClientContext,io.vertx.core.net.impl.transport.EpollTransport,io.vertx.core.net.impl.transport.KQueueTransport,io.vertx.core.http.impl.VertxHttp2ClientUpgradeCodec \ + -H:ReflectionConfigurationResources=${.}/reflection.json + +JavaArgs = -Dvertx.disableDnsResolver=true \ + -Dvertx.cacheDirBase=/tmp/vertx-cache \ + -Djava.net.preferIPv4Stack=true diff --git a/boilerplate/src/main/resources/META-INF/native-image/xyz.jetdrone/vertx.lambda.aws/reflection.json b/boilerplate/src/main/resources/META-INF/native-image/xyz.jetdrone/vertx.lambda.aws/reflection.json new file mode 100644 index 0000000..124fcac --- /dev/null +++ b/boilerplate/src/main/resources/META-INF/native-image/xyz.jetdrone/vertx.lambda.aws/reflection.json @@ -0,0 +1,8 @@ +[ + { + "name": "java.util.LinkedHashMap", + "methods": [ + { "name": "", "parameterTypes": [] } + ] + } +] diff --git a/boilerplate/src/main/resources/assemblies/aws-function.xml b/boilerplate/src/main/resources/assemblies/aws-function.xml new file mode 100644 index 0000000..582bd18 --- /dev/null +++ b/boilerplate/src/main/resources/assemblies/aws-function.xml @@ -0,0 +1,18 @@ + + + aws-function + + + zip + + false + + + ${project.build.directory}/bootstrap + . + 0755 + + + diff --git a/boilerplate/src/main/resources/schema/apigw-custom-authorizer-request.json b/boilerplate/src/main/resources/schema/apigw-custom-authorizer-request.json new file mode 100644 index 0000000..2aa5bac --- /dev/null +++ b/boilerplate/src/main/resources/schema/apigw-custom-authorizer-request.json @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/APIGatewayCustomAuthorizerRequest", + "definitions": { + "APIGatewayCustomAuthorizerRequest": { + "required": [ + "type", + "authorizationToken", + "methodArn" + ], + "properties": { + "authorizationToken": { + "type": "string" + }, + "methodArn": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/apigw-custom-authorizer-response.json b/boilerplate/src/main/resources/schema/apigw-custom-authorizer-response.json new file mode 100644 index 0000000..5e3f957 --- /dev/null +++ b/boilerplate/src/main/resources/schema/apigw-custom-authorizer-response.json @@ -0,0 +1,81 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/APIGatewayCustomAuthorizerResponse", + "definitions": { + "APIGatewayCustomAuthorizerPolicy": { + "required": [ + "Version", + "Statement" + ], + "properties": { + "Statement": { + "items": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/IAMPolicyStatement" + }, + "type": "array" + }, + "Version": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "APIGatewayCustomAuthorizerResponse": { + "required": [ + "principalId", + "policyDocument" + ], + "properties": { + "context": { + "patternProperties": { + ".*": { + "additionalProperties": true, + "type": "object" + } + }, + "type": "object" + }, + "policyDocument": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/APIGatewayCustomAuthorizerPolicy" + }, + "principalId": { + "type": "string" + }, + "usageIdentifierKey": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "IAMPolicyStatement": { + "required": [ + "Action", + "Effect", + "Resource" + ], + "properties": { + "Action": { + "items": { + "type": "string" + }, + "type": "array" + }, + "Effect": { + "type": "string" + }, + "Resource": { + "items": { + "type": "string" + }, + "type": "array" + } + }, + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/apigw-proxy-request.json b/boilerplate/src/main/resources/schema/apigw-proxy-request.json new file mode 100644 index 0000000..b448c9d --- /dev/null +++ b/boilerplate/src/main/resources/schema/apigw-proxy-request.json @@ -0,0 +1,177 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/APIGatewayProxyRequest", + "definitions": { + "APIGatewayProxyRequest": { + "required": [ + "resource", + "path", + "httpMethod", + "headers", + "queryStringParameters", + "pathParameters", + "stageVariables", + "requestContext", + "body" + ], + "properties": { + "body": { + "type": "string" + }, + "headers": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, + "httpMethod": { + "type": "string" + }, + "isBase64Encoded": { + "type": "boolean" + }, + "path": { + "type": "string" + }, + "pathParameters": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, + "queryStringParameters": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, + "requestContext": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/APIGatewayProxyRequestContext" + }, + "resource": { + "type": "string" + }, + "stageVariables": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + } + }, + "additionalProperties": false, + "type": "object" + }, + "APIGatewayProxyRequestContext": { + "required": [ + "accountId", + "resourceId", + "stage", + "requestId", + "identity", + "resourcePath", + "authorizer", + "httpMethod", + "apiId" + ], + "properties": { + "accountId": { + "type": "string" + }, + "apiId": { + "type": "string" + }, + "authorizer": { + "patternProperties": { + ".*": { + "additionalProperties": true, + "type": "object" + } + }, + "type": "object" + }, + "httpMethod": { + "type": "string" + }, + "identity": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/APIGatewayRequestIdentity" + }, + "requestId": { + "type": "string" + }, + "resourceId": { + "type": "string" + }, + "resourcePath": { + "type": "string" + }, + "stage": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "APIGatewayRequestIdentity": { + "required": [ + "cognitoIdentityPoolId", + "accountId", + "cognitoIdentityId", + "caller", + "apiKey", + "sourceIp", + "cognitoAuthenticationType", + "cognitoAuthenticationProvider", + "userArn", + "userAgent", + "user" + ], + "properties": { + "accountId": { + "type": "string" + }, + "apiKey": { + "type": "string" + }, + "caller": { + "type": "string" + }, + "cognitoAuthenticationProvider": { + "type": "string" + }, + "cognitoAuthenticationType": { + "type": "string" + }, + "cognitoIdentityId": { + "type": "string" + }, + "cognitoIdentityPoolId": { + "type": "string" + }, + "sourceIp": { + "type": "string" + }, + "user": { + "type": "string" + }, + "userAgent": { + "type": "string" + }, + "userArn": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/apigw-proxy-response.json b/boilerplate/src/main/resources/schema/apigw-proxy-response.json new file mode 100644 index 0000000..8bfabd7 --- /dev/null +++ b/boilerplate/src/main/resources/schema/apigw-proxy-response.json @@ -0,0 +1,34 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/APIGatewayProxyResponse", + "definitions": { + "APIGatewayProxyResponse": { + "required": [ + "statusCode", + "headers", + "body" + ], + "properties": { + "body": { + "type": "string" + }, + "headers": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, + "isBase64Encoded": { + "type": "boolean" + }, + "statusCode": { + "type": "integer" + } + }, + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/cloud-watch-event.json b/boilerplate/src/main/resources/schema/cloud-watch-event.json new file mode 100644 index 0000000..d1f773b --- /dev/null +++ b/boilerplate/src/main/resources/schema/cloud-watch-event.json @@ -0,0 +1,57 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/CloudWatchEvent", + "definitions": { + "CloudWatchEvent": { + "required": [ + "version", + "id", + "detail-type", + "source", + "account", + "time", + "region", + "resources", + "detail" + ], + "properties": { + "account": { + "type": "string" + }, + "detail": { + "items": { + "type": "integer" + }, + "type": "array" + }, + "detail-type": { + "type": "string" + }, + "id": { + "type": "string" + }, + "region": { + "type": "string" + }, + "resources": { + "items": { + "type": "string" + }, + "type": "array" + }, + "source": { + "type": "string" + }, + "time": { + "type": "string", + "format": "date-time" + }, + "version": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/cloud-watch-logs.json b/boilerplate/src/main/resources/schema/cloud-watch-logs.json new file mode 100644 index 0000000..d250497 --- /dev/null +++ b/boilerplate/src/main/resources/schema/cloud-watch-logs.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/CloudwatchLogsEvent", + "definitions": { + "CloudwatchLogsEvent": { + "required": [ + "awslogs" + ], + "properties": { + "awslogs": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/CloudwatchLogsRawData" + } + }, + "additionalProperties": false, + "type": "object" + }, + "CloudwatchLogsRawData": { + "required": [ + "data" + ], + "properties": { + "data": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/config-event.json b/boilerplate/src/main/resources/schema/config-event.json new file mode 100644 index 0000000..b401c08 --- /dev/null +++ b/boilerplate/src/main/resources/schema/config-event.json @@ -0,0 +1,54 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/ConfigEvent", + "definitions": { + "ConfigEvent": { + "required": [ + "accountId", + "configRuleArn", + "configRuleId", + "configRuleName", + "eventLeftScope", + "executionRoleArn", + "invokingEvent", + "resultToken", + "ruleParameters", + "version" + ], + "properties": { + "accountId": { + "type": "string" + }, + "configRuleArn": { + "type": "string" + }, + "configRuleId": { + "type": "string" + }, + "configRuleName": { + "type": "string" + }, + "eventLeftScope": { + "type": "boolean" + }, + "executionRoleArn": { + "type": "string" + }, + "invokingEvent": { + "type": "string" + }, + "resultToken": { + "type": "string" + }, + "ruleParameters": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/firehose-event.json b/boilerplate/src/main/resources/schema/firehose-event.json new file mode 100644 index 0000000..6d86064 --- /dev/null +++ b/boilerplate/src/main/resources/schema/firehose-event.json @@ -0,0 +1,62 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/KinesisFirehoseEvent", + "definitions": { + "KinesisFirehoseEvent": { + "required": [ + "invocationId", + "deliveryStreamArn", + "region", + "records" + ], + "properties": { + "deliveryStreamArn": { + "type": "string" + }, + "invocationId": { + "type": "string" + }, + "records": { + "items": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/KinesisFirehoseEventRecord" + }, + "type": "array" + }, + "region": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "KinesisFirehoseEventRecord": { + "required": [ + "recordId", + "approximateArrivalTimestamp", + "data" + ], + "properties": { + "approximateArrivalTimestamp": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/MilliSecondsEpochTime" + }, + "data": { + "type": "string", + "media": { + "binaryEncoding": "base64" + } + }, + "recordId": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "MilliSecondsEpochTime": { + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/iot-button-event.json b/boilerplate/src/main/resources/schema/iot-button-event.json new file mode 100644 index 0000000..bc6aec4 --- /dev/null +++ b/boilerplate/src/main/resources/schema/iot-button-event.json @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/IoTButtonEvent", + "definitions": { + "IoTButtonEvent": { + "required": [ + "serialNumber", + "clickType", + "batteryVoltage" + ], + "properties": { + "batteryVoltage": { + "type": "string" + }, + "clickType": { + "type": "string" + }, + "serialNumber": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/kinesis-event.json b/boilerplate/src/main/resources/schema/kinesis-event.json new file mode 100644 index 0000000..c052d0b --- /dev/null +++ b/boilerplate/src/main/resources/schema/kinesis-event.json @@ -0,0 +1,102 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/KinesisEvent", + "definitions": { + "KinesisEvent": { + "required": [ + "Records" + ], + "properties": { + "Records": { + "items": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/KinesisEventRecord" + }, + "type": "array" + } + }, + "additionalProperties": false, + "type": "object" + }, + "KinesisEventRecord": { + "required": [ + "awsRegion", + "eventID", + "eventName", + "eventSource", + "eventSourceARN", + "eventVersion", + "invokeIdentityArn", + "kinesis" + ], + "properties": { + "awsRegion": { + "type": "string" + }, + "eventID": { + "type": "string" + }, + "eventName": { + "type": "string" + }, + "eventSource": { + "type": "string" + }, + "eventSourceARN": { + "type": "string" + }, + "eventVersion": { + "type": "string" + }, + "invokeIdentityArn": { + "type": "string" + }, + "kinesis": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/KinesisRecord" + } + }, + "additionalProperties": false, + "type": "object" + }, + "KinesisRecord": { + "required": [ + "approximateArrivalTimestamp", + "data", + "partitionKey", + "sequenceNumber", + "kinesisSchemaVersion" + ], + "properties": { + "approximateArrivalTimestamp": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SecondsEpochTime" + }, + "data": { + "type": "string", + "media": { + "binaryEncoding": "base64" + } + }, + "encryptionType": { + "type": "string" + }, + "kinesisSchemaVersion": { + "type": "string" + }, + "partitionKey": { + "type": "string" + }, + "sequenceNumber": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SecondsEpochTime": { + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/lex-event.json b/boilerplate/src/main/resources/schema/lex-event.json new file mode 100644 index 0000000..0efa436 --- /dev/null +++ b/boilerplate/src/main/resources/schema/lex-event.json @@ -0,0 +1,205 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/LexEvent", + "definitions": { + "Attachment": { + "properties": { + "attachmentLinkUrl": { + "type": "string" + }, + "buttons": { + "items": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + }, + "imageUrl": { + "type": "string" + }, + "subTitle": { + "type": "string" + }, + "title": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "LexBot": { + "properties": { + "alias": { + "type": "string" + }, + "name": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "LexCurrentIntent": { + "properties": { + "confirmationStatus": { + "type": "string" + }, + "name": { + "type": "string" + }, + "slotDetails": { + "patternProperties": { + ".*": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SlotDetail" + } + }, + "type": "object" + }, + "slots": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + } + }, + "additionalProperties": false, + "type": "object" + }, + "LexDialogAction": { + "properties": { + "fulfillmentState": { + "type": "string" + }, + "intentName": { + "type": "string" + }, + "message": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, + "responseCard": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/LexResponseCard" + }, + "slotToElicit": { + "type": "string" + }, + "slots": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, + "type": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "LexEvent": { + "properties": { + "bot": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/LexBot" + }, + "currentIntent": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/LexCurrentIntent" + }, + "dialogAction": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/LexDialogAction" + }, + "inputTranscript": { + "type": "string" + }, + "invocationSource": { + "type": "string" + }, + "messageVersion": { + "type": "string" + }, + "outputDialogMode": { + "type": "string" + }, + "requestAttributes": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, + "sessionAttributes": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, + "userId": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "LexResponseCard": { + "properties": { + "contentType": { + "type": "string" + }, + "genericAttachments": { + "items": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/Attachment" + }, + "type": "array" + }, + "version": { + "type": "integer" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SlotDetail": { + "properties": { + "originalValue": { + "type": "string" + }, + "resolutions": { + "items": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/s3-event.json b/boilerplate/src/main/resources/schema/s3-event.json new file mode 100644 index 0000000..0b2a8f6 --- /dev/null +++ b/boilerplate/src/main/resources/schema/s3-event.json @@ -0,0 +1,177 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/S3Event", + "definitions": { + "S3Bucket": { + "required": [ + "name", + "ownerIdentity", + "arn" + ], + "properties": { + "arn": { + "type": "string" + }, + "name": { + "type": "string" + }, + "ownerIdentity": { + "$ref": "#/definitions/S3UserIdentity" + } + }, + "additionalProperties": false, + "type": "object" + }, + "S3Entity": { + "required": [ + "s3SchemaVersion", + "configurationId", + "bucket", + "object" + ], + "properties": { + "bucket": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/S3Bucket" + }, + "configurationId": { + "type": "string" + }, + "object": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/S3Object" + }, + "s3SchemaVersion": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "S3Event": { + "required": [ + "Records" + ], + "properties": { + "Records": { + "items": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/S3EventRecord" + }, + "type": "array" + } + }, + "additionalProperties": false, + "type": "object" + }, + "S3EventRecord": { + "required": [ + "eventVersion", + "eventSource", + "awsRegion", + "eventTime", + "eventName", + "userIdentity", + "requestParameters", + "responseElements", + "s3" + ], + "properties": { + "awsRegion": { + "type": "string" + }, + "eventName": { + "type": "string" + }, + "eventSource": { + "type": "string" + }, + "eventTime": { + "type": "string", + "format": "date-time" + }, + "eventVersion": { + "type": "string" + }, + "requestParameters": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/S3RequestParameters" + }, + "responseElements": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, + "s3": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/S3Entity" + }, + "userIdentity": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/S3UserIdentity" + } + }, + "additionalProperties": false, + "type": "object" + }, + "S3Object": { + "required": [ + "key", + "size", + "urlDecodedKey", + "versionId", + "eTag", + "sequencer" + ], + "properties": { + "eTag": { + "type": "string" + }, + "key": { + "type": "string" + }, + "sequencer": { + "type": "string" + }, + "size": { + "type": "integer" + }, + "urlDecodedKey": { + "type": "string" + }, + "versionId": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "S3RequestParameters": { + "required": [ + "sourceIPAddress" + ], + "properties": { + "sourceIPAddress": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "S3UserIdentity": { + "required": [ + "principalId" + ], + "properties": { + "principalId": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/ses-event.json b/boilerplate/src/main/resources/schema/ses-event.json new file mode 100644 index 0000000..8202e84 --- /dev/null +++ b/boilerplate/src/main/resources/schema/ses-event.json @@ -0,0 +1,246 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SimpleEmailEvent", + "definitions": { + "SimpleEmailCommonHeaders": { + "required": [ + "from", + "to", + "returnPath", + "messageId", + "date", + "subject" + ], + "properties": { + "date": { + "type": "string" + }, + "from": { + "items": { + "type": "string" + }, + "type": "array" + }, + "messageId": { + "type": "string" + }, + "returnPath": { + "type": "string" + }, + "subject": { + "type": "string" + }, + "to": { + "items": { + "type": "string" + }, + "type": "array" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SimpleEmailEvent": { + "required": [ + "Records" + ], + "properties": { + "Records": { + "items": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SimpleEmailRecord" + }, + "type": "array" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SimpleEmailHeader": { + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SimpleEmailMessage": { + "required": [ + "commonHeaders", + "source", + "timestamp", + "destination", + "headers", + "headersTruncated", + "messageId" + ], + "properties": { + "commonHeaders": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SimpleEmailCommonHeaders" + }, + "destination": { + "items": { + "type": "string" + }, + "type": "array" + }, + "headers": { + "items": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SimpleEmailHeader" + }, + "type": "array" + }, + "headersTruncated": { + "type": "boolean" + }, + "messageId": { + "type": "string" + }, + "source": { + "type": "string" + }, + "timestamp": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SimpleEmailReceipt": { + "required": [ + "recipients", + "timestamp", + "spamVerdict", + "dkimVerdict", + "dmarcVerdict", + "dmarcPolicy", + "spfVerdict", + "virusVerdict", + "action", + "processingTimeMillis" + ], + "properties": { + "action": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SimpleEmailReceiptAction" + }, + "dkimVerdict": { + "$ref": "#/definitions/SimpleEmailVerdict" + }, + "dmarcPolicy": { + "$ref": "#/definitions/SimpleEmailVerdict" + }, + "dmarcVerdict": { + "$ref": "#/definitions/SimpleEmailVerdict" + }, + "processingTimeMillis": { + "type": "integer" + }, + "recipients": { + "items": { + "type": "string" + }, + "type": "array" + }, + "spamVerdict": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SimpleEmailVerdict" + }, + "spfVerdict": { + "$ref": "#/definitions/SimpleEmailVerdict" + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "virusVerdict": { + "$ref": "#/definitions/SimpleEmailVerdict" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SimpleEmailReceiptAction": { + "required": [ + "type", + "invocationType", + "functionArn" + ], + "properties": { + "functionArn": { + "type": "string" + }, + "invocationType": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SimpleEmailRecord": { + "required": [ + "eventVersion", + "eventSource", + "ses" + ], + "properties": { + "eventSource": { + "type": "string" + }, + "eventVersion": { + "type": "string" + }, + "ses": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SimpleEmailService" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SimpleEmailService": { + "required": [ + "mail", + "receipt" + ], + "properties": { + "mail": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SimpleEmailMessage" + }, + "receipt": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SimpleEmailReceipt" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SimpleEmailVerdict": { + "required": [ + "status" + ], + "properties": { + "status": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/sns-event.json b/boilerplate/src/main/resources/schema/sns-event.json new file mode 100644 index 0000000..50dcd81 --- /dev/null +++ b/boilerplate/src/main/resources/schema/sns-event.json @@ -0,0 +1,106 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SNSEvent", + "definitions": { + "SNSEntity": { + "required": [ + "Signature", + "MessageId", + "Type", + "TopicArn", + "MessageAttributes", + "SignatureVersion", + "Timestamp", + "SigningCertUrl", + "Message", + "UnsubscribeUrl", + "Subject" + ], + "properties": { + "Message": { + "type": "string" + }, + "MessageAttributes": { + "patternProperties": { + ".*": { + "additionalProperties": true, + "type": "object" + } + }, + "type": "object" + }, + "MessageId": { + "type": "string" + }, + "Signature": { + "type": "string" + }, + "SignatureVersion": { + "type": "string" + }, + "SigningCertUrl": { + "type": "string" + }, + "Subject": { + "type": "string" + }, + "Timestamp": { + "type": "string", + "format": "date-time" + }, + "TopicArn": { + "type": "string" + }, + "Type": { + "type": "string" + }, + "UnsubscribeUrl": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SNSEvent": { + "required": [ + "Records" + ], + "properties": { + "Records": { + "items": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SNSEventRecord" + }, + "type": "array" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SNSEventRecord": { + "required": [ + "EventVersion", + "EventSubscriptionArn", + "EventSource", + "Sns" + ], + "properties": { + "EventSource": { + "type": "string" + }, + "EventSubscriptionArn": { + "type": "string" + }, + "EventVersion": { + "type": "string" + }, + "Sns": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SNSEntity" + } + }, + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/boilerplate/src/main/resources/schema/sqs-event.json b/boilerplate/src/main/resources/schema/sqs-event.json new file mode 100644 index 0000000..a71cb3f --- /dev/null +++ b/boilerplate/src/main/resources/schema/sqs-event.json @@ -0,0 +1,119 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SQSEvent", + "definitions": { + "SQSEvent": { + "required": [ + "Records" + ], + "properties": { + "Records": { + "items": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SQSMessage" + }, + "type": "array" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SQSMessage": { + "required": [ + "messageId", + "receiptHandle", + "body", + "md5OfBody", + "md5OfMessageAttributes", + "attributes", + "messageAttributes", + "eventSourceARN", + "eventSource", + "awsRegion" + ], + "properties": { + "attributes": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + }, + "awsRegion": { + "type": "string" + }, + "body": { + "type": "string" + }, + "eventSource": { + "type": "string" + }, + "eventSourceARN": { + "type": "string" + }, + "md5OfBody": { + "type": "string" + }, + "md5OfMessageAttributes": { + "type": "string" + }, + "messageAttributes": { + "patternProperties": { + ".*": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/SQSMessageAttribute" + } + }, + "type": "object" + }, + "messageId": { + "type": "string" + }, + "receiptHandle": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "SQSMessageAttribute": { + "required": [ + "stringListValues", + "binaryListValues", + "dataType" + ], + "properties": { + "binaryListValues": { + "items": { + "type": "string", + "media": { + "binaryEncoding": "base64" + } + }, + "type": "array" + }, + "binaryValue": { + "type": "string", + "media": { + "binaryEncoding": "base64" + } + }, + "dataType": { + "type": "string" + }, + "stringListValues": { + "items": { + "type": "string" + }, + "type": "array" + }, + "stringValue": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + } + } +} \ No newline at end of file diff --git a/bootstrap b/bootstrap deleted file mode 100755 index 5e7d18e..0000000 --- a/bootstrap +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -/opt/target/lambda diff --git a/pom.xml b/pom.xml index 06afb40..b552873 100644 --- a/pom.xml +++ b/pom.xml @@ -4,21 +4,21 @@ 4.0.0 - com.example - myapp + vertx.lambda + lambda 0.0.1-SNAPSHOT aws-lambda-vertx-native - vertx.lambda.LambdaBootstrap - UTF-8 + 19.0.0 + 3.7.1 + 0.0.2 1.8 1.8 1.8 1.8 - 19.0.0 @@ -26,7 +26,7 @@ io.vertx vertx-stack-depchain - 3.7.1 + ${vertx.version} pom import @@ -35,18 +35,9 @@ - com.oracle.substratevm - svm-driver - ${graal.version} - provided - - - io.vertx - vertx-core - - - io.vertx - vertx-web-client + xyz.jetdrone + vertx.lambda.aws + ${vertx.lambda.aws.version} io.vertx @@ -63,18 +54,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - - ${vertx.verticle} - - - - com.oracle.substratevm native-image-maven-plugin @@ -88,10 +67,36 @@ - lambda - --enable-all-security-services --report-unsupported-elements-at-runtime --allow-incomplete-classpath + xyz.jetdrone.vertx.lambda.aws.Bootstrap + bootstrap + --report-unsupported-elements-at-runtime --allow-incomplete-classpath --no-server + + org.apache.maven.plugins + maven-assembly-plugin + 3.1.1 + + + xyz.jetdrone + vertx.lambda.aws + ${vertx.lambda.aws.version} + + + + + aws-function + + + + + package + + single + + + + diff --git a/src/main/java/lambda/ApplicationLoadBalancerLambda.java b/src/main/java/lambda/ApplicationLoadBalancerLambda.java new file mode 100644 index 0000000..fb84dce --- /dev/null +++ b/src/main/java/lambda/ApplicationLoadBalancerLambda.java @@ -0,0 +1,55 @@ +/* + * Copyright 2019 Paulo Lopes. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Apache License v2.0 which accompanies this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * The Apache License v2.0 is available at + * http://www.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + */ +package lambda; + +import io.vertx.core.eventbus.Message; +import io.vertx.core.json.JsonObject; +import xyz.jetdrone.vertx.lambda.aws.Lambda; +import xyz.jetdrone.vertx.lambda.aws.event.APIGatewayProxyRequest; +import xyz.jetdrone.vertx.lambda.aws.event.APIGatewayProxyResponse; + +/** + * You can use a Lambda function to process requests from an Application Load Balancer. + * + * Elastic Load Balancing supports Lambda functions as a target for an Application Load Balancer. + * Use load balancer rules to route HTTP requests to a function, based on path or header values. + * Process the request and return an HTTP response from your Lambda function. + * + * Elastic Load Balancing invokes your Lambda function synchronously with an event that contains + * the request body and metadata. + */ +public class ApplicationLoadBalancerLambda implements Lambda { + + @Override + public void handle(Message event) { + // the payload should be a proxy request + APIGatewayProxyRequest req = new APIGatewayProxyRequest(event.body()); + // print the payload + System.out.println(req); + + // Here your business logic... + + event.reply( + new APIGatewayProxyResponse() + .setStatusCode(200) + .setIsBase64Encoded(false) + .setHeaders(new JsonObject() + .put("Content-Type", "text/html")) + .setBody("

Hello from Lambda!

") + // convert to JSON as it's the expected format by lambda + .toJson()); + } +} diff --git a/src/main/java/lambda/DebugLambda.java b/src/main/java/lambda/DebugLambda.java new file mode 100644 index 0000000..e1da343 --- /dev/null +++ b/src/main/java/lambda/DebugLambda.java @@ -0,0 +1,34 @@ +/* + * Copyright 2019 Paulo Lopes. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Apache License v2.0 which accompanies this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * The Apache License v2.0 is available at + * http://www.opensource.org/licenses/apache2.0.php + * + * You may elect to redistribute this code under either of these licenses. + */ +package lambda; + +import io.vertx.core.eventbus.DeliveryOptions; +import io.vertx.core.eventbus.Message; +import xyz.jetdrone.vertx.lambda.aws.Lambda; + +/** + * This is a simple example of a Lambda. that prints to the STDOUT the job and returns it as is. + */ +public class DebugLambda implements Lambda { + + @Override + public void handle(Message msg) { + System.out.println("HEADERS: " + msg.headers()); + System.out.println("BODY: " + msg.body()); + + msg.reply(msg.body(), new DeliveryOptions().setHeaders(msg.headers())); + } +} diff --git a/src/main/java/lambda/EchoLambda.java b/src/main/java/lambda/EchoLambda.java index 29db95d..424f5b5 100644 --- a/src/main/java/lambda/EchoLambda.java +++ b/src/main/java/lambda/EchoLambda.java @@ -15,19 +15,30 @@ */ package lambda; -import io.vertx.core.Future; -import io.vertx.core.MultiMap; import io.vertx.core.Vertx; -import io.vertx.core.buffer.Buffer; -import vertx.lambda.Lambda; +import io.vertx.core.eventbus.DeliveryOptions; +import io.vertx.core.eventbus.EventBus; +import io.vertx.core.eventbus.Message; +import xyz.jetdrone.vertx.lambda.aws.Lambda; /** * This is a simple example of an echo Lambda. */ -public class EchoLambda implements Lambda { +public class EchoLambda implements Lambda { + + private EventBus eb; + + @Override + public void init(Vertx vertx) { + eb = vertx.eventBus(); + } @Override - public Future call(Vertx vertx, MultiMap headers, Buffer body) { - return Future.succeededFuture(body); + public void handle(Message msg) { + // showcase interop over the eventbus + eb.send("lambda.DebugLambda", msg.body(), new DeliveryOptions().setHeaders(msg.headers()), send -> { + // after the message was received and a reply is returned continue + msg.reply(msg.body()); + }); } } diff --git a/src/main/java/lambda/QOTDLambda.java b/src/main/java/lambda/QOTDLambda.java index 8917911..c3c2a53 100644 --- a/src/main/java/lambda/QOTDLambda.java +++ b/src/main/java/lambda/QOTDLambda.java @@ -15,18 +15,16 @@ */ package lambda; -import io.vertx.core.Future; -import io.vertx.core.MultiMap; -import io.vertx.core.Vertx; import io.vertx.core.buffer.Buffer; -import vertx.lambda.Lambda; +import io.vertx.core.eventbus.Message; +import xyz.jetdrone.vertx.lambda.aws.Lambda; import java.util.Random; /** * A simple QOTD Lambda */ -public class QOTDLambda implements Lambda { +public class QOTDLambda implements Lambda { private static final Random RANDOM = new Random(); @@ -43,8 +41,8 @@ public class QOTDLambda implements Lambda { }; @Override - public Future call(Vertx vertx, MultiMap headers, Buffer body) { + public void handle(Message msg) { // return a random qotd - return Future.succeededFuture(Buffer.buffer(QUOTES[RANDOM.nextInt(QUOTES.length)])); + msg.reply(Buffer.buffer(QUOTES[RANDOM.nextInt(QUOTES.length)])); } } diff --git a/src/main/java/vertx/lambda/Lambda.java b/src/main/java/vertx/lambda/Lambda.java deleted file mode 100644 index 371398b..0000000 --- a/src/main/java/vertx/lambda/Lambda.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2019 Paulo Lopes. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * The Apache License v2.0 is available at - * http://www.opensource.org/licenses/apache2.0.php - * - * You may elect to redistribute this code under either of these licenses. - */ -package vertx.lambda; - -import io.vertx.core.Future; -import io.vertx.core.MultiMap; -import io.vertx.core.Vertx; -import io.vertx.core.buffer.Buffer; - -/** - * The functional interface that represents a lambda - */ -@FunctionalInterface -public interface Lambda { - - String LAMBDA_RUNTIME_AWS_REQUEST_ID = "Lambda-Runtime-Aws-Request-Id"; - String LAMBDA_RUNTIME_DEADLINE_MS = "Lambda-Runtime-Deadline-Ms"; - String LAMBDA_RUNTIME_INVOKE_FUNCTION_ARN = "Lambda-Runtime-Invoke-Function-Arn"; - String LAMBDA_RUNTIME_TRACE_ID = "Lambda-Runtime-Trace-Id"; - String LAMBDA_RUNTIME_CLIENT_CONTEXT = "Lambda-Runtime-Client-Context"; - String LAMBDA_RUNTIME_COGNITO_IDENTITY = "Lambda-Runtime-Cognito-Identity"; - - /** - * Responses are asynchronous. - * - * @param vertx the vertx instance if needed for more IO - * @param headers the request headers - * @param body the request body (null if no body) - * @return return a future with the buffer to be returned. - */ - Future call(Vertx vertx, MultiMap headers, Buffer body); -} diff --git a/src/main/java/vertx/lambda/LambdaBootstrap.java b/src/main/java/vertx/lambda/LambdaBootstrap.java deleted file mode 100644 index c58e839..0000000 --- a/src/main/java/vertx/lambda/LambdaBootstrap.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright 2019 Paulo Lopes. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * The Apache License v2.0 is available at - * http://www.opensource.org/licenses/apache2.0.php - * - * You may elect to redistribute this code under either of these licenses. - */ -package vertx.lambda; - -import io.vertx.core.AsyncResult; -import io.vertx.core.Future; -import io.vertx.core.Handler; -import io.vertx.core.Vertx; -import io.vertx.core.buffer.Buffer; -import io.vertx.core.json.JsonObject; -import io.vertx.ext.web.client.HttpResponse; -import io.vertx.ext.web.client.WebClient; - -import static java.lang.System.getenv; - -import java.text.MessageFormat; -import java.util.HashMap; -import java.util.Map; -import java.util.ServiceLoader; - -/** - * Main entrypoint for the application. - */ -public class LambdaBootstrap { - - private static final String LAMBDA_VERSION_DATE = "2018-06-01"; - - private static final String LAMBDA_RUNTIME_TEMPLATE = "/{0}/runtime/invocation/next"; - private static final String LAMBDA_INVOCATION_TEMPLATE = "/{0}/runtime/invocation/{1}/response"; - private static final String LAMBDA_INIT_ERROR_TEMPLATE = "/{0}/runtime/init/error"; - private static final String LAMBDA_ERROR_TEMPLATE = "/{0}/runtime/invocation/{1}/error"; - - private static final Map HANDLERS = new HashMap<>(); - - static { - // load all handlers available, if this becomes a performance - ServiceLoader serviceLoader = ServiceLoader.load(Lambda.class); - for (Lambda fn : serviceLoader) { - HANDLERS.put(fn.getClass().getName(), fn); - } - } - - public static void main(String[] args) { - try { - new LambdaBootstrap(Vertx.vertx()); - } catch (RuntimeException e) { - e.printStackTrace(); - System.exit(1); - } - } - - private final WebClient client; - - private final Lambda fn; - - private final String host; - private final int port; - - private LambdaBootstrap(Vertx vertx) { - // create an WebClient - this.client = WebClient.create(vertx); - - String runtimeApi = getenv("AWS_LAMBDA_RUNTIME_API"); - - int sep = runtimeApi.indexOf(':'); - if (sep != -1) { - host = runtimeApi.substring(0, sep); - port = Integer.parseInt(runtimeApi.substring(sep + 1)); - } else { - host = runtimeApi; - port = 80; - } - - // Get the handler class and method name from the Lambda Configuration in the format of - this.fn = HANDLERS.get(getenv("_HANDLER")); - final String runtimeUrl = MessageFormat.format(LAMBDA_RUNTIME_TEMPLATE, LAMBDA_VERSION_DATE); - - if (fn == null) { - // Not much else to do handler can't be found. - final String uri = MessageFormat.format(LAMBDA_INIT_ERROR_TEMPLATE, LAMBDA_VERSION_DATE); - fail(uri, "Could not find handler method", "InitError"); - } else { - process(vertx, runtimeUrl); - } - } - - private void process(Vertx vertx, String runtimeUrl) { - client.get(port, host, runtimeUrl).send(getAbs -> { - if (getAbs.succeeded()) { - HttpResponse response = getAbs.result(); - - if (response.statusCode() != 200) { - System.exit(0); - } - - String requestId = response.getHeader("Lambda-Runtime-Aws-Request-Id"); - - try { - // Invoke Handler Method - fn.call(vertx, response.headers(), response.body()) - .setHandler(ar -> { - if (ar.succeeded()) { - // Post the results of Handler Invocation - String invocationUrl = MessageFormat.format(LAMBDA_INVOCATION_TEMPLATE, LAMBDA_VERSION_DATE, requestId); - success(invocationUrl, ar.result(), ack -> { - if (ack.failed()) { - ack.cause().printStackTrace(); - // terminate the process - System.exit(1); - } else { - // process the next call - // run on context to avoid large stacks - vertx.runOnContext(v -> process(vertx, runtimeUrl)); - } - }); - } else { - String initErrorUrl = MessageFormat.format(LAMBDA_ERROR_TEMPLATE, LAMBDA_VERSION_DATE, requestId); - fail(initErrorUrl, "Invocation Error", "RuntimeError"); - } - }); - - } catch (Exception e) { - String initErrorUrl = MessageFormat.format(LAMBDA_ERROR_TEMPLATE, LAMBDA_VERSION_DATE, requestId); - fail(initErrorUrl, "Invocation Error", "RuntimeError"); - } - } else { - getAbs.cause().printStackTrace(); - System.exit(1); - } - }); - } - - private void success(String requestURI, Buffer result, Handler> handler) { - client.post(port, host, requestURI) - .sendBuffer(result, ar -> { - if (ar.succeeded()) { - // we don't really care about the response - handler.handle(Future.succeededFuture()); - } else { - handler.handle(Future.failedFuture(ar.cause())); - } - }); - } - - private void fail(String requestURI, String errMsg, String errType) { - System.err.println("ERR: " + errMsg); - - final JsonObject error = new JsonObject() - .put("errorMessage", errMsg) - .put("errorType", errType); - - client.post(port, host, requestURI) - .sendJson(error, ar -> { - if (ar.failed()) { - ar.cause().printStackTrace(); - } - // terminate the process - System.exit(1); - }); - } -} diff --git a/src/main/resources/META-INF/native-image/io.vertx/vertx-core/native-image.properties b/src/main/resources/META-INF/native-image/io.vertx/vertx-core/native-image.properties deleted file mode 100644 index 905163a..0000000 --- a/src/main/resources/META-INF/native-image/io.vertx/vertx-core/native-image.properties +++ /dev/null @@ -1,17 +0,0 @@ -Args = --initialize-at-build-time=io.netty,io.vertx,com.fasterxml.jackson,javax \ - --initialize-at-run-time=io.netty.util.internal.logging.Log4JLogger,io.netty.handler.codec.http.HttpObjectEncoder,io.netty.handler.codec.http.websocketx.WebSocket00FrameEncoder,io.netty.handler.codec.http2.Http2CodecUtil,io.netty.handler.codec.http2.DefaultHttp2FrameWriter,io.netty.handler.ssl.ReferenceCountedOpenSslServerContext,io.netty.handler.ssl.JdkNpnApplicationProtocolNegotiator,io.netty.handler.ssl.ReferenceCountedOpenSslEngine,io.netty.handler.ssl.ConscryptAlpnSslEngine,io.netty.handler.ssl.JettyNpnSslEngine,io.netty.handler.ssl.ReferenceCountedOpenSslClientContext,io.vertx.core.net.impl.transport.EpollTransport,io.vertx.core.net.impl.transport.KQueueTransport,io.vertx.core.http.impl.VertxHttp2ClientUpgradeCodec \ - -H:+UseServiceLoaderFeature \ - -H:IncludeResources=META-INF/.* \ - -H:ReflectionConfigurationFiles=classes/${.}/reflection.json - -Args0 = -H:+ReportUnsupportedElementsAtRuntime \ - --allow-incomplete-classpath \ - --rerun-class-initialization-at-runtime=io.netty.handler.codec.http2.Http2CodecUtil \ - --delay-class-initialization-to-runtime=io.netty.handler.codec.http.HttpObjectEncoder,io.netty.handler.codec.http2.DefaultHttp2FrameWriter,io.netty.handler.codec.http.websocketx.WebSocket00FrameEncoder,io.netty.handler.ssl.JdkNpnApplicationProtocolNegotiator,io.netty.handler.ssl.ReferenceCountedOpenSslEngine,io.vertx.core.net.impl.transport.EpollTransport,io.vertx.core.net.impl.transport.KQueueTransport,io.netty.handler.ssl.ReferenceCountedOpenSslClientContext,io.netty.handler.ssl.ReferenceCountedOpenSslServerContext,io.netty.handler.ssl.ConscryptAlpnSslEngine,io.netty.handler.ssl.JettyNpnSslEngine \ - -H:IncludeResources=(META-INF/vertx|META-INF/services|static|webroot|template)/.* \ - -H:ReflectionConfigurationFiles=classes/${.}/reflection.json \ - -H:Name=lambda - -JavaArgs = -Dvertx.disableDnsResolver=true \ - -Dvertx.cacheDirBase=/tmp/vertx-cache \ - -Djava.net.preferIPv4Stack=true diff --git a/src/main/resources/META-INF/native-image/io.vertx/vertx-core/reflection.json b/src/main/resources/META-INF/native-image/io.vertx/vertx-core/reflection.json deleted file mode 100644 index 7c633ae..0000000 --- a/src/main/resources/META-INF/native-image/io.vertx/vertx-core/reflection.json +++ /dev/null @@ -1,26 +0,0 @@ -[ - { - "name": "java.util.LinkedHashMap", - "methods": [ - { "name": "", "parameterTypes": [] } - ] - }, - { - "name": "io.vertx.core.impl.launcher.commands.RunCommand", - "allDeclaredConstructors": true, - "allDeclaredMethods": true - }, - { - "name": "io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer", - "allDeclaredConstructors": true, - "allDeclaredMethods": true - }, - { - "name": "java.lang.Long", - "allDeclaredConstructors": true - }, - { - "name": "java.lang.Integer", - "allDeclaredConstructors": true - } -] diff --git a/src/main/resources/META-INF/services/vertx.lambda.Lambda b/src/main/resources/META-INF/services/vertx.lambda.Lambda deleted file mode 100644 index e65fe27..0000000 --- a/src/main/resources/META-INF/services/vertx.lambda.Lambda +++ /dev/null @@ -1,2 +0,0 @@ -lambda.EchoLambda -lambda.QOTDLambda diff --git a/src/main/resources/META-INF/services/xyz.jetdrone.vertx.lambda.aws.Lambda b/src/main/resources/META-INF/services/xyz.jetdrone.vertx.lambda.aws.Lambda new file mode 100644 index 0000000..ee7f05a --- /dev/null +++ b/src/main/resources/META-INF/services/xyz.jetdrone.vertx.lambda.aws.Lambda @@ -0,0 +1,4 @@ +lambda.EchoLambda +lambda.QOTDLambda +lambda.DebugLambda +lambda.ApplicationLoadBalancerLambda diff --git a/src/test/java/lambda/EchoLambdaTest.java b/src/test/java/lambda/EchoLambdaTest.java index 21942da..52ef843 100644 --- a/src/test/java/lambda/EchoLambdaTest.java +++ b/src/test/java/lambda/EchoLambdaTest.java @@ -15,39 +15,48 @@ */ package lambda; -import io.vertx.core.Future; -import io.vertx.core.MultiMap; import io.vertx.core.buffer.Buffer; +import io.vertx.core.eventbus.EventBus; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.RunTestOnContext; import io.vertx.ext.unit.junit.VertxUnitRunner; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import xyz.jetdrone.vertx.lambda.aws.Lambda; + +import java.util.ServiceLoader; @RunWith(VertxUnitRunner.class) public class EchoLambdaTest { - private final EchoLambda fn = new EchoLambda(); - @Rule public RunTestOnContext rule = new RunTestOnContext(); + @Before + public void beforeTest() { + // register all lambda's into the eventbus + ServiceLoader serviceLoader = ServiceLoader.load(Lambda.class); + for (Lambda fn : serviceLoader) { + fn.init(rule.vertx()); + rule.vertx().eventBus().localConsumer(fn.getClass().getName(), fn); + } + } + @Test public void shouldGetAnEchoMessage(TestContext should) { final Async test = should.async(); + final EventBus eb = rule.vertx().eventBus(); - Future fut = fn.call(rule.vertx(), MultiMap.caseInsensitiveMultiMap(), Buffer.buffer("Hello World")); - - fut.setHandler(call -> { - if (call.failed()) { - should.fail(call.cause()); + eb.send(EchoLambda.class.getName(), Buffer.buffer("Hello World"), msg -> { + if (msg.failed()) { + should.fail(msg.cause()); } else { - should.assertEquals(Buffer.buffer("Hello World"), call.result()); + should.assertEquals(Buffer.buffer("Hello World"), msg.result().body()); test.complete(); } }); } - } diff --git a/src/test/java/lambda/QOTDLambdaTest.java b/src/test/java/lambda/QOTDLambdaTest.java index fac0d8c..e3be05d 100644 --- a/src/test/java/lambda/QOTDLambdaTest.java +++ b/src/test/java/lambda/QOTDLambdaTest.java @@ -15,37 +15,47 @@ */ package lambda; -import io.vertx.core.Future; -import io.vertx.core.MultiMap; import io.vertx.core.buffer.Buffer; +import io.vertx.core.eventbus.EventBus; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.RunTestOnContext; import io.vertx.ext.unit.junit.VertxUnitRunner; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import xyz.jetdrone.vertx.lambda.aws.Lambda; + +import java.util.ServiceLoader; @RunWith(VertxUnitRunner.class) public class QOTDLambdaTest { - private final QOTDLambda fn = new QOTDLambda(); - @Rule public RunTestOnContext rule = new RunTestOnContext(); + @Before + public void beforeTest() { + // register all lambda's into the eventbus + ServiceLoader serviceLoader = ServiceLoader.load(Lambda.class); + for (Lambda fn : serviceLoader) { + fn.init(rule.vertx()); + rule.vertx().eventBus().localConsumer(fn.getClass().getName(), fn); + } + } + @Test public void shouldGetAQOTD(TestContext should) { final Async test = should.async(); + final EventBus eb = rule.vertx().eventBus(); - Future fut = fn.call(rule.vertx(), MultiMap.caseInsensitiveMultiMap(), null); - - fut.setHandler(call -> { - if (call.failed()) { - should.fail(call.cause()); + eb.send(QOTDLambda.class.getName(), Buffer.buffer(), msg -> { + if (msg.failed()) { + should.fail(msg.cause()); } else { - should.assertNotNull(call.result()); - should.assertTrue(call.result().length() > 0); + should.assertNotNull(msg.result().body()); + should.assertTrue(msg.result().body().length() > 0); test.complete(); } });