Creating a Template

Function

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

URI

  • URI format

    POST /v1.0/{project_id}/job_template

  • Parameter description
    Table 1 URI parameter description

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Request

  • Example request
    {
    "name": "simple_stream_sql",
    "desc": "Example of quick start",
    "sql_body": "select * from source_table"
    }
  • Parameter description
    Table 2 Request parameter description

    Parameter

    Mandatory

    Type

    Description

    name

    Yes

    String

    Template name.

    desc

    No

    String

    Template description.

    sql_body

    No

    String

    Stream SQL statement, which includes at least the following three parts: source, query, and sink.

Response

  • Example response
    {
      "message_id": "CS.10001",
      "message": "string",
      "current_time": 1533686888000,
      "payload": {
        "template_id": 0,
        "name": "IoT_example",
    "desc": "Example of quick start",
        "create_time": 1516952710040,
        "is_success": true
      }
    }
  • Parameter description
    Table 3 Response parameters

    Parameter

    Mandatory

    Type

    Description

    message_id

    No

    String

    Message type ID.

    message

    No

    String

    Message content.

    current_time

    No

    Int

    Current time, expressed by milliseconds.

    payload

    No

    None

    Information about the template to be created.

    template_id

    No

    Int

    Template ID.

    name

    No

    String

    Template name.

    desc

    No

    String

    Template description.

    create_time

    No

    Int

    Time when the template is created.

    is_success

    No

    boolean

    Whether the template is successfully created.

Status Code

Table 4 describes the status code.

Table 4 Status code

Status Code

Description

200

A template is created successfully.

400

The input parameters are invalid.

Error Code

For details, see Error Codes.