{-# 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.DeleteObject
-- 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)
--
-- Removes the null version (if there is one) of an object and inserts a
-- delete marker, which becomes the latest version of the object. If there
-- isn\'t a null version, Amazon S3 does not remove any objects but will
-- still respond that the command was successful.
--
-- To remove a specific version, you must be the bucket owner and you must
-- use the version Id subresource. Using this subresource permanently
-- deletes the version. If the object deleted is a delete marker, Amazon S3
-- sets the response header, @x-amz-delete-marker@, to true.
--
-- If the object you want to delete is in a bucket where the bucket
-- versioning configuration is MFA Delete enabled, you must include the
-- @x-amz-mfa@ request header in the DELETE @versionId@ request. Requests
-- that include @x-amz-mfa@ must use HTTPS.
--
-- For more information about MFA Delete, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMFADelete.html Using MFA Delete>.
-- To see sample requests that use versioning, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html#ExampleVersionObjectDelete Sample Request>.
--
-- You can delete objects by explicitly calling DELETE Object or configure
-- its lifecycle
-- (<https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycle.html PutBucketLifecycle>)
-- to enable Amazon S3 to remove them for you. If you want to block users
-- or accounts from removing or deleting objects from your bucket, you must
-- deny them the @s3:DeleteObject@, @s3:DeleteObjectVersion@, and
-- @s3:PutLifeCycleConfiguration@ actions.
--
-- The following action is related to @DeleteObject@:
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html PutObject>
module Amazonka.S3.DeleteObject
  ( -- * Creating a Request
    DeleteObject (..),
    newDeleteObject,

    -- * Request Lenses
    deleteObject_versionId,
    deleteObject_mfa,
    deleteObject_requestPayer,
    deleteObject_bypassGovernanceRetention,
    deleteObject_expectedBucketOwner,
    deleteObject_bucket,
    deleteObject_key,

    -- * Destructuring the Response
    DeleteObjectResponse (..),
    newDeleteObjectResponse,

    -- * Response Lenses
    deleteObjectResponse_requestCharged,
    deleteObjectResponse_versionId,
    deleteObjectResponse_deleteMarker,
    deleteObjectResponse_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:/ 'newDeleteObject' smart constructor.
data DeleteObject = DeleteObject'
  { -- | VersionId used to reference a specific version of the object.
    DeleteObject -> Maybe ObjectVersionId
versionId :: Prelude.Maybe ObjectVersionId,
    -- | 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.
    DeleteObject -> Maybe Text
mfa :: Prelude.Maybe Prelude.Text,
    DeleteObject -> Maybe RequestPayer
requestPayer :: Prelude.Maybe RequestPayer,
    -- | Indicates whether S3 Object Lock should bypass Governance-mode
    -- restrictions to process this operation. To use this header, you must
    -- have the @s3:PutBucketPublicAccessBlock@ permission.
    DeleteObject -> 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.
    DeleteObject -> Maybe Text
expectedBucketOwner :: Prelude.Maybe Prelude.Text,
    -- | The bucket name of the bucket containing the object.
    --
    -- 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/.
    DeleteObject -> BucketName
bucket :: BucketName,
    -- | Key name of the object to delete.
    DeleteObject -> ObjectKey
key :: ObjectKey
  }
  deriving (DeleteObject -> DeleteObject -> Bool
(DeleteObject -> DeleteObject -> Bool)
-> (DeleteObject -> DeleteObject -> Bool) -> Eq DeleteObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteObject -> DeleteObject -> Bool
$c/= :: DeleteObject -> DeleteObject -> Bool
== :: DeleteObject -> DeleteObject -> Bool
$c== :: DeleteObject -> DeleteObject -> Bool
Prelude.Eq, ReadPrec [DeleteObject]
ReadPrec DeleteObject
Int -> ReadS DeleteObject
ReadS [DeleteObject]
(Int -> ReadS DeleteObject)
-> ReadS [DeleteObject]
-> ReadPrec DeleteObject
-> ReadPrec [DeleteObject]
-> Read DeleteObject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteObject]
$creadListPrec :: ReadPrec [DeleteObject]
readPrec :: ReadPrec DeleteObject
$creadPrec :: ReadPrec DeleteObject
readList :: ReadS [DeleteObject]
$creadList :: ReadS [DeleteObject]
readsPrec :: Int -> ReadS DeleteObject
$creadsPrec :: Int -> ReadS DeleteObject
Prelude.Read, Int -> DeleteObject -> ShowS
[DeleteObject] -> ShowS
DeleteObject -> String
(Int -> DeleteObject -> ShowS)
-> (DeleteObject -> String)
-> ([DeleteObject] -> ShowS)
-> Show DeleteObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteObject] -> ShowS
$cshowList :: [DeleteObject] -> ShowS
show :: DeleteObject -> String
$cshow :: DeleteObject -> String
showsPrec :: Int -> DeleteObject -> ShowS
$cshowsPrec :: Int -> DeleteObject -> ShowS
Prelude.Show, (forall x. DeleteObject -> Rep DeleteObject x)
-> (forall x. Rep DeleteObject x -> DeleteObject)
-> Generic DeleteObject
forall x. Rep DeleteObject x -> DeleteObject
forall x. DeleteObject -> Rep DeleteObject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteObject x -> DeleteObject
$cfrom :: forall x. DeleteObject -> Rep DeleteObject x
Prelude.Generic)

