Creating a Job Template
Sample Code
You can use the API to create a job template. Sample code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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.
CreateJobTemplateRequest body = new CreateJobTemplateRequest(); // CreateJobTemplateRequest | Create job template request
try {
JobTemplateCreateResponse result = apiInstance.createJobTemplate(xProjectId, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling TemplateApi#createJobTemplate");
System.err.println(e.getResponseBody());
e.printStackTrace();
}
|
Parameter Description
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| xProjectId | Yes | String | Project ID. This parameter is used to obtain the token for the project. |
| body | Yes | - | Request for creating a job template. For details about parameter types, see Table 2. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | Template name. |
| desc | No | String | Template description. |
| sqlBody | No | String | Stream SQL statement, which includes at least the following three parts: source, query, and sink. |
| tags | No | String | Template tag. |
| 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 4. |
| 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. |
| isSuccess | No | Boolean | Whether the template is successfully created. |
Last Article: Job Template Management
Next Article: Updating a Job Template
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.