-
Notifications
You must be signed in to change notification settings - Fork 138
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/multi_tenancy] Add UpdateDataObject interface, Client, and Connector Implementations #2520
Merged
dhrubo-os
merged 5 commits into
opensearch-project:feature/multi_tenancy
from
dbwiddis:update-api
Jun 14, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1507a6f
Restore original exception handling expectations
dbwiddis 733e8bd
Add UpdateDataObject to interface and implementations
dbwiddis f26971f
Implement UpdateConnector action
dbwiddis 1acfd82
Move CompletionException handling to a common method
dbwiddis f45cda5
Add tests for SDKClient exceptions refactored from Transport Action
dbwiddis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
108 changes: 108 additions & 0 deletions
108
common/src/main/java/org/opensearch/sdk/UpdateDataObjectRequest.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,108 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
package org.opensearch.sdk; | ||
|
||
import org.opensearch.core.xcontent.ToXContentObject; | ||
|
||
public class UpdateDataObjectRequest { | ||
|
||
private final String index; | ||
private final String id; | ||
private final ToXContentObject dataObject; | ||
|
||
/** | ||
* Instantiate this request with an index and data object. | ||
* <p> | ||
* For data storage implementations other than OpenSearch, an index may be referred to as a table and the data object may be referred to as an item. | ||
* @param index the index location to update the object | ||
* @param id the document id | ||
* @param dataObject the data object | ||
*/ | ||
public UpdateDataObjectRequest(String index, String id, ToXContentObject dataObject) { | ||
this.index = index; | ||
this.id = id; | ||
this.dataObject = dataObject; | ||
} | ||
|
||
/** | ||
* Returns the index | ||
* @return the index | ||
*/ | ||
public String index() { | ||
return this.index; | ||
} | ||
|
||
/** | ||
* Returns the document id | ||
* @return the id | ||
*/ | ||
public String id() { | ||
return this.id; | ||
} | ||
|
||
/** | ||
* Returns the data object | ||
* @return the data object | ||
*/ | ||
public ToXContentObject dataObject() { | ||
return this.dataObject; | ||
} | ||
|
||
/** | ||
* Class for constructing a Builder for this Request Object | ||
*/ | ||
public static class Builder { | ||
private String index = null; | ||
private String id = null; | ||
private ToXContentObject dataObject = null; | ||
|
||
/** | ||
* Empty Constructor for the Builder object | ||
*/ | ||
public Builder() {} | ||
|
||
/** | ||
* Add an index to this builder | ||
* @param index the index to put the object | ||
* @return the updated builder | ||
*/ | ||
public Builder index(String index) { | ||
this.index = index; | ||
return this; | ||
} | ||
|
||
/** | ||
* Add an id to this builder | ||
* @param id the document id | ||
* @return the updated builder | ||
*/ | ||
public Builder id(String id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
/** | ||
* Add a data object to this builder | ||
* @param dataObject the data object | ||
* @return the updated builder | ||
*/ | ||
public Builder dataObject(ToXContentObject dataObject) { | ||
this.dataObject = dataObject; | ||
return this; | ||
} | ||
|
||
/** | ||
* Builds the request | ||
* @return A {@link UpdateDataObjectRequest} | ||
*/ | ||
public UpdateDataObjectRequest build() { | ||
return new UpdateDataObjectRequest(this.index, this.id, this.dataObject); | ||
} | ||
} | ||
} |
140 changes: 140 additions & 0 deletions
140
common/src/main/java/org/opensearch/sdk/UpdateDataObjectResponse.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,140 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
package org.opensearch.sdk; | ||
|
||
import org.opensearch.action.support.replication.ReplicationResponse.ShardInfo; | ||
import org.opensearch.core.common.Strings; | ||
import org.opensearch.core.index.shard.ShardId; | ||
|
||
public class UpdateDataObjectResponse { | ||
private final String id; | ||
private final ShardId shardId; | ||
private final ShardInfo shardInfo; | ||
private final boolean updated; | ||
|
||
/** | ||
* Instantiate this request with an id and update status. | ||
* <p> | ||
* For data storage implementations other than OpenSearch, the id may be referred to as a primary key. | ||
* @param id the document id | ||
* @param shardId the shard id | ||
* @param shardInfo the shard info | ||
* @param updated Whether the object was updated. | ||
*/ | ||
public UpdateDataObjectResponse(String id, ShardId shardId, ShardInfo shardInfo, boolean updated) { | ||
this.id = id; | ||
this.shardId = shardId; | ||
this.shardInfo = shardInfo; | ||
this.updated = updated; | ||
} | ||
|
||
/** | ||
* Returns the document id | ||
* @return the id | ||
*/ | ||
public String id() { | ||
return id; | ||
} | ||
|
||
/** | ||
* Returns the shard id. | ||
* @return the shard id, or a generated id if shards are not applicable | ||
*/ | ||
public ShardId shardId() { | ||
return shardId; | ||
} | ||
|
||
/** | ||
* Returns the shard info. | ||
* @return the shard info, or generated info if shards are not applicable | ||
*/ | ||
public ShardInfo shardInfo() { | ||
return shardInfo; | ||
} | ||
|
||
/** | ||
* Returns whether update was successful | ||
* @return true if update was successful | ||
*/ | ||
public boolean updated() { | ||
return updated; | ||
} | ||
|
||
/** | ||
* Class for constructing a Builder for this Response Object | ||
*/ | ||
public static class Builder { | ||
private String id = null; | ||
private ShardId shardId = null; | ||
private ShardInfo shardInfo = null; | ||
private boolean updated = false; | ||
|
||
/** | ||
* Empty Constructor for the Builder object | ||
*/ | ||
public Builder() {} | ||
|
||
/** | ||
* Add an id to this builder | ||
* @param id the id to add | ||
* @return the updated builder | ||
*/ | ||
public Builder id(String id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
/** | ||
* Adds a shard id to this builder | ||
* @param shardId the shard id to add | ||
* @return the updated builder | ||
*/ | ||
public Builder shardId(ShardId shardId) { | ||
this.shardId = shardId; | ||
return this; | ||
} | ||
|
||
/** | ||
* Adds a generated shard id to this builder | ||
* @param indexName the index name to generate a shard id | ||
* @return the updated builder | ||
*/ | ||
public Builder shardId(String indexName) { | ||
this.shardId = new ShardId(indexName, Strings.UNKNOWN_UUID_VALUE, 0); | ||
return this; | ||
} | ||
|
||
/** | ||
* Adds shard information (statistics) to this builder | ||
* @param shardInfo the shard info to add | ||
* @return the updated builder | ||
*/ | ||
public Builder shardInfo(ShardInfo shardInfo) { | ||
this.shardInfo = shardInfo; | ||
return this; | ||
} | ||
/** | ||
* Add a updated status to this builder | ||
* @param updated the updated status to add | ||
* @return the updated builder | ||
*/ | ||
public Builder updated(boolean updated) { | ||
this.updated = updated; | ||
return this; | ||
} | ||
|
||
/** | ||
* Builds the object | ||
* @return A {@link UpdateDataObjectResponse} | ||
*/ | ||
public UpdateDataObjectResponse build() { | ||
return new UpdateDataObjectResponse(this.id, this.shardId, this.shardInfo, this.updated); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why is this information required? Can this be null for non-OpenSearch data stores?
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.
No, it can not be null, you have asked this same question before and it was answered here: #2459 (comment)