{-# 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.OrganizationConfigRule
-- 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.OrganizationConfigRule where

import Amazonka.Config.Types.OrganizationCustomRuleMetadata
import Amazonka.Config.Types.OrganizationManagedRuleMetadata
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An organization config rule that has information about config rules that
-- Config creates in member accounts.
--
-- /See:/ 'newOrganizationConfigRule' smart constructor.
data OrganizationConfigRule = OrganizationConfigRule'
  { -- | An @OrganizationManagedRuleMetadata@ object.
    OrganizationConfigRule -> Maybe OrganizationManagedRuleMetadata
organizationManagedRuleMetadata :: Prelude.Maybe OrganizationManagedRuleMetadata,
    -- | A comma-separated list of accounts excluded from organization config
    -- rule.
    OrganizationConfigRule -> Maybe [Text]
excludedAccounts :: Prelude.Maybe [Prelude.Text],
    -- | An @OrganizationCustomRuleMetadata@ object.
    OrganizationConfigRule -> Maybe OrganizationCustomRuleMetadata
organizationCustomRuleMetadata :: Prelude.Maybe OrganizationCustomRuleMetadata,
    -- | The timestamp of the last update.
    OrganizationConfigRule -> Maybe POSIX
lastUpdateTime :: Prelude.Maybe Core.POSIX,
    -- | The name that you assign to organization config rule.
    OrganizationConfigRule -> Text
organizationConfigRuleName :: Prelude.Text,
    -- | Amazon Resource Name (ARN) of organization config rule.
    OrganizationConfigRule -> Text
organizationConfigRuleArn :: Prelude.Text
  }
  deriving (OrganizationConfigRule -> OrganizationConfigRule -> Bool
(OrganizationConfigRule -> OrganizationConfigRule -> Bool)
-> (OrganizationConfigRule -> OrganizationConfigRule -> Bool)
-> Eq OrganizationConfigRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OrganizationConfigRule -> OrganizationConfigRule -> Bool
$c/= :: OrganizationConfigRule -> OrganizationConfigRule -> Bool
== :: OrganizationConfigRule -> OrganizationConfigRule -> Bool
$c== :: OrganizationConfigRule -> OrganizationConfigRule -> Bool
Prelude.Eq, ReadPrec [OrganizationConfigRule]
ReadPrec OrganizationConfigRule
Int -> ReadS OrganizationConfigRule
ReadS [OrganizationConfigRule]
(Int -> ReadS OrganizationConfigRule)
-> ReadS [OrganizationConfigRule]
-> ReadPrec OrganizationConfigRule
-> ReadPrec [OrganizationConfigRule]
-> Read OrganizationConfigRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OrganizationConfigRule]
$creadListPrec :: ReadPrec [OrganizationConfigRule]
readPrec :: ReadPrec OrganizationConfigRule
$creadPrec :: ReadPrec OrganizationConfigRule
readList :: ReadS [OrganizationConfigRule]
$creadList :: ReadS [OrganizationConfigRule]
readsPrec :: Int -> ReadS OrganizationConfigRule
$creadsPrec :: Int -> ReadS OrganizationConfigRule
Prelude.Read, Int -> OrganizationConfigRule -> ShowS
[OrganizationConfigRule] -> ShowS
OrganizationConfigRule -> String
(Int -> OrganizationConfigRule -> ShowS)
-> (OrganizationConfigRule -> String)
-> ([OrganizationConfigRule] -> ShowS)
-> Show OrganizationConfigRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OrganizationConfigRule] -> ShowS
$cshowList :: [OrganizationConfigRule] -> ShowS
show :: OrganizationConfigRule -> String
$cshow :: OrganizationConfigRule -> String
showsPrec :: Int -> OrganizationConfigRule -> ShowS
$cshowsPrec :: Int -> OrganizationConfigRule -> ShowS
Prelude.Show, (forall x. OrganizationConfigRule -> Rep OrganizationConfigRule x)
-> (forall x.
    Rep OrganizationConfigRule x -> OrganizationConfigRule)
-> Generic OrganizationConfigRule
forall x. Rep OrganizationConfigRule x -> OrganizationConfigRule
forall x. OrganizationConfigRule -> Rep OrganizationConfigRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OrganizationConfigRule x -> OrganizationConfigRule
$cfrom :: forall x. OrganizationConfigRule -> Rep OrganizationConfigRule x
Prelude.Generic)

