-
Couldn't load subscription status.
- Fork 867
Add GetObjectResponse to TransferUtilityOpenStreamResponse mapping. #4076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: GarrettBeatty/stacked/8
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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." | ||
| ] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
| /// 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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| response.ExpiresString = source.ExpiresString; | ||
| target.ExpiresString = source.ExpiresString; | ||
|
|
||
| if (source.IsSetLastModified()) | ||
| response.LastModified = source.LastModified; | ||
| target.LastModified = source.LastModified; | ||
|
|
||
| if (source.Metadata != null) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: source.Metadata won't be null because the getter always creates one if it doesn't exist |
||
| 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; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be throw an exception instead of returning null? usually we'd want to avoid returning null from a method |
||
|
|
||
| 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; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment about returning null |
||
|
|
||
| var response = new TransferUtilityOpenStreamResponse(); | ||
| PopulateGetObjectResponseBase(source, response); | ||
| response.ResponseStream = source.ResponseStream; | ||
|
|
||
| return response; | ||
| } | ||
|
|
||
|
|
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.