{-# 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.StatusReason where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data StatusReason = StatusReason'
{
StatusReason -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
StatusReason -> Text
reasonCode :: Prelude.Text
}
deriving (StatusReason -> StatusReason -> Bool
(StatusReason -> StatusReason -> Bool)
-> (StatusReason -> StatusReason -> Bool) -> Eq StatusReason
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatusReason -> StatusReason -> Bool
$c/= :: StatusReason -> StatusReason -> Bool
== :: StatusReason -> StatusReason -> Bool
$c== :: StatusReason -> StatusReason -> Bool
Prelude.Eq, ReadPrec [StatusReason]
ReadPrec StatusReason
Int -> ReadS StatusReason
ReadS [StatusReason]
(Int -> ReadS StatusReason)
-> ReadS [StatusReason]
-> ReadPrec StatusReason
-> ReadPrec [StatusReason]
-> Read StatusReason
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatusReason]
$creadListPrec :: ReadPrec [StatusReason]
readPrec :: ReadPrec StatusReason
$creadPrec :: ReadPrec StatusReason
readList :: ReadS [StatusReason]
$creadList :: ReadS [StatusReason]
readsPrec :: Int -> ReadS StatusReason
$creadsPrec :: Int -> ReadS StatusReason
Prelude.Read, Int -> StatusReason -> ShowS
[StatusReason] -> ShowS
StatusReason -> String
(Int -> StatusReason -> ShowS)
-> (StatusReason -> String)
-> ([StatusReason] -> ShowS)
-> Show StatusReason
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatusReason] -> ShowS
$cshowList :: [StatusReason] -> ShowS
show :: StatusReason -> String
$cshow :: StatusReason -> String
showsPrec :: Int -> StatusReason -> ShowS
$cshowsPrec :: Int -> StatusReason -> ShowS
Prelude.Show, (forall x. StatusReason -> Rep StatusReason x)
-> (forall x. Rep StatusReason x -> StatusReason)
-> Generic StatusReason
forall x. Rep StatusReason x -> StatusReason
forall x. StatusReason -> Rep StatusReason x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatusReason x -> StatusReason
$cfrom :: forall x. StatusReason -> Rep StatusReason x
Prelude.Generic)
newStatusReason ::
Prelude.Text ->
StatusReason
newStatusReason :: Text -> StatusReason
newStatusReason Text
pReasonCode_ =
StatusReason' :: Maybe Text -> Text -> StatusReason
StatusReason'
{ $sel:description:StatusReason' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:reasonCode:StatusReason' :: Text
reasonCode = Text
pReasonCode_
}
statusReason_description :: Lens.Lens' StatusReason (Prelude.Maybe Prelude.Text)
statusReason_description :: (Maybe Text -> f (Maybe Text)) -> StatusReason -> f StatusReason
statusReason_description = (StatusReason -> Maybe Text)
-> (StatusReason -> Maybe Text -> StatusReason)
-> Lens StatusReason StatusReason (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatusReason' {Maybe Text
description :: Maybe Text
$sel:description:StatusReason' :: StatusReason -> Maybe Text
description} -> Maybe Text
description) (\s :: StatusReason
s@StatusReason' {} Maybe Text
a -> StatusReason
s {$sel:description:StatusReason' :: Maybe Text
description = Maybe Text
a} :: StatusReason)
statusReason_reasonCode :: Lens.Lens' StatusReason Prelude.Text
statusReason_reasonCode :: (Text -> f Text) -> StatusReason -> f StatusReason
statusReason_reasonCode = (StatusReason -> Text)
-> (StatusReason -> Text -> StatusReason)
-> Lens StatusReason StatusReason Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatusReason' {Text
reasonCode :: Text
$sel:reasonCode:StatusReason' :: StatusReason -> Text
reasonCode} -> Text
reasonCode) (\s :: StatusReason
s@StatusReason' {} Text
a -> StatusReason
s {$sel:reasonCode:StatusReason' :: Text
reasonCode = Text
a} :: StatusReason)
instance Core.FromJSON StatusReason where
parseJSON :: Value -> Parser StatusReason
parseJSON =
String
-> (Object -> Parser StatusReason) -> Value -> Parser StatusReason
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"StatusReason"
( \Object
x ->
Maybe Text -> Text -> StatusReason
StatusReason'
(Maybe Text -> Text -> StatusReason)
-> Parser (Maybe Text) -> Parser (Text -> StatusReason)
forall (f :: * -> *) a b. Functor 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
"Description")
Parser (Text -> StatusReason) -> Parser Text -> Parser StatusReason
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ReasonCode")
)
instance Prelude.Hashable StatusReason
instance Prelude.NFData StatusReason
instance Core.ToJSON StatusReason where
toJSON :: StatusReason -> Value
toJSON StatusReason' {Maybe Text
Text
reasonCode :: Text
description :: Maybe Text
$sel:reasonCode:StatusReason' :: StatusReason -> Text
$sel:description:StatusReason' :: StatusReason -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Description" 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
description,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ReasonCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
reasonCode)
]
)