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

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.BackupStatus
import Amazonka.DynamoDB.Types.BackupType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the details of the backup created for the table.
--
-- /See:/ 'newBackupDetails' smart constructor.
data BackupDetails = BackupDetails'
  { -- | Time at which the automatic on-demand backup created by DynamoDB will
    -- expire. This @SYSTEM@ on-demand backup expires automatically 35 days
    -- after its creation.
    BackupDetails -> Maybe POSIX
backupExpiryDateTime :: Prelude.Maybe Core.POSIX,
    -- | Size of the backup in bytes.
    BackupDetails -> Maybe Natural
backupSizeBytes :: Prelude.Maybe Prelude.Natural,
    -- | ARN associated with the backup.
    BackupDetails -> Text
backupArn :: Prelude.Text,
    -- | Name of the requested backup.
    BackupDetails -> Text
backupName :: Prelude.Text,
    -- | Backup can be in one of the following states: CREATING, ACTIVE, DELETED.
    BackupDetails -> BackupStatus
backupStatus :: BackupStatus,
    -- | BackupType:
    --
    -- -   @USER@ - You create and manage these using the on-demand backup
    --     feature.
    --
    -- -   @SYSTEM@ - If you delete a table with point-in-time recovery
    --     enabled, a @SYSTEM@ backup is automatically created and is retained
    --     for 35 days (at no additional cost). System backups allow you to
    --     restore the deleted table to the state it was in just before the
    --     point of deletion.
    --
    -- -   @AWS_BACKUP@ - On-demand backup created by you from AWS Backup
    --     service.
    BackupDetails -> BackupType
backupType :: BackupType,
    -- | Time at which the backup was created. This is the request time of the
    -- backup.
    BackupDetails -> POSIX
backupCreationDateTime :: Core.POSIX
  }
  deriving (BackupDetails -> BackupDetails -> Bool
(BackupDetails -> BackupDetails -> Bool)
-> (BackupDetails -> BackupDetails -> Bool) -> Eq BackupDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BackupDetails -> BackupDetails -> Bool
$c/= :: BackupDetails -> BackupDetails -> Bool
== :: BackupDetails -> BackupDetails -> Bool
$c== :: BackupDetails -> BackupDetails -> Bool
Prelude.Eq, ReadPrec [BackupDetails]
ReadPrec BackupDetails
Int -> ReadS BackupDetails
ReadS [BackupDetails]
(Int -> ReadS BackupDetails)
-> ReadS [BackupDetails]
-> ReadPrec BackupDetails
-> ReadPrec [BackupDetails]
-> Read BackupDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BackupDetails]
$creadListPrec :: ReadPrec [BackupDetails]
readPrec :: ReadPrec BackupDetails
$creadPrec :: ReadPrec BackupDetails
readList :: ReadS [BackupDetails]
$creadList :: ReadS [BackupDetails]
readsPrec :: Int -> ReadS BackupDetails
$creadsPrec :: Int -> ReadS BackupDetails
Prelude.Read, Int -> BackupDetails -> ShowS
[BackupDetails] -> ShowS
BackupDetails -> String
(Int -> BackupDetails -> ShowS)
-> (BackupDetails -> String)
-> ([BackupDetails] -> ShowS)
-> Show BackupDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BackupDetails] -> ShowS
$cshowList :: [BackupDetails] -> ShowS
show :: BackupDetails -> String
$cshow :: BackupDetails -> String
showsPrec :: Int -> BackupDetails -> ShowS
$cshowsPrec :: Int -> BackupDetails -> ShowS
Prelude.Show, (forall x. BackupDetails -> Rep BackupDetails x)
-> (forall x. Rep BackupDetails x -> BackupDetails)
-> Generic BackupDetails
forall x. Rep BackupDetails x -> BackupDetails
forall x. BackupDetails -> Rep BackupDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BackupDetails x -> BackupDetails
$cfrom :: forall x. BackupDetails -> Rep BackupDetails x
Prelude.Generic)

