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

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

-- | Contains details for the restore.
--
-- /See:/ 'newRestoreSummary' smart constructor.
data RestoreSummary = RestoreSummary'
  { -- | The ARN of the source table of the backup that is being restored.
    RestoreSummary -> Maybe Text
sourceTableArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the backup from which the table was
    -- restored.
    RestoreSummary -> Maybe Text
sourceBackupArn :: Prelude.Maybe Prelude.Text,
    -- | Point in time or source backup time.
    RestoreSummary -> POSIX
restoreDateTime :: Core.POSIX,
    -- | Indicates if a restore is in progress or not.
    RestoreSummary -> Bool
restoreInProgress :: Prelude.Bool
  }
  deriving (RestoreSummary -> RestoreSummary -> Bool
(RestoreSummary -> RestoreSummary -> Bool)
-> (RestoreSummary -> RestoreSummary -> Bool) -> Eq RestoreSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RestoreSummary -> RestoreSummary -> Bool
$c/= :: RestoreSummary -> RestoreSummary -> Bool
== :: RestoreSummary -> RestoreSummary -> Bool
$c== :: RestoreSummary -> RestoreSummary -> Bool
Prelude.Eq, ReadPrec [RestoreSummary]
ReadPrec RestoreSummary
Int -> ReadS RestoreSummary
ReadS [RestoreSummary]
(Int -> ReadS RestoreSummary)
-> ReadS [RestoreSummary]
-> ReadPrec RestoreSummary
-> ReadPrec [RestoreSummary]
-> Read RestoreSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RestoreSummary]
$creadListPrec :: ReadPrec [RestoreSummary]
readPrec :: ReadPrec RestoreSummary
$creadPrec :: ReadPrec RestoreSummary
readList :: ReadS [RestoreSummary]
$creadList :: ReadS [RestoreSummary]
readsPrec :: Int -> ReadS RestoreSummary
$creadsPrec :: Int -> ReadS RestoreSummary
Prelude.Read, Int -> RestoreSummary -> ShowS
[RestoreSummary] -> ShowS
RestoreSummary -> String
(Int -> RestoreSummary -> ShowS)
-> (RestoreSummary -> String)
-> ([RestoreSummary] -> ShowS)
-> Show RestoreSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RestoreSummary] -> ShowS
$cshowList :: [RestoreSummary] -> ShowS
show :: RestoreSummary -> String
$cshow :: RestoreSummary -> String
showsPrec :: Int -> RestoreSummary -> ShowS
$cshowsPrec :: Int -> RestoreSummary -> ShowS
Prelude.Show, (forall x. RestoreSummary -> Rep RestoreSummary x)
-> (forall x. Rep RestoreSummary x -> RestoreSummary)
-> Generic RestoreSummary
forall x. Rep RestoreSummary x -> RestoreSummary
forall x. RestoreSummary -> Rep RestoreSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RestoreSummary x -> RestoreSummary
$cfrom :: forall x. RestoreSummary -> Rep RestoreSummary x
Prelude.Generic)

-- |
-- Create a value of 'RestoreSummary' 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:
--
-- 'sourceTableArn', 'restoreSummary_sourceTableArn' - The ARN of the source table of the backup that is being restored.
--
-- 'sourceBackupArn', 'restoreSummary_sourceBackupArn' - The Amazon Resource Name (ARN) of the backup from which the table was
-- restored.
--
-- 'restoreDateTime', 'restoreSummary_restoreDateTime' - Point in time or source backup time.
--
-- 'restoreInProgress', 'restoreSummary_restoreInProgress' - Indicates if a restore is in progress or not.
newRestoreSummary ::
  -- | 'restoreDateTime'
  Prelude.UTCTime ->
  -- | 'restoreInProgress'
  Prelude.Bool ->
  RestoreSummary
newRestoreSummary :: UTCTime -> Bool -> RestoreSummary
newRestoreSummary
  UTCTime
pRestoreDateTime_
  Bool
pRestoreInProgress_ =
    RestoreSummary' :: Maybe Text -> Maybe Text -> POSIX -> Bool -> RestoreSummary
RestoreSummary'
      { $sel:sourceTableArn:RestoreSummary' :: Maybe Text
sourceTableArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:sourceBackupArn:RestoreSummary' :: Maybe Text
sourceBackupArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:restoreDateTime:RestoreSummary' :: POSIX
restoreDateTime =
          Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pRestoreDateTime_,
        $sel:restoreInProgress:RestoreSummary' :: Bool
restoreInProgress = Bool
pRestoreInProgress_
      }

