{-# 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.CloudWatch.Types.ManagedRuleDescription
-- 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.CloudWatch.Types.ManagedRuleDescription where

import Amazonka.CloudWatch.Types.ManagedRuleState
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

-- | Contains information about managed Contributor Insights rules, as
-- returned by @ListManagedInsightRules@.
--
-- /See:/ 'newManagedRuleDescription' smart constructor.
data ManagedRuleDescription = ManagedRuleDescription'
  { -- | If a managed rule is enabled, this is the ARN for the related Amazon Web
    -- Services resource.
    ManagedRuleDescription -> Maybe Text
resourceARN :: Prelude.Maybe Prelude.Text,
    -- | Describes the state of a managed rule. If present, it contains
    -- information about the Contributor Insights rule that contains
    -- information about the related Amazon Web Services resource.
    ManagedRuleDescription -> Maybe ManagedRuleState
ruleState :: Prelude.Maybe ManagedRuleState,
    -- | The template name for the managed rule. Used to enable managed rules
    -- using @PutManagedInsightRules@.
    ManagedRuleDescription -> Maybe Text
templateName :: Prelude.Maybe Prelude.Text
  }
  deriving (ManagedRuleDescription -> ManagedRuleDescription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ManagedRuleDescription -> ManagedRuleDescription -> Bool
$c/= :: ManagedRuleDescription -> ManagedRuleDescription -> Bool
== :: ManagedRuleDescription -> ManagedRuleDescription -> Bool
$c== :: ManagedRuleDescription -> ManagedRuleDescription -> Bool
Prelude.Eq, ReadPrec [ManagedRuleDescription]
ReadPrec ManagedRuleDescription
Int -> ReadS ManagedRuleDescription
ReadS [ManagedRuleDescription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ManagedRuleDescription]
$creadListPrec :: ReadPrec [ManagedRuleDescription]
readPrec :: ReadPrec ManagedRuleDescription
$creadPrec :: ReadPrec ManagedRuleDescription
readList :: ReadS [ManagedRuleDescription]
$creadList :: ReadS [ManagedRuleDescription]
readsPrec :: Int -> ReadS ManagedRuleDescription
$creadsPrec :: Int -> ReadS ManagedRuleDescription
Prelude.Read, Int -> ManagedRuleDescription -> ShowS
[ManagedRuleDescription] -> ShowS
ManagedRuleDescription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ManagedRuleDescription] -> ShowS
$cshowList :: [ManagedRuleDescription] -> ShowS
show :: ManagedRuleDescription -> String
$cshow :: ManagedRuleDescription -> String
showsPrec :: Int -> ManagedRuleDescription -> ShowS
$cshowsPrec :: Int -> ManagedRuleDescription -> ShowS
Prelude.Show, forall x. Rep ManagedRuleDescription x -> ManagedRuleDescription
forall x. ManagedRuleDescription -> Rep ManagedRuleDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ManagedRuleDescription x -> ManagedRuleDescription
$cfrom :: forall x. ManagedRuleDescription -> Rep ManagedRuleDescription x
Prelude.Generic)

-- |
-- Create a value of 'ManagedRuleDescription' 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:
--
-- 'resourceARN', 'managedRuleDescription_resourceARN' - If a managed rule is enabled, this is the ARN for the related Amazon Web
-- Services resource.
--
-- 'ruleState', 'managedRuleDescription_ruleState' - Describes the state of a managed rule. If present, it contains
-- information about the Contributor Insights rule that contains
-- information about the related Amazon Web Services resource.
--
-- 'templateName', 'managedRuleDescription_templateName' - The template name for the managed rule. Used to enable managed rules
-- using @PutManagedInsightRules@.
newManagedRuleDescription ::
  ManagedRuleDescription
newManagedRuleDescription :: ManagedRuleDescription
newManagedRuleDescription =
  ManagedRuleDescription'
    { $sel:resourceARN:ManagedRuleDescription' :: Maybe Text
resourceARN =
        forall a. Maybe a
Prelude.Nothing,
      $sel:ruleState:ManagedRuleDescription' :: Maybe ManagedRuleState
ruleState = forall a. Maybe a
Prelude.Nothing,
      $sel:templateName:ManagedRuleDescription' :: Maybe Text
templateName = forall a. Maybe a
Prelude.Nothing
    }

