module Network.AWS.S3.ListParts
(
ListParts
, listParts
, lpBucket
, lpKey
, lpMaxParts
, lpPartNumberMarker
, lpUploadId
, ListPartsResponse
, listPartsResponse
, lprBucket
, lprInitiator
, lprIsTruncated
, lprKey
, lprMaxParts
, lprNextPartNumberMarker
, lprOwner
, lprPartNumberMarker
, lprParts
, lprStorageClass
, lprUploadId
) where
import Network.AWS.Prelude
import Network.AWS.Request.S3
import Network.AWS.S3.Types
import qualified GHC.Exts
data ListParts = ListParts
{ _lpBucket :: Text
, _lpKey :: Text
, _lpMaxParts :: Maybe Int
, _lpPartNumberMarker :: Maybe Int
, _lpUploadId :: Text
} deriving (Eq, Ord, Show)
listParts :: Text
-> Text
-> Text
-> ListParts
listParts p1 p2 p3 = ListParts
{ _lpBucket = p1
, _lpKey = p2
, _lpUploadId = p3
, _lpMaxParts = Nothing
, _lpPartNumberMarker = Nothing
}
lpBucket :: Lens' ListParts Text
lpBucket = lens _lpBucket (\s a -> s { _lpBucket = a })
lpKey :: Lens' ListParts Text
lpKey = lens _lpKey (\s a -> s { _lpKey = a })
lpMaxParts :: Lens' ListParts (Maybe Int)
lpMaxParts = lens _lpMaxParts (\s a -> s { _lpMaxParts = a })
lpPartNumberMarker :: Lens' ListParts (Maybe Int)
lpPartNumberMarker =
lens _lpPartNumberMarker (\s a -> s { _lpPartNumberMarker = a })
lpUploadId :: Lens' ListParts Text
lpUploadId = lens _lpUploadId (\s a -> s { _lpUploadId = a })
data ListPartsResponse = ListPartsResponse
{ _lprBucket :: Maybe Text
, _lprInitiator :: Maybe Initiator
, _lprIsTruncated :: Maybe Bool
, _lprKey :: Maybe Text
, _lprMaxParts :: Maybe Int
, _lprNextPartNumberMarker :: Maybe Int
, _lprOwner :: Maybe Owner
, _lprPartNumberMarker :: Maybe Int
, _lprParts :: List "Part" Part
, _lprStorageClass :: Maybe StorageClass
, _lprUploadId :: Maybe Text
} deriving (Eq, Show)
listPartsResponse :: ListPartsResponse
listPartsResponse = ListPartsResponse
{ _lprBucket = Nothing
, _lprKey = Nothing
, _lprUploadId = Nothing
, _lprPartNumberMarker = Nothing
, _lprNextPartNumberMarker = Nothing
, _lprMaxParts = Nothing
, _lprIsTruncated = Nothing
, _lprParts = mempty
, _lprInitiator = Nothing
, _lprOwner = Nothing
, _lprStorageClass = Nothing
}
lprBucket :: Lens' ListPartsResponse (Maybe Text)
lprBucket = lens _lprBucket (\s a -> s { _lprBucket = a })
lprInitiator :: Lens' ListPartsResponse (Maybe Initiator)
lprInitiator = lens _lprInitiator (\s a -> s { _lprInitiator = a })
lprIsTruncated :: Lens' ListPartsResponse (Maybe Bool)
lprIsTruncated = lens _lprIsTruncated (\s a -> s { _lprIsTruncated = a })
lprKey :: Lens' ListPartsResponse (Maybe Text)
lprKey = lens _lprKey (\s a -> s { _lprKey = a })
lprMaxParts :: Lens' ListPartsResponse (Maybe Int)
lprMaxParts = lens _lprMaxParts (\s a -> s { _lprMaxParts = a })
lprNextPartNumberMarker :: Lens' ListPartsResponse (Maybe Int)
lprNextPartNumberMarker =
lens _lprNextPartNumberMarker (\s a -> s { _lprNextPartNumberMarker = a })
lprOwner :: Lens' ListPartsResponse (Maybe Owner)
lprOwner = lens _lprOwner (\s a -> s { _lprOwner = a })
lprPartNumberMarker :: Lens' ListPartsResponse (Maybe Int)
lprPartNumberMarker =
lens _lprPartNumberMarker (\s a -> s { _lprPartNumberMarker = a })
lprParts :: Lens' ListPartsResponse [Part]
lprParts = lens _lprParts (\s a -> s { _lprParts = a }) . _List
lprStorageClass :: Lens' ListPartsResponse (Maybe StorageClass)
lprStorageClass = lens _lprStorageClass (\s a -> s { _lprStorageClass = a })
lprUploadId :: Lens' ListPartsResponse (Maybe Text)
lprUploadId = lens _lprUploadId (\s a -> s { _lprUploadId = a })
instance ToPath ListParts where
toPath ListParts{..} = mconcat
[ "/"
, toText _lpBucket
, "/"
, toText _lpKey
]
instance ToQuery ListParts where
toQuery ListParts{..} = mconcat
[ "max-parts" =? _lpMaxParts
, "part-number-marker" =? _lpPartNumberMarker
, "uploadId" =? _lpUploadId
]
instance ToHeaders ListParts
instance ToXMLRoot ListParts where
toXMLRoot = const (namespaced ns "ListParts" [])
instance ToXML ListParts
instance AWSRequest ListParts where
type Sv ListParts = S3
type Rs ListParts = ListPartsResponse
request = get
response = xmlResponse
instance FromXML ListPartsResponse where
parseXML x = ListPartsResponse
<$> x .@? "Bucket"
<*> x .@? "Initiator"
<*> x .@? "IsTruncated"
<*> x .@? "Key"
<*> x .@? "MaxParts"
<*> x .@? "NextPartNumberMarker"
<*> x .@? "Owner"
<*> x .@? "PartNumberMarker"
<*> parseXML x
<*> x .@? "StorageClass"
<*> x .@? "UploadId"
instance AWSPager ListParts where
page rq rs
| stop (rs ^. lprIsTruncated) = Nothing
| otherwise = Just $ rq
& lpPartNumberMarker .~ rs ^. lprNextPartNumberMarker