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

Added client-level REST helpers. #544

Closed dblock closed 10 months ago

dblock commented 11 months ago

Description

Adds client-level REST helpers.

This allows one to do client.http.get(...), .post, etc., instead of client.transport.perform_request("GET", ...).

Issues Resolved

Closes https://github.com/opensearch-project/opensearch-py/issues/498.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.

codecov[bot] commented 11 months ago

Codecov Report

Merging #544 (06a59dd) into main (f02d6de) will increase coverage by 0.12%. Report is 1 commits behind head on main. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #544      +/-   ##
==========================================
+ Coverage   71.74%   71.87%   +0.12%     
==========================================
  Files          87       89       +2     
  Lines        7886     7922      +36     
==========================================
+ Hits         5658     5694      +36     
  Misses       2228     2228              
Files Coverage Δ
opensearchpy/_async/client/__init__.py 46.18% <100.00%> (+0.39%) :arrow_up:
opensearchpy/_async/client/http.py 100.00% <100.00%> (ø)
opensearchpy/client/__init__.py 61.45% <100.00%> (+0.28%) :arrow_up:
opensearchpy/client/http.py 100.00% <100.00%> (ø)
dblock commented 11 months ago

@saimedhi @harshavamsi @Xtansia wdyt?

Xtansia commented 11 months ago

@saimedhi @harshavamsi @Xtansia wdyt?

We're going to have this name clash with get in all the clients presumably, and it'd probably be nice to have this semi-standardised across them. An option is to make an "operation namespace" like raw or http same as we have cat/cluster/indices etc.

dblock commented 11 months ago

@Xtansia What's your most preferred option for client.X.Y.Z?

Xtansia commented 11 months ago

@Xtansia What's your most preferred option for client.X.Y.Z?

I personally feel like client.http.get() is probably the most self-documenting, and least likely to ever conflict with the naming of a "real" operation

dblock commented 10 months ago

Followed suggestion from @Xtansia to make the code client.http.get, client.http.post, etc. This is ready to review!