-- |
-- Create a value of 'DeleteObject' 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:
--
-- 'versionId', 'deleteObject_versionId' - VersionId used to reference a specific version of the object.
--
-- 'mfa', 'deleteObject_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', 'deleteObject_requestPayer' - Undocumented member.
--
-- 'bypassGovernanceRetention', 'deleteObject_bypassGovernanceRetention' - Indicates whether S3 Object Lock should bypass Governance-mode
-- restrictions to process this operation. To use this header, you must
-- have the @s3:PutBucketPublicAccessBlock@ permission.
--
-- 'expectedBucketOwner', 'deleteObject_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', 'deleteObject_bucket' - The bucket name of the bucket containing the object.
--
-- 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/.
--
-- 'key', 'deleteObject_key' - Key name of the object to delete.
newDeleteObject ::
  -- | 'bucket'
  BucketName ->
  -- | 'key'
  ObjectKey ->
  DeleteObject
newDeleteObject :: BucketName -> ObjectKey -> DeleteObject
newDeleteObject BucketName
pBucket_ ObjectKey
pKey_ =
  DeleteObject' :: Maybe ObjectVersionId
-> Maybe Text
-> Maybe RequestPayer
-> Maybe Bool
-> Maybe Text
-> BucketName
-> ObjectKey
-> DeleteObject
DeleteObject'
    { $sel:versionId:DeleteObject' :: Maybe ObjectVersionId
versionId = Maybe ObjectVersionId
forall a. Maybe a
Prelude.Nothing,
      $sel:mfa:DeleteObject' :: Maybe Text
mfa = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:requestPayer:DeleteObject' :: Maybe RequestPayer
requestPayer = Maybe RequestPayer
forall a. Maybe a
Prelude.Nothing,
      $sel:bypassGovernanceRetention:DeleteObject' :: Maybe Bool
bypassGovernanceRetention = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:expectedBucketOwner:DeleteObject' :: Maybe Text
expectedBucketOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:DeleteObject' :: BucketName
bucket = BucketName
pBucket_,
      $sel:key:DeleteObject' :: ObjectKey
key = ObjectKey
pKey_
    }

-- | VersionId used to reference a specific version of the object.
deleteObject_versionId :: Lens.Lens' DeleteObject (Prelude.Maybe ObjectVersionId)
deleteObject_versionId :: (Maybe ObjectVersionId -> f (Maybe ObjectVersionId))
-> DeleteObject -> f DeleteObject
deleteObject_versionId = (DeleteObject -> Maybe ObjectVersionId)
-> (DeleteObject -> Maybe ObjectVersionId -> DeleteObject)
-> Lens
     DeleteObject
     DeleteObject
     (Maybe ObjectVersionId)
     (Maybe ObjectVersionId)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObject' {Maybe ObjectVersionId
versionId :: Maybe ObjectVersionId
$sel:versionId:DeleteObject' :: DeleteObject -> Maybe ObjectVersionId
versionId} -> Maybe ObjectVersionId
versionId) (\s :: DeleteObject
s@DeleteObject' {} Maybe ObjectVersionId
a -> DeleteObject
s {$sel:versionId:DeleteObject' :: Maybe ObjectVersionId
versionId = Maybe ObjectVersionId
a} :: DeleteObject)

