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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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,
    -- | Tags that are associated with the rule.
    RuleMetadata -> Maybe (NonEmpty Text)
ruleTags :: Prelude.Maybe (Prelude.NonEmpty 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,
    -- | A short description of the rule.
    RuleMetadata -> Maybe Text
shortDescription :: Prelude.Maybe Prelude.Text
  }
  deriving (RuleMetadata -> RuleMetadata -> Bool
(RuleMetadata -> RuleMetadata -> Bool)
-> (RuleMetadata -> RuleMetadata -> Bool) -> Eq RuleMetadata
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]
(Int -> ReadS RuleMetadata)
-> ReadS [RuleMetadata]
-> ReadPrec RuleMetadata
-> ReadPrec [RuleMetadata]
-> Read 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
(Int -> RuleMetadata -> ShowS)
-> (RuleMetadata -> String)
-> ([RuleMetadata] -> ShowS)
-> Show RuleMetadata
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. RuleMetadata -> Rep RuleMetadata x)
-> (forall x. Rep RuleMetadata x -> RuleMetadata)
-> Generic RuleMetadata
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.
--
-- 'ruleTags', 'ruleMetadata_ruleTags' - Tags that are associated with the rule.
--
-- 'ruleId', 'ruleMetadata_ruleId' - The ID of the rule.
--
-- 'ruleName', 'ruleMetadata_ruleName' - The name of the rule.
--
-- 'shortDescription', 'ruleMetadata_shortDescription' - A short description of the rule.
newRuleMetadata ::
  RuleMetadata
newRuleMetadata :: RuleMetadata
newRuleMetadata =
  RuleMetadata' :: Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> RuleMetadata
RuleMetadata'
    { $sel:longDescription:RuleMetadata' :: Maybe Text
longDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleTags:RuleMetadata' :: Maybe (NonEmpty Text)
ruleTags = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleId:RuleMetadata' :: Maybe Text
ruleId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleName:RuleMetadata' :: Maybe Text
ruleName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:shortDescription:RuleMetadata' :: Maybe Text
shortDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A long description of the rule.
ruleMetadata_longDescription :: Lens.Lens' RuleMetadata (Prelude.Maybe Prelude.Text)
ruleMetadata_longDescription :: (Maybe Text -> f (Maybe Text)) -> RuleMetadata -> f RuleMetadata
ruleMetadata_longDescription = (RuleMetadata -> Maybe Text)
-> (RuleMetadata -> Maybe Text -> RuleMetadata)
-> Lens RuleMetadata RuleMetadata (Maybe Text) (Maybe Text)
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)

-- | Tags that are associated with the rule.
ruleMetadata_ruleTags :: Lens.Lens' RuleMetadata (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
ruleMetadata_ruleTags :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> RuleMetadata -> f RuleMetadata
ruleMetadata_ruleTags = (RuleMetadata -> Maybe (NonEmpty Text))
-> (RuleMetadata -> Maybe (NonEmpty Text) -> RuleMetadata)
-> Lens
     RuleMetadata
     RuleMetadata
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> RuleMetadata -> f RuleMetadata)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> RuleMetadata
-> f RuleMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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 AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the rule.
ruleMetadata_ruleId :: Lens.Lens' RuleMetadata (Prelude.Maybe Prelude.Text)
ruleMetadata_ruleId :: (Maybe Text -> f (Maybe Text)) -> RuleMetadata -> f RuleMetadata
ruleMetadata_ruleId = (RuleMetadata -> Maybe Text)
-> (RuleMetadata -> Maybe Text -> RuleMetadata)
-> Lens RuleMetadata RuleMetadata (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> RuleMetadata -> f RuleMetadata
ruleMetadata_ruleName = (RuleMetadata -> Maybe Text)
-> (RuleMetadata -> Maybe Text -> RuleMetadata)
-> Lens RuleMetadata RuleMetadata (Maybe Text) (Maybe Text)
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)

-- | A short description of the rule.
ruleMetadata_shortDescription :: Lens.Lens' RuleMetadata (Prelude.Maybe Prelude.Text)
ruleMetadata_shortDescription :: (Maybe Text -> f (Maybe Text)) -> RuleMetadata -> f RuleMetadata
ruleMetadata_shortDescription = (RuleMetadata -> Maybe Text)
-> (RuleMetadata -> Maybe Text -> RuleMetadata)
-> Lens RuleMetadata RuleMetadata (Maybe Text) (Maybe Text)
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 Core.FromJSON RuleMetadata where
  parseJSON :: Value -> Parser RuleMetadata
parseJSON =
    String
-> (Object -> Parser RuleMetadata) -> Value -> Parser RuleMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RuleMetadata"
      ( \Object
x ->
          Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> RuleMetadata
RuleMetadata'
            (Maybe Text
 -> Maybe (NonEmpty Text)
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> RuleMetadata)
-> Parser (Maybe Text)
-> Parser
     (Maybe (NonEmpty Text)
      -> Maybe Text -> Maybe Text -> Maybe Text -> RuleMetadata)
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
"LongDescription")
            Parser
  (Maybe (NonEmpty Text)
   -> Maybe Text -> Maybe Text -> Maybe Text -> RuleMetadata)
-> Parser (Maybe (NonEmpty Text))
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> RuleMetadata)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RuleTags")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> RuleMetadata)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> RuleMetadata)
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
"RuleId")
            Parser (Maybe Text -> Maybe Text -> RuleMetadata)
-> Parser (Maybe Text) -> Parser (Maybe Text -> RuleMetadata)
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
"RuleName")
            Parser (Maybe Text -> RuleMetadata)
-> Parser (Maybe Text) -> Parser RuleMetadata
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
"ShortDescription")
      )

instance Prelude.Hashable RuleMetadata

instance Prelude.NFData RuleMetadata