-- | The ARN of the source table of the backup that is being restored.
restoreSummary_sourceTableArn :: Lens.Lens' RestoreSummary (Prelude.Maybe Prelude.Text)
restoreSummary_sourceTableArn :: (Maybe Text -> f (Maybe Text))
-> RestoreSummary -> f RestoreSummary
restoreSummary_sourceTableArn = (RestoreSummary -> Maybe Text)
-> (RestoreSummary -> Maybe Text -> RestoreSummary)
-> Lens RestoreSummary RestoreSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreSummary' {Maybe Text
sourceTableArn :: Maybe Text
$sel:sourceTableArn:RestoreSummary' :: RestoreSummary -> Maybe Text
sourceTableArn} -> Maybe Text
sourceTableArn) (\s :: RestoreSummary
s@RestoreSummary' {} Maybe Text
a -> RestoreSummary
s {$sel:sourceTableArn:RestoreSummary' :: Maybe Text
sourceTableArn = Maybe Text
a} :: RestoreSummary)

-- | The Amazon Resource Name (ARN) of the backup from which the table was
-- restored.
restoreSummary_sourceBackupArn :: Lens.Lens' RestoreSummary (Prelude.Maybe Prelude.Text)
restoreSummary_sourceBackupArn :: (Maybe Text -> f (Maybe Text))
-> RestoreSummary -> f RestoreSummary
restoreSummary_sourceBackupArn = (RestoreSummary -> Maybe Text)
-> (RestoreSummary -> Maybe Text -> RestoreSummary)
-> Lens RestoreSummary RestoreSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreSummary' {Maybe Text
sourceBackupArn :: Maybe Text
$sel:sourceBackupArn:RestoreSummary' :: RestoreSummary -> Maybe Text
sourceBackupArn} -> Maybe Text
sourceBackupArn) (\s :: RestoreSummary
s@RestoreSummary' {} Maybe Text
a -> RestoreSummary
s {$sel:sourceBackupArn:RestoreSummary' :: Maybe Text
sourceBackupArn = Maybe Text
a} :: RestoreSummary)

-- | Point in time or source backup time.
restoreSummary_restoreDateTime :: Lens.Lens' RestoreSummary Prelude.UTCTime
restoreSummary_restoreDateTime :: (UTCTime -> f UTCTime) -> RestoreSummary -> f RestoreSummary
restoreSummary_restoreDateTime = (RestoreSummary -> POSIX)
-> (RestoreSummary -> POSIX -> RestoreSummary)
-> Lens RestoreSummary RestoreSummary POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreSummary' {POSIX
restoreDateTime :: POSIX
$sel:restoreDateTime:RestoreSummary' :: RestoreSummary -> POSIX
restoreDateTime} -> POSIX
restoreDateTime) (\s :: RestoreSummary
s@RestoreSummary' {} POSIX
a -> RestoreSummary
s {$sel:restoreDateTime:RestoreSummary' :: POSIX
restoreDateTime = POSIX
a} :: RestoreSummary) ((POSIX -> f POSIX) -> RestoreSummary -> f RestoreSummary)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> RestoreSummary
-> f RestoreSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Indicates if a restore is in progress or not.
restoreSummary_restoreInProgress :: Lens.Lens' RestoreSummary Prelude.Bool
restoreSummary_restoreInProgress :: (Bool -> f Bool) -> RestoreSummary -> f RestoreSummary
restoreSummary_restoreInProgress = (RestoreSummary -> Bool)
-> (RestoreSummary -> Bool -> RestoreSummary)
-> Lens RestoreSummary RestoreSummary Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreSummary' {Bool
restoreInProgress :: Bool
$sel:restoreInProgress:RestoreSummary' :: RestoreSummary -> Bool
restoreInProgress} -> Bool
restoreInProgress) (\s :: RestoreSummary
s@RestoreSummary' {} Bool
a -> RestoreSummary
s {$sel:restoreInProgress:RestoreSummary' :: Bool
restoreInProgress = Bool
a} :: RestoreSummary)

instance Core.FromJSON RestoreSummary where
  parseJSON :: Value -> Parser RestoreSummary
parseJSON =
    String
-> (Object -> Parser RestoreSummary)
-> Value
-> Parser RestoreSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RestoreSummary"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> POSIX -> Bool -> RestoreSummary
RestoreSummary'
            (Maybe Text -> Maybe Text -> POSIX -> Bool -> RestoreSummary)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> POSIX -> Bool -> RestoreSummary)
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
"SourceTableArn")
            Parser (Maybe Text -> POSIX -> Bool -> RestoreSummary)
-> Parser (Maybe Text) -> Parser (POSIX -> Bool -> RestoreSummary)
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
"SourceBackupArn")
            Parser (POSIX -> Bool -> RestoreSummary)
-> Parser POSIX -> Parser (Bool -> RestoreSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RestoreDateTime")
            Parser (Bool -> RestoreSummary)
-> Parser Bool -> Parser RestoreSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RestoreInProgress")
      )

instance Prelude.Hashable RestoreSummary

instance Prelude.NFData RestoreSummary