{-# 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.DynamoDB.Types.PointInTimeRecoveryDescription
-- 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.DynamoDB.Types.PointInTimeRecoveryDescription where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.PointInTimeRecoveryStatus
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The description of the point in time settings applied to the table.
--
-- /See:/ 'newPointInTimeRecoveryDescription' smart constructor.
data PointInTimeRecoveryDescription = PointInTimeRecoveryDescription'
  { -- | The current state of point in time recovery:
    --
    -- -   @ENABLING@ - Point in time recovery is being enabled.
    --
    -- -   @ENABLED@ - Point in time recovery is enabled.
    --
    -- -   @DISABLED@ - Point in time recovery is disabled.
    PointInTimeRecoveryDescription -> Maybe PointInTimeRecoveryStatus
pointInTimeRecoveryStatus :: Prelude.Maybe PointInTimeRecoveryStatus,
    -- | Specifies the earliest point in time you can restore your table to. You
    -- can restore your table to any point in time during the last 35 days.
    PointInTimeRecoveryDescription -> Maybe POSIX
earliestRestorableDateTime :: Prelude.Maybe Core.POSIX,
    -- | @LatestRestorableDateTime@ is typically 5 minutes before the current
    -- time.
    PointInTimeRecoveryDescription -> Maybe POSIX
latestRestorableDateTime :: Prelude.Maybe Core.POSIX
  }
  deriving (PointInTimeRecoveryDescription
-> PointInTimeRecoveryDescription -> Bool
(PointInTimeRecoveryDescription
 -> PointInTimeRecoveryDescription -> Bool)
-> (PointInTimeRecoveryDescription
    -> PointInTimeRecoveryDescription -> Bool)
-> Eq PointInTimeRecoveryDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PointInTimeRecoveryDescription
-> PointInTimeRecoveryDescription -> Bool
$c/= :: PointInTimeRecoveryDescription
-> PointInTimeRecoveryDescription -> Bool
== :: PointInTimeRecoveryDescription
-> PointInTimeRecoveryDescription -> Bool
$c== :: PointInTimeRecoveryDescription
-> PointInTimeRecoveryDescription -> Bool
Prelude.Eq, ReadPrec [PointInTimeRecoveryDescription]
ReadPrec PointInTimeRecoveryDescription
Int -> ReadS PointInTimeRecoveryDescription
ReadS [PointInTimeRecoveryDescription]
(Int -> ReadS PointInTimeRecoveryDescription)
-> ReadS [PointInTimeRecoveryDescription]
-> ReadPrec PointInTimeRecoveryDescription
-> ReadPrec [PointInTimeRecoveryDescription]
-> Read PointInTimeRecoveryDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PointInTimeRecoveryDescription]
$creadListPrec :: ReadPrec [PointInTimeRecoveryDescription]
readPrec :: ReadPrec PointInTimeRecoveryDescription
$creadPrec :: ReadPrec PointInTimeRecoveryDescription
readList :: ReadS [PointInTimeRecoveryDescription]
$creadList :: ReadS [PointInTimeRecoveryDescription]
readsPrec :: Int -> ReadS PointInTimeRecoveryDescription
$creadsPrec :: Int -> ReadS PointInTimeRecoveryDescription
Prelude.Read, Int -> PointInTimeRecoveryDescription -> ShowS
[PointInTimeRecoveryDescription] -> ShowS
PointInTimeRecoveryDescription -> String
(Int -> PointInTimeRecoveryDescription -> ShowS)
-> (PointInTimeRecoveryDescription -> String)
-> ([PointInTimeRecoveryDescription] -> ShowS)
-> Show PointInTimeRecoveryDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PointInTimeRecoveryDescription] -> ShowS
$cshowList :: [PointInTimeRecoveryDescription] -> ShowS
show :: PointInTimeRecoveryDescription -> String
$cshow :: PointInTimeRecoveryDescription -> String
showsPrec :: Int -> PointInTimeRecoveryDescription -> ShowS
$cshowsPrec :: Int -> PointInTimeRecoveryDescription -> ShowS
Prelude.Show, (forall x.
 PointInTimeRecoveryDescription
 -> Rep PointInTimeRecoveryDescription x)
-> (forall x.
    Rep PointInTimeRecoveryDescription x
    -> PointInTimeRecoveryDescription)
-> Generic PointInTimeRecoveryDescription
forall x.
Rep PointInTimeRecoveryDescription x
-> PointInTimeRecoveryDescription
forall x.
PointInTimeRecoveryDescription
-> Rep PointInTimeRecoveryDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PointInTimeRecoveryDescription x
-> PointInTimeRecoveryDescription
$cfrom :: forall x.
PointInTimeRecoveryDescription
-> Rep PointInTimeRecoveryDescription x
Prelude.Generic)

