{-# 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.SecurityHub.Types.SeverityUpdate
-- 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.SecurityHub.Types.SeverityUpdate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.SeverityLabel

-- | Updates to the severity information for a finding.
--
-- /See:/ 'newSeverityUpdate' smart constructor.
data SeverityUpdate = SeverityUpdate'
  { -- | The native severity as defined by the Amazon Web Services service or
    -- integrated partner product that generated the finding.
    SeverityUpdate -> Maybe Double
product :: Prelude.Maybe Prelude.Double,
    -- | The severity value of the finding. The allowed values are the following.
    --
    -- -   @INFORMATIONAL@ - No issue was found.
    --
    -- -   @LOW@ - The issue does not require action on its own.
    --
    -- -   @MEDIUM@ - The issue must be addressed but not urgently.
    --
    -- -   @HIGH@ - The issue must be addressed as a priority.
    --
    -- -   @CRITICAL@ - The issue must be remediated immediately to avoid it
    --     escalating.
    SeverityUpdate -> Maybe SeverityLabel
label :: Prelude.Maybe SeverityLabel,
    -- | The normalized severity for the finding. This attribute is to be
    -- deprecated in favor of @Label@.
    --
    -- If you provide @Normalized@ and do not provide @Label@, @Label@ is set
    -- automatically as follows.
    --
    -- -   0 - @INFORMATIONAL@
    --
    -- -   1–39 - @LOW@
    --
    -- -   40–69 - @MEDIUM@
    --
    -- -   70–89 - @HIGH@
    --
    -- -   90–100 - @CRITICAL@
    SeverityUpdate -> Maybe Natural
normalized :: Prelude.Maybe Prelude.Natural
  }
  deriving (SeverityUpdate -> SeverityUpdate -> Bool
(SeverityUpdate -> SeverityUpdate -> Bool)
-> (SeverityUpdate -> SeverityUpdate -> Bool) -> Eq SeverityUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SeverityUpdate -> SeverityUpdate -> Bool
$c/= :: SeverityUpdate -> SeverityUpdate -> Bool
== :: SeverityUpdate -> SeverityUpdate -> Bool
$c== :: SeverityUpdate -> SeverityUpdate -> Bool
Prelude.Eq, ReadPrec [SeverityUpdate]
ReadPrec SeverityUpdate
Int -> ReadS SeverityUpdate
ReadS [SeverityUpdate]
(Int -> ReadS SeverityUpdate)
-> ReadS [SeverityUpdate]
-> ReadPrec SeverityUpdate
-> ReadPrec [SeverityUpdate]
-> Read SeverityUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SeverityUpdate]
$creadListPrec :: ReadPrec [SeverityUpdate]
readPrec :: ReadPrec SeverityUpdate
$creadPrec :: ReadPrec SeverityUpdate
readList :: ReadS [SeverityUpdate]
$creadList :: ReadS [SeverityUpdate]
readsPrec :: Int -> ReadS SeverityUpdate
$creadsPrec :: Int -> ReadS SeverityUpdate
Prelude.Read, Int -> SeverityUpdate -> ShowS
[SeverityUpdate] -> ShowS
SeverityUpdate -> String
(Int -> SeverityUpdate -> ShowS)
-> (SeverityUpdate -> String)
-> ([SeverityUpdate] -> ShowS)
-> Show SeverityUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SeverityUpdate] -> ShowS
$cshowList :: [SeverityUpdate] -> ShowS
show :: SeverityUpdate -> String
$cshow :: SeverityUpdate -> String
showsPrec :: Int -> SeverityUpdate -> ShowS
$cshowsPrec :: Int -> SeverityUpdate -> ShowS
Prelude.Show, (forall x. SeverityUpdate -> Rep SeverityUpdate x)
-> (forall x. Rep SeverityUpdate x -> SeverityUpdate)
-> Generic SeverityUpdate
forall x. Rep SeverityUpdate x -> SeverityUpdate
forall x. SeverityUpdate -> Rep SeverityUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SeverityUpdate x -> SeverityUpdate
$cfrom :: forall x. SeverityUpdate -> Rep SeverityUpdate x
Prelude.Generic)

-- |
-- Create a value of 'SeverityUpdate' 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:
--
-- 'product', 'severityUpdate_product' - The native severity as defined by the Amazon Web Services service or
-- integrated partner product that generated the finding.
--
-- 'label', 'severityUpdate_label' - The severity value of the finding. The allowed values are the following.
--
-- -   @INFORMATIONAL@ - No issue was found.
--
-- -   @LOW@ - The issue does not require action on its own.
--
-- -   @MEDIUM@ - The issue must be addressed but not urgently.
--
-- -   @HIGH@ - The issue must be addressed as a priority.
--
-- -   @CRITICAL@ - The issue must be remediated immediately to avoid it
--     escalating.
--
-- 'normalized', 'severityUpdate_normalized' - The normalized severity for the finding. This attribute is to be
-- deprecated in favor of @Label@.
--
-- If you provide @Normalized@ and do not provide @Label@, @Label@ is set
-- automatically as follows.
--
-- -   0 - @INFORMATIONAL@
--
-- -   1–39 - @LOW@
--
-- -   40–69 - @MEDIUM@
--
-- -   70–89 - @HIGH@
--
-- -   90–100 - @CRITICAL@
newSeverityUpdate ::
  SeverityUpdate
