{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.DeletedObject
-- 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)
module Amazonka.S3.Types.DeletedObject where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal

-- | Information about the deleted object.
--
-- /See:/ 'newDeletedObject' smart constructor.
data DeletedObject = DeletedObject'
  { -- | The version ID of the deleted object.
    DeletedObject -> Maybe ObjectVersionId
versionId :: Prelude.Maybe ObjectVersionId,
    -- | Specifies whether the versioned object that was permanently deleted was
    -- (true) or was not (false) a delete marker. In a simple DELETE, this
    -- header indicates whether (true) or not (false) a delete marker was
    -- created.
    DeletedObject -> Maybe Bool
deleteMarker :: Prelude.Maybe Prelude.Bool,
    -- | The version ID of the delete marker created as a result of the DELETE
    -- operation. If you delete a specific object version, the value returned
    -- by this header is the version ID of the object version deleted.
    DeletedObject -> Maybe Text
deleteMarkerVersionId :: Prelude.Maybe Prelude.Text,
    -- | The name of the deleted object.
    DeletedObject -> Maybe ObjectKey
key :: Prelude.Maybe ObjectKey
  }
  deriving (DeletedObject -> DeletedObject -> Bool
(DeletedObject -> DeletedObject -> Bool)
-> (DeletedObject -> DeletedObject -> Bool) -> Eq DeletedObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletedObject -> DeletedObject -> Bool
$c/= :: DeletedObject -> DeletedObject -> Bool
== :: DeletedObject -> DeletedObject -> Bool
$c== :: DeletedObject -> DeletedObject -> Bool
Prelude.Eq, ReadPrec [DeletedObject]
ReadPrec DeletedObject
Int -> ReadS DeletedObject
ReadS [DeletedObject]
(Int -> ReadS DeletedObject)
-> ReadS [DeletedObject]
-> ReadPrec DeletedObject
-> ReadPrec [DeletedObject]
-> Read DeletedObject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletedObject]
$creadListPrec :: ReadPrec [DeletedObject]
readPrec :: ReadPrec DeletedObject
$creadPrec :: ReadPrec DeletedObject
readList :: ReadS [DeletedObject]
$creadList :: ReadS [DeletedObject]
readsPrec :: Int -> ReadS DeletedObject
$creadsPrec :: Int -> ReadS DeletedObject
Prelude.Read, Int -> DeletedObject -> ShowS
[DeletedObject] -> ShowS
DeletedObject -> String
(Int -> DeletedObject -> ShowS)
-> (DeletedObject -> String)
-> ([DeletedObject] -> ShowS)
-> Show DeletedObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletedObject] -> ShowS
$cshowList :: [DeletedObject] -> ShowS
show :: DeletedObject -> String
$cshow :: DeletedObject -> String
showsPrec :: Int -> DeletedObject -> ShowS
$cshowsPrec :: Int -> DeletedObject -> ShowS
Prelude.Show, (forall x. DeletedObject -> Rep DeletedObject x)
-> (forall x. Rep DeletedObject x -> DeletedObject)
-> Generic DeletedObject
forall x. Rep DeletedObject x -> DeletedObject
forall x. DeletedObject -> Rep DeletedObject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeletedObject x -> DeletedObject
$cfrom :: forall x. DeletedObject -> Rep DeletedObject x
Prelude.Generic)

-- |
-- Create a value of 'DeletedObject' 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', 'deletedObject_versionId' - The version ID of the deleted object.
--
-- 'deleteMarker', 'deletedObject_deleteMarker' - Specifies whether the versioned object that was permanently deleted was
-- (true) or was not (false) a delete marker. In a simple DELETE, this
-- header indicates whether (true) or not (false) a delete marker was
-- created.
--
-- 'deleteMarkerVersionId', 'deletedObject_deleteMarkerVersionId' - The version ID of the delete marker created as a result of the DELETE
-- operation. If you delete a specific object version, the value returned
-- by this header is the version ID of the object version deleted.
--
-- 'key', 'deletedObject_key' - The name of the deleted object.
newDeletedObject ::
  DeletedObject
newDeletedObject :: DeletedObject
newDeletedObject =
  DeletedObject' :: Maybe ObjectVersionId
-> Maybe Bool -> Maybe Text -> Maybe ObjectKey -> DeletedObject
DeletedObject'
    { $sel:versionId:DeletedObject' :: Maybe ObjectVersionId
versionId = Maybe ObjectVersionId
forall a. Maybe a
Prelude.Nothing,
      $sel:deleteMarker:DeletedObject' :: Maybe Bool
deleteMarker = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:deleteMarkerVersionId:DeletedObject' :: Maybe Text
deleteMarkerVersionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:DeletedObject' :: Maybe ObjectKey
key = Maybe ObjectKey
forall a. Maybe a
Prelude.Nothing
    }

-- | The version ID of the deleted object.
deletedObject_versionId :: Lens.Lens' DeletedObject (Prelude.Maybe ObjectVersionId)
deletedObject_versionId :: (Maybe ObjectVersionId -> f (Maybe ObjectVersionId))
-> DeletedObject -> f DeletedObject
deletedObject_versionId = (DeletedObject -> Maybe ObjectVersionId)
-> (DeletedObject -> Maybe ObjectVersionId -> DeletedObject)
-> Lens
     DeletedObject
     DeletedObject
     (Maybe ObjectVersionId)
     (Maybe ObjectVersionId)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletedObject' {Maybe ObjectVersionId
