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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.DLM.Types.Tag
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | __[Snapshot and AMI policies only]__ Specifies optional parameters for
-- snapshot and AMI policies. The set of valid parameters depends on the
-- combination of policy type and target resource type.
--
-- If you choose to exclude boot volumes and you specify tags that
-- consequently exclude all of the additional data volumes attached to an
-- instance, then Amazon Data Lifecycle Manager will not create any
-- snapshots for the affected instance, and it will emit a
-- @SnapshotsCreateFailed@ Amazon CloudWatch metric. For more information,
-- see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/monitor-dlm-cw-metrics.html Monitor your policies using Amazon CloudWatch>.
--
-- /See:/ 'newParameters' smart constructor.
data Parameters = Parameters'
  { -- | __[Snapshot policies that target instances only]__ Indicates whether to
    -- exclude the root volume from multi-volume snapshot sets. The default is
    -- @false@. If you specify @true@, then the root volumes attached to
    -- targeted instances will be excluded from the multi-volume snapshot sets
    -- created by the policy.
    Parameters -> Maybe Bool
excludeBootVolume :: Prelude.Maybe Prelude.Bool,
    -- | __[Snapshot policies that target instances only]__ The tags used to
    -- identify data (non-root) volumes to exclude from multi-volume snapshot
    -- sets.
    --
    -- If you create a snapshot lifecycle policy that targets instances and you
    -- specify tags for this parameter, then data volumes with the specified
    -- tags that are attached to targeted instances will be excluded from the
    -- multi-volume snapshot sets created by the policy.
    Parameters -> Maybe [Tag]
excludeDataVolumeTags :: Prelude.Maybe [Tag],
    -- | __[AMI policies only]__ Indicates whether targeted instances are
    -- rebooted when the lifecycle policy runs. @true@ indicates that targeted
    -- instances are not rebooted when the policy runs. @false@ indicates that
    -- target instances are rebooted when the policy runs. The default is
    -- @true@ (instances are not rebooted).
    Parameters -> Maybe Bool
noReboot :: Prelude.Maybe Prelude.Bool
  }
  deriving (Parameters -> Parameters -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Parameters -> Parameters -> Bool
$c/= :: Parameters -> Parameters -> Bool
== :: Parameters -> Parameters -> Bool
$c== :: Parameters -> Parameters -> Bool
Prelude.Eq, ReadPrec [Parameters]
ReadPrec Parameters
Int -> ReadS Parameters
ReadS [Parameters]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Parameters]
$creadListPrec :: ReadPrec [Parameters]
readPrec :: ReadPrec Parameters
$creadPrec :: ReadPrec Parameters
readList :: ReadS [Parameters]
$creadList :: ReadS [Parameters]
readsPrec :: Int -> ReadS Parameters
$creadsPrec :: Int -> ReadS Parameters
Prelude.Read, Int -> Parameters -> ShowS
[Parameters] -> ShowS
Parameters -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Parameters] -> ShowS
$cshowList :: [Parameters] -> ShowS
show :: Parameters -> String
$cshow :: Parameters -> String
showsPrec :: Int -> Parameters -> ShowS
$cshowsPrec :: Int -> Parameters -> ShowS
Prelude.Show, forall x. Rep Parameters x -> Parameters
forall x. Parameters -> Rep Parameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Parameters x -> Parameters
$cfrom :: forall x. Parameters -> Rep Parameters x
Prelude.Generic)

-- |
-- Create a value of 'Parameters' 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:
--
-- 'excludeBootVolume', 'parameters_excludeBootVolume' - __[Snapshot policies that target instances only]__ Indicates whether to
-- exclude the root volume from multi-volume snapshot sets. The default is
-- @false@. If you specify @true@, then the root volumes attached to
-- targeted instances will be excluded from the multi-volume snapshot sets
-- created by the policy.
--
-- 'excludeDataVolumeTags', 'parameters_excludeDataVolumeTags' - __[Snapshot policies that target instances only]__ The tags used to
-- identify data (non-root) volumes to exclude from multi-volume snapshot
-- sets.
--
-- If you create a snapshot lifecycle policy that targets instances and you
-- specify tags for this parameter, then data volumes with the specified
-- tags that are attached to targeted instances will be excluded from the
-- multi-volume snapshot sets created by the policy.
--
-- 'noReboot', 'parameters_noReboot' - __[AMI policies only]__ Indicates whether targeted instances are
-- rebooted when the lifecycle policy runs. @true@ indicates that targeted
-- instances are not rebooted when the policy runs. @false@ indicates that
-- target instances are rebooted when the policy runs. The default is
-- @true@ (instances are not rebooted).
newParameters ::
  Parameters
newParameters :: Parameters
newParameters =
  Parameters'
    { $sel:excludeBootVolume:Parameters' :: Maybe Bool
excludeBootVolume = forall a. Maybe a
Prelude.Nothing,
      $sel:excludeDataVolumeTags:Parameters' :: Maybe [Tag]
excludeDataVolumeTags = forall a. Maybe a
Prelude.Nothing,
      $sel:noReboot:Parameters' :: Maybe Bool
noReboot = forall a. Maybe a
Prelude.Nothing
    }

