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 support for AWS Sigv4 for UrlLib3. #547

Closed dblock closed 11 months ago

dblock commented 11 months ago

Description

Testing

AOS

export SERVICE=es
export ENDPOINT=https://xyz.us-west-2.aoss.amazonaws.com
poetry run python sigv4/urllib3-hello.py 

INFO:Found credentials in environment variables.
INFO:GET https://search-dblock-test-opensearch-27-xyz.us-west-2.es.amazonaws.com:443/ [status:200 request:0.768s]
opensearch: 2.7.0
INFO:PUT https://search-dblock-test-opensearch-27-xyz.us-west-2.es.amazonaws.com:443/movies [status:200 request:2.298s]
INFO:PUT https://search-dblock-test-opensearch-27-xyz.us-west-2.es.amazonaws.com:443/movies/_doc/1 [status:201 request:0.500s]
INFO:POST https://search-dblock-test-opensearch-27-xyz.us-west-2.es.amazonaws.com:443/_search [status:200 request:0.213s]
{'director': 'Bennett Miller', 'title': 'Moneyball', 'year': 2011}
INFO:DELETE https://search-dblock-test-opensearch-27-xyz.us-west-2.es.amazonaws.com:443/movies/_doc/1 [status:200 request:0.108s]
INFO:DELETE https://search-dblock-test-opensearch-27-xyz.us-west-2.es.amazonaws.com:443/movies [status:200 request:0.223s]

AOSS

export SERVICE=aoss
export ENDPOINT=https://xyz.us-west-2.aoss.amazonaws.com
poetry run python sigv4/urllib3-hello.py 
INFO:Found credentials in environment variables.
INFO:PUT https://xyz.us-west-2.aoss.amazonaws.com:443/movies [status:200 request:4.173s]
INFO:PUT https://xyz.us-west-2.aoss.amazonaws.com:443/movies/_doc/1 [status:201 request:3.117s]
INFO:POST https://xyz.us-west-2.aoss.amazonaws.com:443/_search [status:200 request:4.916s]
{'director': 'Bennett Miller', 'title': 'Moneyball', 'year': 2011}
INFO:DELETE https://xyz.us-west-2.aoss.amazonaws.com:443/movies/_doc/1 [status:200 request:1.249s]
INFO:DELETE https://xyz.us-west-2.aoss.amazonaws.com:443/movies [status:200 request:0.168s]

Issues Resolved

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

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 #547 (284a5fd) into main (fa8f3a7) will increase coverage by 0.02%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #547      +/-   ##
==========================================
+ Coverage   70.63%   70.66%   +0.02%     
==========================================
  Files          83       83              
  Lines        7857     7877      +20     
==========================================
+ Hits         5550     5566      +16     
- Misses       2307     2311       +4     
Files Coverage Δ
opensearchpy/__init__.py 92.85% <100.00%> (ø)
opensearchpy/connection/http_urllib3.py 82.00% <100.00%> (-4.03%) :arrow_down:
opensearchpy/helpers/__init__.py 100.00% <100.00%> (ø)
opensearchpy/helpers/signer.py 98.03% <100.00%> (+3.30%) :arrow_up:

... and 2 files with indirect coverage changes

dblock commented 11 months ago

@harshavamsi would appreciate your CR since you did support for the requests connection class.

dblock commented 11 months ago

@VachaShah I wrote some more tests and addressed your comments. LMK if there's anything else needed for this one