Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Amazon SQS Connector #1

Merged
merged 19 commits into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Compiled class file
*.class
*.balx

# Log file
*.log

#conf file
ballerina.conf

# BlueJ files
*.ctxt

Expand All @@ -21,3 +25,21 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Ignore everything in this directory
target
.classpath
.settings
.project
*.iml
*.iws
*.ipr
.idea
.m2
.vscode/
*.ballerina/

# Ignore ballerina files
temp.bal.ballerina/
target/
.DS_Store
37 changes: 37 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (c) 2019, WSO2 Inc. (http://wso2.com) All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

script:
- BALLERINA_VERSION=${VERSION:-1.0.0}
- echo -e "\033[36m${BALLERINA_VERSION}\033[m"

- DISTRIBUTION_NAME=ballerina-${BALLERINA_VERSION}
- echo -e "\033[36m${DISTRIBUTION_NAME}\033[m"

- DOWNLOAD_CHANNEL=${CHANNEL:-nightly}
- echo -e "\033[36m${DOWNLOAD_CHANNEL}\033[m"

- DOWNLOAD_LOCATION=${URL:-https://product-dist.ballerina.io}
- echo -e "\033[36m${DOWNLOAD_LOCATION}\033[m"

- echo -e "\033[36m${DOWNLOAD_LOCATION}/${DOWNLOAD_CHANNEL}/${BALLERINA_VERSION}${RC:-}/${DISTRIBUTION_NAME}${RC:-}.zip\033[m"
- wget ${DOWNLOAD_LOCATION}/${DOWNLOAD_CHANNEL}/${BALLERINA_VERSION}${RC:-}/${DISTRIBUTION_NAME}${RC:-}.zip

- unzip -q ${DISTRIBUTION_NAME}${RC:-}.zip

- export PATH=${PATH}:$(pwd)/${DISTRIBUTION_NAME}/bin

- ballerina --version

- ballerina build --skip-tests amazonsqs
19 changes: 19 additions & 0 deletions Ballerina.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
org_name = "wso2"
version = "0.9.0"
lockfile_version = "1.0.0"
ballerina_version = "1.0.0"

[[imports."wso2/amazonsqs:0.9.0"]]
org_name = "ballerinax"
name = "java"
version = "0.0.0"

[[imports."wso2/amazonsqs:0.9.0"]]
org_name = "ballerinax"
name = "java.arrays"
version = "0.0.0"

[[imports."ballerinax/java.arrays:0.0.0"]]
org_name = "ballerinax"
name = "java"
version = "0.0.0"
7 changes: 7 additions & 0 deletions Ballerina.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[project]
org-name= "wso2"
license= ["Apache-2.0"]
authors = ["WSO2"]
version= "0.9.0"
keywords = ["amazonsqs", "Amazon", "SQS", "Ballerina", "connector", "client"]
repository = "https://github.com/wso2-ballerina/module-amazonsqs"
79 changes: 78 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,78 @@
# module-amazonsqs
# Ballerina Amazon SQS Connector

Amazon SQS Connector allows you to connect to the Amazon Simple Queue Service (SQS) via REST API from Ballerina.

## Compatibility
| Ballerina Language Version | Amazon SQS API version |
| -------------------------- | ---------------------- |
| 1.0.0 | 2012-11-05 |

The following sections provide you with information on how to use the Ballerina Amazon SQS connector.

- [Contribute To Develop](#contribute-to-develop)
- [Working with Amazon SQS Connector Actions](#Working-with-Amazon-SQS-Connector)
- [Sample](#sample)

### Contribute To develop

Clone the repository by running the following command
```shell
git clone https://github.com/wso2-ballerina/module-amazonsqs.git
```

### Working with Amazon SQS Connector

First, import the `wso2/amazonsqs` module into the Ballerina project.

```ballerina
import wso2/amazonsqs;
```

In order for you to use the Amazon SQS Connector, first you need to create an Amazon SQS Client.

Ballerina provides a [config module](https://ballerina.io/learn/api-docs/ballerina/config.html) to obtain parameters from the configuration file. Specify the configuration object and create the client as follows.

```ballerina
amazonsqs:Configuration configuration = {
Maninda marked this conversation as resolved.
Show resolved Hide resolved
accessKey: config:getAsString("ACCESS_KEY_ID"),
secretKey: config:getAsString("SECRET_ACCESS_KEY"),
region: config:getAsString("REGION"),
accountNumber: config:getAsString("ACCOUNT_NUMBER"),
trustStore: config:getAsString("TRUST_STORE"),
trustStorePassword: config:getAsString("TRUST_STORE_PASSWORD")
};

amazonsqs:Client sqsClient = new(configuration);
```

##### Sample

```ballerina
import ballerina/log;
import wso2/amazonsqs;

// Add the SQS credentials as the Configuration
amazonsqs:Configuration configuration = {
accessKey: "AKIAIOSFODNN7EXAMPLE",
secretKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
region: "us-east-2",
accountNumber: "610973236798",
trustStore: "${ballerina.home}/bre/security/ballerinaTruststore.p12",
trustStorePassword: "ballerina"
};

amazonsqs:Client sqsClient = new(configuration);

public function main(string... args) {

// Create a new SQS Standard queue named "newQueue"
map<string> attributes = {};
string|error response = sqsClient->createQueue("newQueue", attributes);
if (response is string) {
log:printInfo("Created queue URL: " + response);
} else {
log:printInfo("Error while creating a queue");
}

}
```
Loading