-- |
-- Create a value of 'OrganizationConfigRule' 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:
--
-- 'organizationManagedRuleMetadata', 'organizationConfigRule_organizationManagedRuleMetadata' - An @OrganizationManagedRuleMetadata@ object.
--
-- 'excludedAccounts', 'organizationConfigRule_excludedAccounts' - A comma-separated list of accounts excluded from organization config
-- rule.
--
-- 'organizationCustomRuleMetadata', 'organizationConfigRule_organizationCustomRuleMetadata' - An @OrganizationCustomRuleMetadata@ object.
--
-- 'lastUpdateTime', 'organizationConfigRule_lastUpdateTime' - The timestamp of the last update.
--
-- 'organizationConfigRuleName', 'organizationConfigRule_organizationConfigRuleName' - The name that you assign to organization config rule.
--
-- 'organizationConfigRuleArn', 'organizationConfigRule_organizationConfigRuleArn' - Amazon Resource Name (ARN) of organization config rule.
newOrganizationConfigRule ::
  -- | 'organizationConfigRuleName'
  Prelude.Text ->
  -- | 'organizationConfigRuleArn'
  Prelude.Text ->
  OrganizationConfigRule
newOrganizationConfigRule :: Text -> Text -> OrganizationConfigRule
newOrganizationConfigRule
  Text
pOrganizationConfigRuleName_
  Text
pOrganizationConfigRuleArn_ =
    OrganizationConfigRule' :: Maybe OrganizationManagedRuleMetadata
-> Maybe [Text]
-> Maybe OrganizationCustomRuleMetadata
-> Maybe POSIX
-> Text
-> Text
-> OrganizationConfigRule
OrganizationConfigRule'
      { $sel:organizationManagedRuleMetadata:OrganizationConfigRule' :: Maybe OrganizationManagedRuleMetadata
organizationManagedRuleMetadata =
          Maybe OrganizationManagedRuleMetadata
forall a. Maybe a
Prelude.Nothing,
        $sel:excludedAccounts:OrganizationConfigRule' :: Maybe [Text]
excludedAccounts = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:organizationCustomRuleMetadata:OrganizationConfigRule' :: Maybe OrganizationCustomRuleMetadata
organizationCustomRuleMetadata = Maybe OrganizationCustomRuleMetadata
forall a. Maybe a
Prelude.Nothing,
        $sel:lastUpdateTime:OrganizationConfigRule' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
        $sel:organizationConfigRuleName:OrganizationConfigRule' :: Text
organizationConfigRuleName =
          Text
pOrganizationConfigRuleName_,
        $sel:organizationConfigRuleArn:OrganizationConfigRule' :: Text
organizationConfigRuleArn =
          Text
pOrganizationConfigRuleArn_
      }

-- | An @OrganizationManagedRuleMetadata@ object.
organizationConfigRule_organizationManagedRuleMetadata :: Lens.Lens' OrganizationConfigRule (Prelude.Maybe OrganizationManagedRuleMetadata)
organizationConfigRule_organizationManagedRuleMetadata :: (Maybe OrganizationManagedRuleMetadata
 -> f (Maybe OrganizationManagedRuleMetadata))
-> OrganizationConfigRule -> f OrganizationConfigRule
organizationConfigRule_organizationManagedRuleMetadata = (OrganizationConfigRule -> Maybe OrganizationManagedRuleMetadata)
-> (OrganizationConfigRule
    -> Maybe OrganizationManagedRuleMetadata -> OrganizationConfigRule)
-> Lens
     OrganizationConfigRule
     OrganizationConfigRule
     (Maybe OrganizationManagedRuleMetadata)
     (Maybe OrganizationManagedRuleMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OrganizationConfigRule' {Maybe OrganizationManagedRuleMetadata
organizationManagedRuleMetadata :: Maybe OrganizationManagedRuleMetadata
$sel:organizationManagedRuleMetadata:OrganizationConfigRule' :: OrganizationConfigRule -> Maybe OrganizationManagedRuleMetadata
organizationManagedRuleMetadata} -> Maybe OrganizationManagedRuleMetadata
organizationManagedRuleMetadata) (\s :: OrganizationConfigRule
s@OrganizationConfigRule' {} Maybe OrganizationManagedRuleMetadata
a -> OrganizationConfigRule
s {$sel:organizationManagedRuleMetadata:OrganizationConfigRule' :: Maybe OrganizationManagedRuleMetadata
organizationManagedRuleMetadata = Maybe OrganizationManagedRuleMetadata
a} :: OrganizationConfigRule)

