{-# 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.IoT.Types.HttpAction where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types.HttpActionHeader
import Amazonka.IoT.Types.HttpAuthorization
import qualified Amazonka.Prelude as Prelude
data HttpAction = HttpAction'
{
HttpAction -> Maybe HttpAuthorization
auth :: Prelude.Maybe HttpAuthorization,
HttpAction -> Maybe Text
confirmationUrl :: Prelude.Maybe Prelude.Text,
:: Prelude.Maybe [HttpActionHeader],
HttpAction -> Text
url :: Prelude.Text
}
deriving (HttpAction -> HttpAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpAction -> HttpAction -> Bool
$c/= :: HttpAction -> HttpAction -> Bool
== :: HttpAction -> HttpAction -> Bool
$c== :: HttpAction -> HttpAction -> Bool
Prelude.Eq, ReadPrec [HttpAction]
ReadPrec HttpAction
Int -> ReadS HttpAction
ReadS [HttpAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HttpAction]
$creadListPrec :: ReadPrec [HttpAction]
readPrec :: ReadPrec HttpAction
$creadPrec :: ReadPrec HttpAction
readList :: ReadS [HttpAction]
$creadList :: ReadS [HttpAction]
readsPrec :: Int -> ReadS HttpAction
$creadsPrec :: Int -> ReadS HttpAction
Prelude.Read, Int -> HttpAction -> ShowS
[HttpAction] -> ShowS
HttpAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpAction] -> ShowS
$cshowList :: [HttpAction] -> ShowS
show :: HttpAction -> String
$cshow :: HttpAction -> String
showsPrec :: Int -> HttpAction -> ShowS
$cshowsPrec :: Int -> HttpAction -> ShowS
Prelude.Show, forall x. Rep HttpAction x -> HttpAction
forall x. HttpAction -> Rep HttpAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HttpAction x -> HttpAction
$cfrom :: forall x. HttpAction -> Rep HttpAction x
Prelude.Generic)
newHttpAction ::
Prelude.Text ->
HttpAction
newHttpAction :: Text -> HttpAction
newHttpAction Text
pUrl_ =
HttpAction'
{ $sel:auth:HttpAction' :: Maybe HttpAuthorization
auth = forall a. Maybe a
Prelude.Nothing,
$sel:confirmationUrl:HttpAction' :: Maybe Text
confirmationUrl = forall a. Maybe a
Prelude.Nothing,
$sel:headers:HttpAction' :: Maybe [HttpActionHeader]
headers = forall a. Maybe a
Prelude.Nothing,
$sel:url:HttpAction' :: Text
url = Text
pUrl_
}
httpAction_auth :: Lens.Lens' HttpAction (Prelude.Maybe HttpAuthorization)
httpAction_auth :: Lens' HttpAction (Maybe HttpAuthorization)
httpAction_auth = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpAction' {Maybe HttpAuthorization
auth :: Maybe HttpAuthorization
$sel:auth:HttpAction' :: HttpAction -> Maybe HttpAuthorization
auth} -> Maybe HttpAuthorization
auth) (\s :: HttpAction
s@HttpAction' {} Maybe HttpAuthorization
a -> HttpAction
s {$sel:auth:HttpAction' :: Maybe HttpAuthorization
auth = Maybe HttpAuthorization
a} :: HttpAction)
httpAction_confirmationUrl :: Lens.Lens' HttpAction (Prelude.Maybe Prelude.Text)
httpAction_confirmationUrl :: Lens' HttpAction (Maybe Text)
httpAction_confirmationUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpAction' {Maybe Text
confirmationUrl :: Maybe Text
$sel:confirmationUrl:HttpAction' :: HttpAction -> Maybe Text
confirmationUrl} -> Maybe Text
confirmationUrl) (\s :: HttpAction
s@HttpAction' {} Maybe Text
a -> HttpAction
s {$sel:confirmationUrl:HttpAction' :: Maybe Text
confirmationUrl = Maybe Text
a} :: HttpAction)
httpAction_headers :: Lens.Lens' HttpAction (Prelude.Maybe [HttpActionHeader])
= forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpAction' {Maybe [HttpActionHeader]
headers :: Maybe [HttpActionHeader]
$sel:headers:HttpAction' :: HttpAction -> Maybe [HttpActionHeader]
headers} -> Maybe [HttpActionHeader]
headers) (\s :: HttpAction
s@HttpAction' {} Maybe [HttpActionHeader]
a -> HttpAction
s {$sel:headers:HttpAction' :: Maybe [HttpActionHeader]
headers = Maybe [HttpActionHeader]
a} :: HttpAction) 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
httpAction_url :: Lens.Lens' HttpAction Prelude.Text
httpAction_url :: Lens' HttpAction Text
httpAction_url = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpAction' {Text
url :: Text
$sel:url:HttpAction' :: HttpAction -> Text
url} -> Text
url) (\s :: HttpAction
s@HttpAction' {} Text
a -> HttpAction
s {$sel:url:HttpAction' :: Text
url = Text
a} :: HttpAction)
instance Data.FromJSON HttpAction where
parseJSON :: Value -> Parser HttpAction
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"HttpAction"
( \Object
x ->
Maybe HttpAuthorization
-> Maybe Text -> Maybe [HttpActionHeader] -> Text -> HttpAction
HttpAction'
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
"auth")
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
"confirmationUrl")
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
"headers" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
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
"url")
)
instance Prelude.Hashable HttpAction where
hashWithSalt :: Int -> HttpAction -> Int
hashWithSalt Int
_salt HttpAction' {Maybe [HttpActionHeader]
Maybe Text
Maybe HttpAuthorization
Text
url :: Text
headers :: Maybe [HttpActionHeader]
confirmationUrl :: Maybe Text
auth :: Maybe HttpAuthorization
$sel:url:HttpAction' :: HttpAction -> Text
$sel:headers:HttpAction' :: HttpAction -> Maybe [HttpActionHeader]
$sel:confirmationUrl:HttpAction' :: HttpAction -> Maybe Text
$sel:auth:HttpAction' :: HttpAction -> Maybe HttpAuthorization
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe HttpAuthorization
auth
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
confirmationUrl
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [HttpActionHeader]
headers
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
url
instance Prelude.NFData HttpAction where
rnf :: HttpAction -> ()
rnf HttpAction' {Maybe [HttpActionHeader]
Maybe Text
Maybe HttpAuthorization
Text
url :: Text
headers :: Maybe [HttpActionHeader]
confirmationUrl :: Maybe Text
auth :: Maybe HttpAuthorization
$sel:url:HttpAction' :: HttpAction -> Text
$sel:headers:HttpAction' :: HttpAction -> Maybe [HttpActionHeader]
$sel:confirmationUrl:HttpAction' :: HttpAction -> Maybe Text
$sel:auth:HttpAction' :: HttpAction -> Maybe HttpAuthorization
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe HttpAuthorization
auth
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
confirmationUrl
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [HttpActionHeader]
headers
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
url
instance Data.ToJSON HttpAction where
toJSON :: HttpAction -> Value
toJSON HttpAction' {Maybe [HttpActionHeader]
Maybe Text
Maybe HttpAuthorization
Text
url :: Text
headers :: Maybe [HttpActionHeader]
confirmationUrl :: Maybe Text
auth :: Maybe HttpAuthorization
$sel:url:HttpAction' :: HttpAction -> Text
$sel:headers:HttpAction' :: HttpAction -> Maybe [HttpActionHeader]
$sel:confirmationUrl:HttpAction' :: HttpAction -> Maybe Text
$sel:auth:HttpAction' :: HttpAction -> Maybe HttpAuthorization
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"auth" 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 HttpAuthorization
auth,
(Key
"confirmationUrl" 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
confirmationUrl,
(Key
"headers" 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 [HttpActionHeader]
headers,
forall a. a -> Maybe a
Prelude.Just (Key
"url" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
url)
]
)