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

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

-- | Contains details of a table archival operation.
--
-- /See:/ 'newArchivalSummary' smart constructor.
data ArchivalSummary = ArchivalSummary'
  { -- | The reason DynamoDB archived the table. Currently, the only possible
    -- value is:
    --
    -- -   @INACCESSIBLE_ENCRYPTION_CREDENTIALS@ - The table was archived due
    --     to the table\'s AWS KMS key being inaccessible for more than seven
    --     days. An On-Demand backup was created at the archival time.
    ArchivalSummary -> Maybe Text
archivalReason :: Prelude.Maybe Prelude.Text,
    -- | The date and time when table archival was initiated by DynamoDB, in UNIX
    -- epoch time format.
    ArchivalSummary -> Maybe POSIX
archivalDateTime :: Prelude.Maybe Core.POSIX,
    -- | The Amazon Resource Name (ARN) of the backup the table was archived to,
    -- when applicable in the archival reason. If you wish to restore this
    -- backup to the same table name, you will need to delete the original
    -- table.
    ArchivalSummary -> Maybe Text
archivalBackupArn :: Prelude.Maybe Prelude.Text
  }
  deriving (ArchivalSummary -> ArchivalSummary -> Bool
(ArchivalSummary -> ArchivalSummary -> Bool)
-> (ArchivalSummary -> ArchivalSummary -> Bool)
-> Eq ArchivalSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ArchivalSummary -> ArchivalSummary -> Bool
$c/= :: ArchivalSummary -> ArchivalSummary -> Bool
== :: ArchivalSummary -> ArchivalSummary -> Bool
$c== :: ArchivalSummary -> ArchivalSummary -> Bool
Prelude.Eq, ReadPrec [ArchivalSummary]
ReadPrec ArchivalSummary
Int -> ReadS ArchivalSummary
ReadS [ArchivalSummary]
(Int -> ReadS ArchivalSummary)
-> ReadS [ArchivalSummary]
-> ReadPrec ArchivalSummary
-> ReadPrec [ArchivalSummary]
-> Read ArchivalSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ArchivalSummary]
$creadListPrec :: ReadPrec [ArchivalSummary]
readPrec :: ReadPrec ArchivalSummary
$creadPrec :: ReadPrec ArchivalSummary
readList :: ReadS [ArchivalSummary]
$creadList :: ReadS [ArchivalSummary]
readsPrec :: Int -> ReadS ArchivalSummary
$creadsPrec :: Int -> ReadS ArchivalSummary
Prelude.Read, Int -> ArchivalSummary -> ShowS
[ArchivalSummary] -> ShowS
ArchivalSummary -> String
(Int -> ArchivalSummary -> ShowS)
-> (ArchivalSummary -> String)
-> ([ArchivalSummary] -> ShowS)
-> Show ArchivalSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ArchivalSummary] -> ShowS
$cshowList :: [ArchivalSummary] -> ShowS
show :: ArchivalSummary -> String
$cshow :: ArchivalSummary -> String
showsPrec :: Int -> ArchivalSummary -> ShowS
$cshowsPrec :: Int -> ArchivalSummary -> ShowS
Prelude.Show, (forall x. ArchivalSummary -> Rep ArchivalSummary x)
-> (forall x. Rep ArchivalSummary x -> ArchivalSummary)
-> Generic ArchivalSummary
forall x. Rep ArchivalSummary x -> ArchivalSummary
forall x. ArchivalSummary -> Rep ArchivalSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ArchivalSummary x -> ArchivalSummary
$cfrom :: forall x. ArchivalSummary -> Rep ArchivalSummary x
Prelude.Generic)

-- |
-- Create a value of 'ArchivalSummary' 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:
--
-- 'archivalReason', 'archivalSummary_archivalReason' - The reason DynamoDB archived the table. Currently, the only possible
-- value is:
--
-- -   @INACCESSIBLE_ENCRYPTION_CREDENTIALS@ - The table was archived due
--     to the table\'s AWS KMS key being inaccessible for more than seven
--     days. An On-Demand backup was created at the archival time.
--
-- 'archivalDateTime', 'archivalSummary_archivalDateTime' - The date and time when table archival was initiated by DynamoDB, in UNIX
-- epoch time format.
--
-- 'archivalBackupArn', 'archivalSummary_archivalBackupArn' - The Amazon Resource Name (ARN) of the backup the table was archived to,
-- when applicable in the archival reason. If you wish to restore this
-- backup to the same table name, you will need to delete the original
-- table.
newArchivalSummary ::
  ArchivalSummary
newArchivalSummary :: ArchivalSummary
newArchivalSummary =
  ArchivalSummary' :: Maybe Text -> Maybe POSIX -> Maybe Text -> ArchivalSummary
