-
Notifications
You must be signed in to change notification settings - Fork 160
Fix response codes returned by JSON formatting them #2156
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
Changes from all commits
75e9f04
cda01e9
71f4155
be82714
6783ed7
96f3ef0
fb2281e
9c5ffb8
03aba02
767a9cb
e772fde
0e37dca
4363d4d
97b8985
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
|
||
package org.opensearch.sql.datasources.transport; | ||
|
||
import static org.opensearch.sql.protocol.response.format.JsonResponseFormatter.Style.PRETTY; | ||
|
||
import org.opensearch.action.ActionType; | ||
import org.opensearch.action.support.ActionFilters; | ||
import org.opensearch.action.support.HandledTransportAction; | ||
|
@@ -17,6 +19,7 @@ | |
import org.opensearch.sql.datasources.model.transport.CreateDataSourceActionRequest; | ||
import org.opensearch.sql.datasources.model.transport.CreateDataSourceActionResponse; | ||
import org.opensearch.sql.datasources.service.DataSourceServiceImpl; | ||
import org.opensearch.sql.protocol.response.format.JsonResponseFormatter; | ||
import org.opensearch.tasks.Task; | ||
import org.opensearch.transport.TransportService; | ||
|
||
|
@@ -56,9 +59,14 @@ protected void doExecute( | |
try { | ||
DataSourceMetadata dataSourceMetadata = request.getDataSourceMetadata(); | ||
dataSourceService.createDataSource(dataSourceMetadata); | ||
actionListener.onResponse( | ||
new CreateDataSourceActionResponse( | ||
"Created DataSource with name " + dataSourceMetadata.getName())); | ||
String responseContent = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just return string in json format, not schema required? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reasoning behind this change was to have a response class and later on, if we have time we can do something like return the DataSourceMetadata that was Updated/Created. Don't think we will have time for that/I don't know what the standard is for SQL repo - but I reverted it back to just a JSON string for now - it should be fine as long as the UI can parse it. |
||
new JsonResponseFormatter<String>(PRETTY) { | ||
@Override | ||
protected Object buildJsonObject(String response) { | ||
return response; | ||
} | ||
}.format("Created DataSource with name " + dataSourceMetadata.getName()); | ||
actionListener.onResponse(new CreateDataSourceActionResponse(responseContent)); | ||
} catch (Exception e) { | ||
actionListener.onFailure(e); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.