on develop help sign in
Adding documentation and Haddock descriptions
commitafde5443c50b03ea240a9c831fcd9b8c9aa61b13 authorBrendan Hay <brendan.g.hay@gmail.com> dateSun 18 Oct 2015, 11:41 (11 years ago) parent197d3ad
4 files changed+111−7
.travis.yml+4 examples/src/Example/Compute.hs+13 gogol/gogol.cabal+11−1 gogol/src/Network/Google.hs+83−6
.travis.yml+4
@@ -219,3 +219,7 @@ matrix:
219219 addons: { apt: { packages: [ghc-7.10.2], sources: [hvr-ghc] } }
220220 - env: GHCVER=7.10.2 LIBRARY=gogol-youtube-analytics
221221 addons: { apt: { packages: [ghc-7.10.2], sources: [hvr-ghc] } }
222+
223+ # Examples
224+ - env: GHCVER=7.10.2 LIBRARY=amazonka-examples
225+ addons: { apt: { packages: [ghc-7.10.2], sources: [hvr-ghc] } }
examples/src/Example/Compute.hs+13
@@ -0,0 +1,13 @@
1+-- |
2+-- Module : Example.Compute
3+-- Copyright : (c) 2015 Brendan Hay
4+-- License : Mozilla Public License, v. 2.0.
5+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
6+-- Stability : provisional
7+-- Portability : non-portable (GHC extensions)
8+--
9+module Example.Compute where
10+
11+example :: IO ()
12+example = pure ()
13+
gogol/gogol.cabal+11−1
@@ -14,7 +14,17 @@ extra-source-files: README.md CHANGELOG.md
1414cabal-version: >= 1.10
1515
1616description:
17− Pending
17+ This client library contains request and response logic to communicate
18+ with Google Services compatible APIs using the types supplied by the
19+ various @gogol-*@ service libraries. See the <http://hackage.haskell.org/packages/#cat:Google Google>
20+ category on Hackage for supported services.
21+ .
22+ To get started, import the desired @gogol-*@ library (such as
23+ <http://hackage.haskell.org/package/gogol-gmail/docs/Network-Google-Gmail.html Network.Google.Gmail>)
24+ and @Network.Google@ from this package.
25+ .
26+ /Warning:/ This is an experimental prototype/preview release which is still
27+ under exploratory development and not intended for public use, caveat emptor!
1828
1929source-repository head
2030 type: git
gogol/src/Network/Google.hs+83−6
@@ -6,6 +6,8 @@
66{-# LANGUAGE TypeFamilies #-}
77{-# LANGUAGE UndecidableInstances #-}
88
9+{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
10+
911-- |
1012-- Module : Network.Google
1113-- Copyright : (c) 2015 Brendan Hay
@@ -14,10 +16,67 @@
1416-- Stability : provisional
1517-- Portability : non-portable (GHC extensions)
1618--
17−module Network.Google where
19+-- This module provides a simple 'AWS' monad and a set of operations which
20+-- can be performed against remote Google Service APIs, for use with the types
21+-- supplied by the various @gogol-*@ libraries.
22+--
23+-- A 'MonadGoogle' typeclass is used as a function constraint to provide automatic
24+-- lifting of functions when embedding 'Google' as a layer inside your own
25+-- application stack.
26+module Network.Google
27+ (
28+ -- * Running Google Actions
29+ Google
30+ , runGoogle
31+ , runResourceT
32+
33+ -- * Authentication and Environment
34+ , newEnv
35+ , Env
36+ , HasEnv (..)
37+
38+ -- ** Credential Discovery
39+ , Credentials (..)
40+
41+ -- * Sending Requests
42+ , send
43+
44+ -- ** Media Downloads
45+ , download
46+
47+ -- ** Service Configuration
48+ -- ** Overriding Defaults
49+ , configure
50+ , override
51+
52+ -- *** Scoped Actions
53+ , reconfigure
54+ , timeout
55+
56+ -- ** Media Uploads
57+ , Body
58+ , ToBody (..)
59+ , OctetStream
60+ , PlainText
61+ , JSON
62+
63+ -- * Running Asynchronous Actions
64+ -- $async
65+
66+ -- * Handling Errors
67+ , AsError (..)
68+ , AsAuthError (..)
69+
70+ , trying
71+ , catching
72+
73+ -- * Re-exported Types
74+ , Proxy (..)
75+ , module Network.Google.Types
76+ ) where
1877
1978import Control.Applicative
20−import Control.Exception.Lens (throwingM)
79+import Control.Exception.Lens
2180import Control.Monad
2281import Control.Monad.Base
2382import Control.Monad.Catch
@@ -34,9 +93,11 @@ import Control.Monad.Trans.Maybe (MaybeT)
3493import Control.Monad.Trans.Resource
3594import qualified Control.Monad.Writer.Lazy as LW
3695import qualified Control.Monad.Writer.Strict as W
96+import Network.Google.Auth
3797import Network.Google.Env
3898import Network.Google.Internal.HTTP
3999import Network.Google.Prelude
100+import Network.Google.Types
40101
41102newtype Google a = Google { unGoogle :: ReaderT Env (ResourceT IO) a }
42103 deriving
@@ -93,19 +154,35 @@ instance (Monoid w, MonadGoogle m) => MonadGoogle (RW.RWST r w s m) where
93154instance (Monoid w, MonadGoogle m) => MonadGoogle (LRW.RWST r w s m) where
94155 liftGoogle = lift . liftGoogle
95156
157+-- | Run a 'Google' aciton using the specified environment.
96158runGoogle :: (MonadResource m, HasEnv r) => r -> Google a -> m a
97159runGoogle e m = liftResourceT $ runReaderT (unGoogle m) (e ^. environment)
98160
161+-- | Send a request, returning the associated response if successful.
162+--
163+-- Throws 'Error'.
99164send :: (MonadGoogle m, GoogleRequest a) => a -> m (Rs a)
100165send x = liftGoogle $ do
101166 e <- ask
102167 r <- perform e x
103168 hoistError r
104169
105−media :: (MonadGoogle m, GoogleRequest (MediaDownload a))
106− => a
107− -> m (Rs (MediaDownload a))
108−media = send . MediaDownload
170+-- | Send a request returning the associated streaming media response if successful.
171+--
172+-- Some request data types have two possible responses, the JSON metadata and
173+-- a streaming media response. Use 'send' to retrieve the metadata and 'download'
174+-- to retrieve the streaming media.
175+--
176+-- Throws 'Error'.
177+download :: (MonadGoogle m, GoogleRequest (MediaDownload a))
178+ => a
179+ -> m (Rs (MediaDownload a))
180+download = send . MediaDownload
109181
110182hoistError :: MonadThrow m => Either Error a -> m a
111183hoistError = either (throwingM _Error) return
184+
185+{- $async
186+Requests can be sent asynchronously, but due to guarantees about resource closure
187+require the use of <http://hackage.haskell.org/package/lifted-async lifted-async>.
188+-}