{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.S3.DeleteObjects
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This action enables you to delete multiple objects from a bucket using a
-- single HTTP request. If you know the object keys that you want to
-- delete, then this action provides a suitable alternative to sending
-- individual delete requests, reducing per-request overhead.
--
-- The request contains a list of up to 1000 keys that you want to delete.
-- In the XML, you provide the object key names, and optionally, version
-- IDs if you want to delete a specific version of the object from a
-- versioning-enabled bucket. For each key, Amazon S3 performs a delete
-- action and returns the result of that delete, success, or failure, in
-- the response. Note that if the object specified in the request is not
-- found, Amazon S3 returns the result as deleted.
--
-- The action supports two modes for the response: verbose and quiet. By
-- default, the action uses verbose mode in which the response includes the
-- result of deletion of each key in your request. In quiet mode the
-- response includes only keys where the delete action encountered an
-- error. For a successful deletion, the action does not return any
-- information about the delete in the response body.
--
-- When performing this action on an MFA Delete enabled bucket, that
-- attempts to delete any versioned objects, you must include an MFA token.
-- If you do not provide one, the entire request will fail, even if there
-- are non-versioned objects you are trying to delete. If you provide an
-- invalid token, whether there are versioned keys in the request or not,
-- the entire Multi-Object Delete request will fail. For information about
-- MFA Delete, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/Versioning.html#MultiFactorAuthenticationDelete MFA Delete>.
--
-- Finally, the Content-MD5 header is required for all Multi-Object Delete
-- requests. Amazon S3 uses the header value to ensure that your request
-- body has not been altered in transit.
--
-- The following operations are related to @DeleteObjects@:
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html CreateMultipartUpload>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html UploadPart>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html CompleteMultipartUpload>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html ListParts>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html AbortMultipartUpload>
module Amazonka.S3.DeleteObjects
  ( -- * Creating a Request
    DeleteObjects (..),
    newDeleteObjects,

    -- * Request Lenses
    deleteObjects_mfa,
    deleteObjects_requestPayer,
    deleteObjects_bypassGovernanceRetention,
    deleteObjects_expectedBucketOwner,
    deleteObjects_bucket,
    deleteObjects_delete,

    -- * Destructuring the Response
    DeleteObjectsResponse (..),
    newDeleteObjectsResponse,

    -- * Response Lenses
    deleteObjectsResponse_requestCharged,
    deleteObjectsResponse_deleted,
    deleteObjectsResponse_errors,
    deleteObjectsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.S3.Types

-- | /See:/ 'newDeleteObjects' smart constructor.
data DeleteObjects = DeleteObjects'
  { -- | The concatenation of the authentication device\'s serial number, a
    -- space, and the value that is displayed on your authentication device.
    -- Required to permanently delete a versioned object if versioning is
    -- configured with MFA delete enabled.
    DeleteObjects -> Maybe Text
mfa :: Prelude.Maybe Prelude.Text,
    DeleteObjects -> Maybe RequestPayer
requestPayer :: Prelude.Maybe RequestPayer,
    -- | Specifies whether you want to delete this object even if it has a
    -- Governance-type Object Lock in place. To use this header, you must have
    -- the @s3:PutBucketPublicAccessBlock@ permission.
    DeleteObjects -> Maybe Bool
bypassGovernanceRetention :: Prelude.Maybe Prelude.Bool,
    -- | The account ID of the expected bucket owner. If the bucket is owned by a
    -- different account, the request will fail with an HTTP
    -- @403 (Access Denied)@ error.
    DeleteObjects -> Maybe Text
expectedBucketOwner :: Prelude.Maybe Prelude.Text,
    -- | The bucket name containing the objects to delete.
    --
    -- When using this action with an access point, you must direct requests to
    -- the access point hostname. The access point hostname takes the form
    -- /AccessPointName/-/AccountId/.s3-accesspoint./Region/.amazonaws.com.
    -- When using this action with an access point through the Amazon Web
    -- Services SDKs, you provide the access point ARN in place of the bucket
    -- name. For more information about access point ARNs, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html Using access points>
    -- in the /Amazon S3 User Guide/.
    --
    -- When using this action with Amazon S3 on Outposts, you must direct
    -- requests to the S3 on Outposts hostname. The S3 on Outposts hostname
    -- takes the form
    -- /AccessPointName/-/AccountId/./outpostID/.s3-outposts./Region/.amazonaws.com.
    -- When using this action using S3 on Outposts through the Amazon Web
    -- Services SDKs, you provide the Outposts bucket ARN in place of the
    -- bucket name. For more information about S3 on Outposts ARNs, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html Using S3 on Outposts>
    -- in the /Amazon S3 User Guide/.
    DeleteObjects -> BucketName
bucket :: BucketName,
    -- | Container for the request.
    DeleteObjects -> Delete
delete' :: Delete
  }
  deriving (DeleteObjects -> DeleteObjects -> Bool
(DeleteObjects -> DeleteObjects -> Bool)
-> (DeleteObjects -> DeleteObjects -> Bool) -> Eq DeleteObjects
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteObjects -> DeleteObjects -> Bool
$c/= :: DeleteObjects -> DeleteObjects -> Bool
== :: DeleteObjects -> DeleteObjects -> Bool
$c== :: DeleteObjects -> DeleteObjects -> Bool
Prelude.Eq, ReadPrec [DeleteObjects]
ReadPrec DeleteObjects
Int -> ReadS DeleteObjects
ReadS [DeleteObjects]
(Int -> ReadS DeleteObjects)
-> ReadS [DeleteObjects]
-> ReadPrec DeleteObjects
-> ReadPrec [DeleteObjects]
-> Read DeleteObjects
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteObjects]
$creadListPrec :: ReadPrec [DeleteObjects]
readPrec :: ReadPrec DeleteObjects
$creadPrec :: ReadPrec DeleteObjects
readList :: ReadS [DeleteObjects]
$creadList :: ReadS [DeleteObjects]
readsPrec :: Int -> ReadS DeleteObjects
$creadsPrec :: Int -> ReadS DeleteObjects
Prelude.Read, Int -> DeleteObjects -> ShowS
[DeleteObjects] -> ShowS
DeleteObjects -> String
(Int -> DeleteObjects -> ShowS)
-> (DeleteObjects -> String)
-> ([DeleteObjects] -> ShowS)
-> Show DeleteObjects
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteObjects] -> ShowS
$cshowList :: [DeleteObjects] -> ShowS
show :: DeleteObjects -> String
$cshow :: DeleteObjects -> String
showsPrec :: Int -> DeleteObjects -> ShowS
$cshowsPrec :: Int -> DeleteObjects -> ShowS
Prelude.Show, (forall x. DeleteObjects -> Rep DeleteObjects x)
-> (forall x. Rep DeleteObjects x -> DeleteObjects)
-> Generic DeleteObjects
forall x. Rep DeleteObjects x -> DeleteObjects
forall x. DeleteObjects -> Rep DeleteObjects x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteObjects x -> DeleteObjects
$cfrom :: forall x. DeleteObjects -> Rep DeleteObjects x
Prelude.Generic)

