Skip to content

Commit 1b15c6c

Browse files
Merge pull request #79 from SanduDS/master
Migration to swan lake preview7
2 parents 20937b4 + 234b67c commit 1b15c6c

17 files changed

+137
-18
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ jobs:
1313
uses: ballerina-platform/ballerina-action/@swan-lake-connector-release
1414
with:
1515
args:
16-
build --offline -a -c --skip-tests
16+
build
1717
env:
1818
JAVA_OPTS: -DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true
19+
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
20+
CLIENT_ID: ${{ secrets.CLIENT_ID }}
21+
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
22+
REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}
23+
REFRESH_URL: ${{ secrets.REFRESH_URL }}
24+
RECIPIENT: ${{ secrets.RECIPIENT }}
25+
SENDER: ${{ secrets.SENDER }}
26+
CC: ${{ secrets.CC }}
27+
ATTACHMENT_PATH: ${{ secrets.ATTACHMENT_PATH }}
28+
ATTACHMENT_CONTENT_TYPE: ${{ secrets.ATTACHMENT_CONTENT_TYPE }}
29+
INLINE_IMAGE_PATH: ${{ secrets.INLINE_IMAGE_PATH }}
30+
INLINE_IMAGE_NAME: ${{ secrets.INLINE_IMAGE_NAME }}
31+
IMAGE_CONTENT_TYPE: ${{ secrets.IMAGE_CONTENT_TYPE }}

.github/workflows/release.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,25 @@ jobs:
1313
uses: ballerina-platform/ballerina-action/@swan-lake-connector-release
1414
with:
1515
args:
16-
build --offline -a -c --skip-tests
16+
build
1717
- name: Ballerina Push
1818
uses: ballerina-platform/ballerina-action/@swan-lake-connector-release
1919
with:
2020
args:
21-
push -a
21+
push
2222
env:
2323
JAVA_OPTS: -DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true
2424
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }}
25+
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
26+
CLIENT_ID: ${{ secrets.CLIENT_ID }}
27+
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
28+
REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}
29+
REFRESH_URL: ${{ secrets.REFRESH_URL }}
30+
RECIPIENT: ${{ secrets.RECIPIENT }}
31+
SENDER: ${{ secrets.SENDER }}
32+
CC: ${{ secrets.CC }}
33+
ATTACHMENT_PATH: ${{ secrets.ATTACHMENT_PATH }}
34+
ATTACHMENT_CONTENT_TYPE: ${{ secrets.ATTACHMENT_CONTENT_TYPE }}
35+
INLINE_IMAGE_PATH: ${{ secrets.INLINE_IMAGE_PATH }}
36+
INLINE_IMAGE_NAME: ${{ secrets.INLINE_IMAGE_NAME }}
37+
IMAGE_CONTENT_TYPE: ${{ secrets.IMAGE_CONTENT_TYPE }}

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# limitations under the License.
1414

1515
script:
16-
- wget http://dist-dev.ballerina.io/downloads/swan-lake-preview5/ballerina-linux-installer-x64-swan-lake-preview5.deb
17-
- sudo dpkg -i ballerina-linux-installer-x64-swan-lake-preview5.deb
16+
- wget http://dist-dev.ballerina.io/downloads/swan-lake-preview7/ballerina-linux-installer-x64-swan-lake-preview7.deb
17+
- sudo dpkg -i ballerina-linux-installer-x64-swan-lake-preview7.deb
1818
- sudo apt-get install -f
1919
- ballerina --version
20-
- ballerina build -c --skip-tests googleapis.gmail
20+
- ballerina build -c --skip-tests

Ballerina.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
[project]
2-
org-name= "ballerinax"
3-
version= "0.99.1"
1+
[package]
2+
org = "ballerinax"
3+
name = "googleapis_gmail"
4+
version = "0.99.2"
45
authors = ["Ballerina"]
5-
repository = "https://github.com/ballerina-platform/module-gmail"
6+
repository = "https://github.com/ballerina-platform/module-ballerinax-googleapis.gmail"
67
keywords = ["gmail","email"]
78
license = ["Apache-2.0"]
89

9-
[dependencies]
10+
[build-options]
11+
observabilityIncluded = true
12+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ gmail:Client gmailClient = new (gmailConfig);
4444

4545
| Ballerina Language Versions | Gmail API Version |
4646
|:----------------------------:|:-----------------:|
47-
| Swan Lake Preview5 | v1 |
47+
| Swan Lake Preview7 | v1 |
4848

4949
## Sample
5050

