{-# 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.Shield.Types.ResponseAction 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
import Amazonka.Shield.Types.BlockAction
import Amazonka.Shield.Types.CountAction
data ResponseAction = ResponseAction'
{
ResponseAction -> Maybe BlockAction
block :: Prelude.Maybe BlockAction,
ResponseAction -> Maybe CountAction
count :: Prelude.Maybe CountAction
}
deriving (ResponseAction -> ResponseAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResponseAction -> ResponseAction -> Bool
$c/= :: ResponseAction -> ResponseAction -> Bool
== :: ResponseAction -> ResponseAction -> Bool
$c== :: ResponseAction -> ResponseAction -> Bool
Prelude.Eq, ReadPrec [ResponseAction]
ReadPrec ResponseAction
Int -> ReadS ResponseAction
ReadS [ResponseAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResponseAction]
$creadListPrec :: ReadPrec [ResponseAction]
readPrec :: ReadPrec ResponseAction
$creadPrec :: ReadPrec ResponseAction
readList :: ReadS [ResponseAction]
$creadList :: ReadS [ResponseAction]
readsPrec :: Int -> ReadS ResponseAction
$creadsPrec :: Int -> ReadS ResponseAction
Prelude.Read, Int -> ResponseAction -> ShowS
[ResponseAction] -> ShowS
ResponseAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResponseAction] -> ShowS
$cshowList :: [ResponseAction] -> ShowS
show :: ResponseAction -> String
$cshow :: ResponseAction -> String
showsPrec :: Int -> ResponseAction -> ShowS
$cshowsPrec :: Int -> ResponseAction -> ShowS
Prelude.Show, forall x. Rep ResponseAction x -> ResponseAction
forall x. ResponseAction -> Rep ResponseAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResponseAction x -> ResponseAction
$cfrom :: forall x. ResponseAction -> Rep ResponseAction x
Prelude.Generic)
newResponseAction ::
ResponseAction
newResponseAction :: ResponseAction
newResponseAction =
ResponseAction'
{ $sel:block:ResponseAction' :: Maybe BlockAction
block = forall a. Maybe a
Prelude.Nothing,
$sel:count:ResponseAction' :: Maybe CountAction
count = forall a. Maybe a
Prelude.Nothing
}
responseAction_block :: Lens.Lens' ResponseAction (Prelude.Maybe BlockAction)
responseAction_block :: Lens' ResponseAction (Maybe BlockAction)
responseAction_block = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseAction' {Maybe BlockAction
block :: Maybe BlockAction
$sel:block:ResponseAction' :: ResponseAction -> Maybe BlockAction
block} -> Maybe BlockAction
block) (\s :: ResponseAction
s@ResponseAction' {} Maybe BlockAction
a -> ResponseAction
s {$sel:block:ResponseAction' :: Maybe BlockAction
block = Maybe BlockAction
a} :: ResponseAction)
responseAction_count :: Lens.Lens' ResponseAction (Prelude.Maybe CountAction)
responseAction_count :: Lens' ResponseAction (Maybe CountAction)
responseAction_count = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseAction' {Maybe CountAction
count :: Maybe CountAction
$sel:count:ResponseAction' :: ResponseAction -> Maybe CountAction
count} -> Maybe CountAction
count) (\s :: ResponseAction
s@ResponseAction' {} Maybe CountAction
a -> ResponseAction
s {$sel:count:ResponseAction' :: Maybe CountAction
count = Maybe CountAction
a} :: ResponseAction)
instance Data.FromJSON ResponseAction where
parseJSON :: Value -> Parser ResponseAction
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"ResponseAction"
( \Object
x ->
Maybe BlockAction -> Maybe CountAction -> ResponseAction
ResponseAction'
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
"Block")
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
"Count")
)
instance Prelude.Hashable ResponseAction where
hashWithSalt :: Int -> ResponseAction -> Int
hashWithSalt Int
_salt ResponseAction' {Maybe BlockAction
Maybe CountAction
count :: Maybe CountAction
block :: Maybe BlockAction
$sel:count:ResponseAction' :: ResponseAction -> Maybe CountAction
$sel:block:ResponseAction' :: ResponseAction -> Maybe BlockAction
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BlockAction
block
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CountAction
count
instance Prelude.NFData ResponseAction where
rnf :: ResponseAction -> ()
rnf ResponseAction' {Maybe BlockAction
Maybe CountAction
count :: Maybe CountAction
block :: Maybe BlockAction
$sel:count:ResponseAction' :: ResponseAction -> Maybe CountAction
$sel:block:ResponseAction' :: ResponseAction -> Maybe BlockAction
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe BlockAction
block seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CountAction
count
instance Data.ToJSON ResponseAction where
toJSON :: ResponseAction -> Value
toJSON ResponseAction' {Maybe BlockAction
Maybe CountAction
count :: Maybe CountAction
block :: Maybe BlockAction
$sel:count:ResponseAction' :: ResponseAction -> Maybe CountAction
$sel:block:ResponseAction' :: ResponseAction -> Maybe BlockAction
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Block" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BlockAction
block,
(Key
"Count" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CountAction
count
]
)