-- 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.4
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
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.Compute.Metadata
metadataServer :: String
projectMetadataPath :: String
instanceMetadataPath :: String
-- | Convenience function to read a metadata value from the server. When
-- talking to the metadata server one has to supply a
-- Metadata-Flavor header, otherwise the server refuses to
-- communicate.
readKey :: String -> Cloud ByteString
-- | Like getJSON but for reading from the metadata server.
readJSON :: (FromJSON a) => String -> Cloud a
-- | The ProjectId is a string which the user can freely chose when
-- creating a new project in the Google cloud. It is globally unique.
newtype ProjectId
ProjectId :: Text -> ProjectId
[unProjectId] :: ProjectId -> Text
projectId :: Cloud ProjectId
-- | The NumericProjectId can also be used to refer to a project on
-- Google cloud. It is globally unique.
newtype NumericProjectId
NumericProjectId :: Integer -> NumericProjectId
[unNumericProjectId] :: NumericProjectId -> Integer
numericProjectId :: Cloud NumericProjectId
-- | A project or instance metadata attribute is a key-value pair.
type Attribute = (ByteString, ByteString)
projectAttributes :: Cloud [Attribute]
-- | The ID of an instance. This is a unique, numerical ID that is
-- generated by Google Compute Engine. This is useful for identifying
-- instances if you do not want to use instance names.
newtype InstanceId
InstanceId :: Integer -> InstanceId
[unInstanceId] :: InstanceId -> Integer
instanceId :: Cloud InstanceId
-- | The fully-qualified machine type name of the instance's host machine.
newtype MachineType
MachineType :: Text -> MachineType
[unMachineType] :: MachineType -> Text
machineType :: Cloud MachineType
-- | The internal hostname of the instance.
internalHostname :: Cloud String
-- | The instance's zone.
newtype Zone
Zone :: Text -> Zone
[unZone] :: Zone -> Text
zone :: Cloud Zone
-- | Fetch an access token for the given service account.
serviceAccountToken :: String -> Cloud Token
module Google.Cloud.Internal.Token
-- | 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
data Handle
-- | 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
data Cloud a
-- | Evaluate a Cloud action and return either the Error or
-- the result.
evalCloud :: Handle -> Cloud a -> IO (Either Error a)