newSeverityUpdate :: SeverityUpdate
newSeverityUpdate =
  SeverityUpdate' :: Maybe Double
-> Maybe SeverityLabel -> Maybe Natural -> SeverityUpdate
SeverityUpdate'
    { $sel:product:SeverityUpdate' :: Maybe Double
product = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:label:SeverityUpdate' :: Maybe SeverityLabel
label = Maybe SeverityLabel
forall a. Maybe a
Prelude.Nothing,
      $sel:normalized:SeverityUpdate' :: Maybe Natural
normalized = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The native severity as defined by the Amazon Web Services service or
-- integrated partner product that generated the finding.
severityUpdate_product :: Lens.Lens' SeverityUpdate (Prelude.Maybe Prelude.Double)
severityUpdate_product :: (Maybe Double -> f (Maybe Double))
-> SeverityUpdate -> f SeverityUpdate
severityUpdate_product = (SeverityUpdate -> Maybe Double)
-> (SeverityUpdate -> Maybe Double -> SeverityUpdate)
-> Lens SeverityUpdate SeverityUpdate (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SeverityUpdate' {Maybe Double
product :: Maybe Double
$sel:product:SeverityUpdate' :: SeverityUpdate -> Maybe Double
product} -> Maybe Double
product) (\s :: SeverityUpdate
s@SeverityUpdate' {} Maybe Double
a -> SeverityUpdate
s {$sel:product:SeverityUpdate' :: Maybe Double
product = Maybe Double
a} :: SeverityUpdate)

-- | The severity value of the finding. The allowed values are the following.
--
-- -   @INFORMATIONAL@ - No issue was found.
--
-- -   @LOW@ - The issue does not require action on its own.
--
-- -   @MEDIUM@ - The issue must be addressed but not urgently.
--
-- -   @HIGH@ - The issue must be addressed as a priority.
--
-- -   @CRITICAL@ - The issue must be remediated immediately to avoid it
--     escalating.
severityUpdate_label :: Lens.Lens' SeverityUpdate (Prelude.Maybe SeverityLabel)
severityUpdate_label :: (Maybe SeverityLabel -> f (Maybe SeverityLabel))
-> SeverityUpdate -> f SeverityUpdate
severityUpdate_label = (SeverityUpdate -> Maybe SeverityLabel)
-> (SeverityUpdate -> Maybe SeverityLabel -> SeverityUpdate)
-> Lens
     SeverityUpdate
     SeverityUpdate
     (Maybe SeverityLabel)
     (Maybe SeverityLabel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SeverityUpdate' {Maybe SeverityLabel
label :: Maybe SeverityLabel
$sel:label:SeverityUpdate' :: SeverityUpdate -> Maybe SeverityLabel
label} -> Maybe SeverityLabel
label) (\s :: SeverityUpdate
s@SeverityUpdate' {} Maybe SeverityLabel
a -> SeverityUpdate
s {$sel:label:SeverityUpdate' :: Maybe SeverityLabel
label = Maybe SeverityLabel
a} :: SeverityUpdate)

-- | The normalized severity for the finding. This attribute is to be
-- deprecated in favor of @Label@.
--
-- If you provide @Normalized@ and do not provide @Label@, @Label@ is set
-- automatically as follows.
--
-- -   0 - @INFORMATIONAL@
--
-- -   1–39 - @LOW@
--
-- -   40–69 - @MEDIUM@
--
-- -   70–89 - @HIGH@
--
-- -   90–100 - @CRITICAL@
severityUpdate_normalized :: Lens.Lens' SeverityUpdate (Prelude.Maybe Prelude.Natural)
severityUpdate_normalized :: (Maybe Natural -> f (Maybe Natural))
-> SeverityUpdate -> f SeverityUpdate
severityUpdate_normalized = (SeverityUpdate -> Maybe Natural)
-> (SeverityUpdate -> Maybe Natural -> SeverityUpdate)
-> Lens
     SeverityUpdate SeverityUpdate (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SeverityUpdate' {Maybe Natural
normalized :: Maybe Natural
$sel:normalized:SeverityUpdate' :: SeverityUpdate -> Maybe Natural
normalized} -> Maybe Natural
normalized) (\s :: SeverityUpdate
s@SeverityUpdate' {} Maybe Natural
a -> SeverityUpdate
s {$sel:normalized:SeverityUpdate' :: Maybe Natural
normalized = Maybe Natural
a} :: SeverityUpdate)

instance Prelude.Hashable SeverityUpdate

instance Prelude.NFData SeverityUpdate

instance Core.ToJSON SeverityUpdate where
  toJSON :: SeverityUpdate -> Value
toJSON SeverityUpdate' {Maybe Double
Maybe Natural
Maybe SeverityLabel
normalized :: Maybe Natural
label :: Maybe SeverityLabel
product :: Maybe Double
$sel:normalized:SeverityUpdate' :: SeverityUpdate -> Maybe Natural
$sel:label:SeverityUpdate' :: SeverityUpdate -> Maybe SeverityLabel
$sel:product:SeverityUpdate' :: SeverityUpdate -> Maybe Double
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Product" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
product,
            (Text
"Label" Text -> SeverityLabel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SeverityLabel -> Pair) -> Maybe SeverityLabel -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SeverityLabel
label,
            (Text
"Normalized" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
normalized
          ]
      )