ballerinax/googleapis.drive Ballerina library

3.3.0

Overview

The connector provides the capability to programmatically manage files and folders in the Google Drive.

This module supports Google Drive API v3.

Prerequisites

Before using this connector in your Ballerina application, complete the following:

Quickstart

To use the Google Drive connector in your Ballerina application, update the .bal file as follows:

Step 1: Import the connector

Import the ballerinax/googleapis.drive module into the Ballerina projects shown below.

Copy
import ballerinax/googleapis.drive;

All the actions return a valid response or error. If the action is a success, then the requested resource is returned. If not, an error is returned.

Step 2: Create a new connector instance

Create a drive:ConnectionConfig with the OAuth2 tokens obtained, and initialize the connector with it.

Copy
onfigurable string refreshToken = ?;
onfigurable string clientId = ?;
onfigurable string clientSecret = ?;
onfigurable string refreshUrl = drive:REFRESH_URL;

rive:ConnectionConfig config = {
   auth: {
       clientId: clientId,
       clientSecret: clientSecret,
       refreshUrl: refreshUrl,
       refreshToken: refreshToken
   }
;

rive:Client driveClient = new (config);

Step 3: Invoke the connector operation

  1. Now you can use the operations available within the connector. Note that they are in the form of remote operations.

    Following is an example on how to retrieve a file using the connector.

    Get file with given file ID

    Copy
    public function main() returns error? {
        drive:File response = check driveClient->getFile(fileId);
        log:printInfo("Successfully retreived the file.");
    }
  2. Use bal run command to compile and run the Ballerina program.

You can find a list of samples here

Import

import ballerinax/googleapis.drive;Copy

Metadata

Released date: 5 months ago

Version: 3.3.0

License: Apache-2.0


Compatibility

Platform: any

Ballerina version: 2201.8.0

GraalVM compatible: Yes


Pull count

Total: 

Current verison: 9


Weekly downloads


Source repository


Keywords

Content & Files/File Management & Storage
Cost/Free
Vendor/Google

Contributors

Other versions

See more...