{-# 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.Config.Types.MemberAccountStatus
-- 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.Config.Types.MemberAccountStatus where

import Amazonka.Config.Types.MemberAccountRuleStatus
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

-- | Organization Config rule creation or deletion status in each member
-- account. This includes the name of the rule, the status, error code and
-- error message when the rule creation or deletion failed.
--
-- /See:/ 'newMemberAccountStatus' smart constructor.
data MemberAccountStatus = MemberAccountStatus'
  { -- | An error code that is returned when Config rule creation or deletion
    -- failed in the member account.
    MemberAccountStatus -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | An error message indicating that Config rule account creation or
    -- deletion has failed due to an error in the member account.
    MemberAccountStatus -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | The timestamp of the last status update.
    MemberAccountStatus -> Maybe POSIX
lastUpdateTime :: Prelude.Maybe Data.POSIX,
    -- | The 12-digit account ID of a member account.
    MemberAccountStatus -> Text
accountId :: Prelude.Text,
    -- | The name of Config rule deployed in the member account.
    MemberAccountStatus -> Text
configRuleName :: Prelude.Text,
    -- | Indicates deployment status for Config rule in the member account. When
    -- management account calls @PutOrganizationConfigRule@ action for the
    -- first time, Config rule status is created in the member account. When
    -- management account calls @PutOrganizationConfigRule@ action for the
    -- second time, Config rule status is updated in the member account. Config
    -- rule status is deleted when the management account deletes
    -- @OrganizationConfigRule@ and disables service access for
    -- @config-multiaccountsetup.amazonaws.com@.
    --
    -- Config sets the state of the rule to:
    --
    -- -   @CREATE_SUCCESSFUL@ when Config rule has been created in the member
    --     account.
    --
    -- -   @CREATE_IN_PROGRESS@ when Config rule is being created in the member
    --     account.
    --
    -- -   @CREATE_FAILED@ when Config rule creation has failed in the member
    --     account.
    --
    -- -   @DELETE_FAILED@ when Config rule deletion has failed in the member
    --     account.
    --
    -- -   @DELETE_IN_PROGRESS@ when Config rule is being deleted in the member
    --     account.
    --
    -- -   @DELETE_SUCCESSFUL@ when Config rule has been deleted in the member
    --     account.
    --
    -- -   @UPDATE_SUCCESSFUL@ when Config rule has been updated in the member
    --     account.
    --
    -- -   @UPDATE_IN_PROGRESS@ when Config rule is being updated in the member
    --     account.
    --
    -- -   @UPDATE_FAILED@ when Config rule deletion has failed in the member
    --     account.
    MemberAccountStatus -> MemberAccountRuleStatus
memberAccountRuleStatus :: MemberAccountRuleStatus
  }
  deriving (MemberAccountStatus -> MemberAccountStatus -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MemberAccountStatus -> MemberAccountStatus -> Bool
$c/= :: MemberAccountStatus -> MemberAccountStatus -> Bool
== :: MemberAccountStatus -> MemberAccountStatus -> Bool
$c== :: MemberAccountStatus -> MemberAccountStatus -> Bool
Prelude.Eq, ReadPrec [MemberAccountStatus]
ReadPrec MemberAccountStatus
Int -> ReadS MemberAccountStatus
ReadS [MemberAccountStatus]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MemberAccountStatus]
$creadListPrec :: ReadPrec [MemberAccountStatus]
readPrec :: ReadPrec MemberAccountStatus
$creadPrec :: ReadPrec MemberAccountStatus
readList :: ReadS [MemberAccountStatus]
$creadList :: ReadS [MemberAccountStatus]
readsPrec :: Int -> ReadS MemberAccountStatus
$creadsPrec :: Int -> ReadS MemberAccountStatus
Prelude.Read, Int -> MemberAccountStatus -> ShowS
[MemberAccountStatus] -> ShowS
MemberAccountStatus -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MemberAccountStatus] -> ShowS
$cshowList :: [MemberAccountStatus] -> ShowS
show :: MemberAccountStatus -> String
$cshow :: MemberAccountStatus -> String
showsPrec :: Int -> MemberAccountStatus -> ShowS
$cshowsPrec :: Int -> MemberAccountStatus -> ShowS
Prelude.Show, forall x. Rep MemberAccountStatus x -> MemberAccountStatus
forall x. MemberAccountStatus -> Rep MemberAccountStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MemberAccountStatus x -> MemberAccountStatus
$cfrom :: forall x. MemberAccountStatus -> Rep MemberAccountStatus x
Prelude.Generic)