-- | __[Snapshot policies that target instances only]__ Indicates whether to
-- exclude the root volume from multi-volume snapshot sets. The default is
-- @false@. If you specify @true@, then the root volumes attached to
-- targeted instances will be excluded from the multi-volume snapshot sets
-- created by the policy.
parameters_excludeBootVolume :: Lens.Lens' Parameters (Prelude.Maybe Prelude.Bool)
parameters_excludeBootVolume :: Lens' Parameters (Maybe Bool)
parameters_excludeBootVolume = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Parameters' {Maybe Bool
excludeBootVolume :: Maybe Bool
$sel:excludeBootVolume:Parameters' :: Parameters -> Maybe Bool
excludeBootVolume} -> Maybe Bool
excludeBootVolume) (\s :: Parameters
s@Parameters' {} Maybe Bool
a -> Parameters
s {$sel:excludeBootVolume:Parameters' :: Maybe Bool
excludeBootVolume = Maybe Bool
a} :: Parameters)

-- | __[Snapshot policies that target instances only]__ The tags used to
-- identify data (non-root) volumes to exclude from multi-volume snapshot
-- sets.
--
-- If you create a snapshot lifecycle policy that targets instances and you
-- specify tags for this parameter, then data volumes with the specified
-- tags that are attached to targeted instances will be excluded from the
-- multi-volume snapshot sets created by the policy.
parameters_excludeDataVolumeTags :: Lens.Lens' Parameters (Prelude.Maybe [Tag])
parameters_excludeDataVolumeTags :: Lens' Parameters (Maybe [Tag])
parameters_excludeDataVolumeTags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Parameters' {Maybe [Tag]
excludeDataVolumeTags :: Maybe [Tag]
$sel:excludeDataVolumeTags:Parameters' :: Parameters -> Maybe [Tag]
excludeDataVolumeTags} -> Maybe [Tag]
excludeDataVolumeTags) (\s :: Parameters
s@Parameters' {} Maybe [Tag]
a -> Parameters
s {$sel:excludeDataVolumeTags:Parameters' :: Maybe [Tag]
excludeDataVolumeTags = Maybe [Tag]
a} :: Parameters) 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

-- | __[AMI policies only]__ Indicates whether targeted instances are
-- rebooted when the lifecycle policy runs. @true@ indicates that targeted
-- instances are not rebooted when the policy runs. @false@ indicates that
-- target instances are rebooted when the policy runs. The default is
-- @true@ (instances are not rebooted).
parameters_noReboot :: Lens.Lens' Parameters (Prelude.Maybe Prelude.Bool)
parameters_noReboot :: Lens' Parameters (Maybe Bool)
parameters_noReboot = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Parameters' {Maybe Bool
noReboot :: Maybe Bool
$sel:noReboot:Parameters' :: Parameters -> Maybe Bool
noReboot} -> Maybe Bool
noReboot) (\s :: Parameters
s@Parameters' {} Maybe Bool
a -> Parameters
s {$sel:noReboot:Parameters' :: Maybe Bool
noReboot = Maybe Bool
a} :: Parameters)

instance Data.FromJSON Parameters where
  parseJSON :: Value -> Parser Parameters
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Parameters"
      ( \Object
x ->
          Maybe Bool -> Maybe [Tag] -> Maybe Bool -> Parameters
Parameters'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ExcludeBootVolume")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ExcludeDataVolumeTags"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NoReboot")
      )

instance Prelude.Hashable Parameters where
  hashWithSalt :: Int -> Parameters -> Int
hashWithSalt Int
_salt Parameters' {Maybe Bool
Maybe [Tag]
noReboot :: Maybe Bool
excludeDataVolumeTags :: Maybe [Tag]
excludeBootVolume :: Maybe Bool
$sel:noReboot:Parameters' :: Parameters -> Maybe Bool
$sel:excludeDataVolumeTags:Parameters' :: Parameters -> Maybe [Tag]
$sel:excludeBootVolume:Parameters' :: Parameters -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
excludeBootVolume
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
excludeDataVolumeTags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
noReboot

instance Prelude.NFData Parameters where
  rnf :: Parameters -> ()
rnf Parameters' {Maybe Bool
Maybe [Tag]
noReboot :: Maybe Bool
excludeDataVolumeTags :: Maybe [Tag]
excludeBootVolume :: Maybe Bool
$sel:noReboot:Parameters' :: Parameters -> Maybe Bool
$sel:excludeDataVolumeTags:Parameters' :: Parameters -> Maybe [Tag]
$sel:excludeBootVolume:Parameters' :: Parameters -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
excludeBootVolume
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
excludeDataVolumeTags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
noReboot

instance Data.ToJSON Parameters where
  toJSON :: Parameters -> Value
toJSON Parameters' {Maybe Bool
Maybe [Tag]
noReboot :: Maybe Bool
excludeDataVolumeTags :: Maybe [Tag]
excludeBootVolume :: Maybe Bool
$sel:noReboot:Parameters' :: Parameters -> Maybe Bool
$sel:excludeDataVolumeTags:Parameters' :: Parameters -> Maybe [Tag]
$sel:excludeBootVolume:Parameters' :: Parameters -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ExcludeBootVolume" 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 Bool
excludeBootVolume,
            (Key
"ExcludeDataVolumeTags" 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 [Tag]
excludeDataVolumeTags,
            (Key
"NoReboot" 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 Bool
noReboot
          ]
      )