Counting databases

Method and URI

To count all protected and unprotected databases registered by IBM Spectrum Protect Plus, use a POST method and a URI:

POST    https://{hostname|IP}/api/endeavour/catalog/application/database

Parameters

Parameter 1: action

Invoke the aggregate functions.

  • Value: aggregate

  • Type: System string. Required.

Data

Data 1: op

Use the COUNT() function to count the pk objects. For more information about the COUNT() function, see COUNT(). Name the output variable count.

  • Value:

[
    {
        "operation":  "count",
        "fieldname":  "pk",
        "outputname": "count"
    }
]
  • Type: Array. Required.

Example: Count databases

A Python snippet that is similar to the following example can be used to invoke an aggregate function that counts the total number of databases registered by IBM Spectrum Protect Plus. The number includes protected and unprotected databases.

_params = {"action": "aggregate"}

_data = f'''{{
    "op": [
        {{
            "operation":  "count",
            "fieldname":  "pk",
            "outputname": "count"
        }}
    ]
}}'''

requests.post('https://' + spp_ipv4
    + '/api/endeavour/catalog/application/database',
    headers={...}, params=_params, data=_data, verify=...)

The request prompts a response that is structured as shown, with the HTTP status of 200 (OK).

{
    "links": {...},
    "results": [
        {
            "_id": null,
            "count": 100
        }
    ]
}