{-# 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.ComplianceByResource
-- 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.ComplianceByResource 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 Amazon Web Services resource that is evaluated
-- according to one or more Config rules is compliant. A resource is
-- compliant if it complies with all of the rules that evaluate it. A
-- resource is noncompliant if it does not comply with one or more of these
-- rules.
--
-- /See:/ 'newComplianceByResource' smart constructor.
data ComplianceByResource = ComplianceByResource'
  { -- | The ID of the Amazon Web Services resource that was evaluated.
    ComplianceByResource -> Maybe Text
resourceId :: Prelude.Maybe Prelude.Text,
    -- | The type of the Amazon Web Services resource that was evaluated.
    ComplianceByResource -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether the Amazon Web Services resource complies with all of
    -- the Config rules that evaluated it.
    ComplianceByResource -> Maybe Compliance
compliance :: Prelude.Maybe Compliance
  }
  deriving (ComplianceByResource -> ComplianceByResource -> Bool
(ComplianceByResource -> ComplianceByResource -> Bool)
-> (ComplianceByResource -> ComplianceByResource -> Bool)
-> Eq ComplianceByResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComplianceByResource -> ComplianceByResource -> Bool
$c/= :: ComplianceByResource -> ComplianceByResource -> Bool
== :: ComplianceByResource -> ComplianceByResource -> Bool
$c== :: ComplianceByResource -> ComplianceByResource -> Bool
Prelude.Eq, ReadPrec [ComplianceByResource]
ReadPrec ComplianceByResource
Int -> ReadS ComplianceByResource
ReadS [ComplianceByResource]
(Int -> ReadS ComplianceByResource)
-> ReadS [ComplianceByResource]
-> ReadPrec ComplianceByResource
-> ReadPrec [ComplianceByResource]
-> Read ComplianceByResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComplianceByResource]
$creadListPrec :: ReadPrec [ComplianceByResource]
readPrec :: ReadPrec ComplianceByResource
$creadPrec :: ReadPrec ComplianceByResource
readList :: ReadS [ComplianceByResource]
$creadList :: ReadS [ComplianceByResource]
readsPrec :: Int -> ReadS ComplianceByResource
$creadsPrec :: Int -> ReadS ComplianceByResource
Prelude.Read, Int -> ComplianceByResource -> ShowS
[ComplianceByResource] -> ShowS
ComplianceByResource -> String
(Int -> ComplianceByResource -> ShowS)
-> (ComplianceByResource -> String)
-> ([ComplianceByResource] -> ShowS)
-> Show ComplianceByResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComplianceByResource] -> ShowS
$cshowList :: [ComplianceByResource] -> ShowS
show :: ComplianceByResource -> String
$cshow :: ComplianceByResource -> String
showsPrec :: Int -> ComplianceByResource -> ShowS
$cshowsPrec :: Int -> ComplianceByResource -> ShowS
Prelude.Show, (forall x. ComplianceByResource -> Rep ComplianceByResource x)
-> (forall x. Rep ComplianceByResource x -> ComplianceByResource)
-> Generic ComplianceByResource
forall x. Rep ComplianceByResource x -> ComplianceByResource
forall x. ComplianceByResource -> Rep ComplianceByResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ComplianceByResource x -> ComplianceByResource
$cfrom :: forall x. ComplianceByResource -> Rep ComplianceByResource x
Prelude.Generic)

-- |
-- Create a value of 'ComplianceByResource' 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:
--
-- 'resourceId', 'complianceByResource_resourceId' - The ID of the Amazon Web Services resource that was evaluated.
--
-- 'resourceType', 'complianceByResource_resourceType' - The type of the Amazon Web Services resource that was evaluated.
--
-- 'compliance', 'complianceByResource_compliance' - Indicates whether the Amazon Web Services resource complies with all of
-- the Config rules that evaluated it.
newComplianceByResource ::
  ComplianceByResource
newComplianceByResource :: ComplianceByResource
newComplianceByResource =
  ComplianceByResource' :: Maybe Text
