Software Secure Workload
Activity Configure

Inventory search

This endpoint returns the list of inventory items matching the specified criteria.

POST /openapi/v1/inventory/search

The list of columns that can be specified in the filter criteria can be obtained with the /openapi/v1/inventory/ search/dimensions API.

Parameters:

Name

Type

Description

filter

JSON

A filter query.

scopeName

string

(optional) Name of the scope by which to limit results.

limit

integer

(optional) Max number of results to return.

offset

integer

(optional) Offset from the previous request to get the next page.

The body of the request must be a JSON formatted query. An example of a query body is shown below.


    {
        "filter": {
            "type": "contains",
            "field": "hostname",
            "value": "collector"
        },
        "scopeName": "Default:Production:Web",  // optional
        "limit": 100,
        "offset": "<offset-object>"               // optional
    }

To get the different types of filters supported refer to Filters

The query body consists of a JSON body with the following keys.

Keys

Values

filter

Query filter. If filter is empty (i.e. {}), then query matches all inventory items.

scopeName

Full name of the scope to which query is restricted to (optional)

dimensions

List of dimension names to be returned in the result of inventory search API. This is an optional parameter. If unspecified, results return all the available dimensions. This option is useful to specify a subset of the available dimensions when caller does not care about the rest of the dimensions.

limit

Number of response items limit (optional)

offset

Offset object received from previous response (optional)

Response

The response is a JSON object in the body with the following properties.

Name

Type

Description

offset

integer

Response offset to be passed for the next page of results.

results

array of objects

List of results.

The response may contain an offset field for paginated responses. Users will need to specify the same offset in the subsequent request to get the next set of results.

Sample Python code


  req_payload = {
    "scopeName": "Tetration", # optional
    "limit": 2,
    "filter": {"type": "and",
       "filters": [
          {"type": "eq", "field": "vrf_name", "value": "Tetration"},
          {"type": "subnet", "field": "ip", "value": "1.1.1.0/24"},
          {"type": "contains", "field": "hostname", "value": "collector"}
       ]
    }
  }

  resp = restclient.post('/inventory/search', json_body=json.dumps(req_payload))
  print resp.status_code
  if resp.status_code == 200:
     parsed_resp = json.loads(resp.content)
     print json.dumps(parsed_resp, indent=4, sort_keys=True)