From 70bc52a6f545912f357b8e0c1c52fbd928d1c217 Mon Sep 17 00:00:00 2001 From: kasthuriraajan Date: Mon, 3 May 2021 15:41:49 +0530 Subject: [PATCH] Migrate to SwanLake Alpha5 --- .ballerina/ballerina-version | 2 +- Ballerina.toml | 8 ++++++-- Dependencies.toml | 25 +++++++++++++------------ Package.md | 20 ++++++++++---------- README.md | 20 ++++++++++---------- endpoint.bal | 9 ++++++--- samples/createContact.bal | 2 +- samples/createContactGroup.bal | 2 +- samples/deleteContact.bal | 2 +- samples/deleteContactGroup.bal | 2 +- samples/deleteContactPhoto.bal | 2 +- samples/getContactGroup.bal | 2 +- samples/getContacts.bal | 2 +- samples/listContactGroup.bal | 2 +- samples/listContacts.bal | 2 +- samples/searchContacts.bal | 2 +- samples/updateContactGroup.bal | 2 +- samples/uploadContactPhoto.bal | 2 +- tests/main_test.bal | 6 +++--- utils.bal | 8 +++++++- 20 files changed, 68 insertions(+), 54 deletions(-) diff --git a/.ballerina/ballerina-version b/.ballerina/ballerina-version index ebc291f..d6f4ee4 100755 --- a/.ballerina/ballerina-version +++ b/.ballerina/ballerina-version @@ -1 +1 @@ -ballerina-slalpha4 +ballerina-slalpha5 diff --git a/Ballerina.toml b/Ballerina.toml index dc824e7..dff6f45 100644 --- a/Ballerina.toml +++ b/Ballerina.toml @@ -1,7 +1,11 @@ [package] org= "ballerinax" -name= "googleapis_people" -version= "0.1.0" +name= "googleapis.people" +version= "0.1.1" +license= ["Apache-2.0"] +authors = ["Ballerina"] +keywords = ["google", "people", "contact"] +repository = "https://github.com/ballerina-platform/module-ballerinax-googleapis.people" [build-options] observabilityIncluded = true diff --git a/Dependencies.toml b/Dependencies.toml index 33fa2c6..3f70e67 100644 --- a/Dependencies.toml +++ b/Dependencies.toml @@ -1,30 +1,31 @@ [[dependency]] org = "ballerina" -name = "io" -version = "0.6.0-alpha7" +name = "log" +version = "1.1.0-alpha8" [[dependency]] org = "ballerina" -name = "test" -version = "0.0.0" +name = "os" +version = "0.8.0-alpha8" [[dependency]] org = "ballerina" -name = "http" -version = "1.1.0-alpha7" +name = "url" +version = "1.1.0-alpha8" [[dependency]] org = "ballerina" -name = "url" -version = "1.1.0-alpha7" +name = "test" +version = "0.0.0" [[dependency]] org = "ballerina" -name = "log" -version = "1.1.0-alpha7" +name = "http" +version = "1.1.0-alpha8" [[dependency]] org = "ballerina" -name = "os" -version = "1.1.0-alpha7" +name = "io" +version = "0.6.0-alpha8" + diff --git a/Package.md b/Package.md index 970df54..378ea93 100644 --- a/Package.md +++ b/Package.md @@ -18,8 +18,8 @@ The Google People Ballerina Connector allows you to access the Google People API * Java 11 Installed Java Development Kit (JDK) with version 11 is required. -* Download the Ballerina [distribution](https://ballerinalang.org/downloads/) SLAlpha4 - Ballerina Swan Lake Alpha Version 4 is required. +* Download the Ballerina [distribution](https://ballerinalang.org/downloads/) SLAlpha5 + Ballerina Swan Lake Alpha Version 5 is required. * Instantiate the connector by giving authentication details in the HTTP client config. The HTTP client config has built-in support for BasicAuth and OAuth 2.0. Google People uses OAuth 2.0 to authenticate and authorize requests. * The Google People connector can be minimally instantiated in the HTTP client config using client ID, client secret, and refresh token. @@ -36,7 +36,7 @@ The Google People Ballerina Connector allows you to access the Google People API | | Versions | |:---------------------------:|:-------------------------------:| -| Ballerina Language | Swan Lake Alpha 4 | +| Ballerina Language | Swan Lake Alpha 5 | | Google People API | V1 | @@ -60,7 +60,7 @@ This file should have following configurations. Add the tokens obtained in the p #### For client operations ``` -[ballerinax.googleapis_people] +[ballerinax.googleapis.people] clientId = " clientSecret = "" refreshToken = "" @@ -72,7 +72,7 @@ refreshUrl = "" ### Create a Contact ```ballerina -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; @@ -112,7 +112,7 @@ public function main() { ``` ### Fetch a Contact ```ballerina -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; @@ -163,7 +163,7 @@ public function main() { ``` ### Search a Contact using a string value ```ballerina -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; @@ -195,7 +195,7 @@ public function main() { ### Delete a Contact ```ballerina -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; @@ -247,7 +247,7 @@ public function main() { ### Create a Contact Group ```ballerina -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; @@ -278,7 +278,7 @@ public function main() { ``` ### Fetch a Contact Group ```ballerina -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/README.md b/README.md index eeba367..48011a4 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ The Google People Ballerina Connector allows you to access the Google People API * Java 11 Installed Java Development Kit (JDK) with version 11 is required. -* Download the Ballerina [distribution](https://ballerinalang.org/downloads/) SLAlpha4 - Ballerina Swan Lake Alpha Version 4 is required. +* Download the Ballerina [distribution](https://ballerinalang.org/downloads/) SLAlpha5 + Ballerina Swan Lake Alpha Version 5 is required. * Instantiate the connector by giving authentication details in the HTTP client config. The HTTP client config has built-in support for BasicAuth and OAuth 2.0. Google People uses OAuth 2.0 to authenticate and authorize requests. * The Google People connector can be minimally instantiated in the HTTP client config using client ID, client secret, and refresh token. @@ -38,7 +38,7 @@ The Google People Ballerina Connector allows you to access the Google People API | | Versions | |:---------------------------:|:-------------------------------:| -| Ballerina Language | Swan Lake Alpha 4 | +| Ballerina Language | Swan Lake Alpha 5 | | Google People API | V1 | @@ -62,7 +62,7 @@ This file should have following configurations. Add the tokens obtained in the p #### For client operations ``` -[ballerinax.googleapis_people] +[ballerinax.googleapis.people] clientId = " clientSecret = "" refreshToken = "" @@ -73,7 +73,7 @@ refreshUrl = "" ### Create a Contact ```ballerina -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; @@ -113,7 +113,7 @@ public function main() { ``` ### Fetch a Contact ```ballerina -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; @@ -164,7 +164,7 @@ public function main() { ``` ### Search a Contact using a string value ```ballerina -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; @@ -196,7 +196,7 @@ public function main() { ### Delete a Contact ```ballerina -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; @@ -248,7 +248,7 @@ public function main() { ### Create a Contact Group ```ballerina -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; @@ -279,7 +279,7 @@ public function main() { ``` ### Fetch a Contact Group ```ballerina -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/endpoint.bal b/endpoint.bal index d7b23a2..9194f2d 100644 --- a/endpoint.bal +++ b/endpoint.bal @@ -43,6 +43,7 @@ public client class Client { # Fetch all from "Other Contacts". # # + readMasks - Restrict which fields on the person are returned + # + options - Record that contains options # + return - Stream of `PersonResponse` on success else an `error` @display {label: "List OtherContacts"} isolated remote function listOtherContacts(@display {label: "Read Masks"} OtherContactFieldMask[] readMasks, @@ -93,6 +94,7 @@ public client class Client { # Search a contacts. # # + query - String to be searched + # + readMasks - Restrict which fields on the person are returned # + return - `PersonResponse[]` on success else an `error` @display {label: "Search a Contact"} isolated remote function searchContacts(@display {label: "Searchable substring"} string query, @@ -129,7 +131,7 @@ public client class Client { http:Request request = new; string encodedString = check convertImageToBase64String(imagePath); json updatePayload = {"photoBytes": encodedString}; - request.setJsonPayload(updatePayload); + request.setJsonPayload(<@untainted>updatePayload); http:Response uploadResponse = check self.googleContactClient->patch(path, request); return handleUploadPhotoResponse(uploadResponse); } @@ -176,6 +178,7 @@ public client class Client { # Update a contact. # # + resourceName - Contact resource name + # + person - Person # + updatePersonFields - Restrict which fields on the person are returned # + personFields - Restrict which fields on the person are returned # + return - `Person` on success else an `error` @@ -198,7 +201,7 @@ public client class Client { string pathWithPersonFields = prepareUrlWithPersonFields(pathWithFields, personFields); Person updatedContact = propareUpdate(person, getContact); json payload = check getContact.cloneWithType(json); - request.setJsonPayload(payload); + request.setJsonPayload(<@untainted>payload); http:Response updateResponse = check self.googleContactClient->patch(pathWithPersonFields, request); var response = check handleResponse(updateResponse); return check response.cloneWithType(PersonResponse); @@ -326,7 +329,7 @@ public client class Client { getContactGroup.name = updateName; json payload = check getContactGroup.cloneWithType(json); json newpayload = {"contactGroup": payload}; - request.setJsonPayload(newpayload); + request.setJsonPayload(<@untainted>newpayload); http:Response httpResponse = check self.googleContactClient->put(path, request); var response = check handleResponse(httpResponse); return check response.cloneWithType(ContactGroup); diff --git a/samples/createContact.bal b/samples/createContact.bal index f06ea06..7ccf433 100644 --- a/samples/createContact.bal +++ b/samples/createContact.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/samples/createContactGroup.bal b/samples/createContactGroup.bal index 2db788d..70566ab 100644 --- a/samples/createContactGroup.bal +++ b/samples/createContactGroup.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/samples/deleteContact.bal b/samples/deleteContact.bal index f7dd05b..c3c5936 100644 --- a/samples/deleteContact.bal +++ b/samples/deleteContact.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/samples/deleteContactGroup.bal b/samples/deleteContactGroup.bal index a36c0a2..0f39ee9 100644 --- a/samples/deleteContactGroup.bal +++ b/samples/deleteContactGroup.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/samples/deleteContactPhoto.bal b/samples/deleteContactPhoto.bal index 83f5767..99fdb33 100644 --- a/samples/deleteContactPhoto.bal +++ b/samples/deleteContactPhoto.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/samples/getContactGroup.bal b/samples/getContactGroup.bal index 53d13b6..c7cb469 100644 --- a/samples/getContactGroup.bal +++ b/samples/getContactGroup.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/samples/getContacts.bal b/samples/getContacts.bal index aea0503..d5e47c7 100644 --- a/samples/getContacts.bal +++ b/samples/getContacts.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/samples/listContactGroup.bal b/samples/listContactGroup.bal index c068362..67870eb 100644 --- a/samples/listContactGroup.bal +++ b/samples/listContactGroup.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/samples/listContacts.bal b/samples/listContacts.bal index 0211b86..ae7d924 100644 --- a/samples/listContacts.bal +++ b/samples/listContacts.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/samples/searchContacts.bal b/samples/searchContacts.bal index e120b7c..eae0ee0 100644 --- a/samples/searchContacts.bal +++ b/samples/searchContacts.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/samples/updateContactGroup.bal b/samples/updateContactGroup.bal index b06aa14..23b33d3 100644 --- a/samples/updateContactGroup.bal +++ b/samples/updateContactGroup.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/samples/uploadContactPhoto.bal b/samples/uploadContactPhoto.bal index 9197cdd..addfa3e 100644 --- a/samples/uploadContactPhoto.bal +++ b/samples/uploadContactPhoto.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -import ballerinax/googleapis_people as contacts; +import ballerinax/googleapis.people as contacts; import ballerina/log; configurable string refreshToken = ?; diff --git a/tests/main_test.bal b/tests/main_test.bal index e896c4c..2e82e70 100644 --- a/tests/main_test.bal +++ b/tests/main_test.bal @@ -80,7 +80,7 @@ function testCreateContactGroup() { var createContactGroup = googleContactClient->createContactGroup("TestContactGroup"); if (createContactGroup is ContactGroup) { log:printInfo(createContactGroup.toString()); - contactGroupResourceName = createContactGroup.resourceName; + contactGroupResourceName = <@untainted>createContactGroup.resourceName; test:assertTrue(true, msg = "Creating Contact Group Failed"); } else { test:assertFail(msg = createContactGroup.message()); @@ -245,7 +245,7 @@ function testGetContactGroup() { var getContactGroup = googleContactClient->getContactGroup(contactGroupResourceName, 10); if (getContactGroup is ContactGroup) { log:printInfo(getContactGroup.toString()); - contactGroupResourceName = getContactGroup.resourceName; + contactGroupResourceName = <@untainted>getContactGroup.resourceName; test:assertTrue(true, msg = "Fetching Contact Group Failed"); } else { test:assertFail(msg = getContactGroup.message()); @@ -284,7 +284,7 @@ function testUpdateContactGroup() { var updateContactGroup = googleContactClient->updateContactGroup(contactGroupResourceName, "TestUpdated"); if (updateContactGroup is ContactGroup) { log:printInfo(updateContactGroup.toString()); - contactGroupResourceName = updateContactGroup.resourceName; + contactGroupResourceName = <@untainted>updateContactGroup.resourceName; test:assertTrue(true, msg = "Update Contact Group Failed"); } else { test:assertFail(msg = updateContactGroup.message()); diff --git a/utils.bal b/utils.bal index 8924c9f..17681aa 100644 --- a/utils.bal +++ b/utils.bal @@ -154,6 +154,7 @@ isolated function prepareReadGroupFieldsString(string[] readGroupFields) returns # Prepare URL with for batch operations. # +# + pathReceived - Recieved path # + resourceNames - String array of resource names # + return - The prepared URL string isolated function prepareResourceString(string pathReceived, string[] resourceNames) returns string { @@ -171,7 +172,7 @@ isolated function prepareResourceString(string pathReceived, string[] resourceNa # # + imagePath - Path to image source from root directory # + return - PersonResponse stream on success, else an error -isolated function convertImageToBase64String(string imagePath) returns string|error { +isolated function convertImageToBase64String(string imagePath) returns @tainted string|error { byte[] bytes = check io:fileReadBytes(imagePath); string encodedString = bytes.toBase64(); return encodedString; @@ -181,6 +182,7 @@ isolated function convertImageToBase64String(string imagePath) returns string|er # # + googleContactClient - Contact client # + persons - PersonResponse array +# + pathProvided -Provided path # + options - Record that contains options parameters # + return - PersonResponse stream on success, else an error function getContacts(http:Client googleContactClient, @tainted PersonResponse[] persons, string pathProvided = EMPTY_STRING, @@ -221,6 +223,7 @@ function getContacts(http:Client googleContactClient, @tainted PersonResponse[] # # + googleContactClient - Contact client # + persons - PersonResponse array +# + pathProvided -Provided path # + options - Record that contains options parameters # + return - PersonResponse stream on success, else an error isolated function getContactsStream(http:Client googleContactClient, @tainted PersonResponse[] persons, string pathProvided = EMPTY_STRING, @@ -256,6 +259,7 @@ isolated function getContactsStream(http:Client googleContactClient, @tainted Pe # # + googleContactClient - Contact client # + persons - PersonResponse array +# + pathProvided -Provided path # + options - Record that contains options parameters # + return - PersonResponse stream on success, else an error isolated function getOtherContactsStream(http:Client googleContactClient, @tainted PersonResponse[] persons, @@ -292,6 +296,7 @@ isolated function getOtherContactsStream(http:Client googleContactClient, @taint # # + googleContactClient - Contact client # + contactgroups - Array of contact groups +# + pathProvided -Provided path # + options - Record that contains options parameters # + return - PersonResponse stream on success, else an error isolated function getContactGroupStream(http:Client googleContactClient, @tainted ContactGroup[] contactgroups, @@ -327,6 +332,7 @@ isolated function getContactGroupStream(http:Client googleContactClient, @tainte # Prepare URL with contact list options. # # + pathProvided - An string of path +# + options - Record that contains options parameters # + return - The prepared URL string isolated function prepareUrlWithContactOptions(string pathProvided = EMPTY_STRING, ContactListOptions? options = ()) returns string {