-- |
-- Create a value of 'MemberAccountStatus' 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:
--
-- 'errorCode', 'memberAccountStatus_errorCode' - An error code that is returned when Config rule creation or deletion
-- failed in the member account.
--
-- 'errorMessage', 'memberAccountStatus_errorMessage' - An error message indicating that Config rule account creation or
-- deletion has failed due to an error in the member account.
--
-- 'lastUpdateTime', 'memberAccountStatus_lastUpdateTime' - The timestamp of the last status update.
--
-- 'accountId', 'memberAccountStatus_accountId' - The 12-digit account ID of a member account.
--
-- 'configRuleName', 'memberAccountStatus_configRuleName' - The name of Config rule deployed in the member account.
--
-- 'memberAccountRuleStatus', 'memberAccountStatus_memberAccountRuleStatus' - Indicates deployment status for Config rule in the member account. When
-- management account calls @PutOrganizationConfigRule@ action for the
-- first time, Config rule status is created in the member account. When
-- management account calls @PutOrganizationConfigRule@ action for the
-- second time, Config rule status is updated in the member account. Config
-- rule status is deleted when the management account deletes
-- @OrganizationConfigRule@ and disables service access for
-- @config-multiaccountsetup.amazonaws.com@.
--
-- Config sets the state of the rule to:
--
-- -   @CREATE_SUCCESSFUL@ when Config rule has been created in the member
--     account.
--
-- -   @CREATE_IN_PROGRESS@ when Config rule is being created in the member
--     account.
--
-- -   @CREATE_FAILED@ when Config rule creation has failed in the member
--     account.
--
-- -   @DELETE_FAILED@ when Config rule deletion has failed in the member
--     account.
--
-- -   @DELETE_IN_PROGRESS@ when Config rule is being deleted in the member
--     account.
--
-- -   @DELETE_SUCCESSFUL@ when Config rule has been deleted in the member
--     account.
--
-- -   @UPDATE_SUCCESSFUL@ when Config rule has been updated in the member
--     account.
--
-- -   @UPDATE_IN_PROGRESS@ when Config rule is being updated in the member
--     account.
--
-- -   @UPDATE_FAILED@ when Config rule deletion has failed in the member
--     account.
newMemberAccountStatus ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'configRuleName'
  Prelude.Text ->
  -- | 'memberAccountRuleStatus'
  MemberAccountRuleStatus ->
  MemberAccountStatus
newMemberAccountStatus :: Text -> Text -> MemberAccountRuleStatus -> MemberAccountStatus
newMemberAccountStatus
  Text
pAccountId_
  Text
pConfigRuleName_
  MemberAccountRuleStatus
pMemberAccountRuleStatus_ =
    MemberAccountStatus'
      { $sel:errorCode:MemberAccountStatus' :: Maybe Text
errorCode = forall a. Maybe a
Prelude.Nothing,
        $sel:errorMessage:MemberAccountStatus' :: Maybe Text
errorMessage = forall a. Maybe a
Prelude.Nothing,
        $sel:lastUpdateTime:MemberAccountStatus' :: Maybe POSIX
lastUpdateTime = forall a. Maybe a
Prelude.Nothing,
        $sel:accountId:MemberAccountStatus' :: Text
accountId = Text
pAccountId_,
        $sel:configRuleName:MemberAccountStatus' :: Text
configRuleName = Text
pConfigRuleName_,
        $sel:memberAccountRuleStatus:MemberAccountStatus' :: MemberAccountRuleStatus
memberAccountRuleStatus = MemberAccountRuleStatus
pMemberAccountRuleStatus_
      }