-- | A comma-separated list of accounts excluded from organization config
-- rule.
organizationConfigRule_excludedAccounts :: Lens.Lens' OrganizationConfigRule (Prelude.Maybe [Prelude.Text])
organizationConfigRule_excludedAccounts :: (Maybe [Text] -> f (Maybe [Text]))
-> OrganizationConfigRule -> f OrganizationConfigRule
organizationConfigRule_excludedAccounts = (OrganizationConfigRule -> Maybe [Text])
-> (OrganizationConfigRule
    -> Maybe [Text] -> OrganizationConfigRule)
-> Lens
     OrganizationConfigRule
     OrganizationConfigRule
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OrganizationConfigRule' {Maybe [Text]
excludedAccounts :: Maybe [Text]
$sel:excludedAccounts:OrganizationConfigRule' :: OrganizationConfigRule -> Maybe [Text]
excludedAccounts} -> Maybe [Text]
excludedAccounts) (\s :: OrganizationConfigRule
s@OrganizationConfigRule' {} Maybe [Text]
a -> OrganizationConfigRule
s {$sel:excludedAccounts:OrganizationConfigRule' :: Maybe [Text]
excludedAccounts = Maybe [Text]
a} :: OrganizationConfigRule) ((Maybe [Text] -> f (Maybe [Text]))
 -> OrganizationConfigRule -> f OrganizationConfigRule)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> OrganizationConfigRule
-> f OrganizationConfigRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An @OrganizationCustomRuleMetadata@ object.
organizationConfigRule_organizationCustomRuleMetadata :: Lens.Lens' OrganizationConfigRule (Prelude.Maybe OrganizationCustomRuleMetadata)
organizationConfigRule_organizationCustomRuleMetadata :: (Maybe OrganizationCustomRuleMetadata
 -> f (Maybe OrganizationCustomRuleMetadata))
-> OrganizationConfigRule -> f OrganizationConfigRule
organizationConfigRule_organizationCustomRuleMetadata = (OrganizationConfigRule -> Maybe OrganizationCustomRuleMetadata)
-> (OrganizationConfigRule
    -> Maybe OrganizationCustomRuleMetadata -> OrganizationConfigRule)
-> Lens
     OrganizationConfigRule
     OrganizationConfigRule
     (Maybe OrganizationCustomRuleMetadata)
     (Maybe OrganizationCustomRuleMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OrganizationConfigRule' {Maybe OrganizationCustomRuleMetadata
organizationCustomRuleMetadata :: Maybe OrganizationCustomRuleMetadata
$sel:organizationCustomRuleMetadata:OrganizationConfigRule' :: OrganizationConfigRule -> Maybe OrganizationCustomRuleMetadata
organizationCustomRuleMetadata} -> Maybe OrganizationCustomRuleMetadata
organizationCustomRuleMetadata) (\s :: OrganizationConfigRule
s@OrganizationConfigRule' {} Maybe OrganizationCustomRuleMetadata
a -> OrganizationConfigRule
s {$sel:organizationCustomRuleMetadata:OrganizationConfigRule' :: Maybe OrganizationCustomRuleMetadata
organizationCustomRuleMetadata = Maybe OrganizationCustomRuleMetadata
a} :: OrganizationConfigRule)

-- | The timestamp of the last update.
organizationConfigRule_lastUpdateTime :: Lens.Lens' OrganizationConfigRule (Prelude.Maybe Prelude.UTCTime)
organizationConfigRule_lastUpdateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> OrganizationConfigRule -> f OrganizationConfigRule
organizationConfigRule_lastUpdateTime = (OrganizationConfigRule -> Maybe POSIX)
-> (OrganizationConfigRule
    -> Maybe POSIX -> OrganizationConfigRule)
-> Lens
     OrganizationConfigRule
     OrganizationConfigRule
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OrganizationConfigRule' {Maybe POSIX
lastUpdateTime :: Maybe POSIX
$sel:lastUpdateTime:OrganizationConfigRule' :: OrganizationConfigRule -> Maybe POSIX
lastUpdateTime} -> Maybe POSIX
lastUpdateTime) (\s :: OrganizationConfigRule
s@OrganizationConfigRule' {} Maybe POSIX
a -> OrganizationConfigRule
s {$sel:lastUpdateTime:OrganizationConfigRule' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
a} :: OrganizationConfigRule) ((Maybe POSIX -> f (Maybe POSIX))
 -> OrganizationConfigRule -> f OrganizationConfigRule)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> OrganizationConfigRule
