Usage of Odata Filtering for Catalog API
search cancel

Usage of Odata Filtering for Catalog API

book

Article ID: 330789

calendar_today

Updated On:

Products

VMware Aria Suite

Issue/Introduction

This article provides information about usage of Odata filtering and applying it to the specific use case.

Environment

VMware vRealize Automation 7.2.x
VMware vRealize Automation 7.4.x
VMware vRealize Automation 7.0.x
VMware vRealize Automation 6.x
VMware vRealize Automation 6.2.x
VMware vRealize Automation 7.3.x
VMware vRealize Automation 6.2
VMware vRealize Automation 7.1.x

Resolution

Filtering is performed by passing the $filter query parameter in the OData spec. Filtering can also be done on nested objects by using a / to identify the child relationship.

Following are examples for odata filtering with catalog get requests API:
  1. Filter based on requestCompletion/requestCompletionState:

    https://{{url}}/catalog-service/api/consumer/requests?$filter=requestCompletion/requestCompletionState+eq+'SUCCESSFUL'
     
  2. Filter by description:

    https://{{url}}/catalog-service/api/consumer/requests?$filter=description eq 'test'

    https://{{url}}/catalog-service/api/consumer/requests?$filter=(substringof('tes',tolower(description)))

     
  3. Filter by catalogItem/name:

    Search full name https://{{url}}/catalog-service/api/consumer/requests?$filter=catalogItem/name eq 'bp1'

    Search substring https://{{url}}/catalog-service/api/consumer/requests?$filter=(substringof('bp',tolower(catalogItem/name)))

     
  4. Filter by description and requestCompletion/requestCompletionState:

    https://{{url}}/catalog-service/api/consumer/requests?$filter=(description eq 'test') and requestCompletion/requestCompletionState+eq+'SUCCESSFUL'
     
  5. Filter by description and catalogItem/name:

    https://{{url}}/catalog-service/api/consumer/requests?$filter=(description eq 'test') and (catalogItem/name eq 'bp1')
     
  6. Filter using substringof and tolower for requestCompletion/requestCompletionState.

    https://{{url}}/catalog-service/api/consumer/requests?$filter=substringof('failed',tolower(requestCompletion/requestCompletionState))
     
  7. Filter by Resource Action:

    https://{{url}}/catalog-service/api/consumer/requests?$filter=(substringof('destroy',tolower(resourceAction/name))

    https://{{url}}/catalog-service/api/consumer/requests?$filter=(substringof('lease',tolower(resourceAction/name))

     
  8. Filter by description, catalogitem, resourceAction/name, and resource/name:

    https://{{url}}/catalog-service/api/consumer/requests?$expand=resource($filter=requestedBy eq '[email protected]' and ((substringof('lease',tolower(resourceAction/name))) or (substringof('bp1',tolower(resource/name))) or (substringof('bp1',tolower(catalogItem/name))) or (substringof('test',tolower(description)))))
     
For more information on $expand filter, see Expand System Query.

Disclaimer: VMware is not responsible for the reliability of any data, opinions, advice, or statements made on third-party websites. Inclusion of such links does not imply that VMware endorses, recommends, or accepts any responsibility for the content of such sites.