-- |
-- Create a value of 'DeleteObjects' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'mfa', 'deleteObjects_mfa' - The concatenation of the authentication device\'s serial number, a
-- space, and the value that is displayed on your authentication device.
-- Required to permanently delete a versioned object if versioning is
-- configured with MFA delete enabled.
--
-- 'requestPayer', 'deleteObjects_requestPayer' - Undocumented member.
--
-- 'bypassGovernanceRetention', 'deleteObjects_bypassGovernanceRetention' - Specifies whether you want to delete this object even if it has a
-- Governance-type Object Lock in place. To use this header, you must have
-- the @s3:PutBucketPublicAccessBlock@ permission.
--
-- 'expectedBucketOwner', 'deleteObjects_expectedBucketOwner' - The account ID of the expected bucket owner. If the bucket is owned by a
-- different account, the request will fail with an HTTP
-- @403 (Access Denied)@ error.
--
-- 'bucket', 'deleteObjects_bucket' - The bucket name containing the objects to delete.
--
-- When using this action with an access point, you must direct requests to
-- the access point hostname. The access point hostname takes the form
-- /AccessPointName/-/AccountId/.s3-accesspoint./Region/.amazonaws.com.
-- When using this action with an access point through the Amazon Web
-- Services SDKs, you provide the access point ARN in place of the bucket
-- name. For more information about access point ARNs, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html Using access points>
-- in the /Amazon S3 User Guide/.
--
-- When using this action with Amazon S3 on Outposts, you must direct
-- requests to the S3 on Outposts hostname. The S3 on Outposts hostname
-- takes the form
-- /AccessPointName/-/AccountId/./outpostID/.s3-outposts./Region/.amazonaws.com.
-- When using this action using S3 on Outposts through the Amazon Web
-- Services SDKs, you provide the Outposts bucket ARN in place of the
-- bucket name. For more information about S3 on Outposts ARNs, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html Using S3 on Outposts>
-- in the /Amazon S3 User Guide/.
--
-- 'delete'', 'deleteObjects_delete' - Container for the request.
newDeleteObjects ::
  -- | 'bucket'
  BucketName ->
  -- | 'delete''
  Delete ->
  DeleteObjects
