Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions generator/.DevConfigs/433a9a6d-b8ea-4676-b763-70711e8288e6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"services": [
{
"serviceName": "S3",
"type": "patch",
"changeLogMessages": [
"Added CompleteMultipartUploadResponse to TransferUtilityUploadResponse mapping"
]
}
]
}
61 changes: 61 additions & 0 deletions sdk/src/Services/S3/Custom/Transfer/Internal/ResponseMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,67 @@ internal static TransferUtilityUploadResponse MapPutObjectResponse(PutObjectResp

return response;
}

/// <summary>
/// Maps a CompleteMultipartUploadResponse to TransferUtilityUploadResponse.
/// Uses the field mappings defined in mapping.json "Conversion" -> "CompleteMultipartResponse" -> "UploadResponse".
/// </summary>
/// <param name="source">The CompleteMultipartUploadResponse to map from</param>
/// <returns>A new TransferUtilityUploadResponse with mapped fields</returns>
internal static TransferUtilityUploadResponse MapCompleteMultipartUploadResponse(CompleteMultipartUploadResponse source)
{
if (source == null)
return null;

var response = new TransferUtilityUploadResponse();

// Map all fields as defined in mapping.json "Conversion" -> "CompleteMultipartResponse" -> "UploadResponse"
if (source.IsSetBucketKeyEnabled())
Copy link
Contributor

Choose a reason for hiding this comment

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

so anytime a new property is added to CompleteMultipartUploadResponse we have to remember to update this mapping?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you don't really have to validate mapping.json against s3 model per se. If s3 adds a new field, the new TM request/response objects will simply not have those new fields, which means customers will not be able to use them unless we manually update mappings.json and ask SDKs to update their TM implementation to add those new fields

this is the expectation from zoe right now. that its just a one time check we are currently doing. if we get asked to update the mapping.json file then we would need to make updates

response.BucketKeyEnabled = source.BucketKeyEnabled.GetValueOrDefault();

if (source.IsSetChecksumCRC32())
response.ChecksumCRC32 = source.ChecksumCRC32;

if (source.IsSetChecksumCRC32C())
response.ChecksumCRC32C = source.ChecksumCRC32C;

if (source.IsSetChecksumCRC64NVME())
response.ChecksumCRC64NVME = source.ChecksumCRC64NVME;

if (source.IsSetChecksumSHA1())
response.ChecksumSHA1 = source.ChecksumSHA1;

if (source.IsSetChecksumSHA256())
response.ChecksumSHA256 = source.ChecksumSHA256;

if (source.ChecksumType != null)
response.ChecksumType = source.ChecksumType;

if (source.IsSetETag())
response.ETag = source.ETag;

if (source.Expiration != null)
response.Expiration = source.Expiration;

if (source.IsSetRequestCharged())
response.RequestCharged = source.RequestCharged;

if (source.ServerSideEncryptionMethod != null)
response.ServerSideEncryptionMethod = source.ServerSideEncryptionMethod;

if (source.IsSetServerSideEncryptionKeyManagementServiceKeyId())
response.ServerSideEncryptionKeyManagementServiceKeyId = source.ServerSideEncryptionKeyManagementServiceKeyId;

if (source.IsSetVersionId())
response.VersionId = source.VersionId;

// Copy response metadata
response.ResponseMetadata = source.ResponseMetadata;
response.ContentLength = source.ContentLength;
response.HttpStatusCode = source.HttpStatusCode;

return response;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
},
"AbortMultipartUploadRequest": {
"Bucket": "BucketName"
},
"CompleteMultipartUploadResponse": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in mapping.json (existing file) we are looking for ServerSideEncryption and SSEKMSKeyId which have slightly different property names in .net compared to other SDKs so we need to add that mapping here

"ServerSideEncryption": "ServerSideEncryptionMethod",
"SSEKMSKeyId": "ServerSideEncryptionKeyManagementServiceKeyId"
}
}
}
50 changes: 50 additions & 0 deletions sdk/test/Services/S3/UnitTests/Custom/ResponseMapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,56 @@ public void ValidateTransferUtilityUploadResponseDefinitionCompleteness()
"TransferUtilityUploadResponse");
}

[TestMethod]
[TestCategory("S3")]
public void MapCompleteMultipartUploadResponse_AllMappedProperties_WorkCorrectly()
{
ValidateMappingTransferUtilityAndSdkRequests<CompleteMultipartUploadResponse, TransferUtilityUploadResponse>(
new[] { "Conversion", "CompleteMultipartResponse", "UploadResponse" },
(sourceResponse) =>
{
return ResponseMapper.MapCompleteMultipartUploadResponse(sourceResponse);
},
usesHeadersCollection: false,
(sourceResponse) =>
{
sourceResponse.HttpStatusCode = HttpStatusCode.OK;
sourceResponse.ContentLength = 2048;
},
(sourceResponse, targetResponse) =>
{
Assert.AreEqual(sourceResponse.HttpStatusCode, targetResponse.HttpStatusCode, "HttpStatusCode should match");
Assert.AreEqual(sourceResponse.ContentLength, targetResponse.ContentLength, "ContentLength should match");
});
}

[TestMethod]
[TestCategory("S3")]
public void MapCompleteMultipartUploadResponse_NullValues_HandledCorrectly()
{
// Test null handling scenarios
var testCases = new[]
{
// Test null Expiration
new CompleteMultipartUploadResponse { Expiration = null },

// Test null enum conversions
new CompleteMultipartUploadResponse { ChecksumType = null, RequestCharged = null, ServerSideEncryptionMethod = null }
};

foreach (var testCase in testCases)
{
var mapped = ResponseMapper.MapCompleteMultipartUploadResponse(testCase);
Assert.IsNotNull(mapped, "Response should always be mappable");

// Test null handling
if (testCase.Expiration == null)
{
Assert.IsNull(mapped.Expiration, "Null Expiration should map to null");
}
}
}

[TestMethod]
[TestCategory("S3")]
public void ValidateCompleteMultipartUploadResponseConversionCompleteness()
Expand Down