From a22ba035dec240f892f541c400e20e672da03926 Mon Sep 17 00:00:00 2001 From: Nuvindu Nirmana <63797478+Nuvindu@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:04:06 +0530 Subject: [PATCH] Change EOF format to LF (#9) --- README.md | 472 ++++++++++++------------- ballerina/Ballerina.toml | 32 +- ballerina/build.gradle | 162 ++++----- ballerina/tests/admin-test.bal | 490 +++++++++++++------------- build-config/resources/Ballerina.toml | 32 +- docs/spec/sanitations.md | 46 +-- examples/README.md | 114 +++--- examples/build.gradle | 152 ++++---- gradle.properties | 26 +- 9 files changed, 763 insertions(+), 763 deletions(-) diff --git a/README.md b/README.md index 1df3106..9c8af85 100644 --- a/README.md +++ b/README.md @@ -1,236 +1,236 @@ -# Ballerina Docusign Admin Connector - -[![Build](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/actions/workflows/ci.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/actions/workflows/ci.yml) -[![Trivy](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/actions/workflows/trivy-scan.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/actions/workflows/trivy-scan.yml) -[![GraalVM Check](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/actions/workflows/build-with-bal-test-native.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/actions/workflows/build-with-bal-test-native.yml) -[![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerinax-docusign.dsadmin.svg)](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/commits/main) -[![GitHub Issues](https://img.shields.io/github/issues/ballerina-platform/ballerina-library/module/docusign.dsadmin.svg?label=Open%20Issues)](https://github.com/ballerina-platform/ballerina-library/labels/module%2Fdocusign.dsadmin) -[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) - -[DocuSign](https://www.docusign.com) is a digital transaction management platform that enables users to securely sign, send, and manage documents electronically. - -The Ballerina DocuSign Admin connector integrates with the DocuSign platform, provides APIs to efficiently manages DocuSign users and permissions across all the accounts and domains within Ballerina applications. It supports [DocuSign Admin API V2](https://github.com/docusign/OpenAPI-Specifications/blob/master/admin.rest.swagger-v2.1.json). - -## Setup guide - -To utilize the DocuSign Admin connector, you must have access to the DocuSign REST API through a DocuSign account. - -### Step 1: Create a DocuSign account - -In order to use the DocuSign Admin connector, you need to first create the DocuSign credentials for the connector to interact with DocuSign. - -- You can [create an account](https://go.docusign.com/o/sandbox/) for free at the [Developer Center](https://developers.docusign.com/). - - Create DocuSign Account - -### Step 2: Create integration key and secret key - -1. **Create an integration key**: Visit the [Apps and Keys](https://admindemo.docusign.com/apps-and-keys) page on DocuSign. Click on `Add App and Integration Key,` provide a name for the app, and click `Create App`. This will generate an `Integration Key`. - - Create Integration Key - -2. **Generate a secret key**: Under the `Authentication` section, click on `Add Secret Key`. This will generate a secret Key. Make sure to copy and save both the `Integration Key` and `Secret Key`. - - Add Secret Key - -### Step 3: Generate refresh token - -1. **Add a redirect URI**: Click on `Add URI` and enter your redirect URI (e.g., ). - - Add Redirect URI - -2. **Generate the encoded key**: The `Encoded Key` is a base64 encoded string of your `Integration key` and `Secret Key` in the format `{IntegrationKey:SecretKey}`. You can generate this in your web browser's console using the `btoa()` function: `btoa('IntegrationKey:SecretKey')`. You can either generate the encoded key from an online base64 encoder. - -3. **Get the authorization code**: Visit the following URL in your web browser, replacing `{iKey}` with your Integration Key and `{redirectUri}` with your redirect URI. - - ```url - https://account-d.docusign.com/oauth/auth?response_type=code&scope=signature%20organization_read%20group_read%20account_read%20permission_read%20user_read%20user_write&client_id={iKey}&redirect_uri={redirectUri} - ``` - - This will redirect you to your Redirect URI with a `code` query parameter. This is your `authorization code`. - -4. **Get the refresh token**: Use the following `curl` command to get the refresh token, replacing `{encodedKey}` with your Encoded Key and `{codeFromUrl}` with your `authorization code`. - - ```bash - curl --location 'https://account-d.docusign.com/oauth/token' \ - --header 'Authorization: Basic {encodedKey}' \ - --header 'Content-Type: application/x-www-form-urlencoded' \ - --data-urlencode 'code={codeFromUrl}' \ - --data-urlencode 'grant_type=authorization_code' - ``` - - The response will contain your refresh token. Use `https://account-d.docusign.com/oauth/token` as the refresh URL. - -Remember to replace `{IntegrationKey:SecretKey}`, `{iKey}`, `{redirectUri}`, `{encodedKey}`, and `{codeFromUrl}` with your actual values. - -Above is about using the DocuSign Admin API in the developer mode. If your app is ready to go live, you need to follow the guidelines given [here](https://developers.docusign.com/docs/admin-api/go-live/) to make it work. - -## Quickstart - -To use the DocuSign Admin connector in your Ballerina project, modify the `.bal` file as follows. - -### Step 1: Import the module - -Import the `ballerinax/docusign.dsadmin` module into your Ballerina project. - -```ballerina -import ballerinax/docusign.dsadmin; -``` - -### Step 2: Instantiate a new connector - -Create a `dsadmin:ConnectionConfig` with the obtained OAuth2.0 tokens and initialize the connector with it. - -```ballerina -configurable string clientId = ?; -configurable string clientSecret = ?; -configurable string refreshToken = ?; -configurable string refreshUrl = ?; - -dsadmin:Client docuSignClient = check new({ - auth: { - clientId, - clientSecret, - refreshToken, - refreshUrl - } -}); -``` - -### Step 3: Invoke the connector operation - -You can now utilize the operations available within the connector. - -```ballerina -public function main() returns error? { - - dsadmin:OrganizationsResponse orgResponse = check docuSignClient->/v2/organizations(); - - dsadmin:OrganizationResponse[]? organizations = orgResponse.organizations; - dsadmin:OrganizationResponse organization = organizations[0]; - - dsadmin:NewUserResponse newUserResponse = check docuSignClient->/v2/organizations/[organization.id]/users.post( - { - user_name: "user1", - first_name: "name1", - email: "user1@docusignmail.com", - accounts: [ - { - id: accountId, - company_name: "Company" - } - ] - } - ); -} -``` - -### Step 4: Run the Ballerina application - -Use the following command to compile and run the Ballerina program. - -```bash -bal run -``` - -## Examples - -The DocuSign Admin connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/tree/main/examples). - -1. [Manage user information with DocuSign Admin](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/tree/main/examples/manage-user-information) - This example shows how to use DocuSign Admin API to to create users and retrieve user informations related to eSignature tasks. - -2. [Access permissions in user accounts](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/tree/main/examples/permissions-in-organizations) - This example shows how to use DocuSign Admin API to to view permission details of the user accounts. - -## Issues and projects - -The **Issues** and **Projects** tabs are disabled for this repository as this is part of the Ballerina library. To report bugs, request new features, start new discussions, view project boards, etc., visit the Ballerina library [parent repository](https://github.com/ballerina-platform/ballerina-library). - -This repository only contains the source code for the package. - -## Building from the source - -### Prerequisites - -1. Download and install Java SE Development Kit (JDK) version 17. You can download it from either of the following sources: - - - [Oracle JDK](https://www.oracle.com/java/technologies/downloads/) - - [OpenJDK](https://adoptium.net/) - - > **Note:** After installation, remember to set the `JAVA_HOME` environment variable to the directory where JDK was installed. - -2. Download and install [Ballerina Swan Lake](https://ballerina.io/). - -3. Download and install [Docker](https://www.docker.com/get-started). - - > **Note**: Ensure that the Docker daemon is running before executing any tests. - -4. Generate a Github access token with read package permissions, then set the following `env` variables: - - ```bash - export packageUser= - export packagePAT= - ``` - -### Build options - -Execute the commands below to build from the source. - -1. To build the package: - - ```bash - ./gradlew clean build - ``` - -2. To run the tests: - - ```bash - ./gradlew clean test - ``` - -3. To build the without the tests: - - ```bash - ./gradlew clean build -x test - ``` - -4. To debug package with a remote debugger: - - ```bash - ./gradlew clean build -Pdebug= - ``` - -5. To debug with Ballerina language: - - ```bash - ./gradlew clean build -PbalJavaDebug= - ``` - -6. Publish the generated artifacts to the local Ballerina central repository: - - ```bash - ./gradlew clean build -PpublishToLocalCentral=true - ``` - -7. Publish the generated artifacts to the Ballerina central repository: - - ```bash - ./gradlew clean build -PpublishToCentral=true - ``` - -## Contributing to Ballerina - -As an open source project, Ballerina welcomes contributions from the community. - -For more information, go to the [contribution guidelines](https://github.com/ballerina-platform/ballerina-lang/blob/master/CONTRIBUTING.md). - -## Code of conduct - -All contributors are encouraged to read the [Ballerina Code of Conduct](https://ballerina.io/code-of-conduct). - -## Useful links - -- Discuss code changes of the Ballerina project in [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com). -- Chat live with us via our [Discord server](https://discord.gg/ballerinalang). -- Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. +# Ballerina Docusign Admin Connector + +[![Build](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/actions/workflows/ci.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/actions/workflows/ci.yml) +[![Trivy](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/actions/workflows/trivy-scan.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/actions/workflows/trivy-scan.yml) +[![GraalVM Check](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/actions/workflows/build-with-bal-test-native.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/actions/workflows/build-with-bal-test-native.yml) +[![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerinax-docusign.dsadmin.svg)](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/commits/main) +[![GitHub Issues](https://img.shields.io/github/issues/ballerina-platform/ballerina-library/module/docusign.dsadmin.svg?label=Open%20Issues)](https://github.com/ballerina-platform/ballerina-library/labels/module%2Fdocusign.dsadmin) +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) + +[DocuSign](https://www.docusign.com) is a digital transaction management platform that enables users to securely sign, send, and manage documents electronically. + +The Ballerina DocuSign Admin connector integrates with the DocuSign platform, provides APIs to efficiently manages DocuSign users and permissions across all the accounts and domains within Ballerina applications. It supports [DocuSign Admin API V2](https://github.com/docusign/OpenAPI-Specifications/blob/master/admin.rest.swagger-v2.1.json). + +## Setup guide + +To utilize the DocuSign Admin connector, you must have access to the DocuSign REST API through a DocuSign account. + +### Step 1: Create a DocuSign account + +In order to use the DocuSign Admin connector, you need to first create the DocuSign credentials for the connector to interact with DocuSign. + +- You can [create an account](https://go.docusign.com/o/sandbox/) for free at the [Developer Center](https://developers.docusign.com/). + + Create DocuSign Account + +### Step 2: Create integration key and secret key + +1. **Create an integration key**: Visit the [Apps and Keys](https://admindemo.docusign.com/apps-and-keys) page on DocuSign. Click on `Add App and Integration Key,` provide a name for the app, and click `Create App`. This will generate an `Integration Key`. + + Create Integration Key + +2. **Generate a secret key**: Under the `Authentication` section, click on `Add Secret Key`. This will generate a secret Key. Make sure to copy and save both the `Integration Key` and `Secret Key`. + + Add Secret Key + +### Step 3: Generate refresh token + +1. **Add a redirect URI**: Click on `Add URI` and enter your redirect URI (e.g., ). + + Add Redirect URI + +2. **Generate the encoded key**: The `Encoded Key` is a base64 encoded string of your `Integration key` and `Secret Key` in the format `{IntegrationKey:SecretKey}`. You can generate this in your web browser's console using the `btoa()` function: `btoa('IntegrationKey:SecretKey')`. You can either generate the encoded key from an online base64 encoder. + +3. **Get the authorization code**: Visit the following URL in your web browser, replacing `{iKey}` with your Integration Key and `{redirectUri}` with your redirect URI. + + ```url + https://account-d.docusign.com/oauth/auth?response_type=code&scope=signature%20organization_read%20group_read%20account_read%20permission_read%20user_read%20user_write&client_id={iKey}&redirect_uri={redirectUri} + ``` + + This will redirect you to your Redirect URI with a `code` query parameter. This is your `authorization code`. + +4. **Get the refresh token**: Use the following `curl` command to get the refresh token, replacing `{encodedKey}` with your Encoded Key and `{codeFromUrl}` with your `authorization code`. + + ```bash + curl --location 'https://account-d.docusign.com/oauth/token' \ + --header 'Authorization: Basic {encodedKey}' \ + --header 'Content-Type: application/x-www-form-urlencoded' \ + --data-urlencode 'code={codeFromUrl}' \ + --data-urlencode 'grant_type=authorization_code' + ``` + + The response will contain your refresh token. Use `https://account-d.docusign.com/oauth/token` as the refresh URL. + +Remember to replace `{IntegrationKey:SecretKey}`, `{iKey}`, `{redirectUri}`, `{encodedKey}`, and `{codeFromUrl}` with your actual values. + +Above is about using the DocuSign Admin API in the developer mode. If your app is ready to go live, you need to follow the guidelines given [here](https://developers.docusign.com/docs/admin-api/go-live/) to make it work. + +## Quickstart + +To use the DocuSign Admin connector in your Ballerina project, modify the `.bal` file as follows. + +### Step 1: Import the module + +Import the `ballerinax/docusign.dsadmin` module into your Ballerina project. + +```ballerina +import ballerinax/docusign.dsadmin; +``` + +### Step 2: Instantiate a new connector + +Create a `dsadmin:ConnectionConfig` with the obtained OAuth2.0 tokens and initialize the connector with it. + +```ballerina +configurable string clientId = ?; +configurable string clientSecret = ?; +configurable string refreshToken = ?; +configurable string refreshUrl = ?; + +dsadmin:Client docuSignClient = check new({ + auth: { + clientId, + clientSecret, + refreshToken, + refreshUrl + } +}); +``` + +### Step 3: Invoke the connector operation + +You can now utilize the operations available within the connector. + +```ballerina +public function main() returns error? { + + dsadmin:OrganizationsResponse orgResponse = check docuSignClient->/v2/organizations(); + + dsadmin:OrganizationResponse[]? organizations = orgResponse.organizations; + dsadmin:OrganizationResponse organization = organizations[0]; + + dsadmin:NewUserResponse newUserResponse = check docuSignClient->/v2/organizations/[organization.id]/users.post( + { + user_name: "user1", + first_name: "name1", + email: "user1@docusignmail.com", + accounts: [ + { + id: accountId, + company_name: "Company" + } + ] + } + ); +} +``` + +### Step 4: Run the Ballerina application + +Use the following command to compile and run the Ballerina program. + +```bash +bal run +``` + +## Examples + +The DocuSign Admin connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/tree/main/examples). + +1. [Manage user information with DocuSign Admin](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/tree/main/examples/manage-user-information) + This example shows how to use DocuSign Admin API to to create users and retrieve user informations related to eSignature tasks. + +2. [Access permissions in user accounts](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/tree/main/examples/permissions-in-organizations) + This example shows how to use DocuSign Admin API to to view permission details of the user accounts. + +## Issues and projects + +The **Issues** and **Projects** tabs are disabled for this repository as this is part of the Ballerina library. To report bugs, request new features, start new discussions, view project boards, etc., visit the Ballerina library [parent repository](https://github.com/ballerina-platform/ballerina-library). + +This repository only contains the source code for the package. + +## Building from the source + +### Prerequisites + +1. Download and install Java SE Development Kit (JDK) version 17. You can download it from either of the following sources: + + - [Oracle JDK](https://www.oracle.com/java/technologies/downloads/) + - [OpenJDK](https://adoptium.net/) + + > **Note:** After installation, remember to set the `JAVA_HOME` environment variable to the directory where JDK was installed. + +2. Download and install [Ballerina Swan Lake](https://ballerina.io/). + +3. Download and install [Docker](https://www.docker.com/get-started). + + > **Note**: Ensure that the Docker daemon is running before executing any tests. + +4. Generate a Github access token with read package permissions, then set the following `env` variables: + + ```bash + export packageUser= + export packagePAT= + ``` + +### Build options + +Execute the commands below to build from the source. + +1. To build the package: + + ```bash + ./gradlew clean build + ``` + +2. To run the tests: + + ```bash + ./gradlew clean test + ``` + +3. To build the without the tests: + + ```bash + ./gradlew clean build -x test + ``` + +4. To debug package with a remote debugger: + + ```bash + ./gradlew clean build -Pdebug= + ``` + +5. To debug with Ballerina language: + + ```bash + ./gradlew clean build -PbalJavaDebug= + ``` + +6. Publish the generated artifacts to the local Ballerina central repository: + + ```bash + ./gradlew clean build -PpublishToLocalCentral=true + ``` + +7. Publish the generated artifacts to the Ballerina central repository: + + ```bash + ./gradlew clean build -PpublishToCentral=true + ``` + +## Contributing to Ballerina + +As an open source project, Ballerina welcomes contributions from the community. + +For more information, go to the [contribution guidelines](https://github.com/ballerina-platform/ballerina-lang/blob/master/CONTRIBUTING.md). + +## Code of conduct + +All contributors are encouraged to read the [Ballerina Code of Conduct](https://ballerina.io/code-of-conduct). + +## Useful links + +- Discuss code changes of the Ballerina project in [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com). +- Chat live with us via our [Discord server](https://discord.gg/ballerinalang). +- Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 6d3d1f2..a715315 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,16 +1,16 @@ -[package] -distribution = "2201.8.4" -org = "ballerinax" -name = "docusign.dsadmin" -version = "2.0.0" -license = ["Apache-2.0"] -authors = ["Ballerina"] -keywords = ["eSignature", "Cost/Freemium", "Administration", "Admin API", "Collaboration", "Digital Signature"] -icon = "icon.png" -repository = "https://github.com/ballerina-platform/module-ballerinax-docusign" - -[build-options] -observabilityIncluded = true - -[platform.java17] -graalvmCompatible = true +[package] +distribution = "2201.8.4" +org = "ballerinax" +name = "docusign.dsadmin" +version = "2.0.0" +license = ["Apache-2.0"] +authors = ["Ballerina"] +keywords = ["eSignature", "Cost/Freemium", "Administration", "Admin API", "Collaboration", "Digital Signature"] +icon = "icon.png" +repository = "https://github.com/ballerina-platform/module-ballerinax-docusign" + +[build-options] +observabilityIncluded = true + +[platform.java17] +graalvmCompatible = true diff --git a/ballerina/build.gradle b/ballerina/build.gradle index 3800a10..ad5ab1c 100644 --- a/ballerina/build.gradle +++ b/ballerina/build.gradle @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 LLC. licenses this file to you 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. - */ - -import org.apache.tools.ant.taskdefs.condition.Os - -plugins { - id 'io.ballerina.plugin' -} - -description = 'DocuSign - Ballerina' - -def packageName = "docusign.dsadmin" -def packageOrg = "ballerinax" -def tomlVersion = stripBallerinaExtensionVersion("${project.version}") -def ballerinaTomlFilePlaceHolder = new File("${project.rootDir}/build-config/resources/Ballerina.toml") -def ballerinaTomlFile = new File("$project.projectDir/Ballerina.toml") - -def stripBallerinaExtensionVersion(String extVersion) { - if (extVersion.matches(project.ext.timestampedVersionRegex)) { - def splitVersion = extVersion.split('-') - if (splitVersion.length > 3) { - def strippedValues = splitVersion[0..-4] - return strippedValues.join('-') - } else { - return extVersion - } - } else { - return extVersion.replace("${project.ext.snapshotVersion}", "") - } -} - -ballerina { - packageOrganization = packageOrg - module = packageName - testCoverageParam = "--code-coverage --coverage-format=xml" - isConnector = true - platform = "any" -} - -task updateTomlFiles { - doLast { - def newBallerinaToml = ballerinaTomlFilePlaceHolder.text.replace("@project.version@", project.version) - newBallerinaToml = newBallerinaToml.replace("@toml.version@", tomlVersion) - ballerinaTomlFile.text = newBallerinaToml - } -} - -task commitTomlFiles { - doLast { - project.exec { - ignoreExitValue true - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - commandLine 'cmd', '/c', "git commit -m \"[Automated] Update the toml files\" Ballerina.toml Dependencies.toml" - } else { - commandLine 'sh', '-c', "git commit -m '[Automated] Update the toml files' Ballerina.toml Dependencies.toml" - } - } - } -} - -clean { - delete 'build' -} - -publishToMavenLocal.dependsOn build -publish.dependsOn build +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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. + */ + +import org.apache.tools.ant.taskdefs.condition.Os + +plugins { + id 'io.ballerina.plugin' +} + +description = 'DocuSign - Ballerina' + +def packageName = "docusign.dsadmin" +def packageOrg = "ballerinax" +def tomlVersion = stripBallerinaExtensionVersion("${project.version}") +def ballerinaTomlFilePlaceHolder = new File("${project.rootDir}/build-config/resources/Ballerina.toml") +def ballerinaTomlFile = new File("$project.projectDir/Ballerina.toml") + +def stripBallerinaExtensionVersion(String extVersion) { + if (extVersion.matches(project.ext.timestampedVersionRegex)) { + def splitVersion = extVersion.split('-') + if (splitVersion.length > 3) { + def strippedValues = splitVersion[0..-4] + return strippedValues.join('-') + } else { + return extVersion + } + } else { + return extVersion.replace("${project.ext.snapshotVersion}", "") + } +} + +ballerina { + packageOrganization = packageOrg + module = packageName + testCoverageParam = "--code-coverage --coverage-format=xml" + isConnector = true + platform = "any" +} + +task updateTomlFiles { + doLast { + def newBallerinaToml = ballerinaTomlFilePlaceHolder.text.replace("@project.version@", project.version) + newBallerinaToml = newBallerinaToml.replace("@toml.version@", tomlVersion) + ballerinaTomlFile.text = newBallerinaToml + } +} + +task commitTomlFiles { + doLast { + project.exec { + ignoreExitValue true + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + commandLine 'cmd', '/c', "git commit -m \"[Automated] Update the toml files\" Ballerina.toml Dependencies.toml" + } else { + commandLine 'sh', '-c', "git commit -m '[Automated] Update the toml files' Ballerina.toml Dependencies.toml" + } + } + } +} + +clean { + delete 'build' +} + +publishToMavenLocal.dependsOn build +publish.dependsOn build diff --git a/ballerina/tests/admin-test.bal b/ballerina/tests/admin-test.bal index 8b4a492..708821b 100644 --- a/ballerina/tests/admin-test.bal +++ b/ballerina/tests/admin-test.bal @@ -1,245 +1,245 @@ -// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. -// -// WSO2 LLC. licenses this file to you 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. - -import ballerina/os; -import ballerina/test; - -Client docuSignClient = test:mock(Client); - -configurable boolean isTestOnLiveServer = os:getEnv("IS_TEST_ON_LIVE_SERVER") == "true"; -configurable string clientId = ?; -configurable string clientSecret = ?; -configurable string refreshToken = ?; -configurable string refreshUrl = ?; -configurable string accountId = ?; -configurable string userId = ?; -configurable string email = ?; - -@test:BeforeSuite -function initializeClientsForDocuSignServer() returns error? { - if isTestOnLiveServer { - docuSignClient = check new("https://api-d.docusign.net/management/", - { - timeout: 10000, - auth: { - clientId: os:getEnv("CLIENT_ID"), - clientSecret: os:getEnv("CLIENT_SECRET"), - refreshToken: os:getEnv("REFRESH_TOKEN"), - refreshUrl: os:getEnv("REFRESH_URL") - } - } - ); - } else { - docuSignClient = check new("http://localhost:9090/management", - { - timeout: 10000, - auth: { - clientId, - clientSecret, - refreshToken, - refreshUrl - } - } - ); - } -} - -@test:Config { - groups: ["account"] -} -function testGetOrganizations() returns error? { - OrganizationsResponse response = check docuSignClient->/v2/organizations(); - test:assertNotEquals(response.organizations, ()); - OrganizationResponse[]? organizations = response.organizations; - if organizations is () { - return error("Organizations not found"); - } - test:assertEquals(organizations[0].default_account_id, accountId); -} - -@test:Config { - groups: ["account"] -} -function testGetUsersInOrganization() returns error? { - OrganizationsResponse response = check docuSignClient->/v2/organizations(); - OrganizationResponse[]? organizations = response.organizations; - if organizations is () { - return error("Organizations not found"); - } - OrganizationResponse organization = organizations[0]; - string organizationId = organization.id; - OrganizationUsersResponse organizationResponse = check docuSignClient->/v2/organizations/[organizationId]/users(email = email); - OrganizationUserResponse[]? organizationUsers = organizationResponse.users; - if organizationUsers is () { - return error("Users not found"); - } - test:assertEquals(organizationUsers[0].email, email); -} - -@test:Config { - groups: ["account"] -} -function testGetPermissions() returns error? { - OrganizationsResponse response = check docuSignClient->/v2/organizations(); - OrganizationResponse[]? organizations = response.organizations; - if organizations is () { - return error("Organizations not found"); - } - OrganizationResponse organization = organizations[0]; - string organizationId = organization.id; - PermissionsResponse permissionResponse = check docuSignClient->/v2/organizations/[organizationId]/accounts/[accountId]/permissions(); - PermissionProfileResponse[]? permissions = permissionResponse.permissions; - if permissions is () { - return error("Permissions not found"); - } - test:assertNotEquals(permissions.length(), 0); -} - -@test:Config { - groups: ["account"] -} -function testGetExportRequests() returns error? { - OrganizationsResponse response = check docuSignClient->/v2/organizations(); - OrganizationResponse[]? organizations = response.organizations; - if organizations is () { - return error("Organizations not found"); - } - OrganizationResponse organization = organizations[0]; - string organizationId = organization.id; - OrganizationExportsResponse expectedRes = { - exports: [] - }; - OrganizationExportsResponse exportResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/user_list(); - test:assertEquals(exportResponse, expectedRes); -} - -@test:Config { - groups: ["account"] -} -function testGetUserInfo() returns error? { - OrganizationsResponse response = check docuSignClient->/v2/organizations(); - OrganizationResponse[]? organizations = response.organizations; - if organizations is () { - return error("Organizations not found"); - } - OrganizationResponse organization = organizations[0]; - string organizationId = organization.id; - UsersDrilldownResponse exportResponse = check docuSignClient->/v2/organizations/[organizationId]/users/profile(email = email); - UserDrilldownResponse[]? users = exportResponse.users; - if users is () { - return error("Users not found"); - } - test:assertEquals(users[0].default_account_id, accountId); -} - -@test:Config { - groups: ["account"] -} -function testGetMemberGroups() returns error? { - OrganizationsResponse response = check docuSignClient->/v2/organizations(); - OrganizationResponse[]? organizations = response.organizations; - if organizations is () { - return error("Organizations not found"); - } - OrganizationResponse organization = organizations[0]; - string organizationId = organization.id; - MemberGroupsResponse memberGroupResponse = check docuSignClient->/v2/organizations/[organizationId]/accounts/[accountId]/groups(); - test:assertNotEquals((memberGroupResponse.groups).length(), 0); -} - -@test:Config { - groups: ["account"] -} -function testGetIdentityProviders() returns error? { - OrganizationsResponse response = check docuSignClient->/v2/organizations(); - OrganizationResponse[]? organizations = response.organizations; - if organizations is () { - return error("Organizations not found"); - } - OrganizationResponse organization = organizations[0]; - string organizationId = organization.id; - IdentityProvidersResponse identityProviders = check docuSignClient->/v2/organizations/[organizationId]/identity_providers(); - test:assertEquals(identityProviders, {}); -} - -@test:Config { - groups: ["account"] -} -function testGetAccountSettingsExport() returns error? { - OrganizationsResponse response = check docuSignClient->/v2/organizations(); - OrganizationResponse[]? organizations = response.organizations; - if organizations is () { - return error("Organizations not found"); - } - OrganizationResponse organization = organizations[0]; - string organizationId = organization.id; - OrganizationExportsResponse getExportResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/account_settings(); - OrganizationExportResponse[] exports = getExportResponse.exports; - test:assertNotEquals(exports.length(), 0); -} - -@test:Config { - groups: ["account"] -} -function testCreateAndDeleteAccountSettingsExport() returns error? { - OrganizationsResponse response = check docuSignClient->/v2/organizations(); - OrganizationResponse[]? organizations = response.organizations; - if organizations is () { - return error("Organizations not found"); - } - OrganizationResponse organization = organizations[0]; - string organizationId = organization.id; - OrganizationExportResponse exportResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/account_settings.post({ - accounts: [ - { - account_id: accountId - } - ] - }); - OrganizationExportRequestorResponse exportRes = exportResponse.requestor; - test:assertEquals(exportRes.email, email); - - json deleteResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/user_list/[exportResponse.id].delete(); - test:assertEquals(deleteResponse.success, true); -} - -@test:Config { - groups: ["account"] -} -function testGetAccountSettingExport() returns error? { - OrganizationsResponse response = check docuSignClient->/v2/organizations(); - OrganizationResponse[]? organizations = response.organizations; - if organizations is () { - return error("Organizations not found"); - } - OrganizationResponse organization = organizations[0]; - string organizationId = organization.id; - OrganizationExportResponse exportResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/account_settings.post({ - accounts: [ - { - account_id: accountId - } - ] - }); - OrganizationExportRequestorResponse exportRes = exportResponse.requestor; - test:assertEquals(exportRes.email, email); - - OrganizationExportsResponse getResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/account_settings(); - test:assertNotEquals(getResponse.exports, ()); - - json deleteResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/user_list/[exportResponse.id].delete(); - test:assertEquals(deleteResponse.success, true); -} +// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. +// +// WSO2 LLC. licenses this file to you 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. + +import ballerina/os; +import ballerina/test; + +Client docuSignClient = test:mock(Client); + +configurable boolean isTestOnLiveServer = os:getEnv("IS_TEST_ON_LIVE_SERVER") == "true"; +configurable string clientId = ?; +configurable string clientSecret = ?; +configurable string refreshToken = ?; +configurable string refreshUrl = ?; +configurable string accountId = ?; +configurable string userId = ?; +configurable string email = ?; + +@test:BeforeSuite +function initializeClientsForDocuSignServer() returns error? { + if isTestOnLiveServer { + docuSignClient = check new("https://api-d.docusign.net/management/", + { + timeout: 10000, + auth: { + clientId: os:getEnv("CLIENT_ID"), + clientSecret: os:getEnv("CLIENT_SECRET"), + refreshToken: os:getEnv("REFRESH_TOKEN"), + refreshUrl: os:getEnv("REFRESH_URL") + } + } + ); + } else { + docuSignClient = check new("http://localhost:9090/management", + { + timeout: 10000, + auth: { + clientId, + clientSecret, + refreshToken, + refreshUrl + } + } + ); + } +} + +@test:Config { + groups: ["account"] +} +function testGetOrganizations() returns error? { + OrganizationsResponse response = check docuSignClient->/v2/organizations(); + test:assertNotEquals(response.organizations, ()); + OrganizationResponse[]? organizations = response.organizations; + if organizations is () { + return error("Organizations not found"); + } + test:assertEquals(organizations[0].default_account_id, accountId); +} + +@test:Config { + groups: ["account"] +} +function testGetUsersInOrganization() returns error? { + OrganizationsResponse response = check docuSignClient->/v2/organizations(); + OrganizationResponse[]? organizations = response.organizations; + if organizations is () { + return error("Organizations not found"); + } + OrganizationResponse organization = organizations[0]; + string organizationId = organization.id; + OrganizationUsersResponse organizationResponse = check docuSignClient->/v2/organizations/[organizationId]/users(email = email); + OrganizationUserResponse[]? organizationUsers = organizationResponse.users; + if organizationUsers is () { + return error("Users not found"); + } + test:assertEquals(organizationUsers[0].email, email); +} + +@test:Config { + groups: ["account"] +} +function testGetPermissions() returns error? { + OrganizationsResponse response = check docuSignClient->/v2/organizations(); + OrganizationResponse[]? organizations = response.organizations; + if organizations is () { + return error("Organizations not found"); + } + OrganizationResponse organization = organizations[0]; + string organizationId = organization.id; + PermissionsResponse permissionResponse = check docuSignClient->/v2/organizations/[organizationId]/accounts/[accountId]/permissions(); + PermissionProfileResponse[]? permissions = permissionResponse.permissions; + if permissions is () { + return error("Permissions not found"); + } + test:assertNotEquals(permissions.length(), 0); +} + +@test:Config { + groups: ["account"] +} +function testGetExportRequests() returns error? { + OrganizationsResponse response = check docuSignClient->/v2/organizations(); + OrganizationResponse[]? organizations = response.organizations; + if organizations is () { + return error("Organizations not found"); + } + OrganizationResponse organization = organizations[0]; + string organizationId = organization.id; + OrganizationExportsResponse expectedRes = { + exports: [] + }; + OrganizationExportsResponse exportResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/user_list(); + test:assertEquals(exportResponse, expectedRes); +} + +@test:Config { + groups: ["account"] +} +function testGetUserInfo() returns error? { + OrganizationsResponse response = check docuSignClient->/v2/organizations(); + OrganizationResponse[]? organizations = response.organizations; + if organizations is () { + return error("Organizations not found"); + } + OrganizationResponse organization = organizations[0]; + string organizationId = organization.id; + UsersDrilldownResponse exportResponse = check docuSignClient->/v2/organizations/[organizationId]/users/profile(email = email); + UserDrilldownResponse[]? users = exportResponse.users; + if users is () { + return error("Users not found"); + } + test:assertEquals(users[0].default_account_id, accountId); +} + +@test:Config { + groups: ["account"] +} +function testGetMemberGroups() returns error? { + OrganizationsResponse response = check docuSignClient->/v2/organizations(); + OrganizationResponse[]? organizations = response.organizations; + if organizations is () { + return error("Organizations not found"); + } + OrganizationResponse organization = organizations[0]; + string organizationId = organization.id; + MemberGroupsResponse memberGroupResponse = check docuSignClient->/v2/organizations/[organizationId]/accounts/[accountId]/groups(); + test:assertNotEquals((memberGroupResponse.groups).length(), 0); +} + +@test:Config { + groups: ["account"] +} +function testGetIdentityProviders() returns error? { + OrganizationsResponse response = check docuSignClient->/v2/organizations(); + OrganizationResponse[]? organizations = response.organizations; + if organizations is () { + return error("Organizations not found"); + } + OrganizationResponse organization = organizations[0]; + string organizationId = organization.id; + IdentityProvidersResponse identityProviders = check docuSignClient->/v2/organizations/[organizationId]/identity_providers(); + test:assertEquals(identityProviders, {}); +} + +@test:Config { + groups: ["account"] +} +function testGetAccountSettingsExport() returns error? { + OrganizationsResponse response = check docuSignClient->/v2/organizations(); + OrganizationResponse[]? organizations = response.organizations; + if organizations is () { + return error("Organizations not found"); + } + OrganizationResponse organization = organizations[0]; + string organizationId = organization.id; + OrganizationExportsResponse getExportResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/account_settings(); + OrganizationExportResponse[] exports = getExportResponse.exports; + test:assertNotEquals(exports.length(), 0); +} + +@test:Config { + groups: ["account"] +} +function testCreateAndDeleteAccountSettingsExport() returns error? { + OrganizationsResponse response = check docuSignClient->/v2/organizations(); + OrganizationResponse[]? organizations = response.organizations; + if organizations is () { + return error("Organizations not found"); + } + OrganizationResponse organization = organizations[0]; + string organizationId = organization.id; + OrganizationExportResponse exportResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/account_settings.post({ + accounts: [ + { + account_id: accountId + } + ] + }); + OrganizationExportRequestorResponse exportRes = exportResponse.requestor; + test:assertEquals(exportRes.email, email); + + json deleteResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/user_list/[exportResponse.id].delete(); + test:assertEquals(deleteResponse.success, true); +} + +@test:Config { + groups: ["account"] +} +function testGetAccountSettingExport() returns error? { + OrganizationsResponse response = check docuSignClient->/v2/organizations(); + OrganizationResponse[]? organizations = response.organizations; + if organizations is () { + return error("Organizations not found"); + } + OrganizationResponse organization = organizations[0]; + string organizationId = organization.id; + OrganizationExportResponse exportResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/account_settings.post({ + accounts: [ + { + account_id: accountId + } + ] + }); + OrganizationExportRequestorResponse exportRes = exportResponse.requestor; + test:assertEquals(exportRes.email, email); + + OrganizationExportsResponse getResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/account_settings(); + test:assertNotEquals(getResponse.exports, ()); + + json deleteResponse = check docuSignClient->/v2/organizations/[organizationId]/exports/user_list/[exportResponse.id].delete(); + test:assertEquals(deleteResponse.success, true); +} diff --git a/build-config/resources/Ballerina.toml b/build-config/resources/Ballerina.toml index 2af2bd8..0cec9c7 100644 --- a/build-config/resources/Ballerina.toml +++ b/build-config/resources/Ballerina.toml @@ -1,16 +1,16 @@ -[package] -distribution = "2201.8.4" -org = "ballerinax" -name = "docusign.dsadmin" -version = "@toml.version@" -license = ["Apache-2.0"] -authors = ["Ballerina"] -keywords = ["eSignature", "Cost/Freemium", "Administration", "Admin API", "Collaboration", "Digital Signature"] -icon = "icon.png" -repository = "https://github.com/ballerina-platform/module-ballerinax-docusign" - -[build-options] -observabilityIncluded = true - -[platform.java17] -graalvmCompatible = true +[package] +distribution = "2201.8.4" +org = "ballerinax" +name = "docusign.dsadmin" +version = "@toml.version@" +license = ["Apache-2.0"] +authors = ["Ballerina"] +keywords = ["eSignature", "Cost/Freemium", "Administration", "Admin API", "Collaboration", "Digital Signature"] +icon = "icon.png" +repository = "https://github.com/ballerina-platform/module-ballerinax-docusign" + +[build-options] +observabilityIncluded = true + +[platform.java17] +graalvmCompatible = true diff --git a/docs/spec/sanitations.md b/docs/spec/sanitations.md index 0af59c8..69bb3dd 100644 --- a/docs/spec/sanitations.md +++ b/docs/spec/sanitations.md @@ -1,23 +1,23 @@ -# Sanitations for OpenAPI specification - -_Authors_: @Nuvindu \ -_Reviewers_: @shafreenAnfar @ThisaruGuruge \ -_Created_: 2024/03/13 \ -_Updated_: 2024/02/13 \ -_Edition_: Swan Lake - -## Introduction - -The Ballerina DocuSign Admin connector facilitates integration with the [DocuSign Admin API](https://developers.docusign.com/docs/admin-api/reference) through the generation of client code using the [OpenAPI specification](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/blob/main/docs/spec/openapi.json). To enhance usability, the following modifications have been applied to the original specification. - -1. Response descriptions -Previously, all responses for resource functions were labeled with a generic "Successful Response". This has been revised to "A successful response or an error". - -2. Avoid path segments with backslashes -To prevent errors associated with backslashes in the resource path, the functions in the format, `get v2\.1/accounts/.../` have been modified as `get accounts/.../` to avoid broken paths in the API calls. - -## OpenAPI cli command - -```bash -bal openapi -i docs/spec/openapi.json --mode client -o ballerina -``` +# Sanitations for OpenAPI specification + +_Authors_: @Nuvindu \ +_Reviewers_: @shafreenAnfar @ThisaruGuruge \ +_Created_: 2024/03/13 \ +_Updated_: 2024/02/13 \ +_Edition_: Swan Lake + +## Introduction + +The Ballerina DocuSign Admin connector facilitates integration with the [DocuSign Admin API](https://developers.docusign.com/docs/admin-api/reference) through the generation of client code using the [OpenAPI specification](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/blob/main/docs/spec/openapi.json). To enhance usability, the following modifications have been applied to the original specification. + +1. Response descriptions +Previously, all responses for resource functions were labeled with a generic "Successful Response". This has been revised to "A successful response or an error". + +2. Avoid path segments with backslashes +To prevent errors associated with backslashes in the resource path, the functions in the format, `get v2\.1/accounts/.../` have been modified as `get accounts/.../` to avoid broken paths in the API calls. + +## OpenAPI cli command + +```bash +bal openapi -i docs/spec/openapi.json --mode client -o ballerina +``` diff --git a/examples/README.md b/examples/README.md index 88e000a..06efb33 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,57 +1,57 @@ -## Examples - -The DocuSign Admin connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/tree/main/examples). - -1. [Manage user information with DocuSign Admin](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/tree/main/examples/manage-user-information) - This example shows how to use DocuSign Admin API to to create users and retrieve user informations related to eSignature tasks. - -2. [Access permissions in user accounts](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/tree/main/examples/permissions-in-organizations) - This example shows how to use DocuSign Admin API to to view permission details of the user accounts. - -## Prerequisites - -1. Follow the [instructions](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin#set-up-guide) to set up the DocuSign Admin API. - -2. For each example, create a `Config.toml` file with your OAuth2 tokens, client ID, and client secret. Here's an example of how your `Config.toml` file should look: - - ```toml - clientId="" - clientSecret="" - refreshToken="" - refreshUrl="" - accountId = "" - ``` - -## Running an example - -Execute the following commands to build an example from the source: - -* To build an example: - - ```bash - bal build - ``` - -* To run an example: - - ```bash - bal run - ``` - -## Building the examples with the local module - -**Warning**: Due to the absence of support for reading local repositories for single Ballerina files, the Bala of the module is manually written to the central repository as a workaround. Consequently, the bash script may modify your local Ballerina repositories. - -Execute the following commands to build all the examples against the changes you have made to the module locally: - -* To build all the examples: - - ```bash - ./build.sh build - ``` - -* To run all the examples: - - ```bash - ./build.sh run - ``` +## Examples + +The DocuSign Admin connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/tree/main/examples). + +1. [Manage user information with DocuSign Admin](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/tree/main/examples/manage-user-information) + This example shows how to use DocuSign Admin API to to create users and retrieve user informations related to eSignature tasks. + +2. [Access permissions in user accounts](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin/tree/main/examples/permissions-in-organizations) + This example shows how to use DocuSign Admin API to to view permission details of the user accounts. + +## Prerequisites + +1. Follow the [instructions](https://github.com/ballerina-platform/module-ballerinax-docusign.dsadmin#set-up-guide) to set up the DocuSign Admin API. + +2. For each example, create a `Config.toml` file with your OAuth2 tokens, client ID, and client secret. Here's an example of how your `Config.toml` file should look: + + ```toml + clientId="" + clientSecret="" + refreshToken="" + refreshUrl="" + accountId = "" + ``` + +## Running an example + +Execute the following commands to build an example from the source: + +* To build an example: + + ```bash + bal build + ``` + +* To run an example: + + ```bash + bal run + ``` + +## Building the examples with the local module + +**Warning**: Due to the absence of support for reading local repositories for single Ballerina files, the Bala of the module is manually written to the central repository as a workaround. Consequently, the bash script may modify your local Ballerina repositories. + +Execute the following commands to build all the examples against the changes you have made to the module locally: + +* To build all the examples: + + ```bash + ./build.sh build + ``` + +* To run all the examples: + + ```bash + ./build.sh run + ``` diff --git a/examples/build.gradle b/examples/build.gradle index 9489dcc..b1b3837 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2024, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you 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. - */ - -import org.apache.tools.ant.taskdefs.condition.Os - -apply plugin: 'java' - -def graalvmFlag = "" - -task testExamples { - if (project.hasProperty("balGraalVMTest")) { - graalvmFlag = "--graalvm" - } - doLast { - try { - exec { - workingDir project.projectDir - println("Working dir: ${workingDir}") - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - commandLine 'sh', "/c", "chmod +x ./build.sh && ./build.sh run && exit %%ERRORLEVEL%%" - } else { - commandLine 'sh', "-c", "chmod +x ./build.sh && ./build.sh run" - } - } - } catch (Exception e) { - println("Example Build failed: " + e.message) - throw e - } - } -} - -task buildExamples { - gradle.taskGraph.whenReady { graph -> - if (graph.hasTask(":docusign.esign-examples:test")) { - buildExamples.enabled = false - } else { - testExamples.enabled = false - } - } - doLast { - try { - exec { - workingDir project.projectDir - println("Working dir: ${workingDir}") - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - commandLine 'sh', "/c", "chmod +x ./build.sh && ./build.sh build && exit %%ERRORLEVEL%%" - } else { - commandLine 'sh', "-c", "chmod +x ./build.sh && ./build.sh build" - } - } - } catch (Exception e) { - println("Example Build failed: " + e.message) - throw e - } - } -} - -buildExamples.dependsOn ":docusign.dsadmin-ballerina:build" -testExamples.dependsOn ":docusign.dsadmin-ballerina:build" - -build.dependsOn buildExamples +/* + * Copyright (c) 2024, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you 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. + */ + +import org.apache.tools.ant.taskdefs.condition.Os + +apply plugin: 'java' + +def graalvmFlag = "" + +task testExamples { + if (project.hasProperty("balGraalVMTest")) { + graalvmFlag = "--graalvm" + } + doLast { + try { + exec { + workingDir project.projectDir + println("Working dir: ${workingDir}") + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + commandLine 'sh', "/c", "chmod +x ./build.sh && ./build.sh run && exit %%ERRORLEVEL%%" + } else { + commandLine 'sh', "-c", "chmod +x ./build.sh && ./build.sh run" + } + } + } catch (Exception e) { + println("Example Build failed: " + e.message) + throw e + } + } +} + +task buildExamples { + gradle.taskGraph.whenReady { graph -> + if (graph.hasTask(":docusign.esign-examples:test")) { + buildExamples.enabled = false + } else { + testExamples.enabled = false + } + } + doLast { + try { + exec { + workingDir project.projectDir + println("Working dir: ${workingDir}") + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + commandLine 'sh', "/c", "chmod +x ./build.sh && ./build.sh build && exit %%ERRORLEVEL%%" + } else { + commandLine 'sh', "-c", "chmod +x ./build.sh && ./build.sh build" + } + } + } catch (Exception e) { + println("Example Build failed: " + e.message) + throw e + } + } +} + +buildExamples.dependsOn ":docusign.dsadmin-ballerina:build" +testExamples.dependsOn ":docusign.dsadmin-ballerina:build" + +build.dependsOn buildExamples diff --git a/gradle.properties b/gradle.properties index 04b3033..46b9099 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,13 +1,13 @@ -org.gradle.caching=true -group=io.ballerina.lib -version=2.0.0-SNAPSHOT - -checkstylePluginVersion=10.12.0 -spotbugsPluginVersion=5.0.14 -shadowJarPluginVersion=8.1.1 -downloadPluginVersion=5.4.0 -releasePluginVersion=2.8.0 -testngVersion=7.6.1 -eclipseLsp4jVersion=0.12.0 -ballerinaGradlePluginVersion=2.2.3 -ballerinaLangVersion=2201.8.4 +org.gradle.caching=true +group=io.ballerina.lib +version=2.0.0-SNAPSHOT + +checkstylePluginVersion=10.12.0 +spotbugsPluginVersion=5.0.14 +shadowJarPluginVersion=8.1.1 +downloadPluginVersion=5.4.0 +releasePluginVersion=2.8.0 +testngVersion=7.6.1 +eclipseLsp4jVersion=0.12.0 +ballerinaGradlePluginVersion=2.2.3 +ballerinaLangVersion=2201.8.4