Querying the Job Template List

Sample Code

You can use the API to query the job template list. In this example, the query results are displayed in descending order and information about the job templates whose IDs are less than the value of cursor is displayed. Sample code is as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
import com.huaweicloud.cs.java.v1.client.ApiException;
import com.huaweicloud.cs.java.v1.TemplateApi;


TemplateApi apiInstance = new TemplateApi(apiClient);//apiClient is created when initializing a CS API client.
String xProjectId = "xProjectId_example"; // String | Project ID used for obtaining the token for the project.
Long cursor = 789L; // Long | Job template ID.
Integer limit = 56; // Integer | Maximum number of records that can be queried.
String order = "desc"; // String | Query result display. The query results can be displayed in ascending or descending order.
try {
    JobTemplateListResponse result = apiInstance.getJobTemplates(xProjectId, cursor, limit, order);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling TemplateApi#getJobTemplates");
    System.err.println(e.getResponseBody());
    e.printStackTrace();
}

Parameter Description

Table 1 Parameters

Parameter

Mandatory

Type

Description

xProjectId

Yes

String

Project ID. This parameter is used to obtain the token for the project.

cursor

No

Integer

Job template ID.

limit

No

Integer

Maximum number of records that can be queried.

order

No

String

Query result display. Value asc indicates that the query results are displayed in ascending order, and value desc indicates that the query results are displayed in descending order. The default value is desc.

Table 2 Parameters involved in JobTemplateListResponse

Parameter

Mandatory

Type

Description

messageId

No

String

Message type ID.

message

No

String

Message content.

currentTime

No

Integer

Current time, expressed by milliseconds.

payload

No

-

For details about parameter types, see Table 3.

Table 3 Parameters involved in JobTemplateListResponsePayload

Parameter

Mandatory

Type

Description

total

No

Integer

Number of records in the query result.

templates

No

List<JobTemplate>

Template name. For details about parameter types, see Table 4.

Table 4 Parameters involved in JobTemplate

Parameter

Mandatory

Type

Description

templateId

No

Integer

Template ID.

name

No

String

Template name.

desc

No

String

Template description.

createTime

No

Integer

Time when the template is created.

updateTime

No

Integer

Update time of the template.

sqlBody

No

String

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