├── custom-connector-sdk ├── src │ ├── test │ │ └── resources │ │ │ ├── UnknownRequest.json │ │ │ ├── DescribeConnectorConfigurationRequest.json │ │ │ ├── ValidateConnectorRuntimeSettingsRequest.json │ │ │ ├── ValidateCredentialsRequest.json │ │ │ ├── DescribeEntityRequest.json │ │ │ ├── ListEntitiesRequest.json │ │ │ ├── RetrieveDataRequest.json │ │ │ ├── QueryDataRequest.json │ │ │ └── WriteDataRequest.json │ └── main │ │ └── java │ │ └── com │ │ └── amazonaws │ │ └── appflow │ │ └── custom │ │ └── connector │ │ ├── model │ │ ├── connectorconfiguration │ │ │ ├── TriggerType.java │ │ │ ├── auth │ │ │ │ ├── OAuth2CustomPropType.java │ │ │ │ ├── OAuth2GrantType.java │ │ │ │ ├── OAuth2MethodType.java │ │ │ │ ├── OAuth2ContentType.java │ │ │ │ ├── CustomAuthConfig.java │ │ │ │ ├── AuthParameter.java │ │ │ │ ├── OAuth2CustomParameter.java │ │ │ │ └── AuthenticationConfig.java │ │ │ ├── TriggerFrequency.java │ │ │ ├── DataTransferType.java │ │ │ ├── ConnectorModes.java │ │ │ ├── ConnectorOperator.java │ │ │ └── DescribeConnectorConfigurationRequest.java │ │ ├── write │ │ │ ├── WriteOperationType.java │ │ │ ├── WriteRecordResult.java │ │ │ ├── WriteDataResponse.java │ │ │ └── WriteDataRequest.java │ │ ├── settings │ │ │ ├── ConnectorRuntimeSettingDataType.java │ │ │ ├── ConnectorRuntimeSettingScope.java │ │ │ ├── ValidateConnectorRuntimeSettingsResponse.java │ │ │ ├── ValidateConnectorRuntimeSettingsRequest.java │ │ │ └── ConnectorRuntimeSetting.java │ │ ├── metadata │ │ │ ├── FieldDataType.java │ │ │ ├── RangeConstraint.java │ │ │ ├── EntityDefinition.java │ │ │ ├── ReadOperationProperty.java │ │ │ ├── DescribeEntityRequest.java │ │ │ ├── DescribeEntityResponse.java │ │ │ ├── FieldConstraints.java │ │ │ ├── ListEntitiesResponse.java │ │ │ ├── Entity.java │ │ │ ├── ListEntitiesRequest.java │ │ │ └── WriteOperationProperty.java │ │ ├── credentials │ │ │ ├── AuthenticationType.java │ │ │ ├── BasicAuthCredentials.java │ │ │ ├── ApiKeyCredentials.java │ │ │ ├── OAuth2Credentials.java │ │ │ ├── ValidateCredentialsResponse.java │ │ │ ├── CustomAuthCredentials.java │ │ │ ├── Credentials.java │ │ │ └── ValidateCredentialsRequest.java │ │ ├── ErrorDetails.java │ │ ├── ConnectorRequestStyle.java │ │ ├── CacheControl.java │ │ ├── retreive │ │ │ ├── RetrieveDataResponse.java │ │ │ └── RetrieveDataRequest.java │ │ ├── query │ │ │ ├── QueryDataResponse.java │ │ │ └── QueryDataRequest.java │ │ ├── ErrorCode.java │ │ ├── ConnectorContext.java │ │ └── ConnectorRequest.java │ │ ├── util │ │ ├── DataFormatValidationException.java │ │ └── CustomObjectMapper.java │ │ ├── Constants.java │ │ └── handlers │ │ ├── MetadataHandler.java │ │ ├── RecordHandler.java │ │ └── ConfigurationHandler.java └── pom.xml ├── custom-connector-example ├── salesforce-example-test-files │ ├── salesforce-insert-file.csv │ ├── test-file-3.json │ ├── describe-connector-entity-validation-file.json │ ├── list-entities-validation-file.json │ └── test-file-2.json ├── Dockerfile ├── src │ ├── main │ │ ├── resources │ │ │ └── log4j2.xml │ │ └── java │ │ │ └── com │ │ │ └── amazonaws │ │ │ └── appflow │ │ │ └── custom │ │ │ └── connector │ │ │ └── example │ │ │ ├── SalesforceResponse.java │ │ │ ├── configuration │ │ │ ├── ConnectorSettingKey.java │ │ │ └── SupportedSalesforceVersion.java │ │ │ ├── handler │ │ │ └── SalesforceLambdaHandler.java │ │ │ ├── query │ │ │ └── QueryObject.java │ │ │ └── parser │ │ │ ├── AbstractParser.java │ │ │ └── RecordResponseParser.java │ └── test │ │ └── java │ │ └── com │ │ └── amazonaws │ │ └── appflow │ │ └── custom │ │ └── connector │ │ └── example │ │ └── integ │ │ └── SalesforceTestDataProvider.java ├── testng.xml └── template.yml ├── images ├── appflow-console-home.png ├── appflow-console-create-flow.png ├── appflow-console-connector-label.png ├── appflow-console-connectors-page.png ├── appflow-console-lambda-function.png ├── appflow-console-test-connector.png ├── appflow-console-connection-details.png ├── appflow-console-create-connection.png ├── appflow-console-registered-connector.png ├── appflow-console-custom-connectors-dropdown.png └── appflow-console-custom-connectors-view-details.png ├── CODE_OF_CONDUCT.md ├── checkstyle-suppressions.xml ├── custom-connector-integ-test └── src │ ├── base-test-config.json │ └── main │ └── java │ └── com │ └── amazonaws │ └── appflow │ └── custom │ └── connector │ └── integ │ ├── providers │ ├── DataProvider.java │ ├── AuthenticationType.java │ ├── TestCredentials.java │ └── ServiceProvider.java │ ├── util │ ├── PollingConfiguration.java │ └── S3Helper.java │ └── data │ ├── TestBucketConfiguration.java │ ├── CustomConnectorConfiguration.java │ ├── ListConnectorEntitiesTestConfiguration.java │ ├── DescribeConnectorEntityTestConfiguration.java │ ├── OnDemandToS3TestConfiguration.java │ ├── CustomConnectorProfileConfiguration.java │ ├── OnDemandFromS3TestConfiguration.java │ └── TestConfiguration.java ├── custom-connector-queryfilter └── src │ └── main │ ├── java │ └── com │ │ └── amazonaws │ │ └── appflow │ │ └── custom │ │ └── connector │ │ └── queryfilter │ │ ├── antlr │ │ ├── CustomConnectorQueryFilterLexer.tokens │ │ └── CustomConnectorQueryFilterParser.tokens │ │ ├── InvalidFilterExpressionException.java │ │ ├── SyntaxErrorReporter.java │ │ └── CustomConnectorParseTreeBuilder.java │ └── configuration │ └── grammar │ ├── CustomConnectorQueryFilterLexer.g4 │ └── CustomConnectorQueryFilterParser.g4 ├── .github └── workflows │ └── maven_build.yml ├── custom-connector-tests ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── amazonaws │ │ │ └── appflow │ │ │ └── custom │ │ │ └── connector │ │ │ └── tests │ │ │ ├── exceptions │ │ │ └── ValidationException.java │ │ │ ├── model │ │ │ ├── QueryRecordConfiguration.java │ │ │ ├── RetrieveRecordConfiguration.java │ │ │ ├── WriteRecordConfiguration.java │ │ │ └── TestConfig.java │ │ │ ├── resources │ │ │ ├── TestLogger.java │ │ │ └── TestContext.java │ │ │ ├── invokers │ │ │ └── ConnectorTestInvoker.java │ │ │ └── validation │ │ │ └── UrlValidator.java │ │ └── configuration │ │ └── TestConfig.json └── pom.xml ├── License and Notice.txt ├── ChangeLog.md └── custom-connector-tools ├── logFetcher.sh └── deploy.sh /custom-connector-sdk/src/test/resources/UnknownRequest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "UnknownRequest" 3 | } 4 | -------------------------------------------------------------------------------- /custom-connector-example/salesforce-example-test-files/salesforce-insert-file.csv: -------------------------------------------------------------------------------- 1 | Name,Description 2 | aaron,first account! -------------------------------------------------------------------------------- /images/appflow-console-home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-appflow-custom-connector-java/HEAD/images/appflow-console-home.png -------------------------------------------------------------------------------- /images/appflow-console-create-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-appflow-custom-connector-java/HEAD/images/appflow-console-create-flow.png -------------------------------------------------------------------------------- /images/appflow-console-connector-label.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-appflow-custom-connector-java/HEAD/images/appflow-console-connector-label.png -------------------------------------------------------------------------------- /images/appflow-console-connectors-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-appflow-custom-connector-java/HEAD/images/appflow-console-connectors-page.png -------------------------------------------------------------------------------- /images/appflow-console-lambda-function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-appflow-custom-connector-java/HEAD/images/appflow-console-lambda-function.png -------------------------------------------------------------------------------- /images/appflow-console-test-connector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-appflow-custom-connector-java/HEAD/images/appflow-console-test-connector.png -------------------------------------------------------------------------------- /images/appflow-console-connection-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-appflow-custom-connector-java/HEAD/images/appflow-console-connection-details.png -------------------------------------------------------------------------------- /images/appflow-console-create-connection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-appflow-custom-connector-java/HEAD/images/appflow-console-create-connection.png -------------------------------------------------------------------------------- /custom-connector-sdk/src/test/resources/DescribeConnectorConfigurationRequest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "DescribeConnectorConfigurationRequest", 3 | "locale": "en-US" 4 | } 5 | -------------------------------------------------------------------------------- /images/appflow-console-registered-connector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-appflow-custom-connector-java/HEAD/images/appflow-console-registered-connector.png -------------------------------------------------------------------------------- /images/appflow-console-custom-connectors-dropdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-appflow-custom-connector-java/HEAD/images/appflow-console-custom-connectors-dropdown.png -------------------------------------------------------------------------------- /images/appflow-console-custom-connectors-view-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-appflow-custom-connector-java/HEAD/images/appflow-console-custom-connectors-view-details.png -------------------------------------------------------------------------------- /custom-connector-sdk/src/test/resources/ValidateConnectorRuntimeSettingsRequest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "ValidateConnectorRuntimeSettingsRequest", 3 | "scope": "CONNECTOR_PROFILE", 4 | "connectorRuntimeSettings": { 5 | "instanceUrl": "https://www.example.com" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. -------------------------------------------------------------------------------- /custom-connector-example/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM public.ecr.aws/lambda/java:11 2 | 3 | # Copy function code and runtime dependencies from Maven layout 4 | COPY target/classes ${LAMBDA_TASK_ROOT} 5 | COPY target/dependency/* ${LAMBDA_TASK_ROOT}/lib/ 6 | 7 | # Set the CMD to your handler 8 | CMD [ "com.amazonaws.appflow.custom.connector.example.handler.SalesforceLambdaHandler::handleRequest" ] -------------------------------------------------------------------------------- /checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/test/resources/ValidateCredentialsRequest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "ValidateCredentialsRequest", 3 | "connectorRuntimeSettings": { 4 | "instanceUrl": "https://www.example.com" 5 | }, 6 | "credentials": { 7 | "basicAuthCredentials": { 8 | "userName": "testUser", 9 | "password": "testPassword" 10 | }, 11 | "apiKeyCredentials": null, 12 | "oAuth2Credentials": null, 13 | "customAuthCredentials": null 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/base-test-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourcePrefix": "string", 3 | "customConnectorConfigurations": [], 4 | "customConnectorProfileConfigurations": [], 5 | "testBucketConfiguration": 6 | { 7 | "bucketName":"string", 8 | "bucketPrefix":"string" 9 | }, 10 | "listConnectorEntitiesTestConfigurations": [], 11 | "describeConnectorEntityTestConfigurations":[], 12 | "onDemandFromS3TestConfigurations": [], 13 | "onDemandToS3TestConfigurations": [] 14 | } -------------------------------------------------------------------------------- /custom-connector-example/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{yyyy-MM-dd HH:mm:ss} %X{AWSRequestId} %-5p %c{1} - %m%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /custom-connector-example/testng.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/test/resources/DescribeEntityRequest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "DescribeEntityRequest", 3 | "entityIdentifier": "testId", 4 | "connectorContext": { 5 | "connectorRuntimeSettings": { 6 | "instanceUrl": "https://www.example.com" 7 | }, 8 | "credentials": { 9 | "basicAuthCredentials": { 10 | "userName": "testUser", 11 | "password": "testPassword" 12 | }, 13 | "apiKeyCredentials": null, 14 | "oAuth2Credentials": null, 15 | "customAuthCredentials": null 16 | }, 17 | "apiVersion": "V1.0", 18 | "entityDefinition": null 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /custom-connector-queryfilter/src/main/java/com/amazonaws/appflow/custom/connector/queryfilter/antlr/CustomConnectorQueryFilterLexer.tokens: -------------------------------------------------------------------------------- 1 | AND=1 2 | OR=2 3 | NOT=3 4 | TRUE=4 5 | FALSE=5 6 | GT=6 7 | GE=7 8 | LT=8 9 | LE=9 10 | EQ=10 11 | NE=11 12 | LIKE=12 13 | BETWEEN=13 14 | LPAREN=14 15 | RPAREN=15 16 | NULL=16 17 | IN=17 18 | LIMIT=18 19 | COMMA=19 20 | IDENTIFIER=20 21 | POS_INTEGER=21 22 | DECIMAL=22 23 | SINGLE_STRING=23 24 | DOUBLE_STRING=24 25 | EMPTY_SINGLE_STRING=25 26 | EMPTY_DOUBLE_STRING=26 27 | WS=27 28 | DATE=28 29 | DATETIME=29 30 | '>'=6 31 | '>='=7 32 | '<'=8 33 | '<='=9 34 | '='=10 35 | '!='=11 36 | '('=14 37 | ')'=15 38 | 'null'=16 39 | ','=19 40 | -------------------------------------------------------------------------------- /custom-connector-queryfilter/src/main/java/com/amazonaws/appflow/custom/connector/queryfilter/antlr/CustomConnectorQueryFilterParser.tokens: -------------------------------------------------------------------------------- 1 | AND=1 2 | OR=2 3 | NOT=3 4 | TRUE=4 5 | FALSE=5 6 | GT=6 7 | GE=7 8 | LT=8 9 | LE=9 10 | EQ=10 11 | NE=11 12 | LIKE=12 13 | BETWEEN=13 14 | LPAREN=14 15 | RPAREN=15 16 | NULL=16 17 | IN=17 18 | LIMIT=18 19 | COMMA=19 20 | IDENTIFIER=20 21 | POS_INTEGER=21 22 | DECIMAL=22 23 | SINGLE_STRING=23 24 | DOUBLE_STRING=24 25 | EMPTY_SINGLE_STRING=25 26 | EMPTY_DOUBLE_STRING=26 27 | WS=27 28 | DATE=28 29 | DATETIME=29 30 | '>'=6 31 | '>='=7 32 | '<'=8 33 | '<='=9 34 | '='=10 35 | '!='=11 36 | '('=14 37 | ')'=15 38 | 'null'=16 39 | ','=19 40 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/test/resources/ListEntitiesRequest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "ListEntitiesRequest", 3 | "entitiesPath": "testPath", 4 | "maxResult": 1000, 5 | "nextToken": null, 6 | "connectorContext": { 7 | "connectorRuntimeSettings": { 8 | "instanceUrl": "https://www.example.com" 9 | }, 10 | "credentials": { 11 | "basicAuthCredentials": { 12 | "userName": "testUser", 13 | "password": "testPassword" 14 | }, 15 | "apiKeyCredentials": null, 16 | "oAuth2Credentials": null, 17 | "customAuthCredentials": null 18 | }, 19 | "apiVersion": "V1.0", 20 | "entityDefinition": null 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/test/resources/RetrieveDataRequest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "RetrieveDataRequest", 3 | "entityIdentifier": "testIdentifier", 4 | "selectedFieldNames": null, 5 | "idFieldName": null, 6 | "ids": null, 7 | "connectorContext": { 8 | "connectorRuntimeSettings": { 9 | "instanceUrl": "https://www.example.com" 10 | }, 11 | "credentials": { 12 | "basicAuthCredentials": { 13 | "userName": "testUser", 14 | "password": "testPassword" 15 | }, 16 | "apiKeyCredentials": null, 17 | "oAuth2Credentials": null, 18 | "customAuthCredentials": null 19 | }, 20 | "apiVersion": "V1.0", 21 | "entityDefinition": null 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/test/resources/QueryDataRequest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "QueryDataRequest", 3 | "entityIdentifier": "testIdentifier", 4 | "selectedFieldNames": null, 5 | "filterExpression": null, 6 | "nextToken": null, 7 | "connectorContext": { 8 | "connectorRuntimeSettings": { 9 | "instanceUrl": "https://www.example.com" 10 | }, 11 | "credentials": { 12 | "basicAuthCredentials": { 13 | "userName": "testUser", 14 | "password": "testPassword" 15 | }, 16 | "apiKeyCredentials": null, 17 | "oAuth2Credentials": null, 18 | "customAuthCredentials": null 19 | }, 20 | "apiVersion": "V1.0", 21 | "entityDefinition": null 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/test/resources/WriteDataRequest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "WriteDataRequest", 3 | "entityIdentifier": "testIdentifier", 4 | "operation": "INSERT", 5 | "idFieldNames": null, 6 | "records": null, 7 | "allOrNone": null, 8 | "connectorContext": { 9 | "connectorRuntimeSettings": { 10 | "instanceUrl": "https://www.example.com" 11 | }, 12 | "credentials": { 13 | "basicAuthCredentials": { 14 | "userName": "testUser", 15 | "password": "testPassword" 16 | }, 17 | "apiKeyCredentials": null, 18 | "oAuth2Credentials": null, 19 | "customAuthCredentials": null 20 | }, 21 | "apiVersion": "V1.0", 22 | "entityDefinition": null 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.github/workflows/maven_build.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: BuildSDK 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | pull_request: 10 | branches: [ main ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v3 19 | - name: Set up JDK 11 20 | uses: actions/setup-java@v3 21 | with: 22 | java-version: '11' 23 | distribution: 'temurin' 24 | cache: maven 25 | - name: Build src with Maven 26 | run: mvn compile -Dcheckstyle.skip 27 | - name: Build tst with Maven 28 | run: mvn test-compile -Dcheckstyle.skip 29 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/TriggerType.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Amazon AppFlow Custom Connector SDK 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration; 21 | 22 | /** 23 | * Enum for trigger type. 24 | */ 25 | public enum TriggerType { 26 | SCHEDULED, ONDEMAND 27 | } 28 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/auth/OAuth2CustomPropType.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-sdk 4 | * %% 5 | * Copyright (C) 2021 - 2022 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration.auth; 21 | 22 | public enum OAuth2CustomPropType { 23 | 24 | TOKEN_URL, 25 | 26 | AUTH_URL; 27 | } 28 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/auth/OAuth2GrantType.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Amazon AppFlow Custom Connector SDK 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration.auth; 21 | 22 | public enum OAuth2GrantType { 23 | 24 | CLIENT_CREDENTIALS, 25 | 26 | AUTHORIZATION_CODE; 27 | } 28 | -------------------------------------------------------------------------------- /custom-connector-tests/src/main/java/com/amazonaws/appflow/custom/connector/tests/exceptions/ValidationException.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * custom-connector-tests 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.tests.exceptions; 21 | 22 | public class ValidationException extends RuntimeException { 23 | public ValidationException(final String message) { 24 | super(message); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/write/WriteOperationType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.write; 26 | 27 | /** 28 | * Enum for Write operation type. 29 | */ 30 | public enum WriteOperationType { 31 | INSERT, 32 | UPDATE, 33 | UPSERT, 34 | DELETE 35 | } 36 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/providers/DataProvider.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.providers; 21 | 22 | /** 23 | * Interface that can be implemented as part of the destination flow test case in order to create the sample data 24 | * used in during flow execution. 25 | */ 26 | public interface DataProvider { 27 | 28 | String GenerateData(); 29 | } 30 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/util/PollingConfiguration.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.util; 21 | 22 | import org.immutables.value.Value; 23 | 24 | @Value.Immutable 25 | public interface PollingConfiguration { 26 | int maxPollTimeS(); 27 | 28 | int timeBetweenPollsS(); 29 | 30 | String executionId(); 31 | 32 | String flowName(); 33 | } 34 | -------------------------------------------------------------------------------- /custom-connector-tests/src/main/java/com/amazonaws/appflow/custom/connector/tests/model/QueryRecordConfiguration.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * custom-connector-tests 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.tests.model; 21 | 22 | import lombok.Getter; 23 | import lombok.Setter; 24 | 25 | import java.util.List; 26 | 27 | @Getter 28 | @Setter 29 | public class QueryRecordConfiguration { 30 | String entityIdentifier; 31 | List selectedFieldNames; 32 | String filterExpression; 33 | } 34 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/TriggerFrequency.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration; 26 | 27 | /** 28 | * Enum for Flow trigger frequency. 29 | */ 30 | public enum TriggerFrequency { 31 | BYMINUTE, 32 | HOURLY, 33 | DAILY, 34 | WEEKLY, 35 | MONTHLY, 36 | ONCE 37 | } 38 | -------------------------------------------------------------------------------- /custom-connector-tests/src/main/java/com/amazonaws/appflow/custom/connector/tests/model/RetrieveRecordConfiguration.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * custom-connector-tests 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.tests.model; 21 | 22 | import lombok.Getter; 23 | import lombok.Setter; 24 | 25 | import java.util.List; 26 | 27 | @Getter 28 | @Setter 29 | public class RetrieveRecordConfiguration { 30 | String entityIdentifier; 31 | List selectedFieldNames; 32 | String idFieldName; 33 | List ids; 34 | } 35 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/settings/ConnectorRuntimeSettingDataType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.settings; 26 | 27 | /** 28 | * Enum for connector runtime setting data type. 29 | */ 30 | public enum ConnectorRuntimeSettingDataType { 31 | String, 32 | Date, 33 | DateTime, 34 | Long, 35 | Integer, 36 | Boolean, 37 | Url 38 | } 39 | -------------------------------------------------------------------------------- /custom-connector-example/src/test/java/com/amazonaws/appflow/custom/connector/example/integ/SalesforceTestDataProvider.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.example.integ; 21 | 22 | import com.amazonaws.appflow.custom.connector.integ.providers.DataProvider; 23 | 24 | public class SalesforceTestDataProvider implements DataProvider { 25 | 26 | @Override 27 | public String GenerateData() { 28 | return "Name,Description\naaron,\"first account!\""; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /custom-connector-example/template.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: 'AWS::Serverless-2016-10-31' 3 | Description: Template to deploy the lambda connector in your account. 4 | Resources: 5 | Function: 6 | Type: 'AWS::Serverless::Function' 7 | Properties: 8 | Handler: "com.amazonaws.appflow.custom.connector.example.handler.SalesforceLambdaHandler::handleRequest" 9 | CodeUri: "./target/custom-connector-example-1.0.7.jar" 10 | Description: "Example for writing and deploying your AppFlow connector" 11 | Runtime: java8 12 | Timeout: 30 13 | MemorySize: 256 14 | Policies: 15 | Version: '2012-10-17' 16 | Statement: 17 | Effect: Allow 18 | Action: 'secretsmanager:GetSecretValue' 19 | Resource: !Sub 'arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:appflow!${AWS::AccountId}--*' 20 | PolicyPermission: 21 | Type: 'AWS::Lambda::Permission' 22 | Properties: 23 | FunctionName: !GetAtt Function.Arn 24 | Action: lambda:InvokeFunction 25 | Principal: 'appflow.amazonaws.com' 26 | SourceAccount: !Ref 'AWS::AccountId' 27 | SourceArn: !Sub 'arn:aws:appflow:${AWS::Region}:${AWS::AccountId}:*' 28 | -------------------------------------------------------------------------------- /custom-connector-queryfilter/src/main/java/com/amazonaws/appflow/custom/connector/queryfilter/InvalidFilterExpressionException.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Amazon AppFlow Custom Connector SDK 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.queryfilter; 21 | 22 | /** 23 | * This exception is thrown when invalid filter expression as an input to the query expression parser 24 | */ 25 | public class InvalidFilterExpressionException extends RuntimeException { 26 | 27 | public InvalidFilterExpressionException(final String msg) { 28 | super(msg, null); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /custom-connector-example/src/main/java/com/amazonaws/appflow/custom/connector/example/SalesforceResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.example; 26 | 27 | import org.immutables.value.Value; 28 | 29 | import javax.annotation.Nullable; 30 | 31 | /** 32 | * Class contains Salesforce response. 33 | */ 34 | @Value.Immutable 35 | public interface SalesforceResponse { 36 | int statusCode(); 37 | 38 | @Nullable 39 | String response(); 40 | 41 | String errorReason(); 42 | } 43 | -------------------------------------------------------------------------------- /custom-connector-tests/src/main/java/com/amazonaws/appflow/custom/connector/tests/resources/TestLogger.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * custom-connector-tests 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.tests.resources; 21 | 22 | import com.amazonaws.services.lambda.runtime.LambdaLogger; 23 | 24 | public class TestLogger implements LambdaLogger { 25 | @Override 26 | public void log(final String message) { 27 | //Intentionally blank for tests 28 | } 29 | 30 | @Override 31 | public void log(final byte[] message) { 32 | //Intentionally blank for tests 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/auth/OAuth2MethodType.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-sdk 4 | * %% 5 | * Copyright (C) 2021 - 2022 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration.auth; 21 | 22 | /** 23 | * OAuth2 Http method to use for the token request. AppFlow uses this when making login requests. 24 | * Default: POST 25 | */ 26 | public enum OAuth2MethodType { 27 | 28 | /** 29 | * POST method type 30 | */ 31 | HTTP_POST, 32 | 33 | /** 34 | * GET method type 35 | */ 36 | HTTP_GET 37 | } 38 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/metadata/FieldDataType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.metadata; 26 | 27 | /** 28 | * Data Type of a field 29 | */ 30 | public enum FieldDataType { 31 | String, 32 | Integer, 33 | Float, 34 | Double, 35 | Long, 36 | Short, 37 | BigInteger, 38 | BigDecimal, 39 | ByteArray, 40 | Boolean, 41 | Date, 42 | DateTime, 43 | Struct, 44 | Map, 45 | List 46 | } 47 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/providers/AuthenticationType.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.providers; 21 | 22 | /** 23 | * Authentication types supported by the SDK interface. 24 | */ 25 | public enum AuthenticationType { 26 | OAUTH2("OAuth2"), 27 | BASIC("Basic"), 28 | API_KEY("ApiKey"), 29 | CUSTOM("Custom"), 30 | NO_AUTH("NoAuth"); 31 | 32 | private final String type; 33 | 34 | AuthenticationType(final String type) { 35 | this.type = type; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /License and Notice.txt: -------------------------------------------------------------------------------- 1 | Amazon AppFlow Custom Connector Software Developer Kit License Agreement 2 | Copyright 2022 Amazon Web Services, Inc. or its affiliates. All Rights Reserved. 3 | 4 | By installing or using this software development kit ("Software"), you agree to 5 | the AWS Customer Agreement (https://aws.amazon.com/agreement) or other agreement 6 | with Amazon Web Services, Inc. ("AWS") governing your use of services provided by 7 | AWS, including the AWS Service Terms (https://aws.amazon.com/service-terms). 8 | The Software is AWS Content, and you may install and use the Software solely for 9 | the purpose of use with Amazon AppFlow in accordance with the Documentation. 10 | 11 | Certain components of the Software contain third party software programs which 12 | are governed by separate licenses, including but not limited to open source 13 | software licenses, identified in the included "THIRD PARTY ATTRIBUTIONS" file. 14 | Your rights and obligations with respect to these components are defined by the 15 | applicable software license, and nothing in this agreement will restrict, limit, 16 | or otherwise affect your rights or obligations under such software licenses. 17 | 18 | 19 | To learn more about the Amazon AppFlow Custom Connector Software Developer Kit see: 20 | https://docs.aws.amazon.com/appflow/ 21 | -------------------------------------------------------------------------------- /custom-connector-tests/src/main/java/com/amazonaws/appflow/custom/connector/tests/model/WriteRecordConfiguration.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * custom-connector-tests 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.tests.model; 21 | 22 | import com.amazonaws.appflow.custom.connector.model.write.WriteOperationType; 23 | import lombok.Getter; 24 | import lombok.Setter; 25 | 26 | import java.util.List; 27 | 28 | @Getter 29 | @Setter 30 | public class WriteRecordConfiguration { 31 | String entityIdentifier; 32 | WriteOperationType operation; 33 | List idFieldNames; 34 | List records; 35 | boolean allOrNone; 36 | } 37 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/credentials/AuthenticationType.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Amazon AppFlow Custom Connector SDK 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.model.credentials; 21 | 22 | /** 23 | * Enum of Authentication Types. 24 | */ 25 | public enum AuthenticationType { 26 | /** 27 | * Basic Authentication. 28 | */ 29 | BasicAuth, 30 | 31 | /** 32 | * OAuth2 Authentication. 33 | */ 34 | OAuth2, 35 | 36 | /** 37 | * ApiKey Authentication. 38 | */ 39 | ApiKey, 40 | 41 | /** 42 | * Custom Authentication. 43 | */ 44 | CustomAuth 45 | } 46 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/auth/OAuth2ContentType.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-sdk 4 | * %% 5 | * Copyright (C) 2021 - 2022 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration.auth; 21 | 22 | /** 23 | * OAuth2 Content type to use in the token request header. AppFlow uses this when making login requests. 24 | * Default: URL_ENCODED 25 | */ 26 | public enum OAuth2ContentType { 27 | 28 | /** 29 | * Content Type is: "application/x-www-form-urlencoded" 30 | */ 31 | URL_ENCODED, 32 | 33 | /** 34 | * Content Type is: "application/json" 35 | */ 36 | APPLICATION_JSON 37 | } 38 | -------------------------------------------------------------------------------- /custom-connector-example/src/main/java/com/amazonaws/appflow/custom/connector/example/configuration/ConnectorSettingKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Example Custom Connector. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.example.configuration; 26 | 27 | /** 28 | * This class consists constants for Salesforce Connector setting keys. 29 | */ 30 | public final class ConnectorSettingKey { 31 | private ConnectorSettingKey() { 32 | } 33 | 34 | public static final String INSTANCE_URL = "instanceUrl"; 35 | public static final String API_VERSION = "api_version"; 36 | public static final String IS_SANDBOX_ACCOUNT = "IsSandboxAccount"; 37 | } 38 | -------------------------------------------------------------------------------- /custom-connector-example/src/main/java/com/amazonaws/appflow/custom/connector/example/handler/SalesforceLambdaHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Example Custom Connector. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.example.handler; 26 | 27 | import com.amazonaws.appflow.custom.connector.lambda.handler.BaseLambdaConnectorHandler; 28 | 29 | /** 30 | * Lambda entry point for Salesforce. 31 | */ 32 | public class SalesforceLambdaHandler extends BaseLambdaConnectorHandler { 33 | 34 | public SalesforceLambdaHandler() { 35 | super(new SalesforceMetadataHandler(), new SalesforceRecordHandler(), new SalesforceConfigurationHandler()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/DataTransferType.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-sdk 4 | * %% 5 | * Copyright (C) 2021 - 2023 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration; 21 | 22 | /** 23 | * Enum class representing the types of data transfers. 24 | */ 25 | public enum DataTransferType { 26 | /** 27 | * Represents data transfer in the form of records. This type is used when data transfer involves structured records. 28 | */ 29 | RECORD, 30 | /** 31 | * Represents data transfer in the form of files. This type is used when data transfer involves files or binary data. 32 | */ 33 | FILE 34 | } 35 | -------------------------------------------------------------------------------- /custom-connector-example/src/main/java/com/amazonaws/appflow/custom/connector/example/configuration/SupportedSalesforceVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Example Custom Connector. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.example.configuration; 26 | 27 | /** 28 | * Enum of supported salesforce versions. 29 | */ 30 | public enum SupportedSalesforceVersion { 31 | V51("v51.0"); 32 | 33 | private final String versionNumber; 34 | 35 | SupportedSalesforceVersion(final String versionNumber) { 36 | this.versionNumber = versionNumber; 37 | } 38 | 39 | public String getVersionNumber() { 40 | return this.versionNumber; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/ConnectorModes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration; 26 | 27 | /** 28 | * Enumerates the supported connector Modes. Used by Connectors to declare the modes of operation a custom connector 29 | * supports. 30 | */ 31 | public enum ConnectorModes { 32 | /** 33 | * Connector contains implementation for retrieveData and queryData. 34 | */ 35 | SOURCE, 36 | /** 37 | * Connector contains implementation for writeData. 38 | */ 39 | DESTINATION 40 | } 41 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/util/DataFormatValidationException.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-sdk 4 | * %% 5 | * Copyright (C) 2021 - 2023 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.util; 21 | 22 | /** 23 | * Exception that is thrown when the Data does not match the SDK format. 24 | */ 25 | public class DataFormatValidationException extends Exception { 26 | 27 | public DataFormatValidationException() { 28 | super(); 29 | } 30 | 31 | public DataFormatValidationException(final String message) { 32 | super(message); 33 | } 34 | 35 | public DataFormatValidationException(final String message, final Exception e) { 36 | super(message, e); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/data/TestBucketConfiguration.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.data; 21 | 22 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 23 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 24 | import org.immutables.value.Value; 25 | 26 | /** 27 | * Refer to sample-test-config.json 28 | */ 29 | @Value.Immutable 30 | @JsonDeserialize(as = ImmutableTestBucketConfiguration.class) 31 | @JsonSerialize(as = ImmutableTestBucketConfiguration.class) 32 | public interface TestBucketConfiguration { 33 | 34 | String bucketName(); 35 | 36 | String bucketPrefix(); 37 | } 38 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/data/CustomConnectorConfiguration.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.data; 21 | 22 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 23 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 24 | import org.immutables.value.Value; 25 | 26 | import java.util.Optional; 27 | 28 | /** 29 | * Refer to sample-test-config.json 30 | */ 31 | @Value.Immutable 32 | @JsonDeserialize(as = ImmutableCustomConnectorConfiguration.class) 33 | @JsonSerialize(as = ImmutableCustomConnectorConfiguration.class) 34 | public interface CustomConnectorConfiguration { 35 | 36 | String lambdaArn(); 37 | 38 | String name(); 39 | 40 | Optional validationFileName(); 41 | } 42 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/credentials/BasicAuthCredentials.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.credentials; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | /** 32 | * Credentials for Basic authentication. 33 | */ 34 | @Value.Immutable 35 | @JsonSerialize(as = ImmutableBasicAuthCredentials.class) 36 | @JsonDeserialize(as = ImmutableBasicAuthCredentials.class) 37 | public interface BasicAuthCredentials { 38 | /** 39 | * Username. 40 | */ 41 | String userName(); 42 | 43 | /** 44 | * Password. 45 | */ 46 | String password(); 47 | } 48 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/credentials/ApiKeyCredentials.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.credentials; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import javax.annotation.Nullable; 32 | 33 | /** 34 | * Credentials for ApiKey authentication. 35 | */ 36 | @Value.Immutable 37 | @JsonSerialize(as = ImmutableApiKeyCredentials.class) 38 | @JsonDeserialize(as = ImmutableApiKeyCredentials.class) 39 | public interface ApiKeyCredentials { 40 | /** 41 | * API key. 42 | */ 43 | String apiKey(); 44 | 45 | /** 46 | * Secret key. 47 | */ 48 | @Nullable 49 | String secretKey(); 50 | } 51 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/metadata/RangeConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.metadata; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import java.math.BigDecimal; 32 | 33 | /** 34 | * Represents the range for a field. 35 | */ 36 | @Value.Immutable 37 | @JsonSerialize(as = ImmutableRangeConstraint.class) 38 | @JsonDeserialize(as = ImmutableRangeConstraint.class) 39 | public interface RangeConstraint { 40 | /** 41 | * Minimum value of the range. 42 | */ 43 | BigDecimal minRange(); 44 | 45 | /** 46 | * Maximum value of the range. 47 | */ 48 | BigDecimal maxRange(); 49 | } 50 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/providers/TestCredentials.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.providers; 21 | 22 | import com.amazonaws.appflow.custom.connector.model.credentials.Credentials; 23 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 24 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 25 | import org.immutables.value.Value; 26 | 27 | import java.util.Optional; 28 | 29 | /** 30 | * Contains the test credentials required to create the connector profile. 31 | */ 32 | @Value.Immutable 33 | @JsonDeserialize(as = ImmutableTestCredentials.class) 34 | @JsonSerialize(as = ImmutableTestCredentials.class) 35 | public interface TestCredentials { 36 | 37 | Optional credentials(); 38 | 39 | Optional clientId(); 40 | 41 | Optional clientSecret(); 42 | } 43 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/credentials/OAuth2Credentials.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.credentials; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import javax.annotation.Nullable; 32 | 33 | /** 34 | * Credentials for OAuth2 authentication. 35 | */ 36 | @Value.Immutable 37 | @JsonSerialize(as = ImmutableOAuth2Credentials.class) 38 | @JsonDeserialize(as = ImmutableOAuth2Credentials.class) 39 | public interface OAuth2Credentials { 40 | /** 41 | * Access Token. 42 | */ 43 | String accessToken(); 44 | 45 | /** 46 | * Refresh Token. 47 | */ 48 | @Nullable 49 | String refreshToken(); 50 | } 51 | -------------------------------------------------------------------------------- /custom-connector-example/salesforce-example-test-files/test-file-3.json: -------------------------------------------------------------------------------- 1 | { 2 | "customConnectorConfigurations": [ 3 | { 4 | "name": "connector1", 5 | "lambdaArn": "arn:aws:lambda:us-west-2:*********:function:custom-connector-function-xomoZvWcPYLp", 6 | "validationFileName": "describe-connector-validation-file.json" 7 | } 8 | ], 9 | "customConnectorProfileConfigurations": [ 10 | { 11 | "connectorName": "connector1", 12 | "name": "profile1", 13 | "profileProperties": { 14 | "api_version": "v51.0", 15 | "instanceUrl": "https://*********.my.salesforce.com" 16 | }, 17 | "defaultApiVersion": "v51.0", 18 | "authenticationType": "OAUTH2", 19 | "oAuth2Properties": { 20 | "oAuth2GrantType": "CLIENT_CREDENTIALS", 21 | "tokenUrl": "https://login.salesforce.com/services/oauth2/token", 22 | "refreshUrl":"https://login.salesforce.com/services/oauth2/token" 23 | }, 24 | "secretsManagerArn": "arn:aws:secretsmanager:us-west-2:*********:secret:custom-connector-qrSqOc" 25 | } 26 | ], 27 | "testBucketConfiguration": { 28 | "bucketName": "cvs-beta", 29 | "bucketPrefix": "" 30 | }, 31 | "listConnectorEntitiesTestConfigurations": [ 32 | { 33 | "validationFileName": "list-entities-validation-file.json" 34 | } 35 | ], 36 | "describeConnectorEntityTestConfigurations": [ 37 | { 38 | "validationFileName": "describe-connector-entity-validation-file.json", 39 | "entityName" : "Account" 40 | } 41 | ], 42 | "onDemandFromS3TestConfigurations": [ 43 | ], 44 | "onDemandToS3TestConfigurations": [ 45 | ] 46 | } -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/Constants.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Amazon AppFlow Custom Connector SDK 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector; 21 | 22 | public final class Constants { 23 | private Constants(){ 24 | } 25 | 26 | public static final Long MAX_RESULT_SIZE = 1000L; 27 | public static final String AUTHENTICATION_TYPE = "authenticationType"; 28 | 29 | //BasicAuthCredentials Constants 30 | public static final String USERNAME = "username"; 31 | public static final String PASSWORD = "password"; 32 | 33 | //ApiKeyCredentials Constants 34 | public static final String API_KEY = "apiKey"; 35 | public static final String SECRET_KEY = "apiSecretKey"; 36 | 37 | //OAuth2Credentials Constants 38 | public static final String ACCESS_TOKEN = "accessToken"; 39 | 40 | //CustomAuthCredentials Constant 41 | public static final String CUSTOM_AUTHENTICATION_TYPE = "customAuthenticationType"; 42 | } 43 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/data/ListConnectorEntitiesTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.data; 21 | 22 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 23 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 24 | import org.immutables.value.Value; 25 | 26 | import java.util.Optional; 27 | 28 | /** 29 | * Refer to sample-test-config.json 30 | */ 31 | @Value.Immutable 32 | @JsonDeserialize(as = ImmutableListConnectorEntitiesTestConfiguration.class) 33 | @JsonSerialize(as = ImmutableListConnectorEntitiesTestConfiguration.class) 34 | public interface ListConnectorEntitiesTestConfiguration { 35 | Optional entitiesPath(); 36 | 37 | Optional validationFileName(); 38 | 39 | Optional profileName(); 40 | 41 | Optional testName(); 42 | 43 | Optional apiVersion(); 44 | } 45 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/data/DescribeConnectorEntityTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.data; 21 | 22 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 23 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 24 | import org.immutables.value.Value; 25 | 26 | import java.util.Optional; 27 | 28 | /** 29 | * Refer to sample-test-config.json 30 | */ 31 | @Value.Immutable 32 | @JsonDeserialize(as = ImmutableDescribeConnectorEntityTestConfiguration.class) 33 | @JsonSerialize(as = ImmutableDescribeConnectorEntityTestConfiguration.class) 34 | public interface DescribeConnectorEntityTestConfiguration { 35 | 36 | String entityName(); 37 | 38 | Optional validationFileName(); 39 | 40 | Optional profileName(); 41 | 42 | Optional testName(); 43 | 44 | Optional apiVersion(); 45 | } 46 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/auth/CustomAuthConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration.auth; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import java.util.List; 32 | 33 | /** 34 | * Represents the Custom authentication configuration. 35 | */ 36 | @Value.Immutable 37 | @JsonSerialize(as = ImmutableCustomAuthConfig.class) 38 | @JsonDeserialize(as = ImmutableCustomAuthConfig.class) 39 | public interface CustomAuthConfig { 40 | /** 41 | * AuthenticationType string value defined by Connector. 42 | */ 43 | String authenticationType(); 44 | 45 | /** 46 | * List of Auth Parameters. 47 | */ 48 | List authParameters(); 49 | } 50 | -------------------------------------------------------------------------------- /custom-connector-example/salesforce-example-test-files/describe-connector-entity-validation-file.json: -------------------------------------------------------------------------------- 1 | { 2 | "connectorEntityFields": [ 3 | { 4 | "identifier": "Id", 5 | "label": "Account ID", 6 | "isPrimaryKey": false, 7 | "defaultValue": null, 8 | "isDeprecated": false, 9 | "supportedFieldTypeDetails": { 10 | "v1": { 11 | "fieldType": "String", 12 | "filterOperators": [ 13 | "CONTAINS", 14 | "EQUAL_TO", 15 | "NOT_EQUAL_TO" 16 | ], 17 | "supportedValues": [ 18 | ], 19 | "valueRegexPattern": null, 20 | "supportedDateFormat": null, 21 | "fieldValueRange": null, 22 | "fieldLengthRange": null 23 | } 24 | }, 25 | "description": "Account ID", 26 | "sourceProperties": { 27 | "isRetrievable": true, 28 | "isQueryable": true, 29 | "isTimestampFieldForIncrementalQueries": false, 30 | "queryable": true, 31 | "retrievable": true, 32 | "timestampFieldForIncrementalQueries": false 33 | }, 34 | "destinationProperties": { 35 | "isCreatable": false, 36 | "isNullable": false, 37 | "isUpsertable": false, 38 | "isUpdatable": false, 39 | "isDefaultedOnCreate": true, 40 | "supportedWriteOperations": [ 41 | "UPSERT", 42 | "UPDATE" 43 | ], 44 | "defaultedOnCreate": true, 45 | "updatable": false, 46 | "nullable": false, 47 | "creatable": false, 48 | "upsertable": false 49 | }, 50 | "customProperties": null, 51 | "primaryKey": false, 52 | "deprecated": false 53 | } 54 | ] 55 | } -------------------------------------------------------------------------------- /custom-connector-tests/src/main/java/com/amazonaws/appflow/custom/connector/tests/model/TestConfig.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * custom-connector-tests 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.tests.model; 21 | 22 | import com.amazonaws.appflow.custom.connector.model.credentials.Credentials; 23 | import lombok.Getter; 24 | import lombok.NoArgsConstructor; 25 | import lombok.Setter; 26 | 27 | import java.util.List; 28 | import java.util.Map; 29 | 30 | @NoArgsConstructor 31 | @Getter 32 | @Setter 33 | public class TestConfig { 34 | RuntimeSettings runtimeSettings; 35 | Credentials credentials; 36 | String testEntityIdentifier; 37 | List retrieveRecordConfigurations; 38 | List writeRecordConfigurations; 39 | List queryRecordConfigurations; 40 | 41 | @Getter 42 | @Setter 43 | public static class RuntimeSettings { 44 | Map connectorProfile; 45 | Map source; 46 | Map destination; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /custom-connector-example/salesforce-example-test-files/list-entities-validation-file.json: -------------------------------------------------------------------------------- 1 | { 2 | "connectorEntityMap": { 3 | "Objects": [ 4 | { 5 | "name": "AIApplication", 6 | "label": "AI Application", 7 | "hasNestedEntities": false 8 | }, 9 | { 10 | "name": "AIApplicationConfig", 11 | "label": "AI Application config", 12 | "hasNestedEntities": false 13 | }, 14 | { 15 | "name": "AIInsightAction", 16 | "label": "AI Insight Action", 17 | "hasNestedEntities": false 18 | }, 19 | { 20 | "name": "AIInsightFeedback", 21 | "label": "AI Insight Feedback", 22 | "hasNestedEntities": false 23 | }, 24 | { 25 | "name": "AIInsightReason", 26 | "label": "AI Insight Reason", 27 | "hasNestedEntities": false 28 | }, 29 | { 30 | "name": "AIInsightValue", 31 | "label": "AI Insight Value", 32 | "hasNestedEntities": false 33 | }, 34 | { 35 | "name": "AIPredictionEvent", 36 | "label": "AI Prediction Event", 37 | "hasNestedEntities": false 38 | }, 39 | { 40 | "name": "AIRecordInsight", 41 | "label": "AI Record Insight", 42 | "hasNestedEntities": false 43 | }, 44 | { 45 | "name": "AcceptedEventRelation", 46 | "label": "Accepted Event Relation", 47 | "hasNestedEntities": false 48 | }, 49 | { 50 | "name": "Account", 51 | "label": "Account", 52 | "hasNestedEntities": false 53 | }, 54 | { 55 | "name": "AccountChangeEvent", 56 | "label": "Account Change Event", 57 | "hasNestedEntities": false 58 | } 59 | ] 60 | } 61 | } -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/ErrorDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import javax.annotation.Nullable; 32 | 33 | /** 34 | * Represents the error details. 35 | */ 36 | @Value.Immutable 37 | @JsonSerialize(as = ImmutableErrorDetails.class) 38 | @JsonDeserialize(as = ImmutableErrorDetails.class) 39 | public interface ErrorDetails { 40 | /** 41 | * Error Code. 42 | */ 43 | ErrorCode errorCode(); 44 | 45 | /** 46 | * Specifies the time delay in seconds after which operation can be retried. 47 | */ 48 | @Nullable 49 | Integer retryAfterSeconds(); 50 | 51 | /** 52 | * Detailed error message corresponding to the error code. 53 | */ 54 | String errorMessage(); 55 | } 56 | -------------------------------------------------------------------------------- /custom-connector-example/src/main/java/com/amazonaws/appflow/custom/connector/example/query/QueryObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Example Custom Connector. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.example.query; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.metadata.EntityDefinition; 28 | import org.immutables.value.Value; 29 | 30 | import javax.annotation.Nullable; 31 | import java.util.List; 32 | 33 | /** 34 | * Class contains all the information to build query. It might be deleted or method implementations might be changed 35 | * after adding Antlr parser code. 36 | */ 37 | @Value.Immutable 38 | public interface QueryObject { 39 | 40 | String sObject(); 41 | 42 | @Nullable 43 | List selectedFieldNames(); 44 | 45 | @Nullable 46 | String filterExpression(); 47 | 48 | @Nullable 49 | String idFieldName(); 50 | 51 | @Nullable 52 | List fields(); 53 | 54 | @Nullable 55 | String dataType(); 56 | 57 | @Nullable 58 | EntityDefinition entityDefinition(); 59 | } 60 | -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | 7 | ## [Unreleased] 8 | ## [1.0.9] - 2023-02-28 9 | ### Added 10 | - Added support for `LIMIT` in the query filter expression. 11 | - Added a JSON validator to validate that objects match the SDK format. 12 | - Added `Url` type in the ConnectorRuntimeSettingDataType. 13 | - Added `DataTransferType` ENUM and added supportedDataTransferTypes in DescribeConnectorConfigurationResponse 14 | 15 | ## [1.0.8] - 2022-12-21 16 | ### Added 17 | - Added support for subfields delimited by periods. 18 | 19 | ## [1.0.7] - 2022-10-21 20 | ### Added 21 | - Added support for Entity specific custom properties. 22 | 23 | ## [1.0.6] - 2022-08-16 24 | ### Added 25 | - Basic auth support for OAuth2. We need to add Base64 encoded Basic Auth header while making OAuth2 request in OAuth2 retrieve token scheme. 26 | - Removed ConnectorContext from validate creds request 27 | - Made api version nullable 28 | - Removed api version from connector runtime settings 29 | - Allowed hypen to be present in field names while generating the filter query 30 | 31 | ## [1.0.5] - 2022-05-27 32 | ### Added 33 | - Added OAuth2 enhancements like connector can define the EntityType and MethodType to get the token. 34 | - Added flag to support entity can be used as destination or not. 35 | 36 | ## [1.0.2] - 2022-03-04 37 | ### Added 38 | - Added ErrorCode for ResourceNotFound like AWS SecretManagerARN etc. 39 | 40 | ## [1.0.1] - 2022-03-01 41 | ### Added 42 | - Added ErrorCode for partial write failures. 43 | 44 | ### Changed 45 | - Updated documentation for `allOrNone` field in WriteDataRequest. 46 | - Updated documentation for `isSuccess` field in WriteDataResponse. -------------------------------------------------------------------------------- /custom-connector-tests/src/main/java/com/amazonaws/appflow/custom/connector/tests/invokers/ConnectorTestInvoker.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * custom-connector-tests 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.tests.invokers; 21 | 22 | /** 23 | * This interface defines the functionality that is required for testing custom connector implementation. 24 | * The tests must verify behavior of all three handlers along with some implementation specific validations. 25 | */ 26 | public interface ConnectorTestInvoker { 27 | 28 | /** 29 | * Tests for the ConfigurationHandler. This includes verifying behaviour of ValidateCredentials, 30 | * ValidateConnectorRuntimeSetting and DescribeConnectorConfiguration. 31 | */ 32 | void invokeConfigurationHandlerTests(); 33 | 34 | /** 35 | * Tests for the MetadataHandler. This includes verifying behaviour of ListEntities and DescribeEntity. 36 | */ 37 | void invokeMetadataHandlerTests(); 38 | 39 | /** 40 | * Tests for the RecordHandler. This includes verifying behaviour of RetrieveData, WriteData and QueryData. 41 | */ 42 | void invokeRecordHandlerTests(); 43 | } 44 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/credentials/ValidateCredentialsResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.credentials; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.ErrorDetails; 28 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 29 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 30 | import org.immutables.value.Value; 31 | 32 | import javax.annotation.Nullable; 33 | 34 | /** 35 | * Represents the output of a ValidateCredentials operation. 36 | */ 37 | @Value.Immutable 38 | @JsonSerialize(as = ImmutableValidateCredentialsResponse.class) 39 | @JsonDeserialize(as = ImmutableValidateCredentialsResponse.class) 40 | public interface ValidateCredentialsResponse { 41 | /** 42 | * Specifies if the operation is successful or not. 43 | */ 44 | boolean isSuccess(); 45 | 46 | /** 47 | * Error details if the Operation is unsuccessful. 48 | */ 49 | @Nullable 50 | ErrorDetails errorDetails(); 51 | } 52 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/write/WriteRecordResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.write; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import javax.annotation.Nullable; 32 | 33 | /** 34 | * Contains write result whether it is successful or not at record level. 35 | */ 36 | @Value.Immutable 37 | @JsonSerialize(as = ImmutableWriteRecordResult.class) 38 | @JsonDeserialize(as = ImmutableWriteRecordResult.class) 39 | public interface WriteRecordResult { 40 | /** 41 | * Specifies if the record is written successfully or not. 42 | */ 43 | boolean isSuccess(); 44 | 45 | /** 46 | * Unique identifier for the record. 47 | */ 48 | String recordId(); 49 | 50 | /** 51 | * Error message if the record is not written to the destination successfully. 52 | */ 53 | @Nullable 54 | String errorMessage(); 55 | } 56 | -------------------------------------------------------------------------------- /custom-connector-tests/src/main/configuration/TestConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeSettings": { 3 | "connectorProfile": { 4 | "instanceUrl": "https://amazon-1de-dev-ed.my.salesforce.com", 5 | "credentialsArn": "CredentialsArn", 6 | "api_version": "v51.0" 7 | } 8 | }, 9 | "credentials": { 10 | "secretArn": "" 11 | "authenticationType":"" 12 | } 13 | }, 14 | "testEntityIdentifier": "Account", 15 | "retrieveRecordConfigurations": [ 16 | { 17 | "entityIdentifier": "Account", 18 | "selectedFieldNames": [ 19 | "Name", 20 | "AccountNumber" 21 | ], 22 | "idFieldName": "AccountNumber", 23 | "ids": [ 24 | "12345" 25 | ] 26 | } 27 | ], 28 | "writeRecordConfigurations": [ 29 | { 30 | "entityIdentifier": "Account", 31 | "operation": "INSERT", 32 | "idFieldNames": [], 33 | "records": [ 34 | "{\"Name\": \"TestAccount\"}" 35 | ], 36 | "allOrNone": false 37 | }, 38 | { 39 | "entityIdentifier": "Account", 40 | "operation": "UPDATE", 41 | "idFieldNames": ["Id"], 42 | "records": [ 43 | "{\"Name\": \"UpdateOperationTest\", \"Id\": \"0015e00000USsUgAAL\"}" 44 | ], 45 | "allOrNone": false 46 | }, 47 | { 48 | "entityIdentifier": "Account", 49 | "operation": "UPSERT", 50 | "idFieldNames": ["ExternalId__c"], 51 | "records": [ 52 | "{\"Name\": \"UpsertOperationTestAccount\", \"ExternalId__c\": \"Identifier123\"}" 53 | ], 54 | "allOrNone": false 55 | } 56 | ], 57 | "queryRecordConfigurations": [ 58 | { 59 | "entityIdentifier": "Account", 60 | "selectedFieldNames": [ 61 | "Name", 62 | "AccountNumber" 63 | ], 64 | "filterExpression": "Name contains \"Test\"" 65 | } 66 | ] 67 | } 68 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/ConnectorRequestStyle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model; 26 | 27 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 28 | import com.fasterxml.jackson.annotation.JsonTypeName; 29 | import org.immutables.value.Value; 30 | 31 | import java.lang.annotation.ElementType; 32 | import java.lang.annotation.Retention; 33 | import java.lang.annotation.RetentionPolicy; 34 | import java.lang.annotation.Target; 35 | 36 | /** 37 | * Annotation to customize code generated for immutable values. 38 | */ 39 | @Target(ElementType.TYPE) 40 | @Retention(RetentionPolicy.CLASS) 41 | @Value.Style ( 42 | visibility = Value.Style.ImplementationVisibility.PUBLIC, // Generated class will be always public 43 | isInitialized = "wasInitialized", // Converting immutable internal method to avoid mapper deserialization issue 44 | create = "new", 45 | passAnnotations = {JsonTypeInfo.class, JsonTypeName.class}, 46 | jdkOnly = true 47 | ) 48 | public @interface ConnectorRequestStyle { 49 | } 50 | -------------------------------------------------------------------------------- /custom-connector-example/salesforce-example-test-files/test-file-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "customConnectorConfigurations":[ 3 | { 4 | "name":"connector1", 5 | "lambdaArn":"arn:aws:lambda:us-west-2:*********:function:custom-connector-function-xomoZvWcPYLp" 6 | } 7 | ], 8 | "customConnectorProfileConfigurations":[ 9 | { 10 | "connectorName":"connector1", 11 | "name":"profile1", 12 | "profileProperties":{ 13 | "api_version":"v51.0", 14 | "instanceUrl":"https://*********.my.salesforce.com" 15 | }, 16 | "defaultApiVersion": "v51.0", 17 | "authenticationType":"OAUTH2", 18 | "oAuth2Properties":{ 19 | "oAuth2GrantType":"CLIENT_CREDENTIALS", 20 | "tokenUrl":"https://login.salesforce.com/services/oauth2/token", 21 | "refreshUrl":"https://login.salesforce.com/services/oauth2/token" 22 | }, 23 | "secretsManagerArn":"arn:aws:secretsmanager:us-west-2:*********:secret:custom-connector-qrSqOc" 24 | } 25 | ], 26 | "testBucketConfiguration": 27 | { 28 | "bucketName":"cvs-beta", 29 | "bucketPrefix":"" 30 | }, 31 | "listConnectorEntitiesTestConfigurations":[ 32 | 33 | ], 34 | "describeConnectorEntityTestConfigurations":[ 35 | 36 | ], 37 | "onDemandFromS3TestConfigurations":[ 38 | { 39 | "flowName": "flow4", 40 | "entityName":"Account", 41 | "writeOperationType": "INSERT", 42 | "dataGeneratorClassName":"com.amazonaws.appflow.custom.connector.example.integ.SalesforceTestDataProvider", 43 | "destinationRuntimeSettings": {} 44 | }, 45 | { 46 | "flowName": "flow2", 47 | "entityName":"Account", 48 | "writeOperationType": "INSERT", 49 | "sourceDataFile":"salesforce-insert-file.csv", 50 | "destinationRuntimeSettings": {} 51 | } 52 | ], 53 | "onDemandToS3TestConfigurations":[ 54 | 55 | ] 56 | } -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/CacheControl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import javax.annotation.Nullable; 32 | import java.util.concurrent.TimeUnit; 33 | 34 | /** 35 | * Represents the caching policy for metadata for the supported entities. 36 | */ 37 | @Value.Immutable 38 | @JsonSerialize(as = ImmutableCacheControl.class) 39 | @JsonDeserialize(as = ImmutableCacheControl.class) 40 | public interface CacheControl { 41 | 42 | /** 43 | * Time to keep the metadata in cache. 44 | * 45 | * Return a large number when entity metadata is not dynamic and can 46 | * be cached for long time. The minimum allowed value is 600 seconds. 47 | */ 48 | long timeToLive(); 49 | 50 | /** 51 | * TimeUnit for the timeToLive. 52 | */ 53 | @Nullable 54 | TimeUnit timeToLiveUnit(); 55 | } 56 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/settings/ConnectorRuntimeSettingScope.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.settings; 26 | 27 | /** 28 | * Defines the scope for a given connector runtime setting. All connector runtime settings will be aggregated and will 29 | * be sent along with every function invocation on the connector. 30 | */ 31 | public enum ConnectorRuntimeSettingScope { 32 | /** 33 | * Settings to be populated during connector profile creation 34 | */ 35 | CONNECTOR_PROFILE, 36 | 37 | /** 38 | * Setting to be populated during a flow creation if the connector is chosen as a source connector. 39 | */ 40 | SOURCE, 41 | 42 | /** 43 | * Setting to be populated during a flow creation if the connector is chosen as a destination connector. 44 | */ 45 | DESTINATION, 46 | 47 | /** 48 | * Setting to be populated during a flow creation if the connector is chosen either as a source or a destination 49 | * connector. 50 | */ 51 | SOURCE_AND_DESTINATION 52 | } 53 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/metadata/EntityDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.metadata; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import javax.annotation.Nullable; 32 | import java.util.List; 33 | import java.util.Map; 34 | 35 | /** 36 | * Data model of the Entity. 37 | */ 38 | @Value.Immutable 39 | @JsonSerialize(as = ImmutableEntityDefinition.class) 40 | @JsonDeserialize(as = ImmutableEntityDefinition.class) 41 | public interface EntityDefinition { 42 | /** 43 | * Contains its name, description, label or if it has child properties or not. 44 | */ 45 | Entity entity(); 46 | 47 | /** 48 | * List of data models of the fields an Entity has. 49 | */ 50 | List fields(); 51 | 52 | /** 53 | * Custom properties defined for an Entity. 54 | */ 55 | @Nullable 56 | Map customProperties(); 57 | } 58 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/data/OnDemandToS3TestConfiguration.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.data; 21 | 22 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 23 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 24 | import org.immutables.value.Value; 25 | 26 | import java.util.List; 27 | import java.util.Map; 28 | import java.util.Optional; 29 | 30 | /** 31 | * Refer to sample-test-config.json 32 | */ 33 | @Value.Immutable 34 | @JsonDeserialize(as = ImmutableOnDemandToS3TestConfiguration.class) 35 | @JsonSerialize(as = ImmutableOnDemandToS3TestConfiguration.class) 36 | public interface OnDemandToS3TestConfiguration { 37 | Optional testName(); 38 | 39 | Optional apiVersion(); 40 | 41 | Optional profileName(); 42 | 43 | String flowName(); 44 | 45 | String entityName(); 46 | 47 | Optional query(); 48 | 49 | Optional flowTimeout(); 50 | 51 | List entityFields(); 52 | 53 | Optional outputSize(); 54 | 55 | Optional> sourceRuntimeProperties(); 56 | } 57 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/ConnectorOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration; 26 | 27 | /** 28 | * Enumerates the set of operations that are allowed for constructing filter criteria against specific entity fields. 29 | */ 30 | public enum ConnectorOperator { 31 | 32 | // TODO: Need to add description for each of the following 33 | 34 | // Column Filter Operator 35 | PROJECTION, 36 | 37 | // Row Filter Operators 38 | LESS_THAN, 39 | GREATER_THAN, 40 | BETWEEN, 41 | LESS_THAN_OR_EQUAL_TO, 42 | GREATER_THAN_OR_EQUAL_TO, 43 | EQUAL_TO, 44 | CONTAINS, 45 | NOT_EQUAL_TO, 46 | 47 | // Operators with a Destination Field 48 | ADDITION, 49 | SUBTRACTION, 50 | MULTIPLICATION, 51 | DIVISION, 52 | 53 | // Masking related operators 54 | MASK_ALL, 55 | MASK_FIRST_N, 56 | MASK_LAST_N, 57 | 58 | // Validation specific operators 59 | VALIDATE_NON_NULL, 60 | VALIDATE_NON_ZERO, 61 | VALIDATE_NON_NEGATIVE, 62 | VALIDATE_NUMERIC, 63 | 64 | NO_OP 65 | } 66 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/credentials/CustomAuthCredentials.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.credentials; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import java.util.Map; 32 | 33 | /** 34 | * Credentials for Custom authentication supported by connector. This structure is embedded in the Credentials 35 | * structure withing the ConnectorConnect that is sent with every API call. 36 | */ 37 | @Value.Immutable 38 | @JsonSerialize(as = ImmutableCustomAuthCredentials.class) 39 | @JsonDeserialize(as = ImmutableCustomAuthCredentials.class) 40 | public interface CustomAuthCredentials { 41 | /** 42 | * Authentication Type defined by Connector. 43 | */ 44 | String customAuthenticationType(); 45 | 46 | /** 47 | * Custom Credentials provided by connector user. Key will be AuthParameter.key() and value will be the 48 | * input provided by user. 49 | */ 50 | Map customCredentials(); 51 | } 52 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/data/CustomConnectorProfileConfiguration.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.data; 21 | 22 | import com.amazonaws.appflow.custom.connector.integ.providers.AuthenticationType; 23 | import com.amazonaws.services.appflow.model.OAuth2Properties; 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 25 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 26 | import org.immutables.value.Value; 27 | 28 | import java.util.Map; 29 | import java.util.Optional; 30 | 31 | /** 32 | * Refer to sample-test-config.json 33 | */ 34 | @Value.Immutable 35 | @JsonDeserialize(as = ImmutableCustomConnectorProfileConfiguration.class) 36 | @JsonSerialize(as = ImmutableCustomConnectorProfileConfiguration.class) 37 | public interface CustomConnectorProfileConfiguration { 38 | 39 | Optional secretsManagerArn(); 40 | 41 | String name(); 42 | 43 | Optional oAuth2Properties(); 44 | 45 | Optional connectorName(); 46 | 47 | Optional> profileProperties(); 48 | 49 | AuthenticationType authenticationType(); 50 | 51 | Optional defaultApiVersion(); 52 | } 53 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/data/OnDemandFromS3TestConfiguration.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.data; 21 | 22 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 23 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 24 | import org.immutables.value.Value; 25 | 26 | import java.util.List; 27 | import java.util.Map; 28 | import java.util.Optional; 29 | 30 | /** 31 | * Refer to sample-test-config.json 32 | */ 33 | @Value.Immutable 34 | @JsonDeserialize(as = ImmutableOnDemandFromS3TestConfiguration.class) 35 | @JsonSerialize(as = ImmutableOnDemandFromS3TestConfiguration.class) 36 | public interface OnDemandFromS3TestConfiguration { 37 | Optional testName(); 38 | 39 | Optional apiVersion(); 40 | 41 | Optional profileName(); 42 | 43 | String entityName(); 44 | 45 | String flowName(); 46 | 47 | Optional> idFieldNames(); 48 | 49 | String writeOperationType(); 50 | 51 | Optional flowTimeout(); 52 | 53 | Optional sourceDataFile(); 54 | 55 | Optional dataGeneratorClassName(); 56 | 57 | Optional> destinationRuntimeSettings(); 58 | } 59 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/retreive/RetrieveDataResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.retreive; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.ErrorDetails; 28 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 29 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 30 | import org.immutables.value.Value; 31 | 32 | import javax.annotation.Nullable; 33 | import java.util.List; 34 | 35 | /** 36 | * Represents the output of a RetrieveData operation. 37 | */ 38 | @Value.Immutable 39 | @JsonSerialize(as = ImmutableRetrieveDataResponse.class) 40 | @JsonDeserialize(as = ImmutableRetrieveDataResponse.class) 41 | public interface RetrieveDataResponse { 42 | /** 43 | * Specifies if the operation is successful or not. 44 | */ 45 | boolean isSuccess(); 46 | 47 | /** 48 | * Error details if the Operation is unsuccessful. 49 | */ 50 | @Nullable 51 | ErrorDetails errorDetails(); 52 | 53 | /** 54 | * List of json serialized string of the entity record as per the entity metadata. 55 | */ 56 | @Nullable 57 | List records(); 58 | } 59 | -------------------------------------------------------------------------------- /custom-connector-tools/logFetcher.sh: -------------------------------------------------------------------------------- 1 | echo -e "\033[33m*********** Warning: Please make sure you give correct region, loggroup and Suffix ***********\033[0m" 2 | echo -n "Provide Region:" 3 | read -r 4 | region=$REPLY 5 | echo -n "Provide Loggroup (Should be in the format of /aws/lambda/custom-connector-logging-Aaw0rrvylsya):" 6 | read -r 7 | loggroup=$REPLY 8 | echo -n "Provide name for log file that will be generated:" 9 | read -r 10 | filePath=$REPLY 11 | echo -n "Provide start time (in epoc seconds) for log query:" 12 | read -r 13 | startTime=$REPLY 14 | echo -n "Provide End Time (in epoc seconds) for log query:" 15 | read -r 16 | endTime=$REPLY 17 | read -r -p "Provide Query String:" 18 | query=$REPLY 19 | echo -n "Provide Bucket for log file:" 20 | read -r 21 | bucket=$REPLY 22 | echo -n "Provide number of seconds until the pre-signed URL expires." 23 | read -r 24 | expiryInSeconds=$REPLY 25 | echo -n "Cloudwatch query takes time to execute. The time depends on the interval for which logs are being fetched." 26 | echo -n "Provide wait time (seconds) before query finished." 27 | sleepTime=$REPLY 28 | echo -n "Are above details correct, Please select y/n:" 29 | read -r 30 | if [[ "$REPLY" = "n" ]]; then 31 | echo -e "User chose to end the script.Exiting...." 32 | exit 1 33 | fi 34 | if [[ "$REPLY" != "y" ]]; then 35 | echo -e "Please type either 'y' on 'n'.Exiting...." 36 | exit 1 37 | fi 38 | query_response=$(aws logs start-query \ 39 | --region $region \ 40 | --log-group-name $loggroup \ 41 | --start-time $startTime \ 42 | --end-time $endTime \ 43 | --query-string "$query") 44 | query_id=$(echo $query_response | jq -r '.queryId') 45 | 46 | echo -e "\033[33m*********** Sleeping for someitme to make sure the query is in complete state ***********\033[0m" 47 | sleep $sleepTime 48 | 49 | aws logs get-query-results --query-id $query_id --region $region > /home/$USER/$filePath 50 | 51 | aws s3 cp $filePath s3://$bucket 52 | aws s3 presign s3://$bucket/$filePath --expires-in $expiryInSeconds 53 | -------------------------------------------------------------------------------- /custom-connector-example/src/main/java/com/amazonaws/appflow/custom/connector/example/parser/AbstractParser.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * custom-connector-example 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.example.parser; 21 | 22 | import com.google.gson.JsonObject; 23 | 24 | public abstract class AbstractParser { 25 | 26 | //Gets a String value from a Json Object and defaults to null with null values 27 | protected static String getStringValue(final JsonObject object, final String fieldName) { 28 | if (fieldName == null || object.get(fieldName) == null || object.get(fieldName).isJsonNull()) { 29 | return null; 30 | } else { 31 | return object.get(fieldName).getAsString(); 32 | } 33 | } 34 | 35 | //Gets a Boolean value from a Json Object and defaults to false with null values 36 | // will default to true if fieldname is "true" 37 | protected static boolean getBooleanValue(final JsonObject object, final String fieldName) { 38 | if (fieldName == null) { 39 | return false; 40 | } else if ("true".equals(fieldName)) { 41 | return true; 42 | } else if (object.get(fieldName).isJsonNull()) { 43 | return false; 44 | } else { 45 | return object.get(fieldName).getAsBoolean(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/credentials/Credentials.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.credentials; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import javax.annotation.Nullable; 32 | 33 | /** 34 | * This class represents the Credentials structure. These credentials will be passed along with every connector 35 | * invocation within the ConnectorContext. 36 | * 37 | * @note Only one type of the Authentication credentials will be present (after the user selects the one they want 38 | * to use) and others will be null. 39 | */ 40 | @Value.Immutable 41 | @JsonSerialize(as = ImmutableCredentials.class) 42 | @JsonDeserialize(as = ImmutableCredentials.class) 43 | public interface Credentials { 44 | 45 | /** 46 | * ARN of the secret (authentication credentials) stored in AWS Secret Manager. 47 | */ 48 | @Nullable 49 | String secretArn(); 50 | 51 | /** 52 | * Authentication type associated with the credentials stored in AWS Secret Manager. 53 | */ 54 | @Nullable 55 | AuthenticationType authenticationType(); 56 | } 57 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/data/TestConfiguration.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.data; 21 | 22 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 23 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 24 | import org.immutables.value.Value; 25 | 26 | import java.util.List; 27 | import java.util.Optional; 28 | 29 | /** 30 | * Refer to sample-test-config.json 31 | */ 32 | @Value.Immutable 33 | @JsonDeserialize(as = ImmutableTestConfiguration.class) 34 | @JsonSerialize(as = ImmutableTestConfiguration.class) 35 | public interface TestConfiguration { 36 | 37 | Optional resourcePrefix(); 38 | 39 | List customConnectorConfigurations(); 40 | 41 | List customConnectorProfileConfigurations(); 42 | 43 | List onDemandToS3TestConfigurations(); 44 | 45 | List onDemandFromS3TestConfigurations(); 46 | 47 | List listConnectorEntitiesTestConfigurations(); 48 | 49 | List describeConnectorEntityTestConfigurations(); 50 | 51 | TestBucketConfiguration testBucketConfiguration(); 52 | } 53 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/query/QueryDataResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.query; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.ErrorDetails; 28 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 29 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 30 | import org.immutables.value.Value; 31 | 32 | import javax.annotation.Nullable; 33 | import java.util.List; 34 | 35 | /** 36 | * Represents the output of a QueryData operation. 37 | */ 38 | @Value.Immutable 39 | @JsonSerialize(as = ImmutableQueryDataResponse.class) 40 | @JsonDeserialize(as = ImmutableQueryDataResponse.class) 41 | public interface QueryDataResponse { 42 | /** 43 | * Specifies if the operation is successful or not. 44 | */ 45 | boolean isSuccess(); 46 | 47 | /** 48 | * Error details if the Operation is unsuccessful. 49 | */ 50 | @Nullable 51 | ErrorDetails errorDetails(); 52 | 53 | /** 54 | * The pagination token for the next page of data. 55 | */ 56 | @Nullable 57 | String nextToken(); 58 | 59 | /** 60 | * List of json serialized string of the entity record as per the entity metadata. 61 | */ 62 | @Nullable 63 | List records(); 64 | } 65 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/metadata/ReadOperationProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.metadata; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import javax.annotation.Nullable; 32 | 33 | /** 34 | * The properties that can be applied to a field when the connector is being used as a SOURCE. 35 | */ 36 | @Value.Immutable 37 | @JsonSerialize(as = ImmutableReadOperationProperty.class) 38 | @JsonDeserialize(as = ImmutableReadOperationProperty.class) 39 | public interface ReadOperationProperty { 40 | /** 41 | * Specifies if the source field can be returned in a search result. 42 | */ 43 | @Nullable 44 | Boolean isRetrievable(); 45 | 46 | /** 47 | * Specifies if the source field can have a null value. 48 | */ 49 | @Nullable 50 | Boolean isNullable(); 51 | 52 | /** 53 | * Specifies if the source field can be queried. 54 | */ 55 | @Nullable 56 | Boolean isQueryable(); 57 | 58 | /** 59 | * Specifies if the source field can be used for incremental queries. 60 | */ 61 | @Nullable 62 | Boolean isTimestampFieldForIncrementalQueries(); 63 | } 64 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/write/WriteDataResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.write; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.ErrorDetails; 28 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 29 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 30 | import org.immutables.value.Value; 31 | 32 | import javax.annotation.Nullable; 33 | import java.util.List; 34 | 35 | /** 36 | * Represents the output of a WriteData operation. 37 | */ 38 | @Value.Immutable 39 | @JsonSerialize(as = ImmutableWriteDataResponse.class) 40 | @JsonDeserialize(as = ImmutableWriteDataResponse.class) 41 | public interface WriteDataResponse { 42 | /** 43 | * Specifies if the operation is successful or not. In case of partial failure, 44 | * this flag should be set to false and the error code should be set to PartialWriteFailure. 45 | */ 46 | boolean isSuccess(); 47 | 48 | /** 49 | * Error details if the Operation is unsuccessful. 50 | */ 51 | @Nullable 52 | ErrorDetails errorDetails(); 53 | 54 | /** 55 | * List of input records write call response with success and failure details. 56 | */ 57 | @Nullable 58 | List writeRecordResults(); 59 | } 60 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/metadata/DescribeEntityRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.metadata; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.ConnectorContext; 28 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequest; 29 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequestStyle; 30 | import com.fasterxml.jackson.annotation.JsonTypeName; 31 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 32 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 33 | import org.immutables.value.Value; 34 | 35 | /** 36 | * Represents the input of a DescribeEntity operation. 37 | */ 38 | @ConnectorRequestStyle 39 | @Value.Immutable 40 | @JsonSerialize(as = ImmutableDescribeEntityRequest.class) 41 | @JsonDeserialize(as = ImmutableDescribeEntityRequest.class) 42 | @JsonTypeName("DescribeEntityRequest") 43 | public interface DescribeEntityRequest extends ConnectorRequest { 44 | /** 45 | * Unique identifier for the entity. Can be entityId/ entityName / entityPath+name / entityUrl etc. 46 | */ 47 | String entityIdentifier(); 48 | 49 | /** 50 | * Context contains the connector settings, credentials and APi version etc. 51 | */ 52 | ConnectorContext connectorContext(); 53 | } 54 | -------------------------------------------------------------------------------- /custom-connector-tools/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -o pipefail 3 | 4 | cat << EOF 5 | # Run this script from the custom_connector_tools directory. 6 | # This script performs the following actions: 7 | # 1. Creates the bucket if you have provided empty string. 8 | # 2. Builds the maven project. 9 | # 3. Uploads the packaged connector code to the S3 bucket you specified/or created if not specified. 10 | # 4. Deploys the connector. 11 | # 5. Describe the connector stack resources created. 12 | # 6. Please verify the policies in custom-connector-example/template.yml. 13 | EOF 14 | 15 | while true; do 16 | read -p "Do you wish to proceed? (yes or no) " yn 17 | case $yn in 18 | [Yy]* ) echo "Proceeding..."; break;; 19 | [Nn]* ) exit;; 20 | * ) echo "Please answer yes or no.";; 21 | esac 22 | done 23 | 24 | if [ "$#" -lt 3 ]; then 25 | echo "\n\nERROR: Script requires 3 arguments \n" 26 | echo "\n1. The AWS_REGION to target (e.g. us-east-1 or us-east-2) \n" 27 | echo "\n2. S3_BUCKET used for publishing artifacts.\n" 28 | echo "\n3. The STACK_NAME to create in cloudformation \n" 29 | exit; 30 | fi 31 | 32 | AWS_REGION=$1 33 | if [ -z "$AWS_REGION" ] 34 | then 35 | AWS_REGION="us-east-1" 36 | fi 37 | echo "Using AWS Region $AWS_REGION" 38 | 39 | BUCKET_NAME=$2 40 | if [ -z "$BUCKET_NAME" ] 41 | then 42 | BUCKET_ID=$(dd if=/dev/random bs=8 count=1 2>/dev/null | od -An -tx1 | tr -d ' \t\n') 43 | BUCKET_NAME=customconnector-artifacts-$BUCKET_ID 44 | aws --region $AWS_REGION s3 mb s3://$BUCKET_NAME 45 | fi 46 | echo "Using Bucket Name $BUCKET_NAME" 47 | 48 | STACK_NAME=$3 49 | echo "Using Stack Name $STACK_NAME" 50 | 51 | PACKAGE_NAME=$4 52 | echo "Using Package Name $PACKAGE_NAME" 53 | 54 | mvn clean install 55 | 56 | aws --region $AWS_REGION cloudformation package --template-file template.yml --s3-bucket "$BUCKET_NAME" --output-template-file out.yml 57 | aws --region $AWS_REGION cloudformation deploy --template-file out.yml --stack-name "$STACK_NAME" --capabilities CAPABILITY_NAMED_IAM 58 | aws --region $AWS_REGION cloudformation describe-stack-resources --stack-name "$STACK_NAME" 59 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/metadata/DescribeEntityResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.metadata; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.CacheControl; 28 | import com.amazonaws.appflow.custom.connector.model.ErrorDetails; 29 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 30 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 31 | import org.immutables.value.Value; 32 | 33 | import javax.annotation.Nullable; 34 | 35 | /** 36 | * Represents the output of a DescribeEntity operation. 37 | */ 38 | @Value.Immutable 39 | @JsonSerialize(as = ImmutableDescribeEntityResponse.class) 40 | @JsonDeserialize(as = ImmutableDescribeEntityResponse.class) 41 | public interface DescribeEntityResponse { 42 | /** 43 | * Specifies if the operation is successful or not. 44 | */ 45 | boolean isSuccess(); 46 | 47 | /** 48 | * Error details if the Operation is unsuccessful. 49 | */ 50 | @Nullable 51 | ErrorDetails errorDetails(); 52 | 53 | /** 54 | * Data model of the entity. 55 | */ 56 | @Nullable 57 | EntityDefinition entityDefinition(); 58 | 59 | /** 60 | * Caching policy for the entity. 61 | */ 62 | @Nullable 63 | CacheControl cacheControl(); 64 | } 65 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/metadata/FieldConstraints.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.metadata; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import javax.annotation.Nullable; 32 | import java.util.List; 33 | 34 | /** 35 | * Constraints that are applicable to the Field. 36 | */ 37 | @Value.Immutable 38 | @JsonSerialize(as = ImmutableFieldConstraints.class) 39 | @JsonDeserialize(as = ImmutableFieldConstraints.class) 40 | public interface FieldConstraints { 41 | /** 42 | * Min and Max range of the length of the value. 43 | */ 44 | @Nullable 45 | RangeConstraint allowedLengthRange(); 46 | 47 | /** 48 | * Min and Max range of value of this field. 49 | */ 50 | @Nullable 51 | RangeConstraint allowedValueRange(); 52 | 53 | /** 54 | * List of allowed values for this field. 55 | */ 56 | @Nullable 57 | List allowedValues(); 58 | 59 | /** 60 | * Value of the field should match with this regex pattern. 61 | */ 62 | @Nullable 63 | String allowedValuesRegexPattern(); 64 | 65 | /** 66 | * Allowed data format for the field. 67 | */ 68 | @Nullable 69 | String allowedDateFormat(); 70 | } 71 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/credentials/ValidateCredentialsRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.credentials; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequest; 28 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequestStyle; 29 | import com.fasterxml.jackson.annotation.JsonTypeName; 30 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 31 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 32 | import org.immutables.value.Value; 33 | 34 | import javax.annotation.Nullable; 35 | import java.util.Map; 36 | 37 | /** 38 | * Represents the input of a ValidateCredentials operation. 39 | */ 40 | @ConnectorRequestStyle 41 | @Value.Immutable 42 | @JsonSerialize(as = ImmutableValidateCredentialsRequest.class) 43 | @JsonDeserialize(as = ImmutableValidateCredentialsRequest.class) 44 | @JsonTypeName("ValidateCredentialsRequest") 45 | public interface ValidateCredentialsRequest extends ConnectorRequest { 46 | /** 47 | * Connector Settings provided for validating the connector credentials. All the Connector Settings for 48 | * CONNECTOR_PROFILE scope will be provided as input. 49 | */ 50 | @Nullable 51 | Map connectorRuntimeSettings(); 52 | 53 | /** 54 | * Credentials needs to validate. 55 | */ 56 | Credentials credentials(); 57 | } 58 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/settings/ValidateConnectorRuntimeSettingsResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.settings; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.ErrorDetails; 28 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 29 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 30 | import org.immutables.value.Value; 31 | 32 | import javax.annotation.Nullable; 33 | import java.util.Map; 34 | 35 | /** 36 | * Represents the output of a ValidateConnectorRuntimeSettings operation. 37 | */ 38 | @Value.Immutable 39 | @JsonSerialize(as = ImmutableValidateConnectorRuntimeSettingsResponse.class) 40 | @JsonDeserialize(as = ImmutableValidateConnectorRuntimeSettingsResponse.class) 41 | public interface ValidateConnectorRuntimeSettingsResponse { 42 | /** 43 | * Specifies if the operation is successful or not. 44 | */ 45 | boolean isSuccess(); 46 | 47 | /** 48 | * Error message for the invalid connector settings keys. Key will be ConnectorRuntimeSetting.key() 49 | * provided as input and value will be the error message. 50 | */ 51 | @Nullable 52 | Map errorsByInputField(); 53 | 54 | /** 55 | * Error details contains ErrorCode and ErrorMessage if the Operation is unsuccessful. 56 | */ 57 | @Nullable 58 | ErrorDetails errorDetails(); 59 | } 60 | -------------------------------------------------------------------------------- /custom-connector-tests/src/main/java/com/amazonaws/appflow/custom/connector/tests/validation/UrlValidator.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * custom-connector-tests 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.tests.validation; 21 | 22 | import com.amazonaws.appflow.custom.connector.tests.exceptions.ValidationException; 23 | import org.apache.commons.lang3.StringUtils; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | import java.net.URI; 28 | import java.net.URISyntaxException; 29 | 30 | public final class UrlValidator { 31 | private static final Logger LOGGER = LoggerFactory.getLogger(UrlValidator.class); 32 | 33 | private UrlValidator() {} 34 | 35 | public static void validate(final String inputUrl) { 36 | if (StringUtils.isBlank(inputUrl)) { 37 | return; 38 | } 39 | 40 | try { 41 | URI uri = new URI(inputUrl); 42 | if (!"https".equals(uri.getScheme())) { 43 | String errorMessage = String.format("Invalid protocol in url %s. Only https format is supported", 44 | inputUrl); 45 | throw new ValidationException(errorMessage); 46 | } 47 | } catch (URISyntaxException e) { 48 | LOGGER.error("Invalid url format!"); 49 | String errorMessage = String.format("Invalid format for url %s." + 50 | " Please check if if the url syntax is correct" + 51 | " and it resolves to a known host.", inputUrl); 52 | throw new ValidationException(errorMessage); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/auth/AuthParameter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration.auth; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import javax.annotation.Nullable; 32 | import java.util.List; 33 | 34 | /** 35 | * Represents the authentication parameter. 36 | */ 37 | @Value.Immutable 38 | @JsonSerialize(as = ImmutableAuthParameter.class) 39 | @JsonDeserialize(as = ImmutableAuthParameter.class) 40 | public interface AuthParameter { 41 | /** 42 | * Unique identifier for AuthParameter. 43 | */ 44 | String key(); 45 | 46 | /** 47 | * Specifies if this AuthParameter is required or not. 48 | */ 49 | boolean required(); 50 | 51 | /** 52 | * Label of the Auth Parameter. 53 | */ 54 | String label(); 55 | 56 | /** 57 | * Description of the Auth Parameter. 58 | */ 59 | String description(); 60 | 61 | /** 62 | * Specifies if this field data is sensitive/Critical that shouldn't be stored as plain text. 63 | */ 64 | @Nullable 65 | Boolean sensitiveField(); 66 | 67 | /** 68 | * Values provided by connector which can be used as input for this AuthParameter. 69 | */ 70 | @Nullable 71 | List connectorSuppliedValues(); 72 | } 73 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/handlers/MetadataHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.handlers; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.metadata.DescribeEntityRequest; 28 | import com.amazonaws.appflow.custom.connector.model.metadata.DescribeEntityResponse; 29 | import com.amazonaws.appflow.custom.connector.model.metadata.ListEntitiesRequest; 30 | import com.amazonaws.appflow.custom.connector.model.metadata.ListEntitiesResponse; 31 | 32 | /** 33 | * This interface defines the functionality to be implemented by custom connectors for metadata operations. 34 | */ 35 | public interface MetadataHandler { 36 | /** 37 | * Lists all the entities available in a paginated fashion. This API is recursive in nature and provides a heretical 38 | * entity listing based on entityPath. If the ListEntityResponse returns hasChildren=true that indicates that 39 | * there are more entities in the next level. 40 | * 41 | * @param request - {@link ListEntitiesRequest} 42 | * @return - {@link ListEntitiesResponse} 43 | */ 44 | ListEntitiesResponse listEntities(ListEntitiesRequest request); 45 | 46 | /** 47 | * Describes the entity definition with its field level metadata. 48 | * 49 | * @param request - {@link DescribeEntityRequest} 50 | * @return - {@link DescribeEntityResponse} 51 | */ 52 | DescribeEntityResponse describeEntity(DescribeEntityRequest request); 53 | } 54 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/metadata/ListEntitiesResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.metadata; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.CacheControl; 28 | import com.amazonaws.appflow.custom.connector.model.ErrorDetails; 29 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 30 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 31 | import org.immutables.value.Value; 32 | 33 | import javax.annotation.Nullable; 34 | import java.util.List; 35 | 36 | /** 37 | * Represents the output of a RetrieveData operation. 38 | */ 39 | @Value.Immutable 40 | @JsonSerialize(as = ImmutableListEntitiesResponse.class) 41 | @JsonDeserialize(as = ImmutableListEntitiesResponse.class) 42 | public interface ListEntitiesResponse { 43 | /** 44 | * Specifies if the operation is successful or not. 45 | */ 46 | boolean isSuccess(); 47 | 48 | /** 49 | * Error details if the Operation is unsuccessful. 50 | */ 51 | @Nullable 52 | ErrorDetails errorDetails(); 53 | 54 | /** 55 | * List of entities. 56 | */ 57 | @Nullable 58 | List entities(); 59 | 60 | /** 61 | * The pagination token for the next page of data. 62 | */ 63 | @Nullable 64 | String nextToken(); 65 | 66 | /** 67 | * Caching policy for the list of entities. 68 | */ 69 | @Nullable 70 | CacheControl cacheControl(); 71 | } 72 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/metadata/Entity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.metadata; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import javax.annotation.Nullable; 32 | import java.util.Map; 33 | 34 | /** 35 | * Represents the entity structure. 36 | */ 37 | @Value.Immutable 38 | @JsonSerialize(as = ImmutableEntity.class) 39 | @JsonDeserialize(as = ImmutableEntity.class) 40 | public interface Entity { 41 | /** 42 | * Unique identifier for the entity. Can be entityId/ entityName / entityPath+name / entityUrl etc. 43 | */ 44 | String entityIdentifier(); 45 | 46 | /** 47 | * Specifies whether the connector entity is a parent or a category and has more entities nested underneath it. 48 | */ 49 | boolean hasNestedEntities(); 50 | 51 | /** 52 | * Specifies if the connector entity is writable 53 | */ 54 | @Value.Default 55 | default boolean isWritable() { return true; } 56 | 57 | /** 58 | * Label of the entity. 59 | */ 60 | @Nullable 61 | String label(); 62 | 63 | /** 64 | * Description of the entity. 65 | */ 66 | @Nullable 67 | String description(); 68 | 69 | /** 70 | * Entity Specific custom properties. 71 | */ 72 | @Nullable 73 | Map customProperties(); 74 | } 75 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/DescribeConnectorConfigurationRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequest; 28 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequestStyle; 29 | import com.fasterxml.jackson.annotation.JsonTypeName; 30 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 31 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 32 | import org.immutables.value.Value; 33 | 34 | import javax.annotation.Nullable; 35 | 36 | /** 37 | * Represents the input of a DescribeConnectorConfiguration operation. 38 | */ 39 | @ConnectorRequestStyle 40 | @Value.Immutable 41 | @JsonSerialize(as = ImmutableDescribeConnectorConfigurationRequest.class) 42 | @JsonDeserialize(as = ImmutableDescribeConnectorConfigurationRequest.class) 43 | @JsonTypeName("DescribeConnectorConfigurationRequest") 44 | public interface DescribeConnectorConfigurationRequest extends ConnectorRequest { 45 | 46 | /** 47 | * Locale value to get the localized string values for labels and descriptions for connector settings. Default is 48 | * en-US. 49 | */ 50 | @Value.Default 51 | default String locale() { 52 | return "en-US"; 53 | } 54 | 55 | /** 56 | * Connector label to be used for logging. 57 | * @return 58 | */ 59 | @Nullable 60 | String connectorLabel(); 61 | } 62 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/util/S3Helper.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.util; 21 | 22 | import com.amazonaws.appflow.custom.connector.integ.data.TestBucketConfiguration; 23 | import com.amazonaws.appflow.custom.connector.integ.providers.ServiceProvider; 24 | import com.amazonaws.services.s3.AmazonS3; 25 | import com.amazonaws.services.s3.model.ObjectMetadata; 26 | import com.amazonaws.services.s3.model.PutObjectRequest; 27 | 28 | import java.io.ByteArrayInputStream; 29 | import java.nio.charset.StandardCharsets; 30 | 31 | /** 32 | * Utility class that uploads files to S3 33 | */ 34 | public class S3Helper { 35 | 36 | private final TestBucketConfiguration testBucketConfiguration; 37 | 38 | public S3Helper(final TestBucketConfiguration testBucketConfiguration) { 39 | this.testBucketConfiguration = testBucketConfiguration; 40 | } 41 | 42 | /** 43 | * Utility for uploading files to the bucket specified in the test configuration. 44 | * @param file the string data that needs to be uploaded. 45 | * @param fileName the s3 prefix that that file will be uploaded under 46 | */ 47 | public void uploadFile(final String file, final String fileName) { 48 | AmazonS3 amazonS3 = ServiceProvider.getS3(); 49 | amazonS3.putObject(new PutObjectRequest( 50 | testBucketConfiguration.bucketName(), 51 | testBucketConfiguration.bucketPrefix() + fileName, 52 | new ByteArrayInputStream(file.getBytes(StandardCharsets.UTF_8)), 53 | new ObjectMetadata())); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/settings/ValidateConnectorRuntimeSettingsRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.settings; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequest; 28 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequestStyle; 29 | import com.amazonaws.appflow.custom.connector.model.credentials.AuthenticationType; 30 | import com.fasterxml.jackson.annotation.JsonTypeName; 31 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 32 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 33 | import org.immutables.value.Value; 34 | 35 | import javax.annotation.Nullable; 36 | import java.util.Map; 37 | 38 | /** 39 | * Represents the input of a ValidateConnectorRuntimeSettings operation. 40 | */ 41 | @ConnectorRequestStyle 42 | @Value.Immutable 43 | @JsonSerialize(as = ImmutableValidateConnectorRuntimeSettingsRequest.class) 44 | @JsonDeserialize(as = ImmutableValidateConnectorRuntimeSettingsRequest.class) 45 | @JsonTypeName("ValidateConnectorRuntimeSettingsRequest") 46 | public interface ValidateConnectorRuntimeSettingsRequest extends ConnectorRequest { 47 | /** 48 | * Scope of the connector runtime settings needs to validated. 49 | */ 50 | ConnectorRuntimeSettingScope scope(); 51 | 52 | /** 53 | * Connector settings input. Key will be ConnectorSetting.key() and value will be input provided by 54 | * user. 55 | */ 56 | Map connectorRuntimeSettings(); 57 | 58 | @Nullable 59 | AuthenticationType authenticationType(); 60 | } 61 | -------------------------------------------------------------------------------- /custom-connector-queryfilter/src/main/java/com/amazonaws/appflow/custom/connector/queryfilter/SyntaxErrorReporter.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Amazon AppFlow Custom Connector SDK 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.queryfilter; 21 | 22 | import org.antlr.v4.runtime.BaseErrorListener; 23 | import org.antlr.v4.runtime.Parser; 24 | import org.antlr.v4.runtime.RecognitionException; 25 | import org.antlr.v4.runtime.Recognizer; 26 | 27 | import java.util.Collections; 28 | import java.util.List; 29 | 30 | /** 31 | * This class is responsible for collecting and reporting syntax errors in passed filter expression in the input request. 32 | * Note : This class is not thread safe. 33 | */ 34 | public class SyntaxErrorReporter extends BaseErrorListener { 35 | 36 | private boolean hasError = false; 37 | private final StringBuilder syntaxErrors = new StringBuilder(); 38 | 39 | public boolean hasError() { 40 | return hasError; 41 | } 42 | 43 | public StringBuilder getSyntaxErrors() { 44 | return syntaxErrors; 45 | } 46 | 47 | @Override 48 | public void syntaxError(final Recognizer recognizer, 49 | final Object offendingSymbol, 50 | final int line, final int charPositionInLine, 51 | final String msg, final RecognitionException e) { 52 | hasError = true; 53 | List stack = ((Parser) recognizer).getRuleInvocationStack(); 54 | Collections.reverse(stack); 55 | syntaxErrors.append("rule stack: ").append(stack).append(" ") 56 | .append("line ").append(line).append(":").append(charPositionInLine).append(" at ") 57 | .append(offendingSymbol).append(":").append(msg); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/auth/OAuth2CustomParameter.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-sdk 4 | * %% 5 | * Copyright (C) 2021 - 2022 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration.auth; 21 | 22 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 23 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 24 | import org.immutables.value.Value; 25 | 26 | import javax.annotation.Nullable; 27 | import java.util.List; 28 | 29 | /** 30 | * Represents the Oauth2 authentication custom parameter. 31 | */ 32 | @Value.Immutable 33 | @JsonSerialize(as = ImmutableOAuth2CustomParameter.class) 34 | @JsonDeserialize(as = ImmutableOAuth2CustomParameter.class) 35 | public interface OAuth2CustomParameter { 36 | /** 37 | * Unique identifier for custom Oauth2 parameter. 38 | */ 39 | String key(); 40 | 41 | /** 42 | * Specifies if this Oauth2 parameter is required or not. 43 | */ 44 | boolean required(); 45 | 46 | /** 47 | * Specifies if this Oauth2 parameter is related to Token Url or Auth Url 48 | */ 49 | OAuth2CustomPropType type(); 50 | 51 | /** 52 | * Label of the custom Oauth2 parameter. 53 | */ 54 | String label(); 55 | 56 | /** 57 | * Description of the custom Oauth2 parameter. 58 | */ 59 | String description(); 60 | 61 | /** 62 | * Specifies if this field data is sensitive/Critical that shouldn't be stored as plain text. 63 | */ 64 | @Nullable 65 | Boolean sensitiveField(); 66 | 67 | /** 68 | * Values provided by connector which can be used as input for this AuthParameter. 69 | */ 70 | @Nullable 71 | List connectorSuppliedValues(); 72 | } 73 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/connectorconfiguration/auth/AuthenticationConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.connectorconfiguration.auth; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import javax.annotation.Nullable; 32 | import java.util.List; 33 | 34 | /** 35 | * Represents Authentication types supported by the connector. 36 | */ 37 | @Value.Immutable 38 | @JsonSerialize(as = ImmutableAuthenticationConfig.class) 39 | @JsonDeserialize(as = ImmutableAuthenticationConfig.class) 40 | public interface AuthenticationConfig { 41 | 42 | /** 43 | * Specifies if the Basic Auth is supported by connector. 44 | */ 45 | @Nullable 46 | Boolean isBasicAuthSupported(); 47 | 48 | /** 49 | * Specifies if the ApiKey Auth is supported by connector. 50 | */ 51 | @Nullable 52 | Boolean isApiKeyAuthSupported(); 53 | 54 | /** 55 | * Specifies if the OAuth2 is supported by connector. 56 | */ 57 | @Nullable 58 | Boolean isOAuth2Supported(); 59 | 60 | /** 61 | * Specifies if the Custom Authentication is supported by connector. 62 | */ 63 | @Nullable 64 | Boolean isCustomAuthSupported(); 65 | 66 | /** 67 | * OAuth2 default values provided by the connector. 68 | */ 69 | @Nullable 70 | OAuth2Defaults oAuth2Defaults(); 71 | 72 | /** 73 | * Configuration for custom Authentication defined by the connector. 74 | */ 75 | @Nullable 76 | List customAuthConfig(); 77 | } 78 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/handlers/RecordHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.handlers; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.query.QueryDataRequest; 28 | import com.amazonaws.appflow.custom.connector.model.query.QueryDataResponse; 29 | import com.amazonaws.appflow.custom.connector.model.retreive.RetrieveDataRequest; 30 | import com.amazonaws.appflow.custom.connector.model.retreive.RetrieveDataResponse; 31 | import com.amazonaws.appflow.custom.connector.model.write.WriteDataRequest; 32 | import com.amazonaws.appflow.custom.connector.model.write.WriteDataResponse; 33 | 34 | /** 35 | * This interface defines the functionality to be implemented by custom connectors for record related operations. 36 | */ 37 | public interface RecordHandler { 38 | /** 39 | * Retrieves the batch of records against a set of identifiers from the source application 40 | * 41 | * @param request - {@link RetrieveDataRequest} 42 | * @return - {@link RetrieveDataResponse} 43 | */ 44 | RetrieveDataResponse retrieveData(RetrieveDataRequest request); 45 | 46 | /** 47 | * Writes batch of records to the destination application 48 | * 49 | * @param request - {@link WriteDataRequest} 50 | * @return - {@link WriteDataResponse} 51 | */ 52 | WriteDataResponse writeData(WriteDataRequest request); 53 | 54 | /** 55 | * Queries the data from the source application against the supplied filter conditions. 56 | * 57 | * @param request - {@link QueryDataRequest} 58 | * @return - {@link QueryDataResponse} 59 | */ 60 | QueryDataResponse queryData(QueryDataRequest request); 61 | } 62 | -------------------------------------------------------------------------------- /custom-connector-tests/src/main/java/com/amazonaws/appflow/custom/connector/tests/resources/TestContext.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * custom-connector-tests 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.tests.resources; 21 | 22 | import com.amazonaws.services.lambda.runtime.ClientContext; 23 | import com.amazonaws.services.lambda.runtime.CognitoIdentity; 24 | import com.amazonaws.services.lambda.runtime.Context; 25 | import com.amazonaws.services.lambda.runtime.LambdaLogger; 26 | 27 | /** 28 | * Sample context for testing purposes. All the unused methods have been stubbed out. 29 | * Only to be used with ConnectorTestInvoker to verify custom connector. 30 | */ 31 | public class TestContext implements Context { 32 | @Override 33 | public String getAwsRequestId() { 34 | return null; 35 | } 36 | 37 | @Override 38 | public String getLogGroupName() { 39 | return null; 40 | } 41 | 42 | @Override 43 | public String getLogStreamName() { 44 | return null; 45 | } 46 | 47 | @Override 48 | public String getFunctionName() { 49 | return null; 50 | } 51 | 52 | @Override 53 | public String getFunctionVersion() { 54 | return null; 55 | } 56 | 57 | @Override 58 | public String getInvokedFunctionArn() { 59 | return null; 60 | } 61 | 62 | @Override 63 | public CognitoIdentity getIdentity() { 64 | return null; 65 | } 66 | 67 | @Override 68 | public ClientContext getClientContext() { 69 | return null; 70 | } 71 | 72 | @Override 73 | public int getRemainingTimeInMillis() { 74 | return 0; 75 | } 76 | 77 | @Override 78 | public int getMemoryLimitInMB() { 79 | return 0; 80 | } 81 | 82 | @Override 83 | public LambdaLogger getLogger() { 84 | return new TestLogger(); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /custom-connector-tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | aws-appflow-custom-connector 7 | software.amazon.appflow 8 | 1.0.9 9 | 10 | 4.0.0 11 | 12 | custom-connector-tests 13 | 14 | 15 | 16 16 | 16 17 | 18 | 19 | 20 | 21 | software.amazon.appflow 22 | custom-connector-example 23 | 1.0.9 24 | 25 | 26 | 27 | commons-cli 28 | commons-cli 29 | 1.3.1 30 | 31 | 32 | org.projectlombok 33 | lombok 34 | 1.18.20 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-shade-plugin 43 | 3.2.2 44 | 45 | 46 | package 47 | 48 | shade 49 | 50 | 51 | 52 | 53 | org.sonatype.haven.HavenCli 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/metadata/ListEntitiesRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.metadata; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.ConnectorContext; 28 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequest; 29 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequestStyle; 30 | import com.fasterxml.jackson.annotation.JsonTypeName; 31 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 32 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 33 | import org.immutables.value.Value; 34 | 35 | import javax.annotation.Nullable; 36 | 37 | import static com.amazonaws.appflow.custom.connector.Constants.MAX_RESULT_SIZE; 38 | 39 | /** 40 | * Represents the input of a ListEntities operation. 41 | */ 42 | @ConnectorRequestStyle 43 | @Value.Immutable 44 | @JsonSerialize(as = ImmutableListEntitiesRequest.class) 45 | @JsonDeserialize(as = ImmutableListEntitiesRequest.class) 46 | @JsonTypeName("ListEntitiesRequest") 47 | public interface ListEntitiesRequest extends ConnectorRequest { 48 | /** 49 | * Path/URI of entities. 50 | */ 51 | @Nullable 52 | String entitiesPath(); 53 | 54 | /** 55 | * Maximum number of records needs to be returned as part of single call. Default value is 1000. 56 | */ 57 | @Nullable 58 | @Value.Default 59 | default Long maxResult() { 60 | return MAX_RESULT_SIZE; 61 | } 62 | 63 | /** 64 | * The pagination token - next page should start from this token value. 65 | */ 66 | @Nullable 67 | String nextToken(); 68 | 69 | /** 70 | * Context contains the connector settings, credentials and APi version etc. 71 | */ 72 | ConnectorContext connectorContext(); 73 | } 74 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/settings/ConnectorRuntimeSetting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.settings; 26 | 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import org.immutables.value.Value; 30 | 31 | import javax.annotation.Nullable; 32 | import java.util.List; 33 | 34 | /** 35 | * Represents the setting that the connector needs at runtime and the input will be provided by the AppFlow user. For 36 | * eg. instanceUrl, maxParallelism etc. 37 | */ 38 | @Value.Immutable 39 | @JsonSerialize(as = ImmutableConnectorRuntimeSetting.class) 40 | @JsonDeserialize(as = ImmutableConnectorRuntimeSetting.class) 41 | public interface ConnectorRuntimeSetting { 42 | /** 43 | * Unique identifier for the connector runtime setting. 44 | */ 45 | String key(); 46 | 47 | /** 48 | * Data type for the connector runtime setting. 49 | */ 50 | ConnectorRuntimeSettingDataType dataType(); 51 | 52 | /** 53 | * Specifies if this setting is required or not. 54 | */ 55 | boolean required(); 56 | 57 | /** 58 | * Label for the connector runtime setting. 59 | */ 60 | String label(); 61 | 62 | /** 63 | * Description of the connector runtime setting. 64 | */ 65 | String description(); 66 | 67 | /** 68 | * Scope of the runtime setting needed for CONNECTOR_PROFILE, SOURCE, DESTINATION etc. 69 | */ 70 | ConnectorRuntimeSettingScope scope(); 71 | 72 | /** 73 | * Optional connector supplied value options (with matching data type) that the user can pick from as a value for 74 | * this runtime setting. 75 | */ 76 | @Nullable 77 | List connectorSuppliedValueOptions(); 78 | } 79 | -------------------------------------------------------------------------------- /custom-connector-integ-test/src/main/java/com/amazonaws/appflow/custom/connector/integ/providers/ServiceProvider.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * aws-custom-connector-integ-test 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.integ.providers; 21 | 22 | import com.amazonaws.services.appflow.AmazonAppflow; 23 | import com.amazonaws.services.appflow.AmazonAppflowClientBuilder; 24 | import com.amazonaws.services.s3.AmazonS3; 25 | import com.amazonaws.services.s3.AmazonS3ClientBuilder; 26 | import com.amazonaws.services.secretsmanager.AWSSecretsManager; 27 | import com.amazonaws.services.secretsmanager.AWSSecretsManagerClientBuilder; 28 | import com.amazonaws.appflow.custom.connector.integ.util.FlowPoller; 29 | 30 | /** 31 | * This class contains singleton service references. 32 | */ 33 | public final class ServiceProvider { 34 | 35 | private ServiceProvider(){} 36 | 37 | private static AmazonAppflow client; 38 | 39 | private static AWSSecretsManager secretsManager; 40 | 41 | private static AmazonS3 amazonS3; 42 | 43 | private static FlowPoller flowPoller; 44 | 45 | public static AmazonAppflow getAppflow() { 46 | if (client == null) { 47 | client = AmazonAppflowClientBuilder.standard() 48 | .build(); 49 | } 50 | return client; 51 | } 52 | 53 | public static FlowPoller getFlowPoller() { 54 | if (flowPoller == null) { 55 | flowPoller = new FlowPoller(); 56 | } 57 | return flowPoller; 58 | } 59 | 60 | public static AmazonS3 getS3() { 61 | if (amazonS3 == null) { 62 | amazonS3 = AmazonS3ClientBuilder.standard() 63 | .build(); 64 | } 65 | return amazonS3; 66 | } 67 | 68 | public static AWSSecretsManager getSecretsManager() { 69 | if (secretsManager == null) { 70 | secretsManager = AWSSecretsManagerClientBuilder.standard().build(); 71 | } 72 | return secretsManager; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/util/CustomObjectMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.util; 26 | 27 | import com.fasterxml.jackson.core.JsonParser; 28 | import com.fasterxml.jackson.databind.DeserializationFeature; 29 | import com.fasterxml.jackson.databind.ObjectMapper; 30 | import com.fasterxml.jackson.databind.SerializationFeature; 31 | import com.fasterxml.jackson.datatype.guava.GuavaModule; 32 | import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; 33 | import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; 34 | 35 | /** 36 | * Custom Object mapper with all the required modules registered. 37 | */ 38 | public final class CustomObjectMapper { 39 | private CustomObjectMapper() { 40 | } 41 | 42 | private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper() 43 | // To properly serialize and deserialize the Immutable collections 44 | .registerModule(new GuavaModule()) 45 | // To properly serialize and deserialize the Jdk8 related classes such as Optional. 46 | .registerModule(new Jdk8Module()) 47 | // To properly serialize and deserialize java time objects 48 | .registerModule(new JavaTimeModule()) 49 | // Enabling the below features 50 | .enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES) 51 | // Disabling the below features 52 | .disable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID) 53 | .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) 54 | .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) 55 | .disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES); 56 | 57 | /** 58 | * Returns a new instance of ObjectMapper. 59 | */ 60 | public static ObjectMapper getObjectMapper() { 61 | return OBJECT_MAPPER.copy(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/retreive/RetrieveDataRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.retreive; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.ConnectorContext; 28 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequest; 29 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequestStyle; 30 | import com.fasterxml.jackson.annotation.JsonTypeName; 31 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 32 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 33 | import org.immutables.value.Value; 34 | 35 | import javax.annotation.Nullable; 36 | import java.util.List; 37 | 38 | /** 39 | * Represents the input of a RetrieveData operation. 40 | */ 41 | @ConnectorRequestStyle 42 | @Value.Immutable 43 | @JsonSerialize(as = ImmutableRetrieveDataRequest.class) 44 | @JsonDeserialize(as = ImmutableRetrieveDataRequest.class) 45 | @JsonTypeName("RetrieveDataRequest") 46 | public interface RetrieveDataRequest extends ConnectorRequest { 47 | /** 48 | * Unique identifier for the entity. Can be entityId/ entityName / entityPath+name / entityUrl etc. 49 | */ 50 | String entityIdentifier(); 51 | 52 | /** 53 | * Field values to retrieve. If null, it will provide all the fields for the entity. 54 | */ 55 | @Nullable 56 | List selectedFieldNames(); 57 | 58 | /** 59 | * Field name which will be used as part of where statement to retrieve the data. Can be primary or any other column 60 | * name. 61 | */ 62 | @Nullable 63 | String idFieldName(); 64 | 65 | /** 66 | * List of values for idFieldName. 67 | */ 68 | @Nullable 69 | List ids(); 70 | 71 | /** 72 | * Context contains the connector settings, credentials and APi version etc. 73 | */ 74 | ConnectorContext connectorContext(); 75 | } 76 | -------------------------------------------------------------------------------- /custom-connector-example/src/main/java/com/amazonaws/appflow/custom/connector/example/parser/RecordResponseParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Example Custom Connector. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.example.parser; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.write.ImmutableWriteRecordResult; 28 | import com.amazonaws.appflow.custom.connector.model.write.WriteRecordResult; 29 | import com.google.gson.Gson; 30 | import com.google.gson.JsonArray; 31 | import com.google.gson.JsonElement; 32 | import com.google.gson.JsonObject; 33 | 34 | import java.util.ArrayList; 35 | import java.util.List; 36 | import java.util.Objects; 37 | 38 | /** 39 | * Sample implementation for parsing record API responses. 40 | */ 41 | public final class RecordResponseParser extends AbstractParser { 42 | private RecordResponseParser() { 43 | } 44 | 45 | private static final Gson GSON = new Gson(); 46 | 47 | public static List parseQueryResponse(final String jsonString) { 48 | final JsonObject parentObject = GSON.fromJson(jsonString, JsonObject.class); 49 | final List records = new ArrayList<>(); 50 | if (Objects.nonNull(parentObject.get("records"))) { 51 | final JsonArray jsonArray = parentObject.get("records").getAsJsonArray(); 52 | for (final JsonElement jsonElement : jsonArray) { 53 | records.add(jsonElement.toString()); 54 | } 55 | } 56 | return records; 57 | } 58 | 59 | public static WriteRecordResult parseWriteResponse(final String jsonString) { 60 | final JsonObject parentObject = GSON.fromJson(jsonString, JsonObject.class); 61 | return ImmutableWriteRecordResult.builder() 62 | .recordId(getStringValue(parentObject, "id")) 63 | .isSuccess(getBooleanValue(parentObject, "success")) 64 | .errorMessage(Objects.nonNull(parentObject.get("errors")) ? 65 | parentObject.get("errors").getAsJsonArray().toString() : null) 66 | .build(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/metadata/WriteOperationProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.metadata; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.write.WriteOperationType; 28 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 29 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 30 | import org.immutables.value.Value; 31 | 32 | import javax.annotation.Nullable; 33 | import java.util.List; 34 | 35 | /** 36 | * The properties that can be applied to a field when connector is being used as a DESTINATION. 37 | */ 38 | @Value.Immutable 39 | @JsonSerialize(as = ImmutableWriteOperationProperty.class) 40 | @JsonDeserialize(as = ImmutableWriteOperationProperty.class) 41 | public interface WriteOperationProperty { 42 | /** 43 | * Specifies if the destination field can be created by the current user. 44 | */ 45 | @Nullable 46 | Boolean isCreatable(); 47 | 48 | /** 49 | * Specifies whether the field can be updated during an UPDATE or UPSERT write operation. 50 | */ 51 | @Nullable 52 | Boolean isUpdatable(); 53 | 54 | /** 55 | * Specifies if the destination field can have a null value. 56 | */ 57 | @Nullable 58 | Boolean isNullable(); 59 | 60 | /** 61 | * Specifies if the flow run can either insert new rows in the destination field if they do not already exist, or 62 | * update them if they do. 63 | */ 64 | @Nullable 65 | Boolean isUpsertable(); 66 | 67 | /** 68 | * Specifies if default value will be used by application while creating records if not provided. 69 | */ 70 | @Nullable 71 | Boolean isDefaultedOnCreate(); 72 | 73 | /** 74 | * A list of supported write operations. For each write operation listed, this field can be used in idFieldNames 75 | * when that write operation is present as a destination option. 76 | */ 77 | @Nullable 78 | List supportedWriteOperations(); 79 | } 80 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/handlers/ConfigurationHandler.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Amazon AppFlow Custom Connector SDK 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | 21 | package com.amazonaws.appflow.custom.connector.handlers; 22 | 23 | import com.amazonaws.appflow.custom.connector.model.connectorconfiguration.DescribeConnectorConfigurationRequest; 24 | import com.amazonaws.appflow.custom.connector.model.connectorconfiguration.DescribeConnectorConfigurationResponse; 25 | import com.amazonaws.appflow.custom.connector.model.credentials.ValidateCredentialsRequest; 26 | import com.amazonaws.appflow.custom.connector.model.credentials.ValidateCredentialsResponse; 27 | import com.amazonaws.appflow.custom.connector.model.settings.ValidateConnectorRuntimeSettingsRequest; 28 | import com.amazonaws.appflow.custom.connector.model.settings.ValidateConnectorRuntimeSettingsResponse; 29 | 30 | /** 31 | * This interface defines the functionality to be implemented by custom connectors for configurations, credentials 32 | * related operations. 33 | */ 34 | public interface ConfigurationHandler { 35 | /** 36 | * Validates the user inputs corresponding to the connector settings for a given ConnectorRuntimeSettingScope. 37 | * 38 | * @param request - {@link ValidateConnectorRuntimeSettingsRequest} 39 | * @return - {@link ValidateConnectorRuntimeSettingsResponse} 40 | */ 41 | ValidateConnectorRuntimeSettingsResponse validateConnectorRuntimeSettings(ValidateConnectorRuntimeSettingsRequest request); 42 | 43 | /** 44 | * Validates the user provided credentials. 45 | * 46 | * @param request - {@link ValidateCredentialsRequest} 47 | * @return - {@link ValidateCredentialsResponse} 48 | */ 49 | ValidateCredentialsResponse validateCredentials(ValidateCredentialsRequest request); 50 | 51 | /** 52 | * Describes the Connector Configuration supported by the connector. 53 | * 54 | * @param request - {@link DescribeConnectorConfigurationRequest} 55 | * @return {@link DescribeConnectorConfigurationResponse} 56 | */ 57 | DescribeConnectorConfigurationResponse describeConnectorConfiguration(DescribeConnectorConfigurationRequest request); 58 | } 59 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/query/QueryDataRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.query; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.ConnectorContext; 28 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequest; 29 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequestStyle; 30 | import com.fasterxml.jackson.annotation.JsonTypeName; 31 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 32 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 33 | import org.immutables.value.Value; 34 | 35 | import javax.annotation.Nullable; 36 | import java.util.List; 37 | 38 | import static com.amazonaws.appflow.custom.connector.Constants.MAX_RESULT_SIZE; 39 | 40 | /** 41 | * Represents the input of a QueryData operation. 42 | */ 43 | @ConnectorRequestStyle 44 | @Value.Immutable 45 | @JsonSerialize(as = ImmutableQueryDataRequest.class) 46 | @JsonDeserialize(as = ImmutableQueryDataRequest.class) 47 | @JsonTypeName("QueryDataRequest") 48 | public interface QueryDataRequest extends ConnectorRequest { 49 | /** 50 | * Unique identifier for the entity. Can be entityId/ entityName / entityPath+name / entityUrl etc. 51 | */ 52 | String entityIdentifier(); 53 | 54 | /** 55 | * Field values to retrieve. If null, it will provide all the fields for the entity. 56 | */ 57 | @Nullable 58 | List selectedFieldNames(); 59 | 60 | /** 61 | * Filter expression string similar to the WHERE clause in SQL. 62 | */ 63 | @Nullable 64 | String filterExpression(); 65 | 66 | /** 67 | * Maximum number of records needs to be returned as part of single call. Default value is 1000. 68 | */ 69 | @Value.Default 70 | default Long maxResults() { 71 | return MAX_RESULT_SIZE; 72 | } 73 | 74 | /** 75 | * The pagination token - next page should start from this token value. 76 | */ 77 | @Nullable 78 | String nextToken(); 79 | 80 | /** 81 | * Context contains the connector settings, credentials and APi version etc. 82 | */ 83 | ConnectorContext connectorContext(); 84 | } 85 | -------------------------------------------------------------------------------- /custom-connector-queryfilter/src/main/java/com/amazonaws/appflow/custom/connector/queryfilter/CustomConnectorParseTreeBuilder.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Amazon AppFlow Custom Connector SDK 4 | * %% 5 | * Copyright (C) 2021 Amazon Web Services 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package com.amazonaws.appflow.custom.connector.queryfilter; 21 | 22 | import org.antlr.v4.runtime.CharStream; 23 | import org.antlr.v4.runtime.CharStreams; 24 | import org.antlr.v4.runtime.CommonTokenStream; 25 | import org.antlr.v4.runtime.tree.ParseTree; 26 | 27 | import com.amazonaws.appflow.custom.connector.queryfilter.antlr.CustomConnectorQueryFilterLexer; 28 | import com.amazonaws.appflow.custom.connector.queryfilter.antlr.CustomConnectorQueryFilterParser; 29 | 30 | import java.util.Objects; 31 | 32 | /** 33 | * Helper class to validate and construct a parse tree for a given filter expression 34 | */ 35 | public final class CustomConnectorParseTreeBuilder { 36 | 37 | private CustomConnectorParseTreeBuilder() { 38 | // To avoid instantiation of the helper class 39 | } 40 | 41 | /** 42 | * Validates and generates a parse tree the provided filterExpression and reports syntax error if any 43 | * 44 | * @param filterExpression 45 | * @return a parse tree for the expression 46 | */ 47 | public static ParseTree parse(final String filterExpression) { 48 | Objects.requireNonNull(filterExpression, "Filter expression can't be null"); 49 | CharStream cs = CharStreams.fromString(filterExpression); 50 | CustomConnectorQueryFilterLexer customConnectorQueryFilterLexer = new CustomConnectorQueryFilterLexer(cs); 51 | CommonTokenStream cts = new CommonTokenStream(customConnectorQueryFilterLexer); 52 | CustomConnectorQueryFilterParser parser = new CustomConnectorQueryFilterParser(cts); 53 | parser.removeErrorListeners(); // remove any pre-existing error listeners and register custom listeners 54 | SyntaxErrorReporter syntaxErrorReporter = new SyntaxErrorReporter(); 55 | parser.addErrorListener(syntaxErrorReporter); 56 | ParseTree tree = parser.queryfilter(); 57 | if (syntaxErrorReporter.hasError()) { 58 | throw new InvalidFilterExpressionException("Filter expression has the following syntax errors : " 59 | + syntaxErrorReporter.getSyntaxErrors()); 60 | } 61 | return tree; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/write/WriteDataRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model.write; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.ConnectorContext; 28 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequest; 29 | import com.amazonaws.appflow.custom.connector.model.ConnectorRequestStyle; 30 | import com.fasterxml.jackson.annotation.JsonTypeName; 31 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 32 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 33 | import org.immutables.value.Value; 34 | 35 | import javax.annotation.Nullable; 36 | import java.util.List; 37 | 38 | /** 39 | * Represents the input of a WriteData operation. 40 | */ 41 | @ConnectorRequestStyle 42 | @Value.Immutable 43 | @JsonSerialize(as = ImmutableWriteDataRequest.class) 44 | @JsonDeserialize(as = ImmutableWriteDataRequest.class) 45 | @JsonTypeName("WriteDataRequest") 46 | public interface WriteDataRequest extends ConnectorRequest { 47 | /** 48 | * Unique identifier for the entity. Can be entityId/ entityName / entityPath+name / entityUrl etc. 49 | */ 50 | String entityIdentifier(); 51 | 52 | /** 53 | * Write operation type needs to be called. 54 | */ 55 | WriteOperationType operation(); 56 | 57 | /** 58 | * Primary keys of the entity. Used for DELETE/ UPDATE/ UPSERT operations. 59 | */ 60 | @Nullable 61 | List idFieldNames(); 62 | 63 | /** 64 | * List of JSON serialized string of the entity record as per the entity metadata. 65 | */ 66 | @Nullable 67 | List records(); 68 | 69 | /** 70 | * Specifies that the WRITE operation must fail immediately after encountering the first instance of failure 71 | * when writing a batch of records to the Application. Alternatively, if the application supports the allOrNone 72 | * behavior the connector can pass on the flag to the application. 73 | */ 74 | @Nullable 75 | Boolean allOrNone(); 76 | 77 | /** 78 | * Context contains the connector settings, credentials and API version etc. 79 | */ 80 | ConnectorContext connectorContext(); 81 | } 82 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/ErrorCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model; 26 | 27 | /** 28 | * Collection of all normalized error codes for returning errors back to AppFlow. 29 | */ 30 | public enum ErrorCode { 31 | /** 32 | * Invalid arguments provided as input/HttpStatus 400/413 from application/Bad Request exception from Application. 33 | * For example QueryURI too large, write request payload too large etc. 34 | */ 35 | InvalidArgument, 36 | 37 | /** 38 | * Credentials were rejected by the underlying application/HttpStatus 401 from Application. 39 | */ 40 | InvalidCredentials, 41 | 42 | /** 43 | * Resource access denied by the underlying application/HttpStatus 403 from Application. 44 | */ 45 | AccessDenied, 46 | 47 | /** 48 | * The request to the underlying application timed out/HttpStatus 408 from Application/ 49 | * HttpClient timeout while sending request. 50 | */ 51 | RequestTimeout, 52 | 53 | /** 54 | * Request got rejected by the underlying application due to rate limit violation/HttpStatus 429 from Application. 55 | */ 56 | RateLimitExceeded, 57 | 58 | /** 59 | * Application is not available to serve the requests at the moment/HttpStatus 503 from Application. 60 | */ 61 | ServiceUnavailable, 62 | 63 | /** 64 | * Specifies error is due to client or HttpStatus 4XX from Application. 65 | * Use specific error codes if present. 66 | */ 67 | ClientError, 68 | 69 | /** 70 | * Specifies error is due to Application or HttpStatus 5XX from Application. 71 | * Use specific error codes if present. 72 | */ 73 | ServerError, 74 | 75 | /** 76 | * Unknown Error from the Application. Use this ErrorCode only when you are not able to use the 77 | * other specific error codes. 78 | */ 79 | UnknownError, 80 | 81 | /** 82 | * Specifies that the connector encountered failure, for some records, while writing to the application. 83 | */ 84 | PartialWriteFailure, 85 | 86 | /** 87 | * Specifies that the connector is unable to find resource like AWS SecretManagerARN etc. 88 | */ 89 | ResourceNotFoundError 90 | } 91 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/ConnectorContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.credentials.Credentials; 28 | import com.amazonaws.appflow.custom.connector.model.metadata.EntityDefinition; 29 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 30 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 31 | import org.immutables.value.Value; 32 | 33 | import javax.annotation.Nullable; 34 | import java.util.Map; 35 | 36 | /** 37 | * Represents the Connector Context which contains the connectorRuntimeSettings, credentials, apiVersion, entityMetadata. 38 | */ 39 | @Value.Immutable 40 | @JsonSerialize(as = ImmutableConnectorContext.class) 41 | @JsonDeserialize(as = ImmutableConnectorContext.class) 42 | public interface ConnectorContext { 43 | 44 | /** 45 | * Connector settings required for API call. For example, for the Read API it will contains all the 46 | * ConnectorSettingScope.SOURCE settings. Key will be ConnectorSetting.key() and value will be the input provided by 47 | * user. 48 | */ 49 | @Nullable 50 | Map connectorRuntimeSettings(); 51 | 52 | /** 53 | * Credentials which will be used to make API call. 54 | */ 55 | @Nullable 56 | Credentials credentials(); 57 | 58 | /** 59 | * API version to use. Value will be the API Version supported by Connector as part of Connector Configuration. 60 | */ 61 | String apiVersion(); 62 | 63 | /** 64 | * Flow name to use for logging. 65 | * @return 66 | */ 67 | @Nullable 68 | String flowName(); 69 | 70 | /** 71 | * Execution Id to use for logging. 72 | * @return 73 | */ 74 | @Nullable 75 | String executionId(); 76 | 77 | /** 78 | * Connector profile name to use for logging. 79 | * @return 80 | */ 81 | @Nullable 82 | String connectorProfileLabel(); 83 | 84 | /** 85 | * Entity definition in compressed form. As it will be required by calling application as well as connector lambda 86 | * to serialize/deserialize request/response payload. 87 | */ 88 | @Nullable 89 | EntityDefinition entityDefinition(); 90 | } 91 | -------------------------------------------------------------------------------- /custom-connector-sdk/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 29 | 30 | aws-appflow-custom-connector 31 | software.amazon.appflow 32 | 1.0.9 33 | 34 | 4.0.0 35 | 36 | aws-custom-connector-sdk 37 | 38 | 39 | Amazon Web Services 40 | https://aws.amazon.com/ 41 | 42 | 43 | 2021 44 | 45 | 46 | 47 | Apache License 2.0 48 | http://www.apache.org/licenses/LICENSE-2.0 49 | repo 50 | 51 | 52 | 53 | 54 | 2.17.1 55 | 1.0.1 56 | 20231013 57 | 58 | 59 | 60 | 61 | org.apache.logging.log4j 62 | log4j-api 63 | ${log4j.version} 64 | 65 | 66 | org.apache.logging.log4j 67 | log4j-core 68 | ${log4j.version} 69 | 70 | 71 | org.apache.logging.log4j 72 | log4j-slf4j18-impl 73 | ${log4j.version} 74 | 75 | 76 | com.amazonaws.secretsmanager 77 | aws-secretsmanager-caching-java 78 | ${secretsmanager.version} 79 | 80 | 81 | org.json 82 | json 83 | ${json.version} 84 | 85 | 86 | -------------------------------------------------------------------------------- /custom-connector-queryfilter/src/main/configuration/grammar/CustomConnectorQueryFilterLexer.g4: -------------------------------------------------------------------------------- 1 | lexer grammar CustomConnectorQueryFilterLexer; 2 | 3 | @lexer::header{ 4 | package com.amazonaws.appflow.custom.connector.queryfilter.antlr; 5 | } 6 | 7 | // logical operator tokens 8 | AND : 'AND' | 'and' ; 9 | OR : 'OR' | 'or' ; 10 | NOT : 'NOT' | 'not' ; 11 | TRUE : 'TRUE' |'True'|'true' ; 12 | FALSE : 'FALSE' | 'False'| 'false' ; 13 | GT : '>' ; 14 | GE : '>=' ; 15 | LT : '<' ; 16 | LE : '<=' ; 17 | EQ : '=' ; 18 | NE : '!='; 19 | LIKE : 'CONTAINS' | 'contains' ; 20 | BETWEEN : 'BETWEEN' | 'between' ; 21 | // string literals 22 | LPAREN : '(' ; 23 | RPAREN : ')' ; 24 | NULL : 'null'; 25 | IN : 'IN' | 'in'; 26 | LIMIT : 'LIMIT' | 'limit'; 27 | COMMA : ','; 28 | 29 | // represents identifier string in filter expression. 30 | IDENTIFIER : [a-zA-Z][A-Za-z0-9_.-]*; 31 | 32 | // represents a positive non-zero integer 33 | POS_INTEGER: [1-9][0-9]+ 34 | ; 35 | 36 | // represents decimal values like 5.0 or -5.0 etc 37 | DECIMAL :'-'? [0-9]+ ( '.' [0-9]+ )? 38 | ; 39 | 40 | // represents single quote string like 'grammar' etc 41 | SINGLE_STRING 42 | : '\'' (~('\'') | STR_ESC)+ '\'' 43 | ; 44 | 45 | // represents double quote string like "grammar" etc 46 | DOUBLE_STRING 47 | : '"'(~('"') | STR_ESC)+ '"' 48 | ; 49 | 50 | // represents empty single quote string like '' 51 | EMPTY_SINGLE_STRING 52 | : '\'''\'' 53 | ; 54 | 55 | // represents empty double quote string like "" 56 | EMPTY_DOUBLE_STRING 57 | : '"''"' 58 | ; 59 | 60 | fragment STR_ESC 61 | : '\\' ('"' | '\\'|'\''| 't' | 'n' | 'r') // add more: Unicode esapes, ... 62 | ; 63 | // represents white spaces 64 | WS : [ \r\t\u000C\n]+ -> skip; 65 | 66 | // ISO 8601 Date and Time format 67 | // Year: 68 | // YYYY (eg 1997) 69 | // Year and month: 70 | // YYYY-MM (eg 1997-07) 71 | // Complete date: 72 | // YYYY-MM-DD (eg 1997-07-16) 73 | // Complete date plus hours and minutes: 74 | // YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00) 75 | // Complete date plus hours, minutes and seconds: 76 | // YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00) 77 | // Complete date plus hours, minutes, seconds and a decimal fraction of a 78 | //second 79 | // YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00) 80 | //where: 81 | // 82 | // YYYY = four-digit year 83 | // MM = two-digit month (01=January, etc.) 84 | // DD = two-digit day of month (01 through 31) 85 | // hh = two digits of hour (00 through 23) (am/pm NOT allowed) 86 | // mm = two digits of minute (00 through 59) 87 | // ss = two digits of second (00 through 59) 88 | // s = one or more digits representing a decimal fraction of a second 89 | // TZD = time zone designator (Z or +hh:mm or -hh:mm) 90 | 91 | // CustomConnector will either support ISO DATE or ISO DateTime 92 | 93 | DATE : [0-9] [0-9] [0-9] [0-9] '-' ('0'[1-9] | '1'[0-2]) '-' ('0'[0-9] | '1'[0-9] | '2'[0-9] | '3'[0-1]); 94 | DATETIME : DATE 'T' TIME; 95 | 96 | fragment TIME : ('0'[0-9] | '1'[0-9] | '2'[0-4]) ':' [0-5][0-9] ':' [0-5][0-9] ('.' [0-9]+)? 'Z'; 97 | -------------------------------------------------------------------------------- /custom-connector-sdk/src/main/java/com/amazonaws/appflow/custom/connector/model/ConnectorRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * - 3 | * * #%L 4 | * * Amazon AppFlow Custom Connector SDK. 5 | * * 6 | * %% 7 | * Copyright (C) 2021 Amazon Web Services 8 | * * 9 | * %% 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * #L% 22 | * 23 | */ 24 | 25 | package com.amazonaws.appflow.custom.connector.model; 26 | 27 | import com.amazonaws.appflow.custom.connector.model.connectorconfiguration.ImmutableDescribeConnectorConfigurationRequest; 28 | import com.amazonaws.appflow.custom.connector.model.credentials.ImmutableValidateCredentialsRequest; 29 | import com.amazonaws.appflow.custom.connector.model.metadata.ImmutableDescribeEntityRequest; 30 | import com.amazonaws.appflow.custom.connector.model.metadata.ImmutableListEntitiesRequest; 31 | import com.amazonaws.appflow.custom.connector.model.query.ImmutableQueryDataRequest; 32 | import com.amazonaws.appflow.custom.connector.model.retreive.ImmutableRetrieveDataRequest; 33 | import com.amazonaws.appflow.custom.connector.model.settings.ImmutableValidateConnectorRuntimeSettingsRequest; 34 | import com.amazonaws.appflow.custom.connector.model.write.ImmutableWriteDataRequest; 35 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 36 | import com.fasterxml.jackson.annotation.JsonSubTypes; 37 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 38 | 39 | /** 40 | * Base class for all user facing requests. 41 | */ 42 | @JsonIgnoreProperties(ignoreUnknown = true) 43 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") 44 | @JsonSubTypes({ 45 | @JsonSubTypes.Type(value = ImmutableValidateConnectorRuntimeSettingsRequest.class, name = "ValidateConnectorRuntimeSettingsRequest"), 46 | @JsonSubTypes.Type(value = ImmutableValidateCredentialsRequest.class, name = "ValidateCredentialsRequest"), 47 | @JsonSubTypes.Type(value = ImmutableDescribeEntityRequest.class, name = "DescribeEntityRequest"), 48 | @JsonSubTypes.Type(value = ImmutableListEntitiesRequest.class, name = "ListEntitiesRequest"), 49 | @JsonSubTypes.Type(value = ImmutableDescribeConnectorConfigurationRequest.class, name = "DescribeConnectorConfigurationRequest"), 50 | @JsonSubTypes.Type(value = ImmutableQueryDataRequest.class, name = "QueryDataRequest"), 51 | @JsonSubTypes.Type(value = ImmutableRetrieveDataRequest.class, name = "RetrieveDataRequest"), 52 | @JsonSubTypes.Type(value = ImmutableWriteDataRequest.class, name = "WriteDataRequest")}) 53 | public interface ConnectorRequest extends AutoCloseable { 54 | @Override 55 | default void close() throws Exception { 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /custom-connector-queryfilter/src/main/configuration/grammar/CustomConnectorQueryFilterParser.g4: -------------------------------------------------------------------------------- 1 | parser grammar CustomConnectorQueryFilterParser; 2 | 3 | @parser::header{ 4 | package com.amazonaws.appflow.custom.connector.queryfilter.antlr; 5 | } 6 | 7 | options { tokenVocab=CustomConnectorQueryFilterLexer; } 8 | 9 | // 'queryfilter' is the root node for the filter expression 10 | queryfilter 11 | : expression EOF 12 | | limitexpression EOF 13 | ; 14 | 15 | limitexpression 16 | : op=limit right=count #limitExpression 17 | | left=expression op=limit right=count #limitExpression // SQL 'LIMIT xyz' operator 18 | ; 19 | 20 | expression 21 | : LPAREN expression RPAREN #parenExpression // supports parenthesis expressions 22 | // logical operators support 23 | | NOT expression #notExpression 24 | | left=expression op=andBinary right=expression #aNDBinaryExpression 25 | | left=expression op=orBinary right=expression #oRBinaryExpression 26 | | left=identifier op=gtComparator right=value #greaterThanComparatorExpression 27 | | left=identifier op=geComparator right=value #greaterThanEqualToComparatorExpression 28 | | left=identifier op=ltComparator right=value #lesserThanComparatorExpression 29 | | left=identifier op=leComparator right=value #lesserThanEqualToComparatorExpression 30 | | left=identifier op=eqComparator right=value #equalToComparatorExpression 31 | | left=identifier op=eqComparator right=bool #boolEqualToComparatorExpression 32 | | left=identifier op=neComparator right=value #notEqualToComparatorExpression 33 | | left=identifier op=neComparator right=bool #boolNotEqualToComparatorExpression 34 | | left=identifier op=likeComparator right=value #likeComparatorExpression 35 | | (left=identifier op=betweenComparator (l1=value op1=andBinary right=value)) #betweenExpression 36 | | identifier #identifierExpression 37 | // Following is a leaf node in the parse tree 38 | // This allows validation and transformations of values. 39 | | value #valueExpression 40 | | identifier op=in LPAREN value (COMMA value)* RPAREN # inExpression // Supports SQL like 'IN' operator 41 | ; 42 | 43 | gtComparator 44 | : GT ; 45 | 46 | geComparator 47 | : GE ; 48 | 49 | ltComparator 50 | : LT ; 51 | 52 | leComparator 53 | : LE ; 54 | 55 | eqComparator 56 | : EQ ; 57 | 58 | neComparator 59 | : NE ; 60 | 61 | likeComparator 62 | : LIKE ; 63 | 64 | betweenComparator 65 | : BETWEEN ; 66 | 67 | andBinary 68 | : AND ; 69 | 70 | orBinary 71 | : OR 72 | ; 73 | 74 | bool 75 | : TRUE | FALSE 76 | ; 77 | 78 | identifier 79 | :IDENTIFIER ; 80 | 81 | in 82 | :IN ; 83 | 84 | limit 85 | :LIMIT ; 86 | 87 | // Following is to support different String formats in the value expression 88 | string 89 | : SINGLE_STRING 90 | | DOUBLE_STRING 91 | | EMPTY_DOUBLE_STRING 92 | | EMPTY_SINGLE_STRING 93 | | NULL 94 | ; 95 | 96 | value 97 | : string #stringValueExpression 98 | | POS_INTEGER #decimalValueExpression 99 | | DECIMAL #decimalValueExpression 100 | | DATE #isoDate 101 | | DATETIME #isoDateTime 102 | ; 103 | 104 | count 105 | : POS_INTEGER #countValueExpression 106 | ; 107 | --------------------------------------------------------------------------------