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

import Amazonka.Backup.Types.AdvancedBackupSetting
import Amazonka.Backup.Types.BackupRuleInput
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains an optional backup plan display name and an array of
-- @BackupRule@ objects, each of which specifies a backup rule. Each rule
-- in a backup plan is a separate scheduled task.
--
-- /See:/ 'newBackupPlanInput' smart constructor.
data BackupPlanInput = BackupPlanInput'
  { -- | Specifies a list of @BackupOptions@ for each resource type. These
    -- settings are only available for Windows Volume Shadow Copy Service (VSS)
    -- backup jobs.
    BackupPlanInput -> Maybe [AdvancedBackupSetting]
advancedBackupSettings :: Prelude.Maybe [AdvancedBackupSetting],
    -- | The optional display name of a backup plan.
    BackupPlanInput -> Text
backupPlanName :: Prelude.Text,
    -- | An array of @BackupRule@ objects, each of which specifies a scheduled
    -- task that is used to back up a selection of resources.
    BackupPlanInput -> [BackupRuleInput]
rules :: [BackupRuleInput]
  }
  deriving (BackupPlanInput -> BackupPlanInput -> Bool
(BackupPlanInput -> BackupPlanInput -> Bool)
-> (BackupPlanInput -> BackupPlanInput -> Bool)
-> Eq BackupPlanInput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BackupPlanInput -> BackupPlanInput -> Bool
$c/= :: BackupPlanInput -> BackupPlanInput -> Bool
== :: BackupPlanInput -> BackupPlanInput -> Bool
$c== :: BackupPlanInput -> BackupPlanInput -> Bool
Prelude.Eq, Int -> BackupPlanInput -> ShowS
[BackupPlanInput] -> ShowS
BackupPlanInput -> String
(Int -> BackupPlanInput -> ShowS)
-> (BackupPlanInput -> String)
-> ([BackupPlanInput] -> ShowS)
-> Show BackupPlanInput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BackupPlanInput] -> ShowS
$cshowList :: [BackupPlanInput] -> ShowS
show :: BackupPlanInput -> String
$cshow :: BackupPlanInput -> String
showsPrec :: Int -> BackupPlanInput -> ShowS
$cshowsPrec :: Int -> BackupPlanInput -> ShowS
Prelude.Show, (forall x. BackupPlanInput -> Rep BackupPlanInput x)
-> (forall x. Rep BackupPlanInput x -> BackupPlanInput)
-> Generic BackupPlanInput
forall x. Rep BackupPlanInput x -> BackupPlanInput
forall x. BackupPlanInput -> Rep BackupPlanInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BackupPlanInput x -> BackupPlanInput
$cfrom :: forall x. BackupPlanInput -> Rep BackupPlanInput x
Prelude.Generic)

-- |
-- Create a value of 'BackupPlanInput' 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:
--
-- 'advancedBackupSettings', 'backupPlanInput_advancedBackupSettings' - Specifies a list of @BackupOptions@ for each resource type. These
-- settings are only available for Windows Volume Shadow Copy Service (VSS)
-- backup jobs.
--
-- 'backupPlanName', 'backupPlanInput_backupPlanName' - The optional display name of a backup plan.
--
-- 'rules', 'backupPlanInput_rules' - An array of @BackupRule@ objects, each of which specifies a scheduled
-- task that is used to back up a selection of resources.
newBackupPlanInput ::
  -- | 'backupPlanName'
  Prelude.Text ->
  BackupPlanInput
newBackupPlanInput :: Text -> BackupPlanInput
newBackupPlanInput Text
pBackupPlanName_ =
  BackupPlanInput' :: Maybe [AdvancedBackupSetting]
-> Text -> [BackupRuleInput] -> BackupPlanInput
BackupPlanInput'
    { $sel:advancedBackupSettings:BackupPlanInput' :: Maybe [AdvancedBackupSetting]
advancedBackupSettings =
        Maybe [AdvancedBackupSetting]
forall a. Maybe a
Prelude.Nothing,
      $sel:backupPlanName:BackupPlanInput' :: Text
backupPlanName = Text
pBackupPlanName_,
      $sel:rules:BackupPlanInput' :: [BackupRuleInput]
rules = [BackupRuleInput]
forall a. Monoid a => a
Prelude.mempty
    }

-- | Specifies a list of @BackupOptions@ for each resource type. These
-- settings are only available for Windows Volume Shadow Copy Service (VSS)
-- backup jobs.
backupPlanInput_advancedBackupSettings :: Lens.Lens' BackupPlanInput (Prelude.Maybe [AdvancedBackupSetting])
backupPlanInput_advancedBackupSettings :: (Maybe [AdvancedBackupSetting]
 -> f (Maybe [AdvancedBackupSetting]))
-> BackupPlanInput -> f BackupPlanInput
backupPlanInput_advancedBackupSettings = (BackupPlanInput -> Maybe [AdvancedBackupSetting])
-> (BackupPlanInput
    -> Maybe [AdvancedBackupSetting] -> BackupPlanInput)
-> Lens
     BackupPlanInput
     BackupPlanInput
     (Maybe [AdvancedBackupSetting])
     (Maybe [AdvancedBackupSetting])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupPlanInput' {Maybe [AdvancedBackupSetting]