-- | 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.
deleteObject_mfa :: Lens.Lens' DeleteObject (Prelude.Maybe Prelude.Text)
deleteObject_mfa :: (Maybe Text -> f (Maybe Text)) -> DeleteObject -> f DeleteObject
deleteObject_mfa = (DeleteObject -> Maybe Text)
-> (DeleteObject -> Maybe Text -> DeleteObject)
-> Lens DeleteObject DeleteObject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObject' {Maybe Text
mfa :: Maybe Text
$sel:mfa:DeleteObject' :: DeleteObject -> Maybe Text
mfa} -> Maybe Text
mfa) (\s :: DeleteObject
s@DeleteObject' {} Maybe Text
a -> DeleteObject
s {$sel:mfa:DeleteObject' :: Maybe Text
mfa = Maybe Text
a} :: DeleteObject)

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

-- | Indicates whether S3 Object Lock should bypass Governance-mode
-- restrictions to process this operation. To use this header, you must
-- have the @s3:PutBucketPublicAccessBlock@ permission.
deleteObject_bypassGovernanceRetention :: Lens.Lens' DeleteObject (Prelude.Maybe Prelude.Bool)
deleteObject_bypassGovernanceRetention :: (Maybe Bool -> f (Maybe Bool)) -> DeleteObject -> f DeleteObject
deleteObject_bypassGovernanceRetention = (DeleteObject -> Maybe Bool)
-> (DeleteObject -> Maybe Bool -> DeleteObject)
-> Lens DeleteObject DeleteObject (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObject' {Maybe Bool
bypassGovernanceRetention :: Maybe Bool
$sel:bypassGovernanceRetention:DeleteObject' :: DeleteObject -> Maybe Bool
bypassGovernanceRetention} -> Maybe Bool
bypassGovernanceRetention) (\s :: DeleteObject
s@DeleteObject' {} Maybe Bool
a -> DeleteObject
s {$sel:bypassGovernanceRetention:DeleteObject' :: Maybe Bool
bypassGovernanceRetention = Maybe Bool
a} :: DeleteObject)

-- | 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.
deleteObject_expectedBucketOwner :: Lens.Lens' DeleteObject (Prelude.Maybe Prelude.Text)
deleteObject_expectedBucketOwner :: (Maybe Text -> f (Maybe Text)) -> DeleteObject -> f DeleteObject
deleteObject_expectedBucketOwner = (DeleteObject -> Maybe Text)
-> (DeleteObject -> Maybe Text -> DeleteObject)
-> Lens DeleteObject DeleteObject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObject' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:DeleteObject' :: DeleteObject -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: DeleteObject
s@DeleteObject' {} Maybe Text
a -> DeleteObject
s {$sel:expectedBucketOwner:DeleteObject' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: DeleteObject)

-- | The bucket name of the bucket containing the object.
--
-- 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/.
deleteObject_bucket :: Lens.Lens' DeleteObject BucketName
deleteObject_bucket :: (BucketName -> f BucketName) -> DeleteObject -> f DeleteObject
deleteObject_bucket = (DeleteObject -> BucketName)
-> (DeleteObject -> BucketName -> DeleteObject)
-> Lens DeleteObject DeleteObject BucketName BucketName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObject' {BucketName
bucket :: BucketName
$sel:bucket:DeleteObject' :: DeleteObject -> BucketName
bucket} -> BucketName
bucket) (\s :: DeleteObject
s@DeleteObject' {} BucketName
a -> DeleteObject
s {$sel:bucket:DeleteObject' :: BucketName
bucket = BucketName
a} :: DeleteObject)

-- | Key name of the object to delete.
deleteObject_key :: Lens.Lens' DeleteObject ObjectKey
deleteObject_key :: (ObjectKey -> f ObjectKey) -> DeleteObject -> f DeleteObject
deleteObject_key = (DeleteObject -> ObjectKey)
-> (DeleteObject -> ObjectKey -> DeleteObject)
-> Lens DeleteObject DeleteObject ObjectKey ObjectKey
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObject' {ObjectKey
key :: ObjectKey
$sel:key:DeleteObject' :: DeleteObject -> ObjectKey
key} -> ObjectKey
key) (\s :: DeleteObject
s@DeleteObject' {} ObjectKey
a -> DeleteObject
s {$sel:key:DeleteObject' :: ObjectKey
key = ObjectKey
a} :: DeleteObject)

