{-# 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.CodeGuruReviewer.Types.RuleMetadata
-- 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.CodeGuruReviewer.Types.RuleMetadata where

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

-- | Metadata about a rule. Rule metadata includes an ID, a name, a list of
-- tags, and a short and long description. CodeGuru Reviewer uses rules to
-- analyze code. A rule\'s recommendation is included in analysis results
-- if code is detected that violates the rule.
--
-- /See:/ 'newRuleMetadata' smart constructor.
data RuleMetadata = RuleMetadata'
  { -- | A long description of the rule.
    RuleMetadata -> Maybe Text
longDescription :: Prelude.Maybe Prelude.Text,
    -- | The ID of the rule.
    RuleMetadata -> Maybe Text
ruleId :: Prelude.Maybe Prelude.Text,
    -- | The name of the rule.
    RuleMetadata -> Maybe Text
ruleName :: Prelude.Maybe Prelude.Text,
    -- | Tags that are associated with the rule.
    RuleMetadata -> Maybe (NonEmpty Text)
ruleTags :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | A short description of the rule.
    RuleMetadata -> Maybe Text
shortDescription :: Prelude.Maybe Prelude.Text
  }
  deriving (RuleMetadata -> RuleMetadata -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RuleMetadata -> RuleMetadata -> Bool
$c/= :: RuleMetadata -> RuleMetadata -> Bool
== :: RuleMetadata -> RuleMetadata -> Bool
$c== :: RuleMetadata -> RuleMetadata -> Bool
Prelude.Eq, ReadPrec [RuleMetadata]
ReadPrec RuleMetadata
Int -> ReadS RuleMetadata
ReadS [RuleMetadata]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RuleMetadata]
$creadListPrec :: ReadPrec [RuleMetadata]
readPrec :: ReadPrec RuleMetadata
$creadPrec :: ReadPrec RuleMetadata
readList :: ReadS [RuleMetadata]
$creadList :: ReadS [RuleMetadata]
readsPrec :: Int -> ReadS RuleMetadata
$creadsPrec :: Int -> ReadS RuleMetadata
Prelude.Read, Int -> RuleMetadata -> ShowS
[RuleMetadata] -> ShowS
RuleMetadata -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuleMetadata] -> ShowS
$cshowList :: [RuleMetadata] -> ShowS
show :: RuleMetadata -> String
$cshow :: RuleMetadata -> String
showsPrec :: Int -> RuleMetadata -> ShowS
$cshowsPrec :: Int -> RuleMetadata -> ShowS
Prelude.Show, forall x. Rep RuleMetadata x -> RuleMetadata
forall x. RuleMetadata -> Rep RuleMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RuleMetadata x -> RuleMetadata
$cfrom :: forall x. RuleMetadata -> Rep RuleMetadata x
Prelude.Generic)

-- |
-- Create a value of 'RuleMetadata' 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:
--
-- 'longDescription', 'ruleMetadata_longDescription' - A long description of the rule.
--
-- 'ruleId', 'ruleMetadata_ruleId' - The ID of the rule.
--
-- 'ruleName', 'ruleMetadata_ruleName' - The name of the rule.
--
-- 'ruleTags', 'ruleMetadata_ruleTags' - Tags that are associated with the rule.
--
-- 'shortDescription', 'ruleMetadata_shortDescription' - A short description of the rule.
newRuleMetadata ::
  RuleMetadata
newRuleMetadata :: RuleMetadata
newRuleMetadata =
  RuleMetadata'
    { $sel:longDescription:RuleMetadata' :: Maybe Text
longDescription = forall a. Maybe a
Prelude.Nothing,
      $sel:ruleId:RuleMetadata' :: Maybe Text
ruleId = forall a. Maybe a
Prelude.Nothing,
      $sel:ruleName:RuleMetadata' :: Maybe Text
ruleName = forall a. Maybe a
Prelude.Nothing,
      $sel:ruleTags:RuleMetadata' :: Maybe (NonEmpty Text)
ruleTags = forall a. Maybe a
Prelude.Nothing,
      $sel:shortDescription:RuleMetadata' :: Maybe Text
shortDescription = forall a. Maybe a
Prelude.Nothing
    }

-- | A long description of the rule.
ruleMetadata_longDescription :: Lens.Lens' RuleMetadata (Prelude.Maybe Prelude.Text)
ruleMetadata_longDescription :: Lens' RuleMetadata (Maybe Text)
ruleMetadata_longDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleMetadata' {Maybe Text
longDescription :: Maybe Text
$sel:longDescription:RuleMetadata' :: RuleMetadata -> Maybe Text
longDescription} -> Maybe Text
longDescription) (\s :: RuleMetadata
s@RuleMetadata' {} Maybe Text
a -> RuleMetadata
s {$sel:longDescription:RuleMetadata' :: Maybe Text
longDescription = Maybe Text
a} :: RuleMetadata)

