{-# 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.ImageBuilder.Types.SystemsManagerAgent
-- 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.ImageBuilder.Types.SystemsManagerAgent where

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

-- | Contains settings for the Systems Manager agent on your build instance.
--
-- /See:/ 'newSystemsManagerAgent' smart constructor.
data SystemsManagerAgent = SystemsManagerAgent'
  { -- | Controls whether the Systems Manager agent is removed from your final
    -- build image, prior to creating the new AMI. If this is set to true, then
    -- the agent is removed from the final image. If it\'s set to false, then
    -- the agent is left in, so that it is included in the new AMI. The default
    -- value is false.
    SystemsManagerAgent -> Maybe Bool
uninstallAfterBuild :: Prelude.Maybe Prelude.Bool
  }
  deriving (SystemsManagerAgent -> SystemsManagerAgent -> Bool
(SystemsManagerAgent -> SystemsManagerAgent -> Bool)
-> (SystemsManagerAgent -> SystemsManagerAgent -> Bool)
-> Eq SystemsManagerAgent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SystemsManagerAgent -> SystemsManagerAgent -> Bool
$c/= :: SystemsManagerAgent -> SystemsManagerAgent -> Bool
== :: SystemsManagerAgent -> SystemsManagerAgent -> Bool
$c== :: SystemsManagerAgent -> SystemsManagerAgent -> Bool
Prelude.Eq, ReadPrec [SystemsManagerAgent]
ReadPrec SystemsManagerAgent
Int -> ReadS SystemsManagerAgent
ReadS [SystemsManagerAgent]
(Int -> ReadS SystemsManagerAgent)
-> ReadS [SystemsManagerAgent]
-> ReadPrec SystemsManagerAgent
-> ReadPrec [SystemsManagerAgent]
-> Read SystemsManagerAgent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SystemsManagerAgent]
$creadListPrec :: ReadPrec [SystemsManagerAgent]
readPrec :: ReadPrec SystemsManagerAgent
$creadPrec :: ReadPrec SystemsManagerAgent
readList :: ReadS [SystemsManagerAgent]
$creadList :: ReadS [SystemsManagerAgent]
readsPrec :: Int -> ReadS SystemsManagerAgent
$creadsPrec :: Int -> ReadS SystemsManagerAgent
Prelude.Read, Int -> SystemsManagerAgent -> ShowS
[SystemsManagerAgent] -> ShowS
SystemsManagerAgent -> String
(Int -> SystemsManagerAgent -> ShowS)
-> (SystemsManagerAgent -> String)
-> ([SystemsManagerAgent] -> ShowS)
-> Show SystemsManagerAgent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SystemsManagerAgent] -> ShowS
$cshowList :: [SystemsManagerAgent] -> ShowS
show :: SystemsManagerAgent -> String
$cshow :: SystemsManagerAgent -> String
showsPrec :: Int -> SystemsManagerAgent -> ShowS
$cshowsPrec :: Int -> SystemsManagerAgent -> ShowS
Prelude.Show, (forall x. SystemsManagerAgent -> Rep SystemsManagerAgent x)
-> (forall x. Rep SystemsManagerAgent x -> SystemsManagerAgent)
-> Generic SystemsManagerAgent
forall x. Rep SystemsManagerAgent x -> SystemsManagerAgent
forall x. SystemsManagerAgent -> Rep SystemsManagerAgent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SystemsManagerAgent x -> SystemsManagerAgent
$cfrom :: forall x. SystemsManagerAgent -> Rep SystemsManagerAgent x
Prelude.Generic)

-- |
-- Create a value of 'SystemsManagerAgent' 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:
--
-- 'uninstallAfterBuild', 'systemsManagerAgent_uninstallAfterBuild' - Controls whether the Systems Manager agent is removed from your final
-- build image, prior to creating the new AMI. If this is set to true, then
-- the agent is removed from the final image. If it\'s set to false, then
-- the agent is left in, so that it is included in the new AMI. The default
-- value is false.
newSystemsManagerAgent ::
  SystemsManagerAgent
newSystemsManagerAgent :: SystemsManagerAgent
newSystemsManagerAgent =
  SystemsManagerAgent' :: Maybe Bool -> SystemsManagerAgent
SystemsManagerAgent'
    { $sel:uninstallAfterBuild:SystemsManagerAgent' :: Maybe Bool
uninstallAfterBuild =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Controls whether the Systems Manager agent is removed from your final
-- build image, prior to creating the new AMI. If this is set to true, then
-- the agent is removed from the final image. If it\'s set to false, then
-- the agent is left in, so that it is included in the new AMI. The default
-- value is false.
systemsManagerAgent_uninstallAfterBuild :: Lens.Lens' SystemsManagerAgent (Prelude.Maybe Prelude.Bool)
systemsManagerAgent_uninstallAfterBuild :: (Maybe Bool -> f (Maybe Bool))
-> SystemsManagerAgent -> f SystemsManagerAgent
systemsManagerAgent_uninstallAfterBuild = (SystemsManagerAgent -> Maybe Bool)
-> (SystemsManagerAgent -> Maybe Bool -> SystemsManagerAgent)
-> Lens
     SystemsManagerAgent SystemsManagerAgent (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SystemsManagerAgent' {Maybe Bool
uninstallAfterBuild :: Maybe Bool
$sel:uninstallAfterBuild:SystemsManagerAgent' :: SystemsManagerAgent -> Maybe Bool
uninstallAfterBuild} -> Maybe Bool
uninstallAfterBuild) (\s :: SystemsManagerAgent
s@SystemsManagerAgent' {} Maybe Bool
a -> SystemsManagerAgent
s {$sel:uninstallAfterBuild:SystemsManagerAgent' :: Maybe Bool
uninstallAfterBuild = Maybe Bool
a} :: SystemsManagerAgent)

instance Core.FromJSON SystemsManagerAgent where
  parseJSON :: Value -> Parser SystemsManagerAgent
parseJSON =
    String
-> (Object -> Parser SystemsManagerAgent)
-> Value
-> Parser SystemsManagerAgent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SystemsManagerAgent"
      ( \Object
x ->
          Maybe Bool -> SystemsManagerAgent
SystemsManagerAgent'
            (Maybe Bool -> SystemsManagerAgent)
-> Parser (Maybe Bool) -> Parser SystemsManagerAgent
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
"uninstallAfterBuild")
      )

instance Prelude.Hashable SystemsManagerAgent

instance Prelude.NFData SystemsManagerAgent

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