| Copyright | (c) 2015-2016 Brendan Hay |
|---|---|
| License | Mozilla Public License, v. 2.0. |
| Maintainer | Brendan Hay <brendan.g.hay@gmail.com> |
| Stability | provisional |
| Portability | non-portable (GHC extensions) |
| Safe Haskell | None |
| Language | Haskell2010 |
Network.Google.Env
Description
Environment and Google specific configuration for the Network.Google monad.
Synopsis
- data Env (s :: [Symbol]) = Env {
- _envOverride :: !(Dual (Endo ServiceConfig))
- _envLogger :: !Logger
- _envManager :: !Manager
- _envStore :: !(Store s)
- class HasEnv s a | a -> s where
- configure :: HasEnv s a => (ServiceConfig -> ServiceConfig) -> a -> a
- override :: HasEnv s a => ServiceConfig -> a -> a
- timeout :: (MonadReader r m, HasEnv s r) => Seconds -> m a -> m a
- newEnv :: (MonadIO m, MonadCatch m, AllowScopes s) => m (Env s)
- newEnvWith :: (MonadIO m, MonadCatch m, AllowScopes s) => Credentials s -> Logger -> Manager -> m (Env s)
Documentation
data Env (s :: [Symbol]) Source #
The environment containing the parameters required to make Google requests.
Constructors
| Env | |
Fields
| |
Instances
| HasEnv s (Env s) Source # | |
Defined in Network.Google.Env | |
| MonadReader (Env s) (Google s) # | |
class HasEnv s a | a -> s where Source #
Minimal complete definition
Methods
environment :: Lens' a (Env s) Source #
envOverride :: Lens' a (Dual (Endo ServiceConfig)) Source #
The currently applied overrides to all Service configuration.
envLogger :: Lens' a Logger Source #
The function used to output log messages.
envManager :: Lens' a Manager Source #
The Manager used to create and manage open HTTP connections.
envStore :: Lens' a (Store s) Source #
The credential store used to sign requests for authentication with Google.
Instances
| HasEnv s (Env s) Source # | |
Defined in Network.Google.Env | |
configure :: HasEnv s a => (ServiceConfig -> ServiceConfig) -> a -> a Source #
override :: HasEnv s a => ServiceConfig -> a -> a Source #
Override a specific ServiceConfig. All requests belonging to the
supplied service will use this configuration instead of the default.
Typically you would override a modified version of the default ServiceConfig
for the desired service:
override (gmailService & serviceHost .~ "localhost") env
Or when using Network.Google with Control.Monad.Reader or Control.Lens.Zoom
and the ServiceConfig lenses:
local (override (computeService & serviceHost .~ "localhost")) $ do ...
See: configure.
timeout :: (MonadReader r m, HasEnv s r) => Seconds -> m a -> m a Source #
Scope an action such that any HTTP response will use this timeout value.
Default timeouts are chosen by considering:
- This
timeout, if set. - The related
Servicetimeout for the sent request if set. (Default 70s) - The
envManagertimeout, if set. - The
ClientRequesttimeout. (Default 30s)
newEnv :: (MonadIO m, MonadCatch m, AllowScopes s) => m (Env s) Source #
Creates a new environment with a newly initialized Manager, without logging.
and Credentials that are determined by calling getApplicationDefault.
Use newEnvWith to supply custom credentials such as an OAuthClient
and OAuthCode.
The Allowed OAuthScopes are used to authorize any service_account that is
found with the appropriate scopes. See the top-level module of each individual
gogol-* library for a list of available scopes, such as
Network.Google.Compute.authComputeScope.
Lenses from HasEnv can be used to further configure the resulting Env.
See: newEnvWith, getApplicationDefault.
newEnvWith :: (MonadIO m, MonadCatch m, AllowScopes s) => Credentials s -> Logger -> Manager -> m (Env s) Source #
Create a new environment.
See: newEnv.