├── examples ├── project-management-with-calendar │ ├── .github │ │ └── README.md │ ├── Ballerina.toml │ ├── project-management-with-calendar.md │ ├── main.bal │ └── Dependencies.toml ├── work-schedule-management-with-calendar │ ├── .github │ │ └── README.md │ ├── Ballerina.toml │ ├── main.bal │ ├── work-schedule-management-with-calendar.md │ └── Dependencies.toml ├── build.sh ├── README.md └── build.gradle ├── ballerina ├── icon.png ├── resources │ ├── consent-screen.png │ ├── exchange-tokens.png │ ├── oauth-playground.png │ ├── create-credentials.png │ ├── enable-calendar-api.png │ ├── authorize-calendar-apis.png │ └── gcp-console-project-view.png ├── tests │ ├── Config.toml │ └── README.md ├── Ballerina.toml ├── modules │ ├── mock │ │ ├── sts_service.bal │ │ └── openapi_service.bal │ └── oas │ │ ├── utils.bal │ │ └── client.bal ├── build.gradle ├── README.md ├── utils.bal ├── Dependencies.toml └── client.bal ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitattributes ├── .github ├── CODEOWNERS └── workflows │ ├── ci.yml │ ├── daily-build.yml │ ├── pull-request.yml │ ├── release.yml │ ├── dev-stg-release.yml │ └── regenerate-connector.yml ├── gradle.properties ├── changelog.md ├── docs ├── license.txt └── spec │ └── sanitations.md ├── .gitignore ├── pull_request_template.md ├── settings.gradle ├── gradlew.bat ├── gradlew ├── README.md └── LICENSE /examples/project-management-with-calendar/.github/README.md: -------------------------------------------------------------------------------- 1 | ../project-management-with-calendar.md -------------------------------------------------------------------------------- /examples/work-schedule-management-with-calendar/.github/README.md: -------------------------------------------------------------------------------- 1 | ../work-schedule-management-with-calendar.md -------------------------------------------------------------------------------- /ballerina/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/HEAD/ballerina/icon.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /ballerina/resources/consent-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/HEAD/ballerina/resources/consent-screen.png -------------------------------------------------------------------------------- /ballerina/resources/exchange-tokens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/HEAD/ballerina/resources/exchange-tokens.png -------------------------------------------------------------------------------- /ballerina/resources/oauth-playground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/HEAD/ballerina/resources/oauth-playground.png -------------------------------------------------------------------------------- /ballerina/resources/create-credentials.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/HEAD/ballerina/resources/create-credentials.png -------------------------------------------------------------------------------- /ballerina/resources/enable-calendar-api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/HEAD/ballerina/resources/enable-calendar-api.png -------------------------------------------------------------------------------- /examples/project-management-with-calendar/Ballerina.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | org = "ballerina" 3 | name = "project_management" 4 | version = "0.1.0" 5 | distribution = "2201.10.0" 6 | -------------------------------------------------------------------------------- /examples/work-schedule-management-with-calendar/Ballerina.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | org = "ballerina" 3 | name = "work_schedule" 4 | version = "0.1.0" 5 | distribution = "2201.10.0" 6 | -------------------------------------------------------------------------------- /ballerina/resources/authorize-calendar-apis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/HEAD/ballerina/resources/authorize-calendar-apis.png -------------------------------------------------------------------------------- /ballerina/resources/gcp-console-project-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/HEAD/ballerina/resources/gcp-console-project-view.png -------------------------------------------------------------------------------- /ballerina/tests/Config.toml: -------------------------------------------------------------------------------- 1 | [googleapis.gcalendar] 2 | mockClientId = "mock-client-id" 3 | mockClientSecret = "mock-client-secret" 4 | mockRefreshToken = "mock-refresh-token" 5 | mockRefreshUrl = "http://localhost:9444/oauth2/token" 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # Linux start script should use lf 5 | /gradlew text eol=lf 6 | 7 | # These are Windows script files and should use crlf 8 | *.bat text eol=crlf 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Lines starting with '#' are comments. 2 | # Each line is a file pattern followed by one or more owners. 3 | 4 | # See: https://help.github.com/articles/about-codeowners/ 5 | 6 | # These owners will be the default owners for everything in the repo. 7 | * @NipunaRanasinghe @Nuvindu @shafreenAnfar 8 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.caching=true 2 | group=io.ballerina.stdlib 3 | version=5.0.0-SNAPSHOT 4 | 5 | checkstylePluginVersion=10.12.0 6 | spotbugsPluginVersion=5.0.14 7 | shadowJarPluginVersion=8.1.1 8 | downloadPluginVersion=5.4.0 9 | releasePluginVersion=2.8.0 10 | testngVersion=7.6.1 11 | eclipseLsp4jVersion=0.12.0 12 | ballerinaGradlePluginVersion=2.3.0 13 | ballerinaLangVersion=2201.12.2 14 | -------------------------------------------------------------------------------- /ballerina/Ballerina.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | distribution = "2201.12.0" 3 | org = "ballerinax" 4 | name = "googleapis.gcalendar" 5 | version = "5.0.0" 6 | license = ["Apache-2.0"] 7 | authors = ["Ballerina"] 8 | keywords = ["Productivity/Calendars", "Cost/Free", "Vendor/Google", "Collaboration", "Enterprise IT", "Management"] 9 | icon = "icon.png" 10 | repository = "https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar" 11 | 12 | [build-options] 13 | observabilityIncluded = true 14 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - 2201.[0-9]+.x 8 | repository_dispatch: 9 | types: check_connector_for_breaking_changes 10 | 11 | jobs: 12 | call_workflow: 13 | name: Run Connector Build Workflow 14 | if: ${{ github.repository_owner == 'ballerina-platform' }} 15 | uses: ballerina-platform/ballerina-library/.github/workflows/build-connector-template.yml@main 16 | secrets: inherit 17 | with: 18 | repo-name: module-ballerinax-googleapis.calendar 19 | -------------------------------------------------------------------------------- /.github/workflows/daily-build.yml: -------------------------------------------------------------------------------- 1 | name: Daily build 2 | 3 | on: 4 | schedule: 5 | - cron: "30 2 * * *" 6 | 7 | jobs: 8 | call_workflow: 9 | name: Run Daily Build Workflow 10 | if: ${{ github.repository_owner == 'ballerina-platform' }} 11 | uses: ballerina-platform/ballerina-library/.github/workflows/daily-build-connector-template.yml@main 12 | secrets: inherit 13 | with: 14 | repo-name: module-ballerinax-googleapis.calendar 15 | additional-build-flags: "-x :googleapis.gcalendar-examples:build" 16 | additional-test-flags: "-x :googleapis.gcalendar-examples:build" 17 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | This file contains all the notable changes done to the Ballerina `googleapis.gcalendar` package through the releases. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [Unreleased] 9 | 10 | ### Added 11 | 12 | ### Changed 13 | 14 | ## [4.0.1] - 2024-02-14 15 | 16 | ### Changed 17 | 18 | - Improve documentation 19 | 20 | ## [4.0.0] - 2023-01-12 21 | 22 | ### Added 23 | 24 | - [Revamp Calendar connector](https://github.com/ballerina-platform/ballerina-library/issues/5712) 25 | -------------------------------------------------------------------------------- /.github/workflows/pull-request.yml: -------------------------------------------------------------------------------- 1 | name: PR Build 2 | 3 | concurrency: 4 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} 5 | cancel-in-progress: true 6 | 7 | on: pull_request 8 | 9 | jobs: 10 | call_workflow: 11 | name: Run PR Build Workflow 12 | if: ${{ github.repository_owner == 'ballerina-platform' }} 13 | uses: ballerina-platform/ballerina-library/.github/workflows/pr-build-connector-template.yml@main 14 | secrets: inherit 15 | with: 16 | additional-build-flags: "-x :googleapis.gcalendar-examples:build" 17 | additional-test-flags: ${{ github.event.pull_request.head.repo.full_name != github.repository && '-x test' || ''}} 18 | -------------------------------------------------------------------------------- /docs/license.txt: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com). 2 | // 3 | // WSO2 LLC. licenses this file to you under the Apache License, 4 | // Version 2.0 (the "License"); you may not use this file except 5 | // in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, 11 | // software distributed under the License is distributed on an 12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | // KIND, either express or implied. See the License for the 14 | // specific language governing permissions and limitations 15 | // under the License. 16 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Publish Release 2 | 3 | on: 4 | workflow_dispatch: 5 | repository_dispatch: 6 | types: [ stdlib-release-pipeline ] 7 | 8 | jobs: 9 | call_workflow: 10 | name: Run Release Workflow 11 | if: ${{ github.repository_owner == 'ballerina-platform' }} 12 | uses: ballerina-platform/ballerina-library/.github/workflows/release-package-connector-template.yml@main 13 | secrets: inherit 14 | with: 15 | package-name: googleapis.gcalendar 16 | package-org: ballerinax 17 | additional-build-flags: "-x :googleapis.gcalendar-examples:build" 18 | additional-release-flags: "-x :googleapis.gcalendar-examples:build" 19 | additional-publish-flags: "-x :googleapis.gcalendar-examples:build" 20 | -------------------------------------------------------------------------------- /.github/workflows/dev-stg-release.yml: -------------------------------------------------------------------------------- 1 | name: Publish to the Ballerina Dev\Stage Central 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | environment: 7 | type: choice 8 | description: Select Environment 9 | required: true 10 | options: 11 | - DEV CENTRAL 12 | - STAGE CENTRAL 13 | 14 | jobs: 15 | call_workflow: 16 | name: Run Dev\Stage Central Publish Workflow 17 | if: ${{ github.repository_owner == 'ballerina-platform' }} 18 | uses: ballerina-platform/ballerina-library/.github/workflows/dev-stage-central-publish-connector-template.yml@main 19 | secrets: inherit 20 | with: 21 | environment: ${{ github.event.inputs.environment }} 22 | additional-publish-flags: "-x :googleapis.gcalendar-examples:build" 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | *.balx 4 | 5 | # Log file 6 | *.log 7 | 8 | #Config file 9 | Config.toml 10 | **/Config.toml 11 | 12 | # BlueJ files 13 | *.ctxt 14 | 15 | # Mobile Tools for Java (J2ME) 16 | .mtj.tmp/ 17 | 18 | # .DS_Store files 19 | *.DS_Store 20 | 21 | # Package Files # 22 | *.jar 23 | !gradle/wrapper/gradle-wrapper.jar 24 | *.war 25 | *.ear 26 | *.zip 27 | *.tar.gz 28 | *.rar 29 | *.deb 30 | 31 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 32 | hs_err_pid* 33 | 34 | # Ignore everything in this directory 35 | target 36 | .idea 37 | .classpath 38 | .settings 39 | .project 40 | *.iml 41 | *.iws 42 | *.ipr 43 | .idea 44 | .m2 45 | .vscode/ 46 | # Ignore ballerina files 47 | accessToken.bal 48 | temp.bal.ballerina/ 49 | target/ 50 | .DS_Store 51 | *Ballerina.lock 52 | .ballerina 53 | 54 | # Ignore Gradle project-specific cache directory 55 | .gradle 56 | 57 | # Ignore Gradle build output directory 58 | build 59 | generated 60 | 61 | # Ignore Docker env file 62 | docker.env 63 | 64 | # Ignore environment files 65 | *.env 66 | 67 | # Ignore all Dependencies.toml files in the examples directory 68 | examples/**/Dependencies.toml 69 | -------------------------------------------------------------------------------- /ballerina/tests/README.md: -------------------------------------------------------------------------------- 1 | # Running Tests 2 | 3 | There are two test environments for the Google Calendar connector. The default test environment is the mock server for Calendar API. The other test environment is testing against the actual Calendar API endpoint. You can run the tests in either of these environments. 4 | 5 | ## Running Tests against the Mock Server 6 | 7 | To execute the tests on the mock server, ensure that the `IS_TEST_ON_LIVE_SERVER` environment variable is either set to false or unset before initiating the tests. 8 | 9 | You can set your authentication credentials as environment variables: 10 | 11 | ```bash 12 | export IS_TEST_ON_LIVE_SERVER=false 13 | ``` 14 | 15 | Then, run the following command to run the tests: 16 | 17 | ```bash 18 | ./gradlew clean test 19 | ``` 20 | 21 | ## Running Tests against the Live Endpoint 22 | 23 | You can set your authentication credentials as environment variables: 24 | 25 | ```bash 26 | export IS_TEST_ON_LIVE_SERVER=true 27 | export CLIENT_ID="" 28 | export CLIENT_SECRET="" 29 | export REFRESH_TOKEN="" 30 | export REFRESH_URL="" 31 | ``` 32 | 33 | Then, run the following command to run the tests: 34 | 35 | ```bash 36 | ./gradlew clean test 37 | ``` 38 | -------------------------------------------------------------------------------- /pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. 4 | 5 | Fixes # (issue) 6 | 7 | Related Pull Requests (remove if not relevant) 8 | - Pull request 1 9 | - Pull request 2 10 | 11 | One line release note: 12 | - One line describing the feature/improvement/fix made by this PR 13 | 14 | ## Type of change 15 | 16 | Please delete options that are not relevant. 17 | 18 | - [ ] Bug fix (non-breaking change which fixes an issue) 19 | - [ ] New feature (non-breaking change which adds functionality) 20 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 21 | - [ ] This change requires a documentation update 22 | 23 | # How Has This Been Tested? 24 | 25 | Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration 26 | 27 | - [ ] Test A 28 | - [ ] Test B 29 | 30 | **Test Configuration**: 31 | * Ballerina Version: 32 | * Operating System: 33 | * Java SDK: 34 | 35 | # Checklist: 36 | 37 | ### Security checks 38 | - [ ] Followed secure coding standards in http://wso2.com/technical-reports/wso2-secure-engineering-guidelines? 39 | - [ ] Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? 40 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.3/userguide/building_swift_projects.html in the Gradle documentation. 6 | */ 7 | 8 | pluginManagement { 9 | plugins { 10 | id "com.github.spotbugs-base" version "${spotbugsPluginVersion}" 11 | id "com.github.johnrengelman.shadow" version "${shadowJarPluginVersion}" 12 | id "de.undercouch.download" version "${downloadPluginVersion}" 13 | id "net.researchgate.release" version "${releasePluginVersion}" 14 | id "io.ballerina.plugin" version "${ballerinaGradlePluginVersion}" 15 | } 16 | 17 | repositories { 18 | gradlePluginPortal() 19 | maven { 20 | url = 'https://maven.pkg.github.com/ballerina-platform/*' 21 | credentials { 22 | username System.getenv("packageUser") 23 | password System.getenv("packagePAT") 24 | } 25 | } 26 | } 27 | } 28 | 29 | plugins { 30 | id "com.gradle.enterprise" version "3.2" 31 | } 32 | 33 | rootProject.name = 'module-ballerinax-googleapis.gcalendar' 34 | 35 | include ':googleapis.gcalendar-ballerina' 36 | include ':googleapis.gcalendar-examples' 37 | 38 | project(':googleapis.gcalendar-ballerina').projectDir = file("ballerina") 39 | project(':googleapis.gcalendar-examples').projectDir = file("examples") 40 | 41 | gradleEnterprise { 42 | buildScan { 43 | termsOfServiceUrl = 'https://gradle.com/terms-of-service' 44 | termsOfServiceAgree = 'yes' 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /examples/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BAL_EXAMPLES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 4 | BAL_CENTRAL_DIR="$HOME/.ballerina/repositories/central.ballerina.io/" 5 | BAL_HOME_DIR="$BAL_EXAMPLES_DIR/../ballerina" 6 | 7 | set -e 8 | 9 | case "$1" in 10 | build) 11 | BAL_CMD="build" 12 | ;; 13 | run) 14 | BAL_CMD="run" 15 | ;; 16 | *) 17 | echo "Invalid command provided: '$1'. Please provide 'build' or 'run' as the command." 18 | exit 1 19 | ;; 20 | esac 21 | 22 | # Read Ballerina package name 23 | BAL_PACKAGE_NAME=$(awk -F'"' '/^name/ {print $2}' "$BAL_HOME_DIR/Ballerina.toml") 24 | 25 | # Push the package to the local repository 26 | cd "$BAL_HOME_DIR" && 27 | bal pack && 28 | bal push --repository=local 29 | 30 | # Remove the cache directories in the repositories 31 | rm -rf "$BAL_CENTRAL_DIR/cache-*" 32 | 33 | # Update the central repository 34 | BAL_DESTINATION_DIR="$HOME/.ballerina/repositories/central.ballerina.io/bala/ballerinax" 35 | BAL_SOURCE_DIR="$HOME/.ballerina/repositories/local/bala/ballerinax/$BAL_PACKAGE_NAME" 36 | 37 | mkdir -p "$BAL_DESTINATION_DIR" 38 | 39 | [ -d "$BAL_SOURCE_DIR" ] && cp -r "$BAL_SOURCE_DIR" "$BAL_DESTINATION_DIR" 40 | echo "Successfully updated the local central repositories" 41 | 42 | # Loop through examples in the examples directory 43 | cd "$BAL_EXAMPLES_DIR" 44 | for dir in $(find "$BAL_EXAMPLES_DIR" -type d -maxdepth 1 -mindepth 1); do 45 | # Skip the build directory 46 | if [[ "$dir" == *build ]]; then 47 | continue 48 | fi 49 | (cd "$dir" && bal "$BAL_CMD" --offline && cd ..); 50 | done 51 | 52 | # Remove generated JAR files 53 | find "$BAL_HOME_DIR" -maxdepth 1 -type f -name "*.jar" | while read -r JAR_FILE; do 54 | rm "$JAR_FILE" 55 | done 56 | -------------------------------------------------------------------------------- /docs/spec/sanitations.md: -------------------------------------------------------------------------------- 1 | # Sanitations for OpenAPI specification 2 | 3 | _Authors_: @Nuvindu \ 4 | _Reviewers_: @shafreenAnfar @ThisaruGuruge \ 5 | _Created_: 2024/02/14 \ 6 | _Updated_: 2024/11/11 \ 7 | _Edition_: Swan Lake 8 | 9 | ## Introduction 10 | 11 | The Ballerina Google Calendar connector facilitates integration with the [Google Calendar API V3](https://developers.google.com/calendar/api) by generating client code using the [OpenAPI specification](https://github.com/Nuvindu/module-ballerinax-googleapis.calendar/blob/main/docs/spec/openapi.yaml). To improve usability, several modifications have been made to the original specification: 12 | 13 | 1. **Parameter descriptions**: 14 | Undocumented parameters in various resource functions now include detailed descriptions, enhancing clarity and usability. 15 | 16 | 2. **Resource path simplification**: 17 | * Removed `/users/{userId}/settings` due to complex sub-paths with limited utility. 18 | * Excluded `/users/{userId}/watch` and `/users/{userId}/stop`, as they are covered under Google Pub/Sub. 19 | 20 | 3. **Enhanced response descriptions**: 21 | Updated generic "Successful Response" labels to reflect specific return types. 22 | 23 | 4. **Deprecated parameters removal**: 24 | Removed deprecated parameters from resource paths to streamline the connector. 25 | 26 | 5. **Detailed type descriptions**: 27 | Added comprehensive descriptions for undocumented types. 28 | * Calendar, FreeBusyCalendar, ConferenceSolution, EventDateTime, EntryPoint, FreeBusyRequestItem, ConferenceData, ConferenceRequestStatus, TimePeriod, CreateConferenceRequest, Colors, ConferenceProperties, EventWorkingLocationProperties, CalendarListEntry, Events, CalendarList, ColorDefinition, EventReminder, EventAttendee, Error, Acl, FreeBusyGroup, CalendarNotification, FreeBusyRequest, EventAttachment, ConferenceSolutionKey, ConferenceParametersAddOnParameters, ConferenceParameters, Event, AclRule. 29 | 30 | ## OpenAPI cli command 31 | 32 | ```bash 33 | bal openapi -i docs/spec/openapi.yaml --mode client -o ballerina/modules/oas 34 | -------------------------------------------------------------------------------- /.github/workflows/regenerate-connector.yml: -------------------------------------------------------------------------------- 1 | name: Regenerate OpenAPI Connector 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | openapi-url: 7 | description: "URL of the OpenAPI JSON" 8 | required: false 9 | type: string 10 | flatten-openapi: 11 | description: "Enable OpenAPI Flattening" 12 | required: false 13 | type: boolean 14 | default: true 15 | additional-flatten-flags: 16 | description: "Additional flags for OpenAPI Flattening" 17 | required: false 18 | type: string 19 | default: "" 20 | align-openapi: 21 | description: "Enable OpenAPI Alignment" 22 | required: false 23 | type: boolean 24 | default: true 25 | additional-align-flags: 26 | description: "Additional flags for OpenAPI Alignment" 27 | required: false 28 | type: string 29 | default: "" 30 | additional-generation-flags: 31 | description: "Additional flags for OpenAPI Generation" 32 | required: false 33 | type: string 34 | default: "" 35 | distribution-zip: 36 | description: "Distribution of the Ballerina version to be used" 37 | required: false 38 | type: string 39 | default: "" 40 | auto-merge: 41 | description: "Enable auto-merge of the PR" 42 | required: false 43 | type: boolean 44 | default: true 45 | ballerina-version: 46 | description: "Ballerina Language Version" 47 | required: false 48 | type: string 49 | default: "" 50 | 51 | jobs: 52 | call_workflow: 53 | name: Run Regenerate Connector Workflow 54 | if: ${{ github.repository_owner == 'ballerina-platform' }} 55 | uses: ballerina-platform/ballerina-library/.github/workflows/regenerate-connector-template.yml@main 56 | secrets: inherit 57 | with: 58 | openapi-url: ${{ inputs.openapi-url }} 59 | flatten-openapi: ${{ inputs.flatten-openapi }} 60 | additional-flatten-flags: ${{ inputs.additional-flatten-flags }} 61 | align-openapi: ${{ inputs.align-openapi }} 62 | additional-align-flags: ${{ inputs.additional-align-flags }} 63 | additional-generation-flags: ${{ inputs.additional-generation-flags }} 64 | distribution-zip: ${{ inputs.distribution-zip }} 65 | auto-merge: ${{ inputs.auto-merge }} 66 | ballerina-version: ${{ inputs.ballerina-version }} 67 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | The Google Calendar connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar/tree/main/examples), covering use cases like creating calendar, scheduling meeting events, and adding reminders. 4 | 5 | 1. [Project management with Calendar API](https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar/tree/main/examples/project-management-with-calendar) 6 | This example shows how to use Google Calendar APIs to efficiently manage work schedule of a person. It interacts with the API for various tasks related to scheduling and organizing work-related events and meetings. 7 | 2. [Work schedule management with Calendar API](https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar/tree/main/examples/work-schedule-management-with-calendar) 8 | This example shows how to use Google Calendar APIs to managing personal project schedule and collaborating with team members. 9 | 10 | ## Prerequisites 11 | 12 | 1. Follow the [instructions](https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar#set-up-guide) to set up the Calendar API. 13 | 14 | 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: 15 | 16 | ```toml 17 | clientId="" 18 | clientSecret="" 19 | refreshToken="" 20 | refreshUrl="" 21 | ``` 22 | 23 | ## Running an Example 24 | 25 | Execute the following commands to build an example from the source: 26 | 27 | * To build an example: 28 | 29 | ```bash 30 | bal build 31 | ``` 32 | 33 | * To run an example: 34 | 35 | ```bash 36 | bal run 37 | ``` 38 | 39 | ## Building the Examples with the Local Module 40 | 41 | **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. 42 | 43 | Execute the following commands to build all the examples against the changes you have made to the module locally: 44 | 45 | * To build all the examples: 46 | 47 | ```bash 48 | ./build.sh build 49 | ``` 50 | 51 | * To run all the examples: 52 | 53 | ```bash 54 | ./build.sh run 55 | ``` 56 | -------------------------------------------------------------------------------- /ballerina/modules/mock/sts_service.bal: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. 2 | // 3 | // WSO2 LLC. licenses this file to you under the Apache License, 4 | // Version 2.0 (the "License"); you may not use this file except 5 | // in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, 11 | // software distributed under the License is distributed on an 12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | // KIND, either express or implied. See the License for the 14 | // specific language governing permissions and limitations 15 | // under the License. 16 | 17 | import ballerina/http; 18 | import ballerina/log; 19 | 20 | configurable int HTTP_SERVER_PORT = 9444; 21 | configurable int TOKEN_VALIDITY_PERIOD = 1000; // in seconds 22 | 23 | listener http:Listener sts = new (HTTP_SERVER_PORT); 24 | 25 | service /oauth2 on sts { 26 | 27 | function init() { 28 | log:printInfo("STS started on port: " + HTTP_SERVER_PORT.toString() + " (HTTP)"); 29 | } 30 | 31 | // This issues an access token with reference to the received grant type (client credentials, password and refresh token grant type). 32 | resource function post token(http:Request req) returns json|http:Unauthorized|http:BadRequest|http:InternalServerError { 33 | json response = { 34 | "access_token": "asdadadsadadada", 35 | "token_type": "example", 36 | "expires_in": TOKEN_VALIDITY_PERIOD, 37 | "example_parameter": "example_value" 38 | }; 39 | return response; 40 | } 41 | 42 | resource function post introspect(http:Request req) returns json|http:Unauthorized|http:BadRequest { 43 | json response = { 44 | "active": true, 45 | "scope": "read write dolphin", 46 | "client_id": "l238j323ds-23ij4", 47 | "username": "jdoe", 48 | "token_type": "token_type", 49 | "exp": TOKEN_VALIDITY_PERIOD, 50 | "iat": 1419350238, 51 | "nbf": 1419350238, 52 | "sub": "Z5O3upPC88QrAjx00dis", 53 | "aud": "https://protected.example.net/resource", 54 | "iss": "https://server.example.com/", 55 | "jti": "JlbmMiOiJBMTI4Q0JDLUhTMjU2In", 56 | "extension_field": "twenty-seven", 57 | "scp": "admin" 58 | }; 59 | return response; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /examples/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * WSO2 Inc. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | import org.apache.tools.ant.taskdefs.condition.Os 20 | 21 | apply plugin: 'java' 22 | 23 | def graalvmFlag = "" 24 | 25 | task testExamples { 26 | if (project.hasProperty("balGraalVMTest")) { 27 | graalvmFlag = "--graalvm" 28 | } 29 | doLast { 30 | try { 31 | exec { 32 | workingDir project.projectDir 33 | println("Working dir: ${workingDir}") 34 | if (Os.isFamily(Os.FAMILY_WINDOWS)) { 35 | commandLine 'sh', "/c", "chmod +x ./build.sh && ./build.sh run && exit %%ERRORLEVEL%%" 36 | } else { 37 | commandLine 'sh', "-c", "chmod +x ./build.sh && ./build.sh run" 38 | } 39 | } 40 | } catch (Exception e) { 41 | println("Example Build failed: " + e.message) 42 | throw e 43 | } 44 | } 45 | } 46 | 47 | task buildExamples { 48 | gradle.taskGraph.whenReady { graph -> 49 | if (graph.hasTask(":googleapis.gcalendar-examples:test")) { 50 | buildExamples.enabled = false 51 | } else { 52 | testExamples.enabled = false 53 | } 54 | } 55 | doLast { 56 | try { 57 | exec { 58 | workingDir project.projectDir 59 | println("Working dir: ${workingDir}") 60 | if (Os.isFamily(Os.FAMILY_WINDOWS)) { 61 | commandLine 'sh', "/c", "chmod +x ./build.sh && ./build.sh build && exit %%ERRORLEVEL%%" 62 | } else { 63 | commandLine 'sh', "-c", "chmod +x ./build.sh && ./build.sh build" 64 | } 65 | } 66 | } catch (Exception e) { 67 | println("Example Build failed: " + e.message) 68 | throw e 69 | } 70 | } 71 | } 72 | 73 | buildExamples.dependsOn ":googleapis.gcalendar-ballerina:build" 74 | testExamples.dependsOn ":googleapis.gcalendar-ballerina:build" 75 | 76 | build.dependsOn buildExamples 77 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /ballerina/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * WSO2 LLC. licenses this file to you under the Apache License, 5 | * Version 2.0 (the "License"); you may not use this file except 6 | * in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | */ 18 | 19 | import org.apache.tools.ant.taskdefs.condition.Os 20 | 21 | plugins { 22 | id 'io.ballerina.plugin' 23 | } 24 | 25 | description = 'Calendar - Ballerina' 26 | 27 | def packageName = "googleapis.gcalendar" 28 | def packageOrg = "ballerinax" 29 | def tomlVersion = stripBallerinaExtensionVersion("${project.version}") 30 | def ballerinaTomlFilePlaceHolder = new File("${project.rootDir}/build-config/resources/Ballerina.toml") 31 | def ballerinaTomlFile = new File("$project.projectDir/Ballerina.toml") 32 | 33 | def stripBallerinaExtensionVersion(String extVersion) { 34 | if (extVersion.matches(project.ext.timestampedVersionRegex)) { 35 | def splitVersion = extVersion.split('-') 36 | if (splitVersion.length > 3) { 37 | def strippedValues = splitVersion[0..-4] 38 | return strippedValues.join('-') 39 | } else { 40 | return extVersion 41 | } 42 | } else { 43 | return extVersion.replace("${project.ext.snapshotVersion}", "") 44 | } 45 | } 46 | 47 | ballerina { 48 | packageOrganization = packageOrg 49 | module = packageName 50 | testCoverageParam = "--code-coverage --coverage-format=xml" 51 | isConnector = true 52 | platform = "any" 53 | } 54 | 55 | task updateTomlFiles { 56 | doLast { 57 | def newBallerinaToml = ballerinaTomlFilePlaceHolder.text.replace("@project.version@", project.version) 58 | newBallerinaToml = newBallerinaToml.replace("@toml.version@", tomlVersion) 59 | ballerinaTomlFile.text = newBallerinaToml 60 | } 61 | } 62 | 63 | task commitTomlFiles { 64 | doLast { 65 | project.exec { 66 | ignoreExitValue true 67 | if (Os.isFamily(Os.FAMILY_WINDOWS)) { 68 | commandLine 'cmd', '/c', "git commit -m \"[Automated] Update the toml files\" Ballerina.toml Dependencies.toml" 69 | } else { 70 | commandLine 'sh', '-c', "git commit -m '[Automated] Update the toml files' Ballerina.toml Dependencies.toml" 71 | } 72 | } 73 | } 74 | } 75 | 76 | publishing { 77 | publications { 78 | maven(MavenPublication) { 79 | artifact source: createArtifactZip, extension: 'zip' 80 | } 81 | } 82 | repositories { 83 | maven { 84 | name = "GitHubPackages" 85 | url = uri("https://maven.pkg.github.com/ballerina-platform/module-${packageOrg}-${packageName}") 86 | credentials { 87 | username = System.getenv("publishUser") 88 | password = System.getenv("publishPAT") 89 | } 90 | } 91 | } 92 | } 93 | 94 | clean { 95 | delete 'build' 96 | } 97 | 98 | build.dependsOn "generatePomFileForMavenPublication" 99 | publishToMavenLocal.dependsOn build 100 | publish.dependsOn build 101 | -------------------------------------------------------------------------------- /examples/project-management-with-calendar/project-management-with-calendar.md: -------------------------------------------------------------------------------- 1 | # Project management with Google Calendar API 2 | 3 | This example demonstrates the use of the Google Calendar API in Ballerina for managing a personal project schedule and collaborating with team members. 4 | 5 | ## Step 1: Import Google Calendar module 6 | 7 | Import the `ballerinax/googleapis.gcalendar` module. 8 | 9 | ```ballerina 10 | import ballerinax/googleapis.gcalendar; 11 | ``` 12 | 13 | ## Step 2: Create a connector instance 14 | 15 | Next, create a `gcalendar:ConnectionConfig` with OAuth2.0 tokens and initialize the connector. 16 | 17 | ```ballerina 18 | gcalendar:ConnectionConfig config = { 19 | auth: { 20 | clientId: , 21 | clientSecret: , 22 | refreshToken: , 23 | refreshUrl: , 24 | } 25 | }; 26 | 27 | gcalendar:Client calendar = check new(config); 28 | ``` 29 | 30 | Now, the `gcalendar:Client` instance can be used for the following steps. 31 | 32 | ## Step 3: Create a project calendar 33 | 34 | To keep project events organized, create a dedicated calendar with a descriptive title. 35 | 36 | ```ballerina 37 | gcalendar:Calendar projectCalendar = check calendar->/calendars.post({ 38 | summary: "Software Project" 39 | }); 40 | ``` 41 | 42 | ## Step 4: Schedule project tasks 43 | 44 | The following steps are to schedule various project-related tasks using the Google Calendar API. 45 | 46 | ```ballerina 47 | gcalendar:Event codingSession = check calendar->/calendars/[calendarId]/events.post({ 48 | 'start: { 49 | dateTime: "2023-10-20T10:00:00+00:00", 50 | timeZone: "UTC" 51 | }, 52 | end: { 53 | dateTime: "2023-10-20T12:00:00+00:00", 54 | timeZone: "UTC" 55 | }, 56 | summary: "Code Review" 57 | }); 58 | 59 | 60 | gcalendar:Event|error designReview = calendar->/calendars/[calendarId]/events.post({ 61 | 'start: { 62 | dateTime: "2023-10-25T14:00:00+00:00", 63 | timeZone: "UTC" 64 | }, 65 | end: { 66 | dateTime: "2023-10-25T16:00:00+00:00", 67 | timeZone: "UTC" 68 | }, 69 | summary: "Design Review" 70 | }); 71 | ``` 72 | 73 | ## Step 5: Collaborate with team 74 | 75 | Invite team members to project events ensures that everyone involved is aware of and aligned on project milestones. 76 | 77 | ```ballerina 78 | gcalendar:Event|error updatedCodingSession = calendar->/calendars/[calendarId]/events/[codingSessionId].put({ 79 | 'start: { 80 | dateTime: "2023-10-20T10:00:00+00:00", 81 | timeZone: "UTC" 82 | }, 83 | end: { 84 | dateTime: "2023-10-20T12:00:00+00:00", 85 | timeZone: "UTC" 86 | }, 87 | summary: "Code Review - Team A", 88 | attendees: [ 89 | { 90 | "email": "team-member1@gmail.com" 91 | }, 92 | { 93 | "email": "team-member2@gmail.com" 94 | } 95 | ] 96 | }); 97 | ``` 98 | 99 | ## Step 6: Set project milestone reminders 100 | 101 | Set reminders for important milestones. 102 | 103 | ```ballerina 104 | gcalendar:Event|error milestoneEvent = calendar->/calendars/[calendarId]/events.post({ 105 | 'start: { 106 | dateTime: "2023-11-15T09:00:00+00:00", 107 | timeZone: "UTC" 108 | }, 109 | end: { 110 | dateTime: "2023-11-15T17:00:00+00:00", 111 | timeZone: "UTC" 112 | }, 113 | summary: "Project Beta Release", 114 | reminders: { 115 | useDefault: false, 116 | overrides: [ 117 | { 118 | method: "popup", 119 | minutes: 60 120 | }, 121 | { 122 | method: "email", 123 | minutes: 1440 124 | } 125 | ] 126 | } 127 | }); 128 | ``` 129 | 130 | ## Step 7: Monitor project progress 131 | 132 | Retrieve and analyze project events to monitor progress and make data-driven decisions. 133 | 134 | ```ballerina 135 | gcalendar:Events|error projectEvents = calendar->/calendars/[calendarId]/events.get(); 136 | ``` 137 | -------------------------------------------------------------------------------- /examples/project-management-with-calendar/main.bal: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. 2 | // 3 | // WSO2 LLC. licenses this file to you under the Apache License, 4 | // Version 2.0 (the "License"); you may not use this file except 5 | // in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, 11 | // software distributed under the License is distributed on an 12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | // KIND, either express or implied. See the License for the 14 | // specific language governing permissions and limitations 15 | // under the License. 16 | 17 | import ballerina/log; 18 | import ballerinax/googleapis.gcalendar; 19 | import ballerina/os; 20 | 21 | configurable string clientId = os:getEnv("CLIENT_ID"); 22 | configurable string clientSecret = os:getEnv("CLIENT_SECRET"); 23 | configurable string refreshToken = os:getEnv("REFRESH_TOKEN"); 24 | configurable string refreshUrl = os:getEnv("REFRESH_URL"); 25 | 26 | public function main() returns error? { 27 | gcalendar:Client calendar = check new ({ 28 | auth: { 29 | clientId, 30 | clientSecret, 31 | refreshToken, 32 | refreshUrl 33 | } 34 | }); 35 | 36 | gcalendar:Calendar projectCalendar = check calendar->/calendars.post({ 37 | summary: "Software Project" 38 | }); 39 | string calendarId = projectCalendar.id; 40 | 41 | gcalendar:Event codingSession = check calendar->/calendars/[calendarId]/events.post({ 42 | 'start: { 43 | dateTime: "2023-10-20T10:00:00+00:00", 44 | timeZone: "UTC" 45 | }, 46 | end: { 47 | dateTime: "2023-10-20T12:00:00+00:00", 48 | timeZone: "UTC" 49 | }, 50 | summary: "Code Review" 51 | }); 52 | string codingSessionId = codingSession.id; 53 | 54 | gcalendar:Event|error designReview = calendar->/calendars/[calendarId]/events.post({ 55 | 'start: { 56 | dateTime: "2023-10-25T14:00:00+00:00", 57 | timeZone: "UTC" 58 | }, 59 | end: { 60 | dateTime: "2023-10-25T16:00:00+00:00", 61 | timeZone: "UTC" 62 | }, 63 | summary: "Design Review" 64 | }); 65 | 66 | if designReview is error { 67 | log:printError(designReview.message()); 68 | } 69 | 70 | gcalendar:Event|error updatedCodingSession = calendar->/calendars/[calendarId]/events/[codingSessionId].put({ 71 | 'start: { 72 | dateTime: "2023-10-20T10:00:00+00:00", 73 | timeZone: "UTC" 74 | }, 75 | end: { 76 | dateTime: "2023-10-20T12:00:00+00:00", 77 | timeZone: "UTC" 78 | }, 79 | summary: "Code Review - Team A", 80 | attendees: [ 81 | { 82 | "email": "team-member1@gmail.com" 83 | }, 84 | { 85 | "email": "team-member2@gmail.com" 86 | } 87 | ] 88 | }); 89 | 90 | if updatedCodingSession is error { 91 | log:printError(updatedCodingSession.message()); 92 | } 93 | 94 | gcalendar:Event|error milestoneEvent = calendar->/calendars/[calendarId]/events.post({ 95 | 'start: { 96 | dateTime: "2023-11-15T09:00:00+00:00", 97 | timeZone: "UTC" 98 | }, 99 | end: { 100 | dateTime: "2023-11-15T17:00:00+00:00", 101 | timeZone: "UTC" 102 | }, 103 | summary: "Project Beta Release", 104 | reminders: { 105 | useDefault: false, 106 | overrides: [ 107 | { 108 | method: "popup", 109 | minutes: 60 110 | }, 111 | { 112 | method: "email", 113 | minutes: 1440 114 | } 115 | ] 116 | } 117 | }); 118 | 119 | if milestoneEvent is error { 120 | log:printError(milestoneEvent.message()); 121 | } 122 | 123 | gcalendar:Events|error projectEvents = calendar->/calendars/[calendarId]/events.get(); 124 | if projectEvents is error { 125 | log:printError(projectEvents.message()); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /examples/work-schedule-management-with-calendar/main.bal: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. 2 | // 3 | // WSO2 LLC. licenses this file to you under the Apache License, 4 | // Version 2.0 (the "License"); you may not use this file except 5 | // in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, 11 | // software distributed under the License is distributed on an 12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | // KIND, either express or implied. See the License for the 14 | // specific language governing permissions and limitations 15 | // under the License. 16 | 17 | import ballerinax/googleapis.gcalendar; 18 | import ballerina/log; 19 | import ballerina/os; 20 | 21 | configurable string clientId = os:getEnv("CLIENT_ID"); 22 | configurable string clientSecret = os:getEnv("CLIENT_SECRET"); 23 | configurable string refreshToken = os:getEnv("REFRESH_TOKEN"); 24 | configurable string refreshUrl = os:getEnv("REFRESH_URL"); 25 | 26 | public function main() returns error? { 27 | gcalendar:Client calendar = check new ({ 28 | auth: { 29 | clientId, 30 | clientSecret, 31 | refreshToken, 32 | refreshUrl 33 | } 34 | }); 35 | 36 | // create new calendar 37 | gcalendar:Calendar calendarResult = check calendar->/calendars.post({ 38 | summary: "Work Schedule" 39 | }); 40 | string calendarId = calendarResult.id; 41 | 42 | // create new event 43 | gcalendar:Event event = check calendar->/calendars/[calendarId]/events.post({ 44 | 'start: { 45 | dateTime: "2023-10-19T09:00:00+05:30", 46 | timeZone: "Asia/Colombo" 47 | }, 48 | end: { 49 | dateTime: "2023-10-19T09:30:00+05:30", 50 | timeZone: "Asia/Colombo" 51 | }, 52 | summary: "Project Kickoff Meeting" 53 | }); 54 | string eventId = event.id; 55 | 56 | // update event to invite attendees by email 57 | gcalendar:Event updatedEvent = check calendar->/calendars/[calendarId]/events/[eventId].put({ 58 | 'start: { 59 | dateTime: "2023-10-19T09:00:00+05:30", 60 | timeZone: "Asia/Colombo" 61 | }, 62 | end: { 63 | dateTime: "2023-10-19T09:30:00+05:30", 64 | timeZone: "Asia/Colombo" 65 | }, 66 | summary: "Team Meeting", 67 | location: "Conference Room", 68 | description: "Weekly team meeting to discuss project status.", 69 | attendees: [ 70 | { 71 | "email": "team-member1@gmail.com" 72 | }, 73 | { 74 | "email": "team-member2@gmail.com" 75 | } 76 | ] 77 | }); 78 | string updatedEventId = updatedEvent.id; 79 | 80 | // update event to add reminders to send timely notifications to attendees before the meeting 81 | gcalendar:Event|error reminderEvent = calendar->/calendars/[calendarId]/events/[updatedEventId].put({ 82 | 'start: { 83 | dateTime: "2023-10-19T03:00:00+05:30", 84 | timeZone: "Asia/Colombo" 85 | }, 86 | end: { 87 | dateTime: "2023-10-19T03:30:00+05:30", 88 | timeZone: "Asia/Colombo" 89 | }, 90 | reminders: { 91 | useDefault: false, 92 | overrides: [ 93 | {method: "popup", minutes: 15}, 94 | {method: "email", minutes: 30} 95 | ] 96 | } 97 | }); 98 | 99 | if reminderEvent is error { 100 | log:printError(reminderEvent.message()); 101 | } 102 | 103 | // create access control rule and assign it to a team member 104 | gcalendar:AclRule acl = check calendar->/calendars/[calendarId]/acl.post({ 105 | scope: { 106 | 'type: "user", 107 | value: "team_member@gmail.com" 108 | }, 109 | role: "reader" 110 | }); 111 | string aclId = acl.id; 112 | 113 | // change access control rule 114 | gcalendar:AclRule|error response = calendar->/calendars/[calendarId]/acl/[aclId].put({ 115 | scope: { 116 | 'type: "user", 117 | value: "team_member@gmail.com" 118 | }, 119 | role: "writer" 120 | }); 121 | if response is error { 122 | log:printError(response.message()); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /examples/work-schedule-management-with-calendar/work-schedule-management-with-calendar.md: -------------------------------------------------------------------------------- 1 | # Work schedule management with Google Calendar API 2 | 3 | This example demonstrates the use of the Google Calendar API in Ballerina to efficiently manage work schedules, interacting with various tasks related to scheduling and organizing work-related events and meetings. 4 | 5 | ## Step 1: Import Google Calendar module 6 | 7 | Import the `ballerinax/googleapis.gcalendar` module. 8 | 9 | ```ballerina 10 | import ballerinax/googleapis.gcalendar; 11 | ``` 12 | 13 | ## Step 2: Create a new connector instance 14 | 15 | Create a `gcalendar:ConnectionConfig` with the obtained OAuth 2.0 tokens, and initialize the connector with it. 16 | 17 | ```ballerina 18 | gcalendar:ConnectionConfig config = { 19 | auth: { 20 | clientId: , 21 | clientSecret: 22 | refreshToken: , 23 | refreshUrl: , 24 | } 25 | }; 26 | 27 | gcalendar:Client calendar = check new(config); 28 | ``` 29 | 30 | Now, the `gcalendar:Client` instance can be used for the following steps. 31 | 32 | ### Creating a work calendar 33 | 34 | Create a dedicated calendar to organize work events. 35 | 36 | ```ballerina 37 | gcalendar:Calendar calendarResult = check calendar->/calendars.post({ 38 | summary: "Work Schedule" 39 | }); 40 | ``` 41 | 42 | ### Scheduling work events 43 | 44 | Schedule work-related events, meetings, and deadlines by specifying the event's title, date, time, and time zone, as well as any other relevant details. 45 | 46 | ```ballerina 47 | gcalendar:Event event = check calendar->/calendars/[calendarId]/events.post({ 48 | 'start: { 49 | dateTime: "2023-10-19T09:00:00+05:30", 50 | timeZone: "Asia/Colombo" 51 | }, 52 | end: { 53 | dateTime: "2023-10-19T09:30:00+05:30", 54 | timeZone: "Asia/Colombo" 55 | }, 56 | summary: "Project Kickoff Meeting" 57 | }); 58 | ``` 59 | 60 | ### Managing invitations and notifications 61 | 62 | Invite attendees by email, sending out invitations and notifications to ensure that all participants receive the necessary information. 63 | 64 | ```ballerina 65 | gcalendar:Event updatedEvent = check calendar->/calendars/[calendarId]/events/[eventId].put({ 66 | 'start: { 67 | dateTime: "2023-10-19T09:00:00+05:30", 68 | timeZone: "Asia/Colombo" 69 | }, 70 | end: { 71 | dateTime: "2023-10-19T09:30:00+05:30", 72 | timeZone: "Asia/Colombo" 73 | }, 74 | summary: "Team Meeting", 75 | location: "Conference Room", 76 | description: "Weekly team meeting to discuss project status.", 77 | attendees: [ 78 | { 79 | "email": "team-member1@gmail.com" 80 | }, 81 | { 82 | "email": "team-member2@gmail.com" 83 | } 84 | ] 85 | }); 86 | ``` 87 | 88 | ### Setting recurrence and reminders 89 | 90 | Schdule weekly team meetings as recurring events, setting reminders to ensure all team members receive timely notifications before each meeting. 91 | 92 | ```ballerina 93 | gcalendar:Event|error reminderEvent = calendar->/calendars/[calendarId]/events/[updatedEventId].put({ 94 | 'start: { 95 | dateTime: "2023-10-19T03:00:00+05:30", 96 | timeZone: "Asia/Colombo" 97 | }, 98 | end: { 99 | dateTime: "2023-10-19T03:30:00+05:30", 100 | timeZone: "Asia/Colombo" 101 | }, 102 | reminders: { 103 | useDefault: false, 104 | overrides: [ 105 | { 106 | method: "popup", 107 | minutes: 15 108 | }, 109 | { 110 | method: "email", 111 | minutes: 30 112 | } 113 | ] 114 | } 115 | }); 116 | ``` 117 | 118 | ### Sharing with team 119 | 120 | The work calendar can be shared among project team members to facilitate efficient collaboration. Permissions, such as read-only or edit access, can be assigned to ensure the team is aware of the work schedule and can coordinate their activities. 121 | 122 | ```ballerina 123 | gcalendar:AclRule acl = check calendar->/calendars/[calendarId]/acl.post({ 124 | scope: { 125 | 'type: "user", 126 | value: "team_member@gmail.com" 127 | }, 128 | role: "reader" 129 | }); 130 | ``` 131 | 132 | ### Access control 133 | 134 | Limit access to specific events or assign different permissions to various users. 135 | 136 | ```ballerina 137 | gcalendar:AclRule|error response = calendar->/calendars/[calendarId]/acl/[aclId].put({ 138 | scope: { 139 | 'type: "user", 140 | value: "team_member@gmail.com" 141 | }, 142 | role: "writer" 143 | }); 144 | ``` 145 | -------------------------------------------------------------------------------- /ballerina/README.md: -------------------------------------------------------------------------------- 1 | ## Package overview 2 | 3 | The Ballerina Google Calendar Connector provides the capability to manage events and calendar operations. It also provides the capability to support service account authorization that can provide delegated domain-wide access to the GSuite domain and support admins to do operations on behalf of the domain users. 4 | 5 | The Ballerina Google Calendar module supports [Google Calendar API V3](https://developers.google.com/calendar/api). 6 | 7 | ## Setup guide 8 | 9 | To utilize the Calendar connector, you must have access to the Calendar REST API through a [Google Cloud Platform (GCP)](https://console.cloud.google.com/) account and a project under it. If you do not have a GCP account, you can sign up for one [here](https://cloud.google.com/). 10 | 11 | ### Step 1: Create a Google Cloud Platform project 12 | 13 | In order to use the Google Calendar connector, you need to first create the Calendar credentials for the connector to interact with Calendar. 14 | 15 | 1. Open the [Google Cloud Platform console](https://console.cloud.google.com/). 16 | 17 | 2. Click on the project drop-down menu and either select an existing project or create a new one for which you want to add an API key. 18 | 19 | ![GCP Console](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/main/ballerina/resources/gcp-console-project-view.png) 20 | 21 | ### Step 2: Enable Calendar API 22 | 23 | 1. Navigate to the **Library** and enable the Calendar API. 24 | 25 | ![Enable Calendar API](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/main/ballerina/resources/enable-calendar-api.png) 26 | 27 | ### Step 3: Configure OAuth consent 28 | 29 | 1. Click on the **OAuth consent screen** tab in the Google Cloud Platform console. 30 | 31 | ![Consent Screen](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/main/ballerina/resources/consent-screen.png) 32 | 33 | 2. Provide a name for the consent application and save your changes. 34 | 35 | ### Step 4: Create OAuth client 36 | 37 | 1. Navigate to the **Credentials** tab in your Google Cloud Platform console. 38 | 39 | 2. Click **Create credentials** and from the dropdown menu, select **OAuth client ID**. 40 | 41 | ![Create Credentials](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/main/ballerina/resources/create-credentials.png) 42 | 43 | 3. You will be directed to the **OAuth consent** screen, in which you need to fill in the necessary information below. 44 | 45 | | Field | Value | 46 | | ------------------------- | ----- | 47 | | Application type | Web Application | 48 | | Name | CalendarConnector | 49 | | Authorized redirect URIs | | 50 | 51 | 4. After filling in these details, click **Create**. 52 | 53 | 5. Make sure to save the provided Client ID and Client secret. 54 | 55 | ### Step 5: Get the access and refresh tokens 56 | 57 | **Note**: It is recommended to use the [OAuth 2.0 playground](https://developers.google.com/oauthplayground) to obtain the tokens. 58 | 59 | 1. Configure the OAuth playground with the OAuth client ID and client secret. 60 | 61 | ![OAuth Playground](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/main/ballerina/resources/oauth-playground.png) 62 | 63 | 2. Authorize the Calendar APIs. 64 | 65 | ![Authorize APIs](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/main/ballerina/resources/authorize-calendar-apis.png) 66 | 67 | 3. Exchange the authorization code for tokens. 68 | 69 | ![Exchange Tokens](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-googleapis.calendar/main/ballerina/resources/exchange-tokens.png) 70 | 71 | ## Quickstart 72 | 73 | To use the Google Calendar connector in your Ballerina project, modify the `.bal` file as follows: 74 | 75 | ### Step 1: Import the module 76 | 77 | Import the `ballerinax/googleapis.gcalendar` module. 78 | 79 | ```ballerina 80 | import ballerinax/googleapis.gcalendar; 81 | ``` 82 | 83 | ### Step 2: Instantiate a new connector 84 | 85 | Create a `gcalendar:ConnectionConfig` with the obtained OAuth2.0 tokens and initialize the connector with it. 86 | 87 | ```ballerina 88 | configurable string clientId = ?; 89 | configurable string clientSecret = ?; 90 | configurable string refreshToken = ?; 91 | configurable string refreshUrl = ?; 92 | 93 | gcalendar:Client calendar = check new ({ 94 | auth: { 95 | clientId, 96 | clientSecret, 97 | refreshToken, 98 | refreshUrl 99 | } 100 | }); 101 | ``` 102 | 103 | ### Step 3: Invoke the connector operation 104 | 105 | You can now utilize the operations available within the connector. 106 | 107 | ```ballerina 108 | public function main() returns error? { 109 | gcalendar:Client calendar = ...// 110 | 111 | // create a calendar 112 | gcalendar:Calendar calendar = check calendar->/calendars.post({ 113 | summary: "Work Schedule" 114 | }); 115 | 116 | // quick add new event 117 | string eventTitle = "Sample Event"; 118 | gcalendar:Event event = check calendar->/calendars/[calendarId]/events/quickAdd.post(eventTitle); 119 | } 120 | ``` 121 | 122 | ### Step 4: Run the Ballerina application 123 | 124 | Use the following command to compile and run the Ballerina program. 125 | 126 | ```bash 127 | bal run 128 | ``` 129 | 130 | ## Examples 131 | 132 | The Google Calendar connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar/tree/main/examples), covering use cases like creating calendar, scheduling meeting events, and adding reminders. 133 | 134 | 1. [Project management with Calendar API](https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar/tree/main/examples/project-management-with-calendar) 135 | This example shows how to use Google Calendar APIs to efficiently manage work schedule of a person. It interacts with the API for various tasks related to scheduling and organizing work-related events and meetings. 136 | 2. [Work schedule management with Calendar API](https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar/tree/main/examples/work-schedule-management-with-calendar) 137 | This example shows how to use Google Calendar APIs to managing personal project schedule and collaborating with team members. 138 | 139 | For comprehensive information about the connector's functionality, configuration, and usage in Ballerina programs, refer to the Google Calendar connector's reference guide in [Ballerina Central](https://central.ballerina.io/ballerinax/googleapis.calendar/latest). 140 | -------------------------------------------------------------------------------- /examples/work-schedule-management-with-calendar/Dependencies.toml: -------------------------------------------------------------------------------- 1 | # AUTO-GENERATED FILE. DO NOT MODIFY. 2 | 3 | # This file is auto-generated by Ballerina for managing dependency versions. 4 | # It should not be modified by hand. 5 | 6 | [ballerina] 7 | dependencies-toml-version = "2" 8 | distribution-version = "2201.10.0" 9 | 10 | [[package]] 11 | org = "ballerina" 12 | name = "auth" 13 | version = "2.12.0" 14 | dependencies = [ 15 | {org = "ballerina", name = "crypto"}, 16 | {org = "ballerina", name = "jballerina.java"}, 17 | {org = "ballerina", name = "lang.array"}, 18 | {org = "ballerina", name = "lang.string"}, 19 | {org = "ballerina", name = "log"} 20 | ] 21 | 22 | [[package]] 23 | org = "ballerina" 24 | name = "cache" 25 | version = "3.8.0" 26 | dependencies = [ 27 | {org = "ballerina", name = "constraint"}, 28 | {org = "ballerina", name = "jballerina.java"}, 29 | {org = "ballerina", name = "task"}, 30 | {org = "ballerina", name = "time"} 31 | ] 32 | 33 | [[package]] 34 | org = "ballerina" 35 | name = "constraint" 36 | version = "1.5.0" 37 | dependencies = [ 38 | {org = "ballerina", name = "jballerina.java"} 39 | ] 40 | 41 | [[package]] 42 | org = "ballerina" 43 | name = "crypto" 44 | version = "2.7.2" 45 | dependencies = [ 46 | {org = "ballerina", name = "jballerina.java"}, 47 | {org = "ballerina", name = "time"} 48 | ] 49 | 50 | [[package]] 51 | org = "ballerina" 52 | name = "file" 53 | version = "1.10.0" 54 | dependencies = [ 55 | {org = "ballerina", name = "io"}, 56 | {org = "ballerina", name = "jballerina.java"}, 57 | {org = "ballerina", name = "os"}, 58 | {org = "ballerina", name = "time"} 59 | ] 60 | 61 | [[package]] 62 | org = "ballerina" 63 | name = "http" 64 | version = "2.12.2" 65 | dependencies = [ 66 | {org = "ballerina", name = "auth"}, 67 | {org = "ballerina", name = "cache"}, 68 | {org = "ballerina", name = "constraint"}, 69 | {org = "ballerina", name = "crypto"}, 70 | {org = "ballerina", name = "file"}, 71 | {org = "ballerina", name = "io"}, 72 | {org = "ballerina", name = "jballerina.java"}, 73 | {org = "ballerina", name = "jwt"}, 74 | {org = "ballerina", name = "lang.array"}, 75 | {org = "ballerina", name = "lang.decimal"}, 76 | {org = "ballerina", name = "lang.int"}, 77 | {org = "ballerina", name = "lang.regexp"}, 78 | {org = "ballerina", name = "lang.runtime"}, 79 | {org = "ballerina", name = "lang.string"}, 80 | {org = "ballerina", name = "lang.value"}, 81 | {org = "ballerina", name = "log"}, 82 | {org = "ballerina", name = "mime"}, 83 | {org = "ballerina", name = "oauth2"}, 84 | {org = "ballerina", name = "observe"}, 85 | {org = "ballerina", name = "time"}, 86 | {org = "ballerina", name = "url"} 87 | ] 88 | 89 | [[package]] 90 | org = "ballerina" 91 | name = "io" 92 | version = "1.6.1" 93 | dependencies = [ 94 | {org = "ballerina", name = "jballerina.java"}, 95 | {org = "ballerina", name = "lang.value"} 96 | ] 97 | 98 | [[package]] 99 | org = "ballerina" 100 | name = "jballerina.java" 101 | version = "0.0.0" 102 | 103 | [[package]] 104 | org = "ballerina" 105 | name = "jwt" 106 | version = "2.13.0" 107 | dependencies = [ 108 | {org = "ballerina", name = "cache"}, 109 | {org = "ballerina", name = "crypto"}, 110 | {org = "ballerina", name = "io"}, 111 | {org = "ballerina", name = "jballerina.java"}, 112 | {org = "ballerina", name = "lang.int"}, 113 | {org = "ballerina", name = "lang.string"}, 114 | {org = "ballerina", name = "log"}, 115 | {org = "ballerina", name = "time"} 116 | ] 117 | 118 | [[package]] 119 | org = "ballerina" 120 | name = "lang.__internal" 121 | version = "0.0.0" 122 | dependencies = [ 123 | {org = "ballerina", name = "jballerina.java"}, 124 | {org = "ballerina", name = "lang.object"} 125 | ] 126 | 127 | [[package]] 128 | org = "ballerina" 129 | name = "lang.array" 130 | version = "0.0.0" 131 | dependencies = [ 132 | {org = "ballerina", name = "jballerina.java"}, 133 | {org = "ballerina", name = "lang.__internal"} 134 | ] 135 | 136 | [[package]] 137 | org = "ballerina" 138 | name = "lang.decimal" 139 | version = "0.0.0" 140 | dependencies = [ 141 | {org = "ballerina", name = "jballerina.java"} 142 | ] 143 | 144 | [[package]] 145 | org = "ballerina" 146 | name = "lang.int" 147 | version = "0.0.0" 148 | dependencies = [ 149 | {org = "ballerina", name = "jballerina.java"}, 150 | {org = "ballerina", name = "lang.__internal"}, 151 | {org = "ballerina", name = "lang.object"} 152 | ] 153 | 154 | [[package]] 155 | org = "ballerina" 156 | name = "lang.object" 157 | version = "0.0.0" 158 | 159 | [[package]] 160 | org = "ballerina" 161 | name = "lang.regexp" 162 | version = "0.0.0" 163 | dependencies = [ 164 | {org = "ballerina", name = "jballerina.java"} 165 | ] 166 | 167 | [[package]] 168 | org = "ballerina" 169 | name = "lang.runtime" 170 | version = "0.0.0" 171 | dependencies = [ 172 | {org = "ballerina", name = "jballerina.java"} 173 | ] 174 | 175 | [[package]] 176 | org = "ballerina" 177 | name = "lang.string" 178 | version = "0.0.0" 179 | dependencies = [ 180 | {org = "ballerina", name = "jballerina.java"}, 181 | {org = "ballerina", name = "lang.regexp"} 182 | ] 183 | 184 | [[package]] 185 | org = "ballerina" 186 | name = "lang.value" 187 | version = "0.0.0" 188 | dependencies = [ 189 | {org = "ballerina", name = "jballerina.java"} 190 | ] 191 | 192 | [[package]] 193 | org = "ballerina" 194 | name = "log" 195 | version = "2.10.0" 196 | dependencies = [ 197 | {org = "ballerina", name = "io"}, 198 | {org = "ballerina", name = "jballerina.java"}, 199 | {org = "ballerina", name = "lang.value"}, 200 | {org = "ballerina", name = "observe"} 201 | ] 202 | modules = [ 203 | {org = "ballerina", packageName = "log", moduleName = "log"} 204 | ] 205 | 206 | [[package]] 207 | org = "ballerina" 208 | name = "mime" 209 | version = "2.10.1" 210 | dependencies = [ 211 | {org = "ballerina", name = "io"}, 212 | {org = "ballerina", name = "jballerina.java"}, 213 | {org = "ballerina", name = "lang.int"}, 214 | {org = "ballerina", name = "log"} 215 | ] 216 | 217 | [[package]] 218 | org = "ballerina" 219 | name = "oauth2" 220 | version = "2.12.0" 221 | dependencies = [ 222 | {org = "ballerina", name = "cache"}, 223 | {org = "ballerina", name = "crypto"}, 224 | {org = "ballerina", name = "jballerina.java"}, 225 | {org = "ballerina", name = "log"}, 226 | {org = "ballerina", name = "time"}, 227 | {org = "ballerina", name = "url"} 228 | ] 229 | 230 | [[package]] 231 | org = "ballerina" 232 | name = "observe" 233 | version = "1.3.0" 234 | dependencies = [ 235 | {org = "ballerina", name = "jballerina.java"} 236 | ] 237 | 238 | [[package]] 239 | org = "ballerina" 240 | name = "os" 241 | version = "1.8.0" 242 | dependencies = [ 243 | {org = "ballerina", name = "io"}, 244 | {org = "ballerina", name = "jballerina.java"} 245 | ] 246 | modules = [ 247 | {org = "ballerina", packageName = "os", moduleName = "os"} 248 | ] 249 | 250 | [[package]] 251 | org = "ballerina" 252 | name = "task" 253 | version = "2.5.0" 254 | dependencies = [ 255 | {org = "ballerina", name = "jballerina.java"}, 256 | {org = "ballerina", name = "time"} 257 | ] 258 | 259 | [[package]] 260 | org = "ballerina" 261 | name = "time" 262 | version = "2.5.0" 263 | dependencies = [ 264 | {org = "ballerina", name = "jballerina.java"} 265 | ] 266 | 267 | [[package]] 268 | org = "ballerina" 269 | name = "url" 270 | version = "2.4.0" 271 | dependencies = [ 272 | {org = "ballerina", name = "jballerina.java"} 273 | ] 274 | 275 | [[package]] 276 | org = "ballerina" 277 | name = "work_schedule" 278 | version = "0.1.0" 279 | dependencies = [ 280 | {org = "ballerina", name = "log"}, 281 | {org = "ballerina", name = "os"}, 282 | {org = "ballerinax", name = "googleapis.gcalendar"} 283 | ] 284 | modules = [ 285 | {org = "ballerina", packageName = "work_schedule", moduleName = "work_schedule"} 286 | ] 287 | 288 | [[package]] 289 | org = "ballerinai" 290 | name = "observe" 291 | version = "0.0.0" 292 | dependencies = [ 293 | {org = "ballerina", name = "jballerina.java"}, 294 | {org = "ballerina", name = "observe"} 295 | ] 296 | 297 | [[package]] 298 | org = "ballerinax" 299 | name = "googleapis.gcalendar" 300 | version = "4.0.2" 301 | dependencies = [ 302 | {org = "ballerina", name = "constraint"}, 303 | {org = "ballerina", name = "http"}, 304 | {org = "ballerina", name = "log"}, 305 | {org = "ballerina", name = "os"}, 306 | {org = "ballerina", name = "url"}, 307 | {org = "ballerinai", name = "observe"} 308 | ] 309 | modules = [ 310 | {org = "ballerinax", packageName = "googleapis.gcalendar", moduleName = "googleapis.gcalendar"}, 311 | {org = "ballerinax", packageName = "googleapis.gcalendar", moduleName = "googleapis.gcalendar.mock"}, 312 | {org = "ballerinax", packageName = "googleapis.gcalendar", moduleName = "googleapis.gcalendar.oas"} 313 | ] 314 | 315 | -------------------------------------------------------------------------------- /examples/project-management-with-calendar/Dependencies.toml: -------------------------------------------------------------------------------- 1 | # AUTO-GENERATED FILE. DO NOT MODIFY. 2 | 3 | # This file is auto-generated by Ballerina for managing dependency versions. 4 | # It should not be modified by hand. 5 | 6 | [ballerina] 7 | dependencies-toml-version = "2" 8 | distribution-version = "2201.10.0" 9 | 10 | [[package]] 11 | org = "ballerina" 12 | name = "auth" 13 | version = "2.12.0" 14 | dependencies = [ 15 | {org = "ballerina", name = "crypto"}, 16 | {org = "ballerina", name = "jballerina.java"}, 17 | {org = "ballerina", name = "lang.array"}, 18 | {org = "ballerina", name = "lang.string"}, 19 | {org = "ballerina", name = "log"} 20 | ] 21 | 22 | [[package]] 23 | org = "ballerina" 24 | name = "cache" 25 | version = "3.8.0" 26 | dependencies = [ 27 | {org = "ballerina", name = "constraint"}, 28 | {org = "ballerina", name = "jballerina.java"}, 29 | {org = "ballerina", name = "task"}, 30 | {org = "ballerina", name = "time"} 31 | ] 32 | 33 | [[package]] 34 | org = "ballerina" 35 | name = "constraint" 36 | version = "1.5.0" 37 | dependencies = [ 38 | {org = "ballerina", name = "jballerina.java"} 39 | ] 40 | 41 | [[package]] 42 | org = "ballerina" 43 | name = "crypto" 44 | version = "2.7.2" 45 | dependencies = [ 46 | {org = "ballerina", name = "jballerina.java"}, 47 | {org = "ballerina", name = "time"} 48 | ] 49 | 50 | [[package]] 51 | org = "ballerina" 52 | name = "file" 53 | version = "1.10.0" 54 | dependencies = [ 55 | {org = "ballerina", name = "io"}, 56 | {org = "ballerina", name = "jballerina.java"}, 57 | {org = "ballerina", name = "os"}, 58 | {org = "ballerina", name = "time"} 59 | ] 60 | 61 | [[package]] 62 | org = "ballerina" 63 | name = "http" 64 | version = "2.12.2" 65 | dependencies = [ 66 | {org = "ballerina", name = "auth"}, 67 | {org = "ballerina", name = "cache"}, 68 | {org = "ballerina", name = "constraint"}, 69 | {org = "ballerina", name = "crypto"}, 70 | {org = "ballerina", name = "file"}, 71 | {org = "ballerina", name = "io"}, 72 | {org = "ballerina", name = "jballerina.java"}, 73 | {org = "ballerina", name = "jwt"}, 74 | {org = "ballerina", name = "lang.array"}, 75 | {org = "ballerina", name = "lang.decimal"}, 76 | {org = "ballerina", name = "lang.int"}, 77 | {org = "ballerina", name = "lang.regexp"}, 78 | {org = "ballerina", name = "lang.runtime"}, 79 | {org = "ballerina", name = "lang.string"}, 80 | {org = "ballerina", name = "lang.value"}, 81 | {org = "ballerina", name = "log"}, 82 | {org = "ballerina", name = "mime"}, 83 | {org = "ballerina", name = "oauth2"}, 84 | {org = "ballerina", name = "observe"}, 85 | {org = "ballerina", name = "time"}, 86 | {org = "ballerina", name = "url"} 87 | ] 88 | 89 | [[package]] 90 | org = "ballerina" 91 | name = "io" 92 | version = "1.6.1" 93 | dependencies = [ 94 | {org = "ballerina", name = "jballerina.java"}, 95 | {org = "ballerina", name = "lang.value"} 96 | ] 97 | 98 | [[package]] 99 | org = "ballerina" 100 | name = "jballerina.java" 101 | version = "0.0.0" 102 | 103 | [[package]] 104 | org = "ballerina" 105 | name = "jwt" 106 | version = "2.13.0" 107 | dependencies = [ 108 | {org = "ballerina", name = "cache"}, 109 | {org = "ballerina", name = "crypto"}, 110 | {org = "ballerina", name = "io"}, 111 | {org = "ballerina", name = "jballerina.java"}, 112 | {org = "ballerina", name = "lang.int"}, 113 | {org = "ballerina", name = "lang.string"}, 114 | {org = "ballerina", name = "log"}, 115 | {org = "ballerina", name = "time"} 116 | ] 117 | 118 | [[package]] 119 | org = "ballerina" 120 | name = "lang.__internal" 121 | version = "0.0.0" 122 | dependencies = [ 123 | {org = "ballerina", name = "jballerina.java"}, 124 | {org = "ballerina", name = "lang.object"} 125 | ] 126 | 127 | [[package]] 128 | org = "ballerina" 129 | name = "lang.array" 130 | version = "0.0.0" 131 | dependencies = [ 132 | {org = "ballerina", name = "jballerina.java"}, 133 | {org = "ballerina", name = "lang.__internal"} 134 | ] 135 | 136 | [[package]] 137 | org = "ballerina" 138 | name = "lang.decimal" 139 | version = "0.0.0" 140 | dependencies = [ 141 | {org = "ballerina", name = "jballerina.java"} 142 | ] 143 | 144 | [[package]] 145 | org = "ballerina" 146 | name = "lang.int" 147 | version = "0.0.0" 148 | dependencies = [ 149 | {org = "ballerina", name = "jballerina.java"}, 150 | {org = "ballerina", name = "lang.__internal"}, 151 | {org = "ballerina", name = "lang.object"} 152 | ] 153 | 154 | [[package]] 155 | org = "ballerina" 156 | name = "lang.object" 157 | version = "0.0.0" 158 | 159 | [[package]] 160 | org = "ballerina" 161 | name = "lang.regexp" 162 | version = "0.0.0" 163 | dependencies = [ 164 | {org = "ballerina", name = "jballerina.java"} 165 | ] 166 | 167 | [[package]] 168 | org = "ballerina" 169 | name = "lang.runtime" 170 | version = "0.0.0" 171 | dependencies = [ 172 | {org = "ballerina", name = "jballerina.java"} 173 | ] 174 | 175 | [[package]] 176 | org = "ballerina" 177 | name = "lang.string" 178 | version = "0.0.0" 179 | dependencies = [ 180 | {org = "ballerina", name = "jballerina.java"}, 181 | {org = "ballerina", name = "lang.regexp"} 182 | ] 183 | 184 | [[package]] 185 | org = "ballerina" 186 | name = "lang.value" 187 | version = "0.0.0" 188 | dependencies = [ 189 | {org = "ballerina", name = "jballerina.java"} 190 | ] 191 | 192 | [[package]] 193 | org = "ballerina" 194 | name = "log" 195 | version = "2.10.0" 196 | dependencies = [ 197 | {org = "ballerina", name = "io"}, 198 | {org = "ballerina", name = "jballerina.java"}, 199 | {org = "ballerina", name = "lang.value"}, 200 | {org = "ballerina", name = "observe"} 201 | ] 202 | modules = [ 203 | {org = "ballerina", packageName = "log", moduleName = "log"} 204 | ] 205 | 206 | [[package]] 207 | org = "ballerina" 208 | name = "mime" 209 | version = "2.10.1" 210 | dependencies = [ 211 | {org = "ballerina", name = "io"}, 212 | {org = "ballerina", name = "jballerina.java"}, 213 | {org = "ballerina", name = "lang.int"}, 214 | {org = "ballerina", name = "log"} 215 | ] 216 | 217 | [[package]] 218 | org = "ballerina" 219 | name = "oauth2" 220 | version = "2.12.0" 221 | dependencies = [ 222 | {org = "ballerina", name = "cache"}, 223 | {org = "ballerina", name = "crypto"}, 224 | {org = "ballerina", name = "jballerina.java"}, 225 | {org = "ballerina", name = "log"}, 226 | {org = "ballerina", name = "time"}, 227 | {org = "ballerina", name = "url"} 228 | ] 229 | 230 | [[package]] 231 | org = "ballerina" 232 | name = "observe" 233 | version = "1.3.0" 234 | dependencies = [ 235 | {org = "ballerina", name = "jballerina.java"} 236 | ] 237 | 238 | [[package]] 239 | org = "ballerina" 240 | name = "os" 241 | version = "1.8.0" 242 | dependencies = [ 243 | {org = "ballerina", name = "io"}, 244 | {org = "ballerina", name = "jballerina.java"} 245 | ] 246 | modules = [ 247 | {org = "ballerina", packageName = "os", moduleName = "os"} 248 | ] 249 | 250 | [[package]] 251 | org = "ballerina" 252 | name = "project_management" 253 | version = "0.1.0" 254 | dependencies = [ 255 | {org = "ballerina", name = "log"}, 256 | {org = "ballerina", name = "os"}, 257 | {org = "ballerinax", name = "googleapis.gcalendar"} 258 | ] 259 | modules = [ 260 | {org = "ballerina", packageName = "project_management", moduleName = "project_management"} 261 | ] 262 | 263 | [[package]] 264 | org = "ballerina" 265 | name = "task" 266 | version = "2.5.0" 267 | dependencies = [ 268 | {org = "ballerina", name = "jballerina.java"}, 269 | {org = "ballerina", name = "time"} 270 | ] 271 | 272 | [[package]] 273 | org = "ballerina" 274 | name = "time" 275 | version = "2.5.0" 276 | dependencies = [ 277 | {org = "ballerina", name = "jballerina.java"} 278 | ] 279 | 280 | [[package]] 281 | org = "ballerina" 282 | name = "url" 283 | version = "2.4.0" 284 | dependencies = [ 285 | {org = "ballerina", name = "jballerina.java"} 286 | ] 287 | 288 | [[package]] 289 | org = "ballerinai" 290 | name = "observe" 291 | version = "0.0.0" 292 | dependencies = [ 293 | {org = "ballerina", name = "jballerina.java"}, 294 | {org = "ballerina", name = "observe"} 295 | ] 296 | 297 | [[package]] 298 | org = "ballerinax" 299 | name = "googleapis.gcalendar" 300 | version = "4.0.2" 301 | dependencies = [ 302 | {org = "ballerina", name = "constraint"}, 303 | {org = "ballerina", name = "http"}, 304 | {org = "ballerina", name = "log"}, 305 | {org = "ballerina", name = "os"}, 306 | {org = "ballerina", name = "url"}, 307 | {org = "ballerinai", name = "observe"} 308 | ] 309 | modules = [ 310 | {org = "ballerinax", packageName = "googleapis.gcalendar", moduleName = "googleapis.gcalendar"}, 311 | {org = "ballerinax", packageName = "googleapis.gcalendar", moduleName = "googleapis.gcalendar.mock"}, 312 | {org = "ballerinax", packageName = "googleapis.gcalendar", moduleName = "googleapis.gcalendar.oas"} 313 | ] 314 | 315 | -------------------------------------------------------------------------------- /ballerina/utils.bal: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com). 2 | // 3 | // WSO2 LLC. licenses this file to you under the Apache License, 4 | // Version 2.0 (the "License"); you may not use this file except 5 | // in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, 11 | // software distributed under the License is distributed on an 12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | // KIND, either express or implied. See the License for the 14 | // specific language governing permissions and limitations 15 | // under the License. 16 | 17 | import ballerina/http; 18 | import ballerina/url; 19 | 20 | type SimpleBasicType string|boolean|int|float|decimal; 21 | 22 | # Represents encoding mechanism details. 23 | type Encoding record { 24 | # Defines how multiple values are delimited 25 | string style = FORM; 26 | # Specifies whether arrays and objects should generate as separate fields 27 | boolean explode = true; 28 | # Specifies the custom content type 29 | string contentType?; 30 | # Specifies the custom headers 31 | map headers?; 32 | }; 33 | 34 | enum EncodingStyle { 35 | DEEPOBJECT, FORM, SPACEDELIMITED, PIPEDELIMITED 36 | } 37 | 38 | final Encoding & readonly defaultEncoding = {}; 39 | 40 | # Serialize the record according to the deepObject style. 41 | # 42 | # + parent - Parent record name 43 | # + anyRecord - Record to be serialized 44 | # + return - Serialized record as a string 45 | isolated function getDeepObjectStyleRequest(string parent, record {} anyRecord) returns string { 46 | string[] recordArray = []; 47 | foreach [string, anydata] [key, value] in anyRecord.entries() { 48 | if value is SimpleBasicType { 49 | recordArray.push(parent + "[" + key + "]" + "=" + getEncodedUri(value.toString())); 50 | } else if value is SimpleBasicType[] { 51 | recordArray.push(getSerializedArray(parent + "[" + key + "]" + "[]", value, DEEPOBJECT, true)); 52 | } else if value is record {} { 53 | string nextParent = parent + "[" + key + "]"; 54 | recordArray.push(getDeepObjectStyleRequest(nextParent, value)); 55 | } else if value is record {}[] { 56 | string nextParent = parent + "[" + key + "]"; 57 | recordArray.push(getSerializedRecordArray(nextParent, value, DEEPOBJECT)); 58 | } 59 | recordArray.push("&"); 60 | } 61 | _ = recordArray.pop(); 62 | return string:'join("", ...recordArray); 63 | } 64 | 65 | # Serialize the record according to the form style. 66 | # 67 | # + parent - Parent record name 68 | # + anyRecord - Record to be serialized 69 | # + explode - Specifies whether arrays and objects should generate separate parameters 70 | # + return - Serialized record as a string 71 | isolated function getFormStyleRequest(string parent, record {} anyRecord, boolean explode = true) returns string { 72 | string[] recordArray = []; 73 | if explode { 74 | foreach [string, anydata] [key, value] in anyRecord.entries() { 75 | if value is SimpleBasicType { 76 | recordArray.push(key, "=", getEncodedUri(value.toString())); 77 | } else if value is SimpleBasicType[] { 78 | recordArray.push(getSerializedArray(key, value, explode = explode)); 79 | } else if value is record {} { 80 | recordArray.push(getFormStyleRequest(parent, value, explode)); 81 | } 82 | recordArray.push("&"); 83 | } 84 | _ = recordArray.pop(); 85 | } else { 86 | foreach [string, anydata] [key, value] in anyRecord.entries() { 87 | if value is SimpleBasicType { 88 | recordArray.push(key, ",", getEncodedUri(value.toString())); 89 | } else if value is SimpleBasicType[] { 90 | recordArray.push(getSerializedArray(key, value, explode = false)); 91 | } else if value is record {} { 92 | recordArray.push(getFormStyleRequest(parent, value, explode)); 93 | } 94 | recordArray.push(","); 95 | } 96 | _ = recordArray.pop(); 97 | } 98 | return string:'join("", ...recordArray); 99 | } 100 | 101 | # Serialize arrays. 102 | # 103 | # + arrayName - Name of the field with arrays 104 | # + anyArray - Array to be serialized 105 | # + style - Defines how multiple values are delimited 106 | # + explode - Specifies whether arrays and objects should generate separate parameters 107 | # + return - Serialized array as a string 108 | isolated function getSerializedArray(string arrayName, anydata[] anyArray, string style = "form", boolean explode = true) returns string { 109 | string key = arrayName; 110 | string[] arrayValues = []; 111 | if anyArray.length() > 0 { 112 | if style == FORM && !explode { 113 | arrayValues.push(key, "="); 114 | foreach anydata i in anyArray { 115 | arrayValues.push(getEncodedUri(i.toString()), ","); 116 | } 117 | } else if style == SPACEDELIMITED && !explode { 118 | arrayValues.push(key, "="); 119 | foreach anydata i in anyArray { 120 | arrayValues.push(getEncodedUri(i.toString()), "%20"); 121 | } 122 | } else if style == PIPEDELIMITED && !explode { 123 | arrayValues.push(key, "="); 124 | foreach anydata i in anyArray { 125 | arrayValues.push(getEncodedUri(i.toString()), "|"); 126 | } 127 | } else if style == DEEPOBJECT { 128 | foreach anydata i in anyArray { 129 | arrayValues.push(key, "[]", "=", getEncodedUri(i.toString()), "&"); 130 | } 131 | } else { 132 | foreach anydata i in anyArray { 133 | arrayValues.push(key, "=", getEncodedUri(i.toString()), "&"); 134 | } 135 | } 136 | _ = arrayValues.pop(); 137 | } 138 | return string:'join("", ...arrayValues); 139 | } 140 | 141 | # Serialize the array of records according to the form style. 142 | # 143 | # + parent - Parent record name 144 | # + value - Array of records to be serialized 145 | # + style - Defines how multiple values are delimited 146 | # + explode - Specifies whether arrays and objects should generate separate parameters 147 | # + return - Serialized record as a string 148 | isolated function getSerializedRecordArray(string parent, record {}[] value, string style = FORM, boolean explode = true) returns string { 149 | string[] serializedArray = []; 150 | if style == DEEPOBJECT { 151 | int arayIndex = 0; 152 | foreach var recordItem in value { 153 | serializedArray.push(getDeepObjectStyleRequest(parent + "[" + arayIndex.toString() + "]", recordItem), "&"); 154 | arayIndex = arayIndex + 1; 155 | } 156 | } else { 157 | if !explode { 158 | serializedArray.push(parent, "="); 159 | } 160 | foreach var recordItem in value { 161 | serializedArray.push(getFormStyleRequest(parent, recordItem, explode), ","); 162 | } 163 | } 164 | _ = serializedArray.pop(); 165 | return string:'join("", ...serializedArray); 166 | } 167 | 168 | # Get Encoded URI for a given value. 169 | # 170 | # + value - Value to be encoded 171 | # + return - Encoded string 172 | isolated function getEncodedUri(anydata value) returns string { 173 | string|error encoded = url:encode(value.toString(), "UTF8"); 174 | if encoded is string { 175 | return encoded; 176 | } else { 177 | return value.toString(); 178 | } 179 | } 180 | 181 | # Generate query path with query parameter. 182 | # 183 | # + queryParam - Query parameter map 184 | # + encodingMap - Details on serialization mechanism 185 | # + return - Returns generated Path or error at failure of client initialization 186 | isolated function getPathForQueryParam(map queryParam, map encodingMap = {}) returns string|error { 187 | map queriesMap = http:getQueryMap(queryParam); 188 | string[] param = []; 189 | if queriesMap.length() > 0 { 190 | param.push("?"); 191 | foreach var [key, value] in queriesMap.entries() { 192 | if value is () { 193 | _ = queriesMap.remove(key); 194 | continue; 195 | } 196 | Encoding encodingData = encodingMap.hasKey(key) ? encodingMap.get(key) : defaultEncoding; 197 | if value is SimpleBasicType { 198 | param.push(key, "=", getEncodedUri(value.toString())); 199 | } else if value is SimpleBasicType[] { 200 | param.push(getSerializedArray(key, value, encodingData.style, encodingData.explode)); 201 | } else if value is record {} { 202 | if encodingData.style == DEEPOBJECT { 203 | param.push(getDeepObjectStyleRequest(key, value)); 204 | } else { 205 | param.push(getFormStyleRequest(key, value, encodingData.explode)); 206 | } 207 | } else { 208 | param.push(key, "=", value.toString()); 209 | } 210 | param.push("&"); 211 | } 212 | _ = param.pop(); 213 | } 214 | string restOfPath = string:'join("", ...param); 215 | return restOfPath; 216 | } 217 | -------------------------------------------------------------------------------- /ballerina/modules/oas/utils.bal: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. 2 | // 3 | // WSO2 LLC. licenses this file to you under the Apache License, 4 | // Version 2.0 (the "License"); you may not use this file except 5 | // in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, 11 | // software distributed under the License is distributed on an 12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | // KIND, either express or implied. See the License for the 14 | // specific language governing permissions and limitations 15 | // under the License. 16 | 17 | // AUTO-GENERATED FILE. DO NOT MODIFY. 18 | // This file is auto-generated by the Ballerina OpenAPI tool. 19 | 20 | import ballerina/url; 21 | 22 | type SimpleBasicType string|boolean|int|float|decimal; 23 | 24 | # Represents encoding mechanism details. 25 | type Encoding record { 26 | # Defines how multiple values are delimited 27 | string style = FORM; 28 | # Specifies whether arrays and objects should generate as separate fields 29 | boolean explode = true; 30 | # Specifies the custom content type 31 | string contentType?; 32 | # Specifies the custom headers 33 | map headers?; 34 | }; 35 | 36 | enum EncodingStyle { 37 | DEEPOBJECT, FORM, SPACEDELIMITED, PIPEDELIMITED 38 | } 39 | 40 | final Encoding & readonly defaultEncoding = {}; 41 | 42 | # Serialize the record according to the deepObject style. 43 | # 44 | # + parent - Parent record name 45 | # + anyRecord - Record to be serialized 46 | # + return - Serialized record as a string 47 | isolated function getDeepObjectStyleRequest(string parent, record {} anyRecord) returns string { 48 | string[] recordArray = []; 49 | foreach [string, anydata] [key, value] in anyRecord.entries() { 50 | if value is SimpleBasicType { 51 | recordArray.push(parent + "[" + key + "]" + "=" + getEncodedUri(value.toString())); 52 | } else if value is SimpleBasicType[] { 53 | recordArray.push(getSerializedArray(parent + "[" + key + "]" + "[]", value, DEEPOBJECT, true)); 54 | } else if value is record {} { 55 | string nextParent = parent + "[" + key + "]"; 56 | recordArray.push(getDeepObjectStyleRequest(nextParent, value)); 57 | } else if value is record {}[] { 58 | string nextParent = parent + "[" + key + "]"; 59 | recordArray.push(getSerializedRecordArray(nextParent, value, DEEPOBJECT)); 60 | } 61 | recordArray.push("&"); 62 | } 63 | _ = recordArray.pop(); 64 | return string:'join("", ...recordArray); 65 | } 66 | 67 | # Serialize the record according to the form style. 68 | # 69 | # + parent - Parent record name 70 | # + anyRecord - Record to be serialized 71 | # + explode - Specifies whether arrays and objects should generate separate parameters 72 | # + return - Serialized record as a string 73 | isolated function getFormStyleRequest(string parent, record {} anyRecord, boolean explode = true) returns string { 74 | string[] recordArray = []; 75 | if explode { 76 | foreach [string, anydata] [key, value] in anyRecord.entries() { 77 | if value is SimpleBasicType { 78 | recordArray.push(key, "=", getEncodedUri(value.toString())); 79 | } else if value is SimpleBasicType[] { 80 | recordArray.push(getSerializedArray(key, value, explode = explode)); 81 | } else if value is record {} { 82 | recordArray.push(getFormStyleRequest(parent, value, explode)); 83 | } 84 | recordArray.push("&"); 85 | } 86 | _ = recordArray.pop(); 87 | } else { 88 | foreach [string, anydata] [key, value] in anyRecord.entries() { 89 | if value is SimpleBasicType { 90 | recordArray.push(key, ",", getEncodedUri(value.toString())); 91 | } else if value is SimpleBasicType[] { 92 | recordArray.push(getSerializedArray(key, value, explode = false)); 93 | } else if value is record {} { 94 | recordArray.push(getFormStyleRequest(parent, value, explode)); 95 | } 96 | recordArray.push(","); 97 | } 98 | _ = recordArray.pop(); 99 | } 100 | return string:'join("", ...recordArray); 101 | } 102 | 103 | # Serialize arrays. 104 | # 105 | # + arrayName - Name of the field with arrays 106 | # + anyArray - Array to be serialized 107 | # + style - Defines how multiple values are delimited 108 | # + explode - Specifies whether arrays and objects should generate separate parameters 109 | # + return - Serialized array as a string 110 | isolated function getSerializedArray(string arrayName, anydata[] anyArray, string style = "form", boolean explode = true) returns string { 111 | string key = arrayName; 112 | string[] arrayValues = []; 113 | if anyArray.length() > 0 { 114 | if style == FORM && !explode { 115 | arrayValues.push(key, "="); 116 | foreach anydata i in anyArray { 117 | arrayValues.push(getEncodedUri(i.toString()), ","); 118 | } 119 | } else if style == SPACEDELIMITED && !explode { 120 | arrayValues.push(key, "="); 121 | foreach anydata i in anyArray { 122 | arrayValues.push(getEncodedUri(i.toString()), "%20"); 123 | } 124 | } else if style == PIPEDELIMITED && !explode { 125 | arrayValues.push(key, "="); 126 | foreach anydata i in anyArray { 127 | arrayValues.push(getEncodedUri(i.toString()), "|"); 128 | } 129 | } else if style == DEEPOBJECT { 130 | foreach anydata i in anyArray { 131 | arrayValues.push(key, "[]", "=", getEncodedUri(i.toString()), "&"); 132 | } 133 | } else { 134 | foreach anydata i in anyArray { 135 | arrayValues.push(key, "=", getEncodedUri(i.toString()), "&"); 136 | } 137 | } 138 | _ = arrayValues.pop(); 139 | } 140 | return string:'join("", ...arrayValues); 141 | } 142 | 143 | # Serialize the array of records according to the form style. 144 | # 145 | # + parent - Parent record name 146 | # + value - Array of records to be serialized 147 | # + style - Defines how multiple values are delimited 148 | # + explode - Specifies whether arrays and objects should generate separate parameters 149 | # + return - Serialized record as a string 150 | isolated function getSerializedRecordArray(string parent, record {}[] value, string style = FORM, boolean explode = true) returns string { 151 | string[] serializedArray = []; 152 | if style == DEEPOBJECT { 153 | int arayIndex = 0; 154 | foreach var recordItem in value { 155 | serializedArray.push(getDeepObjectStyleRequest(parent + "[" + arayIndex.toString() + "]", recordItem), "&"); 156 | arayIndex = arayIndex + 1; 157 | } 158 | } else { 159 | if !explode { 160 | serializedArray.push(parent, "="); 161 | } 162 | foreach var recordItem in value { 163 | serializedArray.push(getFormStyleRequest(parent, recordItem, explode), ","); 164 | } 165 | } 166 | _ = serializedArray.pop(); 167 | return string:'join("", ...serializedArray); 168 | } 169 | 170 | # Get Encoded URI for a given value. 171 | # 172 | # + value - Value to be encoded 173 | # + return - Encoded string 174 | isolated function getEncodedUri(anydata value) returns string { 175 | string|error encoded = url:encode(value.toString(), "UTF8"); 176 | if encoded is string { 177 | return encoded; 178 | } else { 179 | return value.toString(); 180 | } 181 | } 182 | 183 | # Generate query path with query parameter. 184 | # 185 | # + queryParam - Query parameter map 186 | # + encodingMap - Details on serialization mechanism 187 | # + return - Returns generated Path or error at failure of client initialization 188 | isolated function getPathForQueryParam(map queryParam, map encodingMap = {}) returns string|error { 189 | string[] param = []; 190 | if queryParam.length() > 0 { 191 | param.push("?"); 192 | foreach var [key, value] in queryParam.entries() { 193 | if value is () { 194 | _ = queryParam.remove(key); 195 | continue; 196 | } 197 | Encoding encodingData = encodingMap.hasKey(key) ? encodingMap.get(key) : defaultEncoding; 198 | if value is SimpleBasicType { 199 | param.push(key, "=", getEncodedUri(value.toString())); 200 | } else if value is SimpleBasicType[] { 201 | param.push(getSerializedArray(key, value, encodingData.style, encodingData.explode)); 202 | } else if value is record {} { 203 | if encodingData.style == DEEPOBJECT { 204 | param.push(getDeepObjectStyleRequest(key, value)); 205 | } else { 206 | param.push(getFormStyleRequest(key, value, encodingData.explode)); 207 | } 208 | } else { 209 | param.push(key, "=", value.toString()); 210 | } 211 | param.push("&"); 212 | } 213 | _ = param.pop(); 214 | } 215 | string restOfPath = string:'join("", ...param); 216 | return restOfPath; 217 | } 218 | -------------------------------------------------------------------------------- /ballerina/Dependencies.toml: -------------------------------------------------------------------------------- 1 | # AUTO-GENERATED FILE. DO NOT MODIFY. 2 | 3 | # This file is auto-generated by Ballerina for managing dependency versions. 4 | # It should not be modified by hand. 5 | 6 | [ballerina] 7 | dependencies-toml-version = "2" 8 | distribution-version = "2201.12.2" 9 | 10 | [[package]] 11 | org = "ballerina" 12 | name = "auth" 13 | version = "2.14.0" 14 | dependencies = [ 15 | {org = "ballerina", name = "crypto"}, 16 | {org = "ballerina", name = "jballerina.java"}, 17 | {org = "ballerina", name = "lang.array"}, 18 | {org = "ballerina", name = "lang.string"}, 19 | {org = "ballerina", name = "log"} 20 | ] 21 | 22 | [[package]] 23 | org = "ballerina" 24 | name = "cache" 25 | version = "3.10.0" 26 | dependencies = [ 27 | {org = "ballerina", name = "constraint"}, 28 | {org = "ballerina", name = "jballerina.java"}, 29 | {org = "ballerina", name = "task"}, 30 | {org = "ballerina", name = "time"} 31 | ] 32 | 33 | [[package]] 34 | org = "ballerina" 35 | name = "constraint" 36 | version = "1.7.0" 37 | dependencies = [ 38 | {org = "ballerina", name = "jballerina.java"} 39 | ] 40 | modules = [ 41 | {org = "ballerina", packageName = "constraint", moduleName = "constraint"} 42 | ] 43 | 44 | [[package]] 45 | org = "ballerina" 46 | name = "crypto" 47 | version = "2.9.0" 48 | dependencies = [ 49 | {org = "ballerina", name = "jballerina.java"}, 50 | {org = "ballerina", name = "time"} 51 | ] 52 | 53 | [[package]] 54 | org = "ballerina" 55 | name = "data.jsondata" 56 | version = "1.1.0" 57 | dependencies = [ 58 | {org = "ballerina", name = "jballerina.java"}, 59 | {org = "ballerina", name = "lang.object"} 60 | ] 61 | 62 | [[package]] 63 | org = "ballerina" 64 | name = "file" 65 | version = "1.12.0" 66 | dependencies = [ 67 | {org = "ballerina", name = "io"}, 68 | {org = "ballerina", name = "jballerina.java"}, 69 | {org = "ballerina", name = "os"}, 70 | {org = "ballerina", name = "time"} 71 | ] 72 | 73 | [[package]] 74 | org = "ballerina" 75 | name = "http" 76 | version = "2.14.0" 77 | dependencies = [ 78 | {org = "ballerina", name = "auth"}, 79 | {org = "ballerina", name = "cache"}, 80 | {org = "ballerina", name = "constraint"}, 81 | {org = "ballerina", name = "crypto"}, 82 | {org = "ballerina", name = "data.jsondata"}, 83 | {org = "ballerina", name = "file"}, 84 | {org = "ballerina", name = "io"}, 85 | {org = "ballerina", name = "jballerina.java"}, 86 | {org = "ballerina", name = "jwt"}, 87 | {org = "ballerina", name = "lang.array"}, 88 | {org = "ballerina", name = "lang.decimal"}, 89 | {org = "ballerina", name = "lang.int"}, 90 | {org = "ballerina", name = "lang.regexp"}, 91 | {org = "ballerina", name = "lang.runtime"}, 92 | {org = "ballerina", name = "lang.string"}, 93 | {org = "ballerina", name = "lang.value"}, 94 | {org = "ballerina", name = "log"}, 95 | {org = "ballerina", name = "mime"}, 96 | {org = "ballerina", name = "oauth2"}, 97 | {org = "ballerina", name = "observe"}, 98 | {org = "ballerina", name = "time"}, 99 | {org = "ballerina", name = "url"} 100 | ] 101 | modules = [ 102 | {org = "ballerina", packageName = "http", moduleName = "http"}, 103 | {org = "ballerina", packageName = "http", moduleName = "http.httpscerr"} 104 | ] 105 | 106 | [[package]] 107 | org = "ballerina" 108 | name = "io" 109 | version = "1.8.0" 110 | dependencies = [ 111 | {org = "ballerina", name = "jballerina.java"}, 112 | {org = "ballerina", name = "lang.value"} 113 | ] 114 | 115 | [[package]] 116 | org = "ballerina" 117 | name = "jballerina.java" 118 | version = "0.0.0" 119 | 120 | [[package]] 121 | org = "ballerina" 122 | name = "jwt" 123 | version = "2.15.0" 124 | dependencies = [ 125 | {org = "ballerina", name = "cache"}, 126 | {org = "ballerina", name = "crypto"}, 127 | {org = "ballerina", name = "io"}, 128 | {org = "ballerina", name = "jballerina.java"}, 129 | {org = "ballerina", name = "lang.int"}, 130 | {org = "ballerina", name = "lang.string"}, 131 | {org = "ballerina", name = "log"}, 132 | {org = "ballerina", name = "time"} 133 | ] 134 | 135 | [[package]] 136 | org = "ballerina" 137 | name = "lang.__internal" 138 | version = "0.0.0" 139 | dependencies = [ 140 | {org = "ballerina", name = "jballerina.java"}, 141 | {org = "ballerina", name = "lang.object"} 142 | ] 143 | 144 | [[package]] 145 | org = "ballerina" 146 | name = "lang.array" 147 | version = "0.0.0" 148 | dependencies = [ 149 | {org = "ballerina", name = "jballerina.java"}, 150 | {org = "ballerina", name = "lang.__internal"} 151 | ] 152 | 153 | [[package]] 154 | org = "ballerina" 155 | name = "lang.decimal" 156 | version = "0.0.0" 157 | dependencies = [ 158 | {org = "ballerina", name = "jballerina.java"} 159 | ] 160 | 161 | [[package]] 162 | org = "ballerina" 163 | name = "lang.error" 164 | version = "0.0.0" 165 | scope = "testOnly" 166 | dependencies = [ 167 | {org = "ballerina", name = "jballerina.java"} 168 | ] 169 | 170 | [[package]] 171 | org = "ballerina" 172 | name = "lang.int" 173 | version = "0.0.0" 174 | dependencies = [ 175 | {org = "ballerina", name = "jballerina.java"}, 176 | {org = "ballerina", name = "lang.__internal"}, 177 | {org = "ballerina", name = "lang.object"} 178 | ] 179 | 180 | [[package]] 181 | org = "ballerina" 182 | name = "lang.object" 183 | version = "0.0.0" 184 | 185 | [[package]] 186 | org = "ballerina" 187 | name = "lang.regexp" 188 | version = "0.0.0" 189 | dependencies = [ 190 | {org = "ballerina", name = "jballerina.java"} 191 | ] 192 | 193 | [[package]] 194 | org = "ballerina" 195 | name = "lang.runtime" 196 | version = "0.0.0" 197 | dependencies = [ 198 | {org = "ballerina", name = "jballerina.java"} 199 | ] 200 | 201 | [[package]] 202 | org = "ballerina" 203 | name = "lang.string" 204 | version = "0.0.0" 205 | dependencies = [ 206 | {org = "ballerina", name = "jballerina.java"}, 207 | {org = "ballerina", name = "lang.regexp"} 208 | ] 209 | 210 | [[package]] 211 | org = "ballerina" 212 | name = "lang.value" 213 | version = "0.0.0" 214 | dependencies = [ 215 | {org = "ballerina", name = "jballerina.java"} 216 | ] 217 | 218 | [[package]] 219 | org = "ballerina" 220 | name = "log" 221 | version = "2.12.0" 222 | dependencies = [ 223 | {org = "ballerina", name = "io"}, 224 | {org = "ballerina", name = "jballerina.java"}, 225 | {org = "ballerina", name = "lang.value"}, 226 | {org = "ballerina", name = "observe"} 227 | ] 228 | modules = [ 229 | {org = "ballerina", packageName = "log", moduleName = "log"} 230 | ] 231 | 232 | [[package]] 233 | org = "ballerina" 234 | name = "mime" 235 | version = "2.12.0" 236 | dependencies = [ 237 | {org = "ballerina", name = "io"}, 238 | {org = "ballerina", name = "jballerina.java"}, 239 | {org = "ballerina", name = "lang.int"}, 240 | {org = "ballerina", name = "log"} 241 | ] 242 | 243 | [[package]] 244 | org = "ballerina" 245 | name = "oauth2" 246 | version = "2.14.0" 247 | dependencies = [ 248 | {org = "ballerina", name = "cache"}, 249 | {org = "ballerina", name = "crypto"}, 250 | {org = "ballerina", name = "jballerina.java"}, 251 | {org = "ballerina", name = "log"}, 252 | {org = "ballerina", name = "time"}, 253 | {org = "ballerina", name = "url"} 254 | ] 255 | 256 | [[package]] 257 | org = "ballerina" 258 | name = "observe" 259 | version = "1.5.0" 260 | dependencies = [ 261 | {org = "ballerina", name = "jballerina.java"} 262 | ] 263 | 264 | [[package]] 265 | org = "ballerina" 266 | name = "os" 267 | version = "1.10.0" 268 | dependencies = [ 269 | {org = "ballerina", name = "io"}, 270 | {org = "ballerina", name = "jballerina.java"} 271 | ] 272 | modules = [ 273 | {org = "ballerina", packageName = "os", moduleName = "os"} 274 | ] 275 | 276 | [[package]] 277 | org = "ballerina" 278 | name = "task" 279 | version = "2.7.0" 280 | dependencies = [ 281 | {org = "ballerina", name = "jballerina.java"}, 282 | {org = "ballerina", name = "time"} 283 | ] 284 | 285 | [[package]] 286 | org = "ballerina" 287 | name = "test" 288 | version = "0.0.0" 289 | scope = "testOnly" 290 | dependencies = [ 291 | {org = "ballerina", name = "jballerina.java"}, 292 | {org = "ballerina", name = "lang.array"}, 293 | {org = "ballerina", name = "lang.error"} 294 | ] 295 | modules = [ 296 | {org = "ballerina", packageName = "test", moduleName = "test"} 297 | ] 298 | 299 | [[package]] 300 | org = "ballerina" 301 | name = "time" 302 | version = "2.7.0" 303 | dependencies = [ 304 | {org = "ballerina", name = "jballerina.java"} 305 | ] 306 | 307 | [[package]] 308 | org = "ballerina" 309 | name = "url" 310 | version = "2.6.0" 311 | dependencies = [ 312 | {org = "ballerina", name = "jballerina.java"} 313 | ] 314 | modules = [ 315 | {org = "ballerina", packageName = "url", moduleName = "url"} 316 | ] 317 | 318 | [[package]] 319 | org = "ballerinai" 320 | name = "observe" 321 | version = "0.0.0" 322 | dependencies = [ 323 | {org = "ballerina", name = "jballerina.java"}, 324 | {org = "ballerina", name = "observe"} 325 | ] 326 | modules = [ 327 | {org = "ballerinai", packageName = "observe", moduleName = "observe"} 328 | ] 329 | 330 | [[package]] 331 | org = "ballerinax" 332 | name = "googleapis.gcalendar" 333 | version = "5.0.0" 334 | dependencies = [ 335 | {org = "ballerina", name = "constraint"}, 336 | {org = "ballerina", name = "http"}, 337 | {org = "ballerina", name = "log"}, 338 | {org = "ballerina", name = "os"}, 339 | {org = "ballerina", name = "test"}, 340 | {org = "ballerina", name = "url"}, 341 | {org = "ballerinai", name = "observe"} 342 | ] 343 | modules = [ 344 | {org = "ballerinax", packageName = "googleapis.gcalendar", moduleName = "googleapis.gcalendar"}, 345 | {org = "ballerinax", packageName = "googleapis.gcalendar", moduleName = "googleapis.gcalendar.mock"}, 346 | {org = "ballerinax", packageName = "googleapis.gcalendar", moduleName = "googleapis.gcalendar.oas"} 347 | ] 348 | 349 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit 88 | 89 | # Use the maximum available, or set MAX_FD != -1 to use that value. 90 | MAX_FD=maximum 91 | 92 | warn () { 93 | echo "$*" 94 | } >&2 95 | 96 | die () { 97 | echo 98 | echo "$*" 99 | echo 100 | exit 1 101 | } >&2 102 | 103 | # OS specific support (must be 'true' or 'false'). 104 | cygwin=false 105 | msys=false 106 | darwin=false 107 | nonstop=false 108 | case "$( uname )" in #( 109 | CYGWIN* ) cygwin=true ;; #( 110 | Darwin* ) darwin=true ;; #( 111 | MSYS* | MINGW* ) msys=true ;; #( 112 | NONSTOP* ) nonstop=true ;; 113 | esac 114 | 115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 116 | 117 | 118 | # Determine the Java command to use to start the JVM. 119 | if [ -n "$JAVA_HOME" ] ; then 120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 121 | # IBM's JDK on AIX uses strange locations for the executables 122 | JAVACMD=$JAVA_HOME/jre/sh/java 123 | else 124 | JAVACMD=$JAVA_HOME/bin/java 125 | fi 126 | if [ ! -x "$JAVACMD" ] ; then 127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 128 | 129 | Please set the JAVA_HOME variable in your environment to match the 130 | location of your Java installation." 131 | fi 132 | else 133 | JAVACMD=java 134 | if ! command -v java >/dev/null 2>&1 135 | then 136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 148 | # shellcheck disable=SC3045 149 | MAX_FD=$( ulimit -H -n ) || 150 | warn "Could not query maximum file descriptor limit" 151 | esac 152 | case $MAX_FD in #( 153 | '' | soft) :;; #( 154 | *) 155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 156 | # shellcheck disable=SC3045 157 | ulimit -n "$MAX_FD" || 158 | warn "Could not set maximum file descriptor limit to $MAX_FD" 159 | esac 160 | fi 161 | 162 | # Collect all arguments for the java command, stacking in reverse order: 163 | # * args from the command line 164 | # * the main class name 165 | # * -classpath 166 | # * -D...appname settings 167 | # * --module-path (only if needed) 168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 169 | 170 | # For Cygwin or MSYS, switch paths to Windows format before running java 171 | if "$cygwin" || "$msys" ; then 172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 174 | 175 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 | 177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 | for arg do 179 | if 180 | case $arg in #( 181 | -*) false ;; # don't mess with options #( 182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 | [ -e "$t" ] ;; #( 184 | *) false ;; 185 | esac 186 | then 187 | arg=$( cygpath --path --ignore --mixed "$arg" ) 188 | fi 189 | # Roll the args list around exactly as many times as the number of 190 | # args, so each arg winds up back in the position where it started, but 191 | # possibly modified. 192 | # 193 | # NB: a `for` loop captures its iteration list before it begins, so 194 | # changing the positional parameters here affects neither the number of 195 | # iterations, nor the values presented in `arg`. 196 | shift # remove old arg 197 | set -- "$@" "$arg" # push replacement arg 198 | done 199 | fi 200 | 201 | 202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 | 205 | # Collect all arguments for the java command; 206 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 207 | # shell script including quotes and variable substitutions, so put them in 208 | # double quotes to make sure that they get re-expanded; and 209 | # * put everything else in single quotes, so that it's not re-expanded. 210 | 211 | set -- \ 212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 | -classpath "$CLASSPATH" \ 214 | org.gradle.wrapper.GradleWrapperMain \ 215 | "$@" 216 | 217 | # Stop when "xargs" is not available. 218 | if ! command -v xargs >/dev/null 2>&1 219 | then 220 | die "xargs is not available" 221 | fi 222 | 223 | # Use "xargs" to parse quoted args. 224 | # 225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 226 | # 227 | # In Bash we could simply go: 228 | # 229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 230 | # set -- "${ARGS[@]}" "$@" 231 | # 232 | # but POSIX shell has neither arrays nor command substitution, so instead we 233 | # post-process each arg (as a line of input to sed) to backslash-escape any 234 | # character that might be a shell metacharacter, then use eval to reverse 235 | # that process (while maintaining the separation between arguments), and wrap 236 | # the whole thing up as a single "set" statement. 237 | # 238 | # This will of course break if any of these variables contains a newline or 239 | # an unmatched quote. 240 | # 241 | 242 | eval "set -- $( 243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 244 | xargs -n1 | 245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 246 | tr '\n' ' ' 247 | )" '"$@"' 248 | 249 | exec "$JAVACMD" "$@" 250 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ballerina Google Calendar Connector 2 | 3 | [![Build](https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar/actions/workflows/ci.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar/actions/workflows/ci.yml) 4 | [![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerinax-googleapis.calendar.svg)](https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar/commits/main) 5 | [![GitHub Issues](https://img.shields.io/github/issues/ballerina-platform/ballerina-library/module/googleapis.calendar.svg?label=Open%20Issues)](https://github.com/ballerina-platform/ballerina-library/labels/module%2Fgoogleapis.calendar) 6 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 7 | 8 | [Google Calendar](https://developers.google.com/calendar) is a time-management and scheduling calendar service developed by Google. It lets users to organize their schedule and share events with others.This connector provides the capability to programmatically manage events and calendars. 9 | For more information about configuration and operations, go to the module. 10 | 11 | - [googleapis.gcalendar](ballerina/Module.md) - Perform Google Calendar related operations programmatically 12 | 13 | ## Overview 14 | 15 | The Google Calendar Connector provides the capability to manage events and calendar operations. It also provides the capability to support service account authorization that can provide delegated domain-wide access to the GSuite domain and support admins to do operations on behalf of the domain users. 16 | 17 | This module supports [Google Calendar API V3](https://developers.google.com/calendar/api). 18 | 19 | ## Setup guide 20 | 21 | To utilize the Calendar connector, you must have access to the Calendar REST API through a [Google Cloud Platform (GCP)](https://console.cloud.google.com/) account and a project under it. If you do not have a GCP account, you can sign up for one [here](https://cloud.google.com/). 22 | 23 | ### Step 1: Create a Google Cloud Platform project 24 | 25 | In order to use the Google Calendar connector, you need to first create the Calendar credentials for the connector to interact with Calendar. 26 | 27 | 1. Open the [Google Cloud Platform console](https://console.cloud.google.com/). 28 | 29 | 2. Click on the project drop-down menu and either select an existing project or create a new one for which you want to add an API key. 30 | 31 | GCP Console Project View 32 | 33 | ### Step 2: Enable Calendar API 34 | 35 | 1. Navigate to the **Library** and enable the Calendar API. 36 | 37 | Enable Calendar API 38 | 39 | ### Step 3: Configure OAuth consent 40 | 41 | 1. Click on the **OAuth consent screen** tab in the Google Cloud Platform console. 42 | 43 | Consent Screen 44 | 45 | 2. Provide a name for the consent application and save your changes. 46 | 47 | ### Step 4: Create OAuth client 48 | 49 | 1. Navigate to the **Credentials** tab in your Google Cloud Platform console. 50 | 51 | 2. Click **Create credentials** and from the dropdown menu, select **OAuth client ID**. 52 | 53 | Create Credentials 54 | 55 | 3. You will be directed to the **OAuth consent** screen, in which you need to fill in the necessary information below. 56 | 57 | | Field | Value | 58 | | ------------------------- | ----- | 59 | | Application type | Web Application | 60 | | Name | CalendarConnector | 61 | | Authorized redirect URIs | | 62 | 63 | 4. After filling in these details, click **Create**. 64 | 65 | 5. Make sure to save the provided **Client ID** and **Client secret**. 66 | 67 | ### Step 5: Get the access and refresh tokens 68 | 69 | **Note**: It is recommended to use the [OAuth 2.0 playground](https://developers.google.com/oauthplayground) to obtain the tokens. 70 | 71 | 1. Configure the OAuth playground with the OAuth client ID and client secret. 72 | 73 | OAuth Playground 74 | 75 | 2. Authorize the Calendar APIs. 76 | 77 | Authorize APIs 78 | 79 | 3. Exchange the authorization code for tokens. 80 | 81 | Exchange Tokens 82 | 83 | ## Quickstart 84 | 85 | To use the Google Calendar connector in your Ballerina project, modify the `.bal` file as follows: 86 | 87 | ### Step 1: Import the module 88 | 89 | Import the `ballerinax/googleapis.gcalendar` module. 90 | 91 | ```ballerina 92 | import ballerinax/googleapis.gcalendar; 93 | ``` 94 | 95 | ### Step 2: Instantiate a new connector 96 | 97 | Create a `gcalendar:ConnectionConfig` with the obtained OAuth2.0 tokens and initialize the connector with it. 98 | 99 | ```ballerina 100 | configurable string clientId = ?; 101 | configurable string clientSecret = ?; 102 | configurable string refreshToken = ?; 103 | configurable string refreshUrl = ?; 104 | 105 | gcalendar:Client calendar = check new ({ 106 | auth: { 107 | clientId, 108 | clientSecret, 109 | refreshToken, 110 | refreshUrl 111 | } 112 | }); 113 | ``` 114 | 115 | ### Step 3: Invoke the connector operation 116 | 117 | You can now utilize the operations available within the connector. 118 | 119 | ```ballerina 120 | public function main() returns error? { 121 | gcalendar:Client calendar = ...// 122 | 123 | // create a calendar 124 | gcalendar:Calendar calendar = check calendar->/calendars.post({ 125 | summary: "Work Schedule" 126 | }); 127 | 128 | // quick add new event 129 | string eventTitle = "Sample Event"; 130 | gcalendar:Event event = check calendar->/calendars/[calendarId]/events/quickAdd.post(eventTitle); 131 | } 132 | ``` 133 | 134 | ### Step 4: Run the Ballerina application 135 | 136 | Use the following command to compile and run the Ballerina program. 137 | 138 | ```bash 139 | bal run 140 | ``` 141 | 142 | ## Examples 143 | 144 | The Google Calendar connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar/tree/main/examples), covering use cases like creating calendar, scheduling meeting events, and adding reminders. 145 | 146 | 1. [Project management with Calendar API](https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar/tree/main/examples/project-management-with-calendar) 147 | This example shows how to use Google Calendar APIs to efficiently manage work schedule of a person. It interacts with the API for various tasks related to scheduling and organizing work-related events and meetings. 148 | 2. [Work schedule management with Calendar API](https://github.com/ballerina-platform/module-ballerinax-googleapis.calendar/tree/main/examples/work-schedule-management-with-calendar) 149 | This example shows how to use Google Calendar APIs to managing personal project schedule and collaborating with team members. 150 | 151 | For comprehensive information about the connector's functionality, configuration, and usage in Ballerina programs, refer to the Google Calendar connector's reference guide in [Ballerina Central](https://central.ballerina.io/ballerinax/googleapis.calendar/latest). 152 | 153 | ## Issues and projects 154 | 155 | 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). 156 | 157 | This repository only contains the source code for the package. 158 | 159 | ## Building from the source 160 | 161 | ### Prerequisites 162 | 163 | 1. Download and install Java SE Development Kit (JDK) version 17. You can download it from either of the following sources: 164 | 165 | - [Oracle JDK](https://www.oracle.com/java/technologies/downloads/) 166 | - [OpenJDK](https://adoptium.net/) 167 | 168 | > **Note:** After installation, remember to set the `JAVA_HOME` environment variable to the directory where JDK was installed. 169 | 170 | 2. Download and install [Ballerina Swan Lake](https://ballerina.io/). 171 | 172 | 3. Download and install [Docker](https://www.docker.com/get-started). 173 | 174 | > **Note**: Ensure that the Docker daemon is running before executing any tests. 175 | 176 | 4. Generate a Github access token with read package permissions, then set the following `env` variables: 177 | 178 | ```bash 179 | export packageUser= 180 | export packagePAT= 181 | ``` 182 | 183 | ### Build options 184 | 185 | Execute the commands below to build from the source. 186 | 187 | 1. To build the package: 188 | 189 | ```bash 190 | ./gradlew clean build 191 | ``` 192 | 193 | 2. To run the tests: 194 | 195 | ```bash 196 | ./gradlew clean test 197 | ``` 198 | 199 | 3. To build the without the tests: 200 | 201 | ```bash 202 | ./gradlew clean build -x test 203 | ``` 204 | 205 | 4. To debug package with a remote debugger: 206 | 207 | ```bash 208 | ./gradlew clean build -Pdebug= 209 | ``` 210 | 211 | 5. To debug with Ballerina language: 212 | 213 | ```bash 214 | ./gradlew clean build -PbalJavaDebug= 215 | ``` 216 | 217 | 6. Publish the generated artifacts to the local Ballerina central repository: 218 | 219 | ```bash 220 | ./gradlew clean build -PpublishToLocalCentral=true 221 | ``` 222 | 223 | 7. Publish the generated artifacts to the Ballerina central repository: 224 | 225 | ```bash 226 | ./gradlew clean build -PpublishToCentral=true 227 | ``` 228 | 229 | ## Contributing to Ballerina 230 | 231 | As an open source project, Ballerina welcomes contributions from the community. 232 | 233 | For more information, go to the [contribution guidelines](https://github.com/ballerina-platform/ballerina-lang/blob/master/CONTRIBUTING.md). 234 | 235 | ## Code of conduct 236 | 237 | All contributors are encouraged to read the [Ballerina Code of Conduct](https://ballerina.io/code-of-conduct). 238 | 239 | ## Useful links 240 | 241 | - Discuss code changes of the Ballerina project in [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com). 242 | - Chat live with us via our [Discord server](https://discord.gg/ballerinalang). 243 | - Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. 244 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /ballerina/modules/mock/openapi_service.bal: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. 2 | // 3 | // WSO2 LLC. licenses this file to you under the Apache License, 4 | // Version 2.0 (the "License"); you may not use this file except 5 | // in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, 11 | // software distributed under the License is distributed on an 12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | // KIND, either express or implied. See the License for the 14 | // specific language governing permissions and limitations 15 | // under the License. 16 | 17 | import ballerina/http; 18 | 19 | service /calendar/v3 on new http:Listener(9090) { 20 | 21 | resource function post calendars("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, @http:Payload Calendar payload) returns OkCalendar { 22 | OkCalendar okCalendar = { 23 | body: { 24 | conferenceProperties: { 25 | allowedConferenceSolutionTypes: ["hangoutsMeet"] 26 | }, 27 | description: "calendar description", 28 | etag: "\"Syw9JucVAl83XRddaXunDD-xXrY\"", 29 | id: "b8f24cd945da8adf629e1e680d3a423c197354709c50563e90bbaf9a5a911684@group.gcalendar.google.com", 30 | kind: "calendar#calendar", 31 | location: "Sri Lanka", 32 | summary: payload.summary, 33 | timeZone: "UTC" 34 | } 35 | }; 36 | return okCalendar; 37 | } 38 | 39 | resource function get calendars/[string calendarId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser) returns Calendar { 40 | Calendar calendar = { 41 | conferenceProperties: { 42 | allowedConferenceSolutionTypes: ["hangoutsMeet"] 43 | }, 44 | description: "calendar description", 45 | etag: "\"Syw9JucVAl83XRddaXunDD-xXrY\"", 46 | id: calendarId, 47 | kind: "calendar#calendar", 48 | location: "Sri Lanka", 49 | summary: "calendar summary", 50 | timeZone: "UTC" 51 | }; 52 | return calendar; 53 | } 54 | 55 | resource function put calendars/[string calendarId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, @http:Payload Calendar payload) returns Calendar { 56 | Calendar calendar = { 57 | conferenceProperties: { 58 | allowedConferenceSolutionTypes: ["hangoutsMeet"] 59 | }, 60 | description: payload.description, 61 | etag: "\"Syw9JucVAl83XRddaXunDD-xXrY\"", 62 | id: calendarId, 63 | kind: "calendar#calendar", 64 | location: payload.location ?: "Sri Lanka", 65 | summary: payload.summary, 66 | timeZone: payload.timeZone 67 | }; 68 | return calendar; 69 | } 70 | 71 | resource function delete calendars/[string calendarId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser) returns http:Ok { 72 | return http:OK; 73 | } 74 | 75 | resource function patch calendars/[string calendarId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, @http:Payload Calendar payload) returns Calendar { 76 | Calendar calendar = { 77 | conferenceProperties: { 78 | allowedConferenceSolutionTypes: ["hangoutsMeet"] 79 | }, 80 | description: payload.description ?: "calendar description", 81 | etag: "\"Syw9JucVAl83XRddaXunDD-xXrY\"", 82 | id: calendarId, 83 | kind: "calendar#calendar", 84 | location: payload.location ?: "Sri Lanka", 85 | summary: payload.summary, 86 | timeZone: payload.timeZone ?: "UTC" 87 | }; 88 | calendar.id = calendarId; 89 | return calendar; 90 | } 91 | 92 | resource function get calendars/[string calendarId]/acl("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, int? maxResults, string? pageToken, boolean? showDeleted, string? syncToken) returns Acl { 93 | AclRule aclRule = { 94 | etag: "default-etag", 95 | id: calendarId 96 | }; 97 | Acl acl = { 98 | etag: "\"Syw9JucVAl83XRddaXunDD-xXrY\"", 99 | items: [ 100 | aclRule 101 | ], 102 | kind: "calendar#acl", 103 | nextPageToken: "", 104 | nextSyncToken: "" 105 | }; 106 | return acl; 107 | } 108 | 109 | resource function post calendars/[string calendarId]/acl("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, boolean? sendNotifications, @http:Payload AclRule payload) returns OkAclRule { 110 | OkAclRule okAclRule = { 111 | body: payload 112 | }; 113 | return okAclRule; 114 | } 115 | 116 | resource function get calendars/[string calendarId]/acl/[string ruleId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser) returns AclRule { 117 | AclRule aclRule = { 118 | etag: "\"Syw9JucVAl83XRddaXunDD-xXrY\"", 119 | id: ruleId, 120 | kind: "calendar#aclRule", 121 | role: "reader", 122 | scope: {} 123 | }; 124 | return aclRule; 125 | } 126 | 127 | resource function put calendars/[string calendarId]/acl/[string ruleId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, @http:Payload AclRule payload) returns AclRule { 128 | AclRule aclRule = { 129 | etag: "\"Syw9JucVAl83XRddaXunDD-xXrY\"", 130 | id: ruleId, 131 | kind: "calendar#aclRule", 132 | role: payload.role, 133 | scope: payload.scope 134 | }; 135 | return aclRule; 136 | } 137 | 138 | resource function delete calendars/[string calendarId]/acl/[string ruleId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser) returns http:Ok { 139 | return http:OK; 140 | } 141 | 142 | resource function patch calendars/[string calendarId]/acl/[string ruleId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, boolean? sendNotifications, @http:Payload AclRule payload) returns AclRule { 143 | AclRule aclRule = { 144 | etag: "\"Syw9JucVAl83XRddaXunDD-xXrY\"", 145 | id: ruleId, 146 | kind: "calendar#aclRule", 147 | role: payload.role, 148 | scope: payload.scope 149 | }; 150 | return aclRule; 151 | } 152 | 153 | resource function post calendars/[string calendarId]/clear("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser) returns http:Ok { 154 | return http:OK; 155 | } 156 | 157 | resource function get calendars/[string calendarId]/events("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, string[]? eventTypes, string? iCalUID, int? maxAttendees, int? maxResults, "startTime"|"updated"? orderBy, string? pageToken, string[]? privateExtendedProperty, string? q, string[]? sharedExtendedProperty, boolean? showDeleted, boolean? showHiddenInvitations, boolean? singleEvents, string? syncToken, string? timeMax, string? timeMin, string? timeZone, string? updatedMin) returns Events { 158 | Events events = { 159 | accessRole: "reader", 160 | defaultReminders: [], 161 | description: "Calendar Description", 162 | etag: "\"Syw9JucVAl83XRddaXunDD-xXrY\"", 163 | items: [ 164 | { 165 | anyoneCanAddSelf: false, 166 | attachments: [], 167 | attendees: [], 168 | attendeesOmitted: false, 169 | colorId: "1", 170 | conferenceData: { 171 | conferenceId: "conference_id", 172 | conferenceSolution: { 173 | iconUri: "https://www.gstatic.com/images/icons/material/product/2x/hangoutsMeet_48dp.png", 174 | key: { 175 | 'type: "hangoutsMeet" 176 | }, 177 | name: "Hangouts Meet" 178 | }, 179 | createRequest: { 180 | conferenceSolutionKey: { 181 | 'type: "hangoutsMeet" 182 | }, 183 | requestId: "request_id" 184 | }, 185 | entryPoints: [ 186 | { 187 | accessCode: "access_code", 188 | entryPointFeatures: ["video", "phone"], 189 | entryPointType: "video", 190 | label: "label", 191 | meetingCode: "meeting_code", 192 | passcode: "passcode", 193 | password: "password", 194 | pin: "pin", 195 | regionCode: "region_code", 196 | uri: "https://meet.google.com/abc-defg-hij" 197 | } 198 | ], 199 | notes: "notes", 200 | signature: "signature" 201 | }, 202 | created: "2022-01-01T00:00:00Z", 203 | creator: { 204 | displayName: "creator display name", 205 | email: "" 206 | } 207 | } 208 | ], 209 | kind: "calendar#events", 210 | nextPageToken: "", 211 | nextSyncToken: "", 212 | summary: "Test Event", 213 | timeZone: "GMT", 214 | updated: "2022-01-01T00:00:00Z" 215 | }; 216 | return events; 217 | } 218 | 219 | resource function post calendars/[string calendarId]/events("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, int? conferenceDataVersion, int? maxAttendees, "all"|"externalOnly"|"none"? sendUpdates, boolean? supportsAttachments, @http:Payload Event payload) returns OkEvent { 220 | OkEvent okEvent = { 221 | body: payload 222 | }; 223 | okEvent.body.id = calendarId; 224 | return okEvent; 225 | } 226 | 227 | resource function post calendars/[string calendarId]/events/'import("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, int? conferenceDataVersion, boolean? supportsAttachments, @http:Payload Event payload) returns OkEvent { 228 | OkEvent okEvent = { 229 | body: payload 230 | }; 231 | return okEvent; 232 | } 233 | 234 | resource function post calendars/[string calendarId]/events/quickAdd("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, string text, "all"|"externalOnly"|"none"? sendUpdates) returns OkEvent { 235 | OkEvent okEvent = { 236 | body: { 237 | id: "default-event-id", 238 | summary: text 239 | } 240 | }; 241 | return okEvent; 242 | } 243 | 244 | resource function put calendars/[string calendarId]/events/[string eventId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, int? conferenceDataVersion, int? maxAttendees, "all"|"externalOnly"|"none"? sendUpdates, boolean? supportsAttachments, @http:Payload Event payload) returns Event { 245 | Event event = payload; 246 | event.id = eventId; 247 | event.iCalUID = calendarId; 248 | return event; 249 | } 250 | 251 | resource function delete calendars/[string calendarId]/events/[string eventId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, "all"|"externalOnly"|"none"? sendUpdates) returns http:Ok { 252 | return http:OK; 253 | } 254 | 255 | resource function patch calendars/[string calendarId]/events/[string eventId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, int? conferenceDataVersion, int? maxAttendees, "all"|"externalOnly"|"none"? sendUpdates, boolean? supportsAttachments, @http:Payload Event payload) returns Event { 256 | Event event = payload; 257 | event.id = eventId; 258 | event.iCalUID = calendarId; 259 | return event; 260 | } 261 | 262 | resource function get calendars/[string calendarId]/events/[string eventId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, int? maxAttendees, int? maxResults, string? originalStart, string? pageToken, boolean? showDeleted, string? timeMax, string? timeMin, string? timeZone) returns Event { 263 | Event event = { 264 | id: eventId, 265 | anyoneCanAddSelf: false, 266 | attachments: [], 267 | attendees: [], 268 | attendeesOmitted: false, 269 | colorId: "1", 270 | conferenceData: { 271 | conferenceId: "conference_id", 272 | conferenceSolution: { 273 | iconUri: "https://www.gstatic.com/images/icons/material/product/2x/hangoutsMeet_48dp.png", 274 | key: { 275 | 'type: "hangoutsMeet" 276 | }, 277 | name: "Hangouts Meet" 278 | }, 279 | createRequest: { 280 | conferenceSolutionKey: { 281 | 'type: "hangoutsMeet" 282 | }, 283 | requestId: "request_id" 284 | }, 285 | entryPoints: [ 286 | { 287 | accessCode: "access_code", 288 | entryPointFeatures: ["video", "phone"], 289 | entryPointType: "video", 290 | label: "label", 291 | meetingCode: "meeting_code", 292 | passcode: "passcode", 293 | password: "password", 294 | pin: "pin", 295 | regionCode: "region_code", 296 | uri: "https://meet.google.com/abc-defg-hij" 297 | } 298 | ], 299 | notes: "notes", 300 | signature: "signature" 301 | }, 302 | created: "2022-01-01T00:00:00Z", 303 | creator: { 304 | displayName: "creator display name", 305 | email: "" 306 | }, 307 | summary: "Test Event" 308 | }; 309 | return event; 310 | } 311 | 312 | resource function get calendars/[string calendarId]/events/[string eventId]/instances("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, int? maxAttendees, int? maxResults, string? originalStart, string? pageToken, boolean? showDeleted, string? timeMax, string? timeMin, string? timeZone) returns Events { 313 | Events events = { 314 | accessRole: "reader", 315 | defaultReminders: [], 316 | description: "Calendar Description", 317 | etag: "\"Syw9JucVAl83XRddaXunDD-xXrY\"", 318 | items: [ 319 | { 320 | anyoneCanAddSelf: false, 321 | attachments: [], 322 | attendees: [], 323 | attendeesOmitted: false, 324 | colorId: "1", 325 | conferenceData: { 326 | conferenceId: "conference_id", 327 | conferenceSolution: { 328 | iconUri: "https://www.gstatic.com/images/icons/material/product/2x/hangoutsMeet_48dp.png", 329 | key: { 330 | 'type: "hangoutsMeet" 331 | }, 332 | name: "Hangouts Meet" 333 | }, 334 | createRequest: { 335 | conferenceSolutionKey: { 336 | 'type: "hangoutsMeet" 337 | }, 338 | requestId: "request_id" 339 | }, 340 | entryPoints: [ 341 | { 342 | accessCode: "access_code", 343 | entryPointFeatures: ["video", "phone"], 344 | entryPointType: "video", 345 | label: "label", 346 | meetingCode: "meeting_code", 347 | passcode: "passcode", 348 | password: "password", 349 | pin: "pin", 350 | regionCode: "region_code", 351 | uri: "https://meet.google.com/abc-defg-hij" 352 | } 353 | ], 354 | notes: "notes", 355 | signature: "signature" 356 | }, 357 | created: "2022-01-01T00:00:00Z", 358 | creator: { 359 | displayName: "creator display name", 360 | email: "" 361 | } 362 | } 363 | ], 364 | kind: "calendar#events", 365 | nextPageToken: "", 366 | nextSyncToken: "", 367 | summary: "Test Event", 368 | timeZone: "GMT", 369 | updated: "2022-01-01T00:00:00Z" 370 | }; 371 | return events; 372 | } 373 | 374 | resource function post calendars/[string calendarId]/events/[string eventId]/move("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, string destination, "all"|"externalOnly"|"none"? sendUpdates) returns OkEvent { 375 | OkEvent okEvent = { 376 | body: { 377 | summary: "Test Event", 378 | iCalUID: destination, 379 | id: eventId 380 | } 381 | }; 382 | return okEvent; 383 | } 384 | 385 | resource function get colors("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser) returns Colors { 386 | Colors colors = { 387 | calendar: {}, 388 | event: {}, 389 | kind: "calendar#colors", 390 | updated: "2022-01-01T00:00:00Z" 391 | }; 392 | return colors; 393 | } 394 | 395 | resource function post freeBusy("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, @http:Payload FreeBusyRequest payload) returns OkFreeBusyResponse { 396 | OkFreeBusyResponse response = { 397 | body: { 398 | calendars: {}, 399 | groups: {}, 400 | kind: "calendar#freeBusy", 401 | timeMax: "2022-01-01T00:00:00Z", 402 | timeMin: "2022-01-01T00:00:00Z" 403 | } 404 | }; 405 | return response; 406 | } 407 | 408 | resource function get users/me/calendarList("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, int? maxResults, "freeBusyReader"|"owner"|"reader"|"writer"? minAccessRole, string? pageToken, boolean? showDeleted, boolean? showHidden, string? syncToken) returns CalendarList { 409 | CalendarList calendarList = { 410 | etag: "\"Syw9JucVAl83XRddaXunDD-xXrY\"", 411 | items: [ 412 | { 413 | accessRole: "reader", 414 | backgroundColor: "#ffffff", 415 | colorId: "1", 416 | conferenceProperties: { 417 | allowedConferenceSolutionTypes: ["hangoutsMeet"] 418 | }, 419 | defaultReminders: [], 420 | deleted: false, 421 | description: "Calendar Description", 422 | etag: "\"Syw9JucVAl83XRddaXunDD-xXrY\"", 423 | foregroundColor: "#000000", 424 | hidden: false, 425 | id: "" 426 | } 427 | ], 428 | kind: "calendar#calendarList", 429 | nextPageToken: "", 430 | nextSyncToken: "" 431 | }; 432 | return calendarList; 433 | } 434 | 435 | resource function post users/me/calendarList("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, boolean? colorRgbFormat, @http:Payload CalendarListEntry payload) returns OkCalendarListEntry { 436 | OkCalendarListEntry okEntry = { 437 | body: payload 438 | }; 439 | return okEntry; 440 | } 441 | 442 | resource function get users/me/calendarList/[string calendarId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser) returns CalendarListEntry { 443 | CalendarListEntry entry = { 444 | accessRole: "reader", 445 | backgroundColor: "#ffffff", 446 | colorId: "1", 447 | conferenceProperties: { 448 | allowedConferenceSolutionTypes: ["hangoutsMeet"] 449 | }, 450 | defaultReminders: [], 451 | deleted: false, 452 | description: "Calendar Description", 453 | etag: "\"Syw9JucVAl83XRddaXunDD-xXrY\"", 454 | foregroundColor: "#000000", 455 | hidden: false, 456 | id: calendarId, 457 | kind: "calendar#calendarListEntry", 458 | location: "Sri Lanka", 459 | notificationSettings: { 460 | notifications: [] 461 | }, 462 | primary: false, 463 | selected: true, 464 | summary: "Calendar Summary", 465 | summaryOverride: "Calendar Summary Override", 466 | timeZone: "GMT" 467 | }; 468 | return entry; 469 | } 470 | 471 | resource function put users/me/calendarList/[string calendarId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, boolean? colorRgbFormat, @http:Payload CalendarListEntry payload) returns CalendarListEntry { 472 | CalendarListEntry entry = payload; 473 | return entry; 474 | } 475 | 476 | resource function delete users/me/calendarList/[string calendarId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser) returns http:Ok { 477 | return http:OK; 478 | } 479 | 480 | resource function patch users/me/calendarList/[string calendarId]("json"? alt, string? fields, string? 'key, string? oauth_token, boolean? prettyPrint, string? quotaUser, boolean? colorRgbFormat, @http:Payload CalendarListEntry payload) returns CalendarListEntry { 481 | CalendarListEntry entry = payload; 482 | return entry; 483 | } 484 | } 485 | -------------------------------------------------------------------------------- /ballerina/client.bal: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com). 2 | // 3 | // WSO2 LLC. licenses this file to you under the Apache License, 4 | // Version 2.0 (the "License"); you may not use this file except 5 | // in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, 11 | // software distributed under the License is distributed on an 12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | // KIND, either express or implied. See the License for the 14 | // specific language governing permissions and limitations 15 | // under the License. 16 | 17 | import ballerina/data.jsondata; 18 | import ballerina/http; 19 | 20 | # Manipulates events and other calendar data. 21 | public isolated client class Client { 22 | final http:Client clientEp; 23 | # Gets invoked to initialize the `connector`. 24 | # 25 | # + config - The configurations to be used when initializing the `connector` 26 | # + serviceUrl - URL of the target service 27 | # + return - An error if connector initialization failed 28 | public isolated function init(ConnectionConfig config, string serviceUrl = "https://www.googleapis.com/calendar/v3") returns error? { 29 | http:ClientConfiguration httpClientConfig = {auth: config.auth, httpVersion: config.httpVersion, http1Settings: config.http1Settings, http2Settings: config.http2Settings, timeout: config.timeout, forwarded: config.forwarded, followRedirects: config.followRedirects, poolConfig: config.poolConfig, cache: config.cache, compression: config.compression, circuitBreaker: config.circuitBreaker, retryConfig: config.retryConfig, cookieConfig: config.cookieConfig, responseLimits: config.responseLimits, secureSocket: config.secureSocket, proxy: config.proxy, socketConfig: config.socketConfig, validation: config.validation, laxDataBinding: config.laxDataBinding}; 30 | self.clientEp = check new (serviceUrl, httpClientConfig); 31 | } 32 | 33 | # Creates a secondary calendar. 34 | # 35 | # + headers - Headers to be sent with the request 36 | # + queries - Queries to be sent with the request 37 | # + payload - Data required to create the calendar 38 | # + return - A `gcalendar:Calendar` if successful, otherwise an error 39 | resource isolated function post calendars(Calendar payload, map headers = {}, *CreateCalendarQueries queries) returns Calendar|error { 40 | string resourcePath = string `/calendars`; 41 | resourcePath = resourcePath + check getPathForQueryParam(queries); 42 | http:Request request = new; 43 | json jsonBody = jsondata:toJson(payload); 44 | request.setPayload(jsonBody, "application/json"); 45 | return self.clientEp->post(resourcePath, request, headers); 46 | } 47 | 48 | # Returns metadata for a calendar. 49 | # 50 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 51 | # + headers - Headers to be sent with the request 52 | # + queries - Queries to be sent with the request 53 | # + return - A `gcalendar:Calendar` if successful, otherwise an error 54 | resource isolated function get calendars/[string calendarId](map headers = {}, *CalendarCalendarsGetQueries queries) returns Calendar|error { 55 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}`; 56 | resourcePath = resourcePath + check getPathForQueryParam(queries); 57 | return self.clientEp->get(resourcePath, headers); 58 | } 59 | 60 | # Updates metadata for a calendar. 61 | # 62 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 63 | # + headers - Headers to be sent with the request 64 | # + queries - Queries to be sent with the request 65 | # + payload - Data required to update the calendar 66 | # + return - A `gcalendar:Calendar` if successful, otherwise an error 67 | resource isolated function put calendars/[string calendarId](Calendar payload, map headers = {}, *CalendarCalendarsUpdateQueries queries) returns Calendar|error { 68 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}`; 69 | resourcePath = resourcePath + check getPathForQueryParam(queries); 70 | http:Request request = new; 71 | json jsonBody = jsondata:toJson(payload); 72 | request.setPayload(jsonBody, "application/json"); 73 | return self.clientEp->put(resourcePath, request, headers); 74 | } 75 | 76 | # Deletes a secondary calendar. Use calendars.clear for clearing all events on primary calendars. 77 | # 78 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 79 | # + headers - Headers to be sent with the request 80 | # + queries - Queries to be sent with the request 81 | # + return - If successful `()`, otherwise an error 82 | resource isolated function delete calendars/[string calendarId](map headers = {}, *DeleteCalendarQueries queries) returns error? { 83 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}`; 84 | resourcePath = resourcePath + check getPathForQueryParam(queries); 85 | return self.clientEp->delete(resourcePath, headers = headers); 86 | } 87 | 88 | # Updates metadata for a calendar. This method supports patch semantics. 89 | # 90 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 91 | # + headers - Headers to be sent with the request 92 | # + queries - Queries to be sent with the request 93 | # + payload - Data required to update the calendar 94 | # + return - A `gcalendar:Calendar` if successful, otherwise an error 95 | resource isolated function patch calendars/[string calendarId](Calendar payload, map headers = {}, *CalendarCalendarsPatchQueries queries) returns Calendar|error { 96 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}`; 97 | resourcePath = resourcePath + check getPathForQueryParam(queries); 98 | http:Request request = new; 99 | json jsonBody = jsondata:toJson(payload); 100 | request.setPayload(jsonBody, "application/json"); 101 | return self.clientEp->patch(resourcePath, request, headers); 102 | } 103 | 104 | # Returns the rules in the access control list for the calendar. 105 | # 106 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 107 | # + headers - Headers to be sent with the request 108 | # + queries - Queries to be sent with the request 109 | # + return - A `gcalendar:Acl` if successful, otherwise an error 110 | resource isolated function get calendars/[string calendarId]/acl(map headers = {}, *CalendarAclListQueries queries) returns Acl|error { 111 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/acl`; 112 | resourcePath = resourcePath + check getPathForQueryParam(queries); 113 | return self.clientEp->get(resourcePath, headers); 114 | } 115 | 116 | # Creates an access control rule. 117 | # 118 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 119 | # + headers - Headers to be sent with the request 120 | # + queries - Queries to be sent with the request 121 | # + payload - Data required to create access permissions for the calendar 122 | # + return - A `gcalendar:AclRule` if successful, otherwise an error 123 | resource isolated function post calendars/[string calendarId]/acl(AclRule payload, map headers = {}, *CalendarAclInsertQueries queries) returns AclRule|error { 124 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/acl`; 125 | resourcePath = resourcePath + check getPathForQueryParam(queries); 126 | http:Request request = new; 127 | json jsonBody = jsondata:toJson(payload); 128 | request.setPayload(jsonBody, "application/json"); 129 | return self.clientEp->post(resourcePath, request, headers); 130 | } 131 | 132 | # Returns an access control rule. 133 | # 134 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 135 | # + ruleId - ACL rule identifier 136 | # + headers - Headers to be sent with the request 137 | # + queries - Queries to be sent with the request 138 | # + return - A `gcalendar:AclRule` if successful, otherwise an error 139 | resource isolated function get calendars/[string calendarId]/acl/[string ruleId](map headers = {}, *CalendarAclGetQueries queries) returns AclRule|error { 140 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/acl/${getEncodedUri(ruleId)}`; 141 | resourcePath = resourcePath + check getPathForQueryParam(queries); 142 | return self.clientEp->get(resourcePath, headers); 143 | } 144 | 145 | # Updates an access control rule. 146 | # 147 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 148 | # + ruleId - ACL rule identifier 149 | # + headers - Headers to be sent with the request 150 | # + queries - Queries to be sent with the request 151 | # + payload - Data required to update access permissions for the calendar 152 | # + return - A `gcalendar:AclRule` if successful, otherwise an error 153 | resource isolated function put calendars/[string calendarId]/acl/[string ruleId](AclRule payload, map headers = {}, *CalendarAclUpdateQueries queries) returns AclRule|error { 154 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/acl/${getEncodedUri(ruleId)}`; 155 | resourcePath = resourcePath + check getPathForQueryParam(queries); 156 | http:Request request = new; 157 | json jsonBody = jsondata:toJson(payload); 158 | request.setPayload(jsonBody, "application/json"); 159 | return self.clientEp->put(resourcePath, request, headers); 160 | } 161 | 162 | # Deletes an access control rule. 163 | # 164 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 165 | # + ruleId - ACL rule identifier 166 | # + headers - Headers to be sent with the request 167 | # + queries - Queries to be sent with the request 168 | # + return - If successful `()`, otherwise an error 169 | resource isolated function delete calendars/[string calendarId]/acl/[string ruleId](map headers = {}, *CalendarAclDeleteQueries queries) returns error? { 170 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/acl/${getEncodedUri(ruleId)}`; 171 | resourcePath = resourcePath + check getPathForQueryParam(queries); 172 | return self.clientEp->delete(resourcePath, headers = headers); 173 | } 174 | 175 | # Updates an access control rule. This method supports patch semantics. 176 | # 177 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 178 | # + ruleId - ACL rule identifier 179 | # + headers - Headers to be sent with the request 180 | # + queries - Queries to be sent with the request 181 | # + payload - Data required to update access permissions for the calendar 182 | # + return - A `gcalendar:AclRule` if successful, otherwise an error 183 | resource isolated function patch calendars/[string calendarId]/acl/[string ruleId](AclRule payload, map headers = {}, *CalendarAclPatchQueries queries) returns AclRule|error { 184 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/acl/${getEncodedUri(ruleId)}`; 185 | resourcePath = resourcePath + check getPathForQueryParam(queries); 186 | http:Request request = new; 187 | json jsonBody = jsondata:toJson(payload); 188 | request.setPayload(jsonBody, "application/json"); 189 | return self.clientEp->patch(resourcePath, request, headers); 190 | } 191 | 192 | # Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account. 193 | # 194 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 195 | # + headers - Headers to be sent with the request 196 | # + queries - Queries to be sent with the request 197 | # + return - If successful `()`, otherwise an error 198 | resource isolated function post calendars/[string calendarId]/clear(map headers = {}, *CalendarCalendarsClearQueries queries) returns error? { 199 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/clear`; 200 | resourcePath = resourcePath + check getPathForQueryParam(queries); 201 | http:Request request = new; 202 | return self.clientEp->post(resourcePath, request, headers); 203 | } 204 | 205 | # Returns events on the specified calendar. 206 | # 207 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 208 | # + headers - Headers to be sent with the request 209 | # + queries - Queries to be sent with the request 210 | # + return - A `gcalendar:Events` if successful, otherwise an error 211 | resource isolated function get calendars/[string calendarId]/events(map headers = {}, *CalendarEventsListQueries queries) returns Events|error { 212 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events`; 213 | map queryParamEncoding = {"eventTypes": {style: FORM, explode: true}, "privateExtendedProperty": {style: FORM, explode: true}, "sharedExtendedProperty": {style: FORM, explode: true}}; 214 | resourcePath = resourcePath + check getPathForQueryParam(queries, queryParamEncoding); 215 | return self.clientEp->get(resourcePath, headers); 216 | } 217 | 218 | # Creates an event. 219 | # 220 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 221 | # + headers - Headers to be sent with the request 222 | # + queries - Queries to be sent with the request 223 | # + payload - Data required to create an event 224 | # + return - A `gcalendar:Event` if successful, otherwise an error 225 | resource isolated function post calendars/[string calendarId]/events(Event payload, map headers = {}, *CalendarEventsInsertQueries queries) returns Event|error { 226 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events`; 227 | resourcePath = resourcePath + check getPathForQueryParam(queries); 228 | http:Request request = new; 229 | json jsonBody = jsondata:toJson(payload); 230 | request.setPayload(jsonBody, "application/json"); 231 | return self.clientEp->post(resourcePath, request, headers); 232 | } 233 | 234 | # Imports an event. This operation is used to add a private copy of an existing event to a calendar. 235 | # 236 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 237 | # + headers - Headers to be sent with the request 238 | # + queries - Queries to be sent with the request 239 | # + payload - Data required to import an event 240 | # + return - A `gcalendar:Event` if successful, otherwise an error 241 | resource isolated function post calendars/[string calendarId]/events/'import(Event payload, map headers = {}, *CalendarEventsImportQueries queries) returns Event|error { 242 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/import`; 243 | resourcePath = resourcePath + check getPathForQueryParam(queries); 244 | http:Request request = new; 245 | json jsonBody = jsondata:toJson(payload); 246 | request.setPayload(jsonBody, "application/json"); 247 | return self.clientEp->post(resourcePath, request, headers); 248 | } 249 | 250 | # Creates an event based on a simple text string. 251 | # 252 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 253 | # + headers - Headers to be sent with the request 254 | # + queries - Queries to be sent with the request 255 | # + return - A `gcalendar:Event` if successful, otherwise an error 256 | resource isolated function post calendars/[string calendarId]/events/quickAdd(map headers = {}, *CalendarEventsQuickAddQueries queries) returns Event|error { 257 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/quickAdd`; 258 | resourcePath = resourcePath + check getPathForQueryParam(queries); 259 | http:Request request = new; 260 | return self.clientEp->post(resourcePath, request, headers); 261 | } 262 | 263 | # Returns an event based on its Google Calendar ID. To retrieve an event using its iCalendar ID, call the events.list method using the iCalUID parameter. 264 | # 265 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 266 | # + eventId - Event identifier 267 | # + headers - Headers to be sent with the request 268 | # + queries - Queries to be sent with the request 269 | # + return - A `gcalendar:Event` if successful, otherwise an error 270 | resource isolated function get calendars/[string calendarId]/events/[string eventId](map headers = {}, *CalendarEventsGetQueries queries) returns Event|error { 271 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/${getEncodedUri(eventId)}`; 272 | resourcePath = resourcePath + check getPathForQueryParam(queries); 273 | return self.clientEp->get(resourcePath, headers); 274 | } 275 | 276 | # Updates an event. 277 | # 278 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 279 | # + eventId - Event identifier 280 | # + headers - Headers to be sent with the request 281 | # + queries - Queries to be sent with the request 282 | # + payload - Data required to update the event 283 | # + return - A `gcalendar:Event` if successful, otherwise an error 284 | resource isolated function put calendars/[string calendarId]/events/[string eventId](Event payload, map headers = {}, *CalendarEventsUpdateQueries queries) returns Event|error { 285 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/${getEncodedUri(eventId)}`; 286 | resourcePath = resourcePath + check getPathForQueryParam(queries); 287 | http:Request request = new; 288 | json jsonBody = jsondata:toJson(payload); 289 | request.setPayload(jsonBody, "application/json"); 290 | return self.clientEp->put(resourcePath, request, headers); 291 | } 292 | 293 | # Deletes an event. 294 | # 295 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 296 | # + eventId - Event identifier 297 | # + headers - Headers to be sent with the request 298 | # + queries - Queries to be sent with the request 299 | # + return - if successful `()`, otherwise an error 300 | resource isolated function delete calendars/[string calendarId]/events/[string eventId](map headers = {}, *CalendarEventsDeleteQueries queries) returns error? { 301 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/${getEncodedUri(eventId)}`; 302 | resourcePath = resourcePath + check getPathForQueryParam(queries); 303 | return self.clientEp->delete(resourcePath, headers = headers); 304 | } 305 | 306 | # Updates an event. This method supports patch semantics. 307 | # 308 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 309 | # + eventId - Event identifier 310 | # + headers - Headers to be sent with the request 311 | # + queries - Queries to be sent with the request 312 | # + payload - Data required to update the event 313 | # + return - A `gcalendar:Event` if successful, otherwise an error 314 | resource isolated function patch calendars/[string calendarId]/events/[string eventId](Event payload, map headers = {}, *CalendarEventsPatchQueries queries) returns Event|error { 315 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/${getEncodedUri(eventId)}`; 316 | resourcePath = resourcePath + check getPathForQueryParam(queries); 317 | http:Request request = new; 318 | json jsonBody = jsondata:toJson(payload); 319 | request.setPayload(jsonBody, "application/json"); 320 | return self.clientEp->patch(resourcePath, request, headers); 321 | } 322 | 323 | # Returns instances of the specified recurring event. 324 | # 325 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 326 | # + eventId - Recurring event identifier 327 | # + headers - Headers to be sent with the request 328 | # + queries - Queries to be sent with the request 329 | # + return - A `gcalendar:Events` if successful, otherwise an error 330 | resource isolated function get calendars/[string calendarId]/events/[string eventId]/instances(map headers = {}, *CalendarEventsInstancesQueries queries) returns Events|error { 331 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/${getEncodedUri(eventId)}/instances`; 332 | resourcePath = resourcePath + check getPathForQueryParam(queries); 333 | return self.clientEp->get(resourcePath, headers); 334 | } 335 | 336 | # Moves an event to another calendar, i.e. changes an event's organizer. 337 | # 338 | # + calendarId - Calendar identifier of the source calendar where the event currently is on 339 | # + eventId - Event identifier 340 | # + headers - Headers to be sent with the request 341 | # + queries - Queries to be sent with the request 342 | # + return - A `gcalendar:Event` if successful, otherwise an error 343 | resource isolated function post calendars/[string calendarId]/events/[string eventId]/move(map headers = {}, *CalendarEventsMoveQueries queries) returns Event|error { 344 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/${getEncodedUri(eventId)}/move`; 345 | resourcePath = resourcePath + check getPathForQueryParam(queries); 346 | http:Request request = new; 347 | return self.clientEp->post(resourcePath, request, headers); 348 | } 349 | 350 | # Returns the color definitions for calendars and events. 351 | # 352 | # + headers - Headers to be sent with the request 353 | # + queries - Queries to be sent with the request 354 | # + return - A `gcalendar:Colors` if successful, otherwise an error 355 | resource isolated function get colors(map headers = {}, *CalendarColorsGetQueries queries) returns Colors|error { 356 | string resourcePath = string `/colors`; 357 | resourcePath = resourcePath + check getPathForQueryParam(queries); 358 | return self.clientEp->get(resourcePath, headers); 359 | } 360 | 361 | # Returns free/busy information for a set of calendars. 362 | # 363 | # + headers - Headers to be sent with the request 364 | # + queries - Queries to be sent with the request 365 | # + payload - Data required to return free/busy information 366 | # + return - A `gcalendar:FreeBusyResponse` if successful, otherwise an error 367 | resource isolated function post freeBusy(FreeBusyRequest payload, map headers = {}, *CalendarFreebusyQueryQueries queries) returns FreeBusyResponse|error { 368 | string resourcePath = string `/freeBusy`; 369 | resourcePath = resourcePath + check getPathForQueryParam(queries); 370 | http:Request request = new; 371 | json jsonBody = jsondata:toJson(payload); 372 | request.setPayload(jsonBody, "application/json"); 373 | return self.clientEp->post(resourcePath, request, headers); 374 | } 375 | 376 | # Returns the calendars on the user's calendar list. 377 | # 378 | # + headers - Headers to be sent with the request 379 | # + queries - Queries to be sent with the request 380 | # + return - A `gcalendar:CalendarList` if successful, otherwise an error 381 | resource isolated function get users/me/calendarList(map headers = {}, *CalendarCalendarListListQueries queries) returns CalendarList|error { 382 | string resourcePath = string `/users/me/calendarList`; 383 | resourcePath = resourcePath + check getPathForQueryParam(queries); 384 | return self.clientEp->get(resourcePath, headers); 385 | } 386 | 387 | # Inserts an existing calendar into the user's calendar list. 388 | # 389 | # + headers - Headers to be sent with the request 390 | # + queries - Queries to be sent with the request 391 | # + payload - Data required to identify the calendar 392 | # + return - A `gcalendar:CalendarListEntry` if successful, otherwise an error 393 | resource isolated function post users/me/calendarList(CalendarListEntry payload, map headers = {}, *CalendarCalendarListInsertQueries queries) returns CalendarListEntry|error { 394 | string resourcePath = string `/users/me/calendarList`; 395 | resourcePath = resourcePath + check getPathForQueryParam(queries); 396 | http:Request request = new; 397 | json jsonBody = jsondata:toJson(payload); 398 | request.setPayload(jsonBody, "application/json"); 399 | return self.clientEp->post(resourcePath, request, headers); 400 | } 401 | 402 | # Returns a calendar from the user's calendar list. 403 | # 404 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 405 | # + headers - Headers to be sent with the request 406 | # + queries - Queries to be sent with the request 407 | # + return - A `gcalendar:CalendarListEntry` if successful, otherwise an error 408 | resource isolated function get users/me/calendarList/[string calendarId](map headers = {}, *CalendarCalendarListGetQueries queries) returns CalendarListEntry|error { 409 | string resourcePath = string `/users/me/calendarList/${getEncodedUri(calendarId)}`; 410 | resourcePath = resourcePath + check getPathForQueryParam(queries); 411 | return self.clientEp->get(resourcePath, headers); 412 | } 413 | 414 | # Updates an existing calendar on the user's calendar list. 415 | # 416 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 417 | # + headers - Headers to be sent with the request 418 | # + queries - Queries to be sent with the request 419 | # + payload - Data required to update an existing calendar entry on the user's calendar list 420 | # + return - A `gcalendar:CalendarListEntry` if successful, otherwise an error 421 | resource isolated function put users/me/calendarList/[string calendarId](CalendarListEntry payload, map headers = {}, *CalendarCalendarListUpdateQueries queries) returns CalendarListEntry|error { 422 | string resourcePath = string `/users/me/calendarList/${getEncodedUri(calendarId)}`; 423 | resourcePath = resourcePath + check getPathForQueryParam(queries); 424 | http:Request request = new; 425 | json jsonBody = jsondata:toJson(payload); 426 | request.setPayload(jsonBody, "application/json"); 427 | return self.clientEp->put(resourcePath, request, headers); 428 | } 429 | 430 | # Removes a calendar from the user's calendar list. 431 | # 432 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 433 | # + headers - Headers to be sent with the request 434 | # + queries - Queries to be sent with the request 435 | # + return - If successful `()`, otherwise an error 436 | resource isolated function delete users/me/calendarList/[string calendarId](map headers = {}, *CalendarCalendarListDeleteQueries queries) returns error? { 437 | string resourcePath = string `/users/me/calendarList/${getEncodedUri(calendarId)}`; 438 | resourcePath = resourcePath + check getPathForQueryParam(queries); 439 | return self.clientEp->delete(resourcePath, headers = headers); 440 | } 441 | 442 | # Updates an existing calendar on the user's calendar list. This method supports patch semantics. 443 | # 444 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword 445 | # + headers - Headers to be sent with the request 446 | # + queries - Queries to be sent with the request 447 | # + payload - Data required to update an existing calendar entry on the user's calendar list 448 | # + return - A `gcalendar:CalendarListEntry` if successful, otherwise an error 449 | resource isolated function patch users/me/calendarList/[string calendarId](CalendarListEntry payload, map headers = {}, *CalendarCalendarListPatchQueries queries) returns CalendarListEntry|error { 450 | string resourcePath = string `/users/me/calendarList/${getEncodedUri(calendarId)}`; 451 | resourcePath = resourcePath + check getPathForQueryParam(queries); 452 | http:Request request = new; 453 | json jsonBody = jsondata:toJson(payload); 454 | request.setPayload(jsonBody, "application/json"); 455 | return self.clientEp->patch(resourcePath, request, headers); 456 | } 457 | } 458 | -------------------------------------------------------------------------------- /ballerina/modules/oas/client.bal: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. 2 | // 3 | // WSO2 LLC. licenses this file to you under the Apache License, 4 | // Version 2.0 (the "License"); you may not use this file except 5 | // in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, 11 | // software distributed under the License is distributed on an 12 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | // KIND, either express or implied. See the License for the 14 | // specific language governing permissions and limitations 15 | // under the License. 16 | 17 | // AUTO-GENERATED FILE. DO NOT MODIFY. 18 | // This file is auto-generated by the Ballerina OpenAPI tool. 19 | 20 | import ballerina/http; 21 | 22 | # Manipulates events and other calendar data. 23 | public isolated client class Client { 24 | final http:Client clientEp; 25 | # Gets invoked to initialize the `connector`. 26 | # 27 | # + config - The configurations to be used when initializing the `connector` 28 | # + serviceUrl - URL of the target service 29 | # + return - An error if connector initialization failed 30 | public isolated function init(ConnectionConfig config, string serviceUrl = "https://www.googleapis.com/calendar/v3") returns error? { 31 | http:ClientConfiguration httpClientConfig = {auth: config.auth, httpVersion: config.httpVersion, timeout: config.timeout, forwarded: config.forwarded, poolConfig: config.poolConfig, compression: config.compression, circuitBreaker: config.circuitBreaker, retryConfig: config.retryConfig, validation: config.validation}; 32 | do { 33 | if config.http1Settings is ClientHttp1Settings { 34 | ClientHttp1Settings settings = check config.http1Settings.ensureType(ClientHttp1Settings); 35 | httpClientConfig.http1Settings = {...settings}; 36 | } 37 | if config.http2Settings is http:ClientHttp2Settings { 38 | httpClientConfig.http2Settings = check config.http2Settings.ensureType(http:ClientHttp2Settings); 39 | } 40 | if config.cache is http:CacheConfig { 41 | httpClientConfig.cache = check config.cache.ensureType(http:CacheConfig); 42 | } 43 | if config.responseLimits is http:ResponseLimitConfigs { 44 | httpClientConfig.responseLimits = check config.responseLimits.ensureType(http:ResponseLimitConfigs); 45 | } 46 | if config.secureSocket is http:ClientSecureSocket { 47 | httpClientConfig.secureSocket = check config.secureSocket.ensureType(http:ClientSecureSocket); 48 | } 49 | if config.proxy is http:ProxyConfig { 50 | httpClientConfig.proxy = check config.proxy.ensureType(http:ProxyConfig); 51 | } 52 | } 53 | http:Client httpEp = check new (serviceUrl, httpClientConfig); 54 | self.clientEp = httpEp; 55 | return; 56 | } 57 | 58 | # Deletes a secondary calendar. Use calendars.clear for clearing all events on primary calendars. 59 | # 60 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 61 | # + headers - Headers to be sent with the request 62 | # + queries - Queries to be sent with the request 63 | # + return - If successful `()`, otherwise an error 64 | resource isolated function delete calendars/[string calendarId](map headers = {}, *DeleteCalendarQueries queries) returns error? { 65 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}`; 66 | resourcePath = resourcePath + check getPathForQueryParam(queries); 67 | return self.clientEp->delete(resourcePath, headers = headers); 68 | } 69 | 70 | # Deletes an access control rule. 71 | # 72 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 73 | # + ruleId - ACL rule identifier. 74 | # + headers - Headers to be sent with the request 75 | # + queries - Queries to be sent with the request 76 | # + return - If successful `()`, otherwise an error 77 | resource isolated function delete calendars/[string calendarId]/acl/[string ruleId](map headers = {}, *CalendarAclDeleteQueries queries) returns error? { 78 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/acl/${getEncodedUri(ruleId)}`; 79 | resourcePath = resourcePath + check getPathForQueryParam(queries); 80 | return self.clientEp->delete(resourcePath, headers = headers); 81 | } 82 | 83 | # Deletes an event. 84 | # 85 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 86 | # + eventId - Event identifier. 87 | # + headers - Headers to be sent with the request 88 | # + queries - Queries to be sent with the request 89 | # + return - if successful `()`, otherwise an error 90 | resource isolated function delete calendars/[string calendarId]/events/[string eventId](map headers = {}, *CalendarEventsDeleteQueries queries) returns error? { 91 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/${getEncodedUri(eventId)}`; 92 | resourcePath = resourcePath + check getPathForQueryParam(queries); 93 | return self.clientEp->delete(resourcePath, headers = headers); 94 | } 95 | 96 | # Removes a calendar from the user's calendar list. 97 | # 98 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 99 | # + headers - Headers to be sent with the request 100 | # + queries - Queries to be sent with the request 101 | # + return - If successful `()`, otherwise an error 102 | resource isolated function delete users/me/calendarList/[string calendarId](map headers = {}, *CalendarCalendarlistDeleteQueries queries) returns error? { 103 | string resourcePath = string `/users/me/calendarList/${getEncodedUri(calendarId)}`; 104 | resourcePath = resourcePath + check getPathForQueryParam(queries); 105 | return self.clientEp->delete(resourcePath, headers = headers); 106 | } 107 | 108 | # Returns metadata for a calendar. 109 | # 110 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 111 | # + headers - Headers to be sent with the request 112 | # + queries - Queries to be sent with the request 113 | # + return - A `gcalendar:Calendar` if successful, otherwise an error 114 | resource isolated function get calendars/[string calendarId](map headers = {}, *CalendarCalendarsGetQueries queries) returns Calendar|error { 115 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}`; 116 | resourcePath = resourcePath + check getPathForQueryParam(queries); 117 | return self.clientEp->get(resourcePath, headers); 118 | } 119 | 120 | # Returns the rules in the access control list for the calendar. 121 | # 122 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 123 | # + headers - Headers to be sent with the request 124 | # + queries - Queries to be sent with the request 125 | # + return - A `gcalendar:Acl` if successful, otherwise an error 126 | resource isolated function get calendars/[string calendarId]/acl(map headers = {}, *CalendarAclListQueries queries) returns Acl|error { 127 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/acl`; 128 | resourcePath = resourcePath + check getPathForQueryParam(queries); 129 | return self.clientEp->get(resourcePath, headers); 130 | } 131 | 132 | # Returns an access control rule. 133 | # 134 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 135 | # + ruleId - ACL rule identifier. 136 | # + headers - Headers to be sent with the request 137 | # + queries - Queries to be sent with the request 138 | # + return - A `gcalendar:AclRule` if successful, otherwise an error 139 | resource isolated function get calendars/[string calendarId]/acl/[string ruleId](map headers = {}, *CalendarAclGetQueries queries) returns AclRule|error { 140 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/acl/${getEncodedUri(ruleId)}`; 141 | resourcePath = resourcePath + check getPathForQueryParam(queries); 142 | return self.clientEp->get(resourcePath, headers); 143 | } 144 | 145 | # Returns events on the specified calendar. 146 | # 147 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 148 | # + headers - Headers to be sent with the request 149 | # + queries - Queries to be sent with the request 150 | # + return - A `gcalendar:Events` if successful, otherwise an error 151 | resource isolated function get calendars/[string calendarId]/events(map headers = {}, *CalendarEventsListQueries queries) returns Events|error { 152 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events`; 153 | map queryParamEncoding = {"eventTypes": {style: FORM, explode: true}, "privateExtendedProperty": {style: FORM, explode: true}, "sharedExtendedProperty": {style: FORM, explode: true}}; 154 | resourcePath = resourcePath + check getPathForQueryParam(queries, queryParamEncoding); 155 | return self.clientEp->get(resourcePath, headers); 156 | } 157 | 158 | # Returns an event based on its Google Calendar ID. To retrieve an event using its iCalendar ID, call the events.list method using the iCalUID parameter. 159 | # 160 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 161 | # + eventId - Event identifier. 162 | # + headers - Headers to be sent with the request 163 | # + queries - Queries to be sent with the request 164 | # + return - A `gcalendar:Event` if successful, otherwise an error 165 | resource isolated function get calendars/[string calendarId]/events/[string eventId](map headers = {}, *CalendarEventsGetQueries queries) returns Event|error { 166 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/${getEncodedUri(eventId)}`; 167 | resourcePath = resourcePath + check getPathForQueryParam(queries); 168 | return self.clientEp->get(resourcePath, headers); 169 | } 170 | 171 | # Returns instances of the specified recurring event. 172 | # 173 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 174 | # + eventId - Recurring event identifier. 175 | # + headers - Headers to be sent with the request 176 | # + queries - Queries to be sent with the request 177 | # + return - A `gcalendar:Events` if successful, otherwise an error 178 | resource isolated function get calendars/[string calendarId]/events/[string eventId]/instances(map headers = {}, *CalendarEventsInstancesQueries queries) returns Events|error { 179 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/${getEncodedUri(eventId)}/instances`; 180 | resourcePath = resourcePath + check getPathForQueryParam(queries); 181 | return self.clientEp->get(resourcePath, headers); 182 | } 183 | 184 | # Returns the color definitions for calendars and events. 185 | # 186 | # + headers - Headers to be sent with the request 187 | # + queries - Queries to be sent with the request 188 | # + return - A `gcalendar:Colors` if successful, otherwise an error 189 | resource isolated function get colors(map headers = {}, *CalendarColorsGetQueries queries) returns Colors|error { 190 | string resourcePath = string `/colors`; 191 | resourcePath = resourcePath + check getPathForQueryParam(queries); 192 | return self.clientEp->get(resourcePath, headers); 193 | } 194 | 195 | # Returns the calendars on the user's calendar list. 196 | # 197 | # + headers - Headers to be sent with the request 198 | # + queries - Queries to be sent with the request 199 | # + return - A `gcalendar:CalendarList` if successful, otherwise an error 200 | resource isolated function get users/me/calendarList(map headers = {}, *CalendarCalendarlistListQueries queries) returns CalendarList|error { 201 | string resourcePath = string `/users/me/calendarList`; 202 | resourcePath = resourcePath + check getPathForQueryParam(queries); 203 | return self.clientEp->get(resourcePath, headers); 204 | } 205 | 206 | # Returns a calendar from the user's calendar list. 207 | # 208 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 209 | # + headers - Headers to be sent with the request 210 | # + queries - Queries to be sent with the request 211 | # + return - A `gcalendar:CalendarListEntry` if successful, otherwise an error 212 | resource isolated function get users/me/calendarList/[string calendarId](map headers = {}, *CalendarCalendarlistGetQueries queries) returns CalendarListEntry|error { 213 | string resourcePath = string `/users/me/calendarList/${getEncodedUri(calendarId)}`; 214 | resourcePath = resourcePath + check getPathForQueryParam(queries); 215 | return self.clientEp->get(resourcePath, headers); 216 | } 217 | 218 | # Updates metadata for a calendar. This method supports patch semantics. 219 | # 220 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 221 | # + headers - Headers to be sent with the request 222 | # + queries - Queries to be sent with the request 223 | # + payload - Data required to update the calendar. 224 | # + return - A `gcalendar:Calendar` if successful, otherwise an error 225 | resource isolated function patch calendars/[string calendarId](Calendar payload, map headers = {}, *CalendarCalendarsPatchQueries queries) returns Calendar|error { 226 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}`; 227 | resourcePath = resourcePath + check getPathForQueryParam(queries); 228 | http:Request request = new; 229 | json jsonBody = payload.toJson(); 230 | request.setPayload(jsonBody, "application/json"); 231 | return self.clientEp->patch(resourcePath, request, headers); 232 | } 233 | 234 | # Updates an access control rule. This method supports patch semantics. 235 | # 236 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 237 | # + ruleId - ACL rule identifier. 238 | # + headers - Headers to be sent with the request 239 | # + queries - Queries to be sent with the request 240 | # + payload - Data required to update access permissions for the calendar 241 | # + return - A `gcalendar:AclRule` if successful, otherwise an error 242 | resource isolated function patch calendars/[string calendarId]/acl/[string ruleId](AclRule payload, map headers = {}, *CalendarAclPatchQueries queries) returns AclRule|error { 243 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/acl/${getEncodedUri(ruleId)}`; 244 | resourcePath = resourcePath + check getPathForQueryParam(queries); 245 | http:Request request = new; 246 | json jsonBody = payload.toJson(); 247 | request.setPayload(jsonBody, "application/json"); 248 | return self.clientEp->patch(resourcePath, request, headers); 249 | } 250 | 251 | # Updates an event. This method supports patch semantics. 252 | # 253 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 254 | # + eventId - Event identifier. 255 | # + headers - Headers to be sent with the request 256 | # + queries - Queries to be sent with the request 257 | # + payload - Data required to update the event. 258 | # + return - A `gcalendar:Event` if successful, otherwise an error 259 | resource isolated function patch calendars/[string calendarId]/events/[string eventId](Event payload, map headers = {}, *CalendarEventsPatchQueries queries) returns Event|error { 260 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/${getEncodedUri(eventId)}`; 261 | resourcePath = resourcePath + check getPathForQueryParam(queries); 262 | http:Request request = new; 263 | json jsonBody = payload.toJson(); 264 | request.setPayload(jsonBody, "application/json"); 265 | return self.clientEp->patch(resourcePath, request, headers); 266 | } 267 | 268 | # Updates an existing calendar on the user's calendar list. This method supports patch semantics. 269 | # 270 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 271 | # + headers - Headers to be sent with the request 272 | # + queries - Queries to be sent with the request 273 | # + payload - Data required to update an existing calendar entry on the user's calendar list 274 | # + return - A `gcalendar:CalendarListEntry` if successful, otherwise an error 275 | resource isolated function patch users/me/calendarList/[string calendarId](CalendarListEntry payload, map headers = {}, *CalendarCalendarlistPatchQueries queries) returns CalendarListEntry|error { 276 | string resourcePath = string `/users/me/calendarList/${getEncodedUri(calendarId)}`; 277 | resourcePath = resourcePath + check getPathForQueryParam(queries); 278 | http:Request request = new; 279 | json jsonBody = payload.toJson(); 280 | request.setPayload(jsonBody, "application/json"); 281 | return self.clientEp->patch(resourcePath, request, headers); 282 | } 283 | 284 | # Creates a secondary calendar. 285 | # 286 | # + headers - Headers to be sent with the request 287 | # + queries - Queries to be sent with the request 288 | # + payload - Data required to create the calendar. 289 | # + return - A `gcalendar:Calendar` if successful, otherwise an error 290 | resource isolated function post calendars(Calendar payload, map headers = {}, *CreateCalendarQueries queries) returns Calendar|error { 291 | string resourcePath = string `/calendars`; 292 | resourcePath = resourcePath + check getPathForQueryParam(queries); 293 | http:Request request = new; 294 | json jsonBody = payload.toJson(); 295 | request.setPayload(jsonBody, "application/json"); 296 | return self.clientEp->post(resourcePath, request, headers); 297 | } 298 | 299 | # Creates an access control rule. 300 | # 301 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 302 | # + headers - Headers to be sent with the request 303 | # + queries - Queries to be sent with the request 304 | # + payload - Data required to create access permissions for the calendar. 305 | # + return - A `gcalendar:AclRule` if successful, otherwise an error 306 | resource isolated function post calendars/[string calendarId]/acl(AclRule payload, map headers = {}, *CalendarAclInsertQueries queries) returns AclRule|error { 307 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/acl`; 308 | resourcePath = resourcePath + check getPathForQueryParam(queries); 309 | http:Request request = new; 310 | json jsonBody = payload.toJson(); 311 | request.setPayload(jsonBody, "application/json"); 312 | return self.clientEp->post(resourcePath, request, headers); 313 | } 314 | 315 | # Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account. 316 | # 317 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 318 | # + headers - Headers to be sent with the request 319 | # + queries - Queries to be sent with the request 320 | # + return - If successful `()`, otherwise an error 321 | resource isolated function post calendars/[string calendarId]/clear(map headers = {}, *CalendarCalendarsClearQueries queries) returns error? { 322 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/clear`; 323 | resourcePath = resourcePath + check getPathForQueryParam(queries); 324 | http:Request request = new; 325 | return self.clientEp->post(resourcePath, request, headers); 326 | } 327 | 328 | # Creates an event. 329 | # 330 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 331 | # + headers - Headers to be sent with the request 332 | # + queries - Queries to be sent with the request 333 | # + payload - Data required to create an event. 334 | # + return - A `gcalendar:Event` if successful, otherwise an error 335 | resource isolated function post calendars/[string calendarId]/events(Event payload, map headers = {}, *CalendarEventsInsertQueries queries) returns Event|error { 336 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events`; 337 | resourcePath = resourcePath + check getPathForQueryParam(queries); 338 | http:Request request = new; 339 | json jsonBody = payload.toJson(); 340 | request.setPayload(jsonBody, "application/json"); 341 | return self.clientEp->post(resourcePath, request, headers); 342 | } 343 | 344 | resource isolated function post calendars/[string calendarId]/events/'import(Event payload, map headers = {}, *CalendarEventsImportQueries queries) returns Event|error { 345 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/import`; 346 | resourcePath = resourcePath + check getPathForQueryParam(queries); 347 | http:Request request = new; 348 | json jsonBody = payload.toJson(); 349 | request.setPayload(jsonBody, "application/json"); 350 | return self.clientEp->post(resourcePath, request, headers); 351 | } 352 | 353 | # Moves an event to another calendar, i.e. changes an event's organizer. 354 | # 355 | # + calendarId - Calendar identifier of the source calendar where the event currently is on. 356 | # + eventId - Event identifier. 357 | # + headers - Headers to be sent with the request 358 | # + queries - Queries to be sent with the request 359 | # + return - A `gcalendar:Event` if successful, otherwise an error 360 | resource isolated function post calendars/[string calendarId]/events/[string eventId]/move(map headers = {}, *CalendarEventsMoveQueries queries) returns Event|error { 361 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/${getEncodedUri(eventId)}/move`; 362 | resourcePath = resourcePath + check getPathForQueryParam(queries); 363 | http:Request request = new; 364 | return self.clientEp->post(resourcePath, request, headers); 365 | } 366 | 367 | # Creates an event based on a simple text string. 368 | # 369 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 370 | # + headers - Headers to be sent with the request 371 | # + queries - Queries to be sent with the request 372 | # + return - A `gcalendar:Event` if successful, otherwise an error 373 | resource isolated function post calendars/[string calendarId]/events/quickAdd(map headers = {}, *CalendarEventsQuickaddQueries queries) returns Event|error { 374 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/quickAdd`; 375 | resourcePath = resourcePath + check getPathForQueryParam(queries); 376 | http:Request request = new; 377 | return self.clientEp->post(resourcePath, request, headers); 378 | } 379 | 380 | # Returns free/busy information for a set of calendars. 381 | # 382 | # + headers - Headers to be sent with the request 383 | # + queries - Queries to be sent with the request 384 | # + payload - Data required to return free/busy information 385 | # + return - A `gcalendar:FreeBusyResponse` if successful, otherwise an error 386 | resource isolated function post freeBusy(FreeBusyRequest payload, map headers = {}, *CalendarFreebusyQueryQueries queries) returns FreeBusyResponse|error { 387 | string resourcePath = string `/freeBusy`; 388 | resourcePath = resourcePath + check getPathForQueryParam(queries); 389 | http:Request request = new; 390 | json jsonBody = payload.toJson(); 391 | request.setPayload(jsonBody, "application/json"); 392 | return self.clientEp->post(resourcePath, request, headers); 393 | } 394 | 395 | # Inserts an existing calendar into the user's calendar list. 396 | # 397 | # + headers - Headers to be sent with the request 398 | # + queries - Queries to be sent with the request 399 | # + payload - Data required to identify the calendar 400 | # + return - A `gcalendar:CalendarListEntry` if successful, otherwise an error 401 | resource isolated function post users/me/calendarList(CalendarListEntry payload, map headers = {}, *CalendarCalendarlistInsertQueries queries) returns CalendarListEntry|error { 402 | string resourcePath = string `/users/me/calendarList`; 403 | resourcePath = resourcePath + check getPathForQueryParam(queries); 404 | http:Request request = new; 405 | json jsonBody = payload.toJson(); 406 | request.setPayload(jsonBody, "application/json"); 407 | return self.clientEp->post(resourcePath, request, headers); 408 | } 409 | 410 | # Updates metadata for a calendar. 411 | # 412 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 413 | # + headers - Headers to be sent with the request 414 | # + queries - Queries to be sent with the request 415 | # + payload - Data required to update the calendar. 416 | # + return - A `gcalendar:Calendar` if successful, otherwise an error 417 | resource isolated function put calendars/[string calendarId](Calendar payload, map headers = {}, *CalendarCalendarsUpdateQueries queries) returns Calendar|error { 418 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}`; 419 | resourcePath = resourcePath + check getPathForQueryParam(queries); 420 | http:Request request = new; 421 | json jsonBody = payload.toJson(); 422 | request.setPayload(jsonBody, "application/json"); 423 | return self.clientEp->put(resourcePath, request, headers); 424 | } 425 | 426 | # Updates an access control rule. 427 | # 428 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 429 | # + ruleId - ACL rule identifier. 430 | # + headers - Headers to be sent with the request 431 | # + queries - Queries to be sent with the request 432 | # + payload - Data required to update access permissions for the calendar 433 | # + return - A `gcalendar:AclRule` if successful, otherwise an error 434 | resource isolated function put calendars/[string calendarId]/acl/[string ruleId](AclRule payload, map headers = {}, *CalendarAclUpdateQueries queries) returns AclRule|error { 435 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/acl/${getEncodedUri(ruleId)}`; 436 | resourcePath = resourcePath + check getPathForQueryParam(queries); 437 | http:Request request = new; 438 | json jsonBody = payload.toJson(); 439 | request.setPayload(jsonBody, "application/json"); 440 | return self.clientEp->put(resourcePath, request, headers); 441 | } 442 | 443 | # Updates an event. 444 | # 445 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 446 | # + eventId - Event identifier. 447 | # + headers - Headers to be sent with the request 448 | # + queries - Queries to be sent with the request 449 | # + payload - Data required to update the event. 450 | # + return - A `gcalendar:Event` if successful, otherwise an error 451 | resource isolated function put calendars/[string calendarId]/events/[string eventId](Event payload, map headers = {}, *CalendarEventsUpdateQueries queries) returns Event|error { 452 | string resourcePath = string `/calendars/${getEncodedUri(calendarId)}/events/${getEncodedUri(eventId)}`; 453 | resourcePath = resourcePath + check getPathForQueryParam(queries); 454 | http:Request request = new; 455 | json jsonBody = payload.toJson(); 456 | request.setPayload(jsonBody, "application/json"); 457 | return self.clientEp->put(resourcePath, request, headers); 458 | } 459 | 460 | # Updates an existing calendar on the user's calendar list. 461 | # 462 | # + calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword. 463 | # + headers - Headers to be sent with the request 464 | # + queries - Queries to be sent with the request 465 | # + payload - Data required to update an existing calendar entry on the user's calendar list 466 | # + return - A `gcalendar:CalendarListEntry` if successful, otherwise an error 467 | resource isolated function put users/me/calendarList/[string calendarId](CalendarListEntry payload, map headers = {}, *CalendarCalendarlistUpdateQueries queries) returns CalendarListEntry|error { 468 | string resourcePath = string `/users/me/calendarList/${getEncodedUri(calendarId)}`; 469 | resourcePath = resourcePath + check getPathForQueryParam(queries); 470 | http:Request request = new; 471 | json jsonBody = payload.toJson(); 472 | request.setPayload(jsonBody, "application/json"); 473 | return self.clientEp->put(resourcePath, request, headers); 474 | } 475 | } 476 | --------------------------------------------------------------------------------