{-# 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.ListObjectsV2
(
listObjectsV2
, ListObjectsV2
, lovStartAfter
, lovContinuationToken
, lovFetchOwner
, lovPrefix
, lovEncodingType
, lovRequestPayer
, lovMaxKeys
, lovDelimiter
, lovBucket
, listObjectsV2Response
, ListObjectsV2Response
, lovrsStartAfter
, lovrsKeyCount
, lovrsContents
, lovrsContinuationToken
, lovrsPrefix
, lovrsCommonPrefixes
, lovrsEncodingType
, lovrsName
, lovrsNextContinuationToken
, lovrsMaxKeys
, lovrsIsTruncated
, lovrsDelimiter
, lovrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.S3.Types
import Network.AWS.S3.Types.Product
data ListObjectsV2 = ListObjectsV2'
{ _lovStartAfter :: !(Maybe Text)
, _lovContinuationToken :: !(Maybe Text)
, _lovFetchOwner :: !(Maybe Bool)
, _lovPrefix :: !(Maybe Text)
, _lovEncodingType :: !(Maybe EncodingType)
, _lovRequestPayer :: !(Maybe RequestPayer)
, _lovMaxKeys :: !(Maybe Int)
, _lovDelimiter :: !(Maybe Delimiter)
, _lovBucket :: !BucketName
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listObjectsV2
:: BucketName
-> ListObjectsV2
listObjectsV2 pBucket_ =
ListObjectsV2'
{ _lovStartAfter = Nothing
, _lovContinuationToken = Nothing
, _lovFetchOwner = Nothing
, _lovPrefix = Nothing
, _lovEncodingType = Nothing
, _lovRequestPayer = Nothing
, _lovMaxKeys = Nothing
, _lovDelimiter = Nothing
, _lovBucket = pBucket_
}
lovStartAfter :: Lens' ListObjectsV2 (Maybe Text)
lovStartAfter = lens _lovStartAfter (\ s a -> s{_lovStartAfter = a})
lovContinuationToken :: Lens' ListObjectsV2 (Maybe Text)
lovContinuationToken = lens _lovContinuationToken (\ s a -> s{_lovContinuationToken = a})
lovFetchOwner :: Lens' ListObjectsV2 (Maybe Bool)
lovFetchOwner = lens _lovFetchOwner (\ s a -> s{_lovFetchOwner = a})
lovPrefix :: Lens' ListObjectsV2 (Maybe Text)
lovPrefix = lens _lovPrefix (\ s a -> s{_lovPrefix = a})
lovEncodingType :: Lens' ListObjectsV2 (Maybe EncodingType)
lovEncodingType = lens _lovEncodingType (\ s a -> s{_lovEncodingType = a})
lovRequestPayer :: Lens' ListObjectsV2 (Maybe RequestPayer)
lovRequestPayer = lens _lovRequestPayer (\ s a -> s{_lovRequestPayer = a})
lovMaxKeys :: Lens' ListObjectsV2 (Maybe Int)
lovMaxKeys = lens _lovMaxKeys (\ s a -> s{_lovMaxKeys = a})
lovDelimiter :: Lens' ListObjectsV2 (Maybe Delimiter)
lovDelimiter = lens _lovDelimiter (\ s a -> s{_lovDelimiter = a})
lovBucket :: Lens' ListObjectsV2 BucketName
lovBucket = lens _lovBucket (\ s a -> s{_lovBucket = a})
instance AWSPager ListObjectsV2 where
page rq rs
| stop (rs ^. lovrsIsTruncated) = Nothing
| isNothing (rs ^. lovrsNextContinuationToken) =
Nothing
| otherwise =
Just $ rq &
lovContinuationToken .~
rs ^. lovrsNextContinuationToken
instance AWSRequest ListObjectsV2 where
type Rs ListObjectsV2 = ListObjectsV2Response
request = get s3
response
= receiveXML
(\ s h x ->
ListObjectsV2Response' <$>
(x .@? "StartAfter") <*> (x .@? "KeyCount") <*>
(may (parseXMLList "Contents") x)
<*> (x .@? "ContinuationToken")
<*> (x .@? "Prefix")
<*> (may (parseXMLList "CommonPrefixes") x)
<*> (x .@? "EncodingType")
<*> (x .@? "Name")
<*> (x .@? "NextContinuationToken")
<*> (x .@? "MaxKeys")
<*> (x .@? "IsTruncated")
<*> (x .@? "Delimiter")
<*> (pure (fromEnum s)))
instance Hashable ListObjectsV2 where
instance NFData ListObjectsV2 where
instance ToHeaders ListObjectsV2 where
toHeaders ListObjectsV2'{..}
= mconcat ["x-amz-request-payer" =# _lovRequestPayer]
instance ToPath ListObjectsV2 where
toPath ListObjectsV2'{..}
= mconcat ["/", toBS _lovBucket]
instance ToQuery ListObjectsV2 where
toQuery ListObjectsV2'{..}
= mconcat
["start-after" =: _lovStartAfter,
"continuation-token" =: _lovContinuationToken,
"fetch-owner" =: _lovFetchOwner,
"prefix" =: _lovPrefix,
"encoding-type" =: _lovEncodingType,
"max-keys" =: _lovMaxKeys,
"delimiter" =: _lovDelimiter, "list-type=2"]
data ListObjectsV2Response = ListObjectsV2Response'
{ _lovrsStartAfter :: !(Maybe Text)
, _lovrsKeyCount :: !(Maybe Int)
, _lovrsContents :: !(Maybe [Object])
, _lovrsContinuationToken :: !(Maybe Text)
, _lovrsPrefix :: !(Maybe Text)
, _lovrsCommonPrefixes :: !(Maybe [CommonPrefix])
, _lovrsEncodingType :: !(Maybe EncodingType)
, _lovrsName :: !(Maybe BucketName)
, _lovrsNextContinuationToken :: !(Maybe Text)
, _lovrsMaxKeys :: !(Maybe Int)
, _lovrsIsTruncated :: !(Maybe Bool)
, _lovrsDelimiter :: !(Maybe Delimiter)
, _lovrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listObjectsV2Response
:: Int
-> ListObjectsV2Response
listObjectsV2Response pResponseStatus_ =
ListObjectsV2Response'
{ _lovrsStartAfter = Nothing
, _lovrsKeyCount = Nothing
, _lovrsContents = Nothing
, _lovrsContinuationToken = Nothing
, _lovrsPrefix = Nothing
, _lovrsCommonPrefixes = Nothing
, _lovrsEncodingType = Nothing
, _lovrsName = Nothing
, _lovrsNextContinuationToken = Nothing
, _lovrsMaxKeys = Nothing
, _lovrsIsTruncated = Nothing
, _lovrsDelimiter = Nothing
, _lovrsResponseStatus = pResponseStatus_
}
lovrsStartAfter :: Lens' ListObjectsV2Response (Maybe Text)
lovrsStartAfter = lens _lovrsStartAfter (\ s a -> s{_lovrsStartAfter = a})
lovrsKeyCount :: Lens' ListObjectsV2Response (Maybe Int)
lovrsKeyCount = lens _lovrsKeyCount (\ s a -> s{_lovrsKeyCount = a})
lovrsContents :: Lens' ListObjectsV2Response [Object]
lovrsContents = lens _lovrsContents (\ s a -> s{_lovrsContents = a}) . _Default . _Coerce
lovrsContinuationToken :: Lens' ListObjectsV2Response (Maybe Text)
lovrsContinuationToken = lens _lovrsContinuationToken (\ s a -> s{_lovrsContinuationToken = a})
lovrsPrefix :: Lens' ListObjectsV2Response (Maybe Text)
lovrsPrefix = lens _lovrsPrefix (\ s a -> s{_lovrsPrefix = a})
lovrsCommonPrefixes :: Lens' ListObjectsV2Response [CommonPrefix]
lovrsCommonPrefixes = lens _lovrsCommonPrefixes (\ s a -> s{_lovrsCommonPrefixes = a}) . _Default . _Coerce
lovrsEncodingType :: Lens' ListObjectsV2Response (Maybe EncodingType)
lovrsEncodingType = lens _lovrsEncodingType (\ s a -> s{_lovrsEncodingType = a})
lovrsName :: Lens' ListObjectsV2Response (Maybe BucketName)
lovrsName = lens _lovrsName (\ s a -> s{_lovrsName = a})
lovrsNextContinuationToken :: Lens' ListObjectsV2Response (Maybe Text)
lovrsNextContinuationToken = lens _lovrsNextContinuationToken (\ s a -> s{_lovrsNextContinuationToken = a})
lovrsMaxKeys :: Lens' ListObjectsV2Response (Maybe Int)
lovrsMaxKeys = lens _lovrsMaxKeys (\ s a -> s{_lovrsMaxKeys = a})
lovrsIsTruncated :: Lens' ListObjectsV2Response (Maybe Bool)
lovrsIsTruncated = lens _lovrsIsTruncated (\ s a -> s{_lovrsIsTruncated = a})
lovrsDelimiter :: Lens' ListObjectsV2Response (Maybe Delimiter)
lovrsDelimiter = lens _lovrsDelimiter (\ s a -> s{_lovrsDelimiter = a})
lovrsResponseStatus :: Lens' ListObjectsV2Response Int
lovrsResponseStatus = lens _lovrsResponseStatus (\ s a -> s{_lovrsResponseStatus = a})
instance NFData ListObjectsV2Response where