newDeleteObjects :: BucketName -> Delete -> DeleteObjects
newDeleteObjects BucketName
pBucket_ Delete
pDelete_ =
  DeleteObjects' :: Maybe Text
-> Maybe RequestPayer
-> Maybe Bool
-> Maybe Text
-> BucketName
-> Delete
-> DeleteObjects
DeleteObjects'
    { $sel:mfa:DeleteObjects' :: Maybe Text
mfa = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:requestPayer:DeleteObjects' :: Maybe RequestPayer
requestPayer = Maybe RequestPayer
forall a. Maybe a
Prelude.Nothing,
      $sel:bypassGovernanceRetention:DeleteObjects' :: Maybe Bool
bypassGovernanceRetention = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:expectedBucketOwner:DeleteObjects' :: Maybe Text
expectedBucketOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:DeleteObjects' :: BucketName
bucket = BucketName
pBucket_,
      $sel:delete':DeleteObjects' :: Delete
delete' = Delete
pDelete_
    }

-- | The concatenation of the authentication device\'s serial number, a
-- space, and the value that is displayed on your authentication device.
-- Required to permanently delete a versioned object if versioning is
-- configured with MFA delete enabled.
deleteObjects_mfa :: Lens.Lens' DeleteObjects (Prelude.Maybe Prelude.Text)
deleteObjects_mfa :: (Maybe Text -> f (Maybe Text)) -> DeleteObjects -> f DeleteObjects
deleteObjects_mfa = (DeleteObjects -> Maybe Text)
-> (DeleteObjects -> Maybe Text -> DeleteObjects)
-> Lens DeleteObjects DeleteObjects (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObjects' {Maybe Text
mfa :: Maybe Text
$sel:mfa:DeleteObjects' :: DeleteObjects -> Maybe Text
mfa} -> Maybe Text
mfa) (\s :: DeleteObjects
s@DeleteObjects' {} Maybe Text
a -> DeleteObjects
s {$sel:mfa:DeleteObjects' :: Maybe Text
mfa = Maybe Text
a} :: DeleteObjects)

-- | Undocumented member.
deleteObjects_requestPayer :: Lens.Lens' DeleteObjects (Prelude.Maybe RequestPayer)
deleteObjects_requestPayer :: (Maybe RequestPayer -> f (Maybe RequestPayer))
-> DeleteObjects -> f DeleteObjects
deleteObjects_requestPayer = (DeleteObjects -> Maybe RequestPayer)
-> (DeleteObjects -> Maybe RequestPayer -> DeleteObjects)
-> Lens
     DeleteObjects
     DeleteObjects
     (Maybe RequestPayer)
     (Maybe RequestPayer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObjects' {Maybe RequestPayer
requestPayer :: Maybe RequestPayer
$sel:requestPayer:DeleteObjects' :: DeleteObjects -> Maybe RequestPayer
requestPayer} -> Maybe RequestPayer
requestPayer) (\s :: DeleteObjects
s@DeleteObjects' {} Maybe RequestPayer
a -> DeleteObjects
s {$sel:requestPayer:DeleteObjects' :: Maybe RequestPayer
requestPayer = Maybe RequestPayer
a} :: DeleteObjects)

-- | Specifies whether you want to delete this object even if it has a
-- Governance-type Object Lock in place. To use this header, you must have
-- the @s3:PutBucketPublicAccessBlock@ permission.
deleteObjects_bypassGovernanceRetention :: Lens.Lens' DeleteObjects (Prelude.Maybe Prelude.Bool)
deleteObjects_bypassGovernanceRetention :: (Maybe Bool -> f (Maybe Bool)) -> DeleteObjects -> f DeleteObjects
deleteObjects_bypassGovernanceRetention = (DeleteObjects -> Maybe Bool)
-> (DeleteObjects -> Maybe Bool -> DeleteObjects)
-> Lens DeleteObjects DeleteObjects (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObjects' {Maybe Bool
bypassGovernanceRetention :: Maybe Bool
$sel:bypassGovernanceRetention:DeleteObjects' :: DeleteObjects -> Maybe Bool
bypassGovernanceRetention} -> Maybe Bool
bypassGovernanceRetention) (\s :: DeleteObjects
s@DeleteObjects' {} Maybe Bool
a -> DeleteObjects
s {$sel:bypassGovernanceRetention:DeleteObjects' :: Maybe Bool
bypassGovernanceRetention = Maybe Bool
a} :: DeleteObjects)

