{-# 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 #-}
module Amazonka.SecurityHub.Types.Cvss where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.Adjustment
data Cvss = Cvss'
{
Cvss -> Maybe [Adjustment]
adjustments :: Prelude.Maybe [Adjustment],
Cvss -> Maybe Text
baseVector :: Prelude.Maybe Prelude.Text,
Cvss -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
Cvss -> Maybe Text
source :: Prelude.Maybe Prelude.Text,
Cvss -> Maybe Double
baseScore :: Prelude.Maybe Prelude.Double
}
deriving (Cvss -> Cvss -> Bool
(Cvss -> Cvss -> Bool) -> (Cvss -> Cvss -> Bool) -> Eq Cvss
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Cvss -> Cvss -> Bool
$c/= :: Cvss -> Cvss -> Bool
== :: Cvss -> Cvss -> Bool
$c== :: Cvss -> Cvss -> Bool
Prelude.Eq, ReadPrec [Cvss]
ReadPrec Cvss
Int -> ReadS Cvss
ReadS [Cvss]
(Int -> ReadS Cvss)
-> ReadS [Cvss] -> ReadPrec Cvss -> ReadPrec [Cvss] -> Read Cvss
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Cvss]
$creadListPrec :: ReadPrec [Cvss]
readPrec :: ReadPrec Cvss
$creadPrec :: ReadPrec Cvss
readList :: ReadS [Cvss]
$creadList :: ReadS [Cvss]
readsPrec :: Int -> ReadS Cvss
$creadsPrec :: Int -> ReadS Cvss
Prelude.Read, Int -> Cvss -> ShowS
[Cvss] -> ShowS
Cvss -> String
(Int -> Cvss -> ShowS)
-> (Cvss -> String) -> ([Cvss] -> ShowS) -> Show Cvss
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Cvss] -> ShowS
$cshowList :: [Cvss] -> ShowS
show :: Cvss -> String
$cshow :: Cvss -> String
showsPrec :: Int -> Cvss -> ShowS
$cshowsPrec :: Int -> Cvss -> ShowS
Prelude.Show, (forall x. Cvss -> Rep Cvss x)
-> (forall x. Rep Cvss x -> Cvss) -> Generic Cvss
forall x. Rep Cvss x -> Cvss
forall x. Cvss -> Rep Cvss x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Cvss x -> Cvss
$cfrom :: forall x. Cvss -> Rep Cvss x
Prelude.Generic)
newCvss ::
Cvss
newCvss :: Cvss
newCvss =
Cvss' :: Maybe [Adjustment]
-> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Double -> Cvss
Cvss'
{ $sel:adjustments:Cvss' :: Maybe [Adjustment]
adjustments = Maybe [Adjustment]
forall a. Maybe a
Prelude.Nothing,
$sel:baseVector:Cvss' :: Maybe Text
baseVector = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:version:Cvss' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:source:Cvss' :: Maybe Text
source = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:baseScore:Cvss' :: Maybe Double
baseScore = Maybe Double
forall a. Maybe a
Prelude.Nothing
}
cvss_adjustments :: Lens.Lens' Cvss (Prelude.Maybe [Adjustment])
cvss_adjustments :: (Maybe [Adjustment] -> f (Maybe [Adjustment])) -> Cvss -> f Cvss
cvss_adjustments = (Cvss -> Maybe [Adjustment])
-> (Cvss -> Maybe [Adjustment] -> Cvss)
-> Lens Cvss Cvss (Maybe [Adjustment]) (Maybe [Adjustment])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cvss' {Maybe [Adjustment]
adjustments :: Maybe [Adjustment]
$sel:adjustments:Cvss' :: Cvss -> Maybe [Adjustment]
adjustments} -> Maybe [Adjustment]
adjustments) (\s :: Cvss
s@Cvss' {} Maybe [Adjustment]
a -> Cvss
s {$sel:adjustments:Cvss' :: Maybe [Adjustment]
adjustments = Maybe [Adjustment]
a} :: Cvss) ((Maybe [Adjustment] -> f (Maybe [Adjustment])) -> Cvss -> f Cvss)
-> ((Maybe [Adjustment] -> f (Maybe [Adjustment]))
-> Maybe [Adjustment] -> f (Maybe [Adjustment]))
-> (Maybe [Adjustment] -> f (Maybe [Adjustment]))
-> Cvss
-> f Cvss
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Adjustment] [Adjustment] [Adjustment] [Adjustment]
-> Iso
(Maybe [Adjustment])
(Maybe [Adjustment])
(Maybe [Adjustment])
(Maybe [Adjustment])
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 [Adjustment] [Adjustment] [Adjustment] [Adjustment]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
cvss_baseVector :: Lens.Lens' Cvss (Prelude.Maybe Prelude.Text)
cvss_baseVector :: (Maybe Text -> f (Maybe Text)) -> Cvss -> f Cvss
cvss_baseVector = (Cvss -> Maybe Text)
-> (Cvss -> Maybe Text -> Cvss)
-> Lens Cvss Cvss (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cvss' {Maybe Text
baseVector :: Maybe Text
$sel:baseVector:Cvss' :: Cvss -> Maybe Text
baseVector} -> Maybe Text
baseVector) (\s :: Cvss
s@Cvss' {} Maybe Text
a -> Cvss
s {$sel:baseVector:Cvss' :: Maybe Text
baseVector = Maybe Text
a} :: Cvss)
cvss_version :: Lens.Lens' Cvss (Prelude.Maybe Prelude.Text)
cvss_version :: (Maybe Text -> f (Maybe Text)) -> Cvss -> f Cvss
cvss_version = (Cvss -> Maybe Text)
-> (Cvss -> Maybe Text -> Cvss)
-> Lens Cvss Cvss (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cvss' {Maybe Text
version :: Maybe Text
$sel:version:Cvss' :: Cvss -> Maybe Text
version} -> Maybe Text
version) (\s :: Cvss
s@Cvss' {} Maybe Text
a -> Cvss
s {$sel:version:Cvss' :: Maybe Text
version = Maybe Text
a} :: Cvss)
cvss_source :: Lens.Lens' Cvss (Prelude.Maybe Prelude.Text)
cvss_source :: (Maybe Text -> f (Maybe Text)) -> Cvss -> f Cvss
cvss_source = (Cvss -> Maybe Text)
-> (Cvss -> Maybe Text -> Cvss)
-> Lens Cvss Cvss (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cvss' {Maybe Text
source :: Maybe Text
$sel:source:Cvss' :: Cvss -> Maybe Text
source} -> Maybe Text
source) (\s :: Cvss
s@Cvss' {} Maybe Text
a -> Cvss
s {$sel:source:Cvss' :: Maybe Text
source = Maybe Text
a} :: Cvss)
cvss_baseScore :: Lens.Lens' Cvss (Prelude.Maybe Prelude.Double)
cvss_baseScore :: (Maybe Double -> f (Maybe Double)) -> Cvss -> f Cvss
cvss_baseScore = (Cvss -> Maybe Double)
-> (Cvss -> Maybe Double -> Cvss)
-> Lens Cvss Cvss (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cvss' {Maybe Double
baseScore :: Maybe Double
$sel:baseScore:Cvss' :: Cvss -> Maybe Double
baseScore} -> Maybe Double
baseScore) (\s :: Cvss
s@Cvss' {} Maybe Double
a -> Cvss
s {$sel:baseScore:Cvss' :: Maybe Double
baseScore = Maybe Double
a} :: Cvss)
instance Core.FromJSON Cvss where
parseJSON :: Value -> Parser Cvss
parseJSON =
String -> (Object -> Parser Cvss) -> Value -> Parser Cvss
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Cvss"
( \Object
x ->
Maybe [Adjustment]
-> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Double -> Cvss
Cvss'
(Maybe [Adjustment]
-> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Double -> Cvss)
-> Parser (Maybe [Adjustment])
-> Parser
(Maybe Text -> Maybe Text -> Maybe Text -> Maybe Double -> Cvss)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Adjustment]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Adjustments" Parser (Maybe (Maybe [Adjustment]))
-> Maybe [Adjustment] -> Parser (Maybe [Adjustment])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Adjustment]
forall a. Monoid a => a
Prelude.mempty)
Parser
(Maybe Text -> Maybe Text -> Maybe Text -> Maybe Double -> Cvss)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Double -> Cvss)
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
"BaseVector")
Parser (Maybe Text -> Maybe Text -> Maybe Double -> Cvss)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Double -> Cvss)
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
"Version")
Parser (Maybe Text -> Maybe Double -> Cvss)
-> Parser (Maybe Text) -> Parser (Maybe Double -> Cvss)
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
"Source")
Parser (Maybe Double -> Cvss)
-> Parser (Maybe Double) -> Parser Cvss
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BaseScore")
)
instance Prelude.Hashable Cvss
instance Prelude.NFData Cvss
instance Core.ToJSON Cvss where
toJSON :: Cvss -> Value
toJSON Cvss' {Maybe Double
Maybe [Adjustment]
Maybe Text
baseScore :: Maybe Double
source :: Maybe Text
version :: Maybe Text
baseVector :: Maybe Text
adjustments :: Maybe [Adjustment]
$sel:baseScore:Cvss' :: Cvss -> Maybe Double
$sel:source:Cvss' :: Cvss -> Maybe Text
$sel:version:Cvss' :: Cvss -> Maybe Text
$sel:baseVector:Cvss' :: Cvss -> Maybe Text
$sel:adjustments:Cvss' :: Cvss -> Maybe [Adjustment]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Adjustments" Text -> [Adjustment] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Adjustment] -> Pair) -> Maybe [Adjustment] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Adjustment]
adjustments,
(Text
"BaseVector" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
baseVector,
(Text
"Version" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
version,
(Text
"Source" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
source,
(Text
"BaseScore" 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
baseScore
]
)