{-# 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.DLM.Types.Schedule
-- 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.DLM.Types.Schedule where

import qualified Amazonka.Core as Core
import Amazonka.DLM.Types.CreateRule
import Amazonka.DLM.Types.CrossRegionCopyRule
import Amazonka.DLM.Types.DeprecateRule
import Amazonka.DLM.Types.FastRestoreRule
import Amazonka.DLM.Types.RetainRule
import Amazonka.DLM.Types.ShareRule
import Amazonka.DLM.Types.Tag
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies a backup schedule for a snapshot or AMI lifecycle policy.
--
-- /See:/ 'newSchedule' smart constructor.
data Schedule = Schedule'
  { -- | A collection of key\/value pairs with values determined dynamically when
    -- the policy is executed. Keys may be any valid Amazon EC2 tag key. Values
    -- must be in one of the two following formats: @$(instance-id)@ or
    -- @$(timestamp)@. Variable tags are only valid for EBS Snapshot Management
    -- – Instance policies.
    Schedule -> Maybe [Tag]
variableTags :: Prelude.Maybe [Tag],
    -- | The creation rule.
    Schedule -> Maybe CreateRule
createRule :: Prelude.Maybe CreateRule,
    -- | The AMI deprecation rule for the schedule.
    Schedule -> Maybe DeprecateRule
deprecateRule :: Prelude.Maybe DeprecateRule,
    -- | Copy all user-defined tags on a source volume to snapshots of the volume
    -- created by this policy.
    Schedule -> Maybe Bool
copyTags :: Prelude.Maybe Prelude.Bool,
    -- | The name of the schedule.
    Schedule -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The rule for sharing snapshots with other Amazon Web Services accounts.
    Schedule -> Maybe [ShareRule]
shareRules :: Prelude.Maybe [ShareRule],
    -- | The tags to apply to policy-created resources. These user-defined tags
    -- are in addition to the Amazon Web Services-added lifecycle tags.
    Schedule -> Maybe [Tag]
tagsToAdd :: Prelude.Maybe [Tag],
    -- | The retention rule.
    Schedule -> Maybe RetainRule
retainRule :: Prelude.Maybe RetainRule,
    -- | The rule for cross-Region snapshot copies.
    --
    -- You can only specify cross-Region copy rules for policies that create
    -- snapshots in a Region. If the policy creates snapshots on an Outpost,
    -- then you cannot copy the snapshots to a Region or to an Outpost. If the
    -- policy creates snapshots in a Region, then snapshots can be copied to up
    -- to three Regions or Outposts.
    Schedule -> Maybe [CrossRegionCopyRule]
crossRegionCopyRules :: Prelude.Maybe [CrossRegionCopyRule],
    -- | The rule for enabling fast snapshot restore.
    Schedule -> Maybe FastRestoreRule
fastRestoreRule :: Prelude.Maybe FastRestoreRule
  }
  deriving (Schedule -> Schedule -> Bool
(Schedule -> Schedule -> Bool)
-> (Schedule -> Schedule -> Bool) -> Eq Schedule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Schedule -> Schedule -> Bool
$c/= :: Schedule -> Schedule -> Bool
== :: Schedule -> Schedule -> Bool
$c== :: Schedule -> Schedule -> Bool
Prelude.Eq, ReadPrec [Schedule]
ReadPrec Schedule
Int -> ReadS Schedule
ReadS [Schedule]
(Int -> ReadS Schedule)
-> ReadS [Schedule]
-> ReadPrec Schedule
-> ReadPrec [Schedule]
-> Read Schedule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Schedule]
$creadListPrec :: ReadPrec [Schedule]
readPrec :: ReadPrec Schedule
$creadPrec :: ReadPrec Schedule
readList :: ReadS [Schedule]
$creadList :: ReadS [Schedule]
readsPrec :: Int -> ReadS Schedule
$creadsPrec :: Int -> ReadS Schedule
Prelude.Read, Int -> Schedule -> ShowS
[Schedule] -> ShowS
Schedule -> String
(Int -> Schedule -> ShowS)
-> (Schedule -> String) -> ([Schedule] -> ShowS) -> Show Schedule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Schedule] -> ShowS
$cshowList :: [Schedule] -> ShowS
show :: Schedule -> String
$cshow :: Schedule -> String
showsPrec :: Int -> Schedule -> ShowS
$cshowsPrec :: Int -> Schedule -> ShowS
Prelude.Show, (forall x. Schedule -> Rep Schedule x)
-> (forall x. Rep Schedule x -> Schedule) -> Generic Schedule
forall x. Rep Schedule x -> Schedule
forall x. Schedule -> Rep Schedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Schedule x -> Schedule
$cfrom :: forall x. Schedule -> Rep Schedule x
Prelude.Generic)

