{-# 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.ListObjectVersions
(
listObjectVersions
, ListObjectVersions
, lKeyMarker
, lPrefix
, lEncodingType
, lVersionIdMarker
, lMaxKeys
, lDelimiter
, lBucket
, listObjectVersionsResponse
, ListObjectVersionsResponse
, lrsNextVersionIdMarker
, lrsKeyMarker
, lrsDeleteMarkers
, lrsPrefix
, lrsCommonPrefixes
, lrsEncodingType
, lrsVersions
, lrsName
, lrsNextKeyMarker
, lrsVersionIdMarker
, lrsMaxKeys
, lrsIsTruncated
, lrsDelimiter
, lrsResponseStatus
) 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 ListObjectVersions = ListObjectVersions'
{ _lKeyMarker :: !(Maybe Text)
, _lPrefix :: !(Maybe Text)
, _lEncodingType :: !(Maybe EncodingType)
, _lVersionIdMarker :: !(Maybe Text)
, _lMaxKeys :: !(Maybe Int)
, _lDelimiter :: !(Maybe Delimiter)
, _lBucket :: !BucketName
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listObjectVersions
:: BucketName
-> ListObjectVersions
listObjectVersions pBucket_ =
ListObjectVersions'
{ _lKeyMarker = Nothing
, _lPrefix = Nothing
, _lEncodingType = Nothing
, _lVersionIdMarker = Nothing
, _lMaxKeys = Nothing
, _lDelimiter = Nothing
, _lBucket = pBucket_
}
lKeyMarker :: Lens' ListObjectVersions (Maybe Text)
lKeyMarker = lens _lKeyMarker (\ s a -> s{_lKeyMarker = a})
lPrefix :: Lens' ListObjectVersions (Maybe Text)
lPrefix = lens _lPrefix (\ s a -> s{_lPrefix = a})
lEncodingType :: Lens' ListObjectVersions (Maybe EncodingType)
lEncodingType = lens _lEncodingType (\ s a -> s{_lEncodingType = a})
lVersionIdMarker :: Lens' ListObjectVersions (Maybe Text)
lVersionIdMarker = lens _lVersionIdMarker (\ s a -> s{_lVersionIdMarker = a})
lMaxKeys :: Lens' ListObjectVersions (Maybe Int)
lMaxKeys = lens _lMaxKeys (\ s a -> s{_lMaxKeys = a})
lDelimiter :: Lens' ListObjectVersions (Maybe Delimiter)
lDelimiter = lens _lDelimiter (\ s a -> s{_lDelimiter = a})
lBucket :: Lens' ListObjectVersions BucketName
lBucket = lens _lBucket (\ s a -> s{_lBucket = a})
instance AWSPager ListObjectVersions where
page rq rs
| stop (rs ^. lrsIsTruncated) = Nothing
| isNothing (rs ^. lrsNextKeyMarker) &&
isNothing (rs ^. lrsNextVersionIdMarker)
= Nothing
| otherwise =
Just $ rq & lKeyMarker .~ rs ^. lrsNextKeyMarker &
lVersionIdMarker .~ rs ^. lrsNextVersionIdMarker
instance AWSRequest ListObjectVersions where
type Rs ListObjectVersions =
ListObjectVersionsResponse
request = get s3
response
= receiveXML
(\ s h x ->
ListObjectVersionsResponse' <$>
(x .@? "NextVersionIdMarker") <*> (x .@? "KeyMarker")
<*> (may (parseXMLList "DeleteMarker") x)
<*> (x .@? "Prefix")
<*> (may (parseXMLList "CommonPrefixes") x)
<*> (x .@? "EncodingType")
<*> (may (parseXMLList "Version") x)
<*> (x .@? "Name")
<*> (x .@? "NextKeyMarker")
<*> (x .@? "VersionIdMarker")
<*> (x .@? "MaxKeys")
<*> (x .@? "IsTruncated")
<*> (x .@? "Delimiter")
<*> (pure (fromEnum s)))
instance Hashable ListObjectVersions where
instance NFData ListObjectVersions where
instance ToHeaders ListObjectVersions where
toHeaders = const mempty
instance ToPath ListObjectVersions where
toPath ListObjectVersions'{..}
= mconcat ["/", toBS _lBucket]
instance ToQuery ListObjectVersions where
toQuery ListObjectVersions'{..}
= mconcat
["key-marker" =: _lKeyMarker, "prefix" =: _lPrefix,
"encoding-type" =: _lEncodingType,
"version-id-marker" =: _lVersionIdMarker,
"max-keys" =: _lMaxKeys, "delimiter" =: _lDelimiter,
"versions"]
data ListObjectVersionsResponse = ListObjectVersionsResponse'
{ _lrsNextVersionIdMarker :: !(Maybe Text)
, _lrsKeyMarker :: !(Maybe Text)
, _lrsDeleteMarkers :: !(Maybe [DeleteMarkerEntry])
, _lrsPrefix :: !(Maybe Text)
, _lrsCommonPrefixes :: !(Maybe [CommonPrefix])
, _lrsEncodingType :: !(Maybe EncodingType)
, _lrsVersions :: !(Maybe [ObjectVersion])
, _lrsName :: !(Maybe BucketName)
, _lrsNextKeyMarker :: !(Maybe Text)
, _lrsVersionIdMarker :: !(Maybe Text)
, _lrsMaxKeys :: !(Maybe Int)
, _lrsIsTruncated :: !(Maybe Bool)
, _lrsDelimiter :: !(Maybe Delimiter)
, _lrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listObjectVersionsResponse
:: Int
-> ListObjectVersionsResponse
listObjectVersionsResponse pResponseStatus_ =
ListObjectVersionsResponse'
{ _lrsNextVersionIdMarker = Nothing
, _lrsKeyMarker = Nothing
, _lrsDeleteMarkers = Nothing
, _lrsPrefix = Nothing
, _lrsCommonPrefixes = Nothing
, _lrsEncodingType = Nothing
, _lrsVersions = Nothing
, _lrsName = Nothing
, _lrsNextKeyMarker = Nothing
, _lrsVersionIdMarker = Nothing
, _lrsMaxKeys = Nothing
, _lrsIsTruncated = Nothing
, _lrsDelimiter = Nothing
, _lrsResponseStatus = pResponseStatus_
}
lrsNextVersionIdMarker :: Lens' ListObjectVersionsResponse (Maybe Text)
lrsNextVersionIdMarker = lens _lrsNextVersionIdMarker (\ s a -> s{_lrsNextVersionIdMarker = a})
lrsKeyMarker :: Lens' ListObjectVersionsResponse (Maybe Text)
lrsKeyMarker = lens _lrsKeyMarker (\ s a -> s{_lrsKeyMarker = a})
lrsDeleteMarkers :: Lens' ListObjectVersionsResponse [DeleteMarkerEntry]
lrsDeleteMarkers = lens _lrsDeleteMarkers (\ s a -> s{_lrsDeleteMarkers = a}) . _Default . _Coerce
lrsPrefix :: Lens' ListObjectVersionsResponse (Maybe Text)
lrsPrefix = lens _lrsPrefix (\ s a -> s{_lrsPrefix = a})
lrsCommonPrefixes :: Lens' ListObjectVersionsResponse [CommonPrefix]
lrsCommonPrefixes = lens _lrsCommonPrefixes (\ s a -> s{_lrsCommonPrefixes = a}) . _Default . _Coerce
lrsEncodingType :: Lens' ListObjectVersionsResponse (Maybe EncodingType)
lrsEncodingType = lens _lrsEncodingType (\ s a -> s{_lrsEncodingType = a})
lrsVersions :: Lens' ListObjectVersionsResponse [ObjectVersion]
lrsVersions = lens _lrsVersions (\ s a -> s{_lrsVersions = a}) . _Default . _Coerce
lrsName :: Lens' ListObjectVersionsResponse (Maybe BucketName)
lrsName = lens _lrsName (\ s a -> s{_lrsName = a})
lrsNextKeyMarker :: Lens' ListObjectVersionsResponse (Maybe Text)
lrsNextKeyMarker = lens _lrsNextKeyMarker (\ s a -> s{_lrsNextKeyMarker = a})
lrsVersionIdMarker :: Lens' ListObjectVersionsResponse (Maybe Text)
lrsVersionIdMarker = lens _lrsVersionIdMarker (\ s a -> s{_lrsVersionIdMarker = a})
lrsMaxKeys :: Lens' ListObjectVersionsResponse (Maybe Int)
lrsMaxKeys = lens _lrsMaxKeys (\ s a -> s{_lrsMaxKeys = a})
lrsIsTruncated :: Lens' ListObjectVersionsResponse (Maybe Bool)
lrsIsTruncated = lens _lrsIsTruncated (\ s a -> s{_lrsIsTruncated = a})
lrsDelimiter :: Lens' ListObjectVersionsResponse (Maybe Delimiter)
lrsDelimiter = lens _lrsDelimiter (\ s a -> s{_lrsDelimiter = a})
lrsResponseStatus :: Lens' ListObjectVersionsResponse Int
lrsResponseStatus = lens _lrsResponseStatus (\ s a -> s{_lrsResponseStatus = a})
instance NFData ListObjectVersionsResponse where