module Network.AWS.Machines.AWS (
AWSProcessT,
AWSSourceT,
RequestMod,
M,
withAWS,
withAWSEnv,
awsSource,
pagedSource,
liftAWS,
liftIO,
MonadIO,
MonadAWS,
MonadBaseControl,
AWST',
Env,
ResourceT,
MonadCatch
) where
import Lawless hiding (
fold,
argument,
mapping,
filtered,
dropping,
droppingWhile,
taking,
takingWhile,
cycled,
iterated,
repeated,
replicated,
(<~),
(<>)
)
import IO
import Text
import Machine
import Network.AWS.Machines.Types
default (Text)
withAWS ∷ (MonadCatch m, MonadIO m, M m) ⇒
Credentials → Logger → Region → AWSProcessT m a b → m [b]
withAWS creds lgr reg f = do
env <- set envRegion reg ∘ set envLogger lgr <$> newEnv creds
withAWSEnv env f
withAWSEnv ∷ (MonadCatch m, MonadIO m, M m) ⇒
Env → AWSProcessT m a b → m [b]
withAWSEnv env f =
runResourceT $ runAWST env $ runT f
awsSource ∷
(AWSRequest a, Foldable f) ⇒
GetResponse f a c
→ [RequestMod a]
→ a
→ AWSSourceT m c
awsSource i ms r =
let
r0 = modRequest ms r
unf _ rs = Just (rs ^. i, Nothing)
nr = \case
Nothing → return Nothing
Just q → liftAWS $ send q >>= return ∘ unf q
in
unfoldT nr (Just r0) >~> asParts
pagedSource ∷
(Foldable f, AWSPager a) ⇒
GetResponse f a c
→ [RequestMod a]
→ a
→ AWSSourceT m c
pagedSource i ms r =
let
unf rq rs = Just (rs ^. i, page rq rs)
nr mr =
case mr of
Nothing → return Nothing
Just q → liftAWS $ send q >>= return ∘ unf q
r0 = modRequest ms r
in
unfoldT nr (Just r0) >~> asParts
modRequest ∷
[RequestMod a] → a → a
modRequest [] rq = rq
modRequest (m:ms) rq = modRequest ms $ m rq