Skip to content
Merged
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/7f23582e-3225-487b-83e7-167cf17cb231.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"services": [
{
"serviceName": "S3",
"type": "patch",
"changeLogMessages": [
"Add GetObjectResponse to TransferUtilityDownloadResponse mapping."
]
}
]
}
57 changes: 57 additions & 0 deletions sdk/src/Services/S3/Custom/Transfer/Internal/ResponseMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*
*/

using System.Collections.Generic;
using Amazon.S3.Model;

namespace Amazon.S3.Transfer.Internal
Expand Down Expand Up @@ -104,6 +105,62 @@ internal static TransferUtilityUploadResponse MapCompleteMultipartUploadResponse

return response;
}

/// <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)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i update this in #4076 to throw exception instead of null

return null;

var response = new TransferUtilityDownloadResponse();

// Map all fields as defined in mapping.json "Conversion" -> "GetObjectResponse" -> "DownloadResponse"
response.AcceptRanges = source.AcceptRanges;
response.BucketKeyEnabled = source.BucketKeyEnabled.GetValueOrDefault();
response.ChecksumCRC32 = source.ChecksumCRC32;
response.ChecksumCRC32C = source.ChecksumCRC32C;
response.ChecksumCRC64NVME = source.ChecksumCRC64NVME;
response.ChecksumSHA1 = source.ChecksumSHA1;
response.ChecksumSHA256 = source.ChecksumSHA256;
response.ChecksumType = source.ChecksumType;
response.ContentRange = source.ContentRange;
response.Headers = source.Headers;
response.DeleteMarker = source.DeleteMarker;
response.ETag = source.ETag;
response.Expiration = source.Expiration;
response.ExpiresString = source.ExpiresString;
response.LastModified = source.LastModified;
response.Metadata = source.Metadata;
response.MissingMeta = source.MissingMeta;
response.ObjectLockLegalHoldStatus = source.ObjectLockLegalHoldStatus;
response.ObjectLockMode = source.ObjectLockMode;
response.ObjectLockRetainUntilDate = source.ObjectLockRetainUntilDate;
response.PartsCount = source.PartsCount;
response.ReplicationStatus = source.ReplicationStatus;
response.RequestCharged = source.RequestCharged;
response.RestoreExpiration = source.RestoreExpiration;
response.RestoreInProgress = source.RestoreInProgress;
response.ServerSideEncryptionCustomerMethod = source.ServerSideEncryptionCustomerMethod;
response.ServerSideEncryptionCustomerProvidedKeyMD5 = source.ServerSideEncryptionCustomerProvidedKeyMD5;
response.ServerSideEncryptionKeyManagementServiceKeyId = source.ServerSideEncryptionKeyManagementServiceKeyId;
response.ServerSideEncryptionMethod = source.ServerSideEncryptionMethod;
response.StorageClass = source.StorageClass;
response.TagCount = source.TagCount;
response.VersionId = source.VersionId;
response.WebsiteRedirectLocation = source.WebsiteRedirectLocation;

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

return response;
}

}
}
300 changes: 300 additions & 0 deletions sdk/src/Services/S3/Custom/Transfer/TransferUtilityDownloadResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
/*******************************************************************************
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file.
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
* *****************************************************************************
* __ _ _ ___
* ( )( \/\/ )/ __)
* /__\ \ / \__ \
* (_)(_) \/\/ (___/
*
* AWS SDK for .NET
* API Version: 2006-03-01
*
*/

using System;
using System.Collections.Generic;
using Amazon.Runtime;
using Amazon.S3.Model;

namespace Amazon.S3.Transfer
Copy link
Contributor Author

Choose a reason for hiding this comment

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

eventually this class will be used as the return type of transferUtility.DownloadWithResponseAsync(req)

