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

AWS DDB SDK client support for remote data store #2553

Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@ public class DeleteDataObjectRequest {

private final String index;
private final String id;
private final String tenantId;

/**
* Instantiate this request with an index and id.
* <p>
* For data storage implementations other than OpenSearch, an index may be referred to as a table and the id may be referred to as a primary key.
* @param index the index location to delete the object
* @param id the document id
* @param tenantId the tenant id
*/
arjunkumargiri marked this conversation as resolved.
Show resolved Hide resolved
public DeleteDataObjectRequest(String index, String id) {
public DeleteDataObjectRequest(String index, String id, String tenantId) {
this.index = index;
this.id = id;
this.tenantId = tenantId;
}

/**
Expand All @@ -41,12 +44,21 @@ public String id() {
return this.id;
}

/**
* Returns the tenant id
* @return the tenantId
*/
public String tenantId() {
Copy link
Member

Choose a reason for hiding this comment

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

Needs a javadoc.

Won't repeat this but almost everything added here has no javadocs.

return this.tenantId;
}

/**
* Class for constructing a Builder for this Request Object
*/
public static class Builder {
private String index = null;
private String id = null;
private String tenantId = null;

/**
* Empty Constructor for the Builder object
Expand All @@ -73,12 +85,22 @@ public Builder id(String id) {
return this;
}

/**
* Add a tenant id to this builder
* @param tenantId the tenant id
* @return the updated builder
*/
public Builder tenantId(String tenantId) {
this.tenantId = tenantId;
return this;
}
Comment on lines +93 to +96
Copy link
Member

Choose a reason for hiding this comment

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

I like how we're demonstrating how easy it is to add to these request objects to increase functionality.


/**
* Builds the object
* @return A {@link DeleteDataObjectRequest}
*/
public DeleteDataObjectRequest build() {
return new DeleteDataObjectRequest(this.index, this.id);
return new DeleteDataObjectRequest(this.index, this.id, this.tenantId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class GetDataObjectRequest {

private final String index;
private final String id;
private final String tenantId;
private final FetchSourceContext fetchSourceContext;

/**
Expand All @@ -22,11 +23,13 @@ public class GetDataObjectRequest {
* For data storage implementations other than OpenSearch, an index may be referred to as a table and the id may be referred to as a primary key.
* @param index the index location to get the object
* @param id the document id
* @param tenantId the tenant id
* @param fetchSourceContext the context to use when fetching _source
arjunkumargiri marked this conversation as resolved.
Show resolved Hide resolved
*/
public GetDataObjectRequest(String index, String id, FetchSourceContext fetchSourceContext) {
public GetDataObjectRequest(String index, String id, String tenantId, FetchSourceContext fetchSourceContext) {
this.index = index;
this.id = id;
this.tenantId = tenantId;
this.fetchSourceContext = fetchSourceContext;
}

Expand All @@ -46,6 +49,14 @@ public String id() {
return this.id;
}

/**
* Returns the tenant id
* @return the tenantId
*/
public String tenantId() {
return this.tenantId;
}

/**
* Returns the context for fetching _source
* @return the fetchSourceContext
Expand All @@ -60,6 +71,7 @@ public FetchSourceContext fetchSourceContext() {
public static class Builder {
private String index = null;
private String id = null;
private String tenantId = null;
private FetchSourceContext fetchSourceContext;

/**
Expand Down Expand Up @@ -87,6 +99,16 @@ public Builder id(String id) {
return this;
}

/**
* Add a tenant id to this builder
* @param tenantId the tenant id
* @return the updated builder
*/
public Builder tenantId(String tenantId) {
this.tenantId = tenantId;
return this;
}

/**
* Add a fetchSourceContext to this builder
* @param fetchSourceContext the fetchSourceContext
Expand All @@ -102,7 +124,7 @@ public Builder fetchSourceContext(FetchSourceContext fetchSourceContext) {
* @return A {@link GetDataObjectRequest}
*/
public GetDataObjectRequest build() {
return new GetDataObjectRequest(this.index, this.id, this.fetchSourceContext);
return new GetDataObjectRequest(this.index, this.id, this.tenantId, this.fetchSourceContext);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
public class PutDataObjectRequest {

private final String index;
private final String id;
private final String tenantId;
private final ToXContentObject dataObject;

/**
Expand All @@ -22,8 +24,10 @@ public class PutDataObjectRequest {
* @param index the index location to put the object
* @param dataObject the data object
*/
public PutDataObjectRequest(String index, ToXContentObject dataObject) {
public PutDataObjectRequest(String index, String id, String tenantId, ToXContentObject dataObject) {
this.index = index;
this.id = id;
this.tenantId = tenantId;
this.dataObject = dataObject;
}

Expand All @@ -35,6 +39,22 @@ public String index() {
return this.index;
}

/**
* Returns the document id
* @return the id
*/
public String id() {
return this.id;
}

/**
* Returns the tenant id
* @return the tenantId
*/
public String tenantId() {
return this.tenantId;
}

/**
* Returns the data object
* @return the data object
Expand All @@ -48,6 +68,8 @@ public ToXContentObject dataObject() {
*/
public static class Builder {
private String index = null;
private String id = null;
private String tenantId = null;
private ToXContentObject dataObject = null;

/**
Expand All @@ -65,6 +87,26 @@ public Builder index(String index) {
return this;
}

/**
* Add an id to this builder
* @param id the documet id
* @return the updated builder
*/
public Builder id(String id) {
this.id = id;
return this;
}

/**
* Add a tenant id to this builder
* @param tenantId the tenant id
* @return the updated builder
*/
public Builder tenantId(String tenantId) {
this.tenantId = tenantId;
return this;
}

/**
* Add a data object to this builder
* @param dataObject the data object
Expand All @@ -80,7 +122,7 @@ public Builder dataObject(ToXContentObject dataObject) {
* @return A {@link PutDataObjectRequest}
*/
public PutDataObjectRequest build() {
return new PutDataObjectRequest(this.index, this.dataObject);
return new PutDataObjectRequest(this.index, this.id, this.tenantId, this.dataObject);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class UpdateDataObjectRequest {

private final String index;
private final String id;
private final String tenantId;
private final ToXContentObject dataObject;

/**
Expand All @@ -22,11 +23,13 @@ public class UpdateDataObjectRequest {
* 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 tenantId the tenant id
* @param dataObject the data object
arjunkumargiri marked this conversation as resolved.
Show resolved Hide resolved
*/
public UpdateDataObjectRequest(String index, String id, ToXContentObject dataObject) {
public UpdateDataObjectRequest(String index, String id, String tenantId, ToXContentObject dataObject) {
this.index = index;
this.id = id;
this.tenantId = tenantId;
this.dataObject = dataObject;
}

Expand All @@ -45,6 +48,14 @@ public String index() {
public String id() {
return this.id;
}

/**
* Returns the tenant id
* @return the tenantId
*/
public String tenantId() {
return this.tenantId;
}

/**
* Returns the data object
Expand All @@ -60,6 +71,7 @@ public ToXContentObject dataObject() {
public static class Builder {
private String index = null;
private String id = null;
private String tenantId = null;
private ToXContentObject dataObject = null;

/**
Expand Down Expand Up @@ -87,6 +99,16 @@ public Builder id(String id) {
return this;
}

/**
* Add a tenant ID to this builder
* @param tenantId the tenant id
* @return the updated builder
*/
public Builder tenantId(String tenantId) {
this.tenantId = tenantId;
return this;
}

/**
* Add a data object to this builder
* @param dataObject the data object
Expand All @@ -102,7 +124,7 @@ public Builder dataObject(ToXContentObject dataObject) {
* @return A {@link UpdateDataObjectRequest}
*/
public UpdateDataObjectRequest build() {
return new UpdateDataObjectRequest(this.index, this.id, this.dataObject);
return new UpdateDataObjectRequest(this.index, this.id, this.tenantId, this.dataObject);
}
}
}
22 changes: 22 additions & 0 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,28 @@ dependencies {
implementation 'com.jayway.jsonpath:json-path:2.9.0'

implementation "org.opensearch.client:opensearch-java:2.10.2"
// Dynamo dependencies
implementation("software.amazon.awssdk:sdk-core:2.25.40")
implementation("software.amazon.awssdk:aws-core:2.25.40")
implementation "software.amazon.awssdk:aws-json-protocol:2.25.40"
implementation("software.amazon.awssdk:auth:2.25.40")
implementation("software.amazon.awssdk:checksums:2.25.40")
implementation("software.amazon.awssdk:checksums-spi:2.25.40")
implementation("software.amazon.awssdk:dynamodb:2.25.40")
implementation("software.amazon.awssdk:endpoints-spi:2.25.40")
implementation("software.amazon.awssdk:http-auth-aws:2.25.40")
implementation("software.amazon.awssdk:http-auth-spi:2.25.40")
implementation("software.amazon.awssdk:http-client-spi:2.25.40")
implementation("software.amazon.awssdk:identity-spi:2.25.40")
implementation "software.amazon.awssdk:json-utils:2.25.40"
implementation "software.amazon.awssdk:metrics-spi:2.25.40"
implementation("software.amazon.awssdk:profiles:2.25.40")
implementation "software.amazon.awssdk:protocol-core:2.25.40"
implementation("software.amazon.awssdk:regions:2.25.40")
implementation "software.amazon.awssdk:third-party-jackson-core:2.25.40"
implementation("software.amazon.awssdk:url-connection-client:2.25.40")
implementation("software.amazon.awssdk:utils:2.25.40")


configurations.all {
resolutionStrategy.force 'org.apache.httpcomponents.core5:httpcore5:5.2.4'
Expand Down
Loading
Loading