summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--amazonka-core.cabal2
-rw-r--r--src/Network/AWS/Data/Text.hs3
-rw-r--r--src/Network/AWS/Request.hs33
-rw-r--r--src/Network/AWS/Types.hs69
4 files changed, 61 insertions, 46 deletions
diff --git a/amazonka-core.cabal b/amazonka-core.cabal
index 9669d5a..03ce729 100644
--- a/amazonka-core.cabal
+++ b/amazonka-core.cabal
@@ -1,5 +1,5 @@
name: amazonka-core
-version: 1.4.4
+version: 1.4.5
synopsis: Core data types and functionality for Amazonka libraries.
homepage: https://github.com/brendanhay/amazonka
bug-reports: https://github.com/brendanhay/amazonka/issues
diff --git a/src/Network/AWS/Data/Text.hs b/src/Network/AWS/Data/Text.hs
index ea368d9..8bf8326 100644
--- a/src/Network/AWS/Data/Text.hs
+++ b/src/Network/AWS/Data/Text.hs
@@ -76,6 +76,9 @@ instance FromText Text where
instance FromText ByteString where
parser = Text.encodeUtf8 <$> A.takeText
+instance (CI.FoldCase a, FromText a) => FromText (CI a) where
+ parser = CI.mk <$> parser
+
instance FromText Char where
parser = A.anyChar <* A.endOfInput
diff --git a/src/Network/AWS/Request.hs b/src/Network/AWS/Request.hs
index 67e041d..42f2ca9 100644
--- a/src/Network/AWS/Request.hs
+++ b/src/Network/AWS/Request.hs
@@ -36,8 +36,9 @@ module Network.AWS.Request
-- ** Constructors
, defaultRequest
- -- ** Hashing
- , contentMD5
+ -- ** Operation Plugins
+ , contentMD5Header
+ , expectHeader
-- ** Lenses
, requestHeaders
@@ -98,7 +99,9 @@ postQuery s x = Request
}
postBody :: (ToRequest a, ToBody a) => Service -> a -> Request a
-postBody s x = putBody s x & rqMethod .~ POST
+postBody s x = defaultRequest s x
+ & rqMethod .~ POST
+ & rqBody .~ toBody x
putXML :: (ToRequest a, ToElement a) => Service -> a -> Request a
putXML s x = defaultRequest s x
@@ -112,9 +115,8 @@ putJSON s x = defaultRequest s x
putBody :: (ToRequest a, ToBody a) => Service -> a -> Request a
putBody s x = defaultRequest s x
- & rqMethod .~ PUT
- & rqBody .~ toBody x
- & rqHeaders %~ hdr hExpect "100-continue"
+ & rqMethod .~ PUT
+ & rqBody .~ toBody x
defaultRequest :: ToRequest a => Service -> a -> Request a
defaultRequest s x = Request
@@ -126,14 +128,6 @@ defaultRequest s x = Request
, _rqBody = ""
}
-contentMD5 :: Request a -> Request a
-contentMD5 rq
- | missing, Just x <- md5 = rq & rqHeaders %~ hdr HTTP.hContentMD5 x
- | otherwise = rq
- where
- missing = isNothing $ lookup HTTP.hContentMD5 (_rqHeaders rq)
- md5 = md5Base64 (_rqBody rq)
-
queryString :: Lens' Client.Request ByteString
queryString f x =
f (Client.queryString x) <&> \y -> x { Client.queryString = y }
@@ -159,3 +153,14 @@ requestURL x = scheme
n -> ":" <> toBS n
secure = Client.secure x
+
+contentMD5Header :: Request a -> Request a
+contentMD5Header rq
+ | missing, Just x <- md5 = rq & rqHeaders %~ hdr HTTP.hContentMD5 x
+ | otherwise = rq
+ where
+ missing = isNothing $ lookup HTTP.hContentMD5 (_rqHeaders rq)
+ md5 = md5Base64 (_rqBody rq)
+
+expectHeader :: Request a -> Request a
+expectHeader = rqHeaders %~ hdr hExpect "100-continue"
diff --git a/src/Network/AWS/Types.hs b/src/Network/AWS/Types.hs
index a7f7c0a..667211e 100644
--- a/src/Network/AWS/Types.hs
+++ b/src/Network/AWS/Types.hs
@@ -560,21 +560,23 @@ withAuth :: MonadIO m => Auth -> (AuthEnv -> m a) -> m a
withAuth (Ref _ r) f = liftIO (readIORef r) >>= f
withAuth (Auth e) f = f e
--- | The sum of available AWS regions.
+-- | The available AWS regions.
data Region
- = Ireland -- ^ Europe / eu-west-1
- | Frankfurt -- ^ Europe / eu-central-1
- | 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
- | Oregon -- ^ US / us-west-2
- | GovCloud -- ^ AWS GovCloud / us-gov-west-1
- | GovCloudFIPS -- ^ AWS GovCloud (FIPS 140-2) S3 Only / fips-us-gov-west-1
- | SaoPaulo -- ^ South America / sa-east-1
+ = NorthVirginia -- ^ US East ('us-east-1').
+ | Ohio -- ^ US East ('us-east-2').
+ | NorthCalifornia -- ^ US West ('us-west-1').
+ | Oregon -- ^ US West ('us-west-2').
+ | Tokyo -- ^ Asia Pacific ('ap-northeast-1').
+ | Seoul -- ^ Asia Pacific ('ap-northeast-2').
+ | Mumbai -- ^ Asia Pacific ('ap-south-1').
+ | Singapore -- ^ Asia Pacific ('ap-southeast-1').
+ | Sydney -- ^ Asia Pacific ('ap-southeast-2').
+ | SaoPaulo -- ^ South America ('sa-east-1').
+ | Ireland -- ^ EU ('eu-west-1').
+ | Frankfurt -- ^ EU ('eu-central-1').
+ | GovCloud -- ^ US GovCloud ('us-gov-west-1').
+ | GovCloudFIPS -- ^ US GovCloud FIPS (S3 Only, 'fips-us-gov-west-1').
+ | Beijing -- ^ China ('cn-north-1').
deriving (Eq, Ord, Read, Show, Data, Typeable, Generic)
instance Hashable Region
@@ -582,36 +584,41 @@ instance NFData Region
instance FromText Region where
parser = takeLowerText >>= \case
- "eu-west-1" -> pure Ireland
- "eu-central-1" -> pure Frankfurt
+ "us-east-1" -> pure NorthVirginia
+ "us-east-2" -> pure Ohio
+ "us-west-1" -> pure NorthCalifornia
+ "us-west-2" -> pure Oregon
"ap-northeast-1" -> pure Tokyo
+ "ap-northeast-2" -> pure Seoul
+ "ap-south-1" -> pure Mumbai
"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
- "us-west-1" -> pure NorthCalifornia
+ "sa-east-1" -> pure SaoPaulo
+ "eu-west-1" -> pure Ireland
+ "eu-central-1" -> pure Frankfurt
"us-gov-west-1" -> pure GovCloud
"fips-us-gov-west-1" -> pure GovCloudFIPS
- "sa-east-1" -> pure SaoPaulo
- e -> fromTextError $ "Failure parsing Region from " <> e
+ "cn-north-1" -> pure Beijing
+ e ->
+ fromTextError $ "Failure parsing Region from " <> e
instance ToText Region where
toText = \case
- Ireland -> "eu-west-1"
- Frankfurt -> "eu-central-1"
- Tokyo -> "ap-northeast-1"
- Singapore -> "ap-southeast-1"
- Sydney -> "ap-southeast-2"
- Bombay -> "ap-south-1"
- Beijing -> "cn-north-1"
NorthVirginia -> "us-east-1"
+ Ohio -> "us-east-2"
NorthCalifornia -> "us-west-1"
Oregon -> "us-west-2"
+ Tokyo -> "ap-northeast-1"
+ Seoul -> "ap-northeast-2"
+ Mumbai -> "ap-south-1"
+ Singapore -> "ap-southeast-1"
+ Sydney -> "ap-southeast-2"
+ SaoPaulo -> "sa-east-1"
+ Ireland -> "eu-west-1"
+ Frankfurt -> "eu-central-1"
GovCloud -> "us-gov-west-1"
GovCloudFIPS -> "fips-us-gov-west-1"
- SaoPaulo -> "sa-east-1"
+ Beijing -> "cn-north-1"
instance ToByteString Region