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

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

-- | Specifies a scheduled task used to back up a selection of resources.
--
-- /See:/ 'newBackupRule' smart constructor.
data BackupRule = BackupRule'
  { -- | Uniquely identifies a rule that is used to schedule the backup of a
    -- selection of resources.
    BackupRule -> Maybe Text
ruleId :: Prelude.Maybe Prelude.Text,
    -- | The lifecycle defines when a protected resource is transitioned to cold
    -- storage and when it expires. Backup transitions and expires backups
    -- automatically according to the lifecycle that you define.
    --
    -- Backups transitioned to cold storage must be stored in cold storage for
    -- a minimum of 90 days. Therefore, the “expire after days” setting must be
    -- 90 days greater than the “transition to cold after days” setting. The
    -- “transition to cold after days” setting cannot be changed after a backup
    -- has been transitioned to cold.
    --
    -- Only Amazon EFS file system backups can be transitioned to cold storage.
    BackupRule -> Maybe Lifecycle
lifecycle :: Prelude.Maybe Lifecycle,
    -- | An array of key-value pair strings that are assigned to resources that
    -- are associated with this rule when restored from backup.
    BackupRule -> Maybe (Sensitive (HashMap Text Text))
recoveryPointTags :: Prelude.Maybe (Core.Sensitive (Prelude.HashMap Prelude.Text Prelude.Text)),
    -- | A cron expression in UTC specifying when Backup initiates a backup job.
    -- For more information about cron expressions, see
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html Schedule Expressions for Rules>
    -- in the /Amazon CloudWatch Events User Guide./. Prior to specifying a
    -- value for this parameter, we recommend testing your cron expression
    -- using one of the many available cron generator and testing tools.
    BackupRule -> Maybe Text
scheduleExpression :: Prelude.Maybe Prelude.Text,
    -- | Specifies whether Backup creates continuous backups. True causes Backup
    -- to create continuous backups capable of point-in-time restore (PITR).
    -- False (or not specified) causes Backup to create snapshot backups.
    BackupRule -> Maybe Bool
enableContinuousBackup :: Prelude.Maybe Prelude.Bool,
    -- | A value in minutes after a backup job is successfully started before it
    -- must be completed or it will be canceled by Backup. This value is
    -- optional.
    BackupRule -> Maybe Integer
completionWindowMinutes :: Prelude.Maybe Prelude.Integer,
    -- | An array of @CopyAction@ objects, which contains the details of the copy
    -- operation.
    BackupRule -> Maybe [CopyAction]
copyActions :: Prelude.Maybe [CopyAction],
    -- | A value in minutes after a backup is scheduled before a job will be
    -- canceled if it doesn\'t start successfully. This value is optional.
    BackupRule -> Maybe Integer
startWindowMinutes :: Prelude.Maybe Prelude.Integer,
    -- | An optional display name for a backup rule.
    BackupRule -> Text
ruleName :: Prelude.Text,
    -- | The name of a logical container where backups are stored. Backup vaults
    -- are identified by names that are unique to the account used to create
    -- them and the Amazon Web Services Region where they are created. They
    -- consist of lowercase letters, numbers, and hyphens.
    BackupRule -> Text
targetBackupVaultName :: Prelude.Text
  }
  deriving (BackupRule -> BackupRule -> Bool
(BackupRule -> BackupRule -> Bool)
-> (BackupRule -> BackupRule -> Bool) -> Eq BackupRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BackupRule -> BackupRule -> Bool
$c/= :: BackupRule -> BackupRule -> Bool
== :: BackupRule -> BackupRule -> Bool
$c== :: BackupRule -> BackupRule -> Bool
Prelude.Eq, Int -> BackupRule -> ShowS
[BackupRule] -> ShowS
BackupRule -> String
(Int -> BackupRule -> ShowS)
-> (BackupRule -> String)
-> ([BackupRule] -> ShowS)
-> Show BackupRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BackupRule] -> ShowS
$cshowList :: [BackupRule] -> ShowS
show :: BackupRule -> String
$cshow :: BackupRule -> String
showsPrec :: Int -> BackupRule -> ShowS
$cshowsPrec :: Int -> BackupRule -> ShowS
Prelude.Show, (forall x. BackupRule -> Rep BackupRule x)
-> (forall x. Rep BackupRule x -> BackupRule) -> Generic BackupRule
forall x. Rep BackupRule x -> BackupRule
forall x. BackupRule -> Rep BackupRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BackupRule x -> BackupRule
$cfrom :: forall x. BackupRule -> Rep BackupRule x
Prelude.Generic)

