aws-0.11.3: Amazon Web Services (AWS) for Haskell

Safe HaskellNone
LanguageHaskell2010

Aws

Contents

Synopsis

Logging

data LogLevel Source

The severity of a log message, in rising order.

Constructors

Debug 
Info 
Warning 
Error 

type Logger = LogLevel -> Text -> IO () Source

The interface for any logging function. Takes log level and a log message, and can perform an arbitrary IO action.

defaultLog :: LogLevel -> Logger Source

The default logger defaultLog minLevel, which prints log messages above level minLevel to stderr.

Configuration

data Configuration Source

The configuration for an AWS request. You can use multiple configurations in parallel, even over the same HTTP connection manager.

Constructors

Configuration 

Fields

timeInfo :: TimeInfo

Whether to restrict the signature validity with a plain timestamp, or with explicit expiration (absolute or relative).

credentials :: Credentials

AWS access credentials.

logger :: Logger

The error / message logger.

baseConfiguration :: MonadIO io => io Configuration Source

The default configuration, with credentials loaded from environment variable or configuration file (see loadCredentialsDefault).

dbgConfiguration :: MonadIO io => io Configuration Source

Debug configuration, which logs much more verbosely.

Transaction runners

Safe runners

aws :: Transaction r a => Configuration -> ServiceConfiguration r NormalQuery -> Manager -> r -> ResourceT IO (Response (ResponseMetadata a) a) Source

Run an AWS transaction, with HTTP manager and metadata wrapped in a Response.

All errors are caught and wrapped in the Response value.

Metadata is logged at level Info.

Usage (with existing Manager): resp <- aws cfg serviceCfg manager request

awsRef :: Transaction r a => Configuration -> ServiceConfiguration r NormalQuery -> Manager -> IORef (ResponseMetadata a) -> r -> ResourceT IO a Source

Run an AWS transaction, with HTTP manager and metadata returned in an IORef.

Errors are not caught, and need to be handled with exception handlers.

Metadata is not logged.

Usage (with existing Manager): ref <- newIORef mempty; resp <- awsRef cfg serviceCfg manager request

pureAws :: Transaction r a => Configuration -> ServiceConfiguration r NormalQuery -> Manager -> r -> ResourceT IO a Source

Run an AWS transaction, with HTTP manager and without metadata.

Metadata is logged at level Info.

Usage (with existing Manager): resp <- aws cfg serviceCfg manager request

simpleAws :: (Transaction r a, AsMemoryResponse a, MonadIO io) => Configuration -> ServiceConfiguration r NormalQuery -> r -> io (MemoryResponse a) Source

Run an AWS transaction, without HTTP manager and without metadata.

Metadata is logged at level Info.

Note that this is potentially less efficient than using aws, because HTTP connections cannot be re-used.

Usage: resp <- simpleAws cfg serviceCfg request

Unsafe runners

unsafeAws :: (ResponseConsumer r a, Monoid (ResponseMetadata a), Loggable (ResponseMetadata a), SignQuery r) => Configuration -> ServiceConfiguration r NormalQuery -> Manager -> r -> ResourceT IO (Response (ResponseMetadata a) a) Source

Run an AWS transaction, without enforcing that response and request type form a valid transaction pair.

This is especially useful for debugging and development, you should not have to use it in production.

All errors are caught and wrapped in the Response value.

Metadata is wrapped in the Response, and also logged at level Info.

unsafeAwsRef :: (ResponseConsumer r a, Monoid (ResponseMetadata a), SignQuery r) => Configuration -> ServiceConfiguration r NormalQuery -> Manager -> IORef (ResponseMetadata a) -> r -> ResourceT IO a Source

Run an AWS transaction, without enforcing that response and request type form a valid transaction pair.

This is especially useful for debugging and development, you should not have to use it in production.

Errors are not caught, and need to be handled with exception handlers.

Metadata is put in the IORef, but not logged.

URI runners

awsUri :: (SignQuery request, MonadIO io) => Configuration -> ServiceConfiguration request UriOnlyQuery -> request -> io ByteString Source

Run a URI-only AWS transaction. Returns a URI that can be sent anywhere. Does not work with all requests.

