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

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

-- | 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'
  { -- | 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,
    -- | 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
  }
  deriving (AggregateComplianceByConfigRule
-> AggregateComplianceByConfigRule -> Bool
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]
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
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.
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:
--
-- 'accountId', 'aggregateComplianceByConfigRule_accountId' - The 12-digit account ID of the source account.
--
-- 'awsRegion', 'aggregateComplianceByConfigRule_awsRegion' - The source region from where the data is aggregated.
--
-- '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.
newAggregateComplianceByConfigRule ::
  AggregateComplianceByConfigRule
newAggregateComplianceByConfigRule :: AggregateComplianceByConfigRule
newAggregateComplianceByConfigRule =
  AggregateComplianceByConfigRule'
    { $sel:accountId:AggregateComplianceByConfigRule' :: Maybe Text
accountId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:awsRegion:AggregateComplianceByConfigRule' :: Maybe Text
awsRegion = forall a. Maybe a
Prelude.Nothing,
      $sel:compliance:AggregateComplianceByConfigRule' :: Maybe Compliance
compliance = forall a. Maybe a
Prelude.Nothing,
      $sel:configRuleName:AggregateComplianceByConfigRule' :: Maybe Text
configRuleName = forall a. Maybe a
Prelude.Nothing
    }

-- | The 12-digit account ID of the source account.
aggregateComplianceByConfigRule_accountId :: Lens.Lens' AggregateComplianceByConfigRule (Prelude.Maybe Prelude.Text)
aggregateComplianceByConfigRule_accountId :: Lens' AggregateComplianceByConfigRule (Maybe Text)
aggregateComplianceByConfigRule_accountId = 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 :: Lens' AggregateComplianceByConfigRule (Maybe Text)
aggregateComplianceByConfigRule_awsRegion = 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)

-- | 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 :: Lens' AggregateComplianceByConfigRule (Maybe Compliance)
aggregateComplianceByConfigRule_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 :: Lens' AggregateComplianceByConfigRule (Maybe Text)
aggregateComplianceByConfigRule_configRuleName = 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)

instance
  Data.FromJSON
    AggregateComplianceByConfigRule
  where
  parseJSON :: Value -> Parser AggregateComplianceByConfigRule
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AggregateComplianceByConfigRule"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Compliance
-> Maybe Text
-> AggregateComplianceByConfigRule
AggregateComplianceByConfigRule'
            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
"AccountId")
            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
"AwsRegion")
            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
"Compliance")
            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
"ConfigRuleName")
      )

instance
  Prelude.Hashable
    AggregateComplianceByConfigRule
  where
  hashWithSalt :: Int -> AggregateComplianceByConfigRule -> Int
hashWithSalt
    Int
_salt
    AggregateComplianceByConfigRule' {Maybe Text
Maybe Compliance
configRuleName :: Maybe Text
compliance :: Maybe Compliance
awsRegion :: Maybe Text
accountId :: Maybe Text
$sel:configRuleName:AggregateComplianceByConfigRule' :: AggregateComplianceByConfigRule -> Maybe Text
$sel:compliance:AggregateComplianceByConfigRule' :: AggregateComplianceByConfigRule -> Maybe Compliance
$sel:awsRegion:AggregateComplianceByConfigRule' :: AggregateComplianceByConfigRule -> Maybe Text
$sel:accountId:AggregateComplianceByConfigRule' :: AggregateComplianceByConfigRule -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
awsRegion
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Compliance
compliance
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
configRuleName

instance
  Prelude.NFData
    AggregateComplianceByConfigRule
  where
  rnf :: AggregateComplianceByConfigRule -> ()
rnf AggregateComplianceByConfigRule' {Maybe Text
Maybe Compliance
configRuleName :: Maybe Text
compliance :: Maybe Compliance
awsRegion :: Maybe Text
accountId :: Maybe Text
$sel:configRuleName:AggregateComplianceByConfigRule' :: AggregateComplianceByConfigRule -> Maybe Text
$sel:compliance:AggregateComplianceByConfigRule' :: AggregateComplianceByConfigRule -> Maybe Compliance
$sel:awsRegion:AggregateComplianceByConfigRule' :: AggregateComplianceByConfigRule -> Maybe Text
$sel:accountId:AggregateComplianceByConfigRule' :: AggregateComplianceByConfigRule -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
awsRegion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Compliance
compliance
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
configRuleName