instance Core.AWSRequest DeleteObject where
  type AWSResponse DeleteObject = DeleteObjectResponse
  request :: DeleteObject -> Request DeleteObject
request =
    Request DeleteObject -> Request DeleteObject
forall a. Request a -> Request a
Request.s3vhost
      (Request DeleteObject -> Request DeleteObject)
-> (DeleteObject -> Request DeleteObject)
-> DeleteObject
-> Request DeleteObject
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> DeleteObject -> Request DeleteObject
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteObject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteObject)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteObject))
-> Logger
-> Service
-> Proxy DeleteObject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteObject)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Maybe RequestCharged
-> Maybe ObjectVersionId
-> Maybe Bool
-> Int
-> DeleteObjectResponse
DeleteObjectResponse'
            (Maybe RequestCharged
 -> Maybe ObjectVersionId
 -> Maybe Bool
 -> Int
 -> DeleteObjectResponse)
-> Either String (Maybe RequestCharged)
-> Either
     String
     (Maybe ObjectVersionId
      -> Maybe Bool -> Int -> DeleteObjectResponse)
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 ObjectVersionId
   -> Maybe Bool -> Int -> DeleteObjectResponse)
-> Either String (Maybe ObjectVersionId)
-> Either String (Maybe Bool -> Int -> DeleteObjectResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h ResponseHeaders
-> HeaderName -> Either String (Maybe ObjectVersionId)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"x-amz-version-id")
            Either String (Maybe Bool -> Int -> DeleteObjectResponse)
-> Either String (Maybe Bool)
-> Either String (Int -> DeleteObjectResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Bool)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"x-amz-delete-marker")
            Either String (Int -> DeleteObjectResponse)
-> Either String Int -> Either String DeleteObjectResponse
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 DeleteObject

instance Prelude.NFData DeleteObject

instance Core.ToHeaders DeleteObject where
  toHeaders :: DeleteObject -> ResponseHeaders
toHeaders DeleteObject' {Maybe Bool
Maybe Text
Maybe ObjectVersionId
Maybe RequestPayer
ObjectKey
BucketName
key :: ObjectKey
bucket :: BucketName
expectedBucketOwner :: Maybe Text
bypassGovernanceRetention :: Maybe Bool
requestPayer :: Maybe RequestPayer
mfa :: Maybe Text
versionId :: Maybe ObjectVersionId
$sel:key:DeleteObject' :: DeleteObject -> ObjectKey
$sel:bucket:DeleteObject' :: DeleteObject -> BucketName
$sel:expectedBucketOwner:DeleteObject' :: DeleteObject -> Maybe Text
$sel:bypassGovernanceRetention:DeleteObject' :: DeleteObject -> Maybe Bool
$sel:requestPayer:DeleteObject' :: DeleteObject -> Maybe RequestPayer
$sel:mfa:DeleteObject' :: DeleteObject -> Maybe Text
$sel:versionId:DeleteObject' :: DeleteObject -> Maybe ObjectVersionId
..} =
    [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 DeleteObject where
  toPath :: DeleteObject -> ByteString
toPath DeleteObject' {Maybe Bool
Maybe Text
Maybe ObjectVersionId
Maybe RequestPayer
ObjectKey
BucketName
key :: ObjectKey
bucket :: BucketName
expectedBucketOwner :: Maybe Text
bypassGovernanceRetention :: Maybe Bool
requestPayer :: Maybe RequestPayer
mfa :: Maybe Text
versionId :: Maybe ObjectVersionId
$sel:key:DeleteObject' :: DeleteObject -> ObjectKey
$sel:bucket:DeleteObject' :: DeleteObject -> BucketName
$sel:expectedBucketOwner:DeleteObject' :: DeleteObject -> Maybe Text
$sel:bypassGovernanceRetention:DeleteObject' :: DeleteObject -> Maybe Bool
$sel:requestPayer:DeleteObject' :: DeleteObject -> Maybe RequestPayer
$sel:mfa:DeleteObject' :: DeleteObject -> Maybe Text
$sel:versionId:DeleteObject' :: DeleteObject -> Maybe ObjectVersionId
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/", BucketName -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS BucketName
bucket, ByteString
"/", ObjectKey -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS ObjectKey
key]

instance Core.ToQuery DeleteObject where
  toQuery :: DeleteObject -> QueryString
