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

import Amazonka.Config.Types.Compliance
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Indicates whether an Config rule is compliant based on account ID,
-- region, compliance, and rule name.
--
-- A rule is compliant if all of the resources that the rule evaluated
-- comply with it. It is noncompliant if any of these resources do not
-- comply.
--
-- /See:/ 'newAggregateComplianceByConfigRule' smart constructor.
data AggregateComplianceByConfigRule = AggregateComplianceByConfigRule'
  { -- | Indicates whether an Amazon Web Services resource or Config rule is
    -- compliant and provides the number of contributors that affect the
    -- compliance.
    AggregateComplianceByConfigRule -> Maybe Compliance
compliance :: Prelude.Maybe Compliance,
    -- | The name of the Config rule.
    AggregateComplianceByConfigRule -> Maybe Text
configRuleName :: Prelude.Maybe Prelude.Text,
    -- | The 12-digit account ID of the source account.
    AggregateComplianceByConfigRule -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The source region from where the data is aggregated.
    AggregateComplianceByConfigRule -> Maybe Text
awsRegion :: Prelude.Maybe Prelude.Text
  }
  deriving (AggregateComplianceByConfigRule
-> AggregateComplianceByConfigRule -> Bool
(AggregateComplianceByConfigRule
 -> AggregateComplianceByConfigRule -> Bool)
-> (AggregateComplianceByConfigRule
    -> AggregateComplianceByConfigRule -> Bool)
-> Eq AggregateComplianceByConfigRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AggregateComplianceByConfigRule
-> AggregateComplianceByConfigRule -> Bool
$c/= :: AggregateComplianceByConfigRule
-> AggregateComplianceByConfigRule -> Bool
== :: AggregateComplianceByConfigRule
-> AggregateComplianceByConfigRule -> Bool
$c== :: AggregateComplianceByConfigRule
-> AggregateComplianceByConfigRule -> Bool
Prelude.Eq, ReadPrec [AggregateComplianceByConfigRule]
ReadPrec AggregateComplianceByConfigRule
Int -> ReadS AggregateComplianceByConfigRule
ReadS [AggregateComplianceByConfigRule]
(Int -> ReadS AggregateComplianceByConfigRule)
-> ReadS [AggregateComplianceByConfigRule]
-> ReadPrec AggregateComplianceByConfigRule
-> ReadPrec [AggregateComplianceByConfigRule]
-> Read AggregateComplianceByConfigRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AggregateComplianceByConfigRule]
$creadListPrec :: ReadPrec [AggregateComplianceByConfigRule]
readPrec :: ReadPrec AggregateComplianceByConfigRule
$creadPrec :: ReadPrec AggregateComplianceByConfigRule
readList :: ReadS [AggregateComplianceByConfigRule]
$creadList :: ReadS [AggregateComplianceByConfigRule]
readsPrec :: Int -> ReadS AggregateComplianceByConfigRule
$creadsPrec :: Int -> ReadS AggregateComplianceByConfigRule
Prelude.Read, Int -> AggregateComplianceByConfigRule -> ShowS
[AggregateComplianceByConfigRule] -> ShowS
AggregateComplianceByConfigRule -> String
(Int -> AggregateComplianceByConfigRule -> ShowS)
-> (AggregateComplianceByConfigRule -> String)
-> ([AggregateComplianceByConfigRule] -> ShowS)
-> Show AggregateComplianceByConfigRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AggregateComplianceByConfigRule] -> ShowS
$cshowList :: [AggregateComplianceByConfigRule] -> ShowS
show :: AggregateComplianceByConfigRule -> String
$cshow :: AggregateComplianceByConfigRule -> String
showsPrec :: Int -> AggregateComplianceByConfigRule -> ShowS
$cshowsPrec :: Int -> AggregateComplianceByConfigRule -> ShowS
Prelude.Show, (forall x.
 AggregateComplianceByConfigRule
 -> Rep AggregateComplianceByConfigRule x)
-> (forall x.
    Rep AggregateComplianceByConfigRule x
    -> AggregateComplianceByConfigRule)
