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

import Amazonka.CloudFormation.Types.AccountGateStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Structure that contains the results of the account gate function which
-- CloudFormation invokes, if present, before proceeding with a stack set
-- operation in an account and Region.
--
-- For each account and Region, CloudFormation lets you specify a Lambda
-- function that encapsulates any requirements that must be met before
-- CloudFormation can proceed with a stack set operation in that account
-- and Region. CloudFormation invokes the function each time a stack set
-- operation is requested for that account and Region; if the function
-- returns @FAILED@, CloudFormation cancels the operation in that account
-- and Region, and sets the stack set operation result status for that
-- account and Region to @FAILED@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-account-gating.html Configuring a target account gate>.
--
-- /See:/ 'newAccountGateResult' smart constructor.
data AccountGateResult = AccountGateResult'
  { -- | The status of the account gate function.
    --
    -- -   @SUCCEEDED@: The account gate function has determined that the
    --     account and Region passes any requirements for a stack set operation
    --     to occur. CloudFormation proceeds with the stack operation in that
    --     account and Region.
    --
    -- -   @FAILED@: The account gate function has determined that the account
    --     and Region does not meet the requirements for a stack set operation
    --     to occur. AWS CloudFormation cancels the stack set operation in that
    --     account and Region, and sets the stack set operation result status
    --     for that account and Region to @FAILED@.
    --
    -- -   @SKIPPED@: CloudFormation has skipped calling the account gate
    --     function for this account and Region, for one of the following
    --     reasons:
    --
    --     -   An account gate function has not been specified for the account
    --         and Region. CloudFormation proceeds with the stack set operation
    --         in this account and Region.
    --
    --     -   The @AWSCloudFormationStackSetExecutionRole@ of the stack set
    --         adminstration account lacks permissions to invoke the function.
    --         CloudFormation proceeds with the stack set operation in this
    --         account and Region.
    --
    --     -   Either no action is necessary, or no action is possible, on the
    --         stack. CloudFormation skips the stack set operation in this
    --         account and Region.
    AccountGateResult -> Maybe AccountGateStatus
status :: Prelude.Maybe AccountGateStatus,
    -- | The reason for the account gate status assigned to this account and
    -- Region for the stack set operation.
    AccountGateResult -> Maybe Text
statusReason :: Prelude.Maybe Prelude.Text
  }
  deriving (AccountGateResult -> AccountGateResult -> Bool
(AccountGateResult -> AccountGateResult -> Bool)
-> (AccountGateResult -> AccountGateResult -> Bool)
-> Eq AccountGateResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountGateResult -> AccountGateResult -> Bool
$c/= :: AccountGateResult -> AccountGateResult -> Bool
== :: AccountGateResult -> AccountGateResult -> Bool
$c== :: AccountGateResult -> AccountGateResult -> Bool
Prelude.Eq, ReadPrec [AccountGateResult]
ReadPrec AccountGateResult
Int -> ReadS AccountGateResult
ReadS [AccountGateResult]
(Int -> ReadS AccountGateResult)
-> ReadS [AccountGateResult]
-> ReadPrec AccountGateResult
-> ReadPrec [AccountGateResult]
-> Read AccountGateResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccountGateResult]
$creadListPrec :: ReadPrec [AccountGateResult]
readPrec :: ReadPrec AccountGateResult
$creadPrec :: ReadPrec AccountGateResult
readList :: ReadS [AccountGateResult]
$creadList :: ReadS [AccountGateResult]
readsPrec :: Int -> ReadS AccountGateResult
$creadsPrec :: Int -> ReadS AccountGateResult
Prelude.Read, Int -> AccountGateResult -> ShowS
[AccountGateResult] -> ShowS
AccountGateResult -> String
(Int -> AccountGateResult -> ShowS)
-> (AccountGateResult -> String)
-> ([AccountGateResult] -> ShowS)
-> Show AccountGateResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountGateResult] -> ShowS
$cshowList :: [AccountGateResult] -> ShowS
show :: AccountGateResult -> String
$cshow :: AccountGateResult -> String
showsPrec :: Int -> AccountGateResult -> ShowS
$cshowsPrec :: Int -> AccountGateResult -> ShowS
Prelude.Show, (forall x. AccountGateResult -> Rep AccountGateResult x)
-> (forall x. Rep AccountGateResult x -> AccountGateResult)
-> Generic AccountGateResult
forall x. Rep AccountGateResult x -> AccountGateResult
forall x. AccountGateResult -> Rep AccountGateResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccountGateResult x -> AccountGateResult
$cfrom :: forall x. AccountGateResult -> Rep AccountGateResult x
Prelude.Generic)