-- |
-- Create a value of 'BackupRule' 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:
--
-- 'ruleId', 'backupRule_ruleId' - Uniquely identifies a rule that is used to schedule the backup of a
-- selection of resources.
--
-- 'lifecycle', 'backupRule_lifecycle' - The lifecycle defines when a protected resource is transitioned to cold
-- storage and when it expires. Backup transitions and expires backups
-- automatically according to the lifecycle that you define.
--
-- Backups transitioned to cold storage must be stored in cold storage for
-- a minimum of 90 days. Therefore, the “expire after days” setting must be
-- 90 days greater than the “transition to cold after days” setting. The
-- “transition to cold after days” setting cannot be changed after a backup
-- has been transitioned to cold.
--
-- Only Amazon EFS file system backups can be transitioned to cold storage.
--
-- 'recoveryPointTags', 'backupRule_recoveryPointTags' - An array of key-value pair strings that are assigned to resources that
-- are associated with this rule when restored from backup.
--
-- 'scheduleExpression', 'backupRule_scheduleExpression' - A cron expression in UTC specifying when Backup initiates a backup job.
-- For more information about cron expressions, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html Schedule Expressions for Rules>
-- in the /Amazon CloudWatch Events User Guide./. Prior to specifying a
-- value for this parameter, we recommend testing your cron expression
-- using one of the many available cron generator and testing tools.
--
-- 'enableContinuousBackup', 'backupRule_enableContinuousBackup' - Specifies whether Backup creates continuous backups. True causes Backup
-- to create continuous backups capable of point-in-time restore (PITR).
-- False (or not specified) causes Backup to create snapshot backups.
--
-- 'completionWindowMinutes', 'backupRule_completionWindowMinutes' - A value in minutes after a backup job is successfully started before it
-- must be completed or it will be canceled by Backup. This value is
-- optional.
--
-- 'copyActions', 'backupRule_copyActions' - An array of @CopyAction@ objects, which contains the details of the copy
-- operation.
--
-- 'startWindowMinutes', 'backupRule_startWindowMinutes' - A value in minutes after a backup is scheduled before a job will be
-- canceled if it doesn\'t start successfully. This value is optional.
--
-- 'ruleName', 'backupRule_ruleName' - An optional display name for a backup rule.
--
-- 'targetBackupVaultName', 'backupRule_targetBackupVaultName' - The name of a logical container where backups are stored. Backup vaults
-- are identified by names that are unique to the account used to create
-- them and the Amazon Web Services Region where they are created. They
-- consist of lowercase letters, numbers, and hyphens.
newBackupRule ::
  -- | 'ruleName'
  Prelude.Text ->
  -- | 'targetBackupVaultName'
  Prelude.Text ->
  BackupRule
newBackupRule :: Text -> Text -> BackupRule
newBackupRule Text
pRuleName_ Text
pTargetBackupVaultName_ =
  BackupRule' :: Maybe Text
-> Maybe Lifecycle
-> Maybe (Sensitive (HashMap Text Text))
-> Maybe Text
-> Maybe Bool
-> Maybe Integer
-> Maybe [CopyAction]
-> Maybe Integer
-> Text
-> Text
-> BackupRule
BackupRule'
    { $sel:ruleId:BackupRule' :: Maybe Text
ruleId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lifecycle:BackupRule' :: Maybe Lifecycle
lifecycle = Maybe Lifecycle
forall a. Maybe a
Prelude.Nothing,
      $sel:recoveryPointTags:BackupRule' :: Maybe (Sensitive (HashMap Text Text))
recoveryPointTags = Maybe (Sensitive (HashMap Text Text))
forall a. Maybe a
Prelude.Nothing,
      $sel:scheduleExpression:BackupRule' :: Maybe Text
scheduleExpression = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:enableContinuousBackup:BackupRule' :: Maybe Bool
enableContinuousBackup = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:completionWindowMinutes:BackupRule' :: Maybe Integer
completionWindowMinutes = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:copyActions:BackupRule' :: Maybe [CopyAction]
copyActions = Maybe [CopyAction]
forall a. Maybe a
Prelude.Nothing,
      $sel:startWindowMinutes:BackupRule' :: Maybe Integer
startWindowMinutes = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleName:BackupRule' :: Text
ruleName = Text
pRuleName_,
      $sel:targetBackupVaultName:BackupRule' :: Text
targetBackupVaultName = Text
pTargetBackupVaultName_
    }

