/*******************************************************************************
* 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.Xml.Serialization;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
using Amazon.S3.Util;
namespace Amazon.S3.Model
{
///
/// The parameters to create a pre-signed URL to a bucket or object.
///
///
/// For more information, refer to: .
///
Required Parameters: BucketName, Expires
///
Optional Parameters: Key, VersionId, Verb: default is GET
///
public class GetPreSignedUrlRequest : AmazonWebServiceRequest
{
#region Private Members
ResponseHeaderOverrides _responseHeaders;
string bucketName;
string key;
DateTime? expires;
Protocol protocol;
HttpVerb verb;
string versionId;
string uploadId;
int? partNumber;
ServerSideEncryptionMethod encryption;
RequestPayer requestPayer;
private string serverSideEncryptionKeyManagementServiceKeyId;
private HeadersCollection headersCollection = new HeadersCollection();
private MetadataCollection metadataCollection = new MetadataCollection();
private ParameterCollection parameterCollection = new ParameterCollection();
private ServerSideEncryptionCustomerMethod serverSideCustomerEncryption;
#endregion
#region BucketName
///
/// The name of the bucket to create a pre-signed url to, or containing the object.
///
public string BucketName
{
get { return this.bucketName; }
set { this.bucketName = value; }
}
///
/// Checks if BucketName property is set.
///
/// true if BucketName property is set.
internal bool IsSetBucketName()
{
return !System.String.IsNullOrEmpty(this.bucketName);
}
#endregion
#region Key
///
/// The key to the object for which a pre-signed url should be created.
///
///
/// This property will be used as part of the resource path of the HTTP request. In .NET the System.Uri class
/// is used to construct the uri for the request. The System.Uri class will canonicalize the uri string by compacting characters like "..". /// For example an object key of "foo/../bar/file.txt" will be transformed into "bar/file.txt" because the ".."
/// is interpreted as use parent directory. For further information view the documentation for
/// the Uri class: https://docs.microsoft.com/en-us/dotnet/api/system.uri
///
public string Key
{
get { return this.key; }
set { this.key = value; }
}
///
/// Checks if Key property is set.
///
/// true if Key property is set.
internal bool IsSetKey()
{
return !System.String.IsNullOrEmpty(this.key);
}
#endregion
#region ContentType
///
/// A standard MIME type describing the format of the object data.
///
///
///
/// The content type for the content being uploaded. This property defaults to "binary/octet-stream".
/// For more information, refer to: .
///
///
/// Note that if content type is specified, it should also be included in the HttpRequest headers
/// of the eventual upload request, otherwise a signature error may result.
///
///
public string ContentType
{
get { return this.headersCollection.ContentType; }
set { this.headersCollection.ContentType = value; }
}
#endregion
#region Expires
///
/// The expiry date and time for the pre-signed url.
///
public DateTime Expires
{
get { return this.expires.GetValueOrDefault(); }
set { this.expires = value; }
}
///
/// Checks if Expires property is set.
///
/// true if Expires property is set.
public bool IsSetExpires()
{
return this.expires.HasValue;
}
#endregion
#region Protocol
///
/// The requested protocol (http/https) for the pre-signed url.
///
///
/// Defaults to https.
///
public Protocol Protocol
{
get { return this.protocol; }
set { this.protocol = value; }
}
#endregion
#region Verb
///
/// The verb for the pre-signed url.
///
///
/// Accepted verbs are GET, PUT, DELETE and HEAD.
/// Default is GET.
///
public HttpVerb Verb
{
get { return this.verb; }
set { this.verb = value; }
}
#endregion
#region VersionId
///
/// Version id for the object that the pre-signed url will reference. If not set,
/// the url will reference the latest version of the object.
///
///
/// This is the VersionId for the S3 Object you want to get
/// a PreSigned URL for. The VersionId property will be ignored
/// for PreSigned "PUT" requests and for requests that don't specify
/// the Key property.
///
public string VersionId
{
get { return this.versionId; }
set { this.versionId = value; }
}
///
/// Checks if VersionId property is set.
///
/// true if VersionId property is set.
internal bool IsSetVersionId()
{
return !System.String.IsNullOrEmpty(this.versionId);
}
#endregion
#region UploadId
///
/// The upload id for the multipart upload for which a pre-signed url should be created.
///
public string UploadId
{
get { return this.uploadId; }
set { this.uploadId = value; }
}
///
/// Checks if UploadId property is set.
///
/// true if UploadId property is set.
internal bool IsSetUploadId()
{
return !System.String.IsNullOrEmpty(this.uploadId);
}
#endregion
#region PartNumber
///
/// The part number for the multipart upload for which a pre-signed url should be created.
///
public int PartNumber
{
get { return this.partNumber ?? default(int); }
set { this.partNumber = value; }
}
///
/// Checks if PartNumber property is set.
///
/// true if PartNumber property is set.
internal bool IsSetPartNumber()
{
return this.partNumber.HasValue;
}
#endregion
#region ServerSideEncryption
///
/// Specifies the encryption used on the server to store the content.
///
///
///
/// Default is None.
///
///
/// If specifying encryption (not None), the corresponding request must include header
/// "x-amz-server-side-encryption" with the value of the encryption.
///
///
public ServerSideEncryptionMethod ServerSideEncryptionMethod
{
get { return this.encryption; }
set { this.encryption = value; }
}
///
/// 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.
///
[AWSProperty(Sensitive=true)]
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);
}
#endregion
#region ServerSideEncryption Customer Key
///
/// 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;
}
#endregion
#region RequestPayer
///
/// Confirms that the requester knows that she or he will be charged for the request.
/// Bucket owners need not specify this parameter in their requests.
///
public RequestPayer RequestPayer
{
get { return this.requestPayer; }
set { this.requestPayer = value; }
}
// Check to see if RequestPayer property is set
internal bool IsSetRequestPayer()
{
return !System.String.IsNullOrEmpty(this.requestPayer);
}
#endregion
#region Response Headers
///
/// A set of response headers that should be returned with the pre-signed url creation response.
///
public ResponseHeaderOverrides ResponseHeaderOverrides
{
get
{
if (this._responseHeaders == null)
{
this._responseHeaders = new ResponseHeaderOverrides();
}
return this._responseHeaders;
}
set
{
this._responseHeaders = value;
}
}
#endregion
#region Headers
///
/// The collection of headers for the request.
///
public HeadersCollection Headers
{
get
{
if (this.headersCollection == null)
this.headersCollection = new HeadersCollection();
return this.headersCollection;
}
internal set
{
this.headersCollection = value;
}
}
#endregion
#region Metadata
///
/// The collection of meta data for the request.
///
public MetadataCollection Metadata
{
get
{
if (this.metadataCollection == null)
this.metadataCollection = new MetadataCollection();
return this.metadataCollection;
}
internal set
{
this.metadataCollection = value;
}
}
#endregion
#region Parameters
///
/// Custom parameters to include in the signed request, so that they are tamper-proof.
///
public ParameterCollection Parameters {
get {
if (this.parameterCollection == null)
this.parameterCollection = new ParameterCollection();
return this.parameterCollection;
}
internal set {
this.parameterCollection = value;
}
}
#endregion
}
}