ArchivalSummary'
    { $sel:archivalReason:ArchivalSummary' :: Maybe Text
archivalReason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:archivalDateTime:ArchivalSummary' :: Maybe POSIX
archivalDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:archivalBackupArn:ArchivalSummary' :: Maybe Text
archivalBackupArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The reason DynamoDB archived the table. Currently, the only possible
-- value is:
--
-- -   @INACCESSIBLE_ENCRYPTION_CREDENTIALS@ - The table was archived due
--     to the table\'s AWS KMS key being inaccessible for more than seven
--     days. An On-Demand backup was created at the archival time.
archivalSummary_archivalReason :: Lens.Lens' ArchivalSummary (Prelude.Maybe Prelude.Text)
archivalSummary_archivalReason :: (Maybe Text -> f (Maybe Text))
-> ArchivalSummary -> f ArchivalSummary
archivalSummary_archivalReason = (ArchivalSummary -> Maybe Text)
-> (ArchivalSummary -> Maybe Text -> ArchivalSummary)
-> Lens ArchivalSummary ArchivalSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArchivalSummary' {Maybe Text
archivalReason :: Maybe Text
$sel:archivalReason:ArchivalSummary' :: ArchivalSummary -> Maybe Text
archivalReason} -> Maybe Text
archivalReason) (\s :: ArchivalSummary
s@ArchivalSummary' {} Maybe Text
a -> ArchivalSummary
s {$sel:archivalReason:ArchivalSummary' :: Maybe Text
archivalReason = Maybe Text
a} :: ArchivalSummary)

-- | The date and time when table archival was initiated by DynamoDB, in UNIX
-- epoch time format.
archivalSummary_archivalDateTime :: Lens.Lens' ArchivalSummary (Prelude.Maybe Prelude.UTCTime)
archivalSummary_archivalDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ArchivalSummary -> f ArchivalSummary
archivalSummary_archivalDateTime = (ArchivalSummary -> Maybe POSIX)
-> (ArchivalSummary -> Maybe POSIX -> ArchivalSummary)
-> Lens ArchivalSummary ArchivalSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArchivalSummary' {Maybe POSIX
archivalDateTime :: Maybe POSIX
$sel:archivalDateTime:ArchivalSummary' :: ArchivalSummary -> Maybe POSIX
archivalDateTime} -> Maybe POSIX
archivalDateTime) (\s :: ArchivalSummary
s@ArchivalSummary' {} Maybe POSIX
a -> ArchivalSummary
s {$sel:archivalDateTime:ArchivalSummary' :: Maybe POSIX
archivalDateTime = Maybe POSIX
a} :: ArchivalSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> ArchivalSummary -> f ArchivalSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ArchivalSummary
-> f ArchivalSummary
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

-- | The Amazon Resource Name (ARN) of the backup the table was archived to,
-- when applicable in the archival reason. If you wish to restore this
-- backup to the same table name, you will need to delete the original
-- table.
archivalSummary_archivalBackupArn :: Lens.Lens' ArchivalSummary (Prelude.Maybe Prelude.Text)
archivalSummary_archivalBackupArn :: (Maybe Text -> f (Maybe Text))
-> ArchivalSummary -> f ArchivalSummary
archivalSummary_archivalBackupArn = (ArchivalSummary -> Maybe Text)
-> (ArchivalSummary -> Maybe Text -> ArchivalSummary)
-> Lens ArchivalSummary ArchivalSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArchivalSummary' {Maybe Text
archivalBackupArn :: Maybe Text
$sel:archivalBackupArn:ArchivalSummary' :: ArchivalSummary -> Maybe Text
archivalBackupArn} -> Maybe Text
archivalBackupArn) (\s :: ArchivalSummary
s@ArchivalSummary' {} Maybe Text
a -> ArchivalSummary
s {$sel:archivalBackupArn:ArchivalSummary' :: Maybe Text
archivalBackupArn = Maybe Text
a} :: ArchivalSummary)

instance Core.FromJSON ArchivalSummary where
  parseJSON :: Value -> Parser ArchivalSummary
parseJSON =
    String
-> (Object -> Parser ArchivalSummary)
-> Value
-> Parser ArchivalSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ArchivalSummary"
      ( \Object
x ->
          Maybe Text -> Maybe POSIX -> Maybe Text -> ArchivalSummary
ArchivalSummary'
            (Maybe Text -> Maybe POSIX -> Maybe Text -> ArchivalSummary)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> ArchivalSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ArchivalReason")
            Parser (Maybe POSIX -> Maybe Text -> ArchivalSummary)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> ArchivalSummary)
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
"ArchivalDateTime")
            Parser (Maybe Text -> ArchivalSummary)
-> Parser (Maybe Text) -> Parser ArchivalSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ArchivalBackupArn")
      )

instance Prelude.Hashable ArchivalSummary

instance Prelude.NFData ArchivalSummary