-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Maninda/master
Add Amazon SQS Connector
- Loading branch information
Showing
15 changed files
with
1,508 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = { | ||
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"); | ||
} | ||
} | ||
``` |
Oops, something went wrong.