{-# 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.Inspector2.Types.CvssScore
-- 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.Inspector2.Types.CvssScore 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

-- | The CVSS score for a finding.
--
-- /See:/ 'newCvssScore' smart constructor.
data CvssScore = CvssScore'
  { -- | The base CVSS score used for the finding.
    CvssScore -> Double
baseScore :: Prelude.Double,
    -- | The vector string of the CVSS score.
    CvssScore -> Text
scoringVector :: Prelude.Text,
    -- | The source of the CVSS score.
    CvssScore -> Text
source :: Prelude.Text,
    -- | The version of CVSS used for the score.
    CvssScore -> Text
version :: Prelude.Text
  }
  deriving (CvssScore -> CvssScore -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CvssScore -> CvssScore -> Bool
$c/= :: CvssScore -> CvssScore -> Bool
== :: CvssScore -> CvssScore -> Bool
$c== :: CvssScore -> CvssScore -> Bool
Prelude.Eq, ReadPrec [CvssScore]
ReadPrec CvssScore
Int -> ReadS CvssScore
ReadS [CvssScore]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CvssScore]
$creadListPrec :: ReadPrec [CvssScore]
readPrec :: ReadPrec CvssScore
$creadPrec :: ReadPrec CvssScore
readList :: ReadS [CvssScore]
$creadList :: ReadS [CvssScore]
readsPrec :: Int -> ReadS CvssScore
$creadsPrec :: Int -> ReadS CvssScore
Prelude.Read, Int -> CvssScore -> ShowS
[CvssScore] -> ShowS
CvssScore -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CvssScore] -> ShowS
$cshowList :: [CvssScore] -> ShowS
show :: CvssScore -> String
$cshow :: CvssScore -> String
showsPrec :: Int -> CvssScore -> ShowS
$cshowsPrec :: Int -> CvssScore -> ShowS
Prelude.Show, forall x. Rep CvssScore x -> CvssScore
forall x. CvssScore -> Rep CvssScore x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CvssScore x -> CvssScore
$cfrom :: forall x. CvssScore -> Rep CvssScore x
Prelude.Generic)

-- |
-- Create a value of 'CvssScore' 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:
--
-- 'baseScore', 'cvssScore_baseScore' - The base CVSS score used for the finding.
--
-- 'scoringVector', 'cvssScore_scoringVector' - The vector string of the CVSS score.
--
-- 'source', 'cvssScore_source' - The source of the CVSS score.
--
-- 'version', 'cvssScore_version' - The version of CVSS used for the score.
newCvssScore ::
  -- | 'baseScore'
  Prelude.Double ->
  -- | 'scoringVector'
  Prelude.Text ->
  -- | 'source'
  Prelude.Text ->
  -- | 'version'
  Prelude.Text ->
  CvssScore
newCvssScore :: Double -> Text -> Text -> Text -> CvssScore
newCvssScore
  Double
pBaseScore_
  Text
pScoringVector_
  Text
pSource_
  Text
pVersion_ =
    CvssScore'
      { $sel:baseScore:CvssScore' :: Double
baseScore = Double
pBaseScore_,
        $sel:scoringVector:CvssScore' :: Text
scoringVector = Text
pScoringVector_,
        $sel:source:CvssScore' :: Text
source = Text
pSource_,
        $sel:version:CvssScore' :: Text
version = Text
pVersion_
      }

-- | The base CVSS score used for the finding.
cvssScore_baseScore :: Lens.Lens' CvssScore Prelude.Double
cvssScore_baseScore :: Lens' CvssScore Double
cvssScore_baseScore = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CvssScore' {Double
baseScore :: Double
$sel:baseScore:CvssScore' :: CvssScore -> Double
baseScore} -> Double
baseScore) (\s :: CvssScore
s@CvssScore' {} Double
a -> CvssScore
s {$sel:baseScore:CvssScore' :: Double
baseScore = Double
a} :: CvssScore)

-- | The vector string of the CVSS score.
cvssScore_scoringVector :: Lens.Lens' CvssScore Prelude.Text
cvssScore_scoringVector :: Lens' CvssScore Text
cvssScore_scoringVector = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CvssScore' {Text
scoringVector :: Text
$sel:scoringVector:CvssScore' :: CvssScore -> Text
scoringVector} -> Text
scoringVector) (\s :: CvssScore
s@CvssScore' {} Text
a -> CvssScore
s {$sel:scoringVector:CvssScore' :: Text
scoringVector = Text
a} :: CvssScore)

-- | The source of the CVSS score.
cvssScore_source :: Lens.Lens' CvssScore Prelude.Text
cvssScore_source :: Lens' CvssScore Text
cvssScore_source = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CvssScore' {Text
source :: Text
$sel:source:CvssScore' :: CvssScore -> Text
source} -> Text
source) (\s :: CvssScore
s@CvssScore' {} Text
a -> CvssScore
s {$sel:source:CvssScore' :: Text
source = Text
a} :: CvssScore)

-- | The version of CVSS used for the score.
cvssScore_version :: Lens.Lens' CvssScore Prelude.Text
cvssScore_version :: Lens' CvssScore Text
cvssScore_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CvssScore' {Text
version :: Text
$sel:version:CvssScore' :: CvssScore -> Text
version} -> Text
version) (\s :: CvssScore
s@CvssScore' {} Text
a -> CvssScore
s {$sel:version:CvssScore' :: Text
version = Text
a} :: CvssScore)

instance Data.FromJSON CvssScore where
  parseJSON :: Value -> Parser CvssScore
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CvssScore"
      ( \Object
x ->
          Double -> Text -> Text -> Text -> CvssScore
CvssScore'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"baseScore")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"scoringVector")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"source")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"version")
      )

instance Prelude.Hashable CvssScore where
  hashWithSalt :: Int -> CvssScore -> Int
hashWithSalt Int
_salt CvssScore' {Double
Text
version :: Text
source :: Text
scoringVector :: Text
baseScore :: Double
$sel:version:CvssScore' :: CvssScore -> Text
$sel:source:CvssScore' :: CvssScore -> Text
$sel:scoringVector:CvssScore' :: CvssScore -> Text
$sel:baseScore:CvssScore' :: CvssScore -> Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
baseScore
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
scoringVector
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
source
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
version

instance Prelude.NFData CvssScore where
  rnf :: CvssScore -> ()
rnf CvssScore' {Double
Text
version :: Text
source :: Text
scoringVector :: Text
baseScore :: Double
$sel:version:CvssScore' :: CvssScore -> Text
$sel:source:CvssScore' :: CvssScore -> Text
$sel:scoringVector:CvssScore' :: CvssScore -> Text
$sel:baseScore:CvssScore' :: CvssScore -> Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Double
baseScore
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
scoringVector
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
source
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
version