-- |
-- Create a value of 'BackupDetails' 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:
--
-- 'backupExpiryDateTime', 'backupDetails_backupExpiryDateTime' - Time at which the automatic on-demand backup created by DynamoDB will
-- expire. This @SYSTEM@ on-demand backup expires automatically 35 days
-- after its creation.
--
-- 'backupSizeBytes', 'backupDetails_backupSizeBytes' - Size of the backup in bytes.
--
-- 'backupArn', 'backupDetails_backupArn' - ARN associated with the backup.
--
-- 'backupName', 'backupDetails_backupName' - Name of the requested backup.
--
-- 'backupStatus', 'backupDetails_backupStatus' - Backup can be in one of the following states: CREATING, ACTIVE, DELETED.
--
-- 'backupType', 'backupDetails_backupType' - BackupType:
--
-- -   @USER@ - You create and manage these using the on-demand backup
--     feature.
--
-- -   @SYSTEM@ - If you delete a table with point-in-time recovery
--     enabled, a @SYSTEM@ backup is automatically created and is retained
--     for 35 days (at no additional cost). System backups allow you to
--     restore the deleted table to the state it was in just before the
--     point of deletion.
--
-- -   @AWS_BACKUP@ - On-demand backup created by you from AWS Backup
--     service.
--
-- 'backupCreationDateTime', 'backupDetails_backupCreationDateTime' - Time at which the backup was created. This is the request time of the
-- backup.
newBackupDetails ::
  -- | 'backupArn'
  Prelude.Text ->
  -- | 'backupName'
  Prelude.Text ->
  -- | 'backupStatus'
  BackupStatus ->
  -- | 'backupType'
  BackupType ->
  -- | 'backupCreationDateTime'
  Prelude.UTCTime ->
  BackupDetails
newBackupDetails :: Text
-> Text -> BackupStatus -> BackupType -> UTCTime -> BackupDetails
newBackupDetails
  Text
pBackupArn_
  Text
pBackupName_
  BackupStatus
pBackupStatus_
  BackupType
pBackupType_
  UTCTime
pBackupCreationDateTime_ =
    BackupDetails' :: Maybe POSIX
-> Maybe Natural
-> Text
-> Text
-> BackupStatus
-> BackupType
-> POSIX
-> BackupDetails
BackupDetails'
      { $sel:backupExpiryDateTime:BackupDetails' :: Maybe POSIX
backupExpiryDateTime =
          Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
        $sel:backupSizeBytes:BackupDetails' :: Maybe Natural
backupSizeBytes = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:backupArn:BackupDetails' :: Text
backupArn = Text
pBackupArn_,
        $sel:backupName:BackupDetails' :: Text
backupName = Text
pBackupName_,
        $sel:backupStatus:BackupDetails' :: BackupStatus
backupStatus = BackupStatus
pBackupStatus_,
        $sel:backupType:BackupDetails' :: BackupType
backupType = BackupType
pBackupType_,
        $sel:backupCreationDateTime:BackupDetails' :: POSIX
backupCreationDateTime =
          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
pBackupCreationDateTime_
      }

-- | Time at which the automatic on-demand backup created by DynamoDB will
-- expire. This @SYSTEM@ on-demand backup expires automatically 35 days
-- after its creation.
backupDetails_backupExpiryDateTime :: Lens.Lens' BackupDetails (Prelude.Maybe Prelude.UTCTime)
backupDetails_backupExpiryDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> BackupDetails -> f BackupDetails
backupDetails_backupExpiryDateTime = (BackupDetails -> Maybe POSIX)
-> (BackupDetails -> Maybe POSIX -> BackupDetails)
-> Lens BackupDetails BackupDetails (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupDetails' {Maybe POSIX
backupExpiryDateTime :: Maybe POSIX
$sel:backupExpiryDateTime:BackupDetails' :: BackupDetails -> Maybe POSIX
backupExpiryDateTime} -> Maybe POSIX
backupExpiryDateTime) (\s :: BackupDetails
s@BackupDetails' {} Maybe POSIX
a -> BackupDetails
s {$sel:backupExpiryDateTime:BackupDetails' :: Maybe POSIX
backupExpiryDateTime = Maybe POSIX
a} :: BackupDetails) ((Maybe POSIX -> f (Maybe POSIX))
 -> BackupDetails -> f BackupDetails)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> BackupDetails
