{-# 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.GetBucketAcl
(
GetBucketAcl (..),
newGetBucketAcl,
getBucketAcl_expectedBucketOwner,
getBucketAcl_bucket,
GetBucketAclResponse (..),
newGetBucketAclResponse,
getBucketAclResponse_grants,
getBucketAclResponse_owner,
getBucketAclResponse_httpStatus,
)
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 GetBucketAcl = GetBucketAcl'
{
GetBucketAcl -> Maybe Text
expectedBucketOwner :: Prelude.Maybe Prelude.Text,
GetBucketAcl -> BucketName
bucket :: BucketName
}
deriving (GetBucketAcl -> GetBucketAcl -> Bool
(GetBucketAcl -> GetBucketAcl -> Bool)
-> (GetBucketAcl -> GetBucketAcl -> Bool) -> Eq GetBucketAcl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBucketAcl -> GetBucketAcl -> Bool
$c/= :: GetBucketAcl -> GetBucketAcl -> Bool
== :: GetBucketAcl -> GetBucketAcl -> Bool
$c== :: GetBucketAcl -> GetBucketAcl -> Bool
Prelude.Eq, ReadPrec [GetBucketAcl]
ReadPrec GetBucketAcl
Int -> ReadS GetBucketAcl
ReadS [GetBucketAcl]
(Int -> ReadS GetBucketAcl)
-> ReadS [GetBucketAcl]
-> ReadPrec GetBucketAcl
-> ReadPrec [GetBucketAcl]
-> Read GetBucketAcl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetBucketAcl]
$creadListPrec :: ReadPrec [GetBucketAcl]
readPrec :: ReadPrec GetBucketAcl
$creadPrec :: ReadPrec GetBucketAcl
readList :: ReadS [GetBucketAcl]
$creadList :: ReadS [GetBucketAcl]
readsPrec :: Int -> ReadS GetBucketAcl
$creadsPrec :: Int -> ReadS GetBucketAcl
Prelude.Read, Int -> GetBucketAcl -> ShowS
[GetBucketAcl] -> ShowS
GetBucketAcl -> String
(Int -> GetBucketAcl -> ShowS)
-> (GetBucketAcl -> String)
-> ([GetBucketAcl] -> ShowS)
-> Show GetBucketAcl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBucketAcl] -> ShowS
$cshowList :: [GetBucketAcl] -> ShowS
show :: GetBucketAcl -> String
$cshow :: GetBucketAcl -> String
showsPrec :: Int -> GetBucketAcl -> ShowS
$cshowsPrec :: Int -> GetBucketAcl -> ShowS
Prelude.Show, (forall x. GetBucketAcl -> Rep GetBucketAcl x)
-> (forall x. Rep GetBucketAcl x -> GetBucketAcl)
-> Generic GetBucketAcl
forall x. Rep GetBucketAcl x -> GetBucketAcl
forall x. GetBucketAcl -> Rep GetBucketAcl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetBucketAcl x -> GetBucketAcl
$cfrom :: forall x. GetBucketAcl -> Rep GetBucketAcl x
Prelude.Generic)
newGetBucketAcl ::
BucketName ->
GetBucketAcl
newGetBucketAcl :: BucketName -> GetBucketAcl
newGetBucketAcl BucketName
pBucket_ =
GetBucketAcl' :: Maybe Text -> BucketName -> GetBucketAcl
GetBucketAcl'
{ $sel:expectedBucketOwner:GetBucketAcl' :: Maybe Text
expectedBucketOwner =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:bucket:GetBucketAcl' :: BucketName
bucket = BucketName
pBucket_
}
getBucketAcl_expectedBucketOwner :: Lens.Lens' GetBucketAcl (Prelude.Maybe Prelude.Text)
getBucketAcl_expectedBucketOwner :: (Maybe Text -> f (Maybe Text)) -> GetBucketAcl -> f GetBucketAcl
getBucketAcl_expectedBucketOwner = (GetBucketAcl -> Maybe Text)
-> (GetBucketAcl -> Maybe Text -> GetBucketAcl)
-> Lens GetBucketAcl GetBucketAcl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketAcl' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:GetBucketAcl' :: GetBucketAcl -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: GetBucketAcl
s@GetBucketAcl' {} Maybe Text
a -> GetBucketAcl
s {$sel:expectedBucketOwner:GetBucketAcl' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: GetBucketAcl)
getBucketAcl_bucket :: Lens.Lens' GetBucketAcl BucketName
getBucketAcl_bucket :: (BucketName -> f BucketName) -> GetBucketAcl -> f GetBucketAcl
getBucketAcl_bucket = (GetBucketAcl -> BucketName)
-> (GetBucketAcl -> BucketName -> GetBucketAcl)
-> Lens GetBucketAcl GetBucketAcl BucketName BucketName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketAcl' {BucketName
bucket :: BucketName
$sel:bucket:GetBucketAcl' :: GetBucketAcl -> BucketName
bucket} -> BucketName
bucket) (\s :: GetBucketAcl
s@GetBucketAcl' {} BucketName
a -> GetBucketAcl
s {$sel:bucket:GetBucketAcl' :: BucketName
bucket = BucketName
a} :: GetBucketAcl)
instance Core.AWSRequest GetBucketAcl where
type AWSResponse GetBucketAcl = GetBucketAclResponse
request :: GetBucketAcl -> Request GetBucketAcl
request =
Request GetBucketAcl -> Request GetBucketAcl
forall a. Request a -> Request a
Request.s3vhost
(Request GetBucketAcl -> Request GetBucketAcl)
-> (GetBucketAcl -> Request GetBucketAcl)
-> GetBucketAcl
-> Request GetBucketAcl
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> GetBucketAcl -> Request GetBucketAcl
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy GetBucketAcl
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBucketAcl)))
response =
(Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse GetBucketAcl))
-> Logger
-> Service
-> Proxy GetBucketAcl
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBucketAcl)))
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 ->
Maybe [Grant] -> Maybe Owner -> Int -> GetBucketAclResponse
GetBucketAclResponse'
(Maybe [Grant] -> Maybe Owner -> Int -> GetBucketAclResponse)
-> Either String (Maybe [Grant])
-> Either String (Maybe Owner -> Int -> GetBucketAclResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AccessControlList"
Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
Either String [Node]
-> ([Node] -> Either String (Maybe [Grant]))
-> Either String (Maybe [Grant])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Grant])
-> [Node] -> Either String (Maybe [Grant])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Grant]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Grant")
)
Either String (Maybe Owner -> Int -> GetBucketAclResponse)
-> Either String (Maybe Owner)
-> Either String (Int -> GetBucketAclResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Owner)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Owner")
Either String (Int -> GetBucketAclResponse)
-> Either String Int -> Either String GetBucketAclResponse
forall (f :: * -> *) a b. Applicative f => 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))
)
instance Prelude.Hashable GetBucketAcl
instance Prelude.NFData GetBucketAcl
instance Core.ToHeaders GetBucketAcl where
toHeaders :: GetBucketAcl -> ResponseHeaders
toHeaders GetBucketAcl' {Maybe Text
BucketName
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:bucket:GetBucketAcl' :: GetBucketAcl -> BucketName
$sel:expectedBucketOwner:GetBucketAcl' :: GetBucketAcl -> 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 GetBucketAcl where
toPath :: GetBucketAcl -> ByteString
toPath GetBucketAcl' {Maybe Text
BucketName
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:bucket:GetBucketAcl' :: GetBucketAcl -> BucketName
$sel:expectedBucketOwner:GetBucketAcl' :: GetBucketAcl -> 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 GetBucketAcl where
toQuery :: GetBucketAcl -> QueryString
toQuery = QueryString -> GetBucketAcl -> QueryString
forall a b. a -> b -> a
Prelude.const ([QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [QueryString
"acl"])
data GetBucketAclResponse = GetBucketAclResponse'
{
GetBucketAclResponse -> Maybe [Grant]
grants :: Prelude.Maybe [Grant],
GetBucketAclResponse -> Maybe Owner
owner :: Prelude.Maybe Owner,
GetBucketAclResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetBucketAclResponse -> GetBucketAclResponse -> Bool
(GetBucketAclResponse -> GetBucketAclResponse -> Bool)
-> (GetBucketAclResponse -> GetBucketAclResponse -> Bool)
-> Eq GetBucketAclResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBucketAclResponse -> GetBucketAclResponse -> Bool
$c/= :: GetBucketAclResponse -> GetBucketAclResponse -> Bool
== :: GetBucketAclResponse -> GetBucketAclResponse -> Bool
$c== :: GetBucketAclResponse -> GetBucketAclResponse -> Bool
Prelude.Eq, ReadPrec [GetBucketAclResponse]
ReadPrec GetBucketAclResponse
Int -> ReadS GetBucketAclResponse
ReadS [GetBucketAclResponse]
(Int -> ReadS GetBucketAclResponse)
-> ReadS [GetBucketAclResponse]
-> ReadPrec GetBucketAclResponse
-> ReadPrec [GetBucketAclResponse]
-> Read GetBucketAclResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetBucketAclResponse]
$creadListPrec :: ReadPrec [GetBucketAclResponse]
readPrec :: ReadPrec GetBucketAclResponse
$creadPrec :: ReadPrec GetBucketAclResponse
readList :: ReadS [GetBucketAclResponse]
$creadList :: ReadS [GetBucketAclResponse]
readsPrec :: Int -> ReadS GetBucketAclResponse
$creadsPrec :: Int -> ReadS GetBucketAclResponse
Prelude.Read, Int -> GetBucketAclResponse -> ShowS
[GetBucketAclResponse] -> ShowS
GetBucketAclResponse -> String
(Int -> GetBucketAclResponse -> ShowS)
-> (GetBucketAclResponse -> String)
-> ([GetBucketAclResponse] -> ShowS)
-> Show GetBucketAclResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBucketAclResponse] -> ShowS
$cshowList :: [GetBucketAclResponse] -> ShowS
show :: GetBucketAclResponse -> String
$cshow :: GetBucketAclResponse -> String
showsPrec :: Int -> GetBucketAclResponse -> ShowS
$cshowsPrec :: Int -> GetBucketAclResponse -> ShowS
Prelude.Show, (forall x. GetBucketAclResponse -> Rep GetBucketAclResponse x)
-> (forall x. Rep GetBucketAclResponse x -> GetBucketAclResponse)
-> Generic GetBucketAclResponse
forall x. Rep GetBucketAclResponse x -> GetBucketAclResponse
forall x. GetBucketAclResponse -> Rep GetBucketAclResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetBucketAclResponse x -> GetBucketAclResponse
$cfrom :: forall x. GetBucketAclResponse -> Rep GetBucketAclResponse x
Prelude.Generic)
newGetBucketAclResponse ::
Prelude.Int ->
GetBucketAclResponse
newGetBucketAclResponse :: Int -> GetBucketAclResponse
newGetBucketAclResponse Int
pHttpStatus_ =
GetBucketAclResponse' :: Maybe [Grant] -> Maybe Owner -> Int -> GetBucketAclResponse
GetBucketAclResponse'
{ $sel:grants:GetBucketAclResponse' :: Maybe [Grant]
grants = Maybe [Grant]
forall a. Maybe a
Prelude.Nothing,
$sel:owner:GetBucketAclResponse' :: Maybe Owner
owner = Maybe Owner
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetBucketAclResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getBucketAclResponse_grants :: Lens.Lens' GetBucketAclResponse (Prelude.Maybe [Grant])
getBucketAclResponse_grants :: (Maybe [Grant] -> f (Maybe [Grant]))
-> GetBucketAclResponse -> f GetBucketAclResponse
getBucketAclResponse_grants = (GetBucketAclResponse -> Maybe [Grant])
-> (GetBucketAclResponse -> Maybe [Grant] -> GetBucketAclResponse)
-> Lens
GetBucketAclResponse
GetBucketAclResponse
(Maybe [Grant])
(Maybe [Grant])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketAclResponse' {Maybe [Grant]
grants :: Maybe [Grant]
$sel:grants:GetBucketAclResponse' :: GetBucketAclResponse -> Maybe [Grant]
grants} -> Maybe [Grant]
grants) (\s :: GetBucketAclResponse
s@GetBucketAclResponse' {} Maybe [Grant]
a -> GetBucketAclResponse
s {$sel:grants:GetBucketAclResponse' :: Maybe [Grant]
grants = Maybe [Grant]
a} :: GetBucketAclResponse) ((Maybe [Grant] -> f (Maybe [Grant]))
-> GetBucketAclResponse -> f GetBucketAclResponse)
-> ((Maybe [Grant] -> f (Maybe [Grant]))
-> Maybe [Grant] -> f (Maybe [Grant]))
-> (Maybe [Grant] -> f (Maybe [Grant]))
-> GetBucketAclResponse
-> f GetBucketAclResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Grant] [Grant] [Grant] [Grant]
-> Iso
(Maybe [Grant]) (Maybe [Grant]) (Maybe [Grant]) (Maybe [Grant])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Grant] [Grant] [Grant] [Grant]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getBucketAclResponse_owner :: Lens.Lens' GetBucketAclResponse (Prelude.Maybe Owner)
getBucketAclResponse_owner :: (Maybe Owner -> f (Maybe Owner))
-> GetBucketAclResponse -> f GetBucketAclResponse
getBucketAclResponse_owner = (GetBucketAclResponse -> Maybe Owner)
-> (GetBucketAclResponse -> Maybe Owner -> GetBucketAclResponse)
-> Lens
GetBucketAclResponse
GetBucketAclResponse
(Maybe Owner)
(Maybe Owner)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketAclResponse' {Maybe Owner
owner :: Maybe Owner
$sel:owner:GetBucketAclResponse' :: GetBucketAclResponse -> Maybe Owner
owner} -> Maybe Owner
owner) (\s :: GetBucketAclResponse
s@GetBucketAclResponse' {} Maybe Owner
a -> GetBucketAclResponse
s {$sel:owner:GetBucketAclResponse' :: Maybe Owner
owner = Maybe Owner
a} :: GetBucketAclResponse)
getBucketAclResponse_httpStatus :: Lens.Lens' GetBucketAclResponse Prelude.Int
getBucketAclResponse_httpStatus :: (Int -> f Int) -> GetBucketAclResponse -> f GetBucketAclResponse
getBucketAclResponse_httpStatus = (GetBucketAclResponse -> Int)
-> (GetBucketAclResponse -> Int -> GetBucketAclResponse)
-> Lens GetBucketAclResponse GetBucketAclResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketAclResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetBucketAclResponse' :: GetBucketAclResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetBucketAclResponse
s@GetBucketAclResponse' {} Int
a -> GetBucketAclResponse
s {$sel:httpStatus:GetBucketAclResponse' :: Int
httpStatus = Int
a} :: GetBucketAclResponse)
instance Prelude.NFData GetBucketAclResponse