toQuery DeleteObject' {Maybe Bool
Maybe Text
Maybe ObjectVersionId
Maybe RequestPayer
ObjectKey
BucketName
key :: ObjectKey
bucket :: BucketName
expectedBucketOwner :: Maybe Text
bypassGovernanceRetention :: Maybe Bool
requestPayer :: Maybe RequestPayer
mfa :: Maybe Text
versionId :: Maybe ObjectVersionId
$sel:key:DeleteObject' :: DeleteObject -> ObjectKey
$sel:bucket:DeleteObject' :: DeleteObject -> BucketName
$sel:expectedBucketOwner:DeleteObject' :: DeleteObject -> Maybe Text
$sel:bypassGovernanceRetention:DeleteObject' :: DeleteObject -> Maybe Bool
$sel:requestPayer:DeleteObject' :: DeleteObject -> Maybe RequestPayer
$sel:mfa:DeleteObject' :: DeleteObject -> Maybe Text
$sel:versionId:DeleteObject' :: DeleteObject -> Maybe ObjectVersionId
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"versionId" ByteString -> Maybe ObjectVersionId -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe ObjectVersionId
versionId]

-- | /See:/ 'newDeleteObjectResponse' smart constructor.
data DeleteObjectResponse = DeleteObjectResponse'
  { DeleteObjectResponse -> Maybe RequestCharged
requestCharged :: Prelude.Maybe RequestCharged,
    -- | Returns the version ID of the delete marker created as a result of the
    -- DELETE operation.
    DeleteObjectResponse -> Maybe ObjectVersionId
versionId :: Prelude.Maybe ObjectVersionId,
    -- | Specifies whether the versioned object that was permanently deleted was
    -- (true) or was not (false) a delete marker.
    DeleteObjectResponse -> Maybe Bool
deleteMarker :: Prelude.Maybe Prelude.Bool,
    -- | The response's http status code.
    DeleteObjectResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteObjectResponse -> DeleteObjectResponse -> Bool
(DeleteObjectResponse -> DeleteObjectResponse -> Bool)
-> (DeleteObjectResponse -> DeleteObjectResponse -> Bool)
-> Eq DeleteObjectResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteObjectResponse -> DeleteObjectResponse -> Bool
$c/= :: DeleteObjectResponse -> DeleteObjectResponse -> Bool
== :: DeleteObjectResponse -> DeleteObjectResponse -> Bool
$c== :: DeleteObjectResponse -> DeleteObjectResponse -> Bool
Prelude.Eq, ReadPrec [DeleteObjectResponse]
ReadPrec DeleteObjectResponse
Int -> ReadS DeleteObjectResponse
ReadS [DeleteObjectResponse]
(Int -> ReadS DeleteObjectResponse)
-> ReadS [DeleteObjectResponse]
-> ReadPrec DeleteObjectResponse
-> ReadPrec [DeleteObjectResponse]
-> Read DeleteObjectResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteObjectResponse]
$creadListPrec :: ReadPrec [DeleteObjectResponse]
readPrec :: ReadPrec DeleteObjectResponse
$creadPrec :: ReadPrec DeleteObjectResponse
readList :: ReadS [DeleteObjectResponse]
$creadList :: ReadS [DeleteObjectResponse]
readsPrec :: Int -> ReadS DeleteObjectResponse
$creadsPrec :: Int -> ReadS DeleteObjectResponse
Prelude.Read, Int -> DeleteObjectResponse -> ShowS
[DeleteObjectResponse] -> ShowS
DeleteObjectResponse -> String
(Int -> DeleteObjectResponse -> ShowS)
-> (DeleteObjectResponse -> String)
-> ([DeleteObjectResponse] -> ShowS)
-> Show DeleteObjectResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteObjectResponse] -> ShowS
$cshowList :: [DeleteObjectResponse] -> ShowS
show :: DeleteObjectResponse -> String
$cshow :: DeleteObjectResponse -> String
showsPrec :: Int -> DeleteObjectResponse -> ShowS
$cshowsPrec :: Int -> DeleteObjectResponse -> ShowS
Prelude.Show, (forall x. DeleteObjectResponse -> Rep DeleteObjectResponse x)
-> (forall x. Rep DeleteObjectResponse x -> DeleteObjectResponse)
-> Generic DeleteObjectResponse
forall x. Rep DeleteObjectResponse x -> DeleteObjectResponse
forall x. DeleteObjectResponse -> Rep DeleteObjectResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteObjectResponse x -> DeleteObjectResponse
$cfrom :: forall x. DeleteObjectResponse -> Rep DeleteObjectResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteObjectResponse' 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', 'deleteObjectResponse_requestCharged' - Undocumented member.
--
-- 'versionId', 'deleteObjectResponse_versionId' - Returns the version ID of the delete marker created as a result of the
-- DELETE operation.
--
-- 'deleteMarker', 'deleteObjectResponse_deleteMarker' - Specifies whether the versioned object that was permanently deleted was
-- (true) or was not (false) a delete marker.
--
-- 'httpStatus', 'deleteObjectResponse_httpStatus' - The response's http status code.
newDeleteObjectResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteObjectResponse
newDeleteObjectResponse :: Int -> DeleteObjectResponse
newDeleteObjectResponse Int
pHttpStatus_ =
  DeleteObjectResponse' :: Maybe RequestCharged
