{-# 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.CloudFormation.Types.AutoDeployment
-- 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.CloudFormation.Types.AutoDeployment where

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

-- | [Service-managed permissions] Describes whether StackSets automatically
-- deploys to Organizations accounts that are added to a target
-- organization or organizational unit (OU).
--
-- /See:/ 'newAutoDeployment' smart constructor.
data AutoDeployment = AutoDeployment'
  { -- | If set to @true@, StackSets automatically deploys additional stack
    -- instances to Organizations accounts that are added to a target
    -- organization or organizational unit (OU) in the specified Regions. If an
    -- account is removed from a target organization or OU, StackSets deletes
    -- stack instances from the account in the specified Regions.
    AutoDeployment -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | If set to @true@, stack resources are retained when an account is
    -- removed from a target organization or OU. If set to @false@, stack
    -- resources are deleted. Specify only if @Enabled@ is set to @True@.
    AutoDeployment -> Maybe Bool
retainStacksOnAccountRemoval :: Prelude.Maybe Prelude.Bool
  }
  deriving (AutoDeployment -> AutoDeployment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoDeployment -> AutoDeployment -> Bool
$c/= :: AutoDeployment -> AutoDeployment -> Bool
== :: AutoDeployment -> AutoDeployment -> Bool
$c== :: AutoDeployment -> AutoDeployment -> Bool
Prelude.Eq, ReadPrec [AutoDeployment]
ReadPrec AutoDeployment
Int -> ReadS AutoDeployment
ReadS [AutoDeployment]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoDeployment]
$creadListPrec :: ReadPrec [AutoDeployment]
readPrec :: ReadPrec AutoDeployment
$creadPrec :: ReadPrec AutoDeployment
readList :: ReadS [AutoDeployment]
$creadList :: ReadS [AutoDeployment]
readsPrec :: Int -> ReadS AutoDeployment
$creadsPrec :: Int -> ReadS AutoDeployment
Prelude.Read, Int -> AutoDeployment -> ShowS
[AutoDeployment] -> ShowS
AutoDeployment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoDeployment] -> ShowS
$cshowList :: [AutoDeployment] -> ShowS
show :: AutoDeployment -> String
$cshow :: AutoDeployment -> String
showsPrec :: Int -> AutoDeployment -> ShowS
$cshowsPrec :: Int -> AutoDeployment -> ShowS
Prelude.Show, forall x. Rep AutoDeployment x -> AutoDeployment
forall x. AutoDeployment -> Rep AutoDeployment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AutoDeployment x -> AutoDeployment
$cfrom :: forall x. AutoDeployment -> Rep AutoDeployment x
Prelude.Generic)

-- |
-- Create a value of 'AutoDeployment' 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:
--
-- 'enabled', 'autoDeployment_enabled' - If set to @true@, StackSets automatically deploys additional stack
-- instances to Organizations accounts that are added to a target
-- organization or organizational unit (OU) in the specified Regions. If an
-- account is removed from a target organization or OU, StackSets deletes
-- stack instances from the account in the specified Regions.
--
-- 'retainStacksOnAccountRemoval', 'autoDeployment_retainStacksOnAccountRemoval' - If set to @true@, stack resources are retained when an account is
-- removed from a target organization or OU. If set to @false@, stack
-- resources are deleted. Specify only if @Enabled@ is set to @True@.
newAutoDeployment ::
  AutoDeployment
newAutoDeployment :: AutoDeployment
newAutoDeployment =
  AutoDeployment'
    { $sel:enabled:AutoDeployment' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing,
      $sel:retainStacksOnAccountRemoval:AutoDeployment' :: Maybe Bool
retainStacksOnAccountRemoval = forall a. Maybe a
Prelude.Nothing
    }

-- | If set to @true@, StackSets automatically deploys additional stack
-- instances to Organizations accounts that are added to a target
-- organization or organizational unit (OU) in the specified Regions. If an
-- account is removed from a target organization or OU, StackSets deletes
-- stack instances from the account in the specified Regions.
autoDeployment_enabled :: Lens.Lens' AutoDeployment (Prelude.Maybe Prelude.Bool)
autoDeployment_enabled :: Lens' AutoDeployment (Maybe Bool)
autoDeployment_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoDeployment' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:AutoDeployment' :: AutoDeployment -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: AutoDeployment
s@AutoDeployment' {} Maybe Bool
a -> AutoDeployment
s {$sel:enabled:AutoDeployment' :: Maybe Bool
enabled = Maybe Bool
a} :: AutoDeployment)

-- | If set to @true@, stack resources are retained when an account is
-- removed from a target organization or OU. If set to @false@, stack
-- resources are deleted. Specify only if @Enabled@ is set to @True@.
autoDeployment_retainStacksOnAccountRemoval :: Lens.Lens' AutoDeployment (Prelude.Maybe Prelude.Bool)
autoDeployment_retainStacksOnAccountRemoval :: Lens' AutoDeployment (Maybe Bool)
autoDeployment_retainStacksOnAccountRemoval = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoDeployment' {Maybe Bool
retainStacksOnAccountRemoval :: Maybe Bool
$sel:retainStacksOnAccountRemoval:AutoDeployment' :: AutoDeployment -> Maybe Bool
retainStacksOnAccountRemoval} -> Maybe Bool
retainStacksOnAccountRemoval) (\s :: AutoDeployment
s@AutoDeployment' {} Maybe Bool
a -> AutoDeployment
s {$sel:retainStacksOnAccountRemoval:AutoDeployment' :: Maybe Bool
retainStacksOnAccountRemoval = Maybe Bool
a} :: AutoDeployment)

instance Data.FromXML AutoDeployment where
  parseXML :: [Node] -> Either String AutoDeployment
parseXML [Node]
x =
    Maybe Bool -> Maybe Bool -> AutoDeployment
AutoDeployment'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Enabled")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"RetainStacksOnAccountRemoval")

instance Prelude.Hashable AutoDeployment where
  hashWithSalt :: Int -> AutoDeployment -> Int
hashWithSalt Int
_salt AutoDeployment' {Maybe Bool
retainStacksOnAccountRemoval :: Maybe Bool
enabled :: Maybe Bool
$sel:retainStacksOnAccountRemoval:AutoDeployment' :: AutoDeployment -> Maybe Bool
$sel:enabled:AutoDeployment' :: AutoDeployment -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
retainStacksOnAccountRemoval

instance Prelude.NFData AutoDeployment where
  rnf :: AutoDeployment -> ()
rnf AutoDeployment' {Maybe Bool
retainStacksOnAccountRemoval :: Maybe Bool
enabled :: Maybe Bool
$sel:retainStacksOnAccountRemoval:AutoDeployment' :: AutoDeployment -> Maybe Bool
$sel:enabled:AutoDeployment' :: AutoDeployment -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
retainStacksOnAccountRemoval

instance Data.ToQuery AutoDeployment where
  toQuery :: AutoDeployment -> QueryString
toQuery AutoDeployment' {Maybe Bool
retainStacksOnAccountRemoval :: Maybe Bool
enabled :: Maybe Bool
$sel:retainStacksOnAccountRemoval:AutoDeployment' :: AutoDeployment -> Maybe Bool
$sel:enabled:AutoDeployment' :: AutoDeployment -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Enabled" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
enabled,
        ByteString
"RetainStacksOnAccountRemoval"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
retainStacksOnAccountRemoval
      ]