-- | The account ID of the expected bucket owner. If the bucket is owned by a
-- different account, the request will fail with an HTTP
-- @403 (Access Denied)@ error.
deleteObjects_expectedBucketOwner :: Lens.Lens' DeleteObjects (Prelude.Maybe Prelude.Text)
deleteObjects_expectedBucketOwner :: (Maybe Text -> f (Maybe Text)) -> DeleteObjects -> f DeleteObjects
deleteObjects_expectedBucketOwner = (DeleteObjects -> Maybe Text)
-> (DeleteObjects -> Maybe Text -> DeleteObjects)
-> Lens DeleteObjects DeleteObjects (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObjects' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:DeleteObjects' :: DeleteObjects -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: DeleteObjects
s@DeleteObjects' {} Maybe Text
a -> DeleteObjects
s {$sel:expectedBucketOwner:DeleteObjects' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: DeleteObjects)

-- | The bucket name containing the objects to delete.
--
-- When using this action with an access point, you must direct requests to
-- the access point hostname. The access point hostname takes the form
-- /AccessPointName/-/AccountId/.s3-accesspoint./Region/.amazonaws.com.
-- When using this action with an access point through the Amazon Web
-- Services SDKs, you provide the access point ARN in place of the bucket
-- name. For more information about access point ARNs, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html Using access points>
-- in the /Amazon S3 User Guide/.
--
-- When using this action with Amazon S3 on Outposts, you must direct
-- requests to the S3 on Outposts hostname. The S3 on Outposts hostname
-- takes the form
-- /AccessPointName/-/AccountId/./outpostID/.s3-outposts./Region/.amazonaws.com.
-- When using this action using S3 on Outposts through the Amazon Web
-- Services SDKs, you provide the Outposts bucket ARN in place of the
-- bucket name. For more information about S3 on Outposts ARNs, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html Using S3 on Outposts>
-- in the /Amazon S3 User Guide/.
deleteObjects_bucket :: Lens.Lens' DeleteObjects BucketName
deleteObjects_bucket :: (BucketName -> f BucketName) -> DeleteObjects -> f DeleteObjects
deleteObjects_bucket = (DeleteObjects -> BucketName)
-> (DeleteObjects -> BucketName -> DeleteObjects)
-> Lens DeleteObjects DeleteObjects BucketName BucketName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObjects' {BucketName
bucket :: BucketName
$sel:bucket:DeleteObjects' :: DeleteObjects -> BucketName
bucket} -> BucketName
bucket) (\s :: DeleteObjects
s@DeleteObjects' {} BucketName
a -> DeleteObjects
s {$sel:bucket:DeleteObjects' :: BucketName
bucket = BucketName
a} :: DeleteObjects)

-- | Container for the request.
deleteObjects_delete :: Lens.Lens' DeleteObjects Delete
deleteObjects_delete :: (Delete -> f Delete) -> DeleteObjects -> f DeleteObjects
deleteObjects_delete = (DeleteObjects -> Delete)
-> (DeleteObjects -> Delete -> DeleteObjects)
-> Lens DeleteObjects DeleteObjects Delete Delete
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObjects' {Delete
delete' :: Delete
$sel:delete':DeleteObjects' :: DeleteObjects -> Delete
delete'} -> Delete
delete') (\s :: DeleteObjects
s@DeleteObjects' {} Delete
a -> DeleteObjects
s {$sel:delete':DeleteObjects' :: Delete
delete' = Delete
a} :: DeleteObjects)

instance Core.AWSRequest DeleteObjects where
  type
    AWSResponse DeleteObjects =
      DeleteObjectsResponse
  request :: DeleteObjects -> Request DeleteObjects
request =
    Request DeleteObjects -> Request DeleteObjects
forall a. Request a -> Request a
Request.contentMD5Header
      (Request DeleteObjects -> Request DeleteObjects)
