Skip to content

Commit 967c564

Browse files
committed
Add GetObjectResponse to TransferUtilityOpenStreamResponse mapping.
stack-info: PR: #4076, branch: GarrettBeatty/stacked/9
1 parent 5aab0cd commit 967c564

File tree

7 files changed

+685
-302
lines changed

7 files changed

+685
-302
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"services": [
3+
{
4+
"serviceName": "S3",
5+
"type": "minor",
6+
"changeLogMessages": [
7+
"Add GetObjectResponse to TransferUtilityDownloadResponse mapping."
8+
]
9+
}
10+
]
11+
}

sdk/src/Services/S3/Custom/Transfer/Internal/ResponseMapper.cs

Lines changed: 78 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*
2121
*/
2222

23+
using System;
2324
using System.Collections.Generic;
2425
using Amazon.S3.Model;
2526

@@ -37,10 +38,11 @@ internal static class ResponseMapper
3738
/// </summary>
3839
/// <param name="source">The PutObjectResponse to map from</param>
3940
/// <returns>A new TransferUtilityUploadResponse with mapped fields</returns>
41+
/// <exception cref="ArgumentNullException">Thrown when source is null</exception>
4042
internal static TransferUtilityUploadResponse MapPutObjectResponse(PutObjectResponse source)
4143
{
4244
if (source == null)
43-
return null;
45+
throw new ArgumentNullException(nameof(source));
4446

4547
var response = new TransferUtilityUploadResponse();
4648

@@ -70,10 +72,11 @@ internal static TransferUtilityUploadResponse MapPutObjectResponse(PutObjectResp
7072
/// </summary>
7173
/// <param name="source">The CompleteMultipartUploadResponse to map from</param>
7274
/// <returns>A new TransferUtilityUploadResponse with mapped fields</returns>
75+
/// <exception cref="ArgumentNullException">Thrown when source is null</exception>
7376
internal static TransferUtilityUploadResponse MapCompleteMultipartUploadResponse(CompleteMultipartUploadResponse source)
7477
{
7578
if (source == null)
76-
return null;
79+
throw new ArgumentNullException(nameof(source));
7780

7881
var response = new TransferUtilityUploadResponse();
7982

@@ -94,55 +97,92 @@ internal static TransferUtilityUploadResponse MapCompleteMultipartUploadResponse
9497
return response;
9598
}
9699

100+
/// <summary>
101+
/// Private helper method to populate the common properties from GetObjectResponse to the base response class.
102+
/// Contains all the shared mapping logic for GetObjectResponse fields.
103+
/// </summary>
104+
/// <param name="source">The GetObjectResponse to map from</param>
105+
/// <param name="target">The TransferUtilityGetObjectResponseBase to populate</param>
106+
/// <exception cref="ArgumentNullException">Thrown when source or target is null</exception>
107+
private static void PopulateGetObjectResponseBase(GetObjectResponse source, TransferUtilityGetObjectResponseBase target)
108+
{
109+
if (source == null)
110+
throw new ArgumentNullException(nameof(source));
111+
if (target == null)
112+
throw new ArgumentNullException(nameof(target));
113+
114+
// Map all fields as defined in mapping.json "Conversion" -> "GetObjectResponse" -> "DownloadResponse"
115+
target.AcceptRanges = source.AcceptRanges;
116+
target.BucketKeyEnabled = source.BucketKeyEnabled.GetValueOrDefault();
117+
target.ChecksumCRC32 = source.ChecksumCRC32;
118+
target.ChecksumCRC32C = source.ChecksumCRC32C;
119+
target.ChecksumCRC64NVME = source.ChecksumCRC64NVME;
120+
target.ChecksumSHA1 = source.ChecksumSHA1;
121+
target.ChecksumSHA256 = source.ChecksumSHA256;
122+
target.ChecksumType = source.ChecksumType;
123+
target.ContentRange = source.ContentRange;
124+
target.Headers = source.Headers;
125+
target.DeleteMarker = source.DeleteMarker;
126+
target.ETag = source.ETag;
127+
target.Expiration = source.Expiration;
128+
target.ExpiresString = source.ExpiresString;
129+
target.LastModified = source.LastModified;
130+
target.Metadata = source.Metadata;
131+
target.MissingMeta = source.MissingMeta;
132+
target.ObjectLockLegalHoldStatus = source.ObjectLockLegalHoldStatus;
133+
target.ObjectLockMode = source.ObjectLockMode;
134+
target.ObjectLockRetainUntilDate = source.ObjectLockRetainUntilDate;
135+
target.PartsCount = source.PartsCount;
136+
target.ReplicationStatus = source.ReplicationStatus;
137+
target.RequestCharged = source.RequestCharged;
138+
target.RestoreExpiration = source.RestoreExpiration;
139+
target.RestoreInProgress = source.RestoreInProgress;
140+
target.ServerSideEncryptionCustomerMethod = source.ServerSideEncryptionCustomerMethod;
141+
target.ServerSideEncryptionCustomerProvidedKeyMD5 = source.ServerSideEncryptionCustomerProvidedKeyMD5;
142+
target.ServerSideEncryptionKeyManagementServiceKeyId = source.ServerSideEncryptionKeyManagementServiceKeyId;
143+
target.ServerSideEncryptionMethod = source.ServerSideEncryptionMethod;
144+
target.StorageClass = source.StorageClass;
145+
target.TagCount = source.TagCount;
146+
target.VersionId = source.VersionId;
147+
target.WebsiteRedirectLocation = source.WebsiteRedirectLocation;
148+
}
149+
97150
/// <summary>
98151
/// Maps a GetObjectResponse to TransferUtilityDownloadResponse.
99152
/// Uses the field mappings defined in mapping.json "Conversion" -> "GetObjectResponse" -> "DownloadResponse".
100153
/// </summary>
101154
/// <param name="source">The GetObjectResponse to map from</param>
102155
/// <returns>A new TransferUtilityDownloadResponse with mapped fields</returns>
156+
/// <exception cref="ArgumentNullException">Thrown when source is null</exception>
103157
internal static TransferUtilityDownloadResponse MapGetObjectResponse(GetObjectResponse source)
104158
{
105159
if (source == null)
106-
return null;
160+
throw new ArgumentNullException(nameof(source));
107161

108162
var response = new TransferUtilityDownloadResponse();
109-
110-
// Map all fields as defined in mapping.json "Conversion" -> "GetObjectResponse" -> "DownloadResponse"
111-
response.AcceptRanges = source.AcceptRanges;
112-
response.BucketKeyEnabled = source.BucketKeyEnabled.GetValueOrDefault();
113-
response.ChecksumCRC32 = source.ChecksumCRC32;
114-
response.ChecksumCRC32C = source.ChecksumCRC32C;
115-
response.ChecksumCRC64NVME = source.ChecksumCRC64NVME;
116-
response.ChecksumSHA1 = source.ChecksumSHA1;
117-
response.ChecksumSHA256 = source.ChecksumSHA256;
118-
response.ChecksumType = source.ChecksumType;
119-
response.ContentRange = source.ContentRange;
120-
response.Headers = source.Headers;
121-
response.DeleteMarker = source.DeleteMarker;
122-
response.ETag = source.ETag;
123-
response.Expiration = source.Expiration;
124-
response.ExpiresString = source.ExpiresString;
125-
response.LastModified = source.LastModified;
126-
response.Metadata = source.Metadata;
127-
response.MissingMeta = source.MissingMeta;
128-
response.ObjectLockLegalHoldStatus = source.ObjectLockLegalHoldStatus;
129-
response.ObjectLockMode = source.ObjectLockMode;
130-
response.ObjectLockRetainUntilDate = source.ObjectLockRetainUntilDate;
131-
response.PartsCount = source.PartsCount;
132-
response.ReplicationStatus = source.ReplicationStatus;
133-
response.RequestCharged = source.RequestCharged;
134-
response.RestoreExpiration = source.RestoreExpiration;
135-
response.RestoreInProgress = source.RestoreInProgress;
136-
response.ServerSideEncryptionCustomerMethod = source.ServerSideEncryptionCustomerMethod;
137-
response.ServerSideEncryptionCustomerProvidedKeyMD5 = source.ServerSideEncryptionCustomerProvidedKeyMD5;
138-
response.ServerSideEncryptionKeyManagementServiceKeyId = source.ServerSideEncryptionKeyManagementServiceKeyId;
139-
response.ServerSideEncryptionMethod = source.ServerSideEncryptionMethod;
140-
response.StorageClass = source.StorageClass;
141-
response.TagCount = source.TagCount;
142-
response.VersionId = source.VersionId;
143-
response.WebsiteRedirectLocation = source.WebsiteRedirectLocation;
163+
PopulateGetObjectResponseBase(source, response);
144164
return response;
145165
}
166+
167+
/// <summary>
168+
/// Maps a GetObjectResponse to TransferUtilityOpenStreamResponse.
169+
/// Uses the same field mappings as DownloadResponse plus the ResponseStream property.
170+
/// </summary>
171+
/// <param name="source">The GetObjectResponse to map from</param>
172+
/// <returns>A new TransferUtilityOpenStreamResponse with mapped fields</returns>
173+
/// <exception cref="ArgumentNullException">Thrown when source is null</exception>
174+
internal static TransferUtilityOpenStreamResponse MapGetObjectResponseToOpenStream(GetObjectResponse source)
175+
{
176+
if (source == null)
177+
throw new ArgumentNullException(nameof(source));
178+
179+
var response = new TransferUtilityOpenStreamResponse();
180+
PopulateGetObjectResponseBase(source, response);
181+
response.ResponseStream = source.ResponseStream;
182+
183+
return response;
184+
}
185+
146186

147187
}
148188
}

0 commit comments

Comments
 (0)