aws-0.18: 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

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, 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, 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

Monoid m => Monad (Response m) Source # 

Methods

(>>=) :: Response m a -> (a -> Response m b) -> Response m b #

(>>) :: Response m a -> Response m b -> Response m b #

return :: a -> Response m a #

fail :: String -> Response m a #

Functor (Response m) Source # 

Methods

fmap :: (a -> b) -> Response m a -> Response m b #

(<$) :: a -> Response m b -> Response m a #

Monoid m => Applicative (Response m) Source # 

Methods

pure :: a -> Response m a #

(<*>) :: Response m (a -> b) -> Response m a -> Response m b #

(*>) :: Response m a -> Response m b -> Response m b #

(<*) :: Response m a -> Response m b -> Response m a #

Monoid m => MonadThrow (Response m) Source # 

Methods

throwM :: Exception e => e -> Response m a #

(Show a, Show m) => Show (Response m a) Source # 

Methods

showsPrec :: Int -> Response m a -> ShowS #

show :: Response m a -> String #

showList :: [Response m a] -> ShowS #

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

Minimal complete definition

loadToMemory

Associated Types

type MemoryResponse resp :: * Source #

Methods

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

Instances

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

Exception types

Query

Service configuration

class DefaultServiceConfiguration config where Source #

Default configuration for a specific service.

Minimal complete definition

defServiceConfig

Methods

defServiceConfig :: config Source #

Default service configuration.

debugServiceConfig :: config Source #

Default debugging-only configuration. (Normally using HTTP instead of HTTPS for easier debugging.)

Instances

DefaultServiceConfiguration (DdbConfiguration NormalQuery) Source # 
DefaultServiceConfiguration (IamConfiguration UriOnlyQuery) Source # 
DefaultServiceConfiguration (IamConfiguration NormalQuery) Source # 
DefaultServiceConfiguration (S3Configuration UriOnlyQuery) Source # 
DefaultServiceConfiguration (S3Configuration NormalQuery) Source # 
DefaultServiceConfiguration (SesConfiguration UriOnlyQuery) Source # 
DefaultServiceConfiguration (SesConfiguration NormalQuery) Source # 
DefaultServiceConfiguration (SdbConfiguration UriOnlyQuery) Source # 
DefaultServiceConfiguration (SdbConfiguration NormalQuery) Source # 
DefaultServiceConfiguration (SqsConfiguration UriOnlyQuery) Source # 
DefaultServiceConfiguration (SqsConfiguration NormalQuery) Source # 

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.

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

class Transaction r a => IteratedTransaction r a | r -> a Source #

A transaction that may need to be split over multiple requests, for example because of upstream response size limits.

Minimal complete definition

nextIteratedRequest

Instances

IteratedTransaction Query QueryResponse Source # 
IteratedTransaction Scan ScanResponse Source # 
IteratedTransaction ListAccessKeys ListAccessKeysResponse Source # 
IteratedTransaction ListMfaDevices ListMfaDevicesResponse Source # 
IteratedTransaction ListUserPolicies ListUserPoliciesResponse Source # 
IteratedTransaction ListUsers ListUsersResponse Source # 
IteratedTransaction GetBucket GetBucketResponse Source # 
IteratedTransaction GetBucketObjectVersions GetBucketObjectVersionsResponse Source # 
IteratedTransaction ListDomains ListDomainsResponse Source # 
IteratedTransaction Select SelectResponse Source # 

Credentials

data Credentials Source #

AWS access credentials.

Constructors

Credentials 

Fields

makeCredentials Source #

Arguments

:: MonadIO io 
=> ByteString

AWS Access Key ID

-> ByteString

AWS Secret Access Key

-> io Credentials 

credentialsDefaultFile :: MonadIO io => io (Maybe FilePath) Source #

The file where access credentials are loaded, when using loadCredentialsDefault. May return Nothing if HOME is unset.

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.