-> (DeleteObjects -> Request DeleteObjects)
-> DeleteObjects
-> Request DeleteObjects
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Request DeleteObjects -> Request DeleteObjects
forall a. Request a -> Request a
Request.s3vhost
      (Request DeleteObjects -> Request DeleteObjects)
-> (DeleteObjects -> Request DeleteObjects)
-> DeleteObjects
-> Request DeleteObjects
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> DeleteObjects -> Request DeleteObjects
forall a. (ToRequest a, ToElement a) => Service -> a -> Request a
Request.postXML Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteObjects
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteObjects)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse DeleteObjects))
-> Logger
-> Service
-> Proxy DeleteObjects
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteObjects)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe RequestCharged
-> Maybe [DeletedObject]
-> Maybe [S3ServiceError]
-> Int
-> DeleteObjectsResponse
DeleteObjectsResponse'
            (Maybe RequestCharged
 -> Maybe [DeletedObject]
 -> Maybe [S3ServiceError]
 -> Int
 -> DeleteObjectsResponse)
-> Either String (Maybe RequestCharged)
-> Either
     String
     (Maybe [DeletedObject]
      -> Maybe [S3ServiceError] -> Int -> DeleteObjectsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h ResponseHeaders
-> HeaderName -> Either String (Maybe RequestCharged)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"x-amz-request-charged")
            Either
  String
  (Maybe [DeletedObject]
   -> Maybe [S3ServiceError] -> Int -> DeleteObjectsResponse)
-> Either String (Maybe [DeletedObject])
-> Either
     String (Maybe [S3ServiceError] -> Int -> DeleteObjectsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (([Node] -> Either String [DeletedObject])
-> [Node] -> Either String (Maybe [DeletedObject])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [DeletedObject]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Deleted") [Node]
x)
            Either
  String (Maybe [S3ServiceError] -> Int -> DeleteObjectsResponse)
-> Either String (Maybe [S3ServiceError])
-> Either String (Int -> DeleteObjectsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (([Node] -> Either String [S3ServiceError])
-> [Node] -> Either String (Maybe [S3ServiceError])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [S3ServiceError]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Error") [Node]
x)
            Either String (Int -> DeleteObjectsResponse)
-> Either String Int -> Either String DeleteObjectsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteObjects

instance Prelude.NFData DeleteObjects

instance Core.ToElement DeleteObjects where
  toElement :: DeleteObjects -> Element
toElement DeleteObjects' {Maybe Bool
Maybe Text
Maybe RequestPayer
BucketName
Delete
delete' :: Delete
bucket :: BucketName
expectedBucketOwner :: Maybe Text
bypassGovernanceRetention :: Maybe Bool
requestPayer :: Maybe RequestPayer
mfa :: Maybe Text
$sel:delete':DeleteObjects' :: DeleteObjects -> Delete
$sel:bucket:DeleteObjects' :: DeleteObjects -> BucketName
$sel:expectedBucketOwner:DeleteObjects' :: DeleteObjects -> Maybe Text
$sel:bypassGovernanceRetention:DeleteObjects' :: DeleteObjects -> Maybe Bool
$sel:requestPayer:DeleteObjects' :: DeleteObjects -> Maybe RequestPayer
$sel:mfa:DeleteObjects' :: DeleteObjects -> Maybe Text
..} =
    Name -> Delete -> Element
forall a. ToXML a => Name -> a -> Element
Core.mkElement
      Name
"{http://s3.amazonaws.com/doc/2006-03-01/}Delete"
      Delete
delete'

instance Core.ToHeaders DeleteObjects where
  toHeaders :: DeleteObjects -> ResponseHeaders
toHeaders DeleteObjects' {Maybe Bool
Maybe Text
Maybe RequestPayer
BucketName
Delete
delete' :: Delete
bucket :: BucketName
expectedBucketOwner :: Maybe Text
bypassGovernanceRetention :: Maybe Bool
requestPayer :: Maybe RequestPayer
mfa :: Maybe Text
$sel:delete':DeleteObjects' :: DeleteObjects -> Delete
$sel:bucket:DeleteObjects' :: DeleteObjects -> BucketName
$sel:expectedBucketOwner:DeleteObjects' :: DeleteObjects -> Maybe Text
$sel:bypassGovernanceRetention:DeleteObjects' :: DeleteObjects -> Maybe Bool
$sel:requestPayer:DeleteObjects' :: DeleteObjects -> Maybe RequestPayer
$sel:mfa:DeleteObjects' :: DeleteObjects -> Maybe Text
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"x-amz-mfa" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
mfa,
        HeaderName
"x-amz-request-payer" HeaderName -> Maybe RequestPayer -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe RequestPayer
requestPayer,
        HeaderName
"x-amz-bypass-governance-retention"
          HeaderName -> Maybe Bool -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Bool
bypassGovernanceRetention,
        HeaderName
"x-amz-expected-bucket-owner"
          HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
expectedBucketOwner
      ]

