summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrendanHay <>2016-10-23 08:08:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2016-10-23 08:08:00 (GMT)
commit5cb2e2f6044d4ddc6a7ef1f91c1328c53b324160 (patch)
treeab5f7731c67de17d30c0bc6511f357632278cd5c
parent0cc51c2ee3761b1904098cd524177a368eaf9d6d (diff)
version 1.4.41.4.4
-rw-r--r--amazonka-core.cabal8
-rw-r--r--src/Network/AWS/Data/Base64.hs3
-rw-r--r--src/Network/AWS/Data/JSON.hs3
-rw-r--r--src/Network/AWS/Data/Log.hs5
-rw-r--r--src/Network/AWS/Error.hs45
-rw-r--r--src/Network/AWS/Types.hs94
6 files changed, 87 insertions, 71 deletions
diff --git a/amazonka-core.cabal b/amazonka-core.cabal
index 4bee585..9669d5a 100644
--- a/amazonka-core.cabal
+++ b/amazonka-core.cabal
@@ -1,5 +1,5 @@
name: amazonka-core
-version: 1.4.3
+version: 1.4.4
synopsis: Core data types and functionality for Amazonka libraries.
homepage: https://github.com/brendanhay/amazonka
bug-reports: https://github.com/brendanhay/amazonka/issues
@@ -73,7 +73,7 @@ library
build-depends:
aeson >= 0.8
, attoparsec >= 0.11.3
- , base >= 4.7 && < 5
+ , base >= 4.7 && < 5
, bifunctors >= 4.1
, bytestring >= 0.9
, case-insensitive >= 1.2
@@ -83,7 +83,7 @@ library
, deepseq >= 1.4
, exceptions >= 0.6
, hashable >= 1.2
- , http-conduit >= 2.1.4
+ , http-conduit >= 2.2 && < 3
, http-types >= 0.8
, lens >= 4.4
, memory >= 0.6
@@ -145,4 +145,4 @@ test-suite tests
, text
, time
, QuickCheck
- , quickcheck-unicode \ No newline at end of file
+ , quickcheck-unicode
diff --git a/src/Network/AWS/Data/Base64.hs b/src/Network/AWS/Data/Base64.hs
index f0c3f5f..b973eef 100644
--- a/src/Network/AWS/Data/Base64.hs
+++ b/src/Network/AWS/Data/Base64.hs
@@ -15,6 +15,7 @@ module Network.AWS.Data.Base64
, _Base64
) where
+import Control.Applicative (pure)
import Control.DeepSeq
import Data.Aeson.Types
import qualified Data.Attoparsec.Text as AText
@@ -48,7 +49,7 @@ _Base64 = iso unBase64 Base64
-- the underlying serialisers (JSON, XML) use Text internally.
instance FromText Base64 where
parser = AText.takeText >>=
- either fail (return . Base64)
+ either fail (pure . Base64)
. BA.convertFromBase BA.Base64
. Text.encodeUtf8
diff --git a/src/Network/AWS/Data/JSON.hs b/src/Network/AWS/Data/JSON.hs
index 4f58c2b..e0a3737 100644
--- a/src/Network/AWS/Data/JSON.hs
+++ b/src/Network/AWS/Data/JSON.hs
@@ -13,6 +13,7 @@ module Network.AWS.Data.JSON
-- * FromJSON
FromJSON (..)
, parseJSONText
+ , eitherDecode
, eitherDecode'
-- ** Parser a
@@ -34,7 +35,7 @@ module Network.AWS.Data.JSON
, (.=)
) where
-import Data.Aeson (eitherDecode')
+import Data.Aeson (eitherDecode, eitherDecode')
import Data.Aeson.Types
import qualified Data.HashMap.Strict as Map
import Network.AWS.Data.Text
diff --git a/src/Network/AWS/Data/Log.hs b/src/Network/AWS/Data/Log.hs
index 286c50d..5febe6a 100644
--- a/src/Network/AWS/Data/Log.hs
+++ b/src/Network/AWS/Data/Log.hs
@@ -120,6 +120,9 @@ instance ToLog RequestBody where
instance ToLog HttpException where
build x = "[HttpException] {\n" <> build (show x) <> "\n}"
+instance ToLog HttpExceptionContent where
+ build x = "[HttpExceptionContent] {\n" <> build (show x) <> "\n}"
+
instance ToLog Request where
build x = buildLines
[ "[Client Request] {"
@@ -127,7 +130,7 @@ instance ToLog Request where
, " secure = " <> build (secure x)
, " method = " <> build (method x)
, " target = " <> build target
- , " timeout = " <> build (responseTimeout x)
+ , " timeout = " <> build (show (responseTimeout x))
, " redirects = " <> build (redirectCount x)
, " path = " <> build (path x)
, " query = " <> build (queryString x)
diff --git a/src/Network/AWS/Error.hs b/src/Network/AWS/Error.hs
index ad03ca6..0fff847 100644
--- a/src/Network/AWS/Error.hs
+++ b/src/Network/AWS/Error.hs
@@ -12,22 +12,22 @@
--
module Network.AWS.Error where
-import Control.Applicative
-import Control.Monad
-import Data.Aeson
-import Data.Aeson.Types (parseEither)
-import qualified Data.ByteString.Lazy as LBS
-import Data.Maybe
-import Data.Monoid
-import Network.AWS.Data.ByteString
-import Network.AWS.Data.Headers
-import Network.AWS.Data.Text
-import Network.AWS.Data.XML
-import Network.AWS.Lens (Choice, Getting, Optic', filtered)
-import Network.AWS.Lens ((<&>))
-import Network.AWS.Types
-import Network.HTTP.Conduit
-import Network.HTTP.Types.Status (Status (..))
+import Control.Applicative
+import Control.Monad
+import Data.Aeson
+import Data.Aeson.Types (parseEither)
+import Data.Maybe
+import Data.Monoid
+import Network.AWS.Data.ByteString
+import Network.AWS.Data.Headers
+import Network.AWS.Data.Text
+import Network.AWS.Data.XML
+import Network.AWS.Lens (Choice, Getting, Optic', filtered)
+import Network.AWS.Types
+import Network.HTTP.Conduit
+import Network.HTTP.Types.Status (Status (..))
+
+import qualified Data.ByteString.Lazy as LBS
statusSuccess :: Status -> Bool
statusSuccess (statusCode -> n) = n >= 200 && n < 300
@@ -36,14 +36,19 @@ httpStatus :: AsError a => Getting (First Status) a Status
httpStatus = _Error . f
where
f g = \case
- TransportError (StatusCodeException s h c)
- -> TransportError <$> (StatusCodeException <$> g s <*> pure h <*> pure c)
+ TransportError (HttpExceptionRequest rq (StatusCodeException rs b))
+ -> (\x -> TransportError (HttpExceptionRequest rq (StatusCodeException (rs { responseStatus = x }) b)))
+ <$> g (responseStatus rs)
+
TransportError e
-> pure (TransportError e)
+
SerializeError (SerializeError' a s b e)
- -> g s <&> \x -> SerializeError (SerializeError' a x b e)
+ -> (\x -> SerializeError (SerializeError' a x b e)) <$> g s
+
ServiceError e
- -> g (_serviceStatus e) <&> \x -> ServiceError (e { _serviceStatus = x })
+ -> (\x -> ServiceError (e { _serviceStatus = x }))
+ <$> g (_serviceStatus e)
hasStatus :: (Applicative f, Choice p)
=> Int
diff --git a/src/Network/AWS/Types.hs b/src/Network/AWS/Types.hs
index 76074eb..a7f7c0a 100644
--- a/src/Network/AWS/Types.hs
+++ b/src/Network/AWS/Types.hs
@@ -120,45 +120,44 @@ module Network.AWS.Types
, _Default
) where
-import Control.Applicative
-import Control.Concurrent (ThreadId)
-import Control.DeepSeq
-import Control.Exception
-import Control.Monad.IO.Class
-import Control.Monad.Trans.Resource
-import Data.Aeson hiding (Error)
-import qualified Data.ByteString as BS
-import Data.ByteString.Builder (Builder)
-import Data.Coerce
-import Data.Conduit
-import Data.Data (Data, Typeable)
-import Data.Hashable
-import Data.IORef
-import Data.Maybe
-import Data.Monoid
-import Data.Proxy
-import Data.String
-import qualified Data.Text as Text
-import qualified Data.Text.Encoding as Text
-import Data.Time
-import GHC.Generics (Generic)
-import Network.AWS.Data.Body
-import Network.AWS.Data.ByteString
-import Network.AWS.Data.JSON
-import Network.AWS.Data.Log
-import Network.AWS.Data.Path
-import Network.AWS.Data.Query
-import Network.AWS.Data.Text
-import Network.AWS.Data.XML
-import Network.AWS.Lens (Iso', Lens', Prism', Setter')
-import Network.AWS.Lens (exception, iso, lens, prism,
- sets)
-import Network.HTTP.Conduit hiding (Proxy, Request, Response)
-import qualified Network.HTTP.Conduit as Client
-import Network.HTTP.Types.Header
-import Network.HTTP.Types.Method
-import Network.HTTP.Types.Status (Status)
-import Text.XML (def)
+import Control.Applicative
+import Control.Concurrent (ThreadId)
+import Control.DeepSeq
+import Control.Exception
+import Control.Monad.IO.Class
+import Control.Monad.Trans.Resource
+import Data.Aeson hiding (Error)
+import Data.ByteString.Builder (Builder)
+import Data.Coerce
+import Data.Conduit
+import Data.Data (Data, Typeable)
+import Data.Hashable
+import Data.IORef
+import Data.Maybe
+import Data.Monoid
+import Data.Proxy
+import Data.String
+import Data.Time
+import GHC.Generics (Generic)
+import Network.AWS.Data.Body
+import Network.AWS.Data.ByteString
+import Network.AWS.Data.JSON
+import Network.AWS.Data.Log
+import Network.AWS.Data.Path
+import Network.AWS.Data.Query
+import Network.AWS.Data.Text
+import Network.AWS.Data.XML
+import Network.AWS.Lens (Iso', Lens', Prism', Setter')
+import Network.AWS.Lens (exception, iso, lens, prism, sets)
+import Network.HTTP.Conduit hiding (Proxy, Request, Response)
+import Network.HTTP.Types.Header
+import Network.HTTP.Types.Method
+import Network.HTTP.Types.Status (Status)
+
+import qualified Data.ByteString as BS
+import qualified Data.Text as Text
+import qualified Data.Text.Encoding as Text
+import qualified Network.HTTP.Conduit as Client
-- | A convenience alias to avoid type ambiguity.
type ClientRequest = Client.Request
@@ -443,13 +442,15 @@ serviceRetry = lens _svcRetry (\s a -> s { _svcRetry = a })
-- | Construct a 'ClientRequest' using common parameters such as TLS and prevent
-- throwing errors when receiving erroneous status codes in respones.
clientRequest :: Endpoint -> Maybe Seconds -> ClientRequest
-clientRequest e t = def
+clientRequest e t = Client.defaultRequest
{ Client.secure = _endpointSecure e
, Client.host = _endpointHost e
, Client.port = _endpointPort e
, Client.redirectCount = 0
- , Client.checkStatus = \_ _ _ -> Nothing
- , Client.responseTimeout = microseconds <$> t
+ , Client.responseTimeout =
+ case t of
+ Nothing -> Client.responseTimeoutNone
+ Just x -> Client.responseTimeoutMicro (microseconds x)
}
-- | An unsigned request.
@@ -566,6 +567,7 @@ data Region
| Tokyo -- ^ Asia Pacific / ap-northeast-1
| Singapore -- ^ Asia Pacific / ap-southeast-1
| Sydney -- ^ Asia Pacific / ap-southeast-2
+ | Bombay -- ^ Asia Pacific / ap-south-1
| Beijing -- ^ China / cn-north-1
| NorthVirginia -- ^ US / us-east-1
| NorthCalifornia -- ^ US / us-west-1
@@ -585,6 +587,7 @@ instance FromText Region where
"ap-northeast-1" -> pure Tokyo
"ap-southeast-1" -> pure Singapore
"ap-southeast-2" -> pure Sydney
+ "ap-south-1" -> pure Bombay
"cn-north-1" -> pure Beijing
"us-east-1" -> pure NorthVirginia
"us-west-2" -> pure Oregon
@@ -601,6 +604,7 @@ instance ToText Region where
Tokyo -> "ap-northeast-1"
Singapore -> "ap-southeast-1"
Sydney -> "ap-southeast-2"
+ Bombay -> "ap-south-1"
Beijing -> "cn-north-1"
NorthVirginia -> "us-east-1"
NorthCalifornia -> "us-west-1"
@@ -614,8 +618,10 @@ instance ToByteString Region
instance ToLog Region where
build = build . toBS
-instance FromXML Region where parseXML = parseXMLText "Region"
-instance ToXML Region where toXML = toXMLText
+instance FromXML Region where parseXML = parseXMLText "Region"
+instance ToXML Region where toXML = toXMLText
+instance FromJSON Region where parseJSON = parseJSONText "Region"
+instance ToJSON Region where toJSON = toJSONText
-- | An integral value representing seconds.
newtype Seconds = Seconds Int