{-# 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.DeleteObjects
(
deleteObjects
, DeleteObjects
, dosMFA
, dosRequestPayer
, dosBucket
, dosDelete
, deleteObjectsResponse
, DeleteObjectsResponse
, drsRequestCharged
, drsDeleted
, drsErrors
, drsResponseStatus
) 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 DeleteObjects = DeleteObjects'
{ _dosMFA :: !(Maybe Text)
, _dosRequestPayer :: !(Maybe RequestPayer)
, _dosBucket :: !BucketName
, _dosDelete :: !Delete
} deriving (Eq, Read, Show, Data, Typeable, Generic)
deleteObjects
:: BucketName
-> Delete
-> DeleteObjects
deleteObjects pBucket_ pDelete_ =
DeleteObjects'
{ _dosMFA = Nothing
, _dosRequestPayer = Nothing
, _dosBucket = pBucket_
, _dosDelete = pDelete_
}
dosMFA :: Lens' DeleteObjects (Maybe Text)
dosMFA = lens _dosMFA (\ s a -> s{_dosMFA = a})
dosRequestPayer :: Lens' DeleteObjects (Maybe RequestPayer)
dosRequestPayer = lens _dosRequestPayer (\ s a -> s{_dosRequestPayer = a})
dosBucket :: Lens' DeleteObjects BucketName
dosBucket = lens _dosBucket (\ s a -> s{_dosBucket = a})
dosDelete :: Lens' DeleteObjects Delete
dosDelete = lens _dosDelete (\ s a -> s{_dosDelete = a})
instance AWSRequest DeleteObjects where
type Rs DeleteObjects = DeleteObjectsResponse
request = contentMD5Header . postXML s3
response
= receiveXML
(\ s h x ->
DeleteObjectsResponse' <$>
(h .#? "x-amz-request-charged") <*>
(may (parseXMLList "Deleted") x)
<*> (may (parseXMLList "Error") x)
<*> (pure (fromEnum s)))
instance Hashable DeleteObjects where
instance NFData DeleteObjects where
instance ToElement DeleteObjects where
toElement
= mkElement
"{http://s3.amazonaws.com/doc/2006-03-01/}Delete"
.
_dosDelete
instance ToHeaders DeleteObjects where
toHeaders DeleteObjects'{..}
= mconcat
["x-amz-mfa" =# _dosMFA,
"x-amz-request-payer" =# _dosRequestPayer]
instance ToPath DeleteObjects where
toPath DeleteObjects'{..}
= mconcat ["/", toBS _dosBucket]
instance ToQuery DeleteObjects where
toQuery = const (mconcat ["delete"])
data DeleteObjectsResponse = DeleteObjectsResponse'
{ _drsRequestCharged :: !(Maybe RequestCharged)
, _drsDeleted :: !(Maybe [DeletedObject])
, _drsErrors :: !(Maybe [S3ServiceError])
, _drsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
deleteObjectsResponse
:: Int
-> DeleteObjectsResponse
deleteObjectsResponse pResponseStatus_ =
DeleteObjectsResponse'
{ _drsRequestCharged = Nothing
, _drsDeleted = Nothing
, _drsErrors = Nothing
, _drsResponseStatus = pResponseStatus_
}
drsRequestCharged :: Lens' DeleteObjectsResponse (Maybe RequestCharged)
drsRequestCharged = lens _drsRequestCharged (\ s a -> s{_drsRequestCharged = a})
drsDeleted :: Lens' DeleteObjectsResponse [DeletedObject]
drsDeleted = lens _drsDeleted (\ s a -> s{_drsDeleted = a}) . _Default . _Coerce
drsErrors :: Lens' DeleteObjectsResponse [S3ServiceError]
drsErrors = lens _drsErrors (\ s a -> s{_drsErrors = a}) . _Default . _Coerce
drsResponseStatus :: Lens' DeleteObjectsResponse Int
drsResponseStatus = lens _drsResponseStatus (\ s a -> s{_drsResponseStatus = a})
instance NFData DeleteObjectsResponse where