{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DynamoDB.Types.PointInTimeRecoveryDescription where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DynamoDB.Types.AttributeValue
import Amazonka.DynamoDB.Types.PointInTimeRecoveryStatus
import Amazonka.DynamoDB.Types.WriteRequest
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'
  { -- | 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 Data.POSIX,
    -- | @LatestRestorableDateTime@ is typically 5 minutes before the current
    -- time.
    PointInTimeRecoveryDescription -> Maybe POSIX
latestRestorableDateTime :: Prelude.Maybe Data.POSIX,
    -- | The current state of point in time recovery:
    --
    -- -   @ENABLED@ - Point in time recovery is enabled.
    --
    -- -   @DISABLED@ - Point in time recovery is disabled.
    PointInTimeRecoveryDescription -> Maybe PointInTimeRecoveryStatus
pointInTimeRecoveryStatus :: Prelude.Maybe PointInTimeRecoveryStatus
  }
  deriving (PointInTimeRecoveryDescription
-> PointInTimeRecoveryDescription -> Bool
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]
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
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.
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:
--
-- '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.
--
-- 'pointInTimeRecoveryStatus', 'pointInTimeRecoveryDescription_pointInTimeRecoveryStatus' - The current state of point in time recovery:
--
-- -   @ENABLED@ - Point in time recovery is enabled.
--
-- -   @DISABLED@ - Point in time recovery is disabled.
newPointInTimeRecoveryDescription ::
  PointInTimeRecoveryDescription
newPointInTimeRecoveryDescription :: PointInTimeRecoveryDescription
newPointInTimeRecoveryDescription =
  PointInTimeRecoveryDescription'
    { $sel:earliestRestorableDateTime:PointInTimeRecoveryDescription' :: Maybe POSIX
earliestRestorableDateTime =
        forall a. Maybe a
Prelude.Nothing,
      $sel:latestRestorableDateTime:PointInTimeRecoveryDescription' :: Maybe POSIX
latestRestorableDateTime = forall a. Maybe a
Prelude.Nothing,
      $sel:pointInTimeRecoveryStatus:PointInTimeRecoveryDescription' :: Maybe PointInTimeRecoveryStatus
pointInTimeRecoveryStatus = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' PointInTimeRecoveryDescription (Maybe UTCTime)
pointInTimeRecoveryDescription_earliestRestorableDateTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | @LatestRestorableDateTime@ is typically 5 minutes before the current
-- time.
pointInTimeRecoveryDescription_latestRestorableDateTime :: Lens.Lens' PointInTimeRecoveryDescription (Prelude.Maybe Prelude.UTCTime)
pointInTimeRecoveryDescription_latestRestorableDateTime :: Lens' PointInTimeRecoveryDescription (Maybe UTCTime)
pointInTimeRecoveryDescription_latestRestorableDateTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The current state of point in time recovery:
--
-- -   @ENABLED@ - Point in time recovery is enabled.
--
-- -   @DISABLED@ - Point in time recovery is disabled.
pointInTimeRecoveryDescription_pointInTimeRecoveryStatus :: Lens.Lens' PointInTimeRecoveryDescription (Prelude.Maybe PointInTimeRecoveryStatus)
pointInTimeRecoveryDescription_pointInTimeRecoveryStatus :: Lens'
  PointInTimeRecoveryDescription (Maybe PointInTimeRecoveryStatus)
pointInTimeRecoveryDescription_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)

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

instance
  Prelude.Hashable
    PointInTimeRecoveryDescription
  where
  hashWithSalt :: Int -> PointInTimeRecoveryDescription -> Int
hashWithSalt
    Int
_salt
    PointInTimeRecoveryDescription' {Maybe POSIX
Maybe PointInTimeRecoveryStatus
pointInTimeRecoveryStatus :: Maybe PointInTimeRecoveryStatus
latestRestorableDateTime :: Maybe POSIX
earliestRestorableDateTime :: Maybe POSIX
$sel:pointInTimeRecoveryStatus:PointInTimeRecoveryDescription' :: PointInTimeRecoveryDescription -> Maybe PointInTimeRecoveryStatus
$sel:latestRestorableDateTime:PointInTimeRecoveryDescription' :: PointInTimeRecoveryDescription -> Maybe POSIX
$sel:earliestRestorableDateTime:PointInTimeRecoveryDescription' :: PointInTimeRecoveryDescription -> Maybe POSIX
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
earliestRestorableDateTime
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
latestRestorableDateTime
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PointInTimeRecoveryStatus
pointInTimeRecoveryStatus

instance
  Prelude.NFData
    PointInTimeRecoveryDescription
  where
  rnf :: PointInTimeRecoveryDescription -> ()
rnf PointInTimeRecoveryDescription' {Maybe POSIX
Maybe PointInTimeRecoveryStatus
pointInTimeRecoveryStatus :: Maybe PointInTimeRecoveryStatus
latestRestorableDateTime :: Maybe POSIX
earliestRestorableDateTime :: Maybe POSIX
$sel:pointInTimeRecoveryStatus:PointInTimeRecoveryDescription' :: PointInTimeRecoveryDescription -> Maybe PointInTimeRecoveryStatus
$sel:latestRestorableDateTime:PointInTimeRecoveryDescription' :: PointInTimeRecoveryDescription -> Maybe POSIX
$sel:earliestRestorableDateTime:PointInTimeRecoveryDescription' :: PointInTimeRecoveryDescription -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
earliestRestorableDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
latestRestorableDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PointInTimeRecoveryStatus
pointInTimeRecoveryStatus