-> f OrganizationConfigRule
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 name that you assign to organization config rule.
organizationConfigRule_organizationConfigRuleName :: Lens.Lens' OrganizationConfigRule Prelude.Text
organizationConfigRule_organizationConfigRuleName :: (Text -> f Text)
-> OrganizationConfigRule -> f OrganizationConfigRule
organizationConfigRule_organizationConfigRuleName = (OrganizationConfigRule -> Text)
-> (OrganizationConfigRule -> Text -> OrganizationConfigRule)
-> Lens OrganizationConfigRule OrganizationConfigRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OrganizationConfigRule' {Text
organizationConfigRuleName :: Text
$sel:organizationConfigRuleName:OrganizationConfigRule' :: OrganizationConfigRule -> Text
organizationConfigRuleName} -> Text
organizationConfigRuleName) (\s :: OrganizationConfigRule
s@OrganizationConfigRule' {} Text
a -> OrganizationConfigRule
s {$sel:organizationConfigRuleName:OrganizationConfigRule' :: Text
organizationConfigRuleName = Text
a} :: OrganizationConfigRule)

-- | Amazon Resource Name (ARN) of organization config rule.
organizationConfigRule_organizationConfigRuleArn :: Lens.Lens' OrganizationConfigRule Prelude.Text
organizationConfigRule_organizationConfigRuleArn :: (Text -> f Text)
-> OrganizationConfigRule -> f OrganizationConfigRule
organizationConfigRule_organizationConfigRuleArn = (OrganizationConfigRule -> Text)
-> (OrganizationConfigRule -> Text -> OrganizationConfigRule)
-> Lens OrganizationConfigRule OrganizationConfigRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OrganizationConfigRule' {Text
organizationConfigRuleArn :: Text
$sel:organizationConfigRuleArn:OrganizationConfigRule' :: OrganizationConfigRule -> Text
organizationConfigRuleArn} -> Text
organizationConfigRuleArn) (\s :: OrganizationConfigRule
s@OrganizationConfigRule' {} Text
a -> OrganizationConfigRule
s {$sel:organizationConfigRuleArn:OrganizationConfigRule' :: Text
organizationConfigRuleArn = Text
a} :: OrganizationConfigRule)

instance Core.FromJSON OrganizationConfigRule where
  parseJSON :: Value -> Parser OrganizationConfigRule
parseJSON =
    String
-> (Object -> Parser OrganizationConfigRule)
-> Value
-> Parser OrganizationConfigRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OrganizationConfigRule"
      ( \Object
x ->
          Maybe OrganizationManagedRuleMetadata
-> Maybe [Text]
-> Maybe OrganizationCustomRuleMetadata
-> Maybe POSIX
-> Text
-> Text
-> OrganizationConfigRule
OrganizationConfigRule'
            (Maybe OrganizationManagedRuleMetadata
 -> Maybe [Text]
 -> Maybe OrganizationCustomRuleMetadata
 -> Maybe POSIX
 -> Text
 -> Text
 -> OrganizationConfigRule)
-> Parser (Maybe OrganizationManagedRuleMetadata)
-> Parser
     (Maybe [Text]
      -> Maybe OrganizationCustomRuleMetadata
      -> Maybe POSIX
      -> Text
      -> Text
      -> OrganizationConfigRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe OrganizationManagedRuleMetadata)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OrganizationManagedRuleMetadata")
            Parser
  (Maybe [Text]
   -> Maybe OrganizationCustomRuleMetadata
   -> Maybe POSIX
   -> Text
   -> Text
   -> OrganizationConfigRule)
-> Parser (Maybe [Text])
-> Parser
     (Maybe OrganizationCustomRuleMetadata
      -> Maybe POSIX -> Text -> Text -> OrganizationConfigRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ExcludedAccounts"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe OrganizationCustomRuleMetadata
   -> Maybe POSIX -> Text -> Text -> OrganizationConfigRule)
-> Parser (Maybe OrganizationCustomRuleMetadata)
-> Parser (Maybe POSIX -> Text -> Text -> OrganizationConfigRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe OrganizationCustomRuleMetadata)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OrganizationCustomRuleMetadata")
            Parser (Maybe POSIX -> Text -> Text -> OrganizationConfigRule)
-> Parser (Maybe POSIX)
-> Parser (Text -> Text -> OrganizationConfigRule)
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 -> OrganizationConfigRule)
-> Parser Text -> Parser (Text -> OrganizationConfigRule)
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
"OrganizationConfigRuleName")
            Parser (Text -> OrganizationConfigRule)
-> Parser Text -> Parser OrganizationConfigRule
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
"OrganizationConfigRuleArn")
      )

instance Prelude.Hashable OrganizationConfigRule

instance Prelude.NFData OrganizationConfigRule