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

import Amazonka.Config.Types.ComplianceContributorCount
import Amazonka.Config.Types.ComplianceType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Indicates whether an Amazon Web Services resource or Config rule is
-- compliant and provides the number of contributors that affect the
-- compliance.
--
-- /See:/ 'newCompliance' smart constructor.
data Compliance = Compliance'
  { -- | The number of Amazon Web Services resources or Config rules that cause a
    -- result of @NON_COMPLIANT@, up to a maximum number.
    Compliance -> Maybe ComplianceContributorCount
complianceContributorCount :: Prelude.Maybe ComplianceContributorCount,
    -- | Indicates whether an Amazon Web Services resource or Config rule is
    -- compliant.
    --
    -- A resource is compliant if it complies with all of the Config rules that
    -- evaluate it. A resource is noncompliant if it does not comply with one
    -- or more of these rules.
    --
    -- A rule is compliant if all of the resources that the rule evaluates
    -- comply with it. A rule is noncompliant if any of these resources do not
    -- comply.
    --
    -- Config returns the @INSUFFICIENT_DATA@ value when no evaluation results
    -- are available for the Amazon Web Services resource or Config rule.
    --
    -- For the @Compliance@ data type, Config supports only @COMPLIANT@,
    -- @NON_COMPLIANT@, and @INSUFFICIENT_DATA@ values. Config does not support
    -- the @NOT_APPLICABLE@ value for the @Compliance@ data type.
    Compliance -> Maybe ComplianceType
complianceType :: Prelude.Maybe ComplianceType
  }
  deriving (Compliance -> Compliance -> Bool
(Compliance -> Compliance -> Bool)
-> (Compliance -> Compliance -> Bool) -> Eq Compliance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Compliance -> Compliance -> Bool
$c/= :: Compliance -> Compliance -> Bool
== :: Compliance -> Compliance -> Bool
$c== :: Compliance -> Compliance -> Bool
Prelude.Eq, ReadPrec [Compliance]
ReadPrec Compliance
Int -> ReadS Compliance
ReadS [Compliance]
(Int -> ReadS Compliance)
-> ReadS [Compliance]
-> ReadPrec Compliance
-> ReadPrec [Compliance]
-> Read Compliance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Compliance]
$creadListPrec :: ReadPrec [Compliance]
readPrec :: ReadPrec Compliance
$creadPrec :: ReadPrec Compliance
readList :: ReadS [Compliance]
$creadList :: ReadS [Compliance]
readsPrec :: Int -> ReadS Compliance
$creadsPrec :: Int -> ReadS Compliance
Prelude.Read, Int -> Compliance -> ShowS
[Compliance] -> ShowS
Compliance -> String
(Int -> Compliance -> ShowS)
-> (Compliance -> String)
-> ([Compliance] -> ShowS)
-> Show Compliance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Compliance] -> ShowS
$cshowList :: [Compliance] -> ShowS
show :: Compliance -> String
$cshow :: Compliance -> String
showsPrec :: Int -> Compliance -> ShowS
$cshowsPrec :: Int -> Compliance -> ShowS
Prelude.Show, (forall x. Compliance -> Rep Compliance x)
-> (forall x. Rep Compliance x -> Compliance) -> Generic Compliance
forall x. Rep Compliance x -> Compliance
forall x. Compliance -> Rep Compliance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Compliance x -> Compliance
$cfrom :: forall x. Compliance -> Rep Compliance x
Prelude.Generic)

-- |
-- Create a value of 'Compliance' 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:
--
-- 'complianceContributorCount', 'compliance_complianceContributorCount' - The number of Amazon Web Services resources or Config rules that cause a
-- result of @NON_COMPLIANT@, up to a maximum number.
--
-- 'complianceType', 'compliance_complianceType' - Indicates whether an Amazon Web Services resource or Config rule is
-- compliant.
--
-- A resource is compliant if it complies with all of the Config rules that
-- evaluate it. A resource is noncompliant if it does not comply with one
-- or more of these rules.
--
-- A rule is compliant if all of the resources that the rule evaluates
-- comply with it. A rule is noncompliant if any of these resources do not
-- comply.
--
-- Config returns the @INSUFFICIENT_DATA@ value when no evaluation results
-- are available for the Amazon Web Services resource or Config rule.
--
-- For the @Compliance@ data type, Config supports only @COMPLIANT@,
-- @NON_COMPLIANT@, and @INSUFFICIENT_DATA@ values. Config does not support
-- the @NOT_APPLICABLE@ value for the @Compliance@ data type.
newCompliance ::
  Compliance
