Skip to content

Commit

Permalink
Regenerating all services
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanhay committed Sep 28, 2015
1 parent c5edad2 commit b160225
Show file tree
Hide file tree
Showing 2,204 changed files with 563,360 additions and 231,209 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Gogol

**Warning:** This is an experimental preview release which is still under
heavy development and not intended for public consumption, caveat emptor!
**Warning:** This is an experimental prototype/preview release which is still
under heavy development and not intended for public consumption, caveat emptor!


* [Description](#description)
Expand Down
2 changes: 2 additions & 0 deletions core/gogol-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ library
, servant
, servant-client
, text
, either
, scientific

if !impl(ghc>=7.9)
build-depends:
Expand Down
102 changes: 87 additions & 15 deletions core/src/Network/Google/Prelude.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}

-- |
-- Module : Network.Google.Prelude
-- Copyright : (c) 2015 Brendan Hay <brendan.g.hay@gmail.com>
Expand All @@ -8,6 +17,10 @@
--
module Network.Google.Prelude
( module Export
, module Network.Google.Prelude

-- * Types
, mapping

-- * Serialisation
, parseJSONText
Expand All @@ -18,23 +31,73 @@ module Network.Google.Prelude
, _Default
) where

import Control.Lens as Export (Lens', lens)
import Control.Lens hiding (coerce)
import Data.Aeson as Export
import Control.Lens as Export (Lens', lens,
mapping)
import Control.Lens hiding (coerce)
import Control.Monad
import Control.Monad.Trans.Either as Export (EitherT)
import Data.Aeson as Export
import Data.Aeson.Types
import Data.Coerce
import Data.Data as Export (Data, Typeable)
import Data.Hashable as Export
import Data.Int as Export (Int32, Int64)
import Data.Maybe as Export
import Data.Proxy as Export
import Data.Text as Export (Text)
import Data.Time as Export (UTCTime)
import Data.Word as Export (Word32, Word64, Word8)
import GHC.Generics as Export (Generic)
import Numeric.Natural as Export (Natural)
import Servant.API as Export
import Servant.Client as Export
import Data.Data as Export (Data, Typeable)
import Data.Hashable as Export
import Data.Int as Export (Int32, Int64)
import Data.Maybe as Export
import Data.Proxy as Export
import Data.Scientific
import Data.Text as Export (Text)
import qualified Data.Text as Text
import qualified Data.Text.Lazy as LText
import Data.Text.Lazy.Builder (Builder)
import qualified Data.Text.Lazy.Builder as Build
import qualified Data.Text.Lazy.Builder.Int as Build
import qualified Data.Text.Lazy.Builder.Scientific as Build
import qualified Data.Text.Read as Read
import Data.Time as Export (UTCTime)
import Data.Word as Export (Word32, Word64,
Word8)
import GHC.Exts (Constraint)
import GHC.Generics as Export (Generic)
import Numeric.Natural as Export (Natural)
import Servant.API as Export
import Servant.API as Export
import Servant.Client as Export
import Servant.Common.Req as Export (Req, defReq)
import Servant.Utils.Links as Export

newtype Nat = Nat { unNat :: Natural }
deriving (Eq, Ord, Enum, Show, Read, Num, Real, Integral, Data, Typeable)

_Nat :: Iso' Nat Natural
_Nat = iso unNat Nat

instance FromJSON Nat where
parseJSON = parseJSON >=> go
where
go n = case floatingOrInteger n of
Left (_ :: Double) -> fail (floatErr n)
Right i
| n < 0 -> fail (negateErr n)
| otherwise -> return . Nat $ fromInteger i

floatErr = mappend "Cannot convert float to Natural: " . show
negateErr = mappend "Cannot convert negative number to Natural: " . show

instance ToJSON Nat where
toJSON = Number . flip scientific 0 . toInteger . unNat

instance ToText Nat where
toText = shortText . Build.decimal

instance FromText Nat where
fromText t =
case Read.decimal t of
Right (x, r) | Text.null r
-> Just x
_ -> Nothing

shortText :: Builder -> Text
shortText = LText.toStrict . Build.toLazyTextWith 32

_Coerce :: (Coercible a b, Coercible b a) => Iso' a b
_Coerce = iso coerce coerce
Expand All @@ -52,3 +115,12 @@ parseJSONText n = withText n (maybe (fail n) pure . fromText)

toJSONText :: ToText a => a -> Value
toJSONText = String . toText

class GoogleRequest a where
type Rs a :: *

requestWithRoute :: Req -> BaseUrl -> a -> EitherT ServantError IO (Rs a)
request :: a -> EitherT ServantError IO (Rs a)

send :: GoogleRequest a => a -> EitherT ServantError IO (Rs a)
send = undefined
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}

