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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies optional parameters to add to a policy. The set of valid
-- parameters depends on the combination of policy type and resource type.
--
-- /See:/ 'newParameters' smart constructor.
data Parameters = Parameters'
  { -- | Applies to AMI lifecycle 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,
    -- | [EBS Snapshot Management – Instance policies only] Indicates whether to
    -- exclude the root volume from snapshots created using
    -- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateSnapshots.html CreateSnapshots>.
    -- The default is false.
    Parameters -> Maybe Bool
excludeBootVolume :: Prelude.Maybe Prelude.Bool
  }
  deriving (Parameters -> Parameters -> Bool
(Parameters -> Parameters -> Bool)
-> (Parameters -> Parameters -> Bool) -> Eq Parameters
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]
(Int -> ReadS Parameters)
-> ReadS [Parameters]
-> ReadPrec Parameters
-> ReadPrec [Parameters]
-> Read 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
(Int -> Parameters -> ShowS)
-> (Parameters -> String)
-> ([Parameters] -> ShowS)
-> Show Parameters
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. Parameters -> Rep Parameters x)
-> (forall x. Rep Parameters x -> Parameters) -> Generic Parameters
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:
--
-- 'noReboot', 'parameters_noReboot' - Applies to AMI lifecycle 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).
--
-- 'excludeBootVolume', 'parameters_excludeBootVolume' - [EBS Snapshot Management – Instance policies only] Indicates whether to
-- exclude the root volume from snapshots created using
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateSnapshots.html CreateSnapshots>.
-- The default is false.
newParameters ::
  Parameters
newParameters :: Parameters
newParameters =
  Parameters' :: Maybe Bool -> Maybe Bool -> Parameters
Parameters'
    { $sel:noReboot:Parameters' :: Maybe Bool
noReboot = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:excludeBootVolume:Parameters' :: Maybe Bool
excludeBootVolume = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Applies to AMI lifecycle 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 :: (Maybe Bool -> f (Maybe Bool)) -> Parameters -> f Parameters
parameters_noReboot = (Parameters -> Maybe Bool)
-> (Parameters -> Maybe Bool -> Parameters)
-> Lens Parameters Parameters (Maybe Bool) (Maybe Bool)
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)

-- | [EBS Snapshot Management – Instance policies only] Indicates whether to
-- exclude the root volume from snapshots created using
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateSnapshots.html CreateSnapshots>.
-- The default is false.
parameters_excludeBootVolume :: Lens.Lens' Parameters (Prelude.Maybe Prelude.Bool)
parameters_excludeBootVolume :: (Maybe Bool -> f (Maybe Bool)) -> Parameters -> f Parameters
parameters_excludeBootVolume = (Parameters -> Maybe Bool)
-> (Parameters -> Maybe Bool -> Parameters)
-> Lens Parameters Parameters (Maybe Bool) (Maybe Bool)
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)

instance Core.FromJSON Parameters where
  parseJSON :: Value -> Parser Parameters
parseJSON =
    String
-> (Object -> Parser Parameters) -> Value -> Parser Parameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Parameters"
      ( \Object
x ->
          Maybe Bool -> Maybe Bool -> Parameters
Parameters'
            (Maybe Bool -> Maybe Bool -> Parameters)
-> Parser (Maybe Bool) -> Parser (Maybe Bool -> Parameters)
forall (f :: * -> *) a b. Functor 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
"NoReboot")
            Parser (Maybe Bool -> Parameters)
-> Parser (Maybe Bool) -> Parser Parameters
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
"ExcludeBootVolume")
      )

instance Prelude.Hashable Parameters

instance Prelude.NFData Parameters

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