{-# 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.ECR.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.ECR.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 -> Maybe Double
baseScore :: Prelude.Maybe Prelude.Double,
    -- | The vector string of the CVSS score.
    CvssScore -> Maybe Text
scoringVector :: Prelude.Maybe Prelude.Text,
    -- | The source of the CVSS score.
    CvssScore -> Maybe Text
source :: Prelude.Maybe Prelude.Text,
    -- | The version of CVSS used for the score.
    CvssScore -> Maybe Text
version :: Prelude.Maybe 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 ::
  CvssScore
newCvssScore :: CvssScore
newCvssScore =
  CvssScore'
    { $sel:baseScore:CvssScore' :: Maybe Double
baseScore = forall a. Maybe a
Prelude.Nothing,
      $sel:scoringVector:CvssScore' :: Maybe Text
scoringVector = forall a. Maybe a
Prelude.Nothing,
      $sel:source:CvssScore' :: Maybe Text
source = forall a. Maybe a
Prelude.Nothing,
      $sel:version:CvssScore' :: Maybe Text
version = forall a. Maybe a
Prelude.Nothing
    }

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

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

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

-- | The version of CVSS used for the score.
cvssScore_version :: Lens.Lens' CvssScore (Prelude.Maybe Prelude.Text)
cvssScore_version :: Lens' CvssScore (Maybe Text)
cvssScore_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CvssScore' {Maybe Text
version :: Maybe Text
$sel:version:CvssScore' :: CvssScore -> Maybe Text
version} -> Maybe Text
version) (\s :: CvssScore
s@CvssScore' {} Maybe Text
a -> CvssScore
s {$sel:version:CvssScore' :: Maybe Text
version = Maybe 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 ->
          Maybe Double -> Maybe Text -> Maybe Text -> Maybe 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 (Maybe 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 (Maybe 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 (Maybe 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 (Maybe a)
Data..:? Key
"version")
      )

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

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