-> Maybe ObjectVersionId
-> Maybe Bool
-> Int
-> DeleteObjectResponse
DeleteObjectResponse'
    { $sel:requestCharged:DeleteObjectResponse' :: Maybe RequestCharged
requestCharged =
        Maybe RequestCharged
forall a. Maybe a
Prelude.Nothing,
      $sel:versionId:DeleteObjectResponse' :: Maybe ObjectVersionId
versionId = Maybe ObjectVersionId
forall a. Maybe a
Prelude.Nothing,
      $sel:deleteMarker:DeleteObjectResponse' :: Maybe Bool
deleteMarker = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteObjectResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | Returns the version ID of the delete marker created as a result of the
-- DELETE operation.
deleteObjectResponse_versionId :: Lens.Lens' DeleteObjectResponse (Prelude.Maybe ObjectVersionId)
deleteObjectResponse_versionId :: (Maybe ObjectVersionId -> f (Maybe ObjectVersionId))
-> DeleteObjectResponse -> f DeleteObjectResponse
deleteObjectResponse_versionId = (DeleteObjectResponse -> Maybe ObjectVersionId)
-> (DeleteObjectResponse
    -> Maybe ObjectVersionId -> DeleteObjectResponse)
-> Lens
     DeleteObjectResponse
     DeleteObjectResponse
     (Maybe ObjectVersionId)
     (Maybe ObjectVersionId)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObjectResponse' {Maybe ObjectVersionId
versionId :: Maybe ObjectVersionId
$sel:versionId:DeleteObjectResponse' :: DeleteObjectResponse -> Maybe ObjectVersionId
versionId} -> Maybe ObjectVersionId
versionId) (\s :: DeleteObjectResponse
s@DeleteObjectResponse' {} Maybe ObjectVersionId
a -> DeleteObjectResponse
s {$sel:versionId:DeleteObjectResponse' :: Maybe ObjectVersionId
versionId = Maybe ObjectVersionId
a} :: DeleteObjectResponse)

-- | Specifies whether the versioned object that was permanently deleted was
-- (true) or was not (false) a delete marker.
deleteObjectResponse_deleteMarker :: Lens.Lens' DeleteObjectResponse (Prelude.Maybe Prelude.Bool)
deleteObjectResponse_deleteMarker :: (Maybe Bool -> f (Maybe Bool))
-> DeleteObjectResponse -> f DeleteObjectResponse
deleteObjectResponse_deleteMarker = (DeleteObjectResponse -> Maybe Bool)
-> (DeleteObjectResponse -> Maybe Bool -> DeleteObjectResponse)
-> Lens
     DeleteObjectResponse DeleteObjectResponse (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObjectResponse' {Maybe Bool
deleteMarker :: Maybe Bool
$sel:deleteMarker:DeleteObjectResponse' :: DeleteObjectResponse -> Maybe Bool
deleteMarker} -> Maybe Bool
deleteMarker) (\s :: DeleteObjectResponse
s@DeleteObjectResponse' {} Maybe Bool
a -> DeleteObjectResponse
s {$sel:deleteMarker:DeleteObjectResponse' :: Maybe Bool
deleteMarker = Maybe Bool
a} :: DeleteObjectResponse)

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

instance Prelude.NFData DeleteObjectResponse