Registering APIs

This section describes how to register APIs, and manage and publish APIs generated based on data tables to the API gateways.

DLM supports the registration of RESTful APIs, including GET and POST APIs.

Configuring Basic API Information

  1. Log in to the DGC console, select a DGC instance, and click Access.

    On the displayed page, click the Workspaces tab. In the workspace list, locate the required workspace.

  1. Click Data Lake Mall of the corresponding workspace.

    Navigate to the Data Lake Mall console.

  1. Choose APIs > Register. Configure the basic information.
    Table 1 API basic info

    Parameter

    Description

    API

    An API name consists of 3 to 64 characters and starts with a letter. Only letters, digits, and underscores (_) are allowed.

    API Catalog

    An API catalog is a set of APIs with a specific function or scenario. It is the minimum organization unit of APIs in DLM and the minimum management unit of the API gateway.

    Click Select Catalog to create an API catalog or select an existing one created in Managing an API Catalog.

    Request Path

    The path for accessing an API.

    Example: /v2/{project_id}/streams.

    Protocol

    A parameter protocol is used to transmit requests. HTTP and HTTPS are supported.

    Request Mode

    HTTP defines the following request modes that can be used to send a request to the server:

    GET requests the server to return specified resources.

    POST requests the server to add a resource or perform special operations.

    Description

    A brief description of the API to be registered.

    Tag

    Tag names can include letters, digits, and underscores (_), and cannot start with underscores (_).

    Reviewer

    An owner who has permissions to review APIs.

    Click Add new to enter the Review Center page. On the displayed page, choose Reviewer Management > Add.

    Security Authentication

    Security authentication mode, which can be:

    • App Authentication: API Gateway authenticates API requests.
    • IAM Authentication: IAM authenticates API requests.
    • None-authentication: No authentication is required.

    Display Scope

    After the API is published, all users in the selected scope can view the API in the service catalog.

    • Current workspace APIs
    • Current project APIs
    • Current tenant APIs

    Access Log

    If this parameter is selected, you can view the generated API query results that will be kept for seven days on the Access Logs page.

    Min. Retention Period

    Minimum duration reserved before API unbinding. Before an API developer suspends, brings offline, or cancels the authorization of an API, the system notifies the authorized API callers and reserves at least X hours for them to unbind the API. During the retention period, the API can be used if it is not unbound. The value 0 indicates that there is no minimum retention period.

    Input parameter

    Input parameter is a set of parameters in the API request, including dynamic parameters in the resource path, query parameters in the request URI, and header parameters.

    The following is an example that describes the dynamic parameters in the resource path (request path):

    /v2/{project_id}/streams, where {project_id} is a dynamic parameter that needs to be configured.

    1. Click Add and enter project_id for Name.
    2. Set Parameter Location to PATH.
    3. Set Type to STRING.
    4. Set Example Value and Description as required.
  2. After the basic API information is complete, click Next to go to the Data Extract Logic page.

Configuring the API Parameters

After configuring basic API information, you can set API parameters. The following describes how to configure the API backend services and request parameters.

Table 2 API parameters

Parameter

Description

Protocol

A parameter protocol is used to transmit requests. HTTP and HTTPS are supported.

This parameter is used by DLM to transmit requests to the APIs to be registered.

Request Mode

HTTP defines the following request modes that can be used to send a request to the server: This parameter is used by DLM to transmit requests to the APIs to be registered.

GET requests the server to return specified resources.

POST requests the server to add a resource or perform special operations.

Backend Service Host

Backend service host is the host of the API to be registered. The value cannot start with http:// or https:// and cannot contain Path.

Backend Service Path

Backend service path is the path of the API to be registered. The path can contain parameters placed in {}, for example, /user/{userid}.

Backend Timeout (ms)

This parameter refers to the backend timeout interval.

Backend Service Parameter

The optional parameters can be placed in PATH, Header, and Query. The positions of optional parameters vary depending on the request mode. Select a parameter position as required.

Constant Parameter

Constant parameter is the fixed parameter invisible to the caller. Constant parameter does not need to be transferred during API calling. However, the background service always receives the constant parameter and parameter value defined here. This parameter applies to scenarios in which you want to set a parameter of an API to a fixed value and hide the parameter from the caller.

Testing an API

After all parameters are set, click Debug. Enter the values for parameter Value and click Debug in the lower left corner. You can view the Request and Response details on the right part of the displayed page. If the test fails, follow the instructions as prompted and restart the test. During the configuration, pay attention to the settings of the normal response example.

After the test is complete, click OK.