/*
* Copyright 2010-2013 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.
*/
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Text;
using System.IO;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
namespace Amazon.S3.Model
{
///
/// Container for the parameters to the CopyObject operation.
/// Creates a copy of an object that is already stored in Amazon S3.
///
public partial class CopyObjectRequest : PutWithACLRequest
{
private string srcBucket;
private string srcKey;
private string srcVersionId;
private string dstBucket;
private string dstKey;
private RequestPayer requestPayer;
private S3CannedACL cannedACL;
private string etagToMatch;
private string etagToNotMatch;
private DateTime? modifiedSinceDate;
private DateTime? unmodifiedSinceDate;
private DateTime? modifiedSinceDateUtc;
private DateTime? unmodifiedSinceDateUtc;
private List tagset = new List();
private S3MetadataDirective metadataDirective;
private S3StorageClass storageClass;
private ObjectLockLegalHoldStatus objectLockLegalHoldStatus;
private ObjectLockMode objectLockMode;
private DateTime? objectLockRetainUntilDate;
private string websiteRedirectLocation;
private HeadersCollection headersCollection = new HeadersCollection();
private MetadataCollection metadataCollection = new MetadataCollection();
private ServerSideEncryptionMethod serverSideEncryption;
private ServerSideEncryptionCustomerMethod serverSideCustomerEncryption;
private string serverSideEncryptionCustomerProvidedKey;
private string serverSideEncryptionCustomerProvidedKeyMD5;
private string serverSideEncryptionKeyManagementServiceKeyId;
private string serverSideEncryptionKeyManagementServiceEncryptionContext;
private ServerSideEncryptionCustomerMethod copySourceServerSideCustomerEncryption;
private string copySourceServerSideEncryptionCustomerProvidedKey;
private string copySourceServerSideEncryptionCustomerProvidedKeyMD5;
///
/// The name of the bucket containing the object to copy.
///
public string SourceBucket
{
get { return this.srcBucket; }
set { this.srcBucket = value; }
}
///
/// Checks if SourceBucket property is set.
///
/// true if SourceBucket property is set.
internal bool IsSetSourceBucket()
{
return !System.String.IsNullOrEmpty(this.srcBucket);
}
///
/// The key of the object to copy.
///
public string SourceKey
{
get { return this.srcKey; }
set { this.srcKey = value; }
}
///
/// Checks if SourceKey property is set.
///
/// true if SourceKey property is set.
internal bool IsSetSourceKey()
{
return !System.String.IsNullOrEmpty(this.srcKey);
}
///
/// Specifies a particular version of the source object to copy. By default the latest version is copied.
///
public string SourceVersionId
{
get { return this.srcVersionId; }
set { this.srcVersionId = value; }
}
///
/// Checks if SourceVersionId property is set.
///
/// true if SourceVersionId property is set.
internal bool IsSetSourceVersionId()
{
return !System.String.IsNullOrEmpty(this.srcVersionId);
}
///
/// The name of the bucket to contain the copy of the source object.
///
public string DestinationBucket
{
get { return this.dstBucket; }
set { this.dstBucket = value; }
}
///
/// Checks if DestinationBucket property is set.
///
/// true if DestinationBucket property is set.
internal bool IsSetDestinationBucket()
{
return !System.String.IsNullOrEmpty(this.dstBucket);
}
///
/// The key to be given to the copy of the source object.
///
public string DestinationKey
{
get { return this.dstKey; }
set { this.dstKey = value; }
}
///
/// Checks if DestinationKey property is set.
///
/// true if DestinationKey property is set.
internal bool IsSetDestinationKey()
{
return !System.String.IsNullOrEmpty(this.dstKey);
}
///
/// A canned access control list (CACL) to apply to the object.
/// Please refer to for
/// information on S3 Canned ACLs.
///
public S3CannedACL CannedACL
{
get { return this.cannedACL; }
set { this.cannedACL = value; }
}
// Check to see if CannedACL property is set
internal bool IsSetCannedACL()
{
return cannedACL != null && cannedACL != S3CannedACL.NoACL;
}
///
/// ETag to be matched as a pre-condition for copying the source object
/// otherwise returns a PreconditionFailed.
///
///
/// Copies the object if its entity tag (ETag) matches
/// the specified tag; otherwise return a 412 (precondition failed).
/// Constraints: This property can be used with IfUnmodifiedSince,
/// but cannot be used with other conditional copy properties.
///
public string ETagToMatch
{
get { return this.etagToMatch; }
set { this.etagToMatch = value; }
}
///
/// Checks if ETagToMatch property is set.
///
///
/// Copies the object if its entity tag (ETag) is different
/// than the specified Etag; otherwise returns a 412 (failed condition).
/// Constraints: This header can be used with IfModifiedSince, but cannot
/// be used with other conditional copy properties.
///
/// true if ETagToMatch property is set.
internal bool IsSetETagToMatch()
{
return !System.String.IsNullOrEmpty(this.etagToMatch);
}
///
/// ETag that must not be matched as a pre-condition for copying the source object,
/// otherwise returns a PreconditionFailed.
///
public string ETagToNotMatch
{
get { return this.etagToNotMatch; }
set { this.etagToNotMatch = value; }
}
///
/// Checks if ETagToNotMatch property is set.
///
/// true if ETagToNotMatch property is set.
internal bool IsSetETagToNotMatch()
{
return !System.String.IsNullOrEmpty(this.etagToNotMatch);
}
///
///
/// This property is deprecated. Setting this property results in non-UTC DateTimes not
/// being marshalled correctly. Use ModifiedSinceDateUtc instead. Setting either ModifiedSinceDate or
/// ModifiedSinceDateUtc results in both ModifiedSinceDate and ModifiedSinceDateUtc being assigned,
/// the latest assignment to either one of the two property is reflected in the value of both.
/// ModifiedSinceDate is provided for backwards compatibility only and assigning a non-Utc DateTime
/// to it results in the wrong timestamp being passed to the service.
///
/// Copies the object if it has been modified since the specified time, otherwise returns a PreconditionFailed.
///
///
/// Copies the object if it has been modified since the
/// specified time; otherwise returns a 412 (failed condition).
/// Constraints: This property can be used with ETagToNotMatch,
/// but cannot be used with other conditional copy properties.
///
[Obsolete("Setting this property results in non-UTC DateTimes not being marshalled correctly. " +
"Use ModifiedSinceDateUtc instead. Setting either ModifiedSinceDate or ModifiedSinceDateUtc results in both ModifiedSinceDate and " +
"ModifiedSinceDateUtc being assigned, the latest assignment to either one of the two property is " +
"reflected in the value of both. ModifiedSinceDate is provided for backwards compatibility only and " +
"assigning a non-Utc DateTime to it results in the wrong timestamp being passed to the service.", false)]
public DateTime ModifiedSinceDate
{
get { return this.modifiedSinceDate.GetValueOrDefault(); }
set
{
this.modifiedSinceDate = value;
this.modifiedSinceDateUtc = new DateTime(value.Ticks, DateTimeKind.Utc);
}
}
///
/// Copies the object if it has been modified since the specified time, otherwise returns a PreconditionFailed.
///
///
/// Copies the object if it has been modified since the
/// specified time; otherwise returns a 412 (failed condition).
/// Constraints: This property can be used with ETagToNotMatch,
/// but cannot be used with other conditional copy properties.
///
public DateTime ModifiedSinceDateUtc
{
get { return this.modifiedSinceDateUtc ?? default(DateTime); }
set
{
this.modifiedSinceDateUtc = value;
this.modifiedSinceDate = value;
}
}
///
/// Checks if ModifiedSinceDateUtc property is set.
///
/// true if ModifiedSinceDateUtc property is set.
internal bool IsSetModifiedSinceDateUtc()
{
return this.modifiedSinceDateUtc.HasValue;
}
///
///
/// This property is deprecated. Setting this property results in non-UTC DateTimes not
/// being marshalled correctly. Use UnmodifiedSinceDateUtc instead. Setting either UnmodifiedSinceDate or
/// UnmodifiedSinceDateUtc results in both UnmodifiedSinceDate and UnmodifiedSinceDateUtc being assigned,
/// the latest assignment to either one of the two property is reflected in the value of both.
/// UnmodifiedSinceDate is provided for backwards compatibility only and assigning a non-Utc DateTime
/// to it results in the wrong timestamp being passed to the service.
///
/// Copies the object if it has not been modified since the specified time, otherwise returns a PreconditionFailed.
///
///
/// Copies the object if it hasn't been modified since the
/// specified time; otherwise returns a 412 (precondition failed).
/// Constraints: This property can be used with ETagToMatch,
/// but cannot be used with other conditional copy properties.
///
[Obsolete("Setting this property results in non-UTC DateTimes not being marshalled correctly. " +
"Use UnmodifiedSinceDateUtc instead. Setting either UnmodifiedSinceDate or UnmodifiedSinceDateUtc results in both UnmodifiedSinceDate and " +
"UnmodifiedSinceDateUtc being assigned, the latest assignment to either one of the two property is " +
"reflected in the value of both. UnmodifiedSinceDate is provided for backwards compatibility only and " +
"assigning a non-Utc DateTime to it results in the wrong timestamp being passed to the service.", false)]
public DateTime UnmodifiedSinceDate
{
get { return this.unmodifiedSinceDate ?? default(DateTime); }
set
{
this.unmodifiedSinceDate = value;
this.unmodifiedSinceDateUtc = new DateTime(value.Ticks, DateTimeKind.Utc);
}
}
///
/// Copies the object if it has not been modified since the specified time, otherwise returns a PreconditionFailed.
///
///
/// Copies the object if it hasn't been modified since the
/// specified time; otherwise returns a 412 (precondition failed).
/// Constraints: This property can be used with ETagToMatch,
/// but cannot be used with other conditional copy properties.
///
public DateTime UnmodifiedSinceDateUtc
{
get { return this.unmodifiedSinceDateUtc ?? default(DateTime); }
set
{
this.unmodifiedSinceDateUtc = value;
this.unmodifiedSinceDate = value;
}
}
///
/// Checks if UnmodifiedSinceDateUtc property is set.
///
/// true if UnmodifiedSinceDateUtc property is set.
internal bool IsSetUnmodifiedSinceDateUtc()
{
return this.unmodifiedSinceDateUtc.HasValue;
}
///
/// Specifies whether the metadata is copied from the source object or replaced with metadata provided in the request.
///
///
public S3MetadataDirective MetadataDirective
{
get { return this.metadataDirective; }
set { this.metadataDirective = value; }
}
///
/// Gets and sets the property ObjectLockLegalHoldStatus.
///
/// Specifies whether you want to apply a Legal Hold to the copied object.
///
///
public ObjectLockLegalHoldStatus ObjectLockLegalHoldStatus
{
get { return this.objectLockLegalHoldStatus; }
set { this.objectLockLegalHoldStatus = value; }
}
// Check to see if ObjectLockLegalHoldStatus property is set
internal bool IsSetObjectLockLegalHoldStatus()
{
return this.objectLockLegalHoldStatus != null;
}
///
/// Gets and sets the property ObjectLockMode.
///
/// The Object Lock mode that you want to apply to the copied object.
///
///
public ObjectLockMode ObjectLockMode
{
get { return this.objectLockMode; }
set { this.objectLockMode = value; }
}
// Check to see if ObjectLockMode property is set
internal bool IsSetObjectLockMode()
{
return this.objectLockMode != null;
}
///
/// Gets and sets the property ObjectLockRetainUntilDate.
///
/// The date and time when you want the copied object's Object Lock to expire.
///
///
public DateTime ObjectLockRetainUntilDate
{
get { return this.objectLockRetainUntilDate.GetValueOrDefault(); }
set { this.objectLockRetainUntilDate = value; }
}
// Check to see if ObjectLockRetainUntilDate property is set
internal bool IsSetObjectLockRetainUntilDate()
{
return this.objectLockRetainUntilDate.HasValue;
}
///
/// The Server-side encryption algorithm used when storing this object in S3.
///
///
public ServerSideEncryptionMethod ServerSideEncryptionMethod
{
get { return this.serverSideEncryption; }
set { this.serverSideEncryption = value; }
}
// Check to see if ServerSideEncryption property is set
internal bool IsSetServerSideEncryptionMethod()
{
return this.serverSideEncryption != null && this.serverSideEncryption != ServerSideEncryptionMethod.None;
}
///
/// The id of the AWS Key Management Service key that Amazon S3 should use to encrypt and decrypt the object.
/// If a key id is not specified, the default key will be used for encryption and decryption.
///
public string ServerSideEncryptionKeyManagementServiceKeyId
{
get { return this.serverSideEncryptionKeyManagementServiceKeyId; }
set { this.serverSideEncryptionKeyManagementServiceKeyId = value; }
}
///
/// Checks if ServerSideEncryptionKeyManagementServiceKeyId property is set.
///
/// true if ServerSideEncryptionKeyManagementServiceKeyId property is set.
internal bool IsSetServerSideEncryptionKeyManagementServiceKeyId()
{
return !System.String.IsNullOrEmpty(this.serverSideEncryptionKeyManagementServiceKeyId);
}
///
/// Specifies the AWS KMS Encryption Context to use for object encryption.
/// The value of this header is a base64-encoded UTF-8 string holding JSON with the encryption context key-value pairs.
///
public string ServerSideEncryptionKeyManagementServiceEncryptionContext
{
get { return this.serverSideEncryptionKeyManagementServiceEncryptionContext; }
set { this.serverSideEncryptionKeyManagementServiceEncryptionContext = value; }
}
///
/// Checks if ServerSideEncryptionKeyManagementServiceEncryptionContext property is set.
///
/// true if ServerSideEncryptionKeyManagementServiceEncryptionContext property is set.
internal bool IsSetServerSideEncryptionKeyManagementServiceEncryptionContext()
{
return !System.String.IsNullOrEmpty(this.serverSideEncryptionKeyManagementServiceEncryptionContext);
}
///
/// The type of storage to use for the object. Defaults to 'STANDARD'.
///
///
public S3StorageClass StorageClass
{
get { return this.storageClass; }
set { this.storageClass = value; }
}
// Check to see if StorageClass property is set
internal bool IsSetStorageClass()
{
return this.storageClass != null;
}
///
/// If the bucketName is configured as a website, redirects requests for this object to another object in the same bucketName or to an external URL.
/// Amazon S3 stores the value of this header in the object metadata.
///
///
public string WebsiteRedirectLocation
{
get { return this.websiteRedirectLocation; }
set { this.websiteRedirectLocation = value; }
}
// Check to see if WebsiteRedirectLocation property is set
internal bool IsSetWebsiteRedirectLocation()
{
return this.websiteRedirectLocation != null;
}
///
/// The collection of headers for the request.
///
public HeadersCollection Headers
{
get
{
if (this.headersCollection == null)
this.headersCollection = new HeadersCollection();
return this.headersCollection;
}
}
///
/// The collection of meta data for the request.
///
public MetadataCollection Metadata
{
get
{
if (this.metadataCollection == null)
this.metadataCollection = new MetadataCollection();
return this.metadataCollection;
}
}
///
/// This is a convenience property for Headers.ContentType.
///
public string ContentType
{
get { return this.Headers.ContentType; }
set { this.Headers.ContentType = value; }
}
///
/// The Server-side encryption algorithm to be used with the customer provided key.
///
///
public ServerSideEncryptionCustomerMethod ServerSideEncryptionCustomerMethod
{
get { return this.serverSideCustomerEncryption; }
set { this.serverSideCustomerEncryption = value; }
}
// Check to see if ServerSideEncryptionCustomerMethod property is set
internal bool IsSetServerSideEncryptionCustomerMethod()
{
return this.serverSideCustomerEncryption != null && this.serverSideCustomerEncryption != ServerSideEncryptionCustomerMethod.None;
}
///
/// The base64-encoded encryption key for Amazon S3 to use to encrypt the object
///
/// Using the encryption key you provide as part of your request Amazon S3 manages both the encryption, as it writes
/// to disks, and decryption, when you access your objects. Therefore, you don't need to maintain any data encryption code. The only
/// thing you do is manage the encryption keys you provide.
/// ///
/// When you retrieve an object, you must provide the same encryption key as part of your request. Amazon S3 first verifies
/// the encryption key you provided matches, and then decrypts the object before returning the object data to you.
///
///
/// Important: Amazon S3 does not store the encryption key you provide.
///
///
public string ServerSideEncryptionCustomerProvidedKey
{
get { return this.serverSideEncryptionCustomerProvidedKey; }
set { this.serverSideEncryptionCustomerProvidedKey = value; }
}
///
/// Checks if ServerSideEncryptionCustomerProvidedKey property is set.
///
/// true if ServerSideEncryptionCustomerProvidedKey property is set.
internal bool IsSetServerSideEncryptionCustomerProvidedKey()
{
return !System.String.IsNullOrEmpty(this.serverSideEncryptionCustomerProvidedKey);
}
///
/// The MD5 of the customer encryption key specified in the ServerSideEncryptionCustomerProvidedKey property. The MD5 is
/// base 64 encoded. This field is optional, the SDK will calculate the MD5 if this is not set.
///
public string ServerSideEncryptionCustomerProvidedKeyMD5
{
get { return this.serverSideEncryptionCustomerProvidedKeyMD5; }
set { this.serverSideEncryptionCustomerProvidedKeyMD5 = value; }
}
///
/// Checks if ServerSideEncryptionCustomerProvidedKeyMD5 property is set.
///
/// true if ServerSideEncryptionCustomerProvidedKey property is set.
internal bool IsSetServerSideEncryptionCustomerProvidedKeyMD5()
{
return !System.String.IsNullOrEmpty(this.serverSideEncryptionCustomerProvidedKeyMD5);
}
///
/// The Server-side encryption algorithm to be used with the customer provided key.
///
///
public ServerSideEncryptionCustomerMethod CopySourceServerSideEncryptionCustomerMethod
{
get { return this.copySourceServerSideCustomerEncryption; }
set { this.copySourceServerSideCustomerEncryption = value; }
}
// Check to see if CopySourceServerSideEncryptionCustomerMethod property is set
internal bool IsSetCopySourceServerSideEncryptionCustomerMethod()
{
return this.copySourceServerSideCustomerEncryption != null && this.copySourceServerSideCustomerEncryption != ServerSideEncryptionCustomerMethod.None;
}
///
/// The customer provided encryption key for the source object of the copy.
///
/// Important: Amazon S3 does not store the encryption key you provide.
///
///
public string CopySourceServerSideEncryptionCustomerProvidedKey
{
get { return this.copySourceServerSideEncryptionCustomerProvidedKey; }
set { this.copySourceServerSideEncryptionCustomerProvidedKey = value; }
}
///
/// Checks if CopySourceServerSideEncryptionCustomerProvidedKey property is set.
///
/// true if CopySourceServerSideEncryptionCustomerProvidedKey property is set.
internal bool IsSetCopySourceServerSideEncryptionCustomerProvidedKey()
{
return !System.String.IsNullOrEmpty(this.copySourceServerSideEncryptionCustomerProvidedKey);
}
///
/// The MD5 of the customer encryption key specified in the CopySourceServerSideEncryptionCustomerProvidedKey property. The MD5 is
/// base 64 encoded. This field is optional, the SDK will calculate the MD5 if this is not set.
///
public string CopySourceServerSideEncryptionCustomerProvidedKeyMD5
{
get { return this.copySourceServerSideEncryptionCustomerProvidedKeyMD5; }
set { this.copySourceServerSideEncryptionCustomerProvidedKeyMD5 = value; }
}
///
/// Checks if CopySourceServerSideEncryptionCustomerProvidedKeyMD5 property is set.
///
/// true if CopySourceServerSideEncryptionCustomerProvidedKey property is set.
internal bool IsSetCopySourceServerSideEncryptionCustomerProvidedKeyMD5()
{
return !System.String.IsNullOrEmpty(this.copySourceServerSideEncryptionCustomerProvidedKeyMD5);
}
///
/// Confirms that the requester knows that she or he will be charged for the list objects request.
/// Bucket owners need not specify this parameter in their requests.
///
public RequestPayer RequestPayer
{
get { return this.requestPayer; }
set { this.requestPayer = value; }
}
///
/// Checks to see if RequetsPayer is set.
///
/// true, if RequestPayer property is set.
internal bool IsSetRequestPayer()
{
return requestPayer != null;
}
///
/// The tag-set for the object destination object this value must be used in conjunction with the TaggingDirective. The tag-set must be encoded as URL Query parameters.
///
public List TagSet
{
get { return this.tagset; }
set { this.tagset = value; }
}
///
/// Checks if Tagging property is set
///
/// true if Tagging is set.
internal bool IsSetTagSet()
{
return (this.tagset != null) && (this.tagset.Count > 0);
}
}
}