module Network.AWS.S3.ListParts
(
listParts
, ListParts
, lpMaxParts
, lpRequestPayer
, lpPartNumberMarker
, lpBucket
, lpKey
, lpUploadId
, listPartsResponse
, ListPartsResponse
, lprsParts
, lprsRequestCharged
, lprsMaxParts
, lprsInitiator
, lprsBucket
, lprsAbortDate
, lprsNextPartNumberMarker
, lprsAbortRuleId
, lprsOwner
, lprsKey
, lprsStorageClass
, lprsIsTruncated
, lprsPartNumberMarker
, lprsUploadId
, lprsResponseStatus
) 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 ListParts = ListParts'
{ _lpMaxParts :: !(Maybe Int)
, _lpRequestPayer :: !(Maybe RequestPayer)
, _lpPartNumberMarker :: !(Maybe Int)
, _lpBucket :: !BucketName
, _lpKey :: !ObjectKey
, _lpUploadId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listParts
:: BucketName
-> ObjectKey
-> Text
-> ListParts
listParts pBucket_ pKey_ pUploadId_ =
ListParts'
{ _lpMaxParts = Nothing
, _lpRequestPayer = Nothing
, _lpPartNumberMarker = Nothing
, _lpBucket = pBucket_
, _lpKey = pKey_
, _lpUploadId = pUploadId_
}
lpMaxParts :: Lens' ListParts (Maybe Int)
lpMaxParts = lens _lpMaxParts (\ s a -> s{_lpMaxParts = a});
lpRequestPayer :: Lens' ListParts (Maybe RequestPayer)
lpRequestPayer = lens _lpRequestPayer (\ s a -> s{_lpRequestPayer = a});
lpPartNumberMarker :: Lens' ListParts (Maybe Int)
lpPartNumberMarker = lens _lpPartNumberMarker (\ s a -> s{_lpPartNumberMarker = a});
lpBucket :: Lens' ListParts BucketName
lpBucket = lens _lpBucket (\ s a -> s{_lpBucket = a});
lpKey :: Lens' ListParts ObjectKey
lpKey = lens _lpKey (\ s a -> s{_lpKey = a});
lpUploadId :: Lens' ListParts Text
lpUploadId = lens _lpUploadId (\ s a -> s{_lpUploadId = a});
instance AWSPager ListParts where
page rq rs
| stop (rs ^. lprsIsTruncated) = Nothing
| isNothing (rs ^. lprsNextPartNumberMarker) =
Nothing
| otherwise =
Just $ rq &
lpPartNumberMarker .~ rs ^. lprsNextPartNumberMarker
instance AWSRequest ListParts where
type Rs ListParts = ListPartsResponse
request = get s3
response
= receiveXML
(\ s h x ->
ListPartsResponse' <$>
(may (parseXMLList "Part") x) <*>
(h .#? "x-amz-request-charged")
<*> (x .@? "MaxParts")
<*> (x .@? "Initiator")
<*> (x .@? "Bucket")
<*> (h .#? "x-amz-abort-date")
<*> (x .@? "NextPartNumberMarker")
<*> (h .#? "x-amz-abort-rule-id")
<*> (x .@? "Owner")
<*> (x .@? "Key")
<*> (x .@? "StorageClass")
<*> (x .@? "IsTruncated")
<*> (x .@? "PartNumberMarker")
<*> (x .@? "UploadId")
<*> (pure (fromEnum s)))
instance Hashable ListParts where
instance NFData ListParts where
instance ToHeaders ListParts where
toHeaders ListParts'{..}
= mconcat ["x-amz-request-payer" =# _lpRequestPayer]
instance ToPath ListParts where
toPath ListParts'{..}
= mconcat ["/", toBS _lpBucket, "/", toBS _lpKey]
instance ToQuery ListParts where
toQuery ListParts'{..}
= mconcat
["max-parts" =: _lpMaxParts,
"part-number-marker" =: _lpPartNumberMarker,
"uploadId" =: _lpUploadId]
data ListPartsResponse = ListPartsResponse'
{ _lprsParts :: !(Maybe [Part])
, _lprsRequestCharged :: !(Maybe RequestCharged)
, _lprsMaxParts :: !(Maybe Int)
, _lprsInitiator :: !(Maybe Initiator)
, _lprsBucket :: !(Maybe BucketName)
, _lprsAbortDate :: !(Maybe RFC822)
, _lprsNextPartNumberMarker :: !(Maybe Int)
, _lprsAbortRuleId :: !(Maybe Text)
, _lprsOwner :: !(Maybe Owner)
, _lprsKey :: !(Maybe ObjectKey)
, _lprsStorageClass :: !(Maybe StorageClass)
, _lprsIsTruncated :: !(Maybe Bool)
, _lprsPartNumberMarker :: !(Maybe Int)
, _lprsUploadId :: !(Maybe Text)
, _lprsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listPartsResponse
:: Int
-> ListPartsResponse
listPartsResponse pResponseStatus_ =
ListPartsResponse'
{ _lprsParts = Nothing
, _lprsRequestCharged = Nothing
, _lprsMaxParts = Nothing
, _lprsInitiator = Nothing
, _lprsBucket = Nothing
, _lprsAbortDate = Nothing
, _lprsNextPartNumberMarker = Nothing
, _lprsAbortRuleId = Nothing
, _lprsOwner = Nothing
, _lprsKey = Nothing
, _lprsStorageClass = Nothing
, _lprsIsTruncated = Nothing
, _lprsPartNumberMarker = Nothing
, _lprsUploadId = Nothing
, _lprsResponseStatus = pResponseStatus_
}
lprsParts :: Lens' ListPartsResponse [Part]
lprsParts = lens _lprsParts (\ s a -> s{_lprsParts = a}) . _Default . _Coerce;
lprsRequestCharged :: Lens' ListPartsResponse (Maybe RequestCharged)
lprsRequestCharged = lens _lprsRequestCharged (\ s a -> s{_lprsRequestCharged = a});
lprsMaxParts :: Lens' ListPartsResponse (Maybe Int)
lprsMaxParts = lens _lprsMaxParts (\ s a -> s{_lprsMaxParts = a});
lprsInitiator :: Lens' ListPartsResponse (Maybe Initiator)
lprsInitiator = lens _lprsInitiator (\ s a -> s{_lprsInitiator = a});
lprsBucket :: Lens' ListPartsResponse (Maybe BucketName)
lprsBucket = lens _lprsBucket (\ s a -> s{_lprsBucket = a});
lprsAbortDate :: Lens' ListPartsResponse (Maybe UTCTime)
lprsAbortDate = lens _lprsAbortDate (\ s a -> s{_lprsAbortDate = a}) . mapping _Time;
lprsNextPartNumberMarker :: Lens' ListPartsResponse (Maybe Int)
lprsNextPartNumberMarker = lens _lprsNextPartNumberMarker (\ s a -> s{_lprsNextPartNumberMarker = a});
lprsAbortRuleId :: Lens' ListPartsResponse (Maybe Text)
lprsAbortRuleId = lens _lprsAbortRuleId (\ s a -> s{_lprsAbortRuleId = a});
lprsOwner :: Lens' ListPartsResponse (Maybe Owner)
lprsOwner = lens _lprsOwner (\ s a -> s{_lprsOwner = a});
lprsKey :: Lens' ListPartsResponse (Maybe ObjectKey)
lprsKey = lens _lprsKey (\ s a -> s{_lprsKey = a});
lprsStorageClass :: Lens' ListPartsResponse (Maybe StorageClass)
lprsStorageClass = lens _lprsStorageClass (\ s a -> s{_lprsStorageClass = a});
lprsIsTruncated :: Lens' ListPartsResponse (Maybe Bool)
lprsIsTruncated = lens _lprsIsTruncated (\ s a -> s{_lprsIsTruncated = a});
lprsPartNumberMarker :: Lens' ListPartsResponse (Maybe Int)
lprsPartNumberMarker = lens _lprsPartNumberMarker (\ s a -> s{_lprsPartNumberMarker = a});
lprsUploadId :: Lens' ListPartsResponse (Maybe Text)
lprsUploadId = lens _lprsUploadId (\ s a -> s{_lprsUploadId = a});
lprsResponseStatus :: Lens' ListPartsResponse Int
lprsResponseStatus = lens _lprsResponseStatus (\ s a -> s{_lprsResponseStatus = a});
instance NFData ListPartsResponse where