{-# 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.ObjectLockRetention
-- 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.ObjectLockRetention where

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

-- | A Retention configuration for an object.
--
-- /See:/ 'newObjectLockRetention' smart constructor.
data ObjectLockRetention = ObjectLockRetention'
  { -- | Indicates the Retention mode for the specified object.
    ObjectLockRetention -> Maybe ObjectLockRetentionMode
mode :: Prelude.Maybe ObjectLockRetentionMode,
    -- | The date on which this Object Lock Retention will expire.
    ObjectLockRetention -> Maybe ISO8601
retainUntilDate :: Prelude.Maybe Core.ISO8601
  }
  deriving (ObjectLockRetention -> ObjectLockRetention -> Bool
(ObjectLockRetention -> ObjectLockRetention -> Bool)
-> (ObjectLockRetention -> ObjectLockRetention -> Bool)
-> Eq ObjectLockRetention
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ObjectLockRetention -> ObjectLockRetention -> Bool
$c/= :: ObjectLockRetention -> ObjectLockRetention -> Bool
== :: ObjectLockRetention -> ObjectLockRetention -> Bool
$c== :: ObjectLockRetention -> ObjectLockRetention -> Bool
Prelude.Eq, ReadPrec [ObjectLockRetention]
ReadPrec ObjectLockRetention
Int -> ReadS ObjectLockRetention
ReadS [ObjectLockRetention]
(Int -> ReadS ObjectLockRetention)
-> ReadS [ObjectLockRetention]
-> ReadPrec ObjectLockRetention
-> ReadPrec [ObjectLockRetention]
-> Read ObjectLockRetention
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ObjectLockRetention]
$creadListPrec :: ReadPrec [ObjectLockRetention]
readPrec :: ReadPrec ObjectLockRetention
$creadPrec :: ReadPrec ObjectLockRetention
readList :: ReadS [ObjectLockRetention]
$creadList :: ReadS [ObjectLockRetention]
readsPrec :: Int -> ReadS ObjectLockRetention
$creadsPrec :: Int -> ReadS ObjectLockRetention
Prelude.Read, Int -> ObjectLockRetention -> ShowS
[ObjectLockRetention] -> ShowS
ObjectLockRetention -> String
(Int -> ObjectLockRetention -> ShowS)
-> (ObjectLockRetention -> String)
-> ([ObjectLockRetention] -> ShowS)
-> Show ObjectLockRetention
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ObjectLockRetention] -> ShowS
$cshowList :: [ObjectLockRetention] -> ShowS
show :: ObjectLockRetention -> String
$cshow :: ObjectLockRetention -> String
showsPrec :: Int -> ObjectLockRetention -> ShowS
$cshowsPrec :: Int -> ObjectLockRetention -> ShowS
Prelude.Show, (forall x. ObjectLockRetention -> Rep ObjectLockRetention x)
-> (forall x. Rep ObjectLockRetention x -> ObjectLockRetention)
-> Generic ObjectLockRetention
forall x. Rep ObjectLockRetention x -> ObjectLockRetention
forall x. ObjectLockRetention -> Rep ObjectLockRetention x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ObjectLockRetention x -> ObjectLockRetention
$cfrom :: forall x. ObjectLockRetention -> Rep ObjectLockRetention x
Prelude.Generic)

-- |
-- Create a value of 'ObjectLockRetention' 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:
--
-- 'mode', 'objectLockRetention_mode' - Indicates the Retention mode for the specified object.
--
-- 'retainUntilDate', 'objectLockRetention_retainUntilDate' - The date on which this Object Lock Retention will expire.
newObjectLockRetention ::
  ObjectLockRetention
newObjectLockRetention :: ObjectLockRetention
newObjectLockRetention =
  ObjectLockRetention' :: Maybe ObjectLockRetentionMode
