-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Interface to Google Cloud APIs -- -- High-level, extensible interface to Google Cloud APIs. @package goggles @version 0.2 -- |

Dependencies

-- -- The examples require the following declarations (which in turn mean -- that the req and bytestring libraries are imported -- by the user's project). You will also need the -- OverloadedStrings language extension : -- --
--   import qualified Data.ByteString.Lazy as LB
--   import Network.HTTP.Req (responseBody)
--   import Network.Goggles
--   
-- --

Examples

-- -- This first example, listBucket, reads content from a cloud -- storage bucket: -- --
    --
  1. it loads the GCP credentials (username and RSA key),
  2. --
  3. retrieves a token via OAuth2,
  4. --
  5. performs a single call to the Cloud Storage API endpoint that -- lists the metadata related to the contents of a storage bucket, -- and
  6. --
  7. returns the raw API data to the user as a lazy ByteString.
  8. --
-- --
--   listBucket :: IO LB.ByteString
--   listBucket = do
--     let usr = "...iam.gserviceaccount.com"
--         bucket = "<my-gcs-bucket>"
--         key = "<rsa_key>"
--     pvtkey <- parseRSAPrivateKey key
--     let creds = GCPServiceAccount pvtkey usr Nothing ""
--     hdl <- createHandle creds scopesDefault
--     responseBody <$> evalWebApiIO hdl (listObjects bucket)
--   
module Network.Goggles -- | Create a Handle with an empty token createHandle :: HasCredentials c => Credentials c -> Options c -> IO (Handle c) -- | Evaluate a WebApiM action, given a Handle. -- -- NB : Assumes all exceptions are handled by throwM evalWebApiIO :: Handle c -> WebApiM c a -> IO a -- | Lift an `IO a` action into the WebApiM monad, and catch -- synchronous exceptions, while rethrowing the asynchronous ones to IO liftWebApiIO :: HasCredentials c => IO a -> WebApiM c a -- | 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. newtype WebApiM c a WebApiM :: ReaderT (Handle c) IO a -> WebApiM c a [runWebApiM] :: WebApiM c a -> ReaderT (Handle c) IO a -- | This class class HasCredentials c where { type family Credentials c; type family Options c; type family TokenContent c; } tokenFetch :: HasCredentials c => WebApiM c (Token c) -- | An authentication Token with an expiry date data Token c Token :: TokenContent c -> UTCTime -> Token c [tToken] :: Token c -> TokenContent c [tTime] :: Token c -> UTCTime -- | A Handle contains all information necessary to communicating -- with a cloud API provider: -- -- data Handle c Handle :: Credentials c -> TVar (Maybe (Token c)) -> Options c -> Handle c [credentials] :: Handle c -> Credentials c [token] :: Handle c -> TVar (Maybe (Token c)) [options] :: Handle c -> Options c -- | 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). parseRSAPrivateKey :: MonadThrow m => Text -> m PrivateKey -- | Authentication key exceptions data KeyException NoSecretFound :: !String -> KeyException NoParsePK :: !String -> KeyException NoRSAKey :: !String -> KeyException -- | Errors associated with JWT-encoded token request data JWTError BadExpirationTime :: !String -> JWTError CryptoSignError :: !String -> JWTError -- | Token exchange exceptions data TokenExchangeException -- | Something went wrong with the request, token not found NotFound :: !String -> TokenExchangeException APICredentialsNotFound :: !String -> TokenExchangeException -- | Cloud API exception data CloudException UnknownError :: !String -> CloudException IOError :: !String -> CloudException TimeoutError :: !String -> CloudException JsonDecodeError :: !String -> CloudException XMLDecodeError :: !String -> CloudException module Network.Goggles.Auth