-> Maybe Text -> Maybe Compliance -> ComplianceByResource
ComplianceByResource'
    { $sel:resourceId:ComplianceByResource' :: Maybe Text
resourceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:ComplianceByResource' :: Maybe Text
resourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:compliance:ComplianceByResource' :: Maybe Compliance
compliance = Maybe Compliance
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the Amazon Web Services resource that was evaluated.
complianceByResource_resourceId :: Lens.Lens' ComplianceByResource (Prelude.Maybe Prelude.Text)
complianceByResource_resourceId :: (Maybe Text -> f (Maybe Text))
-> ComplianceByResource -> f ComplianceByResource
complianceByResource_resourceId = (ComplianceByResource -> Maybe Text)
-> (ComplianceByResource -> Maybe Text -> ComplianceByResource)
-> Lens
     ComplianceByResource ComplianceByResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComplianceByResource' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:ComplianceByResource' :: ComplianceByResource -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: ComplianceByResource
s@ComplianceByResource' {} Maybe Text
a -> ComplianceByResource
s {$sel:resourceId:ComplianceByResource' :: Maybe Text
resourceId = Maybe Text
a} :: ComplianceByResource)

-- | The type of the Amazon Web Services resource that was evaluated.
complianceByResource_resourceType :: Lens.Lens' ComplianceByResource (Prelude.Maybe Prelude.Text)
complianceByResource_resourceType :: (Maybe Text -> f (Maybe Text))
-> ComplianceByResource -> f ComplianceByResource
complianceByResource_resourceType = (ComplianceByResource -> Maybe Text)
-> (ComplianceByResource -> Maybe Text -> ComplianceByResource)
-> Lens
     ComplianceByResource ComplianceByResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComplianceByResource' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:ComplianceByResource' :: ComplianceByResource -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: ComplianceByResource
s@ComplianceByResource' {} Maybe Text
a -> ComplianceByResource
s {$sel:resourceType:ComplianceByResource' :: Maybe Text
resourceType = Maybe Text
a} :: ComplianceByResource)

-- | Indicates whether the Amazon Web Services resource complies with all of
-- the Config rules that evaluated it.
complianceByResource_compliance :: Lens.Lens' ComplianceByResource (Prelude.Maybe Compliance)
complianceByResource_compliance :: (Maybe Compliance -> f (Maybe Compliance))
-> ComplianceByResource -> f ComplianceByResource
complianceByResource_compliance = (ComplianceByResource -> Maybe Compliance)
-> (ComplianceByResource
    -> Maybe Compliance -> ComplianceByResource)
-> Lens
     ComplianceByResource
     ComplianceByResource
     (Maybe Compliance)
     (Maybe Compliance)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComplianceByResource' {Maybe Compliance
compliance :: Maybe Compliance
$sel:compliance:ComplianceByResource' :: ComplianceByResource -> Maybe Compliance
compliance} -> Maybe Compliance
compliance) (\s :: ComplianceByResource
s@ComplianceByResource' {} Maybe Compliance
a -> ComplianceByResource
s {$sel:compliance:ComplianceByResource' :: Maybe Compliance
compliance = Maybe Compliance
a} :: ComplianceByResource)

instance Core.FromJSON ComplianceByResource where
  parseJSON :: Value -> Parser ComplianceByResource
parseJSON =
    String
-> (Object -> Parser ComplianceByResource)
-> Value
-> Parser ComplianceByResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ComplianceByResource"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Compliance -> ComplianceByResource
ComplianceByResource'
            (Maybe Text
 -> Maybe Text -> Maybe Compliance -> ComplianceByResource)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Compliance -> ComplianceByResource)
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
"ResourceId")
            Parser (Maybe Text -> Maybe Compliance -> ComplianceByResource)
-> Parser (Maybe Text)
-> Parser (Maybe Compliance -> ComplianceByResource)
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
"ResourceType")
            Parser (Maybe Compliance -> ComplianceByResource)
-> Parser (Maybe Compliance) -> Parser ComplianceByResource
forall (f :: * -> *) a b. Applicative f => 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")
      )

instance Prelude.Hashable ComplianceByResource

instance Prelude.NFData ComplianceByResource