-> Generic AggregateComplianceByConfigRule
forall x.
Rep AggregateComplianceByConfigRule x
-> AggregateComplianceByConfigRule
forall x.
AggregateComplianceByConfigRule
-> Rep AggregateComplianceByConfigRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AggregateComplianceByConfigRule x
-> AggregateComplianceByConfigRule
$cfrom :: forall x.
AggregateComplianceByConfigRule
-> Rep AggregateComplianceByConfigRule x
Prelude.Generic)

-- |
-- Create a value of 'AggregateComplianceByConfigRule' 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:
--
-- 'compliance', 'aggregateComplianceByConfigRule_compliance' - Indicates whether an Amazon Web Services resource or Config rule is
-- compliant and provides the number of contributors that affect the
-- compliance.
--
-- 'configRuleName', 'aggregateComplianceByConfigRule_configRuleName' - The name of the Config rule.
--
-- 'accountId', 'aggregateComplianceByConfigRule_accountId' - The 12-digit account ID of the source account.
--
-- 'awsRegion', 'aggregateComplianceByConfigRule_awsRegion' - The source region from where the data is aggregated.
newAggregateComplianceByConfigRule ::
  AggregateComplianceByConfigRule
newAggregateComplianceByConfigRule :: AggregateComplianceByConfigRule
newAggregateComplianceByConfigRule =
  AggregateComplianceByConfigRule' :: Maybe Compliance
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AggregateComplianceByConfigRule
AggregateComplianceByConfigRule'
    { $sel:compliance:AggregateComplianceByConfigRule' :: Maybe Compliance
compliance =
        Maybe Compliance
forall a. Maybe a
Prelude.Nothing,
      $sel:configRuleName:AggregateComplianceByConfigRule' :: Maybe Text
configRuleName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:AggregateComplianceByConfigRule' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:awsRegion:AggregateComplianceByConfigRule' :: Maybe Text
awsRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether an Amazon Web Services resource or Config rule is
-- compliant and provides the number of contributors that affect the
-- compliance.
aggregateComplianceByConfigRule_compliance :: Lens.Lens' AggregateComplianceByConfigRule (Prelude.Maybe Compliance)
aggregateComplianceByConfigRule_compliance :: (Maybe Compliance -> f (Maybe Compliance))
-> AggregateComplianceByConfigRule
-> f AggregateComplianceByConfigRule
aggregateComplianceByConfigRule_compliance = (AggregateComplianceByConfigRule -> Maybe Compliance)
-> (AggregateComplianceByConfigRule
    -> Maybe Compliance -> AggregateComplianceByConfigRule)
-> Lens
     AggregateComplianceByConfigRule
     AggregateComplianceByConfigRule
     (Maybe Compliance)
     (Maybe Compliance)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregateComplianceByConfigRule' {Maybe Compliance
compliance :: Maybe Compliance
$sel:compliance:AggregateComplianceByConfigRule' :: AggregateComplianceByConfigRule -> Maybe Compliance
compliance} -> Maybe Compliance
compliance) (\s :: AggregateComplianceByConfigRule
s@AggregateComplianceByConfigRule' {} Maybe Compliance
a -> AggregateComplianceByConfigRule
s {$sel:compliance:AggregateComplianceByConfigRule' :: Maybe Compliance
compliance = Maybe Compliance
a} :: AggregateComplianceByConfigRule)

-- | The name of the Config rule.
aggregateComplianceByConfigRule_configRuleName :: Lens.Lens' AggregateComplianceByConfigRule (Prelude.Maybe Prelude.Text)
aggregateComplianceByConfigRule_configRuleName :: (Maybe Text -> f (Maybe Text))
-> AggregateComplianceByConfigRule
-> f AggregateComplianceByConfigRule
aggregateComplianceByConfigRule_configRuleName = (AggregateComplianceByConfigRule -> Maybe Text)
-> (AggregateComplianceByConfigRule
    -> Maybe Text -> AggregateComplianceByConfigRule)