-> f BackupDetails
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

-- | Size of the backup in bytes.
backupDetails_backupSizeBytes :: Lens.Lens' BackupDetails (Prelude.Maybe Prelude.Natural)
backupDetails_backupSizeBytes :: (Maybe Natural -> f (Maybe Natural))
-> BackupDetails -> f BackupDetails
backupDetails_backupSizeBytes = (BackupDetails -> Maybe Natural)
-> (BackupDetails -> Maybe Natural -> BackupDetails)
-> Lens BackupDetails BackupDetails (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupDetails' {Maybe Natural
backupSizeBytes :: Maybe Natural
$sel:backupSizeBytes:BackupDetails' :: BackupDetails -> Maybe Natural
backupSizeBytes} -> Maybe Natural
backupSizeBytes) (\s :: BackupDetails
s@BackupDetails' {} Maybe Natural
a -> BackupDetails
s {$sel:backupSizeBytes:BackupDetails' :: Maybe Natural
backupSizeBytes = Maybe Natural
a} :: BackupDetails)

-- | ARN associated with the backup.
backupDetails_backupArn :: Lens.Lens' BackupDetails Prelude.Text
backupDetails_backupArn :: (Text -> f Text) -> BackupDetails -> f BackupDetails
backupDetails_backupArn = (BackupDetails -> Text)
-> (BackupDetails -> Text -> BackupDetails)
-> Lens BackupDetails BackupDetails Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupDetails' {Text
backupArn :: Text
$sel:backupArn:BackupDetails' :: BackupDetails -> Text
backupArn} -> Text
backupArn) (\s :: BackupDetails
s@BackupDetails' {} Text
a -> BackupDetails
s {$sel:backupArn:BackupDetails' :: Text
backupArn = Text
a} :: BackupDetails)

-- | Name of the requested backup.
backupDetails_backupName :: Lens.Lens' BackupDetails Prelude.Text
backupDetails_backupName :: (Text -> f Text) -> BackupDetails -> f BackupDetails
backupDetails_backupName = (BackupDetails -> Text)
-> (BackupDetails -> Text -> BackupDetails)
-> Lens BackupDetails BackupDetails Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupDetails' {Text
backupName :: Text
$sel:backupName:BackupDetails' :: BackupDetails -> Text
backupName} -> Text
backupName) (\s :: BackupDetails
s@BackupDetails' {} Text
a -> BackupDetails
s {$sel:backupName:BackupDetails' :: Text
backupName = Text
a} :: BackupDetails)

-- | Backup can be in one of the following states: CREATING, ACTIVE, DELETED.
backupDetails_backupStatus :: Lens.Lens' BackupDetails BackupStatus
backupDetails_backupStatus :: (BackupStatus -> f BackupStatus)
-> BackupDetails -> f BackupDetails
backupDetails_backupStatus = (BackupDetails -> BackupStatus)
-> (BackupDetails -> BackupStatus -> BackupDetails)
-> Lens BackupDetails BackupDetails BackupStatus BackupStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupDetails' {BackupStatus
backupStatus :: BackupStatus
$sel:backupStatus:BackupDetails' :: BackupDetails -> BackupStatus
backupStatus} -> BackupStatus
backupStatus) (\s :: BackupDetails
s@BackupDetails' {} BackupStatus
a -> BackupDetails
s {$sel:backupStatus:BackupDetails' :: BackupStatus
backupStatus = BackupStatus
a} :: BackupDetails)