-- | Uniquely identifies a rule that is used to schedule the backup of a
-- selection of resources.
backupRule_ruleId :: Lens.Lens' BackupRule (Prelude.Maybe Prelude.Text)
backupRule_ruleId :: (Maybe Text -> f (Maybe Text)) -> BackupRule -> f BackupRule
backupRule_ruleId = (BackupRule -> Maybe Text)
-> (BackupRule -> Maybe Text -> BackupRule)
-> Lens BackupRule BackupRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupRule' {Maybe Text
ruleId :: Maybe Text
$sel:ruleId:BackupRule' :: BackupRule -> Maybe Text
ruleId} -> Maybe Text
ruleId) (\s :: BackupRule
s@BackupRule' {} Maybe Text
a -> BackupRule
s {$sel:ruleId:BackupRule' :: Maybe Text
ruleId = Maybe Text
a} :: BackupRule)

-- | The lifecycle defines when a protected resource is transitioned to cold
-- storage and when it expires. Backup transitions and expires backups
-- automatically according to the lifecycle that you define.
--
-- Backups transitioned to cold storage must be stored in cold storage for
-- a minimum of 90 days. Therefore, the “expire after days” setting must be
-- 90 days greater than the “transition to cold after days” setting. The
-- “transition to cold after days” setting cannot be changed after a backup
-- has been transitioned to cold.
--
-- Only Amazon EFS file system backups can be transitioned to cold storage.
backupRule_lifecycle :: Lens.Lens' BackupRule (Prelude.Maybe Lifecycle)
backupRule_lifecycle :: (Maybe Lifecycle -> f (Maybe Lifecycle))
-> BackupRule -> f BackupRule
backupRule_lifecycle = (BackupRule -> Maybe Lifecycle)
-> (BackupRule -> Maybe Lifecycle -> BackupRule)
-> Lens BackupRule BackupRule (Maybe Lifecycle) (Maybe Lifecycle)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupRule' {Maybe Lifecycle
lifecycle :: Maybe Lifecycle
$sel:lifecycle:BackupRule' :: BackupRule -> Maybe Lifecycle
lifecycle} -> Maybe Lifecycle
lifecycle) (\s :: BackupRule
s@BackupRule' {} Maybe Lifecycle
a -> BackupRule
s {$sel:lifecycle:BackupRule' :: Maybe Lifecycle
lifecycle = Maybe Lifecycle
a} :: BackupRule)

-- | An array of key-value pair strings that are assigned to resources that
-- are associated with this rule when restored from backup.
backupRule_recoveryPointTags :: Lens.Lens' BackupRule (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
backupRule_recoveryPointTags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> BackupRule -> f BackupRule
backupRule_recoveryPointTags = (BackupRule -> Maybe (Sensitive (HashMap Text Text)))
-> (BackupRule
    -> Maybe (Sensitive (HashMap Text Text)) -> BackupRule)
-> Lens
     BackupRule
     BackupRule
     (Maybe (Sensitive (HashMap Text Text)))
     (Maybe (Sensitive (HashMap Text Text)))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupRule' {Maybe (Sensitive (HashMap Text Text))
recoveryPointTags :: Maybe (Sensitive (HashMap Text Text))
$sel:recoveryPointTags:BackupRule' :: BackupRule -> Maybe (Sensitive (HashMap Text Text))
recoveryPointTags} -> Maybe (Sensitive (HashMap Text Text))
recoveryPointTags) (\s :: BackupRule
s@BackupRule' {} Maybe (Sensitive (HashMap Text Text))
a -> BackupRule
s {$sel:recoveryPointTags:BackupRule' :: Maybe (Sensitive (HashMap Text Text))
recoveryPointTags = Maybe (Sensitive (HashMap Text Text))
a} :: BackupRule) ((Maybe (Sensitive (HashMap Text Text))
  -> f (Maybe (Sensitive (HashMap Text Text))))
 -> BackupRule -> f BackupRule)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (Sensitive (HashMap Text Text))
    -> f (Maybe (Sensitive (HashMap Text Text))))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> BackupRule