versionId :: Maybe ObjectVersionId
$sel:versionId:DeletedObject' :: DeletedObject -> Maybe ObjectVersionId
versionId} -> Maybe ObjectVersionId
versionId) (\s :: DeletedObject
s@DeletedObject' {} Maybe ObjectVersionId
a -> DeletedObject
s {$sel:versionId:DeletedObject' :: Maybe ObjectVersionId
versionId = Maybe ObjectVersionId
a} :: DeletedObject)

-- | Specifies whether the versioned object that was permanently deleted was
-- (true) or was not (false) a delete marker. In a simple DELETE, this
-- header indicates whether (true) or not (false) a delete marker was
-- created.
deletedObject_deleteMarker :: Lens.Lens' DeletedObject (Prelude.Maybe Prelude.Bool)
deletedObject_deleteMarker :: (Maybe Bool -> f (Maybe Bool)) -> DeletedObject -> f DeletedObject
deletedObject_deleteMarker = (DeletedObject -> Maybe Bool)
-> (DeletedObject -> Maybe Bool -> DeletedObject)
-> Lens DeletedObject DeletedObject (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletedObject' {Maybe Bool
deleteMarker :: Maybe Bool
$sel:deleteMarker:DeletedObject' :: DeletedObject -> Maybe Bool
deleteMarker} -> Maybe Bool
deleteMarker) (\s :: DeletedObject
s@DeletedObject' {} Maybe Bool
a -> DeletedObject
s {$sel:deleteMarker:DeletedObject' :: Maybe Bool
deleteMarker = Maybe Bool
a} :: DeletedObject)

-- | The version ID of the delete marker created as a result of the DELETE
-- operation. If you delete a specific object version, the value returned
-- by this header is the version ID of the object version deleted.
deletedObject_deleteMarkerVersionId :: Lens.Lens' DeletedObject (Prelude.Maybe Prelude.Text)
deletedObject_deleteMarkerVersionId :: (Maybe Text -> f (Maybe Text)) -> DeletedObject -> f DeletedObject
deletedObject_deleteMarkerVersionId = (DeletedObject -> Maybe Text)
-> (DeletedObject -> Maybe Text -> DeletedObject)
-> Lens DeletedObject DeletedObject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletedObject' {Maybe Text
deleteMarkerVersionId :: Maybe Text
$sel:deleteMarkerVersionId:DeletedObject' :: DeletedObject -> Maybe Text
deleteMarkerVersionId} -> Maybe Text
deleteMarkerVersionId) (\s :: DeletedObject
s@DeletedObject' {} Maybe Text
a -> DeletedObject
s {$sel:deleteMarkerVersionId:DeletedObject' :: Maybe Text
deleteMarkerVersionId = Maybe Text
a} :: DeletedObject)

-- | The name of the deleted object.
deletedObject_key :: Lens.Lens' DeletedObject (Prelude.Maybe ObjectKey)
deletedObject_key :: (Maybe ObjectKey -> f (Maybe ObjectKey))
-> DeletedObject -> f DeletedObject
deletedObject_key = (DeletedObject -> Maybe ObjectKey)
-> (DeletedObject -> Maybe ObjectKey -> DeletedObject)
-> Lens
     DeletedObject DeletedObject (Maybe ObjectKey) (Maybe ObjectKey)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletedObject' {Maybe ObjectKey
key :: Maybe ObjectKey
$sel:key:DeletedObject' :: DeletedObject -> Maybe ObjectKey
key} -> Maybe ObjectKey
key) (\s :: DeletedObject
s@DeletedObject' {} Maybe ObjectKey
a -> DeletedObject
s {$sel:key:DeletedObject' :: Maybe ObjectKey
key = Maybe ObjectKey
a} :: DeletedObject)

instance Core.FromXML DeletedObject where
  parseXML :: [Node] -> Either String DeletedObject
parseXML [Node]
x =
    Maybe ObjectVersionId
-> Maybe Bool -> Maybe Text -> Maybe ObjectKey -> DeletedObject
DeletedObject'
      (Maybe ObjectVersionId
 -> Maybe Bool -> Maybe Text -> Maybe ObjectKey -> DeletedObject)
-> Either String (Maybe ObjectVersionId)
-> Either
     String
     (Maybe Bool -> Maybe Text -> Maybe ObjectKey -> DeletedObject)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe ObjectVersionId)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"VersionId")
      Either
  String
  (Maybe Bool -> Maybe Text -> Maybe ObjectKey -> DeletedObject)
-> Either String (Maybe Bool)
-> Either String (Maybe Text -> Maybe ObjectKey -> DeletedObject)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DeleteMarker")
      Either String (Maybe Text -> Maybe ObjectKey -> DeletedObject)
-> Either String (Maybe Text)
-> Either String (Maybe ObjectKey -> DeletedObject)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DeleteMarkerVersionId")
      Either String (Maybe ObjectKey -> DeletedObject)
-> Either String (Maybe ObjectKey) -> Either String DeletedObject
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ObjectKey)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Key")

instance Prelude.Hashable DeletedObject

instance Prelude.NFData DeletedObject