{-# 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.Backup.Types.CopyAction
-- 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.Backup.Types.CopyAction where

import Amazonka.Backup.Types.Lifecycle
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The details of the copy operation.
--
-- /See:/ 'newCopyAction' smart constructor.
data CopyAction = CopyAction'
  { CopyAction -> Maybe Lifecycle
lifecycle :: Prelude.Maybe Lifecycle,
    -- | An Amazon Resource Name (ARN) that uniquely identifies the destination
    -- backup vault for the copied backup. For example,
    -- @arn:aws:backup:us-east-1:123456789012:vault:aBackupVault@.
    CopyAction -> Text
destinationBackupVaultArn :: Prelude.Text
  }
  deriving (CopyAction -> CopyAction -> Bool
(CopyAction -> CopyAction -> Bool)
-> (CopyAction -> CopyAction -> Bool) -> Eq CopyAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CopyAction -> CopyAction -> Bool
$c/= :: CopyAction -> CopyAction -> Bool
== :: CopyAction -> CopyAction -> Bool
$c== :: CopyAction -> CopyAction -> Bool
Prelude.Eq, ReadPrec [CopyAction]
ReadPrec CopyAction
Int -> ReadS CopyAction
ReadS [CopyAction]
(Int -> ReadS CopyAction)
-> ReadS [CopyAction]
-> ReadPrec CopyAction
-> ReadPrec [CopyAction]
-> Read CopyAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CopyAction]
$creadListPrec :: ReadPrec [CopyAction]
readPrec :: ReadPrec CopyAction
$creadPrec :: ReadPrec CopyAction
readList :: ReadS [CopyAction]
$creadList :: ReadS [CopyAction]
readsPrec :: Int -> ReadS CopyAction
$creadsPrec :: Int -> ReadS CopyAction
Prelude.Read, Int -> CopyAction -> ShowS
[CopyAction] -> ShowS
CopyAction -> String
(Int -> CopyAction -> ShowS)
-> (CopyAction -> String)
-> ([CopyAction] -> ShowS)
-> Show CopyAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CopyAction] -> ShowS
$cshowList :: [CopyAction] -> ShowS
show :: CopyAction -> String
$cshow :: CopyAction -> String
showsPrec :: Int -> CopyAction -> ShowS
$cshowsPrec :: Int -> CopyAction -> ShowS
Prelude.Show, (forall x. CopyAction -> Rep CopyAction x)
-> (forall x. Rep CopyAction x -> CopyAction) -> Generic CopyAction
forall x. Rep CopyAction x -> CopyAction
forall x. CopyAction -> Rep CopyAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CopyAction x -> CopyAction
$cfrom :: forall x. CopyAction -> Rep CopyAction x
Prelude.Generic)

-- |
-- Create a value of 'CopyAction' 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:
--
-- 'lifecycle', 'copyAction_lifecycle' - Undocumented member.
--
-- 'destinationBackupVaultArn', 'copyAction_destinationBackupVaultArn' - An Amazon Resource Name (ARN) that uniquely identifies the destination
-- backup vault for the copied backup. For example,
-- @arn:aws:backup:us-east-1:123456789012:vault:aBackupVault@.
newCopyAction ::
  -- | 'destinationBackupVaultArn'
  Prelude.Text ->
  CopyAction
newCopyAction :: Text -> CopyAction
newCopyAction Text
pDestinationBackupVaultArn_ =
  CopyAction' :: Maybe Lifecycle -> Text -> CopyAction
CopyAction'
    { $sel:lifecycle:CopyAction' :: Maybe Lifecycle
lifecycle = Maybe Lifecycle
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationBackupVaultArn:CopyAction' :: Text
destinationBackupVaultArn =
        Text
pDestinationBackupVaultArn_
    }

-- | Undocumented member.
copyAction_lifecycle :: Lens.Lens' CopyAction (Prelude.Maybe Lifecycle)
copyAction_lifecycle :: (Maybe Lifecycle -> f (Maybe Lifecycle))
-> CopyAction -> f CopyAction
copyAction_lifecycle = (CopyAction -> Maybe Lifecycle)
-> (CopyAction -> Maybe Lifecycle -> CopyAction)
-> Lens CopyAction CopyAction (Maybe Lifecycle) (Maybe Lifecycle)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopyAction' {Maybe Lifecycle
lifecycle :: Maybe Lifecycle
$sel:lifecycle:CopyAction' :: CopyAction -> Maybe Lifecycle
lifecycle} -> Maybe Lifecycle
lifecycle) (\s :: CopyAction
s@CopyAction' {} Maybe Lifecycle
a -> CopyAction
s {$sel:lifecycle:CopyAction' :: Maybe Lifecycle
lifecycle = Maybe Lifecycle
a} :: CopyAction)

-- | An Amazon Resource Name (ARN) that uniquely identifies the destination
-- backup vault for the copied backup. For example,
-- @arn:aws:backup:us-east-1:123456789012:vault:aBackupVault@.
copyAction_destinationBackupVaultArn :: Lens.Lens' CopyAction Prelude.Text
copyAction_destinationBackupVaultArn :: (Text -> f Text) -> CopyAction -> f CopyAction
copyAction_destinationBackupVaultArn = (CopyAction -> Text)
-> (CopyAction -> Text -> CopyAction)
-> Lens CopyAction CopyAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopyAction' {Text
destinationBackupVaultArn :: Text
$sel:destinationBackupVaultArn:CopyAction' :: CopyAction -> Text
destinationBackupVaultArn} -> Text
destinationBackupVaultArn) (\s :: CopyAction
s@CopyAction' {} Text
a -> CopyAction
s {$sel:destinationBackupVaultArn:CopyAction' :: Text
destinationBackupVaultArn = Text
a} :: CopyAction)

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

instance Prelude.Hashable CopyAction

instance Prelude.NFData CopyAction

instance Core.ToJSON CopyAction where
  toJSON :: CopyAction -> Value
toJSON CopyAction' {Maybe Lifecycle
Text
destinationBackupVaultArn :: Text
lifecycle :: Maybe Lifecycle
$sel:destinationBackupVaultArn:CopyAction' :: CopyAction -> Text
$sel:lifecycle:CopyAction' :: CopyAction -> Maybe Lifecycle
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Lifecycle" Text -> Lifecycle -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Lifecycle -> Pair) -> Maybe Lifecycle -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Lifecycle
lifecycle,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"DestinationBackupVaultArn"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
destinationBackupVaultArn
              )
          ]
      )