ballerinax/googleapis.drive.listener Ballerina library

2.1.0

Overview

This module generates a notification when the following events occur in the drive.

  • Creation of a new file
  • The creation of a new file in a specific folder
  • Creation of a new folder
  • Creation of a new folder in a specific folder
  • File update
  • File deletion
  • File deletion in a specific folder
  • Folder deletion
  • Folder deletion in a specific folder

This module supports Google Drive API v3.

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

Prerequisites

If you fail to verify or set up, see documentation for domain verification process.

Quickstart

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

Step 1: Import listener

Import the Google Drive Listener module to your Ballerina program as follows.

Copy
import ballerinax/googleapis.drive;
import ballerinax/googleapis.drive.'listener as listen;

Step 2: Create a new listener instance

Initialize the Google Drive configuration as follows.

Copy
drive:ConnectionConfig clientConfig = {
    auth: {
        clientId: clientId,
        clientSecret: clientSecret,
        refreshUrl: refreshUrl,
        refreshToken: refreshToken
    }
};

listen:ListenerConfiguration listenerConfig = {
    port: 9090,
    callbackURL: callbackURL,
    domainVerificationFileContent : domainVerificationFileContent,
    clientConfiguration: clientConfig
};

listener listen:DriveEventListener gDrivelistener = new (configuration);

Step 3: Define Ballerina service with the listener

Start the listener as a service.

Copy
service / on gDrivelistener {
    isolated remote function onFileCreate(Change changeInfo) returns error? {
        log:printInfo("Trigger > onFileCreate > changeInfo : ", changeInfo);     
    }
}

You can find a list of samples here

NOTE: If an error occurs at function implementation, the HTTP client returns the Status 500 error. If no error occurs and the user logic is successfully executed, there HTTP client returns status 200 OK.

If the user logic in listener remote operations includes heavy processing, you may face HTTP timeout issues. To overcome this, you should use asynchronous processing when the operation includes heavy processing.

Copy
listener listen:Listener gDrivelistener = new (configuration);

service / on gDrivelistener {
    remote function onFileCreate(listen:Change event) returns error? {
        _ = @strand { thread: "any" } start userLogic(event);
    }
}

function userLogic(listen:Change event) returns error? {
    // Write your logic here
}

Import

import ballerinax/googleapis.drive.listener;Copy

Metadata

Released date: over 2 years ago

Version: 2.1.0

License: Apache-2.0


Compatibility

Platform: java11

Ballerina version: slbeta6


Pull count

Total: 6385

Current verison: 284


Weekly downloads


Source repository


Keywords

Content & Files/File Management & Storage

Cost/Free

Vendor/Google


Contributors

Other versions

See more...