Software Secure Workload
Activity Configure

Inventory count

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

POST /openapi/v1/inventory/count

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.

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


    {
        "filter": {
            "type": "and",
            "filters": [
                {
                    "type": "contains",
                    "field": "hostname",
                    "value": "prod"
                },
                {
                    "type": "subnet",
                    "field": "ip"
                    "value": "6.6.6.0/24"
                }
            ]
        },
        "scopeName": "Default:Production:Web",  # optional
    }

Response

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

Keys

Values

count

Number of inventory items matching the filter Criteria

Sample python code


  req_payload = {
    "scopeName": "Tetration", # optional
    "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/count', 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)