Filter the list result
In this tutorial, you can learn how to tailor responses according to your filtering requirements.
Filtering in PowerProtect DDMC REST API is accomplished by using the filter query parameter. This parameter supports regular expression and multiple criteria. Always refer to the API documentation on regex and conditions that can be used in filter.
?filter=<field-name>=<value> [and <field-name>=<value>] ...
String filters
DDMC REST API supports filtering the list result that is targeted on a specific string “abc”.
For example, if you want to filter users with name containing “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://<DDMC-SYSTEM-IP/FQDN>:3009/rest/v1.0/dd-systems/bb5bed4adc90eebb%3A4496a0e4def16e94/users?filter=name%3Dabc'
It returns a list of users, whose names contain “abc”.
Number range filters
DDMC 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://<DDMC-SYSTEM-IP/FQDN>:3009/rest/v1.0/dd-systems/bb5bed4adc90eebb%3A4496a0e4def16e94/alerts?filter=alert_gen_epoch%3D(1582582529%2C1582582534)
It returns a list of alerts, which have been 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://<DDMC-SYSTEM-IP/FQDN>:3009/rest/v1.0/dd-systems/bb5bed4adc90eebb%3A4496a0e4def16e94/users?filter=name%3Dsys%20and%20role%3Duser'