diff --git a/.github/workflows/build-with-bal-test-native.yml b/.github/workflows/build-with-bal-test-native.yml index 1278664..50a47cc 100644 --- a/.github/workflows/build-with-bal-test-native.yml +++ b/.github/workflows/build-with-bal-test-native.yml @@ -1,40 +1,42 @@ name: GraalVM Check -on: +on: schedule: - cron: '30 18 * * *' workflow_dispatch: jobs: - build: - runs-on: ubuntu-latest + build: + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 + steps: + - uses: actions/checkout@v2 - - name: Set up GraalVM - uses: graalvm/setup-graalvm@v1 - with: - version: 'latest' - java-version: '11' - components: 'native-image' - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Check GraalVM installation - run: | - echo "GRAALVM_HOME: ${{ env.GRAALVM_HOME }}" - echo "JAVA_HOME: ${{ env.JAVA_HOME }}" - native-image --version - - - name: Set Up Ballerina - uses: ballerina-platform/setup-ballerina@v1.1.0 - with: - version: latest + - name: Set up GraalVM + uses: graalvm/setup-graalvm@v1 + with: + version: 'latest' + java-version: '11' + components: 'native-image' + github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Run Ballerina tests using the native executable - run: bal test --graalvm ./aad - env: - REFRESH_URL: ${{ secrets.REFRESH_URL }} - REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + - name: Check GraalVM installation + run: | + echo "GRAALVM_HOME: ${{ env.GRAALVM_HOME }}" + echo "JAVA_HOME: ${{ env.JAVA_HOME }}" + native-image --version + + - name: Set Up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: latest + + - name: Run Ballerina tests using the native executable + working-directory: ./ballerina + run: bal test --graalvm + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + REFRESH_URL: ${{ secrets.REFRESH_URL }} + REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0763b32..1db9b38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,52 +2,62 @@ name: CI on: push: - branches: - - '**' + branches-ignore: + - "automated/dependency_version_update" + - "automated/dependency_version_update_tmp" repository_dispatch: types: check_connector_for_breaking_changes jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Ballerina Build - uses: ballerina-platform/ballerina-action/@nightly - with: - args: - pack ./aad - env: - REFRESH_URL: ${{ secrets.REFRESH_URL }} - REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - - name: Ballerina Test - uses: ballerina-platform/ballerina-action/@nightly - with: - args: - test --test-report --code-coverage --coverage-format=xml ./aad - env: - REFRESH_URL: ${{ secrets.REFRESH_URL }} - REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - - name: Alert notifier on failure - if: failure() && (github.event.action == 'check_connector_for_breaking_changes') - run: | - curl -X POST \ - 'https://api.github.com/repos/ballerina-platform/ballerina-release/dispatches' \ - --header 'Accept: application/vnd.github.v3+json' \ - --header 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \ - --data-raw '{ - "event_type": "notify-ballerinax-connector-build-failure", - "client_payload": { - "repoName": "module-ballerinax-azure.ad", - "workflow": "CI" - } - }' + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + # Setup Ballerina Environment + - name: Set Up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: latest + + # Build Ballerina Project + - name: Ballerina Build + run: bal pack ./ballerina + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Build Module Examples + - name: Ballerina Examples Build + run: chmod +x ./examples/build.sh && ./examples/build.sh build + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Test Ballerina Project + - name: Ballerina Test + run: bal test ./ballerina --test-report --code-coverage --coverage-format=xml + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + REFRESH_URL: ${{ secrets.REFRESH_URL }} + REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + + # Send notification when build fails + - name: Alert notifier on failure + if: failure() && (github.event.action == 'check_connector_for_breaking_changes') + run: | + curl -X POST \ + 'https://api.github.com/repos/ballerina-platform/ballerina-release/dispatches' \ + --header 'Accept: application/vnd.github.v3+json' \ + --header 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \ + --data-raw '{ + "event_type": "notify-ballerinax-connector-build-failure", + "client_payload": { + "repoName": "module-ballerinax-azure.ad", + "workflow": "CI" + } + }' diff --git a/.github/workflows/daily-build.yml b/.github/workflows/daily-build.yml index 3e11f9f..a884718 100644 --- a/.github/workflows/daily-build.yml +++ b/.github/workflows/daily-build.yml @@ -1,57 +1,58 @@ name: Daily build -# Controls when the action will run. -on: +on: schedule: - cron: '30 2 * * *' -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - # Build the ballerina project - - name: Ballerina Build - uses: ballerina-platform/ballerina-action/@nightly - with: - args: - pack ./aad - env: - REFRESH_URL: ${{ secrets.REFRESH_URL }} - REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - - name: Ballerina Test - uses: ballerina-platform/ballerina-action/@nightly - with: - args: - test --test-report --code-coverage --coverage-format=xml ./aad - env: - REFRESH_URL: ${{ secrets.REFRESH_URL }} - REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - - # Send notification when build fails - - name: Notify failure - if: ${{ failure() }} - run: | - curl -X POST \ - 'https://api.github.com/repos/ballerina-platform/ballerina-release/dispatches' \ - -H 'Accept: application/vnd.github.v3+json' \ - -H 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \ - --data "{ - \"event_type\": \"notify-build-failure\", - \"client_payload\": { - \"repoName\": \"module-ballerinax-azure.ad\" - } - }" + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + # Setup Ballerina Environment + - name: Set Up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: latest + + # Build Ballerina Project + - name: Ballerina Build + run: bal pack ./ballerina + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Build Module Examples + - name: Ballerina Examples Build + run: chmod +x ./examples/build.sh && ./examples/build.sh build + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Test Ballerina Project + - name: Ballerina Test + run: bal test ./ballerina --test-report --code-coverage --coverage-format=xml + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + REFRESH_URL: ${{ secrets.REFRESH_URL }} + REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + + # Send notification when build fails + - name: Notify failure + if: ${{ failure() }} + run: | + curl -X POST \ + 'https://api.github.com/repos/ballerina-platform/ballerina-release/dispatches' \ + -H 'Accept: application/vnd.github.v3+json' \ + -H 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \ + --data "{ + \"event_type\": \"notify-build-failure\", + \"client_payload\": { + \"repoName\": \"module-ballerinax-azure.ad\" + } + }" diff --git a/.github/workflows/dev-stg-release.yml b/.github/workflows/dev-stg-release.yml index 12cad98..7369bed 100644 --- a/.github/workflows/dev-stg-release.yml +++ b/.github/workflows/dev-stg-release.yml @@ -7,41 +7,50 @@ on: description: Ballerina Central Environment type: choice options: - - STAGE - - DEV + - STAGE + - DEV required: true + jobs: - build: + release: + runs-on: ubuntu-latest + env: + BALLERINA_${{ github.event.inputs.bal_central_environment }}_CENTRAL: true + steps: + - uses: actions/checkout@v2 + + # Setup Ballerina Environment + - name: Set Up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: 2201.7.0 + + # Build Ballerina Project + - name: Ballerina Build + run: bal pack ./ballerina + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Build Module Examples + - name: Ballerina Examples Build + run: chmod +x ./examples/build.sh && ./examples/build.sh build + env: + JAVA_HOME: /usr/lib/jvm/default-jvm - runs-on: ubuntu-latest - env: - BALLERINA_${{ github.event.inputs.bal_central_environment }}_CENTRAL: true + # Push to Ballerina Staging Central + - name: Push to Staging + if: github.event.inputs.bal_central_environment == 'STAGE' + run: bal push + working-directory: ./ballerina + env: + BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_STAGE_ACCESS_TOKEN }} + JAVA_HOME: /usr/lib/jvm/default-jvm - steps: - - uses: actions/checkout@v2 - - name: Ballerina Build - uses: ballerina-platform/ballerina-action/@2201.2.1 - with: - args: - pack ./aad - - - name: Push to Staging - uses: ballerina-platform/ballerina-action/@2201.2.1 - if: github.event.inputs.bal_central_environment == 'STAGE' - with: - args: - push - env: - WORKING_DIR: ./aad - BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_STAGE_ACCESS_TOKEN }} - - - name: Push to Dev - uses: ballerina-platform/ballerina-action/@2201.2.1 - if: github.event.inputs.bal_central_environment == 'DEV' - with: - args: - push - env: - WORKING_DIR: ./aad - BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }} - + # Push to Ballerina Dev Central + - name: Push to Dev + if: github.event.inputs.bal_central_environment == 'DEV' + run: bal push + working-directory: ./ballerina + env: + BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }} + JAVA_HOME: /usr/lib/jvm/default-jvm diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 12614b0..699f641 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,35 +1,42 @@ -name: CI_pull_request +name: Pull Request -on: [pull_request] +on: [ pull_request ] jobs: build: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - - name: Ballerina Build - uses: ballerina-platform/ballerina-action/@nightly + + # Setup Ballerina Environment + - name: Set Up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 with: - args: - pack ./aad - env: - REFRESH_URL: ${{ secrets.REFRESH_URL }} - REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + version: latest + + # Build Ballerina Project + - name: Ballerina Build + run: bal pack ./ballerina + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Build Module Examples + - name: Ballerina Examples Build + run: chmod +x ./examples/build.sh && ./examples/build.sh build + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Test Ballerina Project - name: Ballerina Test # tests will be skipped if the PR is from a forked repository (as the secrets are not available) if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} - uses: ballerina-platform/ballerina-action/@nightly - with: - args: - test --test-report --code-coverage --coverage-format=xml ./aad + run: bal test ./ballerina --test-report --code-coverage --coverage-format=xml env: + JAVA_HOME: /usr/lib/jvm/default-jvm REFRESH_URL: ${{ secrets.REFRESH_URL }} REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} CLIENT_ID: ${{ secrets.CLIENT_ID }} CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 49879cc..3c4b01a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,31 +2,36 @@ name: Deployment on: release: - types: [published] + types: [ published ] jobs: - build: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 - runs-on: ubuntu-latest + # Setup Ballerina Environment + - name: Set Up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: 2201.7.0 - steps: - - uses: actions/checkout@v2 - - name: Ballerina Build - uses: ballerina-platform/ballerina-action/@2201.2.1 - with: - args: - pack ./aad - env: - REFRESH_URL: ${{ secrets.REFRESH_URL }} - REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - - name: Ballerina Push - uses: ballerina-platform/ballerina-action/@2201.2.1 - with: - args: - push - env: - WORKING_DIR: ./aad - BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }} - \ No newline at end of file + # Build Ballerina Project + - name: Ballerina Build + run: bal pack ./ballerina + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Build Module Examples + - name: Ballerina Examples Build + run: chmod +x ./examples/build.sh && ./examples/build.sh build + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Push to Ballerina Central + - name: Ballerina Push + run: bal push + working-directory: ./ballerina + env: + BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }} + JAVA_HOME: /usr/lib/jvm/default-jvm diff --git a/README.md b/README.md index 8ec525d..ae1a1cf 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,11 @@ Execute the following commands to build from the source: - To build the package: ``` - bal pack ./aad + bal build ./ballerina ``` - To run tests after build: ``` - bal test ./aad + bal test ./ballerina ``` ## Contributing to ballerina diff --git a/aad/.gitignore b/ballerina/.gitignore similarity index 100% rename from aad/.gitignore rename to ballerina/.gitignore diff --git a/aad/Ballerina.toml b/ballerina/Ballerina.toml similarity index 100% rename from aad/Ballerina.toml rename to ballerina/Ballerina.toml diff --git a/aad/Module.md b/ballerina/Module.md similarity index 97% rename from aad/Module.md rename to ballerina/Module.md index 5b03a93..dd86025 100644 --- a/aad/Module.md +++ b/ballerina/Module.md @@ -67,4 +67,4 @@ if (userInfo is ad:User) { ``` 2. Use `bal run` command to compile and run the Ballerina program. -**[You can find a list of samples here](https://github.com/ballerina-platform/module-ballerinax-azure.ad/tree/master/aad/samples)** +**[You can find a list of samples here](https://github.com/ballerina-platform/module-ballerinax-azure.ad/tree/master/examples)** diff --git a/aad/Package.md b/ballerina/Package.md similarity index 100% rename from aad/Package.md rename to ballerina/Package.md diff --git a/aad/client.bal b/ballerina/client.bal similarity index 100% rename from aad/client.bal rename to ballerina/client.bal diff --git a/aad/constants.bal b/ballerina/constants.bal similarity index 100% rename from aad/constants.bal rename to ballerina/constants.bal diff --git a/aad/data_mappings.bal b/ballerina/data_mappings.bal similarity index 100% rename from aad/data_mappings.bal rename to ballerina/data_mappings.bal diff --git a/aad/icon.png b/ballerina/icon.png similarity index 100% rename from aad/icon.png rename to ballerina/icon.png diff --git a/aad/stream_implementer.bal b/ballerina/stream_implementer.bal similarity index 100% rename from aad/stream_implementer.bal rename to ballerina/stream_implementer.bal diff --git a/aad/tests/test.bal b/ballerina/tests/test.bal similarity index 100% rename from aad/tests/test.bal rename to ballerina/tests/test.bal diff --git a/aad/types.bal b/ballerina/types.bal similarity index 100% rename from aad/types.bal rename to ballerina/types.bal diff --git a/aad/utils.bal b/ballerina/utils.bal similarity index 100% rename from aad/utils.bal rename to ballerina/utils.bal diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..28ec345 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,34 @@ +# Examples + +This directory contains a collection of sample code examples written in Ballerina. These examples demonstrate various +use cases of the module. You can follow the instructions below to build and run these examples. + +## Running an Example + +Execute the following commands to build an example from the source. + +* To build an example + + `bal build ` + + +* To run an example + + `bal run ` + +## Building the Examples with the Local Module + +**Warning**: Because of 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 + + `./build.sh build` + + +* To run all the examples + + `./build.sh run` \ No newline at end of file diff --git a/aad/samples/add_member_to_group.bal b/examples/add_member_to_group.bal similarity index 89% rename from aad/samples/add_member_to_group.bal rename to examples/add_member_to_group.bal index ffbff9d..9bd3008 100644 --- a/aad/samples/add_member_to_group.bal +++ b/examples/add_member_to_group.bal @@ -26,12 +26,12 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("Add members to the group"); string groupId = ""; diff --git a/aad/samples/add_owner_to_group.bal b/examples/add_owner_to_group.bal similarity index 89% rename from aad/samples/add_owner_to_group.bal rename to examples/add_owner_to_group.bal index ac1cae6..64d495c 100644 --- a/aad/samples/add_owner_to_group.bal +++ b/examples/add_owner_to_group.bal @@ -26,12 +26,12 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("Add owner to the group"); string groupId = ""; diff --git a/examples/build.sh b/examples/build.sh new file mode 100755 index 0000000..f533627 --- /dev/null +++ b/examples/build.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +BAL_EXAMPLES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +BAL_CENTRAL_DIR="$HOME/.ballerina/repositories/central.ballerina.io/" +BAL_HOME_DIR="$BAL_EXAMPLES_DIR/../ballerina" + +set -e + +case "$1" in +build) + BAL_CMD="build" + ;; +run) + BAL_CMD="run" + ;; +*) + echo "Invalid command provided: '$1'. Please provide 'build' or 'run' as the command." + exit 1 + ;; +esac + +# Read Ballerina package name +BAL_PACKAGE_NAME=$(awk -F'"' '/^name/ {print $2}' "$BAL_HOME_DIR/Ballerina.toml") + +# Push the package to the local repository +cd "$BAL_HOME_DIR" && + bal pack && + bal push --repository=local + +# Remove the cache directories in the repositories +cacheDirs=($(ls -d "$BAL_CENTRAL_DIR"/cache-* 2>/dev/null)) +for dir in "${cacheDirs[@]}"; do + [ -d "$dir" ] && rm -r "$dir" +done +echo "Successfully cleaned the cache directories" + +# Update the central repository +BAL_DESTINATION_DIR="$HOME/.ballerina/repositories/central.ballerina.io/bala/ballerinax/$BAL_PACKAGE_NAME" +BAL_SOURCE_DIR="$HOME/.ballerina/repositories/local/bala/ballerinax/$BAL_PACKAGE_NAME" +[ -d "$BAL_DESTINATION_DIR" ] && rm -r "$BAL_DESTINATION_DIR" +[ -d "$BAL_SOURCE_DIR" ] && cp -r "$BAL_SOURCE_DIR" "$BAL_DESTINATION_DIR" +echo "Successfully updated the local central repositories" + +# Loop through examples in the examples directory +find "$BAL_EXAMPLES_DIR" -type f -name "*.bal" | while read -r BAL_EXAMPLE_FILE; do + bal "$BAL_CMD" --offline "$BAL_EXAMPLE_FILE" +done diff --git a/aad/samples/create_group.bal b/examples/create_group.bal similarity index 88% rename from aad/samples/create_group.bal rename to examples/create_group.bal index 8309f54..8425c0e 100644 --- a/aad/samples/create_group.bal +++ b/examples/create_group.bal @@ -26,18 +26,18 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("Create group"); ad:NewGroup info = { description: "", displayName: "", - groupTypes:["Unified"], + groupTypes: ["Unified"], mailEnabled: true, mailNickname: "", securityEnabled: false diff --git a/aad/samples/create_user.bal b/examples/create_user.bal similarity index 90% rename from aad/samples/create_user.bal rename to examples/create_user.bal index 477903a..d42caa9 100644 --- a/aad/samples/create_user.bal +++ b/examples/create_user.bal @@ -26,12 +26,12 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("Create user"); ad:NewUser info = { diff --git a/aad/samples/delete_group.bal b/examples/delete_group.bal similarity index 84% rename from aad/samples/delete_group.bal rename to examples/delete_group.bal index cf31d8f..0d0a0dd 100644 --- a/aad/samples/delete_group.bal +++ b/examples/delete_group.bal @@ -26,18 +26,18 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret - + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret + } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("Delete group"); string groupId = ""; - error? result = aadClient->deleteGroup(groupId); + error? result = aadClient->deleteGroup(groupId); if (result is ()) { log:printInfo("Sucessfully deleted"); } else { diff --git a/aad/samples/delete_user.bal b/examples/delete_user.bal similarity index 84% rename from aad/samples/delete_user.bal rename to examples/delete_user.bal index 6a3f78d..8b9eaf0 100644 --- a/aad/samples/delete_user.bal +++ b/examples/delete_user.bal @@ -26,18 +26,18 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret - + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret + } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("Delete user"); string userId = ""; - error? result = aadClient->deleteUser(userId); + error? result = aadClient->deleteUser(userId); if (result is ()) { log:printInfo("Sucessfully deleted"); } else { diff --git a/aad/samples/get_group.bal b/examples/get_group.bal similarity index 88% rename from aad/samples/get_group.bal rename to examples/get_group.bal index 9070ae2..dce0aea 100644 --- a/aad/samples/get_group.bal +++ b/examples/get_group.bal @@ -26,12 +26,12 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("Get group"); string groupId = ""; diff --git a/aad/samples/get_user.bal b/examples/get_user.bal similarity index 88% rename from aad/samples/get_user.bal rename to examples/get_user.bal index 91da1c4..300dd5c 100644 --- a/aad/samples/get_user.bal +++ b/examples/get_user.bal @@ -26,16 +26,16 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("Get user"); string userId = ""; - + ad:User|error userInfo = aadClient->getUser(userId); if (userInfo is ad:User) { diff --git a/aad/samples/list_groups.bal b/examples/list_groups.bal similarity index 76% rename from aad/samples/list_groups.bal rename to examples/list_groups.bal index ab89516..d15817e 100644 --- a/aad/samples/list_groups.bal +++ b/examples/list_groups.bal @@ -26,20 +26,20 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("List groups"); - stream|error groupStream = aadClient->listGroups(); - if (groupStream is stream) { - error? e = groupStream.forEach(isolated function (ad:Group item) { + stream|error groupStream = aadClient->listGroups(); + if (groupStream is stream) { + error? e = groupStream.forEach(isolated function(ad:Group item) { log:printInfo(item.toString()); - }); + }); } else { log:printError(groupStream.message()); } diff --git a/aad/samples/list_members_of_group.bal b/examples/list_members_of_group.bal similarity index 76% rename from aad/samples/list_members_of_group.bal rename to examples/list_members_of_group.bal index f4ba729..0aa345a 100644 --- a/aad/samples/list_members_of_group.bal +++ b/examples/list_members_of_group.bal @@ -26,21 +26,21 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("List members in a group"); string groupId = ""; - stream|error groupStream = aadClient->listGroupMembers(groupId); - if (groupStream is stream) { - error? e = groupStream.forEach(isolated function (ad:User item) { + stream|error groupStream = aadClient->listGroupMembers(groupId); + if (groupStream is stream) { + error? e = groupStream.forEach(isolated function(ad:User item) { log:printInfo(item.toString()); - }); + }); } else { log:printError(groupStream.message()); } diff --git a/aad/samples/list_owners_of_group.bal b/examples/list_owners_of_group.bal similarity index 76% rename from aad/samples/list_owners_of_group.bal rename to examples/list_owners_of_group.bal index 06015f5..de34e27 100644 --- a/aad/samples/list_owners_of_group.bal +++ b/examples/list_owners_of_group.bal @@ -26,21 +26,21 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("List owners in a group"); string groupId = ""; - stream|error groupStream = aadClient->listGroupOwners(groupId); - if (groupStream is stream) { - error? e = groupStream.forEach(isolated function (ad:User item) { + stream|error groupStream = aadClient->listGroupOwners(groupId); + if (groupStream is stream) { + error? e = groupStream.forEach(isolated function(ad:User item) { log:printInfo(item.toString()); - }); + }); } else { log:printError(groupStream.message()); } diff --git a/aad/samples/list_parent_groups.bal b/examples/list_parent_groups.bal similarity index 75% rename from aad/samples/list_parent_groups.bal rename to examples/list_parent_groups.bal index 7c120a1..aaa7faa 100644 --- a/aad/samples/list_parent_groups.bal +++ b/examples/list_parent_groups.bal @@ -26,21 +26,21 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("List parent groups"); string groupId = ""; - stream|error groupStream = aadClient->listParentGroups("group", groupId); - if (groupStream is stream) { - error? e = groupStream.forEach(isolated function (ad:Group item) { + stream|error groupStream = aadClient->listParentGroups("group", groupId); + if (groupStream is stream) { + error? e = groupStream.forEach(isolated function(ad:Group item) { log:printInfo(item.toString()); - }); + }); } else { log:printError(groupStream.message()); } diff --git a/aad/samples/list_permission_grants.bal b/examples/list_permission_grants.bal similarity index 74% rename from aad/samples/list_permission_grants.bal rename to examples/list_permission_grants.bal index a5c0b2c..f9541b6 100644 --- a/aad/samples/list_permission_grants.bal +++ b/examples/list_permission_grants.bal @@ -26,21 +26,21 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("List permission grants"); string groupId = ""; - stream|error grantStream = aadClient->listPermissionGrants(groupId); - if (grantStream is stream) { - error? e = grantStream.forEach(isolated function (ad:PermissionGrant item) { + stream|error grantStream = aadClient->listPermissionGrants(groupId); + if (grantStream is stream) { + error? e = grantStream.forEach(isolated function(ad:PermissionGrant item) { log:printInfo(item.toString()); - }); + }); } else { log:printError(grantStream.message()); } diff --git a/aad/samples/list_transitive_members.bal b/examples/list_transitive_members.bal similarity index 76% rename from aad/samples/list_transitive_members.bal rename to examples/list_transitive_members.bal index 4c34a7d..218c6e0 100644 --- a/aad/samples/list_transitive_members.bal +++ b/examples/list_transitive_members.bal @@ -26,21 +26,21 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("List transitive members in a group"); string groupId = ""; - stream|error groupStream = aadClient->listTransitiveGroupMembers(groupId); - if (groupStream is stream) { - error? e = groupStream.forEach(isolated function (ad:User item) { + stream|error groupStream = aadClient->listTransitiveGroupMembers(groupId); + if (groupStream is stream) { + error? e = groupStream.forEach(isolated function(ad:User item) { log:printInfo(item.toString()); - }); + }); } else { log:printError(groupStream.message()); } diff --git a/aad/samples/list_transitive_parent_groups.bal b/examples/list_transitive_parent_groups.bal similarity index 75% rename from aad/samples/list_transitive_parent_groups.bal rename to examples/list_transitive_parent_groups.bal index 41cdd17..a7126bd 100644 --- a/aad/samples/list_transitive_parent_groups.bal +++ b/examples/list_transitive_parent_groups.bal @@ -26,21 +26,21 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("List transitive parent groups"); string groupId = ""; - stream|error groupStream = aadClient->listTransitiveParentGroups("group", groupId); - if (groupStream is stream) { - error? e = groupStream.forEach(isolated function (ad:Group item) { + stream|error groupStream = aadClient->listTransitiveParentGroups("group", groupId); + if (groupStream is stream) { + error? e = groupStream.forEach(isolated function(ad:Group item) { log:printInfo(item.toString()); - }); + }); } else { log:printError(groupStream.message()); } diff --git a/aad/samples/list_users.bal b/examples/list_users.bal similarity index 76% rename from aad/samples/list_users.bal rename to examples/list_users.bal index b003361..d9515fe 100644 --- a/aad/samples/list_users.bal +++ b/examples/list_users.bal @@ -26,20 +26,20 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("List users"); - stream|error userStream = aadClient->listUsers(); - if (userStream is stream) { - error? e = userStream.forEach(isolated function (ad:User item) { + stream|error userStream = aadClient->listUsers(); + if (userStream is stream) { + error? e = userStream.forEach(isolated function(ad:User item) { log:printInfo(item.toString()); - }); + }); } else { log:printError(userStream.message()); } diff --git a/aad/samples/remove_group_member.bal b/examples/remove_group_member.bal similarity index 89% rename from aad/samples/remove_group_member.bal rename to examples/remove_group_member.bal index d2b379d..1f5c64c 100644 --- a/aad/samples/remove_group_member.bal +++ b/examples/remove_group_member.bal @@ -26,12 +26,12 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("Remove member from group"); string groupId = ""; diff --git a/aad/samples/remove_group_owner.bal b/examples/remove_group_owner.bal similarity index 89% rename from aad/samples/remove_group_owner.bal rename to examples/remove_group_owner.bal index a50666d..4b05002 100644 --- a/aad/samples/remove_group_owner.bal +++ b/examples/remove_group_owner.bal @@ -26,12 +26,12 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("Remove owner from group"); string groupId = ""; diff --git a/aad/samples/renew_group.bal b/examples/renew_group.bal similarity index 88% rename from aad/samples/renew_group.bal rename to examples/renew_group.bal index f035947..235813b 100644 --- a/aad/samples/renew_group.bal +++ b/examples/renew_group.bal @@ -26,12 +26,12 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("Renew group"); string groupId = ""; diff --git a/aad/samples/update_group.bal b/examples/update_group.bal similarity index 89% rename from aad/samples/update_group.bal rename to examples/update_group.bal index 834c6b6..4be6f4c 100644 --- a/aad/samples/update_group.bal +++ b/examples/update_group.bal @@ -26,19 +26,19 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("Update group"); string groupId = ""; ad:UpdateGroup info = { mailNickname: "" }; - + error? result = aadClient->updateGroup(groupId, info); if (result is ()) { log:printInfo("Sucessfully updated"); diff --git a/aad/samples/update_user.bal b/examples/update_user.bal similarity index 89% rename from aad/samples/update_user.bal rename to examples/update_user.bal index 7ab1ff3..bbb7b88 100644 --- a/aad/samples/update_user.bal +++ b/examples/update_user.bal @@ -26,12 +26,12 @@ public function main() returns error? { ad:ConnectionConfig configuration = { auth: { refreshUrl: refreshUrl, - refreshToken : refreshToken, - clientId : clientId, - clientSecret : clientSecret + refreshToken: refreshToken, + clientId: clientId, + clientSecret: clientSecret } }; - ad:Client aadClient = check new(configuration); + ad:Client aadClient = check new (configuration); log:printInfo("Update user"); string userId = "";