opensearch-project / opensearch-py

Python Client for OpenSearch
https://opensearch.org/docs/latest/clients/python/
Apache License 2.0
338 stars 170 forks source link

[FEATURE] Add support for returning all index policy objects #629

Closed spapadop closed 8 months ago

spapadop commented 9 months ago

Is your feature request related to a problem?

Currently there is a nice integration for the index management plugin supporting APIs like get_policy. However, that get_policy() API has "policy" as required positional argument.

As a result, there is no way to request all the policies that live in a cluster.

What solution would you like?

Make "policy" an optional argument and return all policies whenever it is not given (or maybe also when policy is set to *, in case we wanna go down that path). Alternatively, add a new API get_policies, which will behave like the alerting plugin's get_alerts.

In any case, the call should behave like running GET _plugins/_ism/policies on the cluster, thus returning:

{
  "policies": [
      { },
      ...
      { }
  ],
  "total_policies": 7
}

What alternatives have you considered?

Can't find a way that could fetch all policies of a cluster.

Do you have any additional context?

N/A

saimedhi commented 9 months ago

Hi @spapadop,

Opensearch server works fine without the "policy" argument at GET https://localhost:9200/_plugins/_ism/policies. Making it optional in opensearch-py would be helpful. If you have some time, could you please give it a try and consider raising a PR?

Thanks a bunch!

spapadop commented 9 months ago

Hello @saimedhi,

I see you've raised already the PR, thanks! I'll follow it up there, in case any help is needed.