-- |
-- Module : Network.Google.API.AdExchangeBuyer.Accounts.Get
-- Copyright : (c) 2015 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- | Gets one account by ID.
--
-- /See:/ <https://developers.google.com/ad-exchange/buyer-rest Ad Exchange Buyer API Reference> for @adexchangebuyer.accounts.get@.
module Network.Google.API.AdExchangeBuyer.Accounts.Get
(
-- * REST Resource
AccountsGetAPI

-- * Creating a Request
, accountsGet'
, AccountsGet'

-- * Request Lenses
, agQuotaUser
, agPrettyPrint
, agUserIp
, agKey
, agId
, agOauthToken
, agFields
, agAlt
) where

import Network.Google.AdExchangeBuyer.Types
import Network.Google.Prelude

-- | A resource alias for adexchangebuyer.accounts.get which the
-- 'AccountsGet'' request conforms to.
type AccountsGetAPI =
"accounts" :>
Capture "id" Int32 :>
QueryParam "quotaUser" Text :>
QueryParam "prettyPrint" Bool :>
QueryParam "userIp" Text :>
QueryParam "key" Text :>
QueryParam "oauth_token" Text :>
QueryParam "fields" Text :>
QueryParam "alt" Alt :> Get '[JSON] Account

-- | Gets one account by ID.
--
-- /See:/ 'accountsGet'' smart constructor.
data AccountsGet' = AccountsGet'
{ _agQuotaUser :: !(Maybe Text)
, _agPrettyPrint :: !Bool
, _agUserIp :: !(Maybe Text)
, _agKey :: !(Maybe Text)
, _agId :: !Int32
, _agOauthToken :: !(Maybe Text)
, _agFields :: !(Maybe Text)
, _agAlt :: !Alt
} deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'AccountsGet'' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'agQuotaUser'
--
-- * 'agPrettyPrint'
--
-- * 'agUserIp'
--
-- * 'agKey'
--
-- * 'agId'
--
-- * 'agOauthToken'
--
-- * 'agFields'
--
-- * 'agAlt'
accountsGet'
:: Int32 -- ^ 'id'
-> AccountsGet'
accountsGet' pAgId_ =
AccountsGet'
{ _agQuotaUser = Nothing
, _agPrettyPrint = True
, _agUserIp = Nothing
, _agKey = Nothing
, _agId = pAgId_
, _agOauthToken = Nothing
, _agFields = Nothing
, _agAlt = JSON
}

-- | Available to use for quota purposes for server-side applications. Can be
-- any arbitrary string assigned to a user, but should not exceed 40
-- characters. Overrides userIp if both are provided.
agQuotaUser :: Lens' AccountsGet' (Maybe Text)
agQuotaUser
= lens _agQuotaUser (\ s a -> s{_agQuotaUser = a})

-- | Returns response with indentations and line breaks.
agPrettyPrint :: Lens' AccountsGet' Bool
agPrettyPrint
= lens _agPrettyPrint
(\ s a -> s{_agPrettyPrint = a})

-- | IP address of the site where the request originates. Use this if you
-- want to enforce per-user limits.
agUserIp :: Lens' AccountsGet' (Maybe Text)
agUserIp = lens _agUserIp (\ s a -> s{_agUserIp = a})

-- | API key. Your API key identifies your project and provides you with API
-- access, quota, and reports. Required unless you provide an OAuth 2.0
-- token.
agKey :: Lens' AccountsGet' (Maybe Text)
agKey = lens _agKey (\ s a -> s{_agKey = a})

-- | The account id
agId :: Lens' AccountsGet' Int32
agId = lens _agId (\ s a -> s{_agId = a})

-- | OAuth 2.0 token for the current user.
agOauthToken :: Lens' AccountsGet' (Maybe Text)
agOauthToken
= lens _agOauthToken (\ s a -> s{_agOauthToken = a})

-- | Selector specifying which fields to include in a partial response.
agFields :: Lens' AccountsGet' (Maybe Text)
agFields = lens _agFields (\ s a -> s{_agFields = a})

-- | Data format for the response.
agAlt :: Lens' AccountsGet' Alt
agAlt = lens _agAlt (\ s a -> s{_agAlt = a})

instance GoogleRequest AccountsGet' where
type Rs AccountsGet' = Account
request = requestWithRoute defReq adExchangeBuyerURL
requestWithRoute r u AccountsGet'{..}
= go _agQuotaUser (Just _agPrettyPrint) _agUserIp
_agKey
_agId
_agOauthToken
_agFields
(Just _agAlt)
where go
= clientWithRoute (Proxy :: Proxy AccountsGetAPI) r u
Loading

0 comments on commit b160225

Please sign in to comment.