packages feed

gogol 0.1.0 → 0.1.1

raw patch · 11 files changed

+70/−68 lines, 11 filesdep −data-default-classdep ~gogol-coredep ~http-clientdep ~http-conduitPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies removed: data-default-class

Dependency ranges changed: gogol-core, http-client, http-conduit

API changes (from Hackage documentation)

- Network.Google: Body :: SrictNotUnpackedMediaType -> SrictNotUnpackedRequestBody -> Body
+ Network.Google: Body :: ~MediaType -> ~RequestBody -> Body
- Network.Google: _Error :: AsError a => Prism' a Error
+ Network.Google: _Error :: Prism' a Error
- Network.Google: _SerializeError :: AsError a => Prism' a SerializeError
+ Network.Google: _SerializeError :: Prism' a SerializeError
- Network.Google: _ServiceError :: AsError a => Prism' a ServiceError
+ Network.Google: _ServiceError :: Prism' a ServiceError
- Network.Google: _TransportError :: AsError a => Prism' a HttpException
+ Network.Google: _TransportError :: Prism' a HttpException
- Network.Google.Auth: exchange :: (MonadIO m, MonadCatch m, AllowScopes s) => Credentials s -> Logger -> Manager -> m (Auth s)
+ Network.Google.Auth: exchange :: forall m s. (MonadIO m, MonadCatch m, AllowScopes s) => Credentials s -> Logger -> Manager -> m (Auth s)
- Network.Google.Auth: formURL :: AllowScopes s => OAuthClient -> proxy s -> Text
+ Network.Google.Auth: formURL :: AllowScopes (s :: [Symbol]) => OAuthClient -> proxy s -> Text
- Network.Google.Auth: refresh :: (MonadIO m, MonadCatch m, AllowScopes s) => Auth s -> Logger -> Manager -> m (Auth s)
+ Network.Google.Auth: refresh :: forall m s. (MonadIO m, MonadCatch m, AllowScopes s) => Auth s -> Logger -> Manager -> m (Auth s)
- Network.Google.Auth.InstalledApplication: formURL :: AllowScopes s => OAuthClient -> proxy s -> Text
+ Network.Google.Auth.InstalledApplication: formURL :: AllowScopes (s :: [Symbol]) => OAuthClient -> proxy s -> Text

Files