-- |
-- Create a value of 'Schedule' 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:
--
-- 'variableTags', 'schedule_variableTags' - A collection of key\/value pairs with values determined dynamically when
-- the policy is executed. Keys may be any valid Amazon EC2 tag key. Values
-- must be in one of the two following formats: @$(instance-id)@ or
-- @$(timestamp)@. Variable tags are only valid for EBS Snapshot Management
-- – Instance policies.
--
-- 'createRule', 'schedule_createRule' - The creation rule.
--
-- 'deprecateRule', 'schedule_deprecateRule' - The AMI deprecation rule for the schedule.
--
-- 'copyTags', 'schedule_copyTags' - Copy all user-defined tags on a source volume to snapshots of the volume
-- created by this policy.
--
-- 'name', 'schedule_name' - The name of the schedule.
--
-- 'shareRules', 'schedule_shareRules' - The rule for sharing snapshots with other Amazon Web Services accounts.
--
-- 'tagsToAdd', 'schedule_tagsToAdd' - The tags to apply to policy-created resources. These user-defined tags
-- are in addition to the Amazon Web Services-added lifecycle tags.
--
-- 'retainRule', 'schedule_retainRule' - The retention rule.
--
-- 'crossRegionCopyRules', 'schedule_crossRegionCopyRules' - The rule for cross-Region snapshot copies.
--
-- You can only specify cross-Region copy rules for policies that create
-- snapshots in a Region. If the policy creates snapshots on an Outpost,
-- then you cannot copy the snapshots to a Region or to an Outpost. If the
-- policy creates snapshots in a Region, then snapshots can be copied to up
-- to three Regions or Outposts.
--
-- 'fastRestoreRule', 'schedule_fastRestoreRule' - The rule for enabling fast snapshot restore.
newSchedule ::
  Schedule
newSchedule :: Schedule
newSchedule =
  Schedule' :: Maybe [Tag]
-> Maybe CreateRule
-> Maybe DeprecateRule
-> Maybe Bool
-> Maybe Text
-> Maybe [ShareRule]
-> Maybe [Tag]
-> Maybe RetainRule
-> Maybe [CrossRegionCopyRule]
-> Maybe FastRestoreRule
-> Schedule
Schedule'
    { $sel:variableTags:Schedule' :: Maybe [Tag]
variableTags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:createRule:Schedule' :: Maybe CreateRule
createRule = Maybe CreateRule
forall a. Maybe a
Prelude.Nothing,
      $sel:deprecateRule:Schedule' :: Maybe DeprecateRule
deprecateRule = Maybe DeprecateRule
forall a. Maybe a
Prelude.Nothing,
      $sel:copyTags:Schedule' :: Maybe Bool
copyTags = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Schedule' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:shareRules:Schedule' :: Maybe [ShareRule]
shareRules = Maybe [ShareRule]
forall a. Maybe a
Prelude.Nothing,
      $sel:tagsToAdd:Schedule' :: Maybe [Tag]
tagsToAdd = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:retainRule:Schedule' :: Maybe RetainRule
retainRule = Maybe RetainRule
forall a. Maybe a
Prelude.Nothing,
      $sel:crossRegionCopyRules:Schedule' :: Maybe [CrossRegionCopyRule]
crossRegionCopyRules = Maybe [CrossRegionCopyRule]
forall a. Maybe a
Prelude.Nothing,
      $sel:fastRestoreRule:Schedule' :: Maybe FastRestoreRule
fastRestoreRule = Maybe FastRestoreRule
forall a. Maybe a
Prelude.Nothing
    }