Usage: uri <- awsUri cfg request

Iterated runners

Response

Full HTTP response

type HTTPResponseConsumer a = Response (ResumableSource (ResourceT IO) ByteString) -> ResourceT IO a Source

A full HTTP response parser. Takes HTTP status, response headers, and response body.

Metadata in responses

data Response m a Source

A response with metadata. Can also contain an error response, or an internal error, via Attempt.

Response forms a Writer-like monad.

Instances

readResponse :: MonadThrow n => Response m a -> n a Source

Read a response result (if it's a success response, fail otherwise).

readResponseIO :: MonadIO io => Response m a -> io a Source

Read a response result (if it's a success response, fail otherwise). In MonadIO.

Memory responses

class AsMemoryResponse resp where Source

Class for responses that are fully loaded into memory

Associated Types

type MemoryResponse resp :: * Source

Methods

loadToMemory :: resp -> ResourceT IO (MemoryResponse resp) Source

Instances

AsMemoryResponse DeleteItemResponse 
AsMemoryResponse GetItemResponse 
AsMemoryResponse PutItemResponse 
AsMemoryResponse QueryResponse 
AsMemoryResponse ScanResponse 
AsMemoryResponse ListTablesResult 
AsMemoryResponse DeleteTableResult 
AsMemoryResponse UpdateTableResult 
AsMemoryResponse DescribeTableResult 
AsMemoryResponse CreateTableResult 
AsMemoryResponse UpdateItemResponse 
AsMemoryResponse CreateAccessKeyResponse 
AsMemoryResponse CreateUserResponse 
AsMemoryResponse DeleteAccessKeyResponse 
AsMemoryResponse DeleteUserResponse 
AsMemoryResponse DeleteUserPolicyResponse 
AsMemoryResponse GetUserResponse 
AsMemoryResponse GetUserPolicyResponse 
AsMemoryResponse ListAccessKeysResponse 
AsMemoryResponse ListUserPoliciesResponse 
AsMemoryResponse ListUsersResponse 
AsMemoryResponse PutUserPolicyResponse 
AsMemoryResponse UpdateAccessKeyResponse 
AsMemoryResponse UpdateUserResponse 
AsMemoryResponse CopyObjectResponse 
AsMemoryResponse DeleteBucketResponse 
AsMemoryResponse DeleteObjectResponse 
AsMemoryResponse DeleteObjectsResponse 
AsMemoryResponse GetBucketResponse 
AsMemoryResponse GetBucketLocationResponse 
AsMemoryResponse GetObjectResponse 
AsMemoryResponse GetServiceResponse 
AsMemoryResponse HeadObjectResponse 
AsMemoryResponse PutBucketResponse 
AsMemoryResponse PutObjectResponse 
AsMemoryResponse SendRawEmailResponse 
AsMemoryResponse ListIdentitiesResponse 
AsMemoryResponse VerifyEmailIdentityResponse 
AsMemoryResponse VerifyDomainIdentityResponse 
AsMemoryResponse VerifyDomainDkimResponse 
AsMemoryResponse DeleteIdentityResponse 
AsMemoryResponse GetIdentityDkimAttributesResponse 
AsMemoryResponse GetIdentityNotificationAttributesResponse 
AsMemoryResponse GetIdentityVerificationAttributesResponse 
AsMemoryResponse SetIdentityNotificationTopicResponse 
AsMemoryResponse SetIdentityDkimEnabledResponse 
AsMemoryResponse SetIdentityFeedbackForwardingEnabledResponse 
AsMemoryResponse BatchDeleteAttributesResponse 
AsMemoryResponse BatchPutAttributesResponse 
AsMemoryResponse DeleteAttributesResponse 
AsMemoryResponse PutAttributesResponse 
AsMemoryResponse GetAttributesResponse 
AsMemoryResponse ListDomainsResponse 
AsMemoryResponse DomainMetadataResponse 
AsMemoryResponse DeleteDomainResponse 
AsMemoryResponse CreateDomainResponse 
AsMemoryResponse SelectResponse 
AsMemoryResponse ChangeMessageVisibilityResponse 
AsMemoryResponse ReceiveMessageResponse 
AsMemoryResponse DeleteMessageResponse 
AsMemoryResponse SendMessageResponse 
AsMemoryResponse RemovePermissionResponse 
AsMemoryResponse AddPermissionResponse 
AsMemoryResponse ListQueuesResponse 
AsMemoryResponse DeleteQueueResponse 
AsMemoryResponse CreateQueueResponse 
AsMemoryResponse SetQueueAttributesResponse 
AsMemoryResponse GetQueueAttributesResponse 
AsMemoryResponse AbortMultipartUploadResponse 
AsMemoryResponse CompleteMultipartUploadResponse 
AsMemoryResponse UploadPartResponse 
AsMemoryResponse InitiateMultipartUploadResponse 

Exception types

newtype XmlException Source

An error that occurred during XML parsing / validation.

Constructors

XmlException 

newtype HeaderException Source

An error that occurred during header parsing / validation.

Constructors

HeaderException 

newtype FormException Source

An error that occurred during form parsing / validation.

Constructors

FormException 

Query

Service configuration

Expiration

data TimeInfo Source

Whether to restrict the signature validity with a plain timestamp, or with explicit expiration (absolute or relative).

Constructors

Timestamp

Use a simple timestamp to let AWS check the request validity.

ExpiresAt

Let requests expire at a specific fixed time.

ExpiresIn

Let requests expire a specific number of seconds after they were generated.

Instances

Transactions

class (SignQuery r, ResponseConsumer r a, Loggable (ResponseMetadata a)) => Transaction r a | r -> a Source

Associates a request type and a response type in a bi-directional way.

This allows the type-checker to infer the response type when given the request type and vice versa.

Note that the actual request generation and response parsing resides in SignQuery and ResponseConsumer respectively.

Instances

Transaction DeleteItem DeleteItemResponse 
Transaction GetItem GetItemResponse 
Transaction PutItem PutItemResponse 
Transaction Query QueryResponse 
Transaction Scan ScanResponse 
Transaction ListTables ListTablesResult 
Transaction DeleteTable DeleteTableResult 
Transaction UpdateTable UpdateTableResult 
Transaction DescribeTable DescribeTableResult 
Transaction CreateTable CreateTableResult 
Transaction UpdateItem UpdateItemResponse 
Transaction CreateAccessKey CreateAccessKeyResponse 
Transaction CreateUser CreateUserResponse 
Transaction DeleteAccessKey DeleteAccessKeyResponse 
Transaction DeleteUser DeleteUserResponse 
Transaction DeleteUserPolicy DeleteUserPolicyResponse 
Transaction GetUser GetUserResponse 
Transaction GetUserPolicy GetUserPolicyResponse 
Transaction ListAccessKeys ListAccessKeysResponse 
Transaction ListUserPolicies ListUserPoliciesResponse 
Transaction ListUsers ListUsersResponse 
Transaction PutUserPolicy PutUserPolicyResponse 
Transaction UpdateAccessKey UpdateAccessKeyResponse 
Transaction UpdateUser UpdateUserResponse 
Transaction CopyObject CopyObjectResponse 
Transaction DeleteBucket DeleteBucketResponse 
Transaction DeleteObject DeleteObjectResponse 
Transaction DeleteObjects DeleteObjectsResponse 
Transaction GetBucket GetBucketResponse 
Transaction GetBucketLocation GetBucketLocationResponse 
Transaction GetObject GetObjectResponse 
Transaction GetService GetServiceResponse 
Transaction HeadObject HeadObjectResponse 
Transaction PutBucket PutBucketResponse 
Transaction PutObject PutObjectResponse 
Transaction SendRawEmail SendRawEmailResponse 
Transaction ListIdentities ListIdentitiesResponse 
Transaction VerifyEmailIdentity VerifyEmailIdentityResponse 
Transaction VerifyDomainIdentity VerifyDomainIdentityResponse 
Transaction VerifyDomainDkim VerifyDomainDkimResponse 
Transaction DeleteIdentity DeleteIdentityResponse 
Transaction GetIdentityDkimAttributes GetIdentityDkimAttributesResponse 
Transaction GetIdentityNotificationAttributes GetIdentityNotificationAttributesResponse 
Transaction GetIdentityVerificationAttributes GetIdentityVerificationAttributesResponse 
Transaction SetIdentityNotificationTopic SetIdentityNotificationTopicResponse 
Transaction SetIdentityDkimEnabled SetIdentityDkimEnabledResponse 
Transaction SetIdentityFeedbackForwardingEnabled SetIdentityFeedbackForwardingEnabledResponse 
Transaction BatchDeleteAttributes BatchDeleteAttributesResponse 
Transaction BatchPutAttributes BatchPutAttributesResponse 
Transaction DeleteAttributes DeleteAttributesResponse 
Transaction PutAttributes PutAttributesResponse 
Transaction GetAttributes GetAttributesResponse 
Transaction ListDomains ListDomainsResponse 
Transaction DomainMetadata DomainMetadataResponse 
Transaction DeleteDomain DeleteDomainResponse 
Transaction CreateDomain CreateDomainResponse 
Transaction Select SelectResponse 
Transaction ChangeMessageVisibility ChangeMessageVisibilityResponse 
Transaction ReceiveMessage ReceiveMessageResponse 
Transaction DeleteMessage DeleteMessageResponse 
Transaction SendMessage SendMessageResponse 
Transaction RemovePermission RemovePermissionResponse 
Transaction AddPermission AddPermissionResponse 
Transaction ListQueues ListQueuesResponse 
Transaction DeleteQueue DeleteQueueResponse 
Transaction CreateQueue CreateQueueResponse 
Transaction SetQueueAttributes SetQueueAttributesResponse 
Transaction GetQueueAttributes GetQueueAttributesResponse 
Transaction AbortMultipartUpload AbortMultipartUploadResponse 
Transaction CompleteMultipartUpload CompleteMultipartUploadResponse 
Transaction UploadPart UploadPartResponse 
Transaction InitiateMultipartUpload InitiateMultipartUploadResponse 

Credentials

data Credentials Source

AWS access credentials.

Constructors

Credentials 

Fields

accessKeyID :: ByteString

AWS Access Key ID.

secretAccessKey :: ByteString

AWS Secret Access Key.

v4SigningKeys :: IORef [V4Key]

Signing keys for signature version 4

iamToken :: Maybe ByteString

Signed IAM token

Instances

makeCredentials Source

Arguments

:: MonadIO io 
=> ByteString

AWS Access Key ID

-> ByteString

AWS Secret Access Key

-> io Credentials 

credentialsDefaultFile :: MonadIO io => io FilePath Source

The file where access credentials are loaded, when using loadCredentialsDefault.

Value: directory/.aws-keys

credentialsDefaultKey :: Text Source

The key to be used in the access credential file that is loaded, when using loadCredentialsDefault.

Value: default

loadCredentialsFromFile :: MonadIO io => FilePath -> Text -> io (Maybe Credentials) Source

Load credentials from a (text) file given a key name.

The file consists of a sequence of lines, each in the following format:

keyName awsKeyID awsKeySecret

loadCredentialsFromEnv :: MonadIO io => io (Maybe Credentials) Source

Load credentials from the environment variables AWS_ACCESS_KEY_ID and AWS_ACCESS_KEY_SECRET (or AWS_SECRET_ACCESS_KEY), if possible.

loadCredentialsFromEnvOrFile :: MonadIO io => FilePath -> Text -> io (Maybe Credentials) Source

Load credentials from environment variables if possible, or alternatively from a file with a given key name.

See loadCredentialsFromEnv and loadCredentialsFromFile for details.

loadCredentialsFromEnvOrFileOrInstanceMetadata :: MonadIO io => FilePath -> Text -> io (Maybe Credentials) Source

Load credentials from environment variables if possible, or alternatively from the instance metadata store, or alternatively from a file with a given key name.

See loadCredentialsFromEnv, loadCredentialsFromFile and loadCredentialsFromInstanceMetadata for details.

loadCredentialsDefault :: MonadIO io => io (Maybe Credentials) Source

Load credentials from environment variables if possible, or alternative from the default file with the default key name.

Default file: directory/.aws-keys Default key name: default

See loadCredentialsFromEnv and loadCredentialsFromFile for details.