{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.S3.GetBucketLocation
(
GetBucketLocation (..),
newGetBucketLocation,
getBucketLocation_expectedBucketOwner,
getBucketLocation_bucket,
GetBucketLocationResponse (..),
newGetBucketLocationResponse,
getBucketLocationResponse_httpStatus,
getBucketLocationResponse_locationConstraint,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.S3.Types
data GetBucketLocation = GetBucketLocation'
{
GetBucketLocation -> Maybe Text
expectedBucketOwner :: Prelude.Maybe Prelude.Text,
GetBucketLocation -> BucketName
bucket :: BucketName
}
deriving (GetBucketLocation -> GetBucketLocation -> Bool
(GetBucketLocation -> GetBucketLocation -> Bool)
-> (GetBucketLocation -> GetBucketLocation -> Bool)
-> Eq GetBucketLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBucketLocation -> GetBucketLocation -> Bool
$c/= :: GetBucketLocation -> GetBucketLocation -> Bool
== :: GetBucketLocation -> GetBucketLocation -> Bool
$c== :: GetBucketLocation -> GetBucketLocation -> Bool
Prelude.Eq, ReadPrec [GetBucketLocation]
ReadPrec GetBucketLocation
Int -> ReadS GetBucketLocation
ReadS [GetBucketLocation]
(Int -> ReadS GetBucketLocation)
-> ReadS [GetBucketLocation]
-> ReadPrec GetBucketLocation
-> ReadPrec [GetBucketLocation]
-> Read GetBucketLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetBucketLocation]
$creadListPrec :: ReadPrec [GetBucketLocation]
readPrec :: ReadPrec GetBucketLocation
$creadPrec :: ReadPrec GetBucketLocation
readList :: ReadS [GetBucketLocation]
$creadList :: ReadS [GetBucketLocation]
readsPrec :: Int -> ReadS GetBucketLocation
$creadsPrec :: Int -> ReadS GetBucketLocation
Prelude.Read, Int -> GetBucketLocation -> ShowS
[GetBucketLocation] -> ShowS
GetBucketLocation -> String
(Int -> GetBucketLocation -> ShowS)
-> (GetBucketLocation -> String)
-> ([GetBucketLocation] -> ShowS)
-> Show GetBucketLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBucketLocation] -> ShowS
$cshowList :: [GetBucketLocation] -> ShowS
show :: GetBucketLocation -> String
$cshow :: GetBucketLocation -> String
showsPrec :: Int -> GetBucketLocation -> ShowS
$cshowsPrec :: Int -> GetBucketLocation -> ShowS
Prelude.Show, (forall x. GetBucketLocation -> Rep GetBucketLocation x)
-> (forall x. Rep GetBucketLocation x -> GetBucketLocation)
-> Generic GetBucketLocation
forall x. Rep GetBucketLocation x -> GetBucketLocation
forall x. GetBucketLocation -> Rep GetBucketLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetBucketLocation x -> GetBucketLocation
$cfrom :: forall x. GetBucketLocation -> Rep GetBucketLocation x
Prelude.Generic)
newGetBucketLocation ::
BucketName ->
GetBucketLocation
newGetBucketLocation :: BucketName -> GetBucketLocation
newGetBucketLocation BucketName
pBucket_ =
GetBucketLocation' :: Maybe Text -> BucketName -> GetBucketLocation
GetBucketLocation'
{ $sel:expectedBucketOwner:GetBucketLocation' :: Maybe Text
expectedBucketOwner =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:bucket:GetBucketLocation' :: BucketName
bucket = BucketName
pBucket_
}
getBucketLocation_expectedBucketOwner :: Lens.Lens' GetBucketLocation (Prelude.Maybe Prelude.Text)
getBucketLocation_expectedBucketOwner :: (Maybe Text -> f (Maybe Text))
-> GetBucketLocation -> f GetBucketLocation
getBucketLocation_expectedBucketOwner = (GetBucketLocation -> Maybe Text)
-> (GetBucketLocation -> Maybe Text -> GetBucketLocation)
-> Lens
GetBucketLocation GetBucketLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketLocation' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:GetBucketLocation' :: GetBucketLocation -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: GetBucketLocation
s@GetBucketLocation' {} Maybe Text
a -> GetBucketLocation
s {$sel:expectedBucketOwner:GetBucketLocation' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: GetBucketLocation)
getBucketLocation_bucket :: Lens.Lens' GetBucketLocation BucketName
getBucketLocation_bucket :: (BucketName -> f BucketName)
-> GetBucketLocation -> f GetBucketLocation
getBucketLocation_bucket = (GetBucketLocation -> BucketName)
-> (GetBucketLocation -> BucketName -> GetBucketLocation)
-> Lens GetBucketLocation GetBucketLocation BucketName BucketName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketLocation' {BucketName
bucket :: BucketName
$sel:bucket:GetBucketLocation' :: GetBucketLocation -> BucketName
bucket} -> BucketName
bucket) (\s :: GetBucketLocation
s@GetBucketLocation' {} BucketName
a -> GetBucketLocation
s {$sel:bucket:GetBucketLocation' :: BucketName
bucket = BucketName
a} :: GetBucketLocation)
instance Core.AWSRequest GetBucketLocation where
type
AWSResponse GetBucketLocation =
GetBucketLocationResponse
request :: GetBucketLocation -> Request GetBucketLocation
request = Service -> GetBucketLocation -> Request GetBucketLocation
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy GetBucketLocation
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse GetBucketLocation)))
response =
(Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse GetBucketLocation))
-> Logger
-> Service
-> Proxy GetBucketLocation
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse GetBucketLocation)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
( \Int
s ResponseHeaders
h [Node]
x ->
Int -> LocationConstraint -> GetBucketLocationResponse
GetBucketLocationResponse'
(Int -> LocationConstraint -> GetBucketLocationResponse)
-> Either String Int
-> Either String (LocationConstraint -> GetBucketLocationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
Either String (LocationConstraint -> GetBucketLocationResponse)
-> Either String LocationConstraint
-> Either String GetBucketLocationResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node] -> Either String LocationConstraint
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
)
instance Prelude.Hashable GetBucketLocation
instance Prelude.NFData GetBucketLocation
instance Core.ToHeaders GetBucketLocation where
toHeaders :: GetBucketLocation -> ResponseHeaders
toHeaders GetBucketLocation' {Maybe Text
BucketName
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:bucket:GetBucketLocation' :: GetBucketLocation -> BucketName
$sel:expectedBucketOwner:GetBucketLocation' :: GetBucketLocation -> Maybe Text
..} =
[ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"x-amz-expected-bucket-owner"
HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
expectedBucketOwner
]
instance Core.ToPath GetBucketLocation where
toPath :: GetBucketLocation -> ByteString
toPath GetBucketLocation' {Maybe Text
BucketName
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:bucket:GetBucketLocation' :: GetBucketLocation -> BucketName
$sel:expectedBucketOwner:GetBucketLocation' :: GetBucketLocation -> Maybe Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/", BucketName -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS BucketName
bucket]
instance Core.ToQuery GetBucketLocation where
toQuery :: GetBucketLocation -> QueryString
toQuery =
QueryString -> GetBucketLocation -> QueryString
forall a b. a -> b -> a
Prelude.const ([QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [QueryString
"location"])
data GetBucketLocationResponse = GetBucketLocationResponse'
{
GetBucketLocationResponse -> Int
httpStatus :: Prelude.Int,
GetBucketLocationResponse -> LocationConstraint
locationConstraint :: LocationConstraint
}
deriving (GetBucketLocationResponse -> GetBucketLocationResponse -> Bool
(GetBucketLocationResponse -> GetBucketLocationResponse -> Bool)
-> (GetBucketLocationResponse -> GetBucketLocationResponse -> Bool)
-> Eq GetBucketLocationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBucketLocationResponse -> GetBucketLocationResponse -> Bool
$c/= :: GetBucketLocationResponse -> GetBucketLocationResponse -> Bool
== :: GetBucketLocationResponse -> GetBucketLocationResponse -> Bool
$c== :: GetBucketLocationResponse -> GetBucketLocationResponse -> Bool
Prelude.Eq, ReadPrec [GetBucketLocationResponse]
ReadPrec GetBucketLocationResponse
Int -> ReadS GetBucketLocationResponse
ReadS [GetBucketLocationResponse]
(Int -> ReadS GetBucketLocationResponse)
-> ReadS [GetBucketLocationResponse]
-> ReadPrec GetBucketLocationResponse
-> ReadPrec [GetBucketLocationResponse]
-> Read GetBucketLocationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetBucketLocationResponse]
$creadListPrec :: ReadPrec [GetBucketLocationResponse]
readPrec :: ReadPrec GetBucketLocationResponse
$creadPrec :: ReadPrec GetBucketLocationResponse
readList :: ReadS [GetBucketLocationResponse]
$creadList :: ReadS [GetBucketLocationResponse]
readsPrec :: Int -> ReadS GetBucketLocationResponse
$creadsPrec :: Int -> ReadS GetBucketLocationResponse
Prelude.Read, Int -> GetBucketLocationResponse -> ShowS
[GetBucketLocationResponse] -> ShowS
GetBucketLocationResponse -> String
(Int -> GetBucketLocationResponse -> ShowS)
-> (GetBucketLocationResponse -> String)
-> ([GetBucketLocationResponse] -> ShowS)
-> Show GetBucketLocationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBucketLocationResponse] -> ShowS
$cshowList :: [GetBucketLocationResponse] -> ShowS
show :: GetBucketLocationResponse -> String
$cshow :: GetBucketLocationResponse -> String
showsPrec :: Int -> GetBucketLocationResponse -> ShowS
$cshowsPrec :: Int -> GetBucketLocationResponse -> ShowS
Prelude.Show, (forall x.
GetBucketLocationResponse -> Rep GetBucketLocationResponse x)
-> (forall x.
Rep GetBucketLocationResponse x -> GetBucketLocationResponse)
-> Generic GetBucketLocationResponse
forall x.
Rep GetBucketLocationResponse x -> GetBucketLocationResponse
forall x.
GetBucketLocationResponse -> Rep GetBucketLocationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetBucketLocationResponse x -> GetBucketLocationResponse
$cfrom :: forall x.
GetBucketLocationResponse -> Rep GetBucketLocationResponse x
Prelude.Generic)
newGetBucketLocationResponse ::
Prelude.Int ->
LocationConstraint ->
GetBucketLocationResponse
newGetBucketLocationResponse :: Int -> LocationConstraint -> GetBucketLocationResponse
newGetBucketLocationResponse
Int
pHttpStatus_
LocationConstraint
pLocationConstraint_ =
GetBucketLocationResponse' :: Int -> LocationConstraint -> GetBucketLocationResponse
GetBucketLocationResponse'
{ $sel:httpStatus:GetBucketLocationResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:locationConstraint:GetBucketLocationResponse' :: LocationConstraint
locationConstraint = LocationConstraint
pLocationConstraint_
}
getBucketLocationResponse_httpStatus :: Lens.Lens' GetBucketLocationResponse Prelude.Int
getBucketLocationResponse_httpStatus :: (Int -> f Int)
-> GetBucketLocationResponse -> f GetBucketLocationResponse
getBucketLocationResponse_httpStatus = (GetBucketLocationResponse -> Int)
-> (GetBucketLocationResponse -> Int -> GetBucketLocationResponse)
-> Lens GetBucketLocationResponse GetBucketLocationResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketLocationResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetBucketLocationResponse' :: GetBucketLocationResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetBucketLocationResponse
s@GetBucketLocationResponse' {} Int
a -> GetBucketLocationResponse
s {$sel:httpStatus:GetBucketLocationResponse' :: Int
httpStatus = Int
a} :: GetBucketLocationResponse)
getBucketLocationResponse_locationConstraint :: Lens.Lens' GetBucketLocationResponse LocationConstraint
getBucketLocationResponse_locationConstraint :: (LocationConstraint -> f LocationConstraint)
-> GetBucketLocationResponse -> f GetBucketLocationResponse
getBucketLocationResponse_locationConstraint = (GetBucketLocationResponse -> LocationConstraint)
-> (GetBucketLocationResponse
-> LocationConstraint -> GetBucketLocationResponse)
-> Lens
GetBucketLocationResponse
GetBucketLocationResponse
LocationConstraint
LocationConstraint
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketLocationResponse' {LocationConstraint
locationConstraint :: LocationConstraint
$sel:locationConstraint:GetBucketLocationResponse' :: GetBucketLocationResponse -> LocationConstraint
locationConstraint} -> LocationConstraint
locationConstraint) (\s :: GetBucketLocationResponse
s@GetBucketLocationResponse' {} LocationConstraint
a -> GetBucketLocationResponse
s {$sel:locationConstraint:GetBucketLocationResponse' :: LocationConstraint
locationConstraint = LocationConstraint
a} :: GetBucketLocationResponse)
instance Prelude.NFData GetBucketLocationResponse