instance Core.ToPath DeleteObjects where
  toPath :: DeleteObjects -> ByteString
toPath DeleteObjects' {Maybe Bool
Maybe Text
Maybe RequestPayer
BucketName
Delete
delete' :: Delete
bucket :: BucketName
expectedBucketOwner :: Maybe Text
bypassGovernanceRetention :: Maybe Bool
requestPayer :: Maybe RequestPayer
mfa :: Maybe Text
$sel:delete':DeleteObjects' :: DeleteObjects -> Delete
$sel:bucket:DeleteObjects' :: DeleteObjects -> BucketName
$sel:expectedBucketOwner:DeleteObjects' :: DeleteObjects -> Maybe Text
$sel:bypassGovernanceRetention:DeleteObjects' :: DeleteObjects -> Maybe Bool
$sel:requestPayer:DeleteObjects' :: DeleteObjects -> Maybe RequestPayer
$sel:mfa:DeleteObjects' :: DeleteObjects -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/", BucketName -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS BucketName
bucket]

instance Core.ToQuery DeleteObjects where
  toQuery :: DeleteObjects -> QueryString
toQuery = QueryString -> DeleteObjects -> QueryString
forall a b. a -> b -> a
Prelude.const ([QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [QueryString
"delete"])

-- | /See:/ 'newDeleteObjectsResponse' smart constructor.
data DeleteObjectsResponse = DeleteObjectsResponse'
  { DeleteObjectsResponse -> Maybe RequestCharged
requestCharged :: Prelude.Maybe RequestCharged,
    -- | Container element for a successful delete. It identifies the object that
    -- was successfully deleted.
    DeleteObjectsResponse -> Maybe [DeletedObject]
deleted :: Prelude.Maybe [DeletedObject],
    -- | Container for a failed delete action that describes the object that
    -- Amazon S3 attempted to delete and the error it encountered.
    DeleteObjectsResponse -> Maybe [S3ServiceError]
errors :: Prelude.Maybe [S3ServiceError],
    -- | The response's http status code.
    DeleteObjectsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteObjectsResponse -> DeleteObjectsResponse -> Bool
(DeleteObjectsResponse -> DeleteObjectsResponse -> Bool)
-> (DeleteObjectsResponse -> DeleteObjectsResponse -> Bool)
-> Eq DeleteObjectsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteObjectsResponse -> DeleteObjectsResponse -> Bool
$c/= :: DeleteObjectsResponse -> DeleteObjectsResponse -> Bool
== :: DeleteObjectsResponse -> DeleteObjectsResponse -> Bool
$c== :: DeleteObjectsResponse -> DeleteObjectsResponse -> Bool
Prelude.Eq, ReadPrec [DeleteObjectsResponse]
ReadPrec DeleteObjectsResponse
Int -> ReadS DeleteObjectsResponse
ReadS [DeleteObjectsResponse]
(Int -> ReadS DeleteObjectsResponse)
-> ReadS [DeleteObjectsResponse]
-> ReadPrec DeleteObjectsResponse
-> ReadPrec [DeleteObjectsResponse]
-> Read DeleteObjectsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteObjectsResponse]
$creadListPrec :: ReadPrec [DeleteObjectsResponse]
readPrec :: ReadPrec DeleteObjectsResponse
$creadPrec :: ReadPrec DeleteObjectsResponse
readList :: ReadS [DeleteObjectsResponse]
$creadList :: ReadS [DeleteObjectsResponse]
readsPrec :: Int -> ReadS DeleteObjectsResponse
$creadsPrec :: Int -> ReadS DeleteObjectsResponse
Prelude.Read, Int -> DeleteObjectsResponse -> ShowS
[DeleteObjectsResponse] -> ShowS
DeleteObjectsResponse -> String
(Int -> DeleteObjectsResponse -> ShowS)
-> (DeleteObjectsResponse -> String)
-> ([DeleteObjectsResponse] -> ShowS)
-> Show DeleteObjectsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteObjectsResponse] -> ShowS
$cshowList :: [DeleteObjectsResponse] -> ShowS
show :: DeleteObjectsResponse -> String
$cshow :: DeleteObjectsResponse -> String
showsPrec :: Int -> DeleteObjectsResponse -> ShowS
$cshowsPrec :: Int -> DeleteObjectsResponse -> ShowS
Prelude.Show, (forall x. DeleteObjectsResponse -> Rep DeleteObjectsResponse x)
-> (forall x. Rep DeleteObjectsResponse x -> DeleteObjectsResponse)
-> Generic DeleteObjectsResponse
forall x. Rep DeleteObjectsResponse x -> DeleteObjectsResponse
forall x. DeleteObjectsResponse -> Rep DeleteObjectsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteObjectsResponse x -> DeleteObjectsResponse
$cfrom :: forall x. DeleteObjectsResponse -> Rep DeleteObjectsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteObjectsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'requestCharged', 'deleteObjectsResponse_requestCharged' - Undocumented member.
--
-- 'deleted', 'deleteObjectsResponse_deleted' - Container element for a successful delete. It identifies the object that
-- was successfully deleted.
--
-- 'errors', 'deleteObjectsResponse_errors' - Container for a failed delete action that describes the object that
-- Amazon S3 attempted to delete and the error it encountered.
--
-- 'httpStatus', 'deleteObjectsResponse_httpStatus' - The response's http status code.
newDeleteObjectsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteObjectsResponse
newDeleteObjectsResponse :: Int -> DeleteObjectsResponse
newDeleteObjectsResponse Int
pHttpStatus_ =
  DeleteObjectsResponse' :: Maybe RequestCharged
