Allow for filters in observer endpoints that return collections of items
Current situation
Many current Observer endpoints return lists of items, but there is no way to restrict those lists to the items of interest.
For example, we can query the events related to a workflow, but we cannot query only the ExecutionCommand events relevant to a workflow. The same applies to other endpoints.
There is currently only one filter, for the /namespaces
endpoint, but this is a special case.
Desired outcome
A way to specify a filter. As we are filtering mostly manifests, using label selectors and field selectors as seen on Kubernetes would be a good thing to have.
We already have evaluators for those two filter types, as this is what we use when subscribing to events.
So, an optional fieldSelector
query parameter as well as an optional labelSelector
query parameter.
For example, for the /channels
(GET) endpoint, we would use:
GET /channels?fieldSelector=status.phase=IDLE
to only get the channels that are idle.
We can provide more than one condition, linked by a logical 'and' operator:
GET /channels?fieldSelector=status.phase=IDLE,metadata.namespace in (ns1, ns2)
That request would return idle channels available in the ns1
or ns2
namespace.
[Please note that, when performing those query on a command-line, you would have to urlencode query parameters, such as /channels?fieldSelector=status.phase%3DIDLE
or /channels?fieldSelector=status.phase%3DIDLE%2Cmetadata.namespace+in+%28ns1%2Cns%29
.]