-- | An error code that is returned when Config rule creation or deletion
-- failed in the member account.
memberAccountStatus_errorCode :: Lens.Lens' MemberAccountStatus (Prelude.Maybe Prelude.Text)
memberAccountStatus_errorCode :: Lens' MemberAccountStatus (Maybe Text)
memberAccountStatus_errorCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberAccountStatus' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:MemberAccountStatus' :: MemberAccountStatus -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: MemberAccountStatus
s@MemberAccountStatus' {} Maybe Text
a -> MemberAccountStatus
s {$sel:errorCode:MemberAccountStatus' :: Maybe Text
errorCode = Maybe Text
a} :: MemberAccountStatus)

-- | An error message indicating that Config rule account creation or
-- deletion has failed due to an error in the member account.
memberAccountStatus_errorMessage :: Lens.Lens' MemberAccountStatus (Prelude.Maybe Prelude.Text)
memberAccountStatus_errorMessage :: Lens' MemberAccountStatus (Maybe Text)
memberAccountStatus_errorMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberAccountStatus' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:MemberAccountStatus' :: MemberAccountStatus -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: MemberAccountStatus
s@MemberAccountStatus' {} Maybe Text
a -> MemberAccountStatus
s {$sel:errorMessage:MemberAccountStatus' :: Maybe Text
errorMessage = Maybe Text
a} :: MemberAccountStatus)

-- | The timestamp of the last status update.
memberAccountStatus_lastUpdateTime :: Lens.Lens' MemberAccountStatus (Prelude.Maybe Prelude.UTCTime)
memberAccountStatus_lastUpdateTime :: Lens' MemberAccountStatus (Maybe UTCTime)
memberAccountStatus_lastUpdateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberAccountStatus' {Maybe POSIX
lastUpdateTime :: Maybe POSIX
$sel:lastUpdateTime:MemberAccountStatus' :: MemberAccountStatus -> Maybe POSIX
lastUpdateTime} -> Maybe POSIX
lastUpdateTime) (\s :: MemberAccountStatus
s@MemberAccountStatus' {} Maybe POSIX
a -> MemberAccountStatus
s {$sel:lastUpdateTime:MemberAccountStatus' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
a} :: MemberAccountStatus) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The 12-digit account ID of a member account.
memberAccountStatus_accountId :: Lens.Lens' MemberAccountStatus Prelude.Text
memberAccountStatus_accountId :: Lens' MemberAccountStatus Text
memberAccountStatus_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberAccountStatus' {Text
accountId :: Text
$sel:accountId:MemberAccountStatus' :: MemberAccountStatus -> Text
accountId} -> Text
accountId) (\s :: MemberAccountStatus
s@MemberAccountStatus' {} Text
a -> MemberAccountStatus
s {$sel:accountId:MemberAccountStatus' :: Text
accountId = Text
a} :: MemberAccountStatus)

-- | The name of Config rule deployed in the member account.
memberAccountStatus_configRuleName :: Lens.Lens' MemberAccountStatus Prelude.Text
memberAccountStatus_configRuleName :: Lens' MemberAccountStatus Text
memberAccountStatus_configRuleName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberAccountStatus' {Text
configRuleName :: Text
$sel:configRuleName:MemberAccountStatus' :: MemberAccountStatus -> Text
configRuleName} -> Text
configRuleName) (\s :: MemberAccountStatus
s@MemberAccountStatus' {} Text
a -> MemberAccountStatus
s {$sel:configRuleName:MemberAccountStatus' :: Text
configRuleName = Text
a} :: MemberAccountStatus)

