{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.S3.ListBuckets
(
listBuckets
, ListBuckets
, listBucketsResponse
, ListBucketsResponse
, lbrsBuckets
, lbrsOwner
, lbrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.S3.Types
import Network.AWS.S3.Types.Product
data ListBuckets =
ListBuckets'
deriving (Eq, Read, Show, Data, Typeable, Generic)
listBuckets
:: ListBuckets
listBuckets = ListBuckets'
instance AWSRequest ListBuckets where
type Rs ListBuckets = ListBucketsResponse
request = get s3
response
= receiveXML
(\ s h x ->
ListBucketsResponse' <$>
(x .@? "Buckets" .!@ mempty >>=
may (parseXMLList "Bucket"))
<*> (x .@? "Owner")
<*> (pure (fromEnum s)))
instance Hashable ListBuckets where
instance NFData ListBuckets where
instance ToHeaders ListBuckets where
toHeaders = const mempty
instance ToPath ListBuckets where
toPath = const "/"
instance ToQuery ListBuckets where
toQuery = const mempty
data ListBucketsResponse = ListBucketsResponse'
{ _lbrsBuckets :: !(Maybe [Bucket])
, _lbrsOwner :: !(Maybe Owner)
, _lbrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listBucketsResponse
:: Int
-> ListBucketsResponse
listBucketsResponse pResponseStatus_ =
ListBucketsResponse'
{ _lbrsBuckets = Nothing
, _lbrsOwner = Nothing
, _lbrsResponseStatus = pResponseStatus_
}
lbrsBuckets :: Lens' ListBucketsResponse [Bucket]
lbrsBuckets = lens _lbrsBuckets (\ s a -> s{_lbrsBuckets = a}) . _Default . _Coerce
lbrsOwner :: Lens' ListBucketsResponse (Maybe Owner)
lbrsOwner = lens _lbrsOwner (\ s a -> s{_lbrsOwner = a})
lbrsResponseStatus :: Lens' ListBucketsResponse Int
lbrsResponseStatus = lens _lbrsResponseStatus (\ s a -> s{_lbrsResponseStatus = a})
instance NFData ListBucketsResponse where