{-# 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.WAFV2.Types.CustomResponse 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.WAFV2.Types.CustomHTTPHeader
data CustomResponse = CustomResponse'
{
CustomResponse -> Maybe Text
customResponseBodyKey :: Prelude.Maybe Prelude.Text,
:: Prelude.Maybe (Prelude.NonEmpty CustomHTTPHeader),
CustomResponse -> Natural
responseCode :: Prelude.Natural
}
deriving (CustomResponse -> CustomResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomResponse -> CustomResponse -> Bool
$c/= :: CustomResponse -> CustomResponse -> Bool
== :: CustomResponse -> CustomResponse -> Bool
$c== :: CustomResponse -> CustomResponse -> Bool
Prelude.Eq, ReadPrec [CustomResponse]
ReadPrec CustomResponse
Int -> ReadS CustomResponse
ReadS [CustomResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomResponse]
$creadListPrec :: ReadPrec [CustomResponse]
readPrec :: ReadPrec CustomResponse
$creadPrec :: ReadPrec CustomResponse
readList :: ReadS [CustomResponse]
$creadList :: ReadS [CustomResponse]
readsPrec :: Int -> ReadS CustomResponse
$creadsPrec :: Int -> ReadS CustomResponse
Prelude.Read, Int -> CustomResponse -> ShowS
[CustomResponse] -> ShowS
CustomResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomResponse] -> ShowS
$cshowList :: [CustomResponse] -> ShowS
show :: CustomResponse -> String
$cshow :: CustomResponse -> String
showsPrec :: Int -> CustomResponse -> ShowS
$cshowsPrec :: Int -> CustomResponse -> ShowS
Prelude.Show, forall x. Rep CustomResponse x -> CustomResponse
forall x. CustomResponse -> Rep CustomResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomResponse x -> CustomResponse
$cfrom :: forall x. CustomResponse -> Rep CustomResponse x
Prelude.Generic)
newCustomResponse ::
Prelude.Natural ->
CustomResponse
newCustomResponse :: Natural -> CustomResponse
newCustomResponse Natural
pResponseCode_ =
CustomResponse'
{ $sel:customResponseBodyKey:CustomResponse' :: Maybe Text
customResponseBodyKey =
forall a. Maybe a
Prelude.Nothing,
$sel:responseHeaders:CustomResponse' :: Maybe (NonEmpty CustomHTTPHeader)
responseHeaders = forall a. Maybe a
Prelude.Nothing,
$sel:responseCode:CustomResponse' :: Natural
responseCode = Natural
pResponseCode_
}
customResponse_customResponseBodyKey :: Lens.Lens' CustomResponse (Prelude.Maybe Prelude.Text)
customResponse_customResponseBodyKey :: Lens' CustomResponse (Maybe Text)
customResponse_customResponseBodyKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomResponse' {Maybe Text
customResponseBodyKey :: Maybe Text
$sel:customResponseBodyKey:CustomResponse' :: CustomResponse -> Maybe Text
customResponseBodyKey} -> Maybe Text
customResponseBodyKey) (\s :: CustomResponse
s@CustomResponse' {} Maybe Text
a -> CustomResponse
s {$sel:customResponseBodyKey:CustomResponse' :: Maybe Text
customResponseBodyKey = Maybe Text
a} :: CustomResponse)
customResponse_responseHeaders :: Lens.Lens' CustomResponse (Prelude.Maybe (Prelude.NonEmpty CustomHTTPHeader))
= forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomResponse' {Maybe (NonEmpty CustomHTTPHeader)
responseHeaders :: Maybe (NonEmpty CustomHTTPHeader)
$sel:responseHeaders:CustomResponse' :: CustomResponse -> Maybe (NonEmpty CustomHTTPHeader)
responseHeaders} -> Maybe (NonEmpty CustomHTTPHeader)
responseHeaders) (\s :: CustomResponse
s@CustomResponse' {} Maybe (NonEmpty CustomHTTPHeader)
a -> CustomResponse
s {$sel:responseHeaders:CustomResponse' :: Maybe (NonEmpty CustomHTTPHeader)
responseHeaders = Maybe (NonEmpty CustomHTTPHeader)
a} :: CustomResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
customResponse_responseCode :: Lens.Lens' CustomResponse Prelude.Natural
customResponse_responseCode :: Lens' CustomResponse Natural
customResponse_responseCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomResponse' {Natural
responseCode :: Natural
$sel:responseCode:CustomResponse' :: CustomResponse -> Natural
responseCode} -> Natural
responseCode) (\s :: CustomResponse
s@CustomResponse' {} Natural
a -> CustomResponse
s {$sel:responseCode:CustomResponse' :: Natural
responseCode = Natural
a} :: CustomResponse)
instance Data.FromJSON CustomResponse where
parseJSON :: Value -> Parser CustomResponse
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"CustomResponse"
( \Object
x ->
Maybe Text
-> Maybe (NonEmpty CustomHTTPHeader) -> Natural -> CustomResponse
CustomResponse'
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
"CustomResponseBodyKey")
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
"ResponseHeaders")
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
"ResponseCode")
)
instance Prelude.Hashable CustomResponse where
hashWithSalt :: Int -> CustomResponse -> Int
hashWithSalt Int
_salt CustomResponse' {Natural
Maybe (NonEmpty CustomHTTPHeader)
Maybe Text
responseCode :: Natural
responseHeaders :: Maybe (NonEmpty CustomHTTPHeader)
customResponseBodyKey :: Maybe Text
$sel:responseCode:CustomResponse' :: CustomResponse -> Natural
$sel:responseHeaders:CustomResponse' :: CustomResponse -> Maybe (NonEmpty CustomHTTPHeader)
$sel:customResponseBodyKey:CustomResponse' :: CustomResponse -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
customResponseBodyKey
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty CustomHTTPHeader)
responseHeaders
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
responseCode
instance Prelude.NFData CustomResponse where
rnf :: CustomResponse -> ()
rnf CustomResponse' {Natural
Maybe (NonEmpty CustomHTTPHeader)
Maybe Text
responseCode :: Natural
responseHeaders :: Maybe (NonEmpty CustomHTTPHeader)
customResponseBodyKey :: Maybe Text
$sel:responseCode:CustomResponse' :: CustomResponse -> Natural
$sel:responseHeaders:CustomResponse' :: CustomResponse -> Maybe (NonEmpty CustomHTTPHeader)
$sel:customResponseBodyKey:CustomResponse' :: CustomResponse -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
customResponseBodyKey
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty CustomHTTPHeader)
responseHeaders
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
responseCode
instance Data.ToJSON CustomResponse where
toJSON :: CustomResponse -> Value
toJSON CustomResponse' {Natural
Maybe (NonEmpty CustomHTTPHeader)
Maybe Text
responseCode :: Natural
responseHeaders :: Maybe (NonEmpty CustomHTTPHeader)
customResponseBodyKey :: Maybe Text
$sel:responseCode:CustomResponse' :: CustomResponse -> Natural
$sel:responseHeaders:CustomResponse' :: CustomResponse -> Maybe (NonEmpty CustomHTTPHeader)
$sel:customResponseBodyKey:CustomResponse' :: CustomResponse -> Maybe Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"CustomResponseBodyKey" 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 Text
customResponseBodyKey,
(Key
"ResponseHeaders" 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 (NonEmpty CustomHTTPHeader)
responseHeaders,
forall a. a -> Maybe a
Prelude.Just (Key
"ResponseCode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
responseCode)
]
)