{-# 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.WAFRegional.Types.HTTPRequest where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAFRegional.Types.HTTPHeader
data HTTPRequest = HTTPRequest'
{
HTTPRequest -> Maybe Text
hTTPVersion :: Prelude.Maybe Prelude.Text,
HTTPRequest -> Maybe Text
country :: Prelude.Maybe Prelude.Text,
HTTPRequest -> Maybe Text
uri :: Prelude.Maybe Prelude.Text,
:: Prelude.Maybe [HTTPHeader],
HTTPRequest -> Maybe Text
method :: Prelude.Maybe Prelude.Text,
HTTPRequest -> Maybe Text
clientIP :: Prelude.Maybe Prelude.Text
}
deriving (HTTPRequest -> HTTPRequest -> Bool
(HTTPRequest -> HTTPRequest -> Bool)
-> (HTTPRequest -> HTTPRequest -> Bool) -> Eq HTTPRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HTTPRequest -> HTTPRequest -> Bool
$c/= :: HTTPRequest -> HTTPRequest -> Bool
== :: HTTPRequest -> HTTPRequest -> Bool
$c== :: HTTPRequest -> HTTPRequest -> Bool
Prelude.Eq, ReadPrec [HTTPRequest]
ReadPrec HTTPRequest
Int -> ReadS HTTPRequest
ReadS [HTTPRequest]
(Int -> ReadS HTTPRequest)
-> ReadS [HTTPRequest]
-> ReadPrec HTTPRequest
-> ReadPrec [HTTPRequest]
-> Read HTTPRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HTTPRequest]
$creadListPrec :: ReadPrec [HTTPRequest]
readPrec :: ReadPrec HTTPRequest
$creadPrec :: ReadPrec HTTPRequest
readList :: ReadS [HTTPRequest]
$creadList :: ReadS [HTTPRequest]
readsPrec :: Int -> ReadS HTTPRequest
$creadsPrec :: Int -> ReadS HTTPRequest
Prelude.Read, Int -> HTTPRequest -> ShowS
[HTTPRequest] -> ShowS
HTTPRequest -> String
(Int -> HTTPRequest -> ShowS)
-> (HTTPRequest -> String)
-> ([HTTPRequest] -> ShowS)
-> Show HTTPRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HTTPRequest] -> ShowS
$cshowList :: [HTTPRequest] -> ShowS
show :: HTTPRequest -> String
$cshow :: HTTPRequest -> String
showsPrec :: Int -> HTTPRequest -> ShowS
$cshowsPrec :: Int -> HTTPRequest -> ShowS
Prelude.Show, (forall x. HTTPRequest -> Rep HTTPRequest x)
-> (forall x. Rep HTTPRequest x -> HTTPRequest)
-> Generic HTTPRequest
forall x. Rep HTTPRequest x -> HTTPRequest
forall x. HTTPRequest -> Rep HTTPRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HTTPRequest x -> HTTPRequest
$cfrom :: forall x. HTTPRequest -> Rep HTTPRequest x
Prelude.Generic)
newHTTPRequest ::
HTTPRequest
newHTTPRequest :: HTTPRequest
newHTTPRequest =
HTTPRequest' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [HTTPHeader]
-> Maybe Text
-> Maybe Text
-> HTTPRequest
HTTPRequest'
{ $sel:hTTPVersion:HTTPRequest' :: Maybe Text
hTTPVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:country:HTTPRequest' :: Maybe Text
country = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:uri:HTTPRequest' :: Maybe Text
uri = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:headers:HTTPRequest' :: Maybe [HTTPHeader]
headers = Maybe [HTTPHeader]
forall a. Maybe a
Prelude.Nothing,
$sel:method:HTTPRequest' :: Maybe Text
method = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:clientIP:HTTPRequest' :: Maybe Text
clientIP = Maybe Text
forall a. Maybe a
Prelude.Nothing
}
hTTPRequest_hTTPVersion :: Lens.Lens' HTTPRequest (Prelude.Maybe Prelude.Text)
hTTPRequest_hTTPVersion :: (Maybe Text -> f (Maybe Text)) -> HTTPRequest -> f HTTPRequest
hTTPRequest_hTTPVersion = (HTTPRequest -> Maybe Text)
-> (HTTPRequest -> Maybe Text -> HTTPRequest)
-> Lens HTTPRequest HTTPRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HTTPRequest' {Maybe Text
hTTPVersion :: Maybe Text
$sel:hTTPVersion:HTTPRequest' :: HTTPRequest -> Maybe Text
hTTPVersion} -> Maybe Text
hTTPVersion) (\s :: HTTPRequest
s@HTTPRequest' {} Maybe Text
a -> HTTPRequest
s {$sel:hTTPVersion:HTTPRequest' :: Maybe Text
hTTPVersion = Maybe Text
a} :: HTTPRequest)
hTTPRequest_country :: Lens.Lens' HTTPRequest (Prelude.Maybe Prelude.Text)
hTTPRequest_country :: (Maybe Text -> f (Maybe Text)) -> HTTPRequest -> f HTTPRequest
hTTPRequest_country = (HTTPRequest -> Maybe Text)
-> (HTTPRequest -> Maybe Text -> HTTPRequest)
-> Lens HTTPRequest HTTPRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HTTPRequest' {Maybe Text
country :: Maybe Text
$sel:country:HTTPRequest' :: HTTPRequest -> Maybe Text
country} -> Maybe Text
country) (\s :: HTTPRequest
s@HTTPRequest' {} Maybe Text
a -> HTTPRequest
s {$sel:country:HTTPRequest' :: Maybe Text
country = Maybe Text
a} :: HTTPRequest)
hTTPRequest_uri :: Lens.Lens' HTTPRequest (Prelude.Maybe Prelude.Text)
hTTPRequest_uri :: (Maybe Text -> f (Maybe Text)) -> HTTPRequest -> f HTTPRequest
hTTPRequest_uri = (HTTPRequest -> Maybe Text)
-> (HTTPRequest -> Maybe Text -> HTTPRequest)
-> Lens HTTPRequest HTTPRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HTTPRequest' {Maybe Text
uri :: Maybe Text
$sel:uri:HTTPRequest' :: HTTPRequest -> Maybe Text
uri} -> Maybe Text
uri) (\s :: HTTPRequest
s@HTTPRequest' {} Maybe Text
a -> HTTPRequest
s {$sel:uri:HTTPRequest' :: Maybe Text
uri = Maybe Text
a} :: HTTPRequest)
hTTPRequest_headers :: Lens.Lens' HTTPRequest (Prelude.Maybe [HTTPHeader])
= (HTTPRequest -> Maybe [HTTPHeader])
-> (HTTPRequest -> Maybe [HTTPHeader] -> HTTPRequest)
-> Lens
HTTPRequest HTTPRequest (Maybe [HTTPHeader]) (Maybe [HTTPHeader])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HTTPRequest' {Maybe [HTTPHeader]
headers :: Maybe [HTTPHeader]
$sel:headers:HTTPRequest' :: HTTPRequest -> Maybe [HTTPHeader]
headers} -> Maybe [HTTPHeader]
headers) (\s :: HTTPRequest
s@HTTPRequest' {} Maybe [HTTPHeader]
a -> HTTPRequest
s {$sel:headers:HTTPRequest' :: Maybe [HTTPHeader]
headers = Maybe [HTTPHeader]
a} :: HTTPRequest) ((Maybe [HTTPHeader] -> f (Maybe [HTTPHeader]))
-> HTTPRequest -> f HTTPRequest)
-> ((Maybe [HTTPHeader] -> f (Maybe [HTTPHeader]))
-> Maybe [HTTPHeader] -> f (Maybe [HTTPHeader]))
-> (Maybe [HTTPHeader] -> f (Maybe [HTTPHeader]))
-> HTTPRequest
-> f HTTPRequest
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [HTTPHeader] [HTTPHeader] [HTTPHeader] [HTTPHeader]
-> Iso
(Maybe [HTTPHeader])
(Maybe [HTTPHeader])
(Maybe [HTTPHeader])
(Maybe [HTTPHeader])
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 [HTTPHeader] [HTTPHeader] [HTTPHeader] [HTTPHeader]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
hTTPRequest_method :: Lens.Lens' HTTPRequest (Prelude.Maybe Prelude.Text)
hTTPRequest_method :: (Maybe Text -> f (Maybe Text)) -> HTTPRequest -> f HTTPRequest
hTTPRequest_method = (HTTPRequest -> Maybe Text)
-> (HTTPRequest -> Maybe Text -> HTTPRequest)
-> Lens HTTPRequest HTTPRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HTTPRequest' {Maybe Text
method :: Maybe Text
$sel:method:HTTPRequest' :: HTTPRequest -> Maybe Text
method} -> Maybe Text
method) (\s :: HTTPRequest
s@HTTPRequest' {} Maybe Text
a -> HTTPRequest
s {$sel:method:HTTPRequest' :: Maybe Text
method = Maybe Text
a} :: HTTPRequest)
hTTPRequest_clientIP :: Lens.Lens' HTTPRequest (Prelude.Maybe Prelude.Text)
hTTPRequest_clientIP :: (Maybe Text -> f (Maybe Text)) -> HTTPRequest -> f HTTPRequest
hTTPRequest_clientIP = (HTTPRequest -> Maybe Text)
-> (HTTPRequest -> Maybe Text -> HTTPRequest)
-> Lens HTTPRequest HTTPRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HTTPRequest' {Maybe Text
clientIP :: Maybe Text
$sel:clientIP:HTTPRequest' :: HTTPRequest -> Maybe Text
clientIP} -> Maybe Text
clientIP) (\s :: HTTPRequest
s@HTTPRequest' {} Maybe Text
a -> HTTPRequest
s {$sel:clientIP:HTTPRequest' :: Maybe Text
clientIP = Maybe Text
a} :: HTTPRequest)
instance Core.FromJSON HTTPRequest where
parseJSON :: Value -> Parser HTTPRequest
parseJSON =
String
-> (Object -> Parser HTTPRequest) -> Value -> Parser HTTPRequest
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"HTTPRequest"
( \Object
x ->
Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [HTTPHeader]
-> Maybe Text
-> Maybe Text
-> HTTPRequest
HTTPRequest'
(Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [HTTPHeader]
-> Maybe Text
-> Maybe Text
-> HTTPRequest)
-> Parser (Maybe Text)
-> Parser
(Maybe Text
-> Maybe Text
-> Maybe [HTTPHeader]
-> Maybe Text
-> Maybe Text
-> HTTPRequest)
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
"HTTPVersion")
Parser
(Maybe Text
-> Maybe Text
-> Maybe [HTTPHeader]
-> Maybe Text
-> Maybe Text
-> HTTPRequest)
-> Parser (Maybe Text)
-> Parser
(Maybe Text
-> Maybe [HTTPHeader] -> Maybe Text -> Maybe Text -> HTTPRequest)
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
"Country")
Parser
(Maybe Text
-> Maybe [HTTPHeader] -> Maybe Text -> Maybe Text -> HTTPRequest)
-> Parser (Maybe Text)
-> Parser
(Maybe [HTTPHeader] -> Maybe Text -> Maybe Text -> HTTPRequest)
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
"URI")
Parser
(Maybe [HTTPHeader] -> Maybe Text -> Maybe Text -> HTTPRequest)
-> Parser (Maybe [HTTPHeader])
-> Parser (Maybe Text -> Maybe Text -> HTTPRequest)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [HTTPHeader]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Headers" Parser (Maybe (Maybe [HTTPHeader]))
-> Maybe [HTTPHeader] -> Parser (Maybe [HTTPHeader])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [HTTPHeader]
forall a. Monoid a => a
Prelude.mempty)
Parser (Maybe Text -> Maybe Text -> HTTPRequest)
-> Parser (Maybe Text) -> Parser (Maybe Text -> HTTPRequest)
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
"Method")
Parser (Maybe Text -> HTTPRequest)
-> Parser (Maybe Text) -> Parser HTTPRequest
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
"ClientIP")
)
instance Prelude.Hashable HTTPRequest
instance Prelude.NFData HTTPRequest