-- | A collection of key\/value pairs with values determined dynamically when
-- the policy is executed. Keys may be any valid Amazon EC2 tag key. Values
-- must be in one of the two following formats: @$(instance-id)@ or
-- @$(timestamp)@. Variable tags are only valid for EBS Snapshot Management
-- – Instance policies.
schedule_variableTags :: Lens.Lens' Schedule (Prelude.Maybe [Tag])
schedule_variableTags :: (Maybe [Tag] -> f (Maybe [Tag])) -> Schedule -> f Schedule
schedule_variableTags = (Schedule -> Maybe [Tag])
-> (Schedule -> Maybe [Tag] -> Schedule)
-> Lens Schedule Schedule (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Schedule' {Maybe [Tag]
variableTags :: Maybe [Tag]
$sel:variableTags:Schedule' :: Schedule -> Maybe [Tag]
variableTags} -> Maybe [Tag]
variableTags) (\s :: Schedule
s@Schedule' {} Maybe [Tag]
a -> Schedule
s {$sel:variableTags:Schedule' :: Maybe [Tag]
variableTags = Maybe [Tag]
a} :: Schedule) ((Maybe [Tag] -> f (Maybe [Tag])) -> Schedule -> f Schedule)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> Schedule
-> f Schedule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The creation rule.
schedule_createRule :: Lens.Lens' Schedule (Prelude.Maybe CreateRule)
schedule_createRule :: (Maybe CreateRule -> f (Maybe CreateRule))
-> Schedule -> f Schedule
schedule_createRule = (Schedule -> Maybe CreateRule)
-> (Schedule -> Maybe CreateRule -> Schedule)
-> Lens Schedule Schedule (Maybe CreateRule) (Maybe CreateRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Schedule' {Maybe CreateRule
createRule :: Maybe CreateRule
$sel:createRule:Schedule' :: Schedule -> Maybe CreateRule
createRule} -> Maybe CreateRule
createRule) (\s :: Schedule
s@Schedule' {} Maybe CreateRule
a -> Schedule
s {$sel:createRule:Schedule' :: Maybe CreateRule
createRule = Maybe CreateRule
a} :: Schedule)

-- | The AMI deprecation rule for the schedule.
schedule_deprecateRule :: Lens.Lens' Schedule (Prelude.Maybe DeprecateRule)
schedule_deprecateRule :: (Maybe DeprecateRule -> f (Maybe DeprecateRule))
-> Schedule -> f Schedule
schedule_deprecateRule = (Schedule -> Maybe DeprecateRule)
-> (Schedule -> Maybe DeprecateRule -> Schedule)
-> Lens
     Schedule Schedule (Maybe DeprecateRule) (Maybe DeprecateRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Schedule' {Maybe DeprecateRule
deprecateRule :: Maybe DeprecateRule
$sel:deprecateRule:Schedule' :: Schedule -> Maybe DeprecateRule
deprecateRule} -> Maybe DeprecateRule
deprecateRule) (\s :: Schedule
s@Schedule' {} Maybe DeprecateRule
a -> Schedule
s {$sel:deprecateRule:Schedule' :: Maybe DeprecateRule
deprecateRule = Maybe DeprecateRule
a} :: Schedule)

-- | Copy all user-defined tags on a source volume to snapshots of the volume
-- created by this policy.
schedule_copyTags :: Lens.Lens' Schedule (Prelude.Maybe Prelude.Bool)
schedule_copyTags :: (Maybe Bool -> f (Maybe Bool)) -> Schedule -> f Schedule
schedule_copyTags = (Schedule -> Maybe Bool)
-> (Schedule -> Maybe Bool -> Schedule)
-> Lens Schedule Schedule (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Schedule' {Maybe Bool
copyTags :: Maybe Bool
$sel:copyTags:Schedule' :: Schedule -> Maybe Bool
copyTags} -> Maybe Bool
copyTags) (\s :: Schedule
s@Schedule' {} Maybe Bool
a -> Schedule
s {$sel:copyTags:Schedule' :: Maybe Bool
copyTags = Maybe Bool
a} :: Schedule)

-- | The name of the schedule.
schedule_name :: Lens.Lens' Schedule (Prelude.Maybe Prelude.Text)
schedule_name :: (Maybe Text -> f (Maybe Text)) -> Schedule -> f Schedule
schedule_name = (Schedule -> Maybe Text)
-> (Schedule -> Maybe Text -> Schedule)
-> Lens Schedule Schedule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Schedule' {Maybe Text
name :: Maybe Text
$sel:name:Schedule' :: Schedule -> Maybe Text
name} -> Maybe Text
name) (\s :: Schedule
s@Schedule' {} Maybe Text
a -> Schedule
s {$sel:name:Schedule' :: Maybe Text
name = Maybe Text
a} :: Schedule)