-> f BackupRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (Sensitive (HashMap Text Text))
  (Sensitive (HashMap Text Text))
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (Sensitive (HashMap Text Text)))
     (Maybe (Sensitive (HashMap Text Text)))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (Sensitive (HashMap Text Text))
  (Sensitive (HashMap Text Text))
  (HashMap Text Text)
  (HashMap Text Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive AnIso
  (Sensitive (HashMap Text Text))
  (Sensitive (HashMap Text Text))
  (HashMap Text Text)
  (HashMap Text Text)
-> (Exchange
      (HashMap Text Text)
      (HashMap Text Text)
      (HashMap Text Text)
      (Identity (HashMap Text Text))
    -> Exchange
         (HashMap Text Text)
         (HashMap Text Text)
         (HashMap Text Text)
         (Identity (HashMap Text Text)))
-> AnIso
     (Sensitive (HashMap Text Text))
     (Sensitive (HashMap Text Text))
     (HashMap Text Text)
     (HashMap Text Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Exchange
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (Identity (HashMap Text Text))
-> Exchange
     (HashMap Text Text)
     (HashMap Text Text)
     (HashMap Text Text)
     (Identity (HashMap Text Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced)

-- | A cron expression in UTC specifying when Backup initiates a backup job.
-- For more information about cron expressions, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html Schedule Expressions for Rules>
-- in the /Amazon CloudWatch Events User Guide./. Prior to specifying a
-- value for this parameter, we recommend testing your cron expression
-- using one of the many available cron generator and testing tools.
backupRule_scheduleExpression :: Lens.Lens' BackupRule (Prelude.Maybe Prelude.Text)
backupRule_scheduleExpression :: (Maybe Text -> f (Maybe Text)) -> BackupRule -> f BackupRule
backupRule_scheduleExpression = (BackupRule -> Maybe Text)
-> (BackupRule -> Maybe Text -> BackupRule)
-> Lens BackupRule BackupRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupRule' {Maybe Text
scheduleExpression :: Maybe Text
$sel:scheduleExpression:BackupRule' :: BackupRule -> Maybe Text
scheduleExpression} -> Maybe Text
scheduleExpression) (\s :: BackupRule
s@BackupRule' {} Maybe Text
a -> BackupRule
s {$sel:scheduleExpression:BackupRule' :: Maybe Text
scheduleExpression = Maybe Text
a} :: BackupRule)

-- | Specifies whether Backup creates continuous backups. True causes Backup
-- to create continuous backups capable of point-in-time restore (PITR).
-- False (or not specified) causes Backup to create snapshot backups.
backupRule_enableContinuousBackup :: Lens.Lens' BackupRule (Prelude.Maybe Prelude.Bool)
backupRule_enableContinuousBackup :: (Maybe Bool -> f (Maybe Bool)) -> BackupRule -> f BackupRule
backupRule_enableContinuousBackup = (BackupRule -> Maybe Bool)
-> (BackupRule -> Maybe Bool -> BackupRule)
-> Lens BackupRule BackupRule (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupRule' {Maybe Bool
enableContinuousBackup :: Maybe Bool
$sel:enableContinuousBackup:BackupRule' :: BackupRule -> Maybe Bool
enableContinuousBackup} -> Maybe Bool
enableContinuousBackup) (\s :: BackupRule
s@BackupRule' {} Maybe Bool
a -> BackupRule
s {$sel:enableContinuousBackup:BackupRule' :: Maybe Bool
enableContinuousBackup = Maybe Bool
a} :: BackupRule)

-- | A value in minutes after a backup job is successfully started before it
-- must be completed or it will be canceled by Backup. This value is
-- optional.
backupRule_completionWindowMinutes :: Lens.Lens' BackupRule (Prelude.Maybe Prelude.Integer)
backupRule_completionWindowMinutes :: (Maybe Integer -> f (Maybe Integer)) -> BackupRule -> f BackupRule
backupRule_completionWindowMinutes = (BackupRule -> Maybe Integer)
-> (BackupRule -> Maybe Integer -> BackupRule)
-> Lens BackupRule BackupRule (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupRule' {Maybe Integer
completionWindowMinutes :: Maybe Integer
$sel:completionWindowMinutes:BackupRule' :: BackupRule -> Maybe Integer
completionWindowMinutes} -> Maybe Integer
completionWindowMinutes) (\s :: BackupRule
s@BackupRule' {} Maybe Integer
a -> BackupRule
s {$sel:completionWindowMinutes:BackupRule' :: Maybe Integer
completionWindowMinutes = Maybe Integer
a} :: BackupRule)

-- | An array of @CopyAction@ objects, which contains the details of the copy
-- operation.
backupRule_copyActions :: Lens.Lens' BackupRule (Prelude.Maybe [CopyAction])
backupRule_copyActions :: (Maybe [CopyAction] -> f (Maybe [CopyAction]))
-> BackupRule -> f BackupRule
backupRule_copyActions = (BackupRule -> Maybe [CopyAction])
-> (BackupRule -> Maybe [CopyAction] -> BackupRule)
-> Lens
     BackupRule BackupRule (Maybe [CopyAction]) (Maybe [CopyAction])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupRule' {Maybe [CopyAction]