-- |
-- Create a value of 'AccountGateResult' 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:
--
-- 'status', 'accountGateResult_status' - The status of the account gate function.
--
-- -   @SUCCEEDED@: The account gate function has determined that the
--     account and Region passes any requirements for a stack set operation
--     to occur. CloudFormation proceeds with the stack operation in that
--     account and Region.
--
-- -   @FAILED@: The account gate function has determined that the account
--     and Region does not meet the requirements for a stack set operation
--     to occur. AWS CloudFormation cancels the stack set operation in that
--     account and Region, and sets the stack set operation result status
--     for that account and Region to @FAILED@.
--
-- -   @SKIPPED@: CloudFormation has skipped calling the account gate
--     function for this account and Region, for one of the following
--     reasons:
--
--     -   An account gate function has not been specified for the account
--         and Region. CloudFormation proceeds with the stack set operation
--         in this account and Region.
--
--     -   The @AWSCloudFormationStackSetExecutionRole@ of the stack set
--         adminstration account lacks permissions to invoke the function.
--         CloudFormation proceeds with the stack set operation in this
--         account and Region.
--
--     -   Either no action is necessary, or no action is possible, on the
--         stack. CloudFormation skips the stack set operation in this
--         account and Region.
--
-- 'statusReason', 'accountGateResult_statusReason' - The reason for the account gate status assigned to this account and
-- Region for the stack set operation.
newAccountGateResult ::
  AccountGateResult
newAccountGateResult :: AccountGateResult
newAccountGateResult =
  AccountGateResult' :: Maybe AccountGateStatus -> Maybe Text -> AccountGateResult
AccountGateResult'
    { $sel:status:AccountGateResult' :: Maybe AccountGateStatus
status = Maybe AccountGateStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:statusReason:AccountGateResult' :: Maybe Text
statusReason = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the account gate function.
--
-- -   @SUCCEEDED@: The account gate function has determined that the
--     account and Region passes any requirements for a stack set operation
--     to occur. CloudFormation proceeds with the stack operation in that
--     account and Region.
--
-- -   @FAILED@: The account gate function has determined that the account
--     and Region does not meet the requirements for a stack set operation
--     to occur. AWS CloudFormation cancels the stack set operation in that
--     account and Region, and sets the stack set operation result status
--     for that account and Region to @FAILED@.
--
-- -   @SKIPPED@: CloudFormation has skipped calling the account gate
--     function for this account and Region, for one of the following
--     reasons:
--
--     -   An account gate function has not been specified for the account
--         and Region. CloudFormation proceeds with the stack set operation
--         in this account and Region.
--
--     -   The @AWSCloudFormationStackSetExecutionRole@ of the stack set
--         adminstration account lacks permissions to invoke the function.
--         CloudFormation proceeds with the stack set operation in this
--         account and Region.
--
--     -   Either no action is necessary, or no action is possible, on the
--         stack. CloudFormation skips the stack set operation in this
--         account and Region.
accountGateResult_status :: Lens.Lens' AccountGateResult (Prelude.Maybe AccountGateStatus)
accountGateResult_status :: (Maybe AccountGateStatus -> f (Maybe AccountGateStatus))
-> AccountGateResult -> f AccountGateResult
accountGateResult_status = (AccountGateResult -> Maybe AccountGateStatus)
-> (AccountGateResult
    -> Maybe AccountGateStatus -> AccountGateResult)
-> Lens
     AccountGateResult
     AccountGateResult
     (Maybe AccountGateStatus)
     (Maybe AccountGateStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountGateResult' {Maybe AccountGateStatus
status :: Maybe AccountGateStatus
$sel:status:AccountGateResult' :: AccountGateResult -> Maybe AccountGateStatus
status} -> Maybe AccountGateStatus
status) (\s :: AccountGateResult
s@AccountGateResult' {} Maybe AccountGateStatus
a -> AccountGateResult
s {$sel:status:AccountGateResult' :: Maybe AccountGateStatus
status = Maybe AccountGateStatus
a} :: AccountGateResult)

-- | The reason for the account gate status assigned to this account and
-- Region for the stack set operation.
accountGateResult_statusReason :: Lens.Lens' AccountGateResult (Prelude.Maybe Prelude.Text)
accountGateResult_statusReason :: (Maybe Text -> f (Maybe Text))
-> AccountGateResult -> f AccountGateResult
accountGateResult_statusReason = (AccountGateResult -> Maybe Text)
-> (AccountGateResult -> Maybe Text -> AccountGateResult)
-> Lens
     AccountGateResult AccountGateResult (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountGateResult' {Maybe Text
statusReason :: Maybe Text
$sel:statusReason:AccountGateResult' :: AccountGateResult -> Maybe Text
statusReason} -> Maybe Text
statusReason) (\s :: AccountGateResult
s@AccountGateResult' {} Maybe Text
a -> AccountGateResult
s {$sel:statusReason:AccountGateResult' :: Maybe Text
statusReason = Maybe Text
a} :: AccountGateResult)

instance Core.FromXML AccountGateResult where
  parseXML :: [Node] -> Either String AccountGateResult
parseXML [Node]
x =
    Maybe AccountGateStatus -> Maybe Text -> AccountGateResult
AccountGateResult'
      (Maybe AccountGateStatus -> Maybe Text -> AccountGateResult)
-> Either String (Maybe AccountGateStatus)
-> Either String (Maybe Text -> AccountGateResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe AccountGateStatus)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Status")
      Either String (Maybe Text -> AccountGateResult)
-> Either String (Maybe Text) -> Either String AccountGateResult
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"StatusReason")

instance Prelude.Hashable AccountGateResult

instance Prelude.NFData AccountGateResult