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

import Amazonka.Config.Types.MemberAccountRuleStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 Core.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
    -- master account calls @PutOrganizationConfigRule@ action for the first
    -- time, config rule status is created in the member account. When master
    -- account calls @PutOrganizationConfigRule@ action for the second time,
    -- config rule status is updated in the member account. Config rule status
    -- is deleted when the master 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
(MemberAccountStatus -> MemberAccountStatus -> Bool)
-> (MemberAccountStatus -> MemberAccountStatus -> Bool)
-> Eq MemberAccountStatus
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]
(Int -> ReadS MemberAccountStatus)
-> ReadS [MemberAccountStatus]
-> ReadPrec MemberAccountStatus
-> ReadPrec [MemberAccountStatus]
-> Read 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
(Int -> MemberAccountStatus -> ShowS)
-> (MemberAccountStatus -> String)
-> ([MemberAccountStatus] -> ShowS)
-> Show MemberAccountStatus
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. MemberAccountStatus -> Rep MemberAccountStatus x)
-> (forall x. Rep MemberAccountStatus x -> MemberAccountStatus)
-> Generic MemberAccountStatus
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
-- master account calls @PutOrganizationConfigRule@ action for the first
-- time, config rule status is created in the member account. When master
-- account calls @PutOrganizationConfigRule@ action for the second time,
-- config rule status is updated in the member account. Config rule status
-- is deleted when the master 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' :: Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Text
-> Text
-> MemberAccountRuleStatus
-> MemberAccountStatus
MemberAccountStatus'
      { $sel:errorCode:MemberAccountStatus' :: Maybe Text
errorCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:errorMessage:MemberAccountStatus' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:lastUpdateTime:MemberAccountStatus' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
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 :: (Maybe Text -> f (Maybe Text))
-> MemberAccountStatus -> f MemberAccountStatus
memberAccountStatus_errorCode = (MemberAccountStatus -> Maybe Text)
-> (MemberAccountStatus -> Maybe Text -> MemberAccountStatus)
-> Lens
     MemberAccountStatus MemberAccountStatus (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> MemberAccountStatus -> f MemberAccountStatus
memberAccountStatus_errorMessage = (MemberAccountStatus -> Maybe Text)
-> (MemberAccountStatus -> Maybe Text -> MemberAccountStatus)
-> Lens
     MemberAccountStatus MemberAccountStatus (Maybe Text) (Maybe Text)
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 :: (Maybe UTCTime -> f (Maybe UTCTime))
-> MemberAccountStatus -> f MemberAccountStatus
memberAccountStatus_lastUpdateTime = (MemberAccountStatus -> Maybe POSIX)
-> (MemberAccountStatus -> Maybe POSIX -> MemberAccountStatus)
-> Lens
     MemberAccountStatus MemberAccountStatus (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> MemberAccountStatus -> f MemberAccountStatus)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> MemberAccountStatus
-> f MemberAccountStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The 12-digit account ID of a member account.
memberAccountStatus_accountId :: Lens.Lens' MemberAccountStatus Prelude.Text
memberAccountStatus_accountId :: (Text -> f Text) -> MemberAccountStatus -> f MemberAccountStatus
memberAccountStatus_accountId = (MemberAccountStatus -> Text)
-> (MemberAccountStatus -> Text -> MemberAccountStatus)
-> Lens MemberAccountStatus MemberAccountStatus Text Text
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 :: (Text -> f Text) -> MemberAccountStatus -> f MemberAccountStatus
memberAccountStatus_configRuleName = (MemberAccountStatus -> Text)
-> (MemberAccountStatus -> Text -> MemberAccountStatus)
-> Lens MemberAccountStatus MemberAccountStatus Text Text
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
-- master account calls @PutOrganizationConfigRule@ action for the first
-- time, config rule status is created in the member account. When master
-- account calls @PutOrganizationConfigRule@ action for the second time,
-- config rule status is updated in the member account. Config rule status
-- is deleted when the master 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 :: (MemberAccountRuleStatus -> f MemberAccountRuleStatus)
-> MemberAccountStatus -> f MemberAccountStatus
memberAccountStatus_memberAccountRuleStatus = (MemberAccountStatus -> MemberAccountRuleStatus)
-> (MemberAccountStatus
    -> MemberAccountRuleStatus -> MemberAccountStatus)
-> Lens
     MemberAccountStatus
     MemberAccountStatus
     MemberAccountRuleStatus
     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 Core.FromJSON MemberAccountStatus where
  parseJSON :: Value -> Parser MemberAccountStatus
parseJSON =
    String
-> (Object -> Parser MemberAccountStatus)
-> Value
-> Parser MemberAccountStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MemberAccountStatus"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Text
-> Text
-> MemberAccountRuleStatus
-> MemberAccountStatus
MemberAccountStatus'
            (Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> Text
 -> Text
 -> MemberAccountRuleStatus
 -> MemberAccountStatus)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Text
      -> Text
      -> MemberAccountRuleStatus
      -> MemberAccountStatus)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ErrorCode")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Text
   -> Text
   -> MemberAccountRuleStatus
   -> MemberAccountStatus)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Text -> Text -> MemberAccountRuleStatus -> MemberAccountStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ErrorMessage")
            Parser
  (Maybe POSIX
   -> Text -> Text -> MemberAccountRuleStatus -> MemberAccountStatus)
-> Parser (Maybe POSIX)
-> Parser
     (Text -> Text -> MemberAccountRuleStatus -> MemberAccountStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastUpdateTime")
            Parser
  (Text -> Text -> MemberAccountRuleStatus -> MemberAccountStatus)
-> Parser Text
-> Parser (Text -> MemberAccountRuleStatus -> MemberAccountStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AccountId")
            Parser (Text -> MemberAccountRuleStatus -> MemberAccountStatus)
-> Parser Text
-> Parser (MemberAccountRuleStatus -> MemberAccountStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ConfigRuleName")
            Parser (MemberAccountRuleStatus -> MemberAccountStatus)
-> Parser MemberAccountRuleStatus -> Parser MemberAccountStatus
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser MemberAccountRuleStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MemberAccountRuleStatus")
      )

instance Prelude.Hashable MemberAccountStatus

instance Prelude.NFData MemberAccountStatus