copyActions :: Maybe [CopyAction]
$sel:copyActions:BackupRule' :: BackupRule -> Maybe [CopyAction]
copyActions} -> Maybe [CopyAction]
copyActions) (\s :: BackupRule
s@BackupRule' {} Maybe [CopyAction]
a -> BackupRule
s {$sel:copyActions:BackupRule' :: Maybe [CopyAction]
copyActions = Maybe [CopyAction]
a} :: BackupRule) ((Maybe [CopyAction] -> f (Maybe [CopyAction]))
 -> BackupRule -> f BackupRule)
-> ((Maybe [CopyAction] -> f (Maybe [CopyAction]))
    -> Maybe [CopyAction] -> f (Maybe [CopyAction]))
-> (Maybe [CopyAction] -> f (Maybe [CopyAction]))
-> BackupRule
-> f BackupRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [CopyAction] [CopyAction] [CopyAction] [CopyAction]
-> Iso
     (Maybe [CopyAction])
     (Maybe [CopyAction])
     (Maybe [CopyAction])
     (Maybe [CopyAction])
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 [CopyAction] [CopyAction] [CopyAction] [CopyAction]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A value in minutes after a backup is scheduled before a job will be
-- canceled if it doesn\'t start successfully. This value is optional.
backupRule_startWindowMinutes :: Lens.Lens' BackupRule (Prelude.Maybe Prelude.Integer)
backupRule_startWindowMinutes :: (Maybe Integer -> f (Maybe Integer)) -> BackupRule -> f BackupRule
backupRule_startWindowMinutes = (BackupRule -> Maybe Integer)
-> (BackupRule -> Maybe Integer -> BackupRule)
-> Lens BackupRule BackupRule (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupRule' {Maybe Integer
startWindowMinutes :: Maybe Integer
$sel:startWindowMinutes:BackupRule' :: BackupRule -> Maybe Integer
startWindowMinutes} -> Maybe Integer
startWindowMinutes) (\s :: BackupRule
s@BackupRule' {} Maybe Integer
a -> BackupRule
s {$sel:startWindowMinutes:BackupRule' :: Maybe Integer
startWindowMinutes = Maybe Integer
a} :: BackupRule)

-- | An optional display name for a backup rule.
backupRule_ruleName :: Lens.Lens' BackupRule Prelude.Text
backupRule_ruleName :: (Text -> f Text) -> BackupRule -> f BackupRule
backupRule_ruleName = (BackupRule -> Text)
-> (BackupRule -> Text -> BackupRule)
-> Lens BackupRule BackupRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupRule' {Text
ruleName :: Text
$sel:ruleName:BackupRule' :: BackupRule -> Text
ruleName} -> Text
ruleName) (\s :: BackupRule
s@BackupRule' {} Text
a -> BackupRule
s {$sel:ruleName:BackupRule' :: Text
ruleName = Text
a} :: BackupRule)

-- | The name of a logical container where backups are stored. Backup vaults
-- are identified by names that are unique to the account used to create
-- them and the Amazon Web Services Region where they are created. They
-- consist of lowercase letters, numbers, and hyphens.
backupRule_targetBackupVaultName :: Lens.Lens' BackupRule Prelude.Text
backupRule_targetBackupVaultName :: (Text -> f Text) -> BackupRule -> f BackupRule
backupRule_targetBackupVaultName = (BackupRule -> Text)
-> (BackupRule -> Text -> BackupRule)
-> Lens BackupRule BackupRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackupRule' {Text
targetBackupVaultName :: Text
$sel:targetBackupVaultName:BackupRule' :: BackupRule -> Text
targetBackupVaultName} -> Text
targetBackupVaultName) (\s :: BackupRule
s@BackupRule' {} Text
a -> BackupRule
s {$sel:targetBackupVaultName:BackupRule' :: Text
targetBackupVaultName = Text
a} :: BackupRule)

instance Core.FromJSON BackupRule where
  parseJSON :: Value -> Parser BackupRule
parseJSON =
    String