-- | If a managed rule is enabled, this is the ARN for the related Amazon Web
-- Services resource.
managedRuleDescription_resourceARN :: Lens.Lens' ManagedRuleDescription (Prelude.Maybe Prelude.Text)
managedRuleDescription_resourceARN :: Lens' ManagedRuleDescription (Maybe Text)
managedRuleDescription_resourceARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleDescription' {Maybe Text
resourceARN :: Maybe Text
$sel:resourceARN:ManagedRuleDescription' :: ManagedRuleDescription -> Maybe Text
resourceARN} -> Maybe Text
resourceARN) (\s :: ManagedRuleDescription
s@ManagedRuleDescription' {} Maybe Text
a -> ManagedRuleDescription
s {$sel:resourceARN:ManagedRuleDescription' :: Maybe Text
resourceARN = Maybe Text
a} :: ManagedRuleDescription)

-- | Describes the state of a managed rule. If present, it contains
-- information about the Contributor Insights rule that contains
-- information about the related Amazon Web Services resource.
managedRuleDescription_ruleState :: Lens.Lens' ManagedRuleDescription (Prelude.Maybe ManagedRuleState)
managedRuleDescription_ruleState :: Lens' ManagedRuleDescription (Maybe ManagedRuleState)
managedRuleDescription_ruleState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleDescription' {Maybe ManagedRuleState
ruleState :: Maybe ManagedRuleState
$sel:ruleState:ManagedRuleDescription' :: ManagedRuleDescription -> Maybe ManagedRuleState
ruleState} -> Maybe ManagedRuleState
ruleState) (\s :: ManagedRuleDescription
s@ManagedRuleDescription' {} Maybe ManagedRuleState
a -> ManagedRuleDescription
s {$sel:ruleState:ManagedRuleDescription' :: Maybe ManagedRuleState
ruleState = Maybe ManagedRuleState
a} :: ManagedRuleDescription)

-- | The template name for the managed rule. Used to enable managed rules
-- using @PutManagedInsightRules@.
managedRuleDescription_templateName :: Lens.Lens' ManagedRuleDescription (Prelude.Maybe Prelude.Text)
managedRuleDescription_templateName :: Lens' ManagedRuleDescription (Maybe Text)
managedRuleDescription_templateName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleDescription' {Maybe Text
templateName :: Maybe Text
$sel:templateName:ManagedRuleDescription' :: ManagedRuleDescription -> Maybe Text
templateName} -> Maybe Text
templateName) (\s :: ManagedRuleDescription
s@ManagedRuleDescription' {} Maybe Text
a -> ManagedRuleDescription
s {$sel:templateName:ManagedRuleDescription' :: Maybe Text
templateName = Maybe Text
a} :: ManagedRuleDescription)

instance Data.FromXML ManagedRuleDescription where
  parseXML :: [Node] -> Either String ManagedRuleDescription
parseXML [Node]
x =
    Maybe Text
-> Maybe ManagedRuleState -> Maybe Text -> ManagedRuleDescription
ManagedRuleDescription'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ResourceARN")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"RuleState")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"TemplateName")

instance Prelude.Hashable ManagedRuleDescription where
  hashWithSalt :: Int -> ManagedRuleDescription -> Int
hashWithSalt Int
_salt ManagedRuleDescription' {Maybe Text
Maybe ManagedRuleState
templateName :: Maybe Text
ruleState :: Maybe ManagedRuleState
resourceARN :: Maybe Text
$sel:templateName:ManagedRuleDescription' :: ManagedRuleDescription -> Maybe Text
$sel:ruleState:ManagedRuleDescription' :: ManagedRuleDescription -> Maybe ManagedRuleState
$sel:resourceARN:ManagedRuleDescription' :: ManagedRuleDescription -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ManagedRuleState
ruleState
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
templateName

instance Prelude.NFData ManagedRuleDescription where
  rnf :: ManagedRuleDescription -> ()
rnf ManagedRuleDescription' {Maybe Text
Maybe ManagedRuleState
templateName :: Maybe Text
ruleState :: Maybe ManagedRuleState
resourceARN :: Maybe Text
$sel:templateName:ManagedRuleDescription' :: ManagedRuleDescription -> Maybe Text
$sel:ruleState:ManagedRuleDescription' :: ManagedRuleDescription -> Maybe ManagedRuleState
$sel:resourceARN:ManagedRuleDescription' :: ManagedRuleDescription -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ManagedRuleState
ruleState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
templateName