Skip to content

Commit

Permalink
Adding documentation for ErrorCode
Browse files Browse the repository at this point in the history
  • Loading branch information
agrshubh committed Feb 28, 2022
1 parent dc7b282 commit becf14a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ The Amazon AppFlow Custom Connector SDK is available for both Java and Python on

#### For Java SDK Users:

Once you have the jar, create the Amazon Appflow client instance and invoke the AppFlow APIs.
Once you have the jar, create the Amazon AppFlow client instance and invoke the AppFlow APIs.

```
AmazonAppflow appflowClient = AmazonAppflowClientBuilder.standard()
Expand Down
2 changes: 1 addition & 1 deletion custom_connector_example/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Resources:
Handler: custom_connector_example.handlers.lambda_handler.salesforce_lambda_handler
Runtime: python3.8
CodeUri: ../.
Description: "Example for writing and deploying your Appflow connector"
Description: "Example for writing and deploying your AppFlow connector"
Timeout: 30
MemorySize: 256
Policies:
Expand Down
8 changes: 4 additions & 4 deletions custom_connector_integ_test/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Integration Test FrameWork
This document explains how to run the integration tests provided by Appflow for a custom connector.
This document explains how to run the integration tests provided by AppFlow for a custom connector.

## Prerequisites:

Expand All @@ -14,7 +14,7 @@ The framework provides the following test cases.
3. Running a flow from s3 -> connector
4. Running a flow from the connector -> s3

Additionally, we provide a test class that cleans up all Appflow resources created by the integration tests.
Additionally, we provide a test class that cleans up all AppFlow resources created by the integration tests.
This test case cleans up resources based on the prefix "Integ_{ResourceType}" e.g. Integ_Profile.
You can also provide a prefix in the test configuration which will be appended to all resources.
If you are running multiple test cases in the same aws account, be sure to use this prefix. Otherwise,
Expand Down Expand Up @@ -69,7 +69,7 @@ A base configuration file can be found in the current directory.
###Resources
The configuration file requires several aws resources to already exist in your account. The purpose of these
resources is described in the sample-test-config.json file.
1. A S3 bucket with Appflow bucket policy.
1. A S3 bucket with AppFlow bucket policy.
2. A Secrets Manager secret for each set of credentials.
3. A Lambda custom connector.

Expand Down Expand Up @@ -114,5 +114,5 @@ Tests in unittest run in alphabetical order. Be sure to name your test so that i
registered and before the profile is created.


This ensures that the Appflow test cases always run, run after the connectors and connector profiles are created,
This ensures that the AppFlow test cases always run, run after the connectors and connector profiles are created,
and run before all resources are deleted.
3 changes: 2 additions & 1 deletion custom_connector_sdk/lambda_handler/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ def __init__(self,
# List of JSON serialized string of the entity record as per the entity metadata.
self.records = records

# Write all or none if any of the entity records error out.
# Specifies that Write operation will fail after the first instance of a failure when attempting to put data
# to the Application. Or if the Connector Supports Batch operation it will write all records or none.
self.all_or_none = all_or_none

@classmethod
Expand Down
44 changes: 23 additions & 21 deletions custom_connector_sdk/lambda_handler/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,42 @@
ALL_TRIGGER_TYPES = [op for op in TriggerType]

class ErrorCode(Enum):
"""Enum of error codes."""
# Specifies error is due to client.
ClientError = auto()

# Specifies error is due to application.
ServerError = auto()

# Invalid arguments provided as input.
"""Collection of all normalized error codes for returning errors back to AppFlow."""
# Invalid arguments provided as input/HttpStatus 400/413 from application/Bad Request exception from Application.
# For example QueryURI too large, write request payload too large etc.
InvalidArgument = auto()

# Credentials were rejected by the underlying application.
# Credentials were rejected by the underlying application/HttpStatus 401 from Application.
InvalidCredentials = auto()

# Resource access denied by the underlying application.
# Resource access denied by the underlying application/HttpStatus 403 from Application.
AccessDenied = auto()

# The request to the underlying application timed out.
# The request to the underlying application timed out/HttpStatus 408 from Application/
# HttpClient timeout while sending request.
RequestTimeout = auto()

# Payload size is too large.
PayloadTooLarge = auto()

# Request got rejected by the underlying application due to rate limit violation.
# Request got rejected by the underlying application due to rate limit violation/HttpStatus 429 from Application.
RateLimitExceeded = auto()

# Not able to serve the request due to an internal error.
InternalServerError = auto()

# Server is not available to serve the requests at the moment.
# Application is not available to serve the requests at the moment/HttpStatus 503 from Application.
ServiceUnavailable = auto()

# Unknown Error from the application.
# Specifies error is due to client or HttpStatus 4XX from Application.
# Use specific error codes if present.
ClientError = auto()

# Specifies error is due to Application or HttpStatus 5XX from Application.
# Use specific error codes if present.
ServerError = auto()

# Unknown Error from the Application. Use this ErrorCode only when you are not able to use the
# other specific error codes.
UnknownError = auto()

# Specifies that the connector is failed to write all the records to the Application.
PartialWriteFailure = auto()

class ErrorDetails:
"""Represents the error details."""
def __init__(self, error_code: ErrorCode, error_message: str, retry_after_seconds: int = None):
Expand Down Expand Up @@ -303,7 +305,7 @@ class WriteDataResponse:
def __init__(self, is_success: bool,
error_details: ErrorDetails = None,
write_record_results: [WriteRecordResult] = None):
# Specifies if the operation is successful or not.
# Specifies if the operation is successful or not. In case of partial failures, this should be set as false.
self.is_success = is_success

# Error details if the Operation is unsuccessful.
Expand Down

0 comments on commit becf14a

Please sign in to comment.