-
Notifications
You must be signed in to change notification settings - Fork 59
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
Added support for headers for ExtensionRestRequest #643
Added support for headers for ExtensionRestRequest #643
Conversation
Signed-off-by: Daulet <[email protected]>
@dbwiddis first option mentioned in previous pr is more complicated because protected constructor of RestRequest requires also to fill HttpRequest. We can create sdkHttpRequest instead sdkRestRequest. sdkHttpRequest can replace anonymous HttpRequest class. |
We still need both. In particular we really need the But we should be able to use an anonymous |
https://github.com/opensearch-project/OpenSearch/blob/bcbb561b51c60776257e68786fcc411eebf4fab4/server/src/main/java/org/opensearch/rest/RestRequest.java#LL170C42-L170C42 |
@dbwiddis I can add path to ExtensionRestRequest. If I keep path, uri, params in ExtensionRestRequest then I can create instance of RestRequest subclass without overhead(converting uri to path, getting params from uri) |
Signed-off-by: Daulet <[email protected]>
Signed-off-by: Daulet <[email protected]>
The "params from uri" happens in OpenSearch inside the RestController. It has already:
It's that second part that we do not have the ability to decode in the Extension, which is why we must pass the Since we have the params, we don't really need the uri, since the path is the interesting part. But since we are recreating the whole HttpRequest it doesn't hurt to include both (by putting the uri where it belongs, the user can get either the path or the uri). It looks like you've handled these in your PR, so I'll go review it now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
I've made a few suggestions for improvements, mostly in the documentation.
One more request: our org.opensearch.sdk
package is getting cluttered and we should move stuff out of it when we can. Please create a new org.opensearch.sdk.rest
package and put your two new SDK classes into it.
Might also be a good home for these classes (we can address in a later PR):
ExtensionRestHandler
BaseExtensionRestHandler
(will break dependent extensions like AD but we can synchronize fix)RouteHandler
(will break dependent extensions like AD but we can synchronize fix)ExtensionRestPathRegistry
src/main/java/org/opensearch/sdk/handlers/ExtensionsRestRequestHandler.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the comment changes and package change requested above, also please update the tests:
- the
TestBaseExtensionRestHandler
class contains a methodcreateTestRestRequest()
. Replace the code there to use your new SDK classes, so that test code relying on them will use your new classes.
Signed-off-by: Daulet <[email protected]>
Signed-off-by: Daulet <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Tests should pass following merge of opensearch-project/OpenSearch#6826
Signed-off-by: Daulet <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, some suggestions to improve it!
@dbwiddis |
Yep! |
@dbwiddis When snapshot that contains latest commits of OpenSearch is will be used? My PR from OpenSearch side is merged but this PR checks didn't see changes from OpenSearch side. |
OK, new snapshot is being read but there's a missing method signature we're trying to read:
|
Yes, there should be protocolVersion() |
Just found that myself :) Should be a quick fix and we can merge this! |
@nassipkali are you going to be fixing that method? |
Signed-off-by: Daulet Nassipkali <[email protected]>
@dbwiddis I have a problem with git push. I made change from github web editor |
Lots of different errors in the build now. Locally you should be able to pull the changes down from your branch. |
@nassipkali I'm going to go ahead and fix up the issues here, since the SDK build is now failing other PRs. One challenge with these companion PRs is finding out what's broken before we merge the companion. You should be using |
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
* added uri and httpVersion to HttpRequest Signed-off-by: Daulet <[email protected]> * added SDKHttpRequest, SDKRestRequest Signed-off-by: Daulet <[email protected]> * spotless applied Signed-off-by: Daulet <[email protected]> * moved SDKHttpRequest and SDKRestRequest to org.opensearch.sdk.rest Signed-off-by: Daulet <[email protected]> * tests changed for new ExtensionRestRequest Signed-off-by: Daulet <[email protected]> * TestSDKRestRequest created Signed-off-by: Daulet <[email protected]> * corrected test for xContentType, added test for contentParser() Signed-off-by: Daulet <[email protected]> * replaced .map() with mapStrings() in contentParser() Signed-off-by: Daulet <[email protected]> * Update SDKHttpRequest.java Signed-off-by: Daulet Nassipkali <[email protected]> * Fix tests for new format Signed-off-by: Daniel Widdis <[email protected]> * Use correct Test annotation so tests actually run Signed-off-by: Daniel Widdis <[email protected]> --------- Signed-off-by: Daulet <[email protected]> Signed-off-by: Daulet Nassipkali <[email protected]> Signed-off-by: Daniel Widdis <[email protected]> Co-authored-by: Daniel Widdis <[email protected]> (cherry picked from commit dfdb050) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* added uri and httpVersion to HttpRequest * added SDKHttpRequest, SDKRestRequest * spotless applied * moved SDKHttpRequest and SDKRestRequest to org.opensearch.sdk.rest * tests changed for new ExtensionRestRequest * TestSDKRestRequest created * corrected test for xContentType, added test for contentParser() * replaced .map() with mapStrings() in contentParser() * Update SDKHttpRequest.java * Fix tests for new format * Use correct Test annotation so tests actually run --------- (cherry picked from commit dfdb050) Signed-off-by: Daulet <[email protected]> Signed-off-by: Daulet Nassipkali <[email protected]> Signed-off-by: Daniel Widdis <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Daniel Widdis <[email protected]>
Description
Adds SDKRestRequest, SDKHttpRequest
Companion PR: opensearch-project/OpenSearch#6826
Issues Resolved
#431
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.