-- |
-- Create a value of 'PointInTimeRecoveryDescription' 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:
--
-- 'pointInTimeRecoveryStatus', 'pointInTimeRecoveryDescription_pointInTimeRecoveryStatus' - The current state of point in time recovery:
--
-- -   @ENABLING@ - Point in time recovery is being enabled.
--
-- -   @ENABLED@ - Point in time recovery is enabled.
--
-- -   @DISABLED@ - Point in time recovery is disabled.
--
-- 'earliestRestorableDateTime', 'pointInTimeRecoveryDescription_earliestRestorableDateTime' - Specifies the earliest point in time you can restore your table to. You
-- can restore your table to any point in time during the last 35 days.
--
-- 'latestRestorableDateTime', 'pointInTimeRecoveryDescription_latestRestorableDateTime' - @LatestRestorableDateTime@ is typically 5 minutes before the current
-- time.
newPointInTimeRecoveryDescription ::
  PointInTimeRecoveryDescription
newPointInTimeRecoveryDescription :: PointInTimeRecoveryDescription
newPointInTimeRecoveryDescription =
  PointInTimeRecoveryDescription' :: Maybe PointInTimeRecoveryStatus
-> Maybe POSIX -> Maybe POSIX -> PointInTimeRecoveryDescription
PointInTimeRecoveryDescription'
    { $sel:pointInTimeRecoveryStatus:PointInTimeRecoveryDescription' :: Maybe PointInTimeRecoveryStatus
pointInTimeRecoveryStatus =
        Maybe PointInTimeRecoveryStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:earliestRestorableDateTime:PointInTimeRecoveryDescription' :: Maybe POSIX
earliestRestorableDateTime =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:latestRestorableDateTime:PointInTimeRecoveryDescription' :: Maybe POSIX
latestRestorableDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The current state of point in time recovery:
--
-- -   @ENABLING@ - Point in time recovery is being enabled.
--
-- -   @ENABLED@ - Point in time recovery is enabled.
--
-- -   @DISABLED@ - Point in time recovery is disabled.
pointInTimeRecoveryDescription_pointInTimeRecoveryStatus :: Lens.Lens' PointInTimeRecoveryDescription (Prelude.Maybe PointInTimeRecoveryStatus)
pointInTimeRecoveryDescription_pointInTimeRecoveryStatus :: (Maybe PointInTimeRecoveryStatus
 -> f (Maybe PointInTimeRecoveryStatus))
-> PointInTimeRecoveryDescription
-> f PointInTimeRecoveryDescription
pointInTimeRecoveryDescription_pointInTimeRecoveryStatus = (PointInTimeRecoveryDescription -> Maybe PointInTimeRecoveryStatus)
-> (PointInTimeRecoveryDescription
    -> Maybe PointInTimeRecoveryStatus
    -> PointInTimeRecoveryDescription)
-> Lens
     PointInTimeRecoveryDescription
     PointInTimeRecoveryDescription
     (Maybe PointInTimeRecoveryStatus)
     (Maybe PointInTimeRecoveryStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PointInTimeRecoveryDescription' {Maybe PointInTimeRecoveryStatus
pointInTimeRecoveryStatus :: Maybe PointInTimeRecoveryStatus
$sel:pointInTimeRecoveryStatus:PointInTimeRecoveryDescription' :: PointInTimeRecoveryDescription -> Maybe PointInTimeRecoveryStatus
pointInTimeRecoveryStatus} -> Maybe PointInTimeRecoveryStatus
pointInTimeRecoveryStatus) (\s :: PointInTimeRecoveryDescription
s@PointInTimeRecoveryDescription' {} Maybe PointInTimeRecoveryStatus
a -> PointInTimeRecoveryDescription
s {$sel:pointInTimeRecoveryStatus:PointInTimeRecoveryDescription' :: Maybe PointInTimeRecoveryStatus
pointInTimeRecoveryStatus = Maybe PointInTimeRecoveryStatus
a} :: PointInTimeRecoveryDescription)

-- | Specifies the earliest point in time you can restore your table to. You
-- can restore your table to any point in time during the last 35 days.
pointInTimeRecoveryDescription_earliestRestorableDateTime :: Lens.Lens' PointInTimeRecoveryDescription (Prelude.Maybe Prelude.UTCTime)
pointInTimeRecoveryDescription_earliestRestorableDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> PointInTimeRecoveryDescription
-> f PointInTimeRecoveryDescription
pointInTimeRecoveryDescription_earliestRestorableDateTime = (PointInTimeRecoveryDescription -> Maybe POSIX)
-> (PointInTimeRecoveryDescription
    -> Maybe POSIX -> PointInTimeRecoveryDescription)
