Run a Command Template

POST /api/v1.2/command_templates/<id>/run

Use this API to run a command template by using its unique ID. Qubole assigns an unique identifier (ID) to each new command template once it is created.

Required Role

The following users can make this API call:

  • Users who belong to the system-user or system-admin group.

  • Users who belong to a group associated with a role that allows running a command template. See Managing Groups and Managing Roles for more information.

Parameters

Note

Parameters marked in bold below are mandatory. Others are optional and have default values.

Parameter

Description

input_vars

Specify values for the variables while running the template. For example, if you compose a query that uses two variables, $Month$ and $Country$, the input variables with default values (escaped) can be as: input_vars: [{"Month":"\"March\""}, {"Country":"\"US\""}]. If default values are set in the command template that is run, then those values are taken if you do not explicitly mention any value for a parameter/variable as part of input_vars. Specify new values for the variables to override the default values (if any). For more information, see Macros.

tags

Add a tag to a command so that it is easily identifiable and searchable from the commands list in the Commands History. Add a tag as a filter value while searching commands. It can contain a maximum of 255 characters. A comma-separated list of tags can be associated with a single command. While adding a tag value, enclose it in square brackets. For example, {"tags":["<tag-value>"]}.

label

Specify the cluster label on which this command template is to be run.

Request API Syntax

Here is the syntax using label for adding a cluster label.

curl -i -X POST -H "X-AUTH-TOKEN: $AUTH_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json"
-d '{"input_vars":[{"<variable1>":"\"<value1>\""}, {"<variable2>":"\"<value2>\""}, {"<variable3>":"\"<value3>\""}],
     "label":"<cluster-label>"}'
"https://api.qubole.com/api/v1.2/command_templates/<id>/run

Here is the syntax using tag for adding a cluster label.

curl -i -X POST -H "X-AUTH-TOKEN: $AUTH_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" \
-d '{"input_vars":[{"<variable1>":"\"<value1>\""}, {"<variable2>":"\"<value2>\""}, {"<variable3>":"\"<value3>\""}],
     "tag":"<cluster-label>"}' \
"https://api.qubole.com/api/v1.2/command_templates/<id>/run

Note

The above syntax uses https://api.qubole.com as the endpoint. Qubole provides other endpoints to access QDS that are described in Supported Qubole Endpoints on Different Cloud Providers.

Sample API Request

Here is the sample API request to run a command template with ID 2134 that must be run on the cluster (with a200 as its label)

curl -i -X POST -H "X-AUTH-TOKEN: $AUTH_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" \
-d '{"input_vars":[{"Month":"\"March\""}, {"Country":"\"US\""}, {"Year":"\"2016\""}] "label":"a200"}' \
"https://api.qubole.com/api/v1.2/command_templates/2134/run