-> Lens
     AggregateComplianceByConfigRule
     AggregateComplianceByConfigRule
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregateComplianceByConfigRule' {Maybe Text
configRuleName :: Maybe Text
$sel:configRuleName:AggregateComplianceByConfigRule' :: AggregateComplianceByConfigRule -> Maybe Text
configRuleName} -> Maybe Text
configRuleName) (\s :: AggregateComplianceByConfigRule
s@AggregateComplianceByConfigRule' {} Maybe Text
a -> AggregateComplianceByConfigRule
s {$sel:configRuleName:AggregateComplianceByConfigRule' :: Maybe Text
configRuleName = Maybe Text
a} :: AggregateComplianceByConfigRule)

-- | The 12-digit account ID of the source account.
aggregateComplianceByConfigRule_accountId :: Lens.Lens' AggregateComplianceByConfigRule (Prelude.Maybe Prelude.Text)
aggregateComplianceByConfigRule_accountId :: (Maybe Text -> f (Maybe Text))
-> AggregateComplianceByConfigRule
-> f AggregateComplianceByConfigRule
aggregateComplianceByConfigRule_accountId = (AggregateComplianceByConfigRule -> Maybe Text)
-> (AggregateComplianceByConfigRule
    -> Maybe Text -> AggregateComplianceByConfigRule)
-> Lens
     AggregateComplianceByConfigRule
     AggregateComplianceByConfigRule
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregateComplianceByConfigRule' {Maybe Text
accountId :: Maybe Text
$sel:accountId:AggregateComplianceByConfigRule' :: AggregateComplianceByConfigRule -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: AggregateComplianceByConfigRule
s@AggregateComplianceByConfigRule' {} Maybe Text
a -> AggregateComplianceByConfigRule
s {$sel:accountId:AggregateComplianceByConfigRule' :: Maybe Text
accountId = Maybe Text
a} :: AggregateComplianceByConfigRule)

-- | The source region from where the data is aggregated.
aggregateComplianceByConfigRule_awsRegion :: Lens.Lens' AggregateComplianceByConfigRule (Prelude.Maybe Prelude.Text)
aggregateComplianceByConfigRule_awsRegion :: (Maybe Text -> f (Maybe Text))
-> AggregateComplianceByConfigRule
-> f AggregateComplianceByConfigRule
aggregateComplianceByConfigRule_awsRegion = (AggregateComplianceByConfigRule -> Maybe Text)
-> (AggregateComplianceByConfigRule
    -> Maybe Text -> AggregateComplianceByConfigRule)
-> Lens
     AggregateComplianceByConfigRule
     AggregateComplianceByConfigRule
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregateComplianceByConfigRule' {Maybe Text
awsRegion :: Maybe Text
$sel:awsRegion:AggregateComplianceByConfigRule' :: AggregateComplianceByConfigRule -> Maybe Text
awsRegion} -> Maybe Text
awsRegion) (\s :: AggregateComplianceByConfigRule
s@AggregateComplianceByConfigRule' {} Maybe Text
a -> AggregateComplianceByConfigRule
s {$sel:awsRegion:AggregateComplianceByConfigRule' :: Maybe Text
awsRegion = Maybe Text
a} :: AggregateComplianceByConfigRule)

instance
  Core.FromJSON
    AggregateComplianceByConfigRule
  where
  parseJSON :: Value -> Parser AggregateComplianceByConfigRule
parseJSON =
    String
-> (Object -> Parser AggregateComplianceByConfigRule)
-> Value
-> Parser AggregateComplianceByConfigRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AggregateComplianceByConfigRule"
      ( \Object
x ->
          Maybe Compliance
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AggregateComplianceByConfigRule
AggregateComplianceByConfigRule'
            (Maybe Compliance
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> AggregateComplianceByConfigRule)
-> Parser (Maybe Compliance)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> AggregateComplianceByConfigRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Compliance)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Compliance")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> AggregateComplianceByConfigRule)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> AggregateComplianceByConfigRule)
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
"ConfigRuleName")
            Parser
  (Maybe Text -> Maybe Text -> AggregateComplianceByConfigRule)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AggregateComplianceByConfigRule)
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
"AccountId")
            Parser (Maybe Text -> AggregateComplianceByConfigRule)
-> Parser (Maybe Text) -> Parser AggregateComplianceByConfigRule
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
"AwsRegion")
      )

instance
  Prelude.Hashable
    AggregateComplianceByConfigRule

instance
  Prelude.NFData
    AggregateComplianceByConfigRule