{-# 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.ListBuckets
(
ListBuckets (..),
newListBuckets,
ListBucketsResponse (..),
newListBucketsResponse,
listBucketsResponse_buckets,
listBucketsResponse_owner,
listBucketsResponse_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 ListBuckets = ListBuckets'
{
}
deriving (ListBuckets -> ListBuckets -> Bool
(ListBuckets -> ListBuckets -> Bool)
-> (ListBuckets -> ListBuckets -> Bool) -> Eq ListBuckets
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBuckets -> ListBuckets -> Bool
$c/= :: ListBuckets -> ListBuckets -> Bool
== :: ListBuckets -> ListBuckets -> Bool
$c== :: ListBuckets -> ListBuckets -> Bool
Prelude.Eq, ReadPrec [ListBuckets]
ReadPrec ListBuckets
Int -> ReadS ListBuckets
ReadS [ListBuckets]
(Int -> ReadS ListBuckets)
-> ReadS [ListBuckets]
-> ReadPrec ListBuckets
-> ReadPrec [ListBuckets]
-> Read ListBuckets
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListBuckets]
$creadListPrec :: ReadPrec [ListBuckets]
readPrec :: ReadPrec ListBuckets
$creadPrec :: ReadPrec ListBuckets
readList :: ReadS [ListBuckets]
$creadList :: ReadS [ListBuckets]
readsPrec :: Int -> ReadS ListBuckets
$creadsPrec :: Int -> ReadS ListBuckets
Prelude.Read, Int -> ListBuckets -> ShowS
[ListBuckets] -> ShowS
ListBuckets -> String
(Int -> ListBuckets -> ShowS)
-> (ListBuckets -> String)
-> ([ListBuckets] -> ShowS)
-> Show ListBuckets
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBuckets] -> ShowS
$cshowList :: [ListBuckets] -> ShowS
show :: ListBuckets -> String
$cshow :: ListBuckets -> String
showsPrec :: Int -> ListBuckets -> ShowS
$cshowsPrec :: Int -> ListBuckets -> ShowS
Prelude.Show, (forall x. ListBuckets -> Rep ListBuckets x)
-> (forall x. Rep ListBuckets x -> ListBuckets)
-> Generic ListBuckets
forall x. Rep ListBuckets x -> ListBuckets
forall x. ListBuckets -> Rep ListBuckets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListBuckets x -> ListBuckets
$cfrom :: forall x. ListBuckets -> Rep ListBuckets x
Prelude.Generic)
newListBuckets ::
ListBuckets
newListBuckets :: ListBuckets
newListBuckets = ListBuckets
ListBuckets'
instance Core.AWSRequest ListBuckets where
type AWSResponse ListBuckets = ListBucketsResponse
request :: ListBuckets -> Request ListBuckets
request =
Request ListBuckets -> Request ListBuckets
forall a. Request a -> Request a
Request.s3vhost
(Request ListBuckets -> Request ListBuckets)
-> (ListBuckets -> Request ListBuckets)
-> ListBuckets
-> Request ListBuckets
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> ListBuckets -> Request ListBuckets
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy ListBuckets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListBuckets)))
response =
(Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse ListBuckets))
-> Logger
-> Service
-> Proxy ListBuckets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListBuckets)))
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 [Bucket] -> Maybe Owner -> Int -> ListBucketsResponse
ListBucketsResponse'
(Maybe [Bucket] -> Maybe Owner -> Int -> ListBucketsResponse)
-> Either String (Maybe [Bucket])
-> Either String (Maybe Owner -> Int -> ListBucketsResponse)
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
"Buckets" 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 [Bucket]))
-> Either String (Maybe [Bucket])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Bucket])
-> [Node] -> Either String (Maybe [Bucket])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Bucket]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Bucket")
)
Either String (Maybe Owner -> Int -> ListBucketsResponse)
-> Either String (Maybe Owner)
-> Either String (Int -> ListBucketsResponse)
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 -> ListBucketsResponse)
-> Either String Int -> Either String ListBucketsResponse
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 ListBuckets
instance Prelude.NFData ListBuckets
instance Core.ToHeaders ListBuckets where
toHeaders :: ListBuckets -> ResponseHeaders
toHeaders = ResponseHeaders -> ListBuckets -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath ListBuckets where
toPath :: ListBuckets -> ByteString
toPath = ByteString -> ListBuckets -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery ListBuckets where
toQuery :: ListBuckets -> QueryString
toQuery = QueryString -> ListBuckets -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data ListBucketsResponse = ListBucketsResponse'
{
ListBucketsResponse -> Maybe [Bucket]
buckets :: Prelude.Maybe [Bucket],
ListBucketsResponse -> Maybe Owner
owner :: Prelude.Maybe Owner,
ListBucketsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ListBucketsResponse -> ListBucketsResponse -> Bool
(ListBucketsResponse -> ListBucketsResponse -> Bool)
-> (ListBucketsResponse -> ListBucketsResponse -> Bool)
-> Eq ListBucketsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBucketsResponse -> ListBucketsResponse -> Bool
$c/= :: ListBucketsResponse -> ListBucketsResponse -> Bool
== :: ListBucketsResponse -> ListBucketsResponse -> Bool
$c== :: ListBucketsResponse -> ListBucketsResponse -> Bool
Prelude.Eq, ReadPrec [ListBucketsResponse]
ReadPrec ListBucketsResponse
Int -> ReadS ListBucketsResponse
ReadS [ListBucketsResponse]
(Int -> ReadS ListBucketsResponse)
-> ReadS [ListBucketsResponse]
-> ReadPrec ListBucketsResponse
-> ReadPrec [ListBucketsResponse]
-> Read ListBucketsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListBucketsResponse]
$creadListPrec :: ReadPrec [ListBucketsResponse]
readPrec :: ReadPrec ListBucketsResponse
$creadPrec :: ReadPrec ListBucketsResponse
readList :: ReadS [ListBucketsResponse]
$creadList :: ReadS [ListBucketsResponse]
readsPrec :: Int -> ReadS ListBucketsResponse
$creadsPrec :: Int -> ReadS ListBucketsResponse
Prelude.Read, Int -> ListBucketsResponse -> ShowS
[ListBucketsResponse] -> ShowS
ListBucketsResponse -> String
(Int -> ListBucketsResponse -> ShowS)
-> (ListBucketsResponse -> String)
-> ([ListBucketsResponse] -> ShowS)
-> Show ListBucketsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBucketsResponse] -> ShowS
$cshowList :: [ListBucketsResponse] -> ShowS
show :: ListBucketsResponse -> String
$cshow :: ListBucketsResponse -> String
showsPrec :: Int -> ListBucketsResponse -> ShowS
$cshowsPrec :: Int -> ListBucketsResponse -> ShowS
Prelude.Show, (forall x. ListBucketsResponse -> Rep ListBucketsResponse x)
-> (forall x. Rep ListBucketsResponse x -> ListBucketsResponse)
-> Generic ListBucketsResponse
forall x. Rep ListBucketsResponse x -> ListBucketsResponse
forall x. ListBucketsResponse -> Rep ListBucketsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListBucketsResponse x -> ListBucketsResponse
$cfrom :: forall x. ListBucketsResponse -> Rep ListBucketsResponse x
Prelude.Generic)
newListBucketsResponse ::
Prelude.Int ->
ListBucketsResponse
newListBucketsResponse :: Int -> ListBucketsResponse
newListBucketsResponse Int
pHttpStatus_ =
ListBucketsResponse' :: Maybe [Bucket] -> Maybe Owner -> Int -> ListBucketsResponse
ListBucketsResponse'
{ $sel:buckets:ListBucketsResponse' :: Maybe [Bucket]
buckets = Maybe [Bucket]
forall a. Maybe a
Prelude.Nothing,
$sel:owner:ListBucketsResponse' :: Maybe Owner
owner = Maybe Owner
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListBucketsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
listBucketsResponse_buckets :: Lens.Lens' ListBucketsResponse (Prelude.Maybe [Bucket])
listBucketsResponse_buckets :: (Maybe [Bucket] -> f (Maybe [Bucket]))
-> ListBucketsResponse -> f ListBucketsResponse
listBucketsResponse_buckets = (ListBucketsResponse -> Maybe [Bucket])
-> (ListBucketsResponse -> Maybe [Bucket] -> ListBucketsResponse)
-> Lens
ListBucketsResponse
ListBucketsResponse
(Maybe [Bucket])
(Maybe [Bucket])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBucketsResponse' {Maybe [Bucket]
buckets :: Maybe [Bucket]
$sel:buckets:ListBucketsResponse' :: ListBucketsResponse -> Maybe [Bucket]
buckets} -> Maybe [Bucket]
buckets) (\s :: ListBucketsResponse
s@ListBucketsResponse' {} Maybe [Bucket]
a -> ListBucketsResponse
s {$sel:buckets:ListBucketsResponse' :: Maybe [Bucket]
buckets = Maybe [Bucket]
a} :: ListBucketsResponse) ((Maybe [Bucket] -> f (Maybe [Bucket]))
-> ListBucketsResponse -> f ListBucketsResponse)
-> ((Maybe [Bucket] -> f (Maybe [Bucket]))
-> Maybe [Bucket] -> f (Maybe [Bucket]))
-> (Maybe [Bucket] -> f (Maybe [Bucket]))
-> ListBucketsResponse
-> f ListBucketsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Bucket] [Bucket] [Bucket] [Bucket]
-> Iso
(Maybe [Bucket]) (Maybe [Bucket]) (Maybe [Bucket]) (Maybe [Bucket])
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 [Bucket] [Bucket] [Bucket] [Bucket]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
listBucketsResponse_owner :: Lens.Lens' ListBucketsResponse (Prelude.Maybe Owner)
listBucketsResponse_owner :: (Maybe Owner -> f (Maybe Owner))
-> ListBucketsResponse -> f ListBucketsResponse
listBucketsResponse_owner = (ListBucketsResponse -> Maybe Owner)
-> (ListBucketsResponse -> Maybe Owner -> ListBucketsResponse)
-> Lens
ListBucketsResponse ListBucketsResponse (Maybe Owner) (Maybe Owner)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBucketsResponse' {Maybe Owner
owner :: Maybe Owner
$sel:owner:ListBucketsResponse' :: ListBucketsResponse -> Maybe Owner
owner} -> Maybe Owner
owner) (\s :: ListBucketsResponse
s@ListBucketsResponse' {} Maybe Owner
a -> ListBucketsResponse
s {$sel:owner:ListBucketsResponse' :: Maybe Owner
owner = Maybe Owner
a} :: ListBucketsResponse)
listBucketsResponse_httpStatus :: Lens.Lens' ListBucketsResponse Prelude.Int
listBucketsResponse_httpStatus :: (Int -> f Int) -> ListBucketsResponse -> f ListBucketsResponse
listBucketsResponse_httpStatus = (ListBucketsResponse -> Int)
-> (ListBucketsResponse -> Int -> ListBucketsResponse)
-> Lens ListBucketsResponse ListBucketsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBucketsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListBucketsResponse' :: ListBucketsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListBucketsResponse
s@ListBucketsResponse' {} Int
a -> ListBucketsResponse
s {$sel:httpStatus:ListBucketsResponse' :: Int
httpStatus = Int
a} :: ListBucketsResponse)
instance Prelude.NFData ListBucketsResponse