-- | Indicates deployment status for Config rule in the member account. When
-- management account calls @PutOrganizationConfigRule@ action for the
-- first time, Config rule status is created in the member account. When
-- management account calls @PutOrganizationConfigRule@ action for the
-- second time, Config rule status is updated in the member account. Config
-- rule status is deleted when the management account deletes
-- @OrganizationConfigRule@ and disables service access for
-- @config-multiaccountsetup.amazonaws.com@.
--
-- Config sets the state of the rule to:
--
-- -   @CREATE_SUCCESSFUL@ when Config rule has been created in the member
--     account.
--
-- -   @CREATE_IN_PROGRESS@ when Config rule is being created in the member
--     account.
--
-- -   @CREATE_FAILED@ when Config rule creation has failed in the member
--     account.
--
-- -   @DELETE_FAILED@ when Config rule deletion has failed in the member
--     account.
--
-- -   @DELETE_IN_PROGRESS@ when Config rule is being deleted in the member
--     account.
--
-- -   @DELETE_SUCCESSFUL@ when Config rule has been deleted in the member
--     account.
--
-- -   @UPDATE_SUCCESSFUL@ when Config rule has been updated in the member
--     account.
--
-- -   @UPDATE_IN_PROGRESS@ when Config rule is being updated in the member
--     account.
--
-- -   @UPDATE_FAILED@ when Config rule deletion has failed in the member
--     account.
memberAccountStatus_memberAccountRuleStatus :: Lens.Lens' MemberAccountStatus MemberAccountRuleStatus
memberAccountStatus_memberAccountRuleStatus :: Lens' MemberAccountStatus MemberAccountRuleStatus
memberAccountStatus_memberAccountRuleStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberAccountStatus' {MemberAccountRuleStatus
memberAccountRuleStatus :: MemberAccountRuleStatus
$sel:memberAccountRuleStatus:MemberAccountStatus' :: MemberAccountStatus -> MemberAccountRuleStatus
memberAccountRuleStatus} -> MemberAccountRuleStatus
memberAccountRuleStatus) (\s :: MemberAccountStatus
s@MemberAccountStatus' {} MemberAccountRuleStatus
a -> MemberAccountStatus
s {$sel:memberAccountRuleStatus:MemberAccountStatus' :: MemberAccountRuleStatus
memberAccountRuleStatus = MemberAccountRuleStatus
a} :: MemberAccountStatus)

instance Data.FromJSON MemberAccountStatus where
  parseJSON :: Value -> Parser MemberAccountStatus
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MemberAccountStatus"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Text
-> Text
-> MemberAccountRuleStatus
-> MemberAccountStatus
MemberAccountStatus'
            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
"ErrorCode")
            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
"ErrorMessage")
            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
"LastUpdateTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AccountId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ConfigRuleName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MemberAccountRuleStatus")
      )

instance Prelude.Hashable MemberAccountStatus where
  hashWithSalt :: Int -> MemberAccountStatus -> Int
hashWithSalt Int
_salt MemberAccountStatus' {Maybe Text
Maybe POSIX
Text
MemberAccountRuleStatus
memberAccountRuleStatus :: MemberAccountRuleStatus
configRuleName :: Text
accountId :: Text
lastUpdateTime :: Maybe POSIX
errorMessage :: Maybe Text
errorCode :: Maybe Text
$sel:memberAccountRuleStatus:MemberAccountStatus' :: MemberAccountStatus -> MemberAccountRuleStatus
$sel:configRuleName:MemberAccountStatus' :: MemberAccountStatus -> Text
$sel:accountId:MemberAccountStatus' :: MemberAccountStatus -> Text
$sel:lastUpdateTime:MemberAccountStatus' :: MemberAccountStatus -> Maybe POSIX
$sel:errorMessage:MemberAccountStatus' :: MemberAccountStatus -> Maybe Text
$sel:errorCode:MemberAccountStatus' :: MemberAccountStatus -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastUpdateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
configRuleName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` MemberAccountRuleStatus
memberAccountRuleStatus

instance Prelude.NFData MemberAccountStatus where
  rnf :: MemberAccountStatus -> ()
rnf MemberAccountStatus' {Maybe Text
Maybe POSIX
Text
MemberAccountRuleStatus
memberAccountRuleStatus :: MemberAccountRuleStatus
configRuleName :: Text
accountId :: Text
lastUpdateTime :: Maybe POSIX
errorMessage :: Maybe Text
errorCode :: Maybe Text
$sel:memberAccountRuleStatus:MemberAccountStatus' :: MemberAccountStatus -> MemberAccountRuleStatus
$sel:configRuleName:MemberAccountStatus' :: MemberAccountStatus -> Text
$sel:accountId:MemberAccountStatus' :: MemberAccountStatus -> Text
$sel:lastUpdateTime:MemberAccountStatus' :: MemberAccountStatus -> Maybe POSIX
$sel:errorMessage:MemberAccountStatus' :: MemberAccountStatus -> Maybe Text
$sel:errorCode:MemberAccountStatus' :: MemberAccountStatus -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastUpdateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
configRuleName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf MemberAccountRuleStatus
memberAccountRuleStatus