/*
* 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.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Amazon.Runtime.Internal.Auth;
namespace Amazon.Runtime.Internal
{
///
/// Represents a request being sent to an Amazon Web Service, including the
/// parameters being sent as part of the request, the endpoint to which the
/// request should be sent, etc.
///
/// This class is only intended for internal use inside the AWS client libraries.
/// Callers shouldn't ever interact directly with objects of this class.
///
///
public interface IRequest
{
///
/// The name of the request
///
string RequestName
{
get;
}
///
/// Returns a dictionary of the headers included in this request.
///
IDictionary Headers
{
get;
}
///
/// Gets and sets a flag that indicates whether the request is sent as a query string instead of the request body.
///
bool UseQueryString
{
get;
set;
}
///
/// Returns a dictionary of the parameters included in this request.
///
IDictionary Parameters
{
get;
}
///
/// Collection of parameters included in this request.
///
ParameterCollection ParameterCollection
{
get;
}
///
/// Returns the subresources that should be appended to the resource path.
/// This is used primarily for Amazon S3, where object keys can contain '?'
/// characters, making string-splitting of a resource path potentially
/// hazardous.
///
IDictionary SubResources
{
get;
}
///
/// Adds a new null entry to the SubResources collection for the request
///
/// The name of the subresource
void AddSubResource(string subResource);
///
/// Adds a new entry to the SubResources collection for the request
///
/// The name of the subresource
/// Value of the entry
void AddSubResource(string subResource, string value);
///
/// Gets and sets the type of http request to make, whether it should be POST,GET or DELETE
///
string HttpMethod
{
get;
set;
}
///
/// Gets and Sets the endpoint for this request.
///
Uri Endpoint
{
get;
set;
}
///
/// Gets and Sets the resource path added on to the endpoint.
///
string ResourcePath
{
get;
set;
}
///
/// Returns the path resources that should be used within the resource path.
/// This is used for services where path keys can contain '/'
/// characters, making string-splitting of a resource path potentially
/// hazardous.
///
IDictionary PathResources
{
get;
}
///
/// Adds a new entry to the PathResources collection for the request
///
/// The name of the pathresource with potential greedy syntax: {key+}
/// Value of the entry
void AddPathResource(string key, string value);
///
/// Gets and Sets the version number for the marshaller used to create this request. The version number
/// is used to support backward compatible changes that would otherwise be breaking changes when a
/// newer core is used with an older service assembly.
///
int MarshallerVersion
{
get;
set;
}
///
/// Gets and Sets the content for this request.
///
byte[] Content
{
get;
set;
}
///
/// Gets the header value from the request.
///
string GetHeaderValue(string headerName);
///
/// Flag that signals that Content was and should be set
/// from the Parameters collection.
///
bool SetContentFromParameters { get; set; }
///
/// Gets and sets the content stream.
///
Stream ContentStream
{
get;
set;
}
///
/// Gets and sets the original stream position.
/// If ContentStream is null or does not support seek, this propery
/// should be equal to -1.
///
long OriginalStreamPosition
{
get;
set;
}
///
/// Computes the SHA 256 hash of the content stream. If the stream is not
/// seekable, it searches the parent stream hierarchy to find a seekable
/// stream prior to computation. Once computed, the hash is cached for future
/// use.
///
string ComputeContentStreamHash();
///
/// If the request needs to be signed with a different service name
/// than the client config AuthenticationServiceName, set it here to override
/// the result of DetermineService in AWS4Signer
///
string OverrideSigningServiceName { get; set; }
///
/// The name of the service to which this request is being sent.
///
string ServiceName
{
get;
}
///
/// Returns the original, user facing request object which this internal
/// request object is representing.
///
AmazonWebServiceRequest OriginalRequest
{
get;
}
///
/// Alternate endpoint to use for this request, if any.
///
RegionEndpoint AlternateEndpoint
{
get;
set;
}
///
/// Host prefix value to prepend to the endpoint for this request, if any.
///
string HostPrefix
{
get;
set;
}
///
/// Gets and sets the Suppress404Exceptions property. If true then 404s return back from AWS will not cause an exception and
/// an empty response object will be returned.
///
bool Suppress404Exceptions
{
get;
set;
}
///
/// If using AWS4 signing protocol, contains the resultant parts of the
/// signature that we may need to make use of if we elect to do a chunked
/// encoding upload.
///
AWS4SigningResult AWS4SignerResult
{
get;
set;
}
///
/// WARNING: Setting DisablePayloadSigning to true disables the SigV4 payload signing
/// data integrity check on this request.
/// If using SigV4, the DisablePayloadSigning flag controls if the payload should be
/// signed on a request by request basis. By default this flag is null which will use the
/// default client behavior. The default client behavior is to sign the payload. When
/// DisablePayloadSigning is true, the request will be signed with an UNSIGNED-PAYLOAD value.
/// Setting DisablePayloadSigning to true requires that the request is sent over a HTTPS
/// connection.
/// Under certain circumstances, such as uploading to S3 while using MD5 hashing, it may
/// be desireable to use UNSIGNED-PAYLOAD to decrease signing CPU usage. This flag only applies
/// to Amazon S3 PutObject and UploadPart requests.
/// MD5Stream, SigV4 payload signing, and HTTPS each provide some data integrity
/// verification. If DisableMD5Stream is true and DisablePayloadSigning is true, then the
/// possibility of data corruption is completely dependant on HTTPS being the only remaining
/// source of data integrity verification.
///
bool? DisablePayloadSigning
{
get;
set;
}
///
/// If using SigV4a signing protocol, contains the resultant parts of the
/// signature that we may need to make use of if we elect to do a chunked
/// encoding upload.
///
AWS4aSigningResult AWS4aSignerResult
{
get;
set;
}
///
/// Determine whether to use a chunked encoding upload for the request
/// (applies to Amazon S3 PutObject and UploadPart requests only). If
/// DisablePayloadSigning is true, UseChunkEncoding will be automatically
/// set to false.
///
bool UseChunkEncoding
{
get;
set;
}
///
/// Used for Amazon S3 requests where the bucket name is removed from
/// the marshalled resource path into the host header. To comply with
/// AWS2 signature calculation, we need to recover the bucket name
/// and include it in the resource canonicalization, which we do using
/// this field.
///
string CanonicalResourcePrefix
{
get;
set;
}
///
/// This flag specifies if SigV4 is required for the current request.
///
[Obsolete("UseSigV4 is deprecated. Use SignatureVersion directly instead.")]
bool UseSigV4 { get; set; }
///
/// Specifies which signature version shall be used for the current request.
///
SignatureVersion SignatureVersion { get; set; }
///
/// The authentication region to use for the request.
/// Set from Config.AuthenticationRegion.
///
string AuthenticationRegion { get; set; }
///
/// The region in which the service request was signed.
///
string DeterminedSigningRegion { get; set; }
///
/// Checks if the request stream can be rewinded.
///
/// Returns true if the request stream can be rewinded ,
/// else false.
bool IsRequestStreamRewindable();
///
/// Returns true if the request can contain a request body, else false.
///
/// Returns true if the currect request can contain a request body, else false.
bool MayContainRequestBody();
///
/// Returns true if the request has a body, else false.
///
/// Returns true if the request has a body, else false.
bool HasRequestBody();
///
/// The checksum algorithm that was selected to validate this request's integrity
///
CoreChecksumAlgorithm SelectedChecksum { get; set; }
///
/// Returns a dictionary of the trailing headers included
/// after this request's content.
///
IDictionary TrailingHeaders { get; }
///
/// Determine whether to use double encoding for request's signer.
///
bool UseDoubleEncoding { get; set; }
}
}