A Usage Example

This example demonstrates how to make a POST call to execute a TQL query by definition to return the name of all CPUs of which the attribute contains Pentium.

Step 1. Retrieve the authentication token

To do this, make a POST call to https://localhost:8443/rest-api/authenticate with the following payload:

{
"username": "sysadmin",
"password": "Sysadmin?123", 
"clientContext": 1
}

Note This example assumes that the REST API is deployed at the following location:

https://localhost:8443/rest-api

You then receive a response that resembles the following:

Status: 200
Response body:
{
 "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NzQzNTc3MDYsImN1c3RvbWVyIjoxLCJ1c2VybmFtZSI6InN5c2FkbWluIn0.cVYsuum1CqaqfZV1K5KJ8nidOOif8Wv9tZsLFFZPbSs"
}

Step 2. Make a POST call to run the TQL query

Make a POST call to https://localhost:8443/rest-api/topologyQuery with the following payload:

{
   "nodes":  [
     {
       "type": "cpu",
       "queryIdentifier": "cpu1",
       "visible": true,
       "includeSubtypes": true,
       "layout": ["name"],
       "attributeConditions": [{
          "attribute": "name",
         "operator": "like",
         "value": "%Pentium%"
     }],
     "linkConditions": []
  }],
 "relations": []
}

At the same time you need to set the following header:

Authorization Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NzQzNTc3MDYsImN1c3RvbWVyIjoxLCJ1c2VybmFtZSI6InN5c2FkbWluIn0.cVYsuum1CqaqfZV1K5KJ8nidOOif8Wv9tZsLFFZPbSs

Note The payload specifies the layout attribute to name, so that the CPU name will be returned.