-- | The rule for sharing snapshots with other Amazon Web Services accounts.
schedule_shareRules :: Lens.Lens' Schedule (Prelude.Maybe [ShareRule])
schedule_shareRules :: (Maybe [ShareRule] -> f (Maybe [ShareRule]))
-> Schedule -> f Schedule
schedule_shareRules = (Schedule -> Maybe [ShareRule])
-> (Schedule -> Maybe [ShareRule] -> Schedule)
-> Lens Schedule Schedule (Maybe [ShareRule]) (Maybe [ShareRule])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Schedule' {Maybe [ShareRule]
shareRules :: Maybe [ShareRule]
$sel:shareRules:Schedule' :: Schedule -> Maybe [ShareRule]
shareRules} -> Maybe [ShareRule]
shareRules) (\s :: Schedule
s@Schedule' {} Maybe [ShareRule]
a -> Schedule
s {$sel:shareRules:Schedule' :: Maybe [ShareRule]
shareRules = Maybe [ShareRule]
a} :: Schedule) ((Maybe [ShareRule] -> f (Maybe [ShareRule]))
 -> Schedule -> f Schedule)
-> ((Maybe [ShareRule] -> f (Maybe [ShareRule]))
    -> Maybe [ShareRule] -> f (Maybe [ShareRule]))
-> (Maybe [ShareRule] -> f (Maybe [ShareRule]))
-> Schedule
-> f Schedule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ShareRule] [ShareRule] [ShareRule] [ShareRule]
-> Iso
     (Maybe [ShareRule])
     (Maybe [ShareRule])
     (Maybe [ShareRule])
     (Maybe [ShareRule])
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 [ShareRule] [ShareRule] [ShareRule] [ShareRule]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The tags to apply to policy-created resources. These user-defined tags
-- are in addition to the Amazon Web Services-added lifecycle tags.
schedule_tagsToAdd :: Lens.Lens' Schedule (Prelude.Maybe [Tag])
schedule_tagsToAdd :: (Maybe [Tag] -> f (Maybe [Tag])) -> Schedule -> f Schedule
schedule_tagsToAdd = (Schedule -> Maybe [Tag])
-> (Schedule -> Maybe [Tag] -> Schedule)
-> Lens Schedule Schedule (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Schedule' {Maybe [Tag]
tagsToAdd :: Maybe [Tag]
$sel:tagsToAdd:Schedule' :: Schedule -> Maybe [Tag]
tagsToAdd} -> Maybe [Tag]
tagsToAdd) (\s :: Schedule
s@Schedule' {} Maybe [Tag]
a -> Schedule
s {$sel:tagsToAdd:Schedule' :: Maybe [Tag]
tagsToAdd = Maybe [Tag]
a} :: Schedule) ((Maybe [Tag] -> f (Maybe [Tag])) -> Schedule -> f Schedule)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> Schedule
-> f Schedule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The retention rule.
schedule_retainRule :: Lens.Lens' Schedule (Prelude.Maybe RetainRule)
schedule_retainRule :: (Maybe RetainRule -> f (Maybe RetainRule))
-> Schedule -> f Schedule
schedule_retainRule = (Schedule -> Maybe RetainRule)
-> (Schedule -> Maybe RetainRule -> Schedule)
-> Lens Schedule Schedule (Maybe RetainRule) (Maybe RetainRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Schedule' {Maybe RetainRule
retainRule :: Maybe RetainRule
$sel:retainRule:Schedule' :: Schedule -> Maybe RetainRule
retainRule} -> Maybe RetainRule
retainRule) (\s :: Schedule
s@Schedule' {} Maybe RetainRule
a -> Schedule
s {$sel:retainRule:Schedule' :: Maybe RetainRule
retainRule = Maybe RetainRule
a} :: Schedule)