CHANGELOG.md view
@@ -1,5 +1,20 @@ # Change Log +## [0.1.1](https://github.com/brendanhay/gogol/tree/0.1.1)+Released: **03 November, 2016**, Compare: [0.1.0](https://github.com/brendanhay/gogol/compare/0.1.0...0.1.1)++### Fixed++- Fixes for incorrectly serialised project/commit URL identifiers. [\#34](https://github.com/brendanhay/gogol/pull/34)+- Correcting `/computeMetadta/V1` path prefix for metadata token refresh URLs. [\#37](https://github.com/brendanhay/gogol/pull/37)+- Fixes for Installed Application authentication flow. [\#39](https://github.com/brendanhay/gogol/pull/34)+++### Updated Service Definitions++- All service definitions have been updated to their latest respective versions.++ ## [0.1.0](https://github.com/brendanhay/gogol/tree/0.1.0) Released: **20 June, 2016**, Compare: [0.0.1](https://github.com/brendanhay/gogol/compare/0.0.1...0.1.0) @@ -19,7 +34,6 @@ - `MonadGoogle`, `Google`, `Env`, and `Credentials` types are now constrained by   the required OAuth2 scopes. - GHC 8 support.-  ### Updated Service Definitions 
gogol.cabal view
@@ -1,5 +1,5 @@ name:                  gogol-version:               0.1.0+version:               0.1.1 synopsis:              Comprehensive Google Services SDK. homepage:              https://github.com/brendanhay/gogol bug-reports:           https://github.com/brendanhay/gogol/issues@@ -63,13 +63,12 @@         , conduit              >= 1.1         , conduit-extra        >= 1.1         , cryptonite           >= 0.6-        , data-default-class   >= 0.0.1         , directory            >= 1.2         , exceptions           >= 0.6         , filepath             >= 1.2-        , gogol-core           == 0.1.0.*-        , http-client          >= 0.4.4-        , http-conduit         >= 2.1.4+        , gogol-core           == 0.1.1.*+        , http-client          >= 0.5 && < 1+        , http-conduit         >= 2.2 && < 3         , http-media           >= 0.6         , http-types           >= 0.8.6         , lens                 >= 4.4
src/Network/Google/Auth.hs view
@@ -1,20 +1,7 @@-{-# LANGUAGE ConstraintKinds            #-}-{-# LANGUAGE DataKinds                  #-}-{-# LANGUAGE DeriveDataTypeable         #-}-{-# LANGUAGE DeriveGeneric              #-}-{-# LANGUAGE FlexibleContexts           #-}-{-# LANGUAGE FlexibleInstances          #-}-{-# LANGUAGE FunctionalDependencies     #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE KindSignatures             #-}-{-# LANGUAGE LambdaCase                 #-}-{-# LANGUAGE OverloadedStrings          #-}-{-# LANGUAGE PolyKinds                  #-}-{-# LANGUAGE RecordWildCards            #-}-{-# LANGUAGE ScopedTypeVariables        #-}-{-# LANGUAGE TypeFamilies               #-}-{-# LANGUAGE TypeOperators              #-}-{-# LANGUAGE UndecidableInstances       #-}+{-# LANGUAGE DataKinds           #-}+{-# LANGUAGE KindSignatures      #-}+{-# LANGUAGE OverloadedStrings   #-}+{-# LANGUAGE ScopedTypeVariables #-}  -- | -- Module      : Network.Google.Auth
src/Network/Google/Auth/InstalledApplication.hs view
@@ -1,4 +1,6 @@+{-# LANGUAGE KindSignatures    #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE DataKinds         #-}  -- | -- Module      : Network.Google.Auth.InstalledApplication@@ -32,6 +34,7 @@ import           Control.Monad.Catch            (MonadCatch) import           Control.Monad.IO.Class         (MonadIO) import qualified Data.Text.Encoding             as Text+import           GHC.TypeLits                   (Symbol) import           Network.Google.Auth.Scope      (AllowScopes (..),                                                  queryEncodeScopes) import           Network.Google.Internal.Auth@@ -52,23 +55,22 @@ -- > {-# LANGUAGE ScopedTypeVariables #-} -- -- > import Data.Proxy     (Proxy (..))+-- > import Data.Text      as T+-- > import Data.Text.IO   as T -- > import System.Exit    (exitFailure) -- > import System.Info    (os) -- > import System.Process (rawSystem) ----- > import qualified Data.ByteString            as BS--- > import qualified Data.ByteString.Lazy.Char8 as LBS8--- >--- > redirectPrompt :: forall s. OAuthClient -> proxy s -> IO (OAuthCode s)+-- > redirectPrompt :: AllowScopes (s :: [Symbol]) => OAuthClient -> proxy s -> IO (OAuthCode s) -- > redirectPrompt c p = do--- >     let url = LBS8.unpack (formURL c (Proxy :: Proxy s))--- >     putStrLn $ "Opening URL " ++ url--- >     case os of--- >         "darwin" -> rawSystem "open"     [url]--- >         "linux"  -> rawSystem "xdg-open" [url]--- >         _        -> putStrLn "Unsupported OS" >> exitFailure--- >     putStrLn "Please input the authorisation code: "--- >     OAuthCode . LBS.fromStrict <$> BS.getLine+-- >   let url = formURL c p+-- >   T.putStrLn $ "Opening URL " `T.append` url+-- >   _ <- case os of+-- >     "darwin" -> rawSystem "open"     [unpack url]+-- >     "linux"  -> rawSystem "xdg-open" [unpack url]+-- >     _        -> T.putStrLn "Unsupported OS" >> exitFailure+-- >   T.putStrLn "Please input the authorisation code: "+-- >   OAuthCode <$> T.getLine -- -- This ensures the scopes passed to 'formURL' and the type of 'OAuthCode' 's' -- are correct.@@ -83,7 +85,7 @@ -- construct a URL that can be used to obtain the 'OAuthCode'. -- -- /See:/ <https://developers.google.com/accounts/docs/OAuth2InstalledApp#formingtheurl Forming the URL>.-formURL :: AllowScopes s => OAuthClient -> proxy s -> Text+formURL :: AllowScopes (s :: [Symbol]) => OAuthClient -> proxy s -> Text formURL c = formURLWith c . allowScopes  -- | Form a URL using 'OAuthScope' values.
src/Network/Google/Auth/Scope.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE DataKinds            #-}-{-# LANGUAGE ExplicitNamespaces   #-} {-# LANGUAGE OverloadedStrings    #-} {-# LANGUAGE PolyKinds            #-} {-# LANGUAGE ScopedTypeVariables  #-}
src/Network/Google/Auth/ServiceAccount.hs view
@@ -44,7 +44,7 @@ -- | Obtain an 'OAuthToken' from the local instace metadata -- using the specific 'ServiceId'. ----- For example: @http:\/\/169.254.169.254\/instance\/service-accounts\/default\/token@+-- For example: @http:\/\/metadata.google.internal\/computeMetadata\/v1\/instance\/service-accounts\/default\/token@ -- will be retrieved if the given 'ServiceId' is @\"default\"@. metadataToken :: (MonadIO m, MonadCatch m)               => ServiceId@@ -53,7 +53,7 @@               -> m (OAuthToken s) metadataToken s = refreshRequest $     metadataRequest-        { Client.path = "instance/service-accounts/"+        { Client.path = "/computeMetadata/v1/instance/service-accounts/"             <> Text.encodeUtf8 (toQueryParam s)             <> "/token"         }@@ -76,8 +76,7 @@             <> "&refresh_token=" <> toQueryParam (fromMaybe (_userRefresh u) r)         } ---- | Obtain an 'OAuthToken' from @https://accounts.google.com/o/oauth2/token@+-- | Obtain an 'OAuthToken' from @https://accounts.google.com/o/oauth2/v2/auth@ -- by signing and sending a JSON Web Token (JWT) using the supplied 'ServiceAccount'. serviceAccountToken :: (MonadIO m, MonadCatch m, AllowScopes s)                     => ServiceAccount
src/Network/Google/Compute/Metadata.hs view
@@ -40,19 +40,20 @@     , getMetadata     ) where +import           Control.Exception       (throwIO) import           Control.Monad.Catch import           Control.Monad.IO.Class  (MonadIO (..)) import           Data.Aeson              (eitherDecode') import           Data.ByteString         (ByteString) import qualified Data.ByteString.Lazy    as LBS import           Data.Char               (toLower)-import           Data.Default.Class      (def) import qualified Data.Text.Encoding      as Text import qualified Data.Text.Lazy          as LText import qualified Data.Text.Lazy.Encoding as LText import           Network.Google.Prelude  (Text, (<>))-import           Network.HTTP.Conduit    (HttpException (..), Manager)-import qualified Network.HTTP.Conduit    as Client+import           Network.HTTP.Client     (HttpException (..),+                                          HttpExceptionContent (..), Manager)+import qualified Network.HTTP.Client     as Client import           Network.HTTP.Types      (HeaderName) import           System.Environment      (lookupEnv) @@ -91,7 +92,7 @@     failure = const (pure False)      rq = metadataRequest-       { Client.responseTimeout = Just 1000000+       { Client.responseTimeout = Client.responseTimeoutMicro 1000000        }  -- | A directory of custom metadata values that have been set for this project.@@ -223,20 +224,24 @@             -> [Int]      -- ^ Acceptable status code responses.             -> Manager             -> m (Client.Response LBS.ByteString)-getMetadata path ss m =-    liftIO . flip Client.httpLbs m $ metadataRequest-        { Client.path        = "/computeMetadata/v1/" <> path-        , Client.checkStatus = \s hs cj ->-            let c = fromEnum s-             in if 200 <= c && c < 300 && notElem c ss-                 then Nothing-                 else Just . toException $ StatusCodeException s hs cj-        }+getMetadata path statuses m =+    liftIO . flip Client.httpLbs m $+        metadataRequest+            { Client.path          = "/computeMetadata/v1/" <> path+            , Client.checkResponse = \rq rs ->+                let c = fromEnum (Client.responseStatus rs)+                 in if 200 <= c && c < 300 && notElem c statuses+                     then return ()+                     else do+                         bs <- Client.brReadSome (Client.responseBody rs) 4096+                         throwIO . HttpExceptionRequest rq $+                             StatusCodeException (() <$ rs) (LBS.toStrict bs)+            }  -- | A default @http-client@ 'Client.Request' with the host, port, and headers -- set appropriately for @metadata.google.internal@ use. metadataRequest :: Client.Request-metadataRequest = def+metadataRequest = Client.defaultRequest     { Client.host           = "metadata.google.internal"     , Client.port           = 80     , Client.secure         = False
src/Network/Google/Internal/Auth.hs view
@@ -32,7 +32,6 @@ import           Data.ByteString                (ByteString) import           Data.ByteString.Builder        () import qualified Data.ByteString.Lazy           as LBS-import           Data.Default.Class             (def) import           Data.String                    (IsString) import qualified Data.Text                      as Text import qualified Data.Text.Encoding             as Text@@ -245,18 +244,17 @@         <$> o .:  "error"         <*> o .:? "error_description" --- | @https://accounts.google.com/o/oauth2/token@.+-- | @https://accounts.google.com/o/oauth2/v2/auth@. accountsURL :: Text-accountsURL = "https://accounts.google.com/o/oauth2/token"+accountsURL = "https://accounts.google.com/o/oauth2/v2/auth"  accountsRequest :: Client.Request-accountsRequest = def+accountsRequest = Client.defaultRequest     { Client.host           = "accounts.google.com"     , Client.port           = 443     , Client.secure         = True-    , Client.checkStatus    = \_ _ _ -> Nothing     , Client.method         = "POST"-    , Client.path           = "/o/oauth2/token"+    , Client.path           = "/o/oauth2/v2/auth"     , Client.requestHeaders =         [ (hContentType, "application/x-www-form-urlencoded")         ]
src/Network/Google/Internal/HTTP.hs view
@@ -22,7 +22,6 @@ import qualified Data.ByteString.Lazy              as LBS import           Data.Conduit                      (($$+-)) import qualified Data.Conduit.List                 as Conduit-import           Data.Default.Class                (Default (..)) import           Data.Monoid                       (Dual (..), Endo (..), (<>)) import qualified Data.Text.Encoding                as Text import qualified Data.Text.Lazy                    as LText@@ -81,11 +80,10 @@                 , _serializeBody    = Just bs                 } -    request ct b = def+    request ct b = Client.defaultRequest         { Client.host            = _svcHost         , Client.port            = _svcPort         , Client.secure          = _svcSecure-        , Client.checkStatus     = \_ _ _ -> Nothing         , Client.responseTimeout = timeout         , Client.method          = _cliMethod         , Client.path            = path@@ -113,7 +111,10 @@                     , _serviceBody    = Just b                     } -    timeout = microseconds <$> _svcTimeout+    timeout =+        maybe Client.responseTimeoutNone+              (Client.responseTimeoutMicro . microseconds)+              _svcTimeout      handlers =         [ Handler $ err
src/Network/Google/Internal/Logger.hs view
@@ -43,7 +43,6 @@ import qualified Data.CaseInsensitive         as CI import           Data.Int                     (Int16, Int8) import           Data.List                    (intersperse)-import qualified Data.Text                    as Text import qualified Data.Text.Encoding           as Text import qualified Data.Text.Lazy               as LText import qualified Data.Text.Lazy.Encoding      as LText@@ -171,7 +170,7 @@         ,  "  host      = " <> build (host x) <> ":" <> build (port x)         ,  "  secure    = " <> build (secure x)         ,  "  method    = " <> build (method x)-        ,  "  timeout   = " <> build (responseTimeout x)+        ,  "  timeout   = " <> build (show (responseTimeout x))         ,  "  redirects = " <> build (redirectCount x)         ,  "  path      = " <> build (path            x)         ,  "  query     = " <> build (queryString     x)
src/Network/Google/Internal/Multipart.hs view
@@ -14,7 +14,6 @@ import           Data.ByteString                       (ByteString) import qualified Data.ByteString                       as BS import           Data.ByteString.Builder.Extra         (byteStringCopy)-import qualified Data.CaseInsensitive                  as CI import           Data.Monoid                           ((<>)) import           Network.Google.Types                  (Body (..)) import           Network.HTTP.Client