Package.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
Connects to Gmail from Ballerina.
2+
3+
## Module Overview
4+
5+
Ballerina Gmail Connector provides the capability to send, read and delete emails through the Gmail REST API. It also provides the ability to read, trash, untrash and delete threads, ability to get the Gmail profile and mailbox history, etc. The connector handles OAuth 2.0 authentication.
6+
7+
## Configurations
8+
9+
Instantiate the connector by giving authentication details in the Gmail client config, which has built-in support for OAuth 2.0. Gmail uses OAuth 2.0 to authenticate and authorize requests. The Gmail connector can be minimally instantiated in the Gmail client config using the Access Token or by using the Client ID, Client Secret and Refresh Token.
10+
11+
**Obtaining Tokens to Run the Sample**
12+
13+
1. Visit [Google API Console](https://console.developers.google.com), click **Create Project**, and follow the wizard to create a new project.
14+
2. Go to **Credentials -> OAuth Consent Screen**, enter a product name to be shown to users, and click **Save**.
15+
3. On the **Credentials** tab, click **Create Credentials** and select **OAuth Client ID**.
16+
4. Select an application type, enter a name for the application, and specify a redirect URI (enter https://developers.google.com/oauthplayground if you want to use
17+
[OAuth 2.0 Playground](https://developers.google.com/oauthplayground) to receive the Authorization Code and obtain the
18+
Access Token and Refresh Token).
19+
5. Click **Create**. Your Client ID and Client Secret will appear.
20+
6. In a separate browser window or tab, visit [OAuth 2.0 Playground](https://developers.google.com/oauthplayground). Click on the `OAuth 2.0 Configuration`
21+
icon in the top right corner and click on `Use your own OAuth credentials` and provide your `OAuth Client ID` and `OAuth Client Secret`.
22+
7. Select the required Gmail API scopes from the list of API's, and then click **Authorize APIs**.
23+
8. When you receive your authorization code, click **Exchange authorization code for tokens** to obtain the refresh token and access token.
24+
25+
You can now enter the credentials in the Gmail client config.
26+
27+
```ballerina
28+
gmail:GmailConfiguration gmailConfig = {
29+
oauthClientConfig: {
30+
accessToken: <ACCESS_TOKEN>,
31+
refreshConfig: {
32+
refreshUrl: gmail:REFRESH_URL,
33+
refreshToken: <REFRESH_TOKEN>,
34+
clientId: <CLIENT_ID>,
35+
clientSecret: <CLIENT_SECRET>
36+
}
37+
}
38+
};
39+
40+
gmail:Client gmailClient = new (gmailConfig);
41+
```
42+
43+
## Compatibility
44+
45+
| Ballerina Language Versions | Gmail API Version |
46+
|:----------------------------:|:-----------------:|
47+
| Swan Lake Preview7 | v1 |
48+
49+
## Sample
50+
51+
```ballerina
52+
import ballerina/io;
53+
import ballerinax/googleapis.gmail;
54+
55+
gmail:GmailConfiguration gmailConfig = {
56+
oauthClientConfig: {
57+
accessToken: <ACCESS_TOKEN>,
58+
refreshConfig: {
59+
refreshUrl: gmail:REFRESH_URL,
60+
refreshToken: <REFRESH_TOKEN>,
61+
clientId: <CLIENT_ID>,
62+
clientSecret: <CLIENT_SECRET>
63+
}
64+
}
65+
};
66+
gmail:Client gmailClient = new (gmailConfig);
67+
public function main(string... args) {
68+
gmail:MessageRequest messageRequest = {};
69+
messageRequest.recipient = "[email protected]";
70+
messageRequest.sender = "[email protected]";
71+
messageRequest.cc = "[email protected]";
72+
messageRequest.subject = "Email-Subject";
73+
messageRequest.messageBody = "Email Message Body Text";
74+
// Set the content type of the mail as TEXT_PLAIN or TEXT_HTML.
75+
messageRequest.contentType = gmail:TEXT_PLAIN;
76+
string userId = "me";
77+
// Send the message.
78+
var sendMessageResponse = gmailClient->sendMessage(userId, messageRequest);
79+
if (sendMessageResponse is [string, string]) {
80+
// If successful, print the message ID and thread ID.
81+
[string, string] [messageId, threadId] = sendMessageResponse;
82+
io:println("Sent Message ID: " + messageId);
83+
io:println("Sent Thread ID: " + threadId);
84+
} else {
85+
// If unsuccessful, print the error returned.
86+
io:println("Error: ", sendMessageResponse);
87+
}
88+
}
89+
```

Readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.org/ballerina-platform/module-gmail.svg?branch=master)](https://travis-ci.org/ballerina-platform/module-gmail)
1+
[![Build Status](https://travis-ci.org/ballerina-platform/module-ballerinax-googleapis.gmail.svg?branch=master)](https://travis-ci.org/ballerina-platform/module-ballerinax-googleapis.gmail)
22

33
# Ballerina Gmail Connector
44

@@ -17,7 +17,7 @@ The following sections provide you with information on how to use the Ballerina
1717

1818
| Ballerina Language Versions | Gmail API Version |
1919
|:----------------------------:|:-----------------:|
20-
| Swan Lake Preview5 | v1 |
20+
| Swan Lake Preview7 | v1 |
2121

2222
## Feature Overview
2323

@@ -148,4 +148,4 @@ if (delete is error) {
148148
} else {
149149
io:println("Message deletion success!");
150150
}
151-
```
151+
```

src/googleapis.gmail/external_functions.bal renamed to external_functions.bal

File renamed without changes.

src/googleapis.gmail/gmail_data_mappings.bal renamed to gmail_data_mappings.bal

File renamed without changes.

0 commit comments

Comments
 (0)