opensearch-project / opensearch-php

Official PHP Client for OpenSearch
Other
109 stars 58 forks source link

[Feature] Send raw json request #177

Closed imdhemy closed 8 months ago

imdhemy commented 8 months ago

Description

This PR adds a wrapper request() method around the client performRequest() to send Raw JSON requests.

Issues Resolved

Closes #166

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 8 months ago

Codecov Report

Attention: Patch coverage is 85.71429% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 27.03%. Comparing base (bf9b981) to head (79d2197). Report is 1 commits behind head on main.

Files Patch % Lines
src/OpenSearch/Client.php 85.71% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #177 +/- ## ============================================ + Coverage 26.97% 27.03% +0.06% - Complexity 2017 2018 +1 ============================================ Files 263 263 Lines 7144 7150 +6 ============================================ + Hits 1927 1933 +6 Misses 5217 5217 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

imdhemy commented 8 months ago

Thank you, @dblock!

I went for get, post etc in the beginning, but I found the get is already used in the Client.

I wasn't sure about the name, so I went for something similar to what's used in Guzzle.

I wouldn't recommend an underscore prefix style, because it brings the bad old days of PHP to mind :).

dblock commented 8 months ago

Btw, link checker needs to be upgraded or locked @1 to get fixed, if you have a second.

dblock commented 8 months ago

Thanks for your help @imdhemy! There's a million workitems in this client, would love some more help. Starting with guides/samples for example.

imdhemy commented 8 months ago

@shyim @dblock My pleasure! :)

I'd like to propose a slight change in the branches that could help improve this client.

Branch Description
1.x For development and releases of OpenSearch v.1.x
2.x For development and releases of OpenSearch v.2.x
main For the next major release. We can introduce breaking changes here

Being the current version of OpenSearch, we need to set the 2.x branch as the default branch instead of the main. Can we do that?

dblock commented 8 months ago

We've been trying to decouple versioning in clients from OpenSearch proper. IMO the client should be broadly compatible with all versions of OpenSearch and follow its own semver. Does this change your recommendation?

imdhemy commented 8 months ago

I'll think about you and may get back to you. Thank you

dblock commented 6 months ago

I opened https://github.com/opensearch-project/opensearch-php/issues/192 for the additional get/put/post DSL, maybe we can do ->http()->get? WDYT @imdhemy?

imdhemy commented 6 months ago

Sounds good, I'll make time to add it. Thanks for opening #192!