-- | The rule for cross-Region snapshot copies.
--
-- You can only specify cross-Region copy rules for policies that create
-- snapshots in a Region. If the policy creates snapshots on an Outpost,
-- then you cannot copy the snapshots to a Region or to an Outpost. If the
-- policy creates snapshots in a Region, then snapshots can be copied to up
-- to three Regions or Outposts.
schedule_crossRegionCopyRules :: Lens.Lens' Schedule (Prelude.Maybe [CrossRegionCopyRule])
schedule_crossRegionCopyRules :: (Maybe [CrossRegionCopyRule] -> f (Maybe [CrossRegionCopyRule]))
-> Schedule -> f Schedule
schedule_crossRegionCopyRules = (Schedule -> Maybe [CrossRegionCopyRule])
-> (Schedule -> Maybe [CrossRegionCopyRule] -> Schedule)
-> Lens
     Schedule
     Schedule
     (Maybe [CrossRegionCopyRule])
     (Maybe [CrossRegionCopyRule])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Schedule' {Maybe [CrossRegionCopyRule]
crossRegionCopyRules :: Maybe [CrossRegionCopyRule]
$sel:crossRegionCopyRules:Schedule' :: Schedule -> Maybe [CrossRegionCopyRule]
crossRegionCopyRules} -> Maybe [CrossRegionCopyRule]
crossRegionCopyRules) (\s :: Schedule
s@Schedule' {} Maybe [CrossRegionCopyRule]
a -> Schedule
s {$sel:crossRegionCopyRules:Schedule' :: Maybe [CrossRegionCopyRule]
crossRegionCopyRules = Maybe [CrossRegionCopyRule]
a} :: Schedule) ((Maybe [CrossRegionCopyRule] -> f (Maybe [CrossRegionCopyRule]))
 -> Schedule -> f Schedule)
-> ((Maybe [CrossRegionCopyRule]
     -> f (Maybe [CrossRegionCopyRule]))
    -> Maybe [CrossRegionCopyRule] -> f (Maybe [CrossRegionCopyRule]))
-> (Maybe [CrossRegionCopyRule] -> f (Maybe [CrossRegionCopyRule]))
-> Schedule
-> f Schedule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CrossRegionCopyRule]
  [CrossRegionCopyRule]
  [CrossRegionCopyRule]
  [CrossRegionCopyRule]
-> Iso
     (Maybe [CrossRegionCopyRule])
     (Maybe [CrossRegionCopyRule])
     (Maybe [CrossRegionCopyRule])
     (Maybe [CrossRegionCopyRule])
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
  [CrossRegionCopyRule]
  [CrossRegionCopyRule]
  [CrossRegionCopyRule]
  [CrossRegionCopyRule]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The rule for enabling fast snapshot restore.
schedule_fastRestoreRule :: Lens.Lens' Schedule (Prelude.Maybe FastRestoreRule)
schedule_fastRestoreRule :: (Maybe FastRestoreRule -> f (Maybe FastRestoreRule))
-> Schedule -> f Schedule
schedule_fastRestoreRule = (Schedule -> Maybe FastRestoreRule)
-> (Schedule -> Maybe FastRestoreRule -> Schedule)
-> Lens
     Schedule Schedule (Maybe FastRestoreRule) (Maybe FastRestoreRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Schedule' {Maybe FastRestoreRule
fastRestoreRule :: Maybe FastRestoreRule
$sel:fastRestoreRule:Schedule' :: Schedule -> Maybe FastRestoreRule
fastRestoreRule} -> Maybe FastRestoreRule
fastRestoreRule) (\s :: Schedule
s@Schedule' {} Maybe FastRestoreRule
a -> Schedule
s {$sel:fastRestoreRule:Schedule' :: Maybe FastRestoreRule
fastRestoreRule = Maybe FastRestoreRule
a} :: Schedule)

instance Core.FromJSON Schedule where
  parseJSON :: Value -> Parser Schedule
