Filter the list result
In this tutorial, you can learn how to tailor responses according to your filtering requirements.
Filtering in PowerProtect DD REST API is accomplished by using the filter query parameter. This parameter supports regular expression and multiple criteria.
?filter=<field-name>=<value> [and <field-name>=<value>] ...
String filters
DD REST API supports filtering the list result that is targeted on a specific string “abc”.
For example, if you want to filter users with names that contain “abc”, use this filter:
?filter=name=abc
If you want to filter users with names that start with “abc”, use this filter:
?filter=name=^abc
If you want to filter users with names that end with “abc”, use this filter:
?filter=name=abc$
If you want to filter users with names that exactly match “abc”, use this filter:
?filter=name=^abc$
Full sample code with URL-encoded query:
curl --request GET \
--header 'content-type: application/json' \
--header 'X-DD-AUTH-TOKEN: <auth-token>' \
--url 'https://<DD-SYSTEM-IP/FQDN>:3009/rest/v1.0/dd-systems/0/users?filter=name%3Dabc'
The query returns a list of users, whose names contain “abc”.
Number range filters
PowerProtect DD REST API also supports filtering the list result by specifying a range in integers.
Regular expression | Number range filter syntax |
---|---|
a <= x <= b | (a,b) |
x >= a | (a, ) |
x <= b | ( ,b) |
x == a | (a,a) |
For example, if you want to filter alerts generated before timestamp “b” including b, use this filter:
?filter=alert_gen_epoch=(,b)
If you want to filter alerts generated after timestamp “a” including a, use this filter:
?filter=alert_gen_epoch=(a,)
If you want to filter alerts generated between timestamp “a” and “b” including a and b, use this filter:
?filter=alert_gen_epoch=(a,b)
Full sample code with URL-encoded query:
curl --request GET \
--header 'content-type: application/json' \
--header 'X-DD-AUTH-TOKEN: <auth-token>' \
--url 'https://<DD-SYSTEM-IP/FQDN>:3009/rest/v1.0/dd-systems/0/alerts?filter=alert_gen_epoch%3D(1582582529%2C1582582534)
The query returns a list of alerts that are generated in (1582582529, 1582582534) in epoch time.
If you have more than one field to filter, you can use the and operator to connect the expressions:
?fitler=name=sys and role=user
Full sample code with URL-encoded query:
curl --request GET \
--header 'content-type: application/json' \
--header 'X-DD-AUTH-TOKEN: <auth-token>' \
--url 'https://<DD-SYSTEM-IP/FQDN>:3009/rest/v1.0/dd-systems/0/users?filter=name%3Dsys%20and%20role%3Duser'