{-# 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-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.ComplianceByResource 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 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'
  { -- | Indicates whether the Amazon Web Services resource complies with all of
    -- the Config rules that evaluated it.
    ComplianceByResource -> Maybe Compliance
compliance :: Prelude.Maybe Compliance,
    -- | 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
  }
  deriving (ComplianceByResource -> ComplianceByResource -> Bool
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]
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
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. 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:
--
-- 'compliance', 'complianceByResource_compliance' - Indicates whether the Amazon Web Services resource complies with all of
-- the Config rules that evaluated it.
--
-- '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.
newComplianceByResource ::
  ComplianceByResource
newComplianceByResource :: ComplianceByResource
newComplianceByResource =
  ComplianceByResource'
    { $sel:compliance:ComplianceByResource' :: Maybe Compliance
compliance = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceId:ComplianceByResource' :: Maybe Text
resourceId = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:ComplianceByResource' :: Maybe Text
resourceType = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' ComplianceByResource (Maybe Compliance)
complianceByResource_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)

-- | The ID of the Amazon Web Services resource that was evaluated.
complianceByResource_resourceId :: Lens.Lens' ComplianceByResource (Prelude.Maybe Prelude.Text)
complianceByResource_resourceId :: Lens' ComplianceByResource (Maybe Text)
complianceByResource_resourceId = 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 :: Lens' ComplianceByResource (Maybe Text)
complianceByResource_resourceType = 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)

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

instance Prelude.Hashable ComplianceByResource where
  hashWithSalt :: Int -> ComplianceByResource -> Int
hashWithSalt Int
_salt ComplianceByResource' {Maybe Text
Maybe Compliance
resourceType :: Maybe Text
resourceId :: Maybe Text
compliance :: Maybe Compliance
$sel:resourceType:ComplianceByResource' :: ComplianceByResource -> Maybe Text
$sel:resourceId:ComplianceByResource' :: ComplianceByResource -> Maybe Text
$sel:compliance:ComplianceByResource' :: ComplianceByResource -> Maybe Compliance
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Compliance
compliance
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceType

instance Prelude.NFData ComplianceByResource where
  rnf :: ComplianceByResource -> ()
rnf ComplianceByResource' {Maybe Text
Maybe Compliance
resourceType :: Maybe Text
resourceId :: Maybe Text
compliance :: Maybe Compliance
$sel:resourceType:ComplianceByResource' :: ComplianceByResource -> Maybe Text
$sel:resourceId:ComplianceByResource' :: ComplianceByResource -> Maybe Text
$sel:compliance:ComplianceByResource' :: ComplianceByResource -> Maybe Compliance
..} =
    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
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceType