{-# 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.CloudHSMV2.Types.DestinationBackup
-- 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.CloudHSMV2.Types.DestinationBackup where

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

-- | Contains information about the backup that will be copied and created by
-- the CopyBackupToRegion operation.
--
-- /See:/ 'newDestinationBackup' smart constructor.
data DestinationBackup = DestinationBackup'
  { -- | The identifier (ID) of the cluster containing the source backup from
    -- which the new backup was copied.
    DestinationBackup -> Maybe Text
sourceCluster :: Prelude.Maybe Prelude.Text,
    -- | The AWS region that contains the source backup from which the new backup
    -- was copied.
    DestinationBackup -> Maybe Text
sourceRegion :: Prelude.Maybe Prelude.Text,
    -- | The identifier (ID) of the source backup from which the new backup was
    -- copied.
    DestinationBackup -> Maybe Text
sourceBackup :: Prelude.Maybe Prelude.Text,
    -- | The date and time when both the source backup was created.
    DestinationBackup -> Maybe POSIX
createTimestamp :: Prelude.Maybe Core.POSIX
  }
  deriving (DestinationBackup -> DestinationBackup -> Bool
(DestinationBackup -> DestinationBackup -> Bool)
-> (DestinationBackup -> DestinationBackup -> Bool)
-> Eq DestinationBackup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DestinationBackup -> DestinationBackup -> Bool
$c/= :: DestinationBackup -> DestinationBackup -> Bool
== :: DestinationBackup -> DestinationBackup -> Bool
$c== :: DestinationBackup -> DestinationBackup -> Bool
Prelude.Eq, ReadPrec [DestinationBackup]
ReadPrec DestinationBackup
Int -> ReadS DestinationBackup
ReadS [DestinationBackup]
(Int -> ReadS DestinationBackup)
-> ReadS [DestinationBackup]
-> ReadPrec DestinationBackup
-> ReadPrec [DestinationBackup]
-> Read DestinationBackup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DestinationBackup]
$creadListPrec :: ReadPrec [DestinationBackup]
readPrec :: ReadPrec DestinationBackup
$creadPrec :: ReadPrec DestinationBackup
readList :: ReadS [DestinationBackup]
$creadList :: ReadS [DestinationBackup]
readsPrec :: Int -> ReadS DestinationBackup
$creadsPrec :: Int -> ReadS DestinationBackup
Prelude.Read, Int -> DestinationBackup -> ShowS
[DestinationBackup] -> ShowS
DestinationBackup -> String
(Int -> DestinationBackup -> ShowS)
-> (DestinationBackup -> String)
-> ([DestinationBackup] -> ShowS)
-> Show DestinationBackup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DestinationBackup] -> ShowS
$cshowList :: [DestinationBackup] -> ShowS
show :: DestinationBackup -> String
$cshow :: DestinationBackup -> String
showsPrec :: Int -> DestinationBackup -> ShowS
$cshowsPrec :: Int -> DestinationBackup -> ShowS
Prelude.Show, (forall x. DestinationBackup -> Rep DestinationBackup x)
-> (forall x. Rep DestinationBackup x -> DestinationBackup)
-> Generic DestinationBackup
forall x. Rep DestinationBackup x -> DestinationBackup
forall x. DestinationBackup -> Rep DestinationBackup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DestinationBackup x -> DestinationBackup
$cfrom :: forall x. DestinationBackup -> Rep DestinationBackup x
Prelude.Generic)

-- |
-- Create a value of 'DestinationBackup' 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:
--
-- 'sourceCluster', 'destinationBackup_sourceCluster' - The identifier (ID) of the cluster containing the source backup from
-- which the new backup was copied.
--
-- 'sourceRegion', 'destinationBackup_sourceRegion' - The AWS region that contains the source backup from which the new backup
-- was copied.
--
-- 'sourceBackup', 'destinationBackup_sourceBackup' - The identifier (ID) of the source backup from which the new backup was
-- copied.
--
-- 'createTimestamp', 'destinationBackup_createTimestamp' - The date and time when both the source backup was created.
newDestinationBackup ::
  DestinationBackup
newDestinationBackup :: DestinationBackup
newDestinationBackup =
  DestinationBackup' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe POSIX -> DestinationBackup
DestinationBackup'
    { $sel:sourceCluster:DestinationBackup' :: Maybe Text
sourceCluster = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceRegion:DestinationBackup' :: Maybe Text
sourceRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceBackup:DestinationBackup' :: Maybe Text
sourceBackup = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createTimestamp:DestinationBackup' :: Maybe POSIX
createTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier (ID) of the cluster containing the source backup from
-- which the new backup was copied.
destinationBackup_sourceCluster :: Lens.Lens' DestinationBackup (Prelude.Maybe Prelude.Text)
destinationBackup_sourceCluster :: (Maybe Text -> f (Maybe Text))
-> DestinationBackup -> f DestinationBackup
destinationBackup_sourceCluster = (DestinationBackup -> Maybe Text)
-> (DestinationBackup -> Maybe Text -> DestinationBackup)
-> Lens
     DestinationBackup DestinationBackup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationBackup' {Maybe Text
sourceCluster :: Maybe Text
$sel:sourceCluster:DestinationBackup' :: DestinationBackup -> Maybe Text
sourceCluster} -> Maybe Text
sourceCluster) (\s :: DestinationBackup
s@DestinationBackup' {} Maybe Text
a -> DestinationBackup
s {$sel:sourceCluster:DestinationBackup' :: Maybe Text
sourceCluster = Maybe Text
a} :: DestinationBackup)

-- | The AWS region that contains the source backup from which the new backup
-- was copied.
destinationBackup_sourceRegion :: Lens.Lens' DestinationBackup (Prelude.Maybe Prelude.Text)
destinationBackup_sourceRegion :: (Maybe Text -> f (Maybe Text))
-> DestinationBackup -> f DestinationBackup
destinationBackup_sourceRegion = (DestinationBackup -> Maybe Text)
-> (DestinationBackup -> Maybe Text -> DestinationBackup)
-> Lens
     DestinationBackup DestinationBackup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationBackup' {Maybe Text
sourceRegion :: Maybe Text
$sel:sourceRegion:DestinationBackup' :: DestinationBackup -> Maybe Text
sourceRegion} -> Maybe Text
sourceRegion) (\s :: DestinationBackup
s@DestinationBackup' {} Maybe Text
a -> DestinationBackup
s {$sel:sourceRegion:DestinationBackup' :: Maybe Text
sourceRegion = Maybe Text
a} :: DestinationBackup)

-- | The identifier (ID) of the source backup from which the new backup was
-- copied.
destinationBackup_sourceBackup :: Lens.Lens' DestinationBackup (Prelude.Maybe Prelude.Text)
destinationBackup_sourceBackup :: (Maybe Text -> f (Maybe Text))
-> DestinationBackup -> f DestinationBackup
destinationBackup_sourceBackup = (DestinationBackup -> Maybe Text)
-> (DestinationBackup -> Maybe Text -> DestinationBackup)
-> Lens
     DestinationBackup DestinationBackup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationBackup' {Maybe Text
sourceBackup :: Maybe Text
$sel:sourceBackup:DestinationBackup' :: DestinationBackup -> Maybe Text
sourceBackup} -> Maybe Text
sourceBackup) (\s :: DestinationBackup
s@DestinationBackup' {} Maybe Text
a -> DestinationBackup
s {$sel:sourceBackup:DestinationBackup' :: Maybe Text
sourceBackup = Maybe Text
a} :: DestinationBackup)

-- | The date and time when both the source backup was created.
destinationBackup_createTimestamp :: Lens.Lens' DestinationBackup (Prelude.Maybe Prelude.UTCTime)
destinationBackup_createTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DestinationBackup -> f DestinationBackup
destinationBackup_createTimestamp = (DestinationBackup -> Maybe POSIX)
-> (DestinationBackup -> Maybe POSIX -> DestinationBackup)
-> Lens
     DestinationBackup DestinationBackup (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationBackup' {Maybe POSIX
createTimestamp :: Maybe POSIX
$sel:createTimestamp:DestinationBackup' :: DestinationBackup -> Maybe POSIX
createTimestamp} -> Maybe POSIX
createTimestamp) (\s :: DestinationBackup
s@DestinationBackup' {} Maybe POSIX
a -> DestinationBackup
s {$sel:createTimestamp:DestinationBackup' :: Maybe POSIX
createTimestamp = Maybe POSIX
a} :: DestinationBackup) ((Maybe POSIX -> f (Maybe POSIX))
 -> DestinationBackup -> f DestinationBackup)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DestinationBackup
-> f DestinationBackup
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 DestinationBackup where
  parseJSON :: Value -> Parser DestinationBackup
parseJSON =
    String
-> (Object -> Parser DestinationBackup)
-> Value
-> Parser DestinationBackup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DestinationBackup"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe POSIX -> DestinationBackup
DestinationBackup'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe POSIX -> DestinationBackup)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe POSIX -> DestinationBackup)
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
"SourceCluster")
            Parser
  (Maybe Text -> Maybe Text -> Maybe POSIX -> DestinationBackup)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe POSIX -> DestinationBackup)
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
"SourceRegion")
            Parser (Maybe Text -> Maybe POSIX -> DestinationBackup)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> DestinationBackup)
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
"SourceBackup")
            Parser (Maybe POSIX -> DestinationBackup)
-> Parser (Maybe POSIX) -> Parser DestinationBackup
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
"CreateTimestamp")
      )

instance Prelude.Hashable DestinationBackup

instance Prelude.NFData DestinationBackup