{-# 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.SQS.Types.Message where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SQS.Types.MessageAttribute
import Amazonka.SQS.Types.MessageAttributeValue
data Message = Message'
{
Message -> Maybe (HashMap Text MessageAttributeValue)
messageAttributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text MessageAttributeValue),
Message -> Maybe Text
mD5OfBody :: Prelude.Maybe Prelude.Text,
Message -> Maybe Text
body :: Prelude.Maybe Prelude.Text,
Message -> Maybe (HashMap MessageAttribute Text)
attributes :: Prelude.Maybe (Prelude.HashMap MessageAttribute Prelude.Text),
Message -> Maybe Text
receiptHandle :: Prelude.Maybe Prelude.Text,
Message -> Maybe Text
messageId :: Prelude.Maybe Prelude.Text,
Message -> Maybe Text
mD5OfMessageAttributes :: Prelude.Maybe Prelude.Text
}
deriving (Message -> Message -> Bool
(Message -> Message -> Bool)
-> (Message -> Message -> Bool) -> Eq Message
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Message -> Message -> Bool
$c/= :: Message -> Message -> Bool
== :: Message -> Message -> Bool
$c== :: Message -> Message -> Bool
Prelude.Eq, ReadPrec [Message]
ReadPrec Message
Int -> ReadS Message
ReadS [Message]
(Int -> ReadS Message)
-> ReadS [Message]
-> ReadPrec Message
-> ReadPrec [Message]
-> Read Message
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Message]
$creadListPrec :: ReadPrec [Message]
readPrec :: ReadPrec Message
$creadPrec :: ReadPrec Message
readList :: ReadS [Message]
$creadList :: ReadS [Message]
readsPrec :: Int -> ReadS Message
$creadsPrec :: Int -> ReadS Message
Prelude.Read, Int -> Message -> ShowS
[Message] -> ShowS
Message -> String
(Int -> Message -> ShowS)
-> (Message -> String) -> ([Message] -> ShowS) -> Show Message
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Message] -> ShowS
$cshowList :: [Message] -> ShowS
show :: Message -> String
$cshow :: Message -> String
showsPrec :: Int -> Message -> ShowS
$cshowsPrec :: Int -> Message -> ShowS
Prelude.Show, (forall x. Message -> Rep Message x)
-> (forall x. Rep Message x -> Message) -> Generic Message
forall x. Rep Message x -> Message
forall x. Message -> Rep Message x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Message x -> Message
$cfrom :: forall x. Message -> Rep Message x
Prelude.Generic)
newMessage ::
Message
newMessage :: Message
newMessage =
Message' :: Maybe (HashMap Text MessageAttributeValue)
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap MessageAttribute Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Message
Message'
{ $sel:messageAttributes:Message' :: Maybe (HashMap Text MessageAttributeValue)
messageAttributes = Maybe (HashMap Text MessageAttributeValue)
forall a. Maybe a
Prelude.Nothing,
$sel:mD5OfBody:Message' :: Maybe Text
mD5OfBody = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:body:Message' :: Maybe Text
body = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:attributes:Message' :: Maybe (HashMap MessageAttribute Text)
attributes = Maybe (HashMap MessageAttribute Text)
forall a. Maybe a
Prelude.Nothing,
$sel:receiptHandle:Message' :: Maybe Text
receiptHandle = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:messageId:Message' :: Maybe Text
messageId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:mD5OfMessageAttributes:Message' :: Maybe Text
mD5OfMessageAttributes = Maybe Text
forall a. Maybe a
Prelude.Nothing
}
message_messageAttributes :: Lens.Lens' Message (Prelude.Maybe (Prelude.HashMap Prelude.Text MessageAttributeValue))
message_messageAttributes :: (Maybe (HashMap Text MessageAttributeValue)
-> f (Maybe (HashMap Text MessageAttributeValue)))
-> Message -> f Message
message_messageAttributes = (Message -> Maybe (HashMap Text MessageAttributeValue))
-> (Message
-> Maybe (HashMap Text MessageAttributeValue) -> Message)
-> Lens
Message
Message
(Maybe (HashMap Text MessageAttributeValue))
(Maybe (HashMap Text MessageAttributeValue))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe (HashMap Text MessageAttributeValue)
messageAttributes :: Maybe (HashMap Text MessageAttributeValue)
$sel:messageAttributes:Message' :: Message -> Maybe (HashMap Text MessageAttributeValue)
messageAttributes} -> Maybe (HashMap Text MessageAttributeValue)
messageAttributes) (\s :: Message
s@Message' {} Maybe (HashMap Text MessageAttributeValue)
a -> Message
s {$sel:messageAttributes:Message' :: Maybe (HashMap Text MessageAttributeValue)
messageAttributes = Maybe (HashMap Text MessageAttributeValue)
a} :: Message) ((Maybe (HashMap Text MessageAttributeValue)
-> f (Maybe (HashMap Text MessageAttributeValue)))
-> Message -> f Message)
-> ((Maybe (HashMap Text MessageAttributeValue)
-> f (Maybe (HashMap Text MessageAttributeValue)))
-> Maybe (HashMap Text MessageAttributeValue)
-> f (Maybe (HashMap Text MessageAttributeValue)))
-> (Maybe (HashMap Text MessageAttributeValue)
-> f (Maybe (HashMap Text MessageAttributeValue)))
-> Message
-> f Message
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text MessageAttributeValue)
(HashMap Text MessageAttributeValue)
(HashMap Text MessageAttributeValue)
(HashMap Text MessageAttributeValue)
-> Iso
(Maybe (HashMap Text MessageAttributeValue))
(Maybe (HashMap Text MessageAttributeValue))
(Maybe (HashMap Text MessageAttributeValue))
(Maybe (HashMap Text MessageAttributeValue))
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
(HashMap Text MessageAttributeValue)
(HashMap Text MessageAttributeValue)
(HashMap Text MessageAttributeValue)
(HashMap Text MessageAttributeValue)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
message_mD5OfBody :: Lens.Lens' Message (Prelude.Maybe Prelude.Text)
message_mD5OfBody :: (Maybe Text -> f (Maybe Text)) -> Message -> f Message
message_mD5OfBody = (Message -> Maybe Text)
-> (Message -> Maybe Text -> Message)
-> Lens Message Message (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Text
mD5OfBody :: Maybe Text
$sel:mD5OfBody:Message' :: Message -> Maybe Text
mD5OfBody} -> Maybe Text
mD5OfBody) (\s :: Message
s@Message' {} Maybe Text
a -> Message
s {$sel:mD5OfBody:Message' :: Maybe Text
mD5OfBody = Maybe Text
a} :: Message)
message_body :: Lens.Lens' Message (Prelude.Maybe Prelude.Text)
message_body :: (Maybe Text -> f (Maybe Text)) -> Message -> f Message
message_body = (Message -> Maybe Text)
-> (Message -> Maybe Text -> Message)
-> Lens Message Message (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Text
body :: Maybe Text
$sel:body:Message' :: Message -> Maybe Text
body} -> Maybe Text
body) (\s :: Message
s@Message' {} Maybe Text
a -> Message
s {$sel:body:Message' :: Maybe Text
body = Maybe Text
a} :: Message)
message_attributes :: Lens.Lens' Message (Prelude.Maybe (Prelude.HashMap MessageAttribute Prelude.Text))
message_attributes :: (Maybe (HashMap MessageAttribute Text)
-> f (Maybe (HashMap MessageAttribute Text)))
-> Message -> f Message
message_attributes = (Message -> Maybe (HashMap MessageAttribute Text))
-> (Message -> Maybe (HashMap MessageAttribute Text) -> Message)
-> Lens
Message
Message
(Maybe (HashMap MessageAttribute Text))
(Maybe (HashMap MessageAttribute Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe (HashMap MessageAttribute Text)
attributes :: Maybe (HashMap MessageAttribute Text)
$sel:attributes:Message' :: Message -> Maybe (HashMap MessageAttribute Text)
attributes} -> Maybe (HashMap MessageAttribute Text)
attributes) (\s :: Message
s@Message' {} Maybe (HashMap MessageAttribute Text)
a -> Message
s {$sel:attributes:Message' :: Maybe (HashMap MessageAttribute Text)
attributes = Maybe (HashMap MessageAttribute Text)
a} :: Message) ((Maybe (HashMap MessageAttribute Text)
-> f (Maybe (HashMap MessageAttribute Text)))
-> Message -> f Message)
-> ((Maybe (HashMap MessageAttribute Text)
-> f (Maybe (HashMap MessageAttribute Text)))
-> Maybe (HashMap MessageAttribute Text)
-> f (Maybe (HashMap MessageAttribute Text)))
-> (Maybe (HashMap MessageAttribute Text)
-> f (Maybe (HashMap MessageAttribute Text)))
-> Message
-> f Message
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap MessageAttribute Text)
(HashMap MessageAttribute Text)
(HashMap MessageAttribute Text)
(HashMap MessageAttribute Text)
-> Iso
(Maybe (HashMap MessageAttribute Text))
(Maybe (HashMap MessageAttribute Text))
(Maybe (HashMap MessageAttribute Text))
(Maybe (HashMap MessageAttribute Text))
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
(HashMap MessageAttribute Text)
(HashMap MessageAttribute Text)
(HashMap MessageAttribute Text)
(HashMap MessageAttribute Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
message_receiptHandle :: Lens.Lens' Message (Prelude.Maybe Prelude.Text)
message_receiptHandle :: (Maybe Text -> f (Maybe Text)) -> Message -> f Message
message_receiptHandle = (Message -> Maybe Text)
-> (Message -> Maybe Text -> Message)
-> Lens Message Message (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Text
receiptHandle :: Maybe Text
$sel:receiptHandle:Message' :: Message -> Maybe Text
receiptHandle} -> Maybe Text
receiptHandle) (\s :: Message
s@Message' {} Maybe Text
a -> Message
s {$sel:receiptHandle:Message' :: Maybe Text
receiptHandle = Maybe Text
a} :: Message)
message_messageId :: Lens.Lens' Message (Prelude.Maybe Prelude.Text)
message_messageId :: (Maybe Text -> f (Maybe Text)) -> Message -> f Message
message_messageId = (Message -> Maybe Text)
-> (Message -> Maybe Text -> Message)
-> Lens Message Message (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Text
messageId :: Maybe Text
$sel:messageId:Message' :: Message -> Maybe Text
messageId} -> Maybe Text
messageId) (\s :: Message
s@Message' {} Maybe Text
a -> Message
s {$sel:messageId:Message' :: Maybe Text
messageId = Maybe Text
a} :: Message)
message_mD5OfMessageAttributes :: Lens.Lens' Message (Prelude.Maybe Prelude.Text)
message_mD5OfMessageAttributes :: (Maybe Text -> f (Maybe Text)) -> Message -> f Message
message_mD5OfMessageAttributes = (Message -> Maybe Text)
-> (Message -> Maybe Text -> Message)
-> Lens Message Message (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Text
mD5OfMessageAttributes :: Maybe Text
$sel:mD5OfMessageAttributes:Message' :: Message -> Maybe Text
mD5OfMessageAttributes} -> Maybe Text
mD5OfMessageAttributes) (\s :: Message
s@Message' {} Maybe Text
a -> Message
s {$sel:mD5OfMessageAttributes:Message' :: Maybe Text
mD5OfMessageAttributes = Maybe Text
a} :: Message)
instance Core.FromXML Message where
parseXML :: [Node] -> Either String Message
parseXML [Node]
x =
Maybe (HashMap Text MessageAttributeValue)
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap MessageAttribute Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Message
Message'
(Maybe (HashMap Text MessageAttributeValue)
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap MessageAttribute Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Message)
-> Either String (Maybe (HashMap Text MessageAttributeValue))
-> Either
String
(Maybe Text
-> Maybe Text
-> Maybe (HashMap MessageAttribute Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Message)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( ([Node] -> Either String (HashMap Text MessageAttributeValue))
-> [Node]
-> Either String (Maybe (HashMap Text MessageAttributeValue))
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may
(Text
-> Text
-> Text
-> [Node]
-> Either String (HashMap Text MessageAttributeValue)
forall k v.
(Eq k, Hashable k, FromText k, FromXML v) =>
Text -> Text -> Text -> [Node] -> Either String (HashMap k v)
Core.parseXMLMap Text
"MessageAttribute" Text
"Name" Text
"Value")
[Node]
x
)
Either
String
(Maybe Text
-> Maybe Text
-> Maybe (HashMap MessageAttribute Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Message)
-> Either String (Maybe Text)
-> Either
String
(Maybe Text
-> Maybe (HashMap MessageAttribute Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Message)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MD5OfBody")
Either
String
(Maybe Text
-> Maybe (HashMap MessageAttribute Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Message)
-> Either String (Maybe Text)
-> Either
String
(Maybe (HashMap MessageAttribute Text)
-> Maybe Text -> Maybe Text -> Maybe Text -> Message)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Body")
Either
String
(Maybe (HashMap MessageAttribute Text)
-> Maybe Text -> Maybe Text -> Maybe Text -> Message)
-> Either String (Maybe (HashMap MessageAttribute Text))
-> Either
String (Maybe Text -> Maybe Text -> Maybe Text -> Message)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( ([Node] -> Either String (HashMap MessageAttribute Text))
-> [Node] -> Either String (Maybe (HashMap MessageAttribute Text))
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may
(Text
-> Text
-> Text
-> [Node]
-> Either String (HashMap MessageAttribute Text)
forall k v.
(Eq k, Hashable k, FromText k, FromXML v) =>
Text -> Text -> Text -> [Node] -> Either String (HashMap k v)
Core.parseXMLMap Text
"Attribute" Text
"Name" Text
"Value")
[Node]
x
)
Either String (Maybe Text -> Maybe Text -> Maybe Text -> Message)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Maybe Text -> Message)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ReceiptHandle")
Either String (Maybe Text -> Maybe Text -> Message)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Message)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MessageId")
Either String (Maybe Text -> Message)
-> Either String (Maybe Text) -> Either String Message
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MD5OfMessageAttributes")
instance Prelude.Hashable Message
instance Prelude.NFData Message