parseJSON =
    String -> (Object -> Parser Schedule) -> Value -> Parser Schedule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Schedule"
      ( \Object
x ->
          Maybe [Tag]
-> Maybe CreateRule
-> Maybe DeprecateRule
-> Maybe Bool
-> Maybe Text
-> Maybe [ShareRule]
-> Maybe [Tag]
-> Maybe RetainRule
-> Maybe [CrossRegionCopyRule]
-> Maybe FastRestoreRule
-> Schedule
Schedule'
            (Maybe [Tag]
 -> Maybe CreateRule
 -> Maybe DeprecateRule
 -> Maybe Bool
 -> Maybe Text
 -> Maybe [ShareRule]
 -> Maybe [Tag]
 -> Maybe RetainRule
 -> Maybe [CrossRegionCopyRule]
 -> Maybe FastRestoreRule
 -> Schedule)
-> Parser (Maybe [Tag])
-> Parser
     (Maybe CreateRule
      -> Maybe DeprecateRule
      -> Maybe Bool
      -> Maybe Text
      -> Maybe [ShareRule]
      -> Maybe [Tag]
      -> Maybe RetainRule
      -> Maybe [CrossRegionCopyRule]
      -> Maybe FastRestoreRule
      -> Schedule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Tag]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"VariableTags" Parser (Maybe (Maybe [Tag])) -> Maybe [Tag] -> Parser (Maybe [Tag])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Tag]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe CreateRule
   -> Maybe DeprecateRule
   -> Maybe Bool
   -> Maybe Text
   -> Maybe [ShareRule]
   -> Maybe [Tag]
   -> Maybe RetainRule
   -> Maybe [CrossRegionCopyRule]
   -> Maybe FastRestoreRule
   -> Schedule)
-> Parser (Maybe CreateRule)
-> Parser
     (Maybe DeprecateRule
      -> Maybe Bool
      -> Maybe Text
      -> Maybe [ShareRule]
      -> Maybe [Tag]
      -> Maybe RetainRule
      -> Maybe [CrossRegionCopyRule]
      -> Maybe FastRestoreRule
      -> Schedule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CreateRule)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreateRule")
            Parser
  (Maybe DeprecateRule
   -> Maybe Bool
   -> Maybe Text
   -> Maybe [ShareRule]
   -> Maybe [Tag]
   -> Maybe RetainRule
   -> Maybe [CrossRegionCopyRule]
   -> Maybe FastRestoreRule
   -> Schedule)
-> Parser (Maybe DeprecateRule)
-> Parser
     (Maybe Bool
      -> Maybe Text
      -> Maybe [ShareRule]
      -> Maybe [Tag]
      -> Maybe RetainRule
      -> Maybe [CrossRegionCopyRule]
      -> Maybe FastRestoreRule
      -> Schedule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DeprecateRule)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeprecateRule")
            Parser
  (Maybe Bool
   -> Maybe Text
   -> Maybe [ShareRule]
   -> Maybe [Tag]
   -> Maybe RetainRule
   -> Maybe [CrossRegionCopyRule]
   -> Maybe FastRestoreRule
   -> Schedule)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text
      -> Maybe [ShareRule]
      -> Maybe [Tag]
      -> Maybe RetainRule
      -> Maybe [CrossRegionCopyRule]
      -> Maybe FastRestoreRule
      -> Schedule)
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
"CopyTags")
            Parser
  (Maybe Text
   -> Maybe [ShareRule]
   -> Maybe [Tag]
   -> Maybe RetainRule
   -> Maybe [CrossRegionCopyRule]
   -> Maybe FastRestoreRule
   -> Schedule)
-> Parser (Maybe Text)
-> Parser
     (Maybe [ShareRule]
      -> Maybe [Tag]
      -> Maybe RetainRule
      -> Maybe [CrossRegionCopyRule]
      -> Maybe FastRestoreRule
      -> Schedule)
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
"Name")
            Parser
  (Maybe [ShareRule]
   -> Maybe [Tag]
   -> Maybe RetainRule
   -> Maybe [CrossRegionCopyRule]
   -> Maybe FastRestoreRule
   -> Schedule)
-> Parser (Maybe [ShareRule])
-> Parser
     (Maybe [Tag]
      -> Maybe RetainRule
      -> Maybe [CrossRegionCopyRule]
      -> Maybe FastRestoreRule
      -> Schedule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [ShareRule]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ShareRules" Parser (Maybe (Maybe [ShareRule]))
-> Maybe [ShareRule] -> Parser (Maybe [ShareRule])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ShareRule]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe [Tag]
   -> Maybe RetainRule
   -> Maybe [CrossRegionCopyRule]
   -> Maybe FastRestoreRule
   -> Schedule)