{
/// <summary>
/// Response object for Transfer Utility download operations.
/// Contains response metadata from download operations.
/// </summary>
public class TransferUtilityDownloadResponse : AmazonWebServiceResponse
{
/// <summary>
/// Gets and sets the AcceptRanges property.
/// </summary>
public string AcceptRanges { get; set; }

/// <summary>
/// Gets and sets the property BucketKeyEnabled.
/// <para>
/// Indicates whether the object uses an S3 Bucket Key for server-side encryption with
/// Amazon Web Services KMS (SSE-KMS).
/// </para>
/// </summary>
public bool? BucketKeyEnabled { get; set; }

/// <summary>
/// The collection of headers for the response.
/// </summary>
public HeadersCollection Headers { get; set; }

/// <summary>
/// Gets and sets the property ChecksumCRC32.
/// <para>
/// The Base64 encoded, 32-bit CRC-32 checksum of the object.
/// </para>
/// </summary>
public string ChecksumCRC32 { get; set; }

/// <summary>
/// Gets and sets the property ChecksumCRC32C.
/// <para>
/// The Base64 encoded, 32-bit CRC-32C checksum of the object.
/// </para>
/// </summary>
public string ChecksumCRC32C { get; set; }

/// <summary>
/// Gets and sets the property ChecksumCRC64NVME.
/// <para>
/// The Base64 encoded, 64-bit CRC-64NVME checksum of the object.
/// </para>
/// </summary>
public string ChecksumCRC64NVME { get; set; }

/// <summary>
/// Gets and sets the property ChecksumSHA1.
/// <para>
/// The Base64 encoded, 160-bit SHA-1 digest of the object.
/// </para>
/// </summary>
public string ChecksumSHA1 { get; set; }

/// <summary>
/// Gets and sets the property ChecksumSHA256.
/// <para>
/// The Base64 encoded, 256-bit SHA-256 checksum of the object.
/// </para>
/// </summary>
public string ChecksumSHA256 { get; set; }

/// <summary>
/// Gets and sets the property ChecksumType.
/// <para>
/// The checksum type used to calculate the object-level checksum.
/// </para>
/// </summary>
public ChecksumType ChecksumType { get; set; }

/// <summary>
/// Gets and sets the ContentRange property.
/// </summary>
public string ContentRange { get; set; }

/// <summary>
/// Gets and sets the DeleteMarker property.
/// <para>
/// Specifies whether the object retrieved was (true) or was not (false) a Delete Marker.
/// </para>
/// </summary>
public string DeleteMarker { get; set; }

/// <summary>
/// Gets and sets the ETag property.
/// <para>
/// An ETag is an opaque identifier assigned by a web server to a specific version of a resource found at a URL.
/// </para>
/// </summary>
public string ETag { get; set; }

/// <summary>
/// Gets and sets the property Expiration.
/// <para>
/// If the object expiration is configured, this will contain the expiration date and rule ID.
/// </para>
/// </summary>
public Expiration Expiration { get; set; }

/// <summary>
/// Gets and sets the ExpiresString property.
/// <para>
/// The date and time at which the object is no longer cacheable (string format).
/// </para>
/// </summary>
public string ExpiresString { get; set; }

/// <summary>
/// Gets and sets the property LastModified.
/// <para>
/// Date and time when the object was last modified.
/// </para>
/// </summary>
public DateTime? LastModified { get; set; }

/// <summary>
/// Gets and sets the Metadata property.
/// <para>
/// The collection of metadata for the object.
/// </para>
/// </summary>
public MetadataCollection Metadata { get; set; }

/// <summary>
/// Gets and sets the property MissingMeta.
/// <para>
/// This is set to the number of metadata entries not returned in the headers that are
/// prefixed with x-amz-meta-.
/// </para>
/// </summary>
public int? MissingMeta { get; set; }

/// <summary>
/// Gets and sets the property ObjectLockLegalHoldStatus.
/// <para>
/// Indicates whether this object has an active legal hold.
/// </para>
/// </summary>
public ObjectLockLegalHoldStatus ObjectLockLegalHoldStatus { get; set; }

/// <summary>
/// Gets and sets the property ObjectLockMode.
/// <para>
/// The Object Lock mode that's currently in place for this object.
/// </para>
/// </summary>
public ObjectLockMode ObjectLockMode { get; set; }

/// <summary>
/// Gets and sets the property ObjectLockRetainUntilDate.
/// <para>
/// The date and time when this object's Object Lock will expire.
/// </para>
/// </summary>
public DateTime? ObjectLockRetainUntilDate { get; set; }

/// <summary>
/// Gets and sets the PartsCount property.
/// <para>
/// The number of parts this object has.
/// </para>
/// </summary>
public int? PartsCount { get; set; }

/// <summary>
/// Gets and sets the property ReplicationStatus.
/// <para>
/// Amazon S3 can return this if your request involves a bucket that is either a source
/// or destination in a replication rule.
/// </para>
/// </summary>
public ReplicationStatus ReplicationStatus { get; set; }

/// <summary>
/// Gets and sets the RequestCharged property.
/// <para>
/// If present, indicates that the requester was successfully charged for the request.
/// </para>
/// </summary>
public RequestCharged RequestCharged { get; set; }

/// <summary>
/// Gets and sets the RestoreExpiration property.
/// <para>
/// RestoreExpiration will be set for objects that have been restored from Amazon Glacier.
/// It indicates for those objects how long the restored object will exist.
/// </para>
/// </summary>
public DateTime? RestoreExpiration { get; set; }

/// <summary>
/// Gets and sets the RestoreInProgress
/// <para>
/// Will be <c>true</c> when the object is in the process of being restored from Amazon Glacier.
/// </para>
/// <para>
/// This functionality is not supported for directory buckets.
/// Only the S3 Express One Zone storage class is supported by directory buckets to store objects.
/// </para>
/// </summary>
public bool? RestoreInProgress { get; set; }

/// <summary>
/// Gets and sets the ServerSideEncryptionCustomerMethod property.
/// <para>
/// The server-side encryption algorithm to be used with the customer provided key.
/// </para>
/// </summary>
public ServerSideEncryptionCustomerMethod ServerSideEncryptionCustomerMethod { get; set; }

/// <summary>
/// Gets and sets the ServerSideEncryptionCustomerProvidedKeyMD5 property.
/// <para>
/// The MD5 server-side encryption of the customer-provided encryption key.
/// </para>
/// </summary>
public string ServerSideEncryptionCustomerProvidedKeyMD5 { get; set; }

/// <summary>
/// Gets and sets the ServerSideEncryptionKeyManagementServiceKeyId property.
/// <para>
/// If present, indicates the ID of the KMS key that was used for object encryption.
/// </para>
/// </summary>
public string ServerSideEncryptionKeyManagementServiceKeyId { get; set; }

/// <summary>
/// Gets and sets the ServerSideEncryptionMethod property.
/// <para>
/// The server-side encryption algorithm used when you store this object in Amazon S3.
/// </para>
/// </summary>
public ServerSideEncryptionMethod ServerSideEncryptionMethod { get; set; }

/// <summary>
/// Gets and sets the property StorageClass.
/// <para>
/// Provides storage class information of the object.
/// </para>
/// </summary>
public S3StorageClass StorageClass { get; set; }

/// <summary>
/// Gets and sets the property TagCount.
/// <para>
/// The number of tags, if any, on the object.
/// </para>
/// </summary>
public int TagCount { get; set; }

/// <summary>
/// Gets and sets the property VersionId.
/// <para>
/// Version ID of the object.
/// </para>
/// </summary>
public string VersionId { get; set; }

/// <summary>
/// Gets and sets the property WebsiteRedirectLocation.
/// <para>
/// If the bucket is configured as a website, redirects requests for this object to another
/// object in the same bucket or to an external URL.
/// </para>
/// </summary>
public string WebsiteRedirectLocation { get; set; }
}
}
Loading