-> Maybe [DeletedObject]
-> Maybe [S3ServiceError]
-> Int
-> DeleteObjectsResponse
DeleteObjectsResponse'
    { $sel:requestCharged:DeleteObjectsResponse' :: Maybe RequestCharged
requestCharged =
        Maybe RequestCharged
forall a. Maybe a
Prelude.Nothing,
      $sel:deleted:DeleteObjectsResponse' :: Maybe [DeletedObject]
deleted = Maybe [DeletedObject]
forall a. Maybe a
Prelude.Nothing,
      $sel:errors:DeleteObjectsResponse' :: Maybe [S3ServiceError]
errors = Maybe [S3ServiceError]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteObjectsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
deleteObjectsResponse_requestCharged :: Lens.Lens' DeleteObjectsResponse (Prelude.Maybe RequestCharged)
deleteObjectsResponse_requestCharged :: (Maybe RequestCharged -> f (Maybe RequestCharged))
-> DeleteObjectsResponse -> f DeleteObjectsResponse
deleteObjectsResponse_requestCharged = (DeleteObjectsResponse -> Maybe RequestCharged)
-> (DeleteObjectsResponse
    -> Maybe RequestCharged -> DeleteObjectsResponse)
-> Lens
     DeleteObjectsResponse
     DeleteObjectsResponse
     (Maybe RequestCharged)
     (Maybe RequestCharged)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObjectsResponse' {Maybe RequestCharged
requestCharged :: Maybe RequestCharged
$sel:requestCharged:DeleteObjectsResponse' :: DeleteObjectsResponse -> Maybe RequestCharged
requestCharged} -> Maybe RequestCharged
requestCharged) (\s :: DeleteObjectsResponse
s@DeleteObjectsResponse' {} Maybe RequestCharged
a -> DeleteObjectsResponse
s {$sel:requestCharged:DeleteObjectsResponse' :: Maybe RequestCharged
requestCharged = Maybe RequestCharged
a} :: DeleteObjectsResponse)

-- | Container element for a successful delete. It identifies the object that
-- was successfully deleted.
deleteObjectsResponse_deleted :: Lens.Lens' DeleteObjectsResponse (Prelude.Maybe [DeletedObject])
deleteObjectsResponse_deleted :: (Maybe [DeletedObject] -> f (Maybe [DeletedObject]))
-> DeleteObjectsResponse -> f DeleteObjectsResponse
deleteObjectsResponse_deleted = (DeleteObjectsResponse -> Maybe [DeletedObject])
-> (DeleteObjectsResponse
    -> Maybe [DeletedObject] -> DeleteObjectsResponse)
-> Lens
     DeleteObjectsResponse
     DeleteObjectsResponse
     (Maybe [DeletedObject])
     (Maybe [DeletedObject])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObjectsResponse' {Maybe [DeletedObject]
