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/252dad9f-d2a9-4d49-bff8-000924f0add4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"services": [
{
"serviceName": "S3",
"type": "minor",
"changeLogMessages": [
"Add GetObjectResponse to TransferUtilityDownloadResponse mapping."
]
}
]
}
121 changes: 76 additions & 45 deletions sdk/src/Services/S3/Custom/Transfer/Internal/ResponseMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,123 +163,154 @@ internal static TransferUtilityUploadResponse MapCompleteMultipartUploadResponse
}

/// <summary>
/// Maps a GetObjectResponse to TransferUtilityDownloadResponse.
/// Uses the field mappings defined in mapping.json "Conversion" -> "GetObjectResponse" -> "DownloadResponse".
/// Private helper method to populate the common properties from GetObjectResponse to the base response class.
Copy link
Contributor Author

@GarrettBeatty GarrettBeatty Oct 23, 2025

Choose a reason for hiding this comment

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

just making a shared helper function for stream and regular download since they have same response object. the only difference is the stream one has an extra responsestream field.

/// Contains all the shared mapping logic for GetObjectResponse fields.
/// </summary>
/// <param name="source">The GetObjectResponse to map from</param>
/// <returns>A new TransferUtilityDownloadResponse with mapped fields</returns>
internal static TransferUtilityDownloadResponse MapGetObjectResponse(GetObjectResponse source)
/// <param name="target">The TransferUtilityGetObjectResponseBase to populate</param>
private static void PopulateGetObjectResponseBase(GetObjectResponse source, TransferUtilityGetObjectResponseBase target)
{
if (source == null)
return null;

var response = new TransferUtilityDownloadResponse();
if (source == null || target == null)
return;

// Map all fields as defined in mapping.json "Conversion" -> "GetObjectResponse" -> "DownloadResponse"
if (source.IsSetAcceptRanges())
response.AcceptRanges = source.AcceptRanges;
target.AcceptRanges = source.AcceptRanges;

if (source.IsSetBucketKeyEnabled())
response.BucketKeyEnabled = source.BucketKeyEnabled.GetValueOrDefault();
target.BucketKeyEnabled = source.BucketKeyEnabled.GetValueOrDefault();

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

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

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

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

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

if (source.IsSetChecksumType())
response.ChecksumType = source.ChecksumType;
target.ChecksumType = source.ChecksumType;

if (source.IsSetContentRange())
response.ContentRange = source.ContentRange;
target.ContentRange = source.ContentRange;

response.Headers = source.Headers;
target.Headers = source.Headers;

if (source.IsSetDeleteMarker())
response.DeleteMarker = source.DeleteMarker;
target.DeleteMarker = source.DeleteMarker;

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

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

if (source.ExpiresString != null)
response.ExpiresString = source.ExpiresString;
target.ExpiresString = source.ExpiresString;

if (source.IsSetLastModified())
response.LastModified = source.LastModified;
target.LastModified = source.LastModified;

if (source.Metadata != null)
response.Metadata = source.Metadata;
target.Metadata = source.Metadata;

if (source.IsSetMissingMeta())
response.MissingMeta = source.MissingMeta;
target.MissingMeta = source.MissingMeta;

if (source.IsSetObjectLockLegalHoldStatus())
response.ObjectLockLegalHoldStatus = source.ObjectLockLegalHoldStatus;
target.ObjectLockLegalHoldStatus = source.ObjectLockLegalHoldStatus;

if (source.IsSetObjectLockMode())
response.ObjectLockMode = source.ObjectLockMode;
target.ObjectLockMode = source.ObjectLockMode;

if (source.IsSetObjectLockRetainUntilDate())
response.ObjectLockRetainUntilDate = source.ObjectLockRetainUntilDate;
target.ObjectLockRetainUntilDate = source.ObjectLockRetainUntilDate;

if (source.IsSetPartsCount())
response.PartsCount = source.PartsCount;
target.PartsCount = source.PartsCount;

if (source.IsSetReplicationStatus())
response.ReplicationStatus = source.ReplicationStatus;
target.ReplicationStatus = source.ReplicationStatus;

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

if (source.RestoreExpiration.HasValue)
response.RestoreExpiration = source.RestoreExpiration;
target.RestoreExpiration = source.RestoreExpiration;

if (source.RestoreInProgress.HasValue)
response.RestoreInProgress = source.RestoreInProgress;
target.RestoreInProgress = source.RestoreInProgress;

if (source.ServerSideEncryptionCustomerMethod != null)
response.ServerSideEncryptionCustomerMethod = source.ServerSideEncryptionCustomerMethod;
target.ServerSideEncryptionCustomerMethod = source.ServerSideEncryptionCustomerMethod;

if (source.ServerSideEncryptionCustomerProvidedKeyMD5 != null)
response.ServerSideEncryptionCustomerProvidedKeyMD5 = source.ServerSideEncryptionCustomerProvidedKeyMD5;
target.ServerSideEncryptionCustomerProvidedKeyMD5 = source.ServerSideEncryptionCustomerProvidedKeyMD5;

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

if (source.IsSetServerSideEncryptionMethod())
response.ServerSideEncryptionMethod = source.ServerSideEncryptionMethod;
target.ServerSideEncryptionMethod = source.ServerSideEncryptionMethod;

if (source.IsSetStorageClass())
response.StorageClass = source.StorageClass;
target.StorageClass = source.StorageClass;

response.TagCount = source.TagCount;
target.TagCount = source.TagCount;

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

if (source.IsSetWebsiteRedirectLocation())
response.WebsiteRedirectLocation = source.WebsiteRedirectLocation;
target.WebsiteRedirectLocation = source.WebsiteRedirectLocation;

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

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

var response = new TransferUtilityDownloadResponse();
PopulateGetObjectResponseBase(source, response);
return response;
}

/// <summary>
/// Maps a GetObjectResponse to TransferUtilityOpenStreamResponse.
/// Uses the same field mappings as DownloadResponse plus the ResponseStream property.
/// </summary>
/// <param name="source">The GetObjectResponse to map from</param>
/// <returns>A new TransferUtilityOpenStreamResponse with mapped fields</returns>
internal static TransferUtilityOpenStreamResponse MapGetObjectResponseToOpenStream(GetObjectResponse source)
{
if (source == null)
return null;

var response = new TransferUtilityOpenStreamResponse();
PopulateGetObjectResponseBase(source, response);
response.ResponseStream = source.ResponseStream;

return response;
}


}
}
Loading