{-# 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.MacieV2.Types.Severity
-- 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.MacieV2.Types.Severity where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.SeverityDescription
import qualified Amazonka.Prelude as Prelude

-- | Provides the numerical and qualitative representations of a finding\'s
-- severity.
--
-- /See:/ 'newSeverity' smart constructor.
data Severity = Severity'
  { -- | The numerical representation of the finding\'s severity, ranging from 1
    -- (least severe) to 3 (most severe).
    Severity -> Maybe Integer
score :: Prelude.Maybe Prelude.Integer,
    -- | The qualitative representation of the finding\'s severity, ranging from
    -- Low (least severe) to High (most severe).
    Severity -> Maybe SeverityDescription
description :: Prelude.Maybe SeverityDescription
  }
  deriving (Severity -> Severity -> Bool
(Severity -> Severity -> Bool)
-> (Severity -> Severity -> Bool) -> Eq Severity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Severity -> Severity -> Bool
$c/= :: Severity -> Severity -> Bool
== :: Severity -> Severity -> Bool
$c== :: Severity -> Severity -> Bool
Prelude.Eq, ReadPrec [Severity]
ReadPrec Severity
Int -> ReadS Severity
ReadS [Severity]
(Int -> ReadS Severity)
-> ReadS [Severity]
-> ReadPrec Severity
-> ReadPrec [Severity]
-> Read Severity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Severity]
$creadListPrec :: ReadPrec [Severity]
readPrec :: ReadPrec Severity
$creadPrec :: ReadPrec Severity
readList :: ReadS [Severity]
$creadList :: ReadS [Severity]
readsPrec :: Int -> ReadS Severity
$creadsPrec :: Int -> ReadS Severity
Prelude.Read, Int -> Severity -> ShowS
[Severity] -> ShowS
Severity -> String
(Int -> Severity -> ShowS)
-> (Severity -> String) -> ([Severity] -> ShowS) -> Show Severity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Severity] -> ShowS
$cshowList :: [Severity] -> ShowS
show :: Severity -> String
$cshow :: Severity -> String
showsPrec :: Int -> Severity -> ShowS
$cshowsPrec :: Int -> Severity -> ShowS
Prelude.Show, (forall x. Severity -> Rep Severity x)
-> (forall x. Rep Severity x -> Severity) -> Generic Severity
forall x. Rep Severity x -> Severity
forall x. Severity -> Rep Severity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Severity x -> Severity
$cfrom :: forall x. Severity -> Rep Severity x
Prelude.Generic)

-- |
-- Create a value of 'Severity' 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:
--
-- 'score', 'severity_score' - The numerical representation of the finding\'s severity, ranging from 1
-- (least severe) to 3 (most severe).
--
-- 'description', 'severity_description' - The qualitative representation of the finding\'s severity, ranging from
-- Low (least severe) to High (most severe).
newSeverity ::
  Severity
newSeverity :: Severity
newSeverity =
  Severity' :: Maybe Integer -> Maybe SeverityDescription -> Severity
Severity'
    { $sel:score:Severity' :: Maybe Integer
score = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:description:Severity' :: Maybe SeverityDescription
description = Maybe SeverityDescription
forall a. Maybe a
Prelude.Nothing
    }

-- | The numerical representation of the finding\'s severity, ranging from 1
-- (least severe) to 3 (most severe).
severity_score :: Lens.Lens' Severity (Prelude.Maybe Prelude.Integer)
severity_score :: (Maybe Integer -> f (Maybe Integer)) -> Severity -> f Severity
severity_score = (Severity -> Maybe Integer)
-> (Severity -> Maybe Integer -> Severity)
-> Lens Severity Severity (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Severity' {Maybe Integer
score :: Maybe Integer
$sel:score:Severity' :: Severity -> Maybe Integer
score} -> Maybe Integer
score) (\s :: Severity
s@Severity' {} Maybe Integer
a -> Severity
s {$sel:score:Severity' :: Maybe Integer
score = Maybe Integer
a} :: Severity)

-- | The qualitative representation of the finding\'s severity, ranging from
-- Low (least severe) to High (most severe).
severity_description :: Lens.Lens' Severity (Prelude.Maybe SeverityDescription)
severity_description :: (Maybe SeverityDescription -> f (Maybe SeverityDescription))
-> Severity -> f Severity
severity_description = (Severity -> Maybe SeverityDescription)
-> (Severity -> Maybe SeverityDescription -> Severity)
-> Lens
     Severity
     Severity
     (Maybe SeverityDescription)
     (Maybe SeverityDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Severity' {Maybe SeverityDescription
description :: Maybe SeverityDescription
$sel:description:Severity' :: Severity -> Maybe SeverityDescription
description} -> Maybe SeverityDescription
description) (\s :: Severity
s@Severity' {} Maybe SeverityDescription
a -> Severity
s {$sel:description:Severity' :: Maybe SeverityDescription
description = Maybe SeverityDescription
a} :: Severity)

instance Core.FromJSON Severity where
  parseJSON :: Value -> Parser Severity
parseJSON =
    String -> (Object -> Parser Severity) -> Value -> Parser Severity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Severity"
      ( \Object
x ->
          Maybe Integer -> Maybe SeverityDescription -> Severity
Severity'
            (Maybe Integer -> Maybe SeverityDescription -> Severity)
-> Parser (Maybe Integer)
-> Parser (Maybe SeverityDescription -> Severity)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"score")
            Parser (Maybe SeverityDescription -> Severity)
-> Parser (Maybe SeverityDescription) -> Parser Severity
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SeverityDescription)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"description")
      )

instance Prelude.Hashable Severity

instance Prelude.NFData Severity