-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'opensearch-project:main' into main
- Loading branch information
Showing
92 changed files
with
5,487 additions
and
1,010 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...ain/java/org/opensearch/sql/datasources/model/transport/PatchDataSourceActionRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* | ||
* * Copyright OpenSearch Contributors | ||
* * SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package org.opensearch.sql.datasources.model.transport; | ||
|
||
import static org.opensearch.sql.analysis.DataSourceSchemaIdentifierNameResolver.DEFAULT_DATASOURCE_NAME; | ||
import static org.opensearch.sql.datasources.utils.XContentParserUtils.CONNECTOR_FIELD; | ||
import static org.opensearch.sql.datasources.utils.XContentParserUtils.NAME_FIELD; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
import lombok.Getter; | ||
import org.opensearch.action.ActionRequest; | ||
import org.opensearch.action.ActionRequestValidationException; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
|
||
public class PatchDataSourceActionRequest extends ActionRequest { | ||
|
||
@Getter private Map<String, Object> dataSourceData; | ||
|
||
/** Constructor of UpdateDataSourceActionRequest from StreamInput. */ | ||
public PatchDataSourceActionRequest(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
public PatchDataSourceActionRequest(Map<String, Object> dataSourceData) { | ||
this.dataSourceData = dataSourceData; | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
if (this.dataSourceData.get(NAME_FIELD).equals(DEFAULT_DATASOURCE_NAME)) { | ||
ActionRequestValidationException exception = new ActionRequestValidationException(); | ||
exception.addValidationError( | ||
"Not allowed to update datasource with name : " + DEFAULT_DATASOURCE_NAME); | ||
return exception; | ||
} else if (this.dataSourceData.get(CONNECTOR_FIELD) != null) { | ||
ActionRequestValidationException exception = new ActionRequestValidationException(); | ||
exception.addValidationError("Not allowed to update connector for datasource"); | ||
return exception; | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...in/java/org/opensearch/sql/datasources/model/transport/PatchDataSourceActionResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* | ||
* * Copyright OpenSearch Contributors | ||
* * SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package org.opensearch.sql.datasources.model.transport; | ||
|
||
import java.io.IOException; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.opensearch.core.action.ActionResponse; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
|
||
@RequiredArgsConstructor | ||
public class PatchDataSourceActionResponse extends ActionResponse { | ||
|
||
@Getter private final String result; | ||
|
||
public PatchDataSourceActionResponse(StreamInput in) throws IOException { | ||
super(in); | ||
result = in.readString(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput streamOutput) throws IOException { | ||
streamOutput.writeString(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.