-> Maybe ISO8601 -> ObjectLockRetention
ObjectLockRetention'
    { $sel:mode:ObjectLockRetention' :: Maybe ObjectLockRetentionMode
mode = Maybe ObjectLockRetentionMode
forall a. Maybe a
Prelude.Nothing,
      $sel:retainUntilDate:ObjectLockRetention' :: Maybe ISO8601
retainUntilDate = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates the Retention mode for the specified object.
objectLockRetention_mode :: Lens.Lens' ObjectLockRetention (Prelude.Maybe ObjectLockRetentionMode)
objectLockRetention_mode :: (Maybe ObjectLockRetentionMode
 -> f (Maybe ObjectLockRetentionMode))
-> ObjectLockRetention -> f ObjectLockRetention
objectLockRetention_mode = (ObjectLockRetention -> Maybe ObjectLockRetentionMode)
-> (ObjectLockRetention
    -> Maybe ObjectLockRetentionMode -> ObjectLockRetention)
-> Lens
     ObjectLockRetention
     ObjectLockRetention
     (Maybe ObjectLockRetentionMode)
     (Maybe ObjectLockRetentionMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectLockRetention' {Maybe ObjectLockRetentionMode
mode :: Maybe ObjectLockRetentionMode
$sel:mode:ObjectLockRetention' :: ObjectLockRetention -> Maybe ObjectLockRetentionMode
mode} -> Maybe ObjectLockRetentionMode
mode) (\s :: ObjectLockRetention
s@ObjectLockRetention' {} Maybe ObjectLockRetentionMode
a -> ObjectLockRetention
s {$sel:mode:ObjectLockRetention' :: Maybe ObjectLockRetentionMode
mode = Maybe ObjectLockRetentionMode
a} :: ObjectLockRetention)

-- | The date on which this Object Lock Retention will expire.
objectLockRetention_retainUntilDate :: Lens.Lens' ObjectLockRetention (Prelude.Maybe Prelude.UTCTime)
objectLockRetention_retainUntilDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ObjectLockRetention -> f ObjectLockRetention
objectLockRetention_retainUntilDate = (ObjectLockRetention -> Maybe ISO8601)
-> (ObjectLockRetention -> Maybe ISO8601 -> ObjectLockRetention)
-> Lens
     ObjectLockRetention
     ObjectLockRetention
     (Maybe ISO8601)
     (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectLockRetention' {Maybe ISO8601
retainUntilDate :: Maybe ISO8601
$sel:retainUntilDate:ObjectLockRetention' :: ObjectLockRetention -> Maybe ISO8601
retainUntilDate} -> Maybe ISO8601
retainUntilDate) (\s :: ObjectLockRetention
s@ObjectLockRetention' {} Maybe ISO8601
a -> ObjectLockRetention
s {$sel:retainUntilDate:ObjectLockRetention' :: Maybe ISO8601
retainUntilDate = Maybe ISO8601
a} :: ObjectLockRetention) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> ObjectLockRetention -> f ObjectLockRetention)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ObjectLockRetention
-> f ObjectLockRetention
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (Maybe UTCTime) (Maybe UTCTime)
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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromXML ObjectLockRetention where
  parseXML :: [Node] -> Either String ObjectLockRetention
parseXML [Node]
x =
    Maybe ObjectLockRetentionMode
-> Maybe ISO8601 -> ObjectLockRetention
ObjectLockRetention'
      (Maybe ObjectLockRetentionMode
 -> Maybe ISO8601 -> ObjectLockRetention)
-> Either String (Maybe ObjectLockRetentionMode)
-> Either String (Maybe ISO8601 -> ObjectLockRetention)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe ObjectLockRetentionMode)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Mode")
      Either String (Maybe ISO8601 -> ObjectLockRetention)
-> Either String (Maybe ISO8601)
-> Either String ObjectLockRetention
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"RetainUntilDate")

instance Prelude.Hashable ObjectLockRetention

instance Prelude.NFData ObjectLockRetention

instance Core.ToXML ObjectLockRetention where
  toXML :: ObjectLockRetention -> XML
toXML ObjectLockRetention' {Maybe ISO8601
Maybe ObjectLockRetentionMode
retainUntilDate :: Maybe ISO8601
mode :: Maybe ObjectLockRetentionMode
$sel:retainUntilDate:ObjectLockRetention' :: ObjectLockRetention -> Maybe ISO8601
$sel:mode:ObjectLockRetention' :: ObjectLockRetention -> Maybe ObjectLockRetentionMode
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Mode" Name -> Maybe ObjectLockRetentionMode -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe ObjectLockRetentionMode
mode,
        Name
"RetainUntilDate" Name -> Maybe ISO8601 -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe ISO8601
retainUntilDate
      ]