-> (Object -> Parser BackupRule) -> Value -> Parser BackupRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BackupRule"
      ( \Object
x ->
          Maybe Text
-> Maybe Lifecycle
-> Maybe (Sensitive (HashMap Text Text))
-> Maybe Text
-> Maybe Bool
-> Maybe Integer
-> Maybe [CopyAction]
-> Maybe Integer
-> Text
-> Text
-> BackupRule
BackupRule'
            (Maybe Text
 -> Maybe Lifecycle
 -> Maybe (Sensitive (HashMap Text Text))
 -> Maybe Text
 -> Maybe Bool
 -> Maybe Integer
 -> Maybe [CopyAction]
 -> Maybe Integer
 -> Text
 -> Text
 -> BackupRule)
-> Parser (Maybe Text)
-> Parser
     (Maybe Lifecycle
      -> Maybe (Sensitive (HashMap Text Text))
      -> Maybe Text
      -> Maybe Bool
      -> Maybe Integer
      -> Maybe [CopyAction]
      -> Maybe Integer
      -> Text
      -> Text
      -> BackupRule)
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
"RuleId")
            Parser
  (Maybe Lifecycle
   -> Maybe (Sensitive (HashMap Text Text))
   -> Maybe Text
   -> Maybe Bool
   -> Maybe Integer
   -> Maybe [CopyAction]
   -> Maybe Integer
   -> Text
   -> Text
   -> BackupRule)
-> Parser (Maybe Lifecycle)
-> Parser
     (Maybe (Sensitive (HashMap Text Text))
      -> Maybe Text
      -> Maybe Bool
      -> Maybe Integer
      -> Maybe [CopyAction]
      -> Maybe Integer
      -> Text
      -> Text
      -> BackupRule)
forall (f :: * -> *) a b. Applicative f => 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
  (Maybe (Sensitive (HashMap Text Text))
   -> Maybe Text
   -> Maybe Bool
   -> Maybe Integer
   -> Maybe [CopyAction]
   -> Maybe Integer
   -> Text
   -> Text
   -> BackupRule)
-> Parser (Maybe (Sensitive (HashMap Text Text)))
-> Parser
     (Maybe Text
      -> Maybe Bool
      -> Maybe Integer
      -> Maybe [CopyAction]
      -> Maybe Integer
      -> Text
      -> Text
      -> BackupRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Parser (Maybe (Maybe (Sensitive (HashMap Text Text))))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RecoveryPointTags"
                            Parser (Maybe (Maybe (Sensitive (HashMap Text Text))))
-> Maybe (Sensitive (HashMap Text Text))
-> Parser (Maybe (Sensitive (HashMap Text Text)))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (Sensitive (HashMap Text Text))
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe Text
   -> Maybe Bool
   -> Maybe Integer
   -> Maybe [CopyAction]
   -> Maybe Integer
   -> Text
   -> Text
   -> BackupRule)
-> Parser (Maybe Text)
-> Parser
     (Maybe Bool
      -> Maybe Integer
      -> Maybe [CopyAction]
      -> Maybe Integer
      -> Text
      -> Text
      -> BackupRule)
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
"ScheduleExpression")
            Parser
  (Maybe Bool
   -> Maybe Integer
   -> Maybe [CopyAction]
   -> Maybe Integer
   -> Text
   -> Text
   -> BackupRule)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Integer
      -> Maybe [CopyAction]
      -> Maybe Integer
      -> Text
      -> Text
      -> BackupRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EnableContinuousBackup")
            Parser
  (Maybe Integer
   -> Maybe [CopyAction]
   -> Maybe Integer
   -> Text
   -> Text
   -> BackupRule)
-> Parser (Maybe Integer)
-> Parser
     (Maybe [CopyAction] -> Maybe Integer -> Text -> Text -> BackupRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CompletionWindowMinutes")
            Parser
  (Maybe [CopyAction] -> Maybe Integer -> Text -> Text -> BackupRule)
-> Parser (Maybe [CopyAction])
-> Parser (Maybe Integer -> Text -> Text -> BackupRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [CopyAction]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CopyActions" Parser (Maybe (Maybe [CopyAction]))
-> Maybe [CopyAction] -> Parser (Maybe [CopyAction])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [CopyAction]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Integer -> Text -> Text -> BackupRule)
-> Parser (Maybe Integer) -> Parser (Text -> Text -> BackupRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StartWindowMinutes")
            Parser (Text -> Text -> BackupRule)
-> Parser Text -> Parser (Text -> BackupRule)
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
"RuleName")
            Parser (Text -> BackupRule) -> Parser Text -> Parser BackupRule
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
"TargetBackupVaultName")
      )

instance Prelude.Hashable BackupRule

instance Prelude.NFData BackupRule