Example 1: Using a Timer Trigger to Periodically Download Files from an OBS Bucket

Scenario

This example guides you through the procedure for creating a Python 2.7 function and associating a timer trigger with it to periodically download files from an OBS bucket.

For details about how to call APIs, see Calling APIs.

Prerequisites

General Procedure

Create a FunctionGraph function and associate a timer trigger with it to periodically download files from an OBS bucket. The procedure is as follows:

  1. Creating a Function: Create a function for downloading files.
  2. Modifying the Metadata of a Function: Modify the OBS address, OBS bucket name, and file name in the function configuration.
  3. Executing a Function Synchronously: Verify whether the function can successfully download files from the OBS bucket.
  4. Creating a Trigger: Create a timer trigger to periodically download files.

Step 1: Create a Function for Downloading Files from OBS

URI: POST /v2/{project_id}/fgs/functions

For details, see Creating a Function.

Step 2: Modify the OBS Address, Bucket Name, and File Name in the Function Configurations

URI: PUT /v2/{project_id}/fgs/functions/{function_urn}/config

For details, see Modifying the Metadata of a Function.

Step 3: Test the Function

URI: POST /v2/{project_id}/fgs/functions/{function_urn}/invocations

For details, see Executing a Function Synchronously.

Step 4: Create a Timer Trigger to Periodically Download Files from OBS

URI: POST /v2/{project_id}/fgs/triggers/{function_urn}

For details, see Creating a Trigger.