-> Parser (Maybe [Tag])
-> Parser
     (Maybe RetainRule
      -> Maybe [CrossRegionCopyRule]
      -> Maybe FastRestoreRule
      -> Schedule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Tag]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TagsToAdd" Parser (Maybe (Maybe [Tag])) -> Maybe [Tag] -> Parser (Maybe [Tag])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Tag]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe RetainRule
   -> Maybe [CrossRegionCopyRule]
   -> Maybe FastRestoreRule
   -> Schedule)
-> Parser (Maybe RetainRule)
-> Parser
     (Maybe [CrossRegionCopyRule] -> Maybe FastRestoreRule -> Schedule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RetainRule)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RetainRule")
            Parser
  (Maybe [CrossRegionCopyRule] -> Maybe FastRestoreRule -> Schedule)
-> Parser (Maybe [CrossRegionCopyRule])
-> Parser (Maybe FastRestoreRule -> Schedule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [CrossRegionCopyRule]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CrossRegionCopyRules"
                            Parser (Maybe (Maybe [CrossRegionCopyRule]))
-> Maybe [CrossRegionCopyRule]
-> Parser (Maybe [CrossRegionCopyRule])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [CrossRegionCopyRule]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe FastRestoreRule -> Schedule)
-> Parser (Maybe FastRestoreRule) -> Parser Schedule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FastRestoreRule)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FastRestoreRule")
      )

instance Prelude.Hashable Schedule

instance Prelude.NFData Schedule

instance Core.ToJSON Schedule where
  toJSON :: Schedule -> Value
toJSON Schedule' {Maybe Bool
Maybe [CrossRegionCopyRule]
Maybe [ShareRule]
Maybe [Tag]
Maybe Text
Maybe CreateRule
Maybe RetainRule
Maybe FastRestoreRule
Maybe DeprecateRule
fastRestoreRule :: Maybe FastRestoreRule
crossRegionCopyRules :: Maybe [CrossRegionCopyRule]
retainRule :: Maybe RetainRule
tagsToAdd :: Maybe [Tag]
shareRules :: Maybe [ShareRule]
name :: Maybe Text
copyTags :: Maybe Bool
deprecateRule :: Maybe DeprecateRule
createRule :: Maybe CreateRule
variableTags :: Maybe [Tag]
$sel:fastRestoreRule:Schedule' :: Schedule -> Maybe FastRestoreRule
$sel:crossRegionCopyRules:Schedule' :: Schedule -> Maybe [CrossRegionCopyRule]
$sel:retainRule:Schedule' :: Schedule -> Maybe RetainRule
$sel:tagsToAdd:Schedule' :: Schedule -> Maybe [Tag]
$sel:shareRules:Schedule' :: Schedule -> Maybe [ShareRule]
$sel:name:Schedule' :: Schedule -> Maybe Text
$sel:copyTags:Schedule' :: Schedule -> Maybe Bool
$sel:deprecateRule:Schedule' :: Schedule -> Maybe DeprecateRule
$sel:createRule:Schedule' :: Schedule -> Maybe CreateRule
$sel:variableTags:Schedule' :: Schedule -> Maybe [Tag]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"VariableTags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
variableTags,
            (Text
"CreateRule" Text -> CreateRule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CreateRule -> Pair) -> Maybe CreateRule -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CreateRule
createRule,
            (Text
"DeprecateRule" Text -> DeprecateRule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DeprecateRule -> Pair) -> Maybe DeprecateRule -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeprecateRule
deprecateRule,
            (Text
"CopyTags" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
copyTags,
            (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Text
"ShareRules" Text -> [ShareRule] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([ShareRule] -> Pair) -> Maybe [ShareRule] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ShareRule]
shareRules,
            (Text
"TagsToAdd" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tagsToAdd,
            (Text
"RetainRule" Text -> RetainRule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RetainRule -> Pair) -> Maybe RetainRule -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RetainRule
retainRule,
            (Text
"CrossRegionCopyRules" Text -> [CrossRegionCopyRule] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([CrossRegionCopyRule] -> Pair)
-> Maybe [CrossRegionCopyRule] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [CrossRegionCopyRule]
crossRegionCopyRules,
            (Text
"FastRestoreRule" Text -> FastRestoreRule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (FastRestoreRule -> Pair) -> Maybe FastRestoreRule -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FastRestoreRule
fastRestoreRule
          ]
      )