Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Send raw json request #177

Merged
merged 7 commits into from
Mar 5, 2024

Conversation

imdhemy
Copy link
Contributor

@imdhemy imdhemy commented Mar 2, 2024

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.

Copy link

codecov bot commented Mar 2, 2024

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 ⚠️
Additional details and impacted files
@@             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              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@imdhemy imdhemy force-pushed the make-raw-json-rest-requests branch from 7821edc to c07c566 Compare March 2, 2024 12:41
@imdhemy imdhemy marked this pull request as ready for review March 2, 2024 12:44
@imdhemy imdhemy force-pushed the make-raw-json-rest-requests branch from dc76246 to aafb793 Compare March 2, 2024 12:47
@imdhemy imdhemy marked this pull request as draft March 2, 2024 13:17
@imdhemy imdhemy changed the title [Feature] Send raw json request [Feature: wip] Send raw json request Mar 2, 2024
@imdhemy imdhemy force-pushed the make-raw-json-rest-requests branch from 798308f to 7efd80b Compare March 2, 2024 20:02
@imdhemy imdhemy marked this pull request as ready for review March 2, 2024 20:02
@imdhemy imdhemy changed the title [Feature: wip] Send raw json request [Feature] Send raw json request Mar 2, 2024
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

Do you think we should add .get, .post, etc, or maybe ._get wrappers on top of this new method as well? Should those be the preferred ones recommended by the docs?

@imdhemy
Copy link
Contributor Author

imdhemy commented Mar 5, 2024

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
dblock previously approved these changes Mar 5, 2024
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge this.

@dblock
Copy link
Member

dblock commented Mar 5, 2024

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

Copy link
Collaborator

@shyim shyim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one :) thank you!

@dblock dblock merged commit 4398973 into opensearch-project:main Mar 5, 2024
36 checks passed
@dblock
Copy link
Member

dblock commented Mar 5, 2024

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 imdhemy deleted the make-raw-json-rest-requests branch March 7, 2024 06:02
@imdhemy
Copy link
Contributor Author

imdhemy commented Mar 7, 2024

@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
Copy link
Member

dblock commented Mar 7, 2024

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
Copy link
Contributor Author

imdhemy commented Mar 7, 2024

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

@dblock
Copy link
Member

dblock commented May 20, 2024

I opened #192 for the additional get/put/post DSL, maybe we can do ->http()->get? WDYT @imdhemy?

@imdhemy
Copy link
Contributor Author

imdhemy commented May 20, 2024

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

@dblock dblock added the enhancement New feature or request label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Make raw JSON REST requests to OpenSearch
3 participants