advancedBackupSettings :: Maybe [AdvancedBackupSetting]
$sel:advancedBackupSettings:BackupPlanInput' :: BackupPlanInput -> Maybe [AdvancedBackupSetting]
advancedBackupSettings} -> Maybe [AdvancedBackupSetting]
advancedBackupSettings) (\s :: BackupPlanInput
s@BackupPlanInput' {} Maybe [AdvancedBackupSetting]
a -> BackupPlanInput
s {$sel:advancedBackupSettings:BackupPlanInput' :: Maybe [AdvancedBackupSetting]
advancedBackupSettings = Maybe [AdvancedBackupSetting]
a} :: BackupPlanInput) ((Maybe [AdvancedBackupSetting]
  -> f (Maybe [AdvancedBackupSetting]))
 -> BackupPlanInput -> f BackupPlanInput)
-> ((Maybe [AdvancedBackupSetting]
     -> f (Maybe [AdvancedBackupSetting]))
    -> Maybe [AdvancedBackupSetting]
    -> f (Maybe [AdvancedBackupSetting]))
-> (Maybe [AdvancedBackupSetting]
    -> f (Maybe [AdvancedBackupSetting]))
-> BackupPlanInput
-> f BackupPlanInput
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AdvancedBackupSetting]
  [AdvancedBackupSetting]
  [AdvancedBackupSetting]
  [AdvancedBackupSetting]
-> Iso
     (Maybe [AdvancedBackupSetting])
     (Maybe [AdvancedBackupSetting])
     (Maybe [AdvancedBackupSetting])
     (Maybe [AdvancedBackupSetting])
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
  [AdvancedBackupSetting]
  [AdvancedBackupSetting]
  [AdvancedBackupSetting]
  [AdvancedBackupSetting]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The optional display name of a backup plan.
backupPlanInput_backupPlanName :: Lens.Lens' BackupPlanInput Prelude.Text
backupPlanInput_backupPlanName :: (Text -> f Text) -> BackupPlanInput -> f BackupPlanInput
backupPlanInput_backupPlanName = (BackupPlanInput -> Text)
-> (BackupPlanInput -> Text -> BackupPlanInput)
-> Lens BackupPlanInput BackupPlanInput Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupPlanInput' {Text
backupPlanName :: Text
$sel:backupPlanName:BackupPlanInput' :: BackupPlanInput -> Text
backupPlanName} -> Text
backupPlanName) (\s :: BackupPlanInput
s@BackupPlanInput' {} Text
a -> BackupPlanInput
s {$sel:backupPlanName:BackupPlanInput' :: Text
backupPlanName = Text
a} :: BackupPlanInput)

-- | An array of @BackupRule@ objects, each of which specifies a scheduled
-- task that is used to back up a selection of resources.
backupPlanInput_rules :: Lens.Lens' BackupPlanInput [BackupRuleInput]
backupPlanInput_rules :: ([BackupRuleInput] -> f [BackupRuleInput])
-> BackupPlanInput -> f BackupPlanInput
backupPlanInput_rules = (BackupPlanInput -> [BackupRuleInput])
-> (BackupPlanInput -> [BackupRuleInput] -> BackupPlanInput)
-> Lens
     BackupPlanInput BackupPlanInput [BackupRuleInput] [BackupRuleInput]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupPlanInput' {[BackupRuleInput]
rules :: [BackupRuleInput]
$sel:rules:BackupPlanInput' :: BackupPlanInput -> [BackupRuleInput]
rules} -> [BackupRuleInput]
rules) (\s :: BackupPlanInput
s@BackupPlanInput' {} [BackupRuleInput]
a -> BackupPlanInput
s {$sel:rules:BackupPlanInput' :: [BackupRuleInput]
rules = [BackupRuleInput]
a} :: BackupPlanInput) (([BackupRuleInput] -> f [BackupRuleInput])
 -> BackupPlanInput -> f BackupPlanInput)
-> (([BackupRuleInput] -> f [BackupRuleInput])
    -> [BackupRuleInput] -> f [BackupRuleInput])
-> ([BackupRuleInput] -> f [BackupRuleInput])
-> BackupPlanInput
-> f BackupPlanInput
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([BackupRuleInput] -> f [BackupRuleInput])
-> [BackupRuleInput] -> f [BackupRuleInput]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable BackupPlanInput

instance Prelude.NFData BackupPlanInput

instance Core.ToJSON BackupPlanInput where
  toJSON :: BackupPlanInput -> Value
toJSON BackupPlanInput' {[BackupRuleInput]
Maybe [AdvancedBackupSetting]
Text
rules :: [BackupRuleInput]
backupPlanName :: Text
advancedBackupSettings :: Maybe [AdvancedBackupSetting]
$sel:rules:BackupPlanInput' :: BackupPlanInput -> [BackupRuleInput]
$sel:backupPlanName:BackupPlanInput' :: BackupPlanInput -> Text
$sel:advancedBackupSettings:BackupPlanInput' :: BackupPlanInput -> Maybe [AdvancedBackupSetting]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AdvancedBackupSettings" Text -> [AdvancedBackupSetting] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([AdvancedBackupSetting] -> Pair)
-> Maybe [AdvancedBackupSetting] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AdvancedBackupSetting]
advancedBackupSettings,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"BackupPlanName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
backupPlanName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Rules" Text -> [BackupRuleInput] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [BackupRuleInput]
rules)
          ]
      )