{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 display name of a backup plan. Must contain 1 to 50 alphanumeric or
    -- \'-_.\' characters.
    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
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
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. 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 display name of a backup plan. Must contain 1 to 50 alphanumeric or
-- \'-_.\' characters.
--
-- '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'
    { $sel:advancedBackupSettings:BackupPlanInput' :: Maybe [AdvancedBackupSetting]
advancedBackupSettings =
        forall a. Maybe a
Prelude.Nothing,
      $sel:backupPlanName:BackupPlanInput' :: Text
backupPlanName = Text
pBackupPlanName_,
      $sel:rules:BackupPlanInput' :: [BackupRuleInput]
rules = 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 :: Lens' BackupPlanInput (Maybe [AdvancedBackupSetting])
backupPlanInput_advancedBackupSettings = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The display name of a backup plan. Must contain 1 to 50 alphanumeric or
-- \'-_.\' characters.
backupPlanInput_backupPlanName :: Lens.Lens' BackupPlanInput Prelude.Text
backupPlanInput_backupPlanName :: Lens' BackupPlanInput Text
backupPlanInput_backupPlanName = 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 :: Lens' BackupPlanInput [BackupRuleInput]
backupPlanInput_rules = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable BackupPlanInput where
  hashWithSalt :: Int -> BackupPlanInput -> Int
hashWithSalt Int
_salt 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]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AdvancedBackupSetting]
advancedBackupSettings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
backupPlanName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [BackupRuleInput]
rules

instance Prelude.NFData BackupPlanInput where
  rnf :: BackupPlanInput -> ()
rnf 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]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AdvancedBackupSetting]
advancedBackupSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
backupPlanName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [BackupRuleInput]
rules

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AdvancedBackupSettings" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AdvancedBackupSetting]
advancedBackupSettings,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"BackupPlanName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
backupPlanName),
            forall a. a -> Maybe a
Prelude.Just (Key
"Rules" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [BackupRuleInput]
rules)
          ]
      )