newCompliance :: Compliance
newCompliance =
  Compliance' :: Maybe ComplianceContributorCount
-> Maybe ComplianceType -> Compliance
Compliance'
    { $sel:complianceContributorCount:Compliance' :: Maybe ComplianceContributorCount
complianceContributorCount =
        Maybe ComplianceContributorCount
forall a. Maybe a
Prelude.Nothing,
      $sel:complianceType:Compliance' :: Maybe ComplianceType
complianceType = Maybe ComplianceType
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of Amazon Web Services resources or Config rules that cause a
-- result of @NON_COMPLIANT@, up to a maximum number.
compliance_complianceContributorCount :: Lens.Lens' Compliance (Prelude.Maybe ComplianceContributorCount)
compliance_complianceContributorCount :: (Maybe ComplianceContributorCount
 -> f (Maybe ComplianceContributorCount))
-> Compliance -> f Compliance
compliance_complianceContributorCount = (Compliance -> Maybe ComplianceContributorCount)
-> (Compliance -> Maybe ComplianceContributorCount -> Compliance)
-> Lens
     Compliance
     Compliance
     (Maybe ComplianceContributorCount)
     (Maybe ComplianceContributorCount)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Compliance' {Maybe ComplianceContributorCount
complianceContributorCount :: Maybe ComplianceContributorCount
$sel:complianceContributorCount:Compliance' :: Compliance -> Maybe ComplianceContributorCount
complianceContributorCount} -> Maybe ComplianceContributorCount
complianceContributorCount) (\s :: Compliance
s@Compliance' {} Maybe ComplianceContributorCount
a -> Compliance
s {$sel:complianceContributorCount:Compliance' :: Maybe ComplianceContributorCount
complianceContributorCount = Maybe ComplianceContributorCount
a} :: Compliance)

-- | Indicates whether an Amazon Web Services resource or Config rule is
-- compliant.
--
-- A resource is compliant if it complies with all of the Config rules that
-- evaluate it. A resource is noncompliant if it does not comply with one
-- or more of these rules.
--
-- A rule is compliant if all of the resources that the rule evaluates
-- comply with it. A rule is noncompliant if any of these resources do not
-- comply.
--
-- Config returns the @INSUFFICIENT_DATA@ value when no evaluation results
-- are available for the Amazon Web Services resource or Config rule.
--
-- For the @Compliance@ data type, Config supports only @COMPLIANT@,
-- @NON_COMPLIANT@, and @INSUFFICIENT_DATA@ values. Config does not support
-- the @NOT_APPLICABLE@ value for the @Compliance@ data type.
compliance_complianceType :: Lens.Lens' Compliance (Prelude.Maybe ComplianceType)
compliance_complianceType :: (Maybe ComplianceType -> f (Maybe ComplianceType))
-> Compliance -> f Compliance
compliance_complianceType = (Compliance -> Maybe ComplianceType)
-> (Compliance -> Maybe ComplianceType -> Compliance)
-> Lens
     Compliance Compliance (Maybe ComplianceType) (Maybe ComplianceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Compliance' {Maybe ComplianceType
complianceType :: Maybe ComplianceType
$sel:complianceType:Compliance' :: Compliance -> Maybe ComplianceType
complianceType} -> Maybe ComplianceType
complianceType) (\s :: Compliance
s@Compliance' {} Maybe ComplianceType
a -> Compliance
s {$sel:complianceType:Compliance' :: Maybe ComplianceType
complianceType = Maybe ComplianceType
a} :: Compliance)

instance Core.FromJSON Compliance where
  parseJSON :: Value -> Parser Compliance
parseJSON =
    String
-> (Object -> Parser Compliance) -> Value -> Parser Compliance
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Compliance"
      ( \Object
x ->
          Maybe ComplianceContributorCount
-> Maybe ComplianceType -> Compliance
Compliance'
            (Maybe ComplianceContributorCount
 -> Maybe ComplianceType -> Compliance)
-> Parser (Maybe ComplianceContributorCount)
-> Parser (Maybe ComplianceType -> Compliance)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ComplianceContributorCount)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ComplianceContributorCount")
            Parser (Maybe ComplianceType -> Compliance)
-> Parser (Maybe ComplianceType) -> Parser Compliance
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ComplianceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ComplianceType")
      )

instance Prelude.Hashable Compliance

instance Prelude.NFData Compliance