You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by am...@apache.org on 2023/08/21 00:21:35 UTC
[iceberg] branch wip-s3sign-body updated (b11a44029e -> 69ce8c728f)
This is an automated email from the ASF dual-hosted git repository.
amoghj pushed a change to branch wip-s3sign-body
in repository https://gitbox.apache.org/repos/asf/iceberg.git
discard b11a44029e AWS: Update S3 signer spec to allow optional string body in SignRequest. Update S3 signer parser implementation to enable serialization/deserialization of the body. Note: This will only be populated for requests which do not transmit relevant data to sign as part of the URI itself (e.g. DeleteObjectsRequest)
new 69ce8c728f AWS: Update S3 signer spec to allow an optional string body in S3SignRequest. Update S3 signer parser implementation to enable serialization/deserialization of the body. Note: This will only be populated for requests which do not transmit relevant data to sign as part of the URI itself (e.g. DeleteObjectsRequest)
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (b11a44029e)
\
N -- N -- N refs/heads/wip-s3sign-body (69ce8c728f)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
[iceberg] 01/01: AWS: Update S3 signer spec to allow an optional string body in S3SignRequest. Update S3 signer parser implementation to enable serialization/deserialization of the body. Note: This will only be populated for requests which do not transmit relevant data to sign as part of the URI itself (e.g. DeleteObjectsRequest)
Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
amoghj pushed a commit to branch wip-s3sign-body
in repository https://gitbox.apache.org/repos/asf/iceberg.git
commit 69ce8c728f8e0193704e46b50e9801861dff74da
Author: amogh-jahagirdar <am...@tabular.io>
AuthorDate: Sun Aug 20 17:14:45 2023 -0700
AWS: Update S3 signer spec to allow an optional string body in S3SignRequest.
Update S3 signer parser implementation to enable
serialization/deserialization of the body.
Note: This will only be populated for requests which do not transmit
relevant data to sign as part of the URI itself (e.g.
DeleteObjectsRequest)
---
.../iceberg/aws/s3/signer/S3SignRequest.java | 7 ++++
.../iceberg/aws/s3/signer/S3SignRequestParser.java | 9 +++++
aws/src/main/resources/s3-signer-open-api.yaml | 2 ++
.../aws/s3/signer/TestS3SignRequestParser.java | 42 ++++++++++++++++++++++
4 files changed, 60 insertions(+)
diff --git a/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3SignRequest.java b/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3SignRequest.java
index d8323fd868..879ce85993 100644
--- a/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3SignRequest.java
+++ b/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3SignRequest.java
@@ -21,6 +21,7 @@ package org.apache.iceberg.aws.s3.signer;
import java.net.URI;
import java.util.List;
import java.util.Map;
+import javax.annotation.Nullable;
import org.apache.iceberg.rest.RESTRequest;
import org.immutables.value.Value;
@@ -36,6 +37,12 @@ public interface S3SignRequest extends RESTRequest {
Map<String, String> properties();
+ @Value.Default
+ @Nullable
+ default String body() {
+ return null;
+ }
+
@Override
default void validate() {}
}
diff --git a/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3SignRequestParser.java b/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3SignRequestParser.java
index f5d6f711a0..efb11b3cdf 100644
--- a/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3SignRequestParser.java
+++ b/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3SignRequestParser.java
@@ -36,6 +36,7 @@ public class S3SignRequestParser {
private static final String URI = "uri";
private static final String HEADERS = "headers";
private static final String PROPERTIES = "properties";
+ private static final String BODY = "body";
private S3SignRequestParser() {}
@@ -61,6 +62,10 @@ public class S3SignRequestParser {
JsonUtil.writeStringMap(PROPERTIES, request.properties(), gen);
}
+ if (request.body() != null && !request.body().isEmpty()) {
+ gen.writeStringField(BODY, request.body());
+ }
+
gen.writeEndObject();
}
@@ -85,6 +90,10 @@ public class S3SignRequestParser {
builder.properties(JsonUtil.getStringMap(PROPERTIES, json));
}
+ if (json.has(BODY)) {
+ builder.body(JsonUtil.getString(BODY, json));
+ }
+
return builder.build();
}
diff --git a/aws/src/main/resources/s3-signer-open-api.yaml b/aws/src/main/resources/s3-signer-open-api.yaml
index be9775b82c..d264469c5b 100644
--- a/aws/src/main/resources/s3-signer-open-api.yaml
+++ b/aws/src/main/resources/s3-signer-open-api.yaml
@@ -121,6 +121,8 @@ components:
type: object
additionalProperties:
type: string
+ body:
+ type: string
#############################
diff --git a/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3SignRequestParser.java b/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3SignRequestParser.java
index 753d2078c4..a6928183f7 100644
--- a/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3SignRequestParser.java
+++ b/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3SignRequestParser.java
@@ -185,4 +185,46 @@ public class TestS3SignRequestParser {
+ " }\n"
+ "}");
}
+
+ @Test
+ public void roundTripWithBody() {
+ ImmutableS3SignRequest s3SignRequest =
+ ImmutableS3SignRequest.builder()
+ .uri(URI.create("http://localhost:49208/iceberg-signer-test"))
+ .method("PUT")
+ .region("us-west-2")
+ .headers(
+ ImmutableMap.of(
+ "amz-sdk-request",
+ Arrays.asList("attempt=1", "max=4"),
+ "Content-Length",
+ Arrays.asList("191"),
+ "Content-Type",
+ Arrays.asList("application/json"),
+ "User-Agent",
+ Arrays.asList("aws-sdk-java/2.20.18", "Linux/5.4.0-126")))
+ .properties(ImmutableMap.of("k1", "v1"))
+ .body("some-body")
+ .build();
+
+ String json = S3SignRequestParser.toJson(s3SignRequest, true);
+ Assertions.assertThat(S3SignRequestParser.fromJson(json)).isEqualTo(s3SignRequest);
+ Assertions.assertThat(json)
+ .isEqualTo(
+ "{\n"
+ + " \"region\" : \"us-west-2\",\n"
+ + " \"method\" : \"PUT\",\n"
+ + " \"uri\" : \"http://localhost:49208/iceberg-signer-test\",\n"
+ + " \"headers\" : {\n"
+ + " \"amz-sdk-request\" : [ \"attempt=1\", \"max=4\" ],\n"
+ + " \"Content-Length\" : [ \"191\" ],\n"
+ + " \"Content-Type\" : [ \"application/json\" ],\n"
+ + " \"User-Agent\" : [ \"aws-sdk-java/2.20.18\", \"Linux/5.4.0-126\" ]\n"
+ + " },\n"
+ + " \"properties\" : {\n"
+ + " \"k1\" : \"v1\"\n"
+ + " },\n"
+ + " \"body\" : \"some-body\"\n"
+ + "}");
+ }
}