|
15 | 15 |
|
16 | 16 | package software.amazon.awssdk.services.s3.internal;
|
17 | 17 |
|
| 18 | +import com.amazonaws.s3.model.ObjectCannedACL; |
| 19 | +import com.amazonaws.s3.model.ObjectLockLegalHoldStatus; |
| 20 | +import com.amazonaws.s3.model.ObjectLockMode; |
| 21 | +import com.amazonaws.s3.model.PutObjectOutput; |
| 22 | +import com.amazonaws.s3.model.RequestPayer; |
| 23 | +import com.amazonaws.s3.model.ServerSideEncryption; |
| 24 | +import com.amazonaws.s3.model.StorageClass; |
18 | 25 | import software.amazon.awssdk.annotations.SdkInternalApi;
|
19 | 26 | import software.amazon.awssdk.auth.credentials.AwsCredentials;
|
20 | 27 | import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
|
|
23 | 30 | import software.amazon.awssdk.crt.auth.credentials.StaticCredentialsProvider;
|
24 | 31 | import software.amazon.awssdk.services.s3.model.GetObjectRequest;
|
25 | 32 | import software.amazon.awssdk.services.s3.model.GetObjectResponse;
|
| 33 | +import software.amazon.awssdk.services.s3.model.PutObjectRequest; |
| 34 | +import software.amazon.awssdk.services.s3.model.PutObjectResponse; |
26 | 35 |
|
27 | 36 | @SdkInternalApi
|
28 | 37 | public final class S3CrtUtils {
|
@@ -64,21 +73,82 @@ public static com.amazonaws.s3.model.GetObjectRequest adaptGetObjectRequest(GetO
|
64 | 73 | // TODO: codegen
|
65 | 74 | public static GetObjectResponse adaptGetObjectOutput(com.amazonaws.s3.model.GetObjectOutput response) {
|
66 | 75 | return GetObjectResponse.builder()
|
67 |
| - .bucketKeyEnabled(response.bucketKeyEnabled()) |
68 |
| - .acceptRanges(response.acceptRanges()) |
69 |
| - .contentDisposition(response.contentDisposition()) |
70 |
| - .cacheControl(response.cacheControl()) |
71 |
| - .contentEncoding(response.contentEncoding()) |
72 |
| - .contentLanguage(response.contentLanguage()) |
73 |
| - .contentRange(response.contentRange()) |
74 |
| - .contentLength(response.contentLength()) |
75 |
| - .contentType(response.contentType()) |
76 |
| - .deleteMarker(response.deleteMarker()) |
77 |
| - .eTag(response.eTag()) |
78 |
| - .expiration(response.expiration()) |
79 |
| - .expires(response.expires()) |
80 |
| - .lastModified(response.lastModified()) |
81 |
| - .metadata(response.metadata()) |
82 |
| - .build(); |
| 76 | + .bucketKeyEnabled(response.bucketKeyEnabled()) |
| 77 | + .acceptRanges(response.acceptRanges()) |
| 78 | + .contentDisposition(response.contentDisposition()) |
| 79 | + .cacheControl(response.cacheControl()) |
| 80 | + .contentEncoding(response.contentEncoding()) |
| 81 | + .contentLanguage(response.contentLanguage()) |
| 82 | + .contentRange(response.contentRange()) |
| 83 | + .contentLength(response.contentLength()) |
| 84 | + .contentType(response.contentType()) |
| 85 | + .deleteMarker(response.deleteMarker()) |
| 86 | + .eTag(response.eTag()) |
| 87 | + .expiration(response.expiration()) |
| 88 | + .expires(response.expires()) |
| 89 | + .lastModified(response.lastModified()) |
| 90 | + .metadata(response.metadata()) |
| 91 | + .build(); |
| 92 | + } |
| 93 | + |
| 94 | + //TODO: codegen |
| 95 | + public static com.amazonaws.s3.model.PutObjectRequest toCrtPutObjectRequest(PutObjectRequest sdkPutObject) { |
| 96 | + return com.amazonaws.s3.model.PutObjectRequest.builder() |
| 97 | + .contentLength(sdkPutObject.contentLength()) |
| 98 | + .aCL(ObjectCannedACL.fromValue(sdkPutObject.aclAsString())) |
| 99 | + .bucket(sdkPutObject.bucket()) |
| 100 | + .key(sdkPutObject.key()) |
| 101 | + .bucketKeyEnabled(sdkPutObject.bucketKeyEnabled()) |
| 102 | + .cacheControl(sdkPutObject.cacheControl()) |
| 103 | + .contentDisposition(sdkPutObject.contentDisposition()) |
| 104 | + .contentEncoding(sdkPutObject.contentEncoding()) |
| 105 | + .contentLanguage(sdkPutObject.contentLanguage()) |
| 106 | + .contentMD5(sdkPutObject.contentMD5()) |
| 107 | + .contentType(sdkPutObject.contentType()) |
| 108 | + .expectedBucketOwner(sdkPutObject.expectedBucketOwner()) |
| 109 | + .expires(sdkPutObject.expires()) |
| 110 | + .grantFullControl(sdkPutObject.grantFullControl()) |
| 111 | + .grantRead(sdkPutObject.grantRead()) |
| 112 | + .grantReadACP(sdkPutObject.grantReadACP()) |
| 113 | + .grantWriteACP(sdkPutObject.grantWriteACP()) |
| 114 | + .metadata(sdkPutObject.metadata()) |
| 115 | + .objectLockLegalHoldStatus(ObjectLockLegalHoldStatus.fromValue(sdkPutObject.objectLockLegalHoldStatusAsString())) |
| 116 | + .objectLockMode(ObjectLockMode.fromValue(sdkPutObject.objectLockModeAsString())) |
| 117 | + .objectLockRetainUntilDate(sdkPutObject.objectLockRetainUntilDate()) |
| 118 | + .requestPayer(RequestPayer.fromValue(sdkPutObject.requestPayerAsString())) |
| 119 | + .serverSideEncryption(ServerSideEncryption.fromValue(sdkPutObject.requestPayerAsString())) |
| 120 | + .sSECustomerAlgorithm(sdkPutObject.sseCustomerAlgorithm()) |
| 121 | + .sSECustomerKey(sdkPutObject.sseCustomerKey()) |
| 122 | + .sSECustomerKeyMD5(sdkPutObject.sseCustomerKeyMD5()) |
| 123 | + .sSEKMSEncryptionContext(sdkPutObject.ssekmsEncryptionContext()) |
| 124 | + .sSEKMSKeyId(sdkPutObject.ssekmsKeyId()) |
| 125 | + .storageClass(StorageClass.fromValue(sdkPutObject.storageClassAsString())) |
| 126 | + .tagging(sdkPutObject.tagging()) |
| 127 | + .websiteRedirectLocation(sdkPutObject.websiteRedirectLocation()) |
| 128 | + .build(); |
| 129 | + } |
| 130 | + |
| 131 | + //TODO: codegen |
| 132 | + public static PutObjectResponse fromCrtPutObjectOutput(PutObjectOutput crtPutObjectOutput) { |
| 133 | + // TODO: Provide the HTTP request-level data (e.g. response metadata, HTTP response) |
| 134 | + PutObjectResponse.Builder builder = PutObjectResponse.builder() |
| 135 | + .bucketKeyEnabled(crtPutObjectOutput.bucketKeyEnabled()) |
| 136 | + .eTag(crtPutObjectOutput.eTag()) |
| 137 | + .expiration(crtPutObjectOutput.expiration()) |
| 138 | + .sseCustomerAlgorithm(crtPutObjectOutput.sSECustomerAlgorithm()) |
| 139 | + .sseCustomerKeyMD5(crtPutObjectOutput.sSECustomerKeyMD5()) |
| 140 | + .ssekmsEncryptionContext(crtPutObjectOutput.sSEKMSEncryptionContext()) |
| 141 | + .ssekmsKeyId(crtPutObjectOutput.sSEKMSKeyId()) |
| 142 | + .versionId(crtPutObjectOutput.versionId()); |
| 143 | + |
| 144 | + if (crtPutObjectOutput.requestCharged() != null) { |
| 145 | + builder.requestCharged(crtPutObjectOutput.requestCharged().value()); |
| 146 | + } |
| 147 | + |
| 148 | + if (crtPutObjectOutput.serverSideEncryption() != null) { |
| 149 | + builder.serverSideEncryption(crtPutObjectOutput.serverSideEncryption().value()); |
| 150 | + } |
| 151 | + |
| 152 | + return builder.build(); |
83 | 153 | }
|
84 | 154 | }
|
0 commit comments