Update Template
PATCH
/v2/template/update/{template_id}
const url = 'http://localhost:3000/v2/template/update/example';const options = { method: 'PATCH', headers: {'Content-Type': 'application/json'}, body: '{"id":"api.query.template.update","ver":"v2","ts":"2024-04-10T16:10:50+05:30","params":{"msgid":"4a7f14c3-d61e-4d4f-be78-181834eeff6d"},"request":{"template_name":"sql_update_test_template","query_type":"sql","query":"SELECT * FROM {{DATASET}} WHERE __time BETWEEN TIMESTAMP {{STARTDATE}} AND TIMESTAMP {{ENDDATE}} lIMIT {{LIMIT}}"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url http://localhost:3000/v2/template/update/example \ --header 'Content-Type: application/json' \ --data '{ "id": "api.query.template.update", "ver": "v2", "ts": "2024-04-10T16:10:50+05:30", "params": { "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d" }, "request": { "template_name": "sql_update_test_template", "query_type": "sql", "query": "SELECT * FROM {{DATASET}} WHERE __time BETWEEN TIMESTAMP {{STARTDATE}} AND TIMESTAMP {{ENDDATE}} lIMIT {{LIMIT}}" } }'Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ” template_id
required
string
Unique identifier for the template
Request Body
Section titled “Request Body ” Media type application/json
object
Example
{ "id": "api.query.template.update", "ver": "v2", "ts": "2024-04-10T16:10:50+05:30", "params": { "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d" }, "request": { "template_name": "sql_update_test_template", "query_type": "sql", "query": "SELECT * FROM {{DATASET}} WHERE __time BETWEEN TIMESTAMP {{STARTDATE}} AND TIMESTAMP {{ENDDATE}} lIMIT {{LIMIT}}" }}Responses
Section titled “ Responses ”OK
Media type application/json
object
Example
{ "id": "api.query.template.update", "ver": "v2", "ts": "2024-05-10T11:21:47+05:30", "params": { "status": "SUCCESS", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "9e4a6959-0eb9-4fc4-8e6f-2eea534d1384" }, "responseCode": "OK", "result": { "message": "Query template updated successfully", "templateId": "sql11template1" }}Headers
Section titled “Headers ” X-Powered-By
string
Example
Express Content-Length
integer
Example
314 ETag
string
Example
W/"13a-jsb3kdb5RR9P3vnOhZWsAWEr37k" Date
string
Example
Fri, 10 May 2024 05:51:47 GMT Connection
string
Example
keep-alive Keep-Alive
string
Example
timeout=5Bad Request
Media type application/json
object
Examples
Failure: required variables not exists to update
{ "id": "api.query.template.update", "ver": "v2", "ts": "2024-05-10T11:23:54+05:30", "params": { "status": "FAILED", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "66b95cb3-2ef2-4735-9045-2674da552dbd" }, "responseCode": "BAD_REQUEST", "result": {}, "error": { "code": "QUERY_TEMPLATE_INVALID_INPUT", "message": "Invalid template provided, A template should consist of variables DATASET,STARTDATE,ENDDATE and type of json,sql", "trace": "" }}Failure: Template name validation failure
{ "id": "api.query.template.update", "ver": "v2", "ts": "2024-05-10T11:26:59+05:30", "params": { "status": "FAILED", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "d6428fcf-53c9-465d-9431-769218f775b8" }, "responseCode": "BAD_REQUEST", "result": {}, "error": { "code": "QUERY_TEMPLATE_INVALID_INPUT", "message": "Template name should contain alphanumeric characters and single space between characters", "trace": "" }}Failure: query_type should when updating query
{ "id": "api.query.template.update", "ver": "v2", "ts": "2024-05-10T12:32:57+05:30", "params": { "status": "FAILED", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "c7a8675a-73f2-4764-abba-bfdf9f8b4621" }, "responseCode": "BAD_REQUEST", "result": {}, "error": { "code": "QUERY_TEMPLATE_INVALID_INPUT", "message": "#properties/request/dependencies should have property query_type when property query is present", "trace": "" }}Failure: query should present when updating query_type
{ "id": "api.query.template.update", "ver": "v2", "ts": "2024-05-10T12:34:55+05:30", "params": { "status": "FAILED", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "2c1098b2-d7b3-4d39-98ee-e3e790fd23b4" }, "responseCode": "BAD_REQUEST", "result": {}, "error": { "code": "QUERY_TEMPLATE_INVALID_INPUT", "message": "#properties/request/dependencies should have property query when property query_type is present", "trace": "" }}Headers
Section titled “Headers ” X-Powered-By
string
Example
Express Content-Length
integer
Example
429 ETag
string
Example
W/"1ad-5sb8WUekFL8s4c1Ink6bUByoHho" Date
string
Example
Fri, 10 May 2024 05:53:54 GMT Connection
string
Example
keep-alive Keep-Alive
string
Example
timeout=5