-- | BackupType:
--
-- -   @USER@ - You create and manage these using the on-demand backup
--     feature.
--
-- -   @SYSTEM@ - If you delete a table with point-in-time recovery
--     enabled, a @SYSTEM@ backup is automatically created and is retained
--     for 35 days (at no additional cost). System backups allow you to
--     restore the deleted table to the state it was in just before the
--     point of deletion.
--
-- -   @AWS_BACKUP@ - On-demand backup created by you from AWS Backup
--     service.
backupDetails_backupType :: Lens.Lens' BackupDetails BackupType
backupDetails_backupType :: (BackupType -> f BackupType) -> BackupDetails -> f BackupDetails
backupDetails_backupType = (BackupDetails -> BackupType)
-> (BackupDetails -> BackupType -> BackupDetails)
-> Lens BackupDetails BackupDetails BackupType BackupType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupDetails' {BackupType
backupType :: BackupType
$sel:backupType:BackupDetails' :: BackupDetails -> BackupType
backupType} -> BackupType
backupType) (\s :: BackupDetails
s@BackupDetails' {} BackupType
a -> BackupDetails
s {$sel:backupType:BackupDetails' :: BackupType
backupType = BackupType
a} :: BackupDetails)

-- | Time at which the backup was created. This is the request time of the
-- backup.
backupDetails_backupCreationDateTime :: Lens.Lens' BackupDetails Prelude.UTCTime
backupDetails_backupCreationDateTime :: (UTCTime -> f UTCTime) -> BackupDetails -> f BackupDetails
backupDetails_backupCreationDateTime = (BackupDetails -> POSIX)
-> (BackupDetails -> POSIX -> BackupDetails)
-> Lens BackupDetails BackupDetails POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupDetails' {POSIX
backupCreationDateTime :: POSIX
$sel:backupCreationDateTime:BackupDetails' :: BackupDetails -> POSIX
backupCreationDateTime} -> POSIX
backupCreationDateTime) (\s :: BackupDetails
s@BackupDetails' {} POSIX
a -> BackupDetails
s {$sel:backupCreationDateTime:BackupDetails' :: POSIX
backupCreationDateTime = POSIX
a} :: BackupDetails) ((POSIX -> f POSIX) -> BackupDetails -> f BackupDetails)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> BackupDetails
-> f BackupDetails
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

instance Core.FromJSON BackupDetails where
  parseJSON :: Value -> Parser BackupDetails
parseJSON =
    String
-> (Object -> Parser BackupDetails)
-> Value
-> Parser BackupDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BackupDetails"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Natural
-> Text
-> Text
-> BackupStatus
-> BackupType
-> POSIX
-> BackupDetails
BackupDetails'
            (Maybe POSIX
 -> Maybe Natural
 -> Text
 -> Text
 -> BackupStatus
 -> BackupType
 -> POSIX
 -> BackupDetails)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Natural
      -> Text
      -> Text
      -> BackupStatus
      -> BackupType
      -> POSIX
      -> BackupDetails)
forall (f :: * -> *) a b. Functor 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
"BackupExpiryDateTime")
            Parser
  (Maybe Natural
   -> Text
   -> Text
   -> BackupStatus
   -> BackupType
   -> POSIX
   -> BackupDetails)
-> Parser (Maybe Natural)
-> Parser
     (Text
      -> Text -> BackupStatus -> BackupType -> POSIX -> BackupDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BackupSizeBytes")
            Parser
  (Text
   -> Text -> BackupStatus -> BackupType -> POSIX -> BackupDetails)
-> Parser Text
-> Parser
     (Text -> BackupStatus -> BackupType -> POSIX -> BackupDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"BackupArn")
            Parser
  (Text -> BackupStatus -> BackupType -> POSIX -> BackupDetails)
-> Parser Text
-> Parser (BackupStatus -> BackupType -> POSIX -> BackupDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"BackupName")
            Parser (BackupStatus -> BackupType -> POSIX -> BackupDetails)
-> Parser BackupStatus
-> Parser (BackupType -> POSIX -> BackupDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser BackupStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"BackupStatus")
            Parser (BackupType -> POSIX -> BackupDetails)
-> Parser BackupType -> Parser (POSIX -> BackupDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser BackupType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"BackupType")
            Parser (POSIX -> BackupDetails)
-> Parser POSIX -> Parser BackupDetails
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
"BackupCreationDateTime")
      )

instance Prelude.Hashable BackupDetails

instance Prelude.NFData BackupDetails