-- | The ID of the rule.
ruleMetadata_ruleId :: Lens.Lens' RuleMetadata (Prelude.Maybe Prelude.Text)
ruleMetadata_ruleId :: Lens' RuleMetadata (Maybe Text)
ruleMetadata_ruleId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleMetadata' {Maybe Text
ruleId :: Maybe Text
$sel:ruleId:RuleMetadata' :: RuleMetadata -> Maybe Text
ruleId} -> Maybe Text
ruleId) (\s :: RuleMetadata
s@RuleMetadata' {} Maybe Text
a -> RuleMetadata
s {$sel:ruleId:RuleMetadata' :: Maybe Text
ruleId = Maybe Text
a} :: RuleMetadata)

-- | The name of the rule.
ruleMetadata_ruleName :: Lens.Lens' RuleMetadata (Prelude.Maybe Prelude.Text)
ruleMetadata_ruleName :: Lens' RuleMetadata (Maybe Text)
ruleMetadata_ruleName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleMetadata' {Maybe Text
ruleName :: Maybe Text
$sel:ruleName:RuleMetadata' :: RuleMetadata -> Maybe Text
ruleName} -> Maybe Text
ruleName) (\s :: RuleMetadata
s@RuleMetadata' {} Maybe Text
a -> RuleMetadata
s {$sel:ruleName:RuleMetadata' :: Maybe Text
ruleName = Maybe Text
a} :: RuleMetadata)

-- | Tags that are associated with the rule.
ruleMetadata_ruleTags :: Lens.Lens' RuleMetadata (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
ruleMetadata_ruleTags :: Lens' RuleMetadata (Maybe (NonEmpty Text))
ruleMetadata_ruleTags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleMetadata' {Maybe (NonEmpty Text)
ruleTags :: Maybe (NonEmpty Text)
$sel:ruleTags:RuleMetadata' :: RuleMetadata -> Maybe (NonEmpty Text)
ruleTags} -> Maybe (NonEmpty Text)
ruleTags) (\s :: RuleMetadata
s@RuleMetadata' {} Maybe (NonEmpty Text)
a -> RuleMetadata
s {$sel:ruleTags:RuleMetadata' :: Maybe (NonEmpty Text)
ruleTags = Maybe (NonEmpty Text)
a} :: RuleMetadata) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A short description of the rule.
ruleMetadata_shortDescription :: Lens.Lens' RuleMetadata (Prelude.Maybe Prelude.Text)
ruleMetadata_shortDescription :: Lens' RuleMetadata (Maybe Text)
ruleMetadata_shortDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleMetadata' {Maybe Text
shortDescription :: Maybe Text
$sel:shortDescription:RuleMetadata' :: RuleMetadata -> Maybe Text
shortDescription} -> Maybe Text
shortDescription) (\s :: RuleMetadata
s@RuleMetadata' {} Maybe Text
a -> RuleMetadata
s {$sel:shortDescription:RuleMetadata' :: Maybe Text
shortDescription = Maybe Text
a} :: RuleMetadata)

instance Data.FromJSON RuleMetadata where
  parseJSON :: Value -> Parser RuleMetadata
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RuleMetadata"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe Text
-> RuleMetadata
RuleMetadata'
            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
"LongDescription")
            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
"RuleId")
            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
"RuleName")
            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
"RuleTags")
            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
"ShortDescription")
      )

instance Prelude.Hashable RuleMetadata where
  hashWithSalt :: Int -> RuleMetadata -> Int
hashWithSalt Int
_salt RuleMetadata' {Maybe (NonEmpty Text)
Maybe Text
shortDescription :: Maybe Text
ruleTags :: Maybe (NonEmpty Text)
ruleName :: Maybe Text
ruleId :: Maybe Text
longDescription :: Maybe Text
$sel:shortDescription:RuleMetadata' :: RuleMetadata -> Maybe Text
$sel:ruleTags:RuleMetadata' :: RuleMetadata -> Maybe (NonEmpty Text)
$sel:ruleName:RuleMetadata' :: RuleMetadata -> Maybe Text
$sel:ruleId:RuleMetadata' :: RuleMetadata -> Maybe Text
$sel:longDescription:RuleMetadata' :: RuleMetadata -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
longDescription
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ruleId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ruleName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
ruleTags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
shortDescription

instance Prelude.NFData RuleMetadata where
  rnf :: RuleMetadata -> ()
rnf RuleMetadata' {Maybe (NonEmpty Text)
Maybe Text
shortDescription :: Maybe Text
ruleTags :: Maybe (NonEmpty Text)
ruleName :: Maybe Text
ruleId :: Maybe Text
longDescription :: Maybe Text
$sel:shortDescription:RuleMetadata' :: RuleMetadata -> Maybe Text
$sel:ruleTags:RuleMetadata' :: RuleMetadata -> Maybe (NonEmpty Text)
$sel:ruleName:RuleMetadata' :: RuleMetadata -> Maybe Text
$sel:ruleId:RuleMetadata' :: RuleMetadata -> Maybe Text
$sel:longDescription:RuleMetadata' :: RuleMetadata -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
longDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ruleId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ruleName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
ruleTags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
shortDescription