on develop help sign in
Updating dummy prelude exports
commit03c6efc9ede50db7864f6f0d73591093240e63cf authorBrendan Hay <brendan.g.hay@gmail.com> dateFri 2 Oct 2015, 09:28 (11 years ago) parentc1211b9
4 files changed+96−26
core/LICENSE−6 core/gogol-core.cabal+3−2 core/src/Network/Google/Prelude.hs+93−12 gogol/LICENSE−6
core/LICENSE−6
@@ -365,9 +365,3 @@ file in a relevant directory) where a recipient would be likely to look
365365for such a notice.
366366
367367You may add additional accurate notices of copyright ownership.
368−
369−Exhibit B - "Incompatible With Secondary Licenses" Notice
370−---------------------------------------------------------
371−
372− This Source Code Form is "Incompatible With Secondary Licenses", as
373− defined by the Mozilla Public License, v. 2.0.
core/gogol-core.cabal+3−2
@@ -45,13 +45,14 @@ library
4545 build-depends:
4646 aeson >= 0.8
4747 , base >= 4.7 && < 5
48+ , either
4849 , hashable >= 1.2
50+ , http-media
4951 , lens >= 4.4
52+ , scientific >= 0.3
5053 , servant >= 0.4.4
5154 , servant-client
5255 , text >= 1.1
53− , either
54− , scientific >= 0.3
5556
5657 if !impl(ghc>=7.9)
5758 build-depends:
core/src/Network/Google/Prelude.hs+93−12
@@ -1,8 +1,11 @@
1−{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE FlexibleContexts #-}
3−{-# LANGUAGE TypeFamilies #-}
4−{-# LANGUAGE TypeOperators #-}
5−{-# LANGUAGE UndecidableInstances #-}
1+{-# LANGUAGE DataKinds #-}
2+{-# LANGUAGE DeriveDataTypeable #-}
3+{-# LANGUAGE DeriveGeneric #-}
4+{-# LANGUAGE FlexibleContexts #-}
5+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
6+{-# LANGUAGE OverloadedStrings #-}
7+{-# LANGUAGE TypeFamilies #-}
8+{-# LANGUAGE TypeOperators #-}
69
710-- |
811-- Module : Network.Google.Prelude
@@ -17,7 +20,8 @@ module Network.Google.Prelude
1720 , module Network.Google.Prelude
1821 ) where
1922
20−import Control.Lens as Export (Lens', lens, mapping)
23+import Control.Lens as Export (Lens', lens, mapping,
24+ _Just)
2125import Control.Lens hiding (coerce)
2226import Control.Monad.Trans.Either as Export (EitherT)
2327import Data.Aeson as Export
@@ -33,18 +37,13 @@ import Data.Word as Export (Word32, Word64, Word8)
3337import GHC.Generics as Export (Generic)
3438import Network.Google.Data.JSON as Export
3539import Network.Google.Data.Numeric as Export
40+import Network.HTTP.Media
3641import Numeric.Natural as Export (Natural)
3742import Servant.API as Export
3843import Servant.Client as Export
3944import Servant.Common.Req as Export (Req, defReq)
4045import Servant.Utils.Links as Export
4146
42−class GoogleRequest a where
43− type Rs a :: *
44−
45− requestWithRoute :: Req -> BaseUrl -> a -> EitherT ServantError IO (Rs a)
46− request :: a -> EitherT ServantError IO (Rs a)
47−
4847_Coerce :: (Coercible a b, Coercible b a) => Iso' a b
4948_Coerce = iso coerce coerce
5049
@@ -55,3 +54,85 @@ _Default = iso f Just
5554 where
5655 f (Just x) = x
5756 f Nothing = mempty
57+
58+data AltJSON = AltJSON
59+ deriving (Eq, Ord, Show, Read, Generic, Data, Typeable)
60+
61+instance ToText AltJSON where
62+ toText = const "json"
63+
64+data AltMedia = AltMedia
65+ deriving (Eq, Ord, Show, Read, Generic, Data, Typeable)
66+
67+instance ToText AltMedia where
68+ toText = const "media"
69+
70+class GoogleRequest a where
71+ type Rs a :: *
72+
73+ requestWithRoute :: Req -> BaseUrl -> a -> EitherT ServantError IO (Rs a)
74+ request :: a -> EitherT ServantError IO (Rs a)
75+
76+newtype Key = Key Text
77+ deriving (Eq, Ord, Show, Read, Generic, Data, Typeable, ToText, FromText)
78+
79+newtype OAuthToken = OAuthToken Text
80+ deriving (Eq, Ord, Show, Read, Generic, Data, Typeable, ToText, FromText)
81+
82+class GoogleAuth a where
83+ authKey :: Traversal' a Key
84+ authToken :: Traversal' a OAuthToken
85+ -- ^ only set if unset semantics?
86+
87+newtype Download a = Download a
88+
89+_Download :: Iso' (Download a) a
90+_Download = iso (\(Download x) -> x) Download
91+
92+instance GoogleAuth a => GoogleAuth (Download a) where
93+ authKey = _Download . authKey
94+ authToken = _Download . authToken
95+
96+data Body = Body -- MediaType
97+ deriving (Eq, Show, Generic, Data, Typeable)
98+
99+data MultipartRelated (metatypes :: [*]) meta media
100+
101+-- POST /upload/drive/v2/files?uploadType=multipart HTTP/1.1
102+-- Host: www.googleapis.com
103+-- Authorization: Bearer your_auth_token
104+-- Content-Type: multipart/related; boundary="foo_bar_baz"
105+-- Content-Length: number_of_bytes_in_entire_request_body
106+--
107+-- --foo_bar_baz
108+-- Content-Type: application/json; charset=UTF-8
109+-- {
110+-- "title": "My File"
111+-- }
112+-- --foo_bar_baz
113+-- Content-Type: image/jpeg
114+-- JPEG data
115+-- --foo_bar_baz--
116+
117+-- "mediaType" param also comes/calculated from the request body?
118+--
119+-- Resumable endpoints - Not supported to begin with, need to figure
120+-- out how to return session id etc.
121+--
122+-- Assume initially that every service supports multipart upload.
123+--
124+-- When downloading media you must set the alt query parameter
125+-- to media in the request URL.
126+--
127+-- "resumable" or "multipart" needs to go into the "uploadType" param
128+--
129+
130+-- if c.protocol_ == "resumable" {
131+-- if c.mediaType_ == "" {
132+-- c.mediaType_ = googleapi.DetectMediaType(c.resumable_)
133+-- }
134+-- req.Header.Set("X-Upload-Content-Type", c.mediaType_)
135+-- req.Header.Set("Content-Type", "application/json; charset=utf-8")
136+-- } else {
137+-- req.Header.Set("Content-Type", ctype)
138+-- }
gogol/LICENSE−6
@@ -365,9 +365,3 @@ file in a relevant directory) where a recipient would be likely to look
365365for such a notice.
366366
367367You may add additional accurate notices of copyright ownership.
368−
369−Exhibit B - "Incompatible With Secondary Licenses" Notice
370−---------------------------------------------------------
371−
372− This Source Code Form is "Incompatible With Secondary Licenses", as
373− defined by the Mozilla Public License, v. 2.0.