Safe Haskell | None |
---|---|
Language | Haskell2010 |
A monad transformer built on top of functions from Network.AWS which encapsulates various common parameters, errors, and usage patterns.
- type AWS = AWST IO
- data AWST m a
- type MonadAWS m = (MonadBaseControl IO m, MonadCatch m, MonadResource m, MonadError Error m, MonadReader Env m)
- runAWST :: MonadBaseControl IO m => Env -> AWST m a -> m (Either Error a)
- data Env
- envAuth :: Lens' Env Auth
- envRegion :: Lens' Env Region
- envManager :: Lens' Env Manager
- envLogger :: Lens' Env Logger
- scoped :: MonadReader Env m => (Env -> m a) -> m a
- data Credentials :: *
- newEnv :: (Functor m, MonadIO m) => Region -> Credentials -> Manager -> ExceptT String m Env
- getEnv :: Region -> Credentials -> IO Env
- debug :: (MonadIO m, MonadReader Env m) => Text -> m ()
- whenDebug :: MonadReader Env m => m () -> m ()
- data Region :: *
- within :: MonadReader Env m => Region -> m a -> m a
- type Error = ServiceError String
- hoistEither :: (MonadError Error m, AWSError e) => Either e a -> m a
- throwAWSError :: (MonadError Error m, AWSError e) => e -> m a
- verify :: (AWSError e, MonadError Error m) => Prism' e a -> e -> m ()
- verifyWith :: (AWSError e, MonadError Error m) => Prism' e a -> (a -> Bool) -> e -> m ()
- send :: (MonadCatch m, MonadResource m, MonadReader Env m, MonadError Error m, AWSRequest a) => a -> m (Rs a)
- send_ :: (MonadCatch m, MonadResource m, MonadReader Env m, MonadError Error m, AWSRequest a) => a -> m ()
- sendCatch :: (MonadCatch m, MonadResource m, MonadReader Env m, AWSRequest a) => a -> m (Response a)
- paginate :: (MonadCatch m, MonadResource m, MonadReader Env m, MonadError Error m, AWSPager a) => a -> Source m (Rs a)
- paginateCatch :: (MonadCatch m, MonadResource m, MonadReader Env m, AWSPager a) => a -> Source m (Response a)
- presign :: (MonadIO m, MonadReader Env m, AWSRequest a, AWSPresigner (Sg (Sv a))) => a -> UTCTime -> UTCTime -> m (Signed a (Sg (Sv a)))
- module Network.AWS.Types
Transformer
The transformer. This satisfies all of the constraints that the functions
in this module require, such as providing MonadResource
instances,
as well as keeping track of the internal Env
environment.
The MonadError
instance for this transformer internally uses ExceptT
to handle actions that result in an Error
. For more information see
sendCatch
and paginateCatch
.
MFunctor AWST | |
MMonad AWST | |
MonadTrans AWST | |
MonadTransControl AWST | |
MonadBaseControl b m => MonadBaseControl b (AWST m) | |
Monad m => MonadError Error (AWST m) | |
Monad m => MonadReader Env (AWST m) | |
MonadBase b m => MonadBase b (AWST m) | |
(Monad m, Functor m) => Alternative (AWST m) | |
Monad m => Monad (AWST m) | |
Functor m => Functor (AWST m) | |
Monad m => MonadPlus (AWST m) | |
(Monad m, Functor m) => Applicative (AWST m) | |
MonadThrow m => MonadThrow (AWST m) | |
MonadCatch m => MonadCatch (AWST m) | |
MonadIO m => MonadIO (AWST m) | |
(Applicative m, MonadIO m, MonadBase IO m, MonadThrow m) => MonadResource (AWST m) | |
data StT AWST = StTAWS {} | |
data StM (AWST m) = StMAWST {} |
type MonadAWS m = (MonadBaseControl IO m, MonadCatch m, MonadResource m, MonadError Error m, MonadReader Env m) Source
Provides an alias for shortening type signatures if preferred.
Note: requires the ConstraintKinds
extension.
Running
Environment
The environment containing the parameters required to make AWS requests.
Monad m => MonadReader Env (AWST m) |
scoped :: MonadReader Env m => (Env -> m a) -> m a Source
Pass the current environment to a function.
Creating the environment
data Credentials :: *
Determines how authentication information is retrieved.
FromKeys AccessKey SecretKey | Explicit access and secret keys.
Note: you can achieve the same result purely by using |
FromSession AccessKey SecretKey SecurityToken | A session containing the access key, secret key, and a security token.
Note: you can achieve the same result purely by using |
FromProfile Text | An IAM Profile name to lookup from the local EC2 instance-data. |
FromEnv Text Text | Environment variables to lookup for the access and secret keys. |
Discover | Attempt to read the default access and secret keys from the environment, falling back to the first available IAM profile if they are not set. Note: This attempts to resolve http://instance-data rather than directly retrieving http://169.254.169.254 for IAM profile information to ensure the dns lookup terminates promptly if not running on EC2. |
newEnv :: (Functor m, MonadIO m) => Region -> Credentials -> Manager -> ExceptT String m Env Source
This creates a new environment without debug logging and uses getAuth
to expand/discover the supplied Credentials
.
Lenses such as envLogger
can be used to modify the Env
with a debug logger.
Debugging
debug :: (MonadIO m, MonadReader Env m) => Text -> m () Source
Use the logger from envLogger
to log a debug message.
whenDebug :: MonadReader Env m => m () -> m () Source
Regionalisation
data Region :: *
The sum of available AWS regions.
Ireland | Europe / eu-west-1 |
Frankfurt | Europe / eu-central-1 |
Tokyo | Asia Pacific / ap-northeast-1 |
Singapore | Asia Pacific / ap-southeast-1 |
Sydney | Asia Pacific / ap-southeast-2 |
Beijing | China / cn-north-1 |
NorthVirginia | US / us-east-1 |
NorthCalifornia | US / us-west-1 |
Oregon | US / us-west-2 |
GovCloud | AWS GovCloud / us-gov-west-1 |
GovCloudFIPS | AWS GovCloud (FIPS 140-2) S3 Only / fips-us-gov-west-1 |
SaoPaulo | South America / sa-east-1 |
Eq Region | |
Ord Region | |
Read Region | |
Show Region | |
Generic Region | |
Hashable Region | |
Default Region | |
FromXML Region | |
ToXML Region | |
ToByteString Region | |
FromText Region | |
ToText Region | |
type Rep Region = D1 D1Region ((:+:) ((:+:) ((:+:) (C1 C1_0Region U1) ((:+:) (C1 C1_1Region U1) (C1 C1_2Region U1))) ((:+:) (C1 C1_3Region U1) ((:+:) (C1 C1_4Region U1) (C1 C1_5Region U1)))) ((:+:) ((:+:) (C1 C1_6Region U1) ((:+:) (C1 C1_7Region U1) (C1 C1_8Region U1))) ((:+:) (C1 C1_9Region U1) ((:+:) (C1 C1_10Region U1) (C1 C1_11Region U1))))) |
within :: MonadReader Env m => Region -> m a -> m a Source
Scope a monadic action within the specific Region
.
Errors
type Error = ServiceError String Source
The top-level error type.
hoistEither :: (MonadError Error m, AWSError e) => Either e a -> m a Source
throwAWSError :: (MonadError Error m, AWSError e) => e -> m a Source
verifyWith :: (AWSError e, MonadError Error m) => Prism' e a -> (a -> Bool) -> e -> m () Source
Requests
Synchronous
send :: (MonadCatch m, MonadResource m, MonadReader Env m, MonadError Error m, AWSRequest a) => a -> m (Rs a) Source
Send a data type which is an instance of AWSRequest
, returning it's
associated Rs
response type.
This will throw any HTTPException
or AWSServiceError
returned by the
service using the MonadError
instance. In the case of AWST
this will
cause the internal ExceptT
to short-circuit and return an Error
in
the Left
case as the result of the computation.
send_ :: (MonadCatch m, MonadResource m, MonadReader Env m, MonadError Error m, AWSRequest a) => a -> m () Source
A variant of send
which discards any successful response.
sendCatch :: (MonadCatch m, MonadResource m, MonadReader Env m, AWSRequest a) => a -> m (Response a) Source
Send a data type which is an instance of AWSRequest
, returning either the
associated Rs
response type in the success case, or the related service's
Er
type in the error case.
This includes HTTPExceptions
, serialisation errors, and any service
errors returned as part of the Response
.
Paginated
paginate :: (MonadCatch m, MonadResource m, MonadReader Env m, MonadError Error m, AWSPager a) => a -> Source m (Rs a) Source
Send a data type which is an instance of AWSPager
and paginate while
there are more results as defined by the related service operation.
Errors will be handle identically to send
.
Note: The ResumableSource
will close when there are no more results or the
ResourceT
computation is unwrapped. See: runResourceT
for more information.
paginateCatch :: (MonadCatch m, MonadResource m, MonadReader Env m, AWSPager a) => a -> Source m (Response a) Source
Send a data type which is an instance of AWSPager
and paginate over
the associated Rs
response type in the success case, or the related service's
Er
type in the error case.
Note: The ResumableSource
will close when there are no more results or the
ResourceT
computation is unwrapped. See: runResourceT
for more information.
Pre-signing URLs
:: (MonadIO m, MonadReader Env m, AWSRequest a, AWSPresigner (Sg (Sv a))) | |
=> a | Request to presign. |
-> UTCTime | Signing time. |
-> UTCTime | Expiry time. |
-> m (Signed a (Sg (Sv a))) |
Presign a URL with expiry to be used at a later time.
Note: Requires the service's signer to be an instance of AWSPresigner
.
Not all signing process support this.
Types
module Network.AWS.Types