-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Client for the Google Cloud APIs
--
-- Storage, Compute, ...
@package google-cloud
@version 0.0.2
module Google.Cloud.Internal.Metadata
metadataServer :: String
module Google.Cloud.Internal.Types
data Handle
Handle :: !Manager -> !(TVar (Maybe Token)) -> !(Cloud Token) -> Handle
-- | Shared HTTP manager.
[hManager] :: Handle -> !Manager
-- | Cache for the access token. Use accessToken when within the
-- Cloud monad to access the token. That function will
-- automatically refresh it when it is about to expire.
[hToken] :: Handle -> !(TVar (Maybe Token))
-- | The action which is used to fetch a fresh access token.
[hFetchToken] :: Handle -> !(Cloud Token)
data Token
Token :: !UTCTime -> !Text -> Token
[tokenExpiresAt] :: Token -> !UTCTime
[tokenValue] :: Token -> !Text
data Error
UnknownError :: !Text -> Error
IOError :: !String -> Error
DecodeError :: !String -> Error
newtype Cloud a
Cloud :: ReaderT Handle (ExceptT Error IO) a -> Cloud a
[runCloud] :: Cloud a -> ReaderT Handle (ExceptT Error IO) a
-- | Evaluate a Cloud action and return either the Error or
-- the result.
evalCloud :: Handle -> Cloud a -> IO (Either Error a)
-- | Transform an synchronous exception into an Error. Async
-- exceptions are left untouched and propagated into the IO monad.
transformException :: (SomeException -> Error) -> SomeException -> IO Error
-- | Run an IO action inside the Cloud monad, catch all
-- synchronous exceptions and transform them into Errors.
cloudIO :: IO a -> Cloud a
-- | Retry a Cloud action multiple times before failing for good.
--
-- TODO: - Make the retry count configurable - Increase backoff after
-- each failure - Add jitter to the backoff
retry :: Cloud a -> Cloud a
instance Control.Monad.Reader.Class.MonadReader Google.Cloud.Internal.Types.Handle Google.Cloud.Internal.Types.Cloud
instance Control.Monad.Error.Class.MonadError Google.Cloud.Internal.Types.Error Google.Cloud.Internal.Types.Cloud
instance Control.Monad.IO.Class.MonadIO Google.Cloud.Internal.Types.Cloud
instance GHC.Base.Monad Google.Cloud.Internal.Types.Cloud
instance GHC.Base.Applicative Google.Cloud.Internal.Types.Cloud
instance GHC.Base.Functor Google.Cloud.Internal.Types.Cloud
instance GHC.Show.Show Google.Cloud.Internal.Types.Error
instance GHC.Show.Show Google.Cloud.Internal.Types.Token
instance GHC.Base.Alternative Google.Cloud.Internal.Types.Cloud
module Google.Cloud.Internal.HTTP
runRequest :: Request -> Cloud ByteString
post :: String -> RequestHeaders -> ByteString -> Cloud ByteString
get :: String -> RequestHeaders -> Cloud ByteString
getJSON :: (FromJSON a) => String -> RequestHeaders -> Cloud a
module Google.Cloud.Internal.Token
tokenUrl :: String
-- | Fetch the access token for the default service account from the local
-- metadata server. This only works when the code is running in the
-- Google cloud and the instance has a services account attached to it.
defaultMetadataToken :: Cloud Token
-- | Store the token in the cache. If the cache already contains a token,
-- the better one of the two is actually stored (where *better* is
-- defined as the one which expires later). So it is safe to call this
-- function even if you are unsure if the token you have is better than
-- the one which is already in the cache.
--
-- Returns the better token.
cacheToken :: Token -> Cloud Token
refreshToken :: Cloud Token
-- | Return the value of the access token. The function guarantees that the
-- token is valid for at least 60 seconds. Though you should not be
-- afraid to call the function frequently, it caches the token inside the
-- Handle so there is very little overhead.
accessToken :: Cloud Text
-- | Construct a Header that contains the authorization details.
-- Such a header needs to be supplied to all requsts which require
-- authorization.
--
-- Not all requests require it. In particular, requests to the metadata
-- server don't.
authorizationHeader :: Cloud Header
module Google.Cloud.Storage
newtype Bucket
Bucket :: String -> Bucket
[unBucket] :: Bucket -> String
newtype Name
Name :: String -> Name
[unName] :: Name -> String
-- | Upload a ByteString to a Bucket. This is the simplest
-- function to upload something into a Bucket.
uploadMedia :: Bucket -> Name -> ByteString -> ByteString -> Cloud ()
module Google.Cloud
-- | Create a new Handle with sensible defaults. The defaults are
-- such that the Handle works out of the box when the application
-- is running on an instance in the Google cloud.
createHandle :: IO Handle
-- | Create a new Handle with your own configuration options.
mkHandle :: Manager -> Cloud Token -> IO Handle