Safe Haskell | None |
---|---|
Language | Haskell2010 |
- createHandle :: HasCredentials c => Credentials c -> Options c -> IO (Handle c)
- evalWebApiIO :: Handle c -> WebApiM c a -> IO a
- liftWebApiIO :: IO a -> WebApiM c a
- newtype WebApiM c a = WebApiM {
- runWebApiM :: ReaderT (Handle c) IO a
- class HasCredentials c where
- type Credentials c
- class HasToken c where
- type TokenContent c
- type Options c
- data Token c = Token {
- tToken :: TokenContent c
- tTime :: UTCTime
- accessToken :: HasToken c => WebApiM c (TokenContent c)
- refreshToken :: HasToken c => WebApiM c (Token c)
- data Handle c = Handle {
- credentials :: Credentials c
- token :: TVar (Maybe (Token c))
- options :: Options c
- parseRSAPrivateKey :: MonadThrow m => Text -> m PrivateKey
- data OAuth2Token = OAuth2Token {}
- data KeyException
- data JWTError
- data TokenExchangeException
- data CloudException
- putLbs :: (HasCredentials c, MonadHttp (WebApiM c)) => Url scheme -> Option scheme -> ByteString -> WebApiM c LbsResponse
- getLbs :: (HasCredentials c, MonadHttp (WebApiM c)) => Url scheme -> Option scheme -> WebApiM c LbsResponse
- urlEncode :: String -> String
Running WebApiM programs
createHandle :: HasCredentials c => Credentials c -> Options c -> IO (Handle c) Source #
Create a Handle
with an empty token
Lifting IO programs into WebApiM
liftWebApiIO :: IO a -> WebApiM c a Source #
Lift an `IO a` action into the WebApiM
monad, and catch synchronous exceptions, while rethrowing the asynchronous ones to IO
Types
The main type of the library. It can easily be re-used in libraries that interface with more than one cloud API provider because its type parameter c
lets us be declare distinct behaviours for each.
WebApiM | |
|
Monad (WebApiM c) Source # | |
Functor (WebApiM c) Source # | |
Applicative (WebApiM c) Source # | |
HasCredentials c => Alternative (WebApiM c) Source # | |
MonadIO (WebApiM c) Source # | |
MonadRandom (WebApiM c) Source # | the whole point of this parametrization is to have a distinct MonadHttp for each API provider/DSP instance HasCredentials c => MonadHttp (Boo c) where handleHttpException = throwM |
MonadThrow (WebApiM c) Source # | |
MonadCatch (WebApiM c) Source # | |
MonadReader (Handle c) (WebApiM c) Source # | |
Authentication
class HasCredentials c Source #
type Credentials c Source #
accessToken :: HasToken c => WebApiM c (TokenContent c) Source #
Extract the token content (needed to authenticate subsequent requests). The token will be valid for at least 60 seconds
A Handle
contains all information necessary to communicating with a cloud API provider:
- Authentication credentials (e.g. username/password)
- Authentication token (used to authenticate every API call)
- Options (e.g. GCP authentication scopes)
Handle | |
|
MonadReader (Handle c) (WebApiM c) Source # | |
Private key
parseRSAPrivateKey :: MonadThrow m => Text -> m PrivateKey Source #
Parse a chunk of text into an RSA private key. For Google Cloud Platform , this is the private key associated with the user's "service account" (for server-to-server API use)
https://console.cloud.google.com/apis/credentials
Note: do not supply the RSA header and footer or any newlines (they will be inserted by this function).
OAuth2 related
data OAuth2Token Source #
Exceptions
data KeyException Source #
Authentication key exceptions
Errors associated with JWT-encoded token request
data TokenExchangeException Source #
Token exchange exceptions
NotFound !String | Something went wrong with the request, token not found |
APICredentialsNotFound !String |
data CloudException Source #
Cloud API exception
Utilities
putLbs :: (HasCredentials c, MonadHttp (WebApiM c)) => Url scheme -> Option scheme -> ByteString -> WebApiM c LbsResponse Source #
getLbs :: (HasCredentials c, MonadHttp (WebApiM c)) => Url scheme -> Option scheme -> WebApiM c LbsResponse Source #