Updated on 2022-12-07 GMT+08:00

Creating a Template

Function

This API is used to create a user template for the DLI service. A maximum of 100 user templates can be created.

URI

  • URI format

    POST /v1.0/{project_id}/streaming/job-templates

  • Parameter description
    Table 1 URI parameters

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID, which is used for resource isolation. For details about how to obtain its value, see Obtaining a Project ID.

Request

Table 2 Request parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Template name. The value can contain 1 to 64 characters.

desc

No

String

Template description. Length range: 0 to 512 characters.

sql_body

No

String

Stream SQL statement, which includes at least the following three parts: source, query, and sink. Length range: 0 to 2,048 characters.

tags

No

Array of Objects

Label of a Flink job template. For details, see Table 3.

job_type

No

String

Flink job template type. The default value is flink_sql_job. You can set this parameter to flink_sql_job or flink_opensource_sql_job only.

Table 3 tags parameter

Parameter

Mandatory

Type

Description

key

Yes

String

Tag key.

value

Yes

String

Tag key.

Response

Table 4 Response parameters

Parameter

Mandatory

Type

Description

is_success

No

Boolean

Indicates whether the request is successful.

message

No

String

Message content.

template

No

Object

Information about job update. For details, see Table 5.

Table 5 template parameters

Parameter

Mandatory

Type

Description

template_id

No

Long

Template ID.

name

No

String

Template name.

desc

No

String

Template description.

create_time

No

Long

Time when the template is created.

job_type

No

String

Job template type

Example Request

{
    "name": "simple_stream_sql",
    "desc": "Example of quick start",
    "sql_body": "select * from source_table"
}

Example Response

{
    "is_success": true,
    "message": "A template is created successfully.",
    "template": {
        "template_id": 0,
        "name": "IoT_example",
       "desc": "Example of quick start",
        "create_time": 1516952710040,
        "job_type": "flink_sql_job"
    }
}

Status Codes

Table 6 describes status codes.

Table 6 Status codes

Status Code

Description

200

A template is created successfully.

400

The input parameter is invalid.

Error Codes

If an error occurs when this API is invoked, the system does not return the result similar to the preceding example, but returns the error code and error information. For details, see Error Code.