deleted :: Maybe [DeletedObject]
$sel:deleted:DeleteObjectsResponse' :: DeleteObjectsResponse -> Maybe [DeletedObject]
deleted} -> Maybe [DeletedObject]
deleted) (\s :: DeleteObjectsResponse
s@DeleteObjectsResponse' {} Maybe [DeletedObject]
a -> DeleteObjectsResponse
s {$sel:deleted:DeleteObjectsResponse' :: Maybe [DeletedObject]
deleted = Maybe [DeletedObject]
a} :: DeleteObjectsResponse) ((Maybe [DeletedObject] -> f (Maybe [DeletedObject]))
 -> DeleteObjectsResponse -> f DeleteObjectsResponse)
-> ((Maybe [DeletedObject] -> f (Maybe [DeletedObject]))
    -> Maybe [DeletedObject] -> f (Maybe [DeletedObject]))
-> (Maybe [DeletedObject] -> f (Maybe [DeletedObject]))
-> DeleteObjectsResponse
-> f DeleteObjectsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DeletedObject] [DeletedObject] [DeletedObject] [DeletedObject]
-> Iso
     (Maybe [DeletedObject])
     (Maybe [DeletedObject])
     (Maybe [DeletedObject])
     (Maybe [DeletedObject])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [DeletedObject] [DeletedObject] [DeletedObject] [DeletedObject]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Container for a failed delete action that describes the object that
-- Amazon S3 attempted to delete and the error it encountered.
deleteObjectsResponse_errors :: Lens.Lens' DeleteObjectsResponse (Prelude.Maybe [S3ServiceError])
deleteObjectsResponse_errors :: (Maybe [S3ServiceError] -> f (Maybe [S3ServiceError]))
-> DeleteObjectsResponse -> f DeleteObjectsResponse
deleteObjectsResponse_errors = (DeleteObjectsResponse -> Maybe [S3ServiceError])
-> (DeleteObjectsResponse
    -> Maybe [S3ServiceError] -> DeleteObjectsResponse)
-> Lens
     DeleteObjectsResponse
     DeleteObjectsResponse
     (Maybe [S3ServiceError])
     (Maybe [S3ServiceError])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObjectsResponse' {Maybe [S3ServiceError]
errors :: Maybe [S3ServiceError]
$sel:errors:DeleteObjectsResponse' :: DeleteObjectsResponse -> Maybe [S3ServiceError]
errors} -> Maybe [S3ServiceError]
errors) (\s :: DeleteObjectsResponse
s@DeleteObjectsResponse' {} Maybe [S3ServiceError]
a -> DeleteObjectsResponse
s {$sel:errors:DeleteObjectsResponse' :: Maybe [S3ServiceError]
errors = Maybe [S3ServiceError]
a} :: DeleteObjectsResponse) ((Maybe [S3ServiceError] -> f (Maybe [S3ServiceError]))
 -> DeleteObjectsResponse -> f DeleteObjectsResponse)
-> ((Maybe [S3ServiceError] -> f (Maybe [S3ServiceError]))
    -> Maybe [S3ServiceError] -> f (Maybe [S3ServiceError]))
-> (Maybe [S3ServiceError] -> f (Maybe [S3ServiceError]))
-> DeleteObjectsResponse
-> f DeleteObjectsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [S3ServiceError] [S3ServiceError] [S3ServiceError] [S3ServiceError]
-> Iso
     (Maybe [S3ServiceError])
     (Maybe [S3ServiceError])
     (Maybe [S3ServiceError])
     (Maybe [S3ServiceError])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [S3ServiceError] [S3ServiceError] [S3ServiceError] [S3ServiceError]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
deleteObjectsResponse_httpStatus :: Lens.Lens' DeleteObjectsResponse Prelude.Int
deleteObjectsResponse_httpStatus :: (Int -> f Int) -> DeleteObjectsResponse -> f DeleteObjectsResponse
deleteObjectsResponse_httpStatus = (DeleteObjectsResponse -> Int)
-> (DeleteObjectsResponse -> Int -> DeleteObjectsResponse)
-> Lens DeleteObjectsResponse DeleteObjectsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObjectsResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteObjectsResponse' :: DeleteObjectsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DeleteObjectsResponse
s@DeleteObjectsResponse' {} Int
a -> DeleteObjectsResponse
s {$sel:httpStatus:DeleteObjectsResponse' :: Int
httpStatus = Int
a} :: DeleteObjectsResponse)

instance Prelude.NFData DeleteObjectsResponse