-> Lens
     PointInTimeRecoveryDescription
     PointInTimeRecoveryDescription
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PointInTimeRecoveryDescription' {Maybe POSIX
earliestRestorableDateTime :: Maybe POSIX
$sel:earliestRestorableDateTime:PointInTimeRecoveryDescription' :: PointInTimeRecoveryDescription -> Maybe POSIX
earliestRestorableDateTime} -> Maybe POSIX
earliestRestorableDateTime) (\s :: PointInTimeRecoveryDescription
s@PointInTimeRecoveryDescription' {} Maybe POSIX
a -> PointInTimeRecoveryDescription
s {$sel:earliestRestorableDateTime:PointInTimeRecoveryDescription' :: Maybe POSIX
earliestRestorableDateTime = Maybe POSIX
a} :: PointInTimeRecoveryDescription) ((Maybe POSIX -> f (Maybe POSIX))
 -> PointInTimeRecoveryDescription
 -> f PointInTimeRecoveryDescription)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> PointInTimeRecoveryDescription
-> f PointInTimeRecoveryDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | @LatestRestorableDateTime@ is typically 5 minutes before the current
-- time.
pointInTimeRecoveryDescription_latestRestorableDateTime :: Lens.Lens' PointInTimeRecoveryDescription (Prelude.Maybe Prelude.UTCTime)
pointInTimeRecoveryDescription_latestRestorableDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> PointInTimeRecoveryDescription
-> f PointInTimeRecoveryDescription
pointInTimeRecoveryDescription_latestRestorableDateTime = (PointInTimeRecoveryDescription -> Maybe POSIX)
-> (PointInTimeRecoveryDescription
    -> Maybe POSIX -> PointInTimeRecoveryDescription)
-> Lens
     PointInTimeRecoveryDescription
     PointInTimeRecoveryDescription
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PointInTimeRecoveryDescription' {Maybe POSIX
latestRestorableDateTime :: Maybe POSIX
$sel:latestRestorableDateTime:PointInTimeRecoveryDescription' :: PointInTimeRecoveryDescription -> Maybe POSIX
latestRestorableDateTime} -> Maybe POSIX
latestRestorableDateTime) (\s :: PointInTimeRecoveryDescription
s@PointInTimeRecoveryDescription' {} Maybe POSIX
a -> PointInTimeRecoveryDescription
s {$sel:latestRestorableDateTime:PointInTimeRecoveryDescription' :: Maybe POSIX
latestRestorableDateTime = Maybe POSIX
a} :: PointInTimeRecoveryDescription) ((Maybe POSIX -> f (Maybe POSIX))
 -> PointInTimeRecoveryDescription
 -> f PointInTimeRecoveryDescription)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> PointInTimeRecoveryDescription
-> f PointInTimeRecoveryDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON PointInTimeRecoveryDescription where
  parseJSON :: Value -> Parser PointInTimeRecoveryDescription
parseJSON =
    String
-> (Object -> Parser PointInTimeRecoveryDescription)
-> Value
-> Parser PointInTimeRecoveryDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PointInTimeRecoveryDescription"
      ( \Object
x ->
          Maybe PointInTimeRecoveryStatus
-> Maybe POSIX -> Maybe POSIX -> PointInTimeRecoveryDescription
PointInTimeRecoveryDescription'
            (Maybe PointInTimeRecoveryStatus
 -> Maybe POSIX -> Maybe POSIX -> PointInTimeRecoveryDescription)
-> Parser (Maybe PointInTimeRecoveryStatus)
-> Parser
     (Maybe POSIX -> Maybe POSIX -> PointInTimeRecoveryDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe PointInTimeRecoveryStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PointInTimeRecoveryStatus")
            Parser
  (Maybe POSIX -> Maybe POSIX -> PointInTimeRecoveryDescription)
-> Parser (Maybe POSIX)
-> Parser (Maybe POSIX -> PointInTimeRecoveryDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EarliestRestorableDateTime")
            Parser (Maybe POSIX -> PointInTimeRecoveryDescription)
-> Parser (Maybe POSIX) -> Parser PointInTimeRecoveryDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LatestRestorableDateTime")
      )

instance
  Prelude.Hashable
    PointInTimeRecoveryDescription

instance
  Prelude.NFData
    PointInTimeRecoveryDescription