Safe Haskell | Safe-Infered |
---|
- data LogLevel
- type Logger = LogLevel -> Text -> IO ()
- defaultLog :: LogLevel -> Logger
- data Configuration = Configuration {}
- baseConfiguration :: MonadIO io => io Configuration
- dbgConfiguration :: MonadIO io => io Configuration
- aws :: (Transaction r a, MonadIO io) => Configuration -> ServiceConfiguration r -> Manager -> r -> io (Response (ResponseMetadata a) a)
- awsRef :: (Transaction r a, MonadIO io) => Configuration -> ServiceConfiguration r -> Manager -> IORef (ResponseMetadata a) -> r -> io a
- simpleAws :: (Transaction r a, MonadIO io) => Configuration -> ServiceConfiguration r -> r -> io (Response (ResponseMetadata a) a)
- simpleAwsRef :: (Transaction r a, MonadIO io) => Configuration -> ServiceConfiguration r -> IORef (ResponseMetadata a) -> r -> io a
- unsafeAws :: (ResponseConsumer r a, Monoid (ResponseMetadata a), SignQuery r, MonadIO io) => Configuration -> ServiceConfiguration r -> Manager -> r -> io (Response (ResponseMetadata a) a)
- unsafeAwsRef :: (ResponseConsumer r a, Monoid (ResponseMetadata a), SignQuery r, MonadIO io) => Configuration -> ServiceConfiguration r -> Manager -> IORef (ResponseMetadata a) -> r -> io a
- awsUri :: (SignQuery request, MonadIO io) => Configuration -> ServiceConfiguration request -> request -> io ByteString
- type HTTPResponseConsumer a = Status -> ResponseHeaders -> Source (ResourceT IO) ByteString -> ResourceT IO a
- data Response m a = Response m (Attempt a)
- newtype XmlException = XmlException {}
- newtype HeaderException = HeaderException {}
- newtype FormException = FormException {}
- class DefaultServiceConfiguration config where
- defaultConfiguration :: config
- defaultConfigurationUri :: config
- debugConfiguration :: config
- debugConfigurationUri :: config
- data TimeInfo
- class (SignQuery r, ResponseConsumer r a) => Transaction r a | r -> a, a -> r
- data Credentials = Credentials {}
- credentialsDefaultFile :: MonadIO io => io FilePath
- credentialsDefaultKey :: Text
- loadCredentialsFromFile :: MonadIO io => FilePath -> Text -> io (Maybe Credentials)
- loadCredentialsFromEnv :: MonadIO io => io (Maybe Credentials)
- loadCredentialsFromEnvOrFile :: MonadIO io => FilePath -> Text -> io (Maybe Credentials)
- loadCredentialsDefault :: MonadIO io => io (Maybe Credentials)
Logging
The severity of a log message, in rising order.
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 -> LoggerSource
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.
Configuration | |
|
baseConfiguration :: MonadIO io => io ConfigurationSource
The default configuration, with credentials loaded from environment variable or configuration file
(see loadCredentialsDefault
).
dbgConfiguration :: MonadIO io => io ConfigurationSource
Debug configuration, which avoids using HTTPS for some queries. DO NOT USE THIS IN PRODUCTION!
Transaction runners
Safe runners
aws :: (Transaction r a, MonadIO io) => Configuration -> ServiceConfiguration r -> Manager -> r -> io (Response (ResponseMetadata a) a)Source
awsRef :: (Transaction r a, MonadIO io) => Configuration -> ServiceConfiguration r -> Manager -> IORef (ResponseMetadata a) -> r -> io aSource
simpleAws :: (Transaction r a, MonadIO io) => Configuration -> ServiceConfiguration r -> r -> io (Response (ResponseMetadata a) a)Source
simpleAwsRef :: (Transaction r a, MonadIO io) => Configuration -> ServiceConfiguration r -> IORef (ResponseMetadata a) -> r -> io aSource
Run an AWS transaction, without HTTP manager and with metadata returned in an IORef
.
Errors are not caught, and need to be handled with exception handlers.
Usage:
ref <- newIORef mempty;
resp <- simpleAwsRef cfg serviceCfg request
Unsafe runners
unsafeAws :: (ResponseConsumer r a, Monoid (ResponseMetadata a), SignQuery r, MonadIO io) => Configuration -> ServiceConfiguration r -> Manager -> r -> 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.
unsafeAwsRef :: (ResponseConsumer r a, Monoid (ResponseMetadata a), SignQuery r, MonadIO io) => Configuration -> ServiceConfiguration r -> Manager -> IORef (ResponseMetadata a) -> r -> io aSource
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.
URI runners
awsUri :: (SignQuery request, MonadIO io) => Configuration -> ServiceConfiguration request -> request -> io ByteStringSource
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
Response
Full HTTP response
type HTTPResponseConsumer a = Status -> ResponseHeaders -> Source (ResourceT IO) ByteString -> ResourceT IO aSource
A full HTTP response parser. Takes HTTP status, response headers, and response body.
Metadata in responses
A response with metadata. Can also contain an error response, or an internal error, via Attempt
.
Response forms a Writer-like monad.
Exception types
newtype XmlException Source
An error that occurred during XML parsing / validation.
newtype HeaderException Source
An error that occurred during header parsing / validation.
newtype FormException Source
An error that occurred during form parsing / validation.
Query
Service configuration
class DefaultServiceConfiguration config whereSource
Default configuration for a specific service.
defaultConfiguration :: configSource
Default service configuration for normal requests.
defaultConfigurationUri :: configSource
Default service configuration for URI-only requests.
debugConfiguration :: configSource
Default debugging-only configuration for normal requests. (Normally using HTTP instead of HTTPS for easier debugging.)
debugConfigurationUri :: configSource
Default debugging-only configuration for URI-only requests. (Normally using HTTP instead of HTTPS for easier debugging.)
Expiration
Whether to restrict the signature validity with a plain timestamp, or with explicit expiration (absolute or relative).
Transactions
class (SignQuery r, ResponseConsumer r a) => Transaction r a | r -> a, a -> rSource
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.
Credentials
data Credentials Source
AWS access credentials.
Credentials | |
|
credentialsDefaultFile :: MonadIO io => io FilePathSource
The file where access credentials are loaded, when using loadCredentialsDefault
.
Value: <user directory>/.aws-keys
credentialsDefaultKey :: TextSource
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.
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: <user directory>/.aws-keys
Default key name: default
See loadCredentialsFromEnv
and loadCredentialsFromFile
for details.