This topic describes how to create, clone, delete, or move a function.

Prerequisites

  • A business process is created. For more information, see Create and manage business processes.
  • An exclusive resource group for DataService Studio is purchased.
    Note To run an Aviator function, you must use an exclusive resource group for DataService Studio.

Background information

DataService Studio supports Aviator functions and Python functions.
  • The feature that allows you to use a Python function as an API filter is being optimized. You cannot create, clone, or publish a Python function.
  • If you want to use a function as an API filter, we recommend that you use an Aviator function. For more information, see Create an Aviator function and use the Aviator function as a filter.

Limits

  • Before you can use a function as an API filter, you must activate DataWorks Basic Edition or a more advanced edition.
  • For the same API, the function that you use as the prefilter and the function that you use as the post-filter must be of the same type.

Create a function

  1. On the Service Development page, move the pointer over the Create icon and choose Create Function > Create Aviator Function.
    You can also find the desired business process, right-click the name of the business process, and then choose New > Function > Create Aviator Function.
  2. In the Create Aviator Function dialog box, configure the parameters. The following table describes the parameters.
    Python
    Parameter Description
    Function Name The name of the function. The name can be up to 256 characters in length.
    Function Template The template that you want to use to create the function. Set the value to AviatorScript Standard v1.
    Function Description The description of the function. The description can be up to 512 characters in length.
    Destination Folder The folder in which you want to store the function.
    Note The value of this parameter can be a business process name, a folder name, or a function category. If no business process is available, you must create a business process.
  3. Click Determine.
  4. In the Edit Code section, enter the code for the function.
  5. Configure a resource group for DataService Studio.
    Function
    1. In the right-side navigation pane of the configuration tab of the function, click Resource Group. In the Resource Group Type section of the Resource Group tab, select Exclusive Resource Group for DataService Studio for the Scheme parameter and select an exclusive resource group from the Exclusive Resource Group for DataService Studio drop-down list.
      You can select only Exclusive Resource Group for DataService Studio for the Scheme parameter.
      Note If the exclusive resource group for DataService Studio that you want to select is not displayed in the drop-down list, you can go to the Resource Groups page in the DataWorks console, and then associate the exclusive resource group with your workspace on the Exclusive Resource Groups tab. You can also click Purchase Resource Group for DataService Studio on the Resource Group tab to purchase an exclusive resource group for DataService Studio.
    2. In the Environment Configuration section, configure the Memory and Function Timeout parameters.
      We recommend that you set the Function Timeout parameter to a value that is less than or equal to 1000 for the shared resource group and less than or equal to 100 for an exclusive resource group for DataService Studio.
  6. Click the Save icon in the upper-left corner of the configuration tab of the function to save the configurations.
After the function is created, you can test and publish the function. Then, you can associate the function with an API and use the function as the prefilter or post-filter for the API.

View the information about the function

After the function is created, you can view the information about the function. The following figure shows how to view the association relationship of the function. View Association Relationship
  • In the right-side navigation pane of the configuration tab of the function, click Properties. On the Properties tab, you can view the basic information about the function, such as the function ID and creation time. A function ID uniquely identifies a function and can be used to search for the function.
  • In the right-side navigation pane of the configuration tab of the function, click Association Relationship. On the Association Relationship tab, you can view the association relationships between the function and published or unpublished APIs. We recommend that you view the association relationships before you delete or modify the function to know the APIs that will be affected by the operation.
  • In the right-side navigation pane of the configuration tab of the function, click Version. On the Version tab, you can view the details of the function version.
  • In the right-side navigation pane of the configuration tab of the function, click Resource Group. On the Resource Group tab, you can view the resource group that is used by the function. You can also change the resource group that is used by the function.

Manage functions

  1. On the Service Development page, click the business process to which the function belongs and click Function.
  2. Right-click the function name. In the shortcut menu that appears, you can select an option to clone, delete, or move the function.
    Clone
    • Select Clone. In the Clone Function dialog box, configure the Function Name and Destination Folder parameters. The function is cloned.
      Note The name of the function can be 4 to 50 characters in length and can contain letters, digits, and underscores (_). The name must start with a letter.
    • Select Delete. In the Delete Function message, click Determine. The function is deleted.
      Note If the function is referenced by specific APIs, the function fails to be deleted. In this case, you must remove the function from the filters of the APIs before you can delete the function.
    • Select Mobile. In the Modify file path dialog box, configure the Destination Folder parameter. The function is moved to the destination folder.

What to do next