{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.SNS.Subscribe
(
Subscribe (..),
newSubscribe,
subscribe_returnSubscriptionArn,
subscribe_attributes,
subscribe_endpoint,
subscribe_topicArn,
subscribe_protocol,
SubscribeResponse (..),
newSubscribeResponse,
subscribeResponse_subscriptionArn,
subscribeResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SNS.Types
data Subscribe = Subscribe'
{
Subscribe -> Maybe Bool
returnSubscriptionArn :: Prelude.Maybe Prelude.Bool,
Subscribe -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
Subscribe -> Maybe Text
endpoint :: Prelude.Maybe Prelude.Text,
Subscribe -> Text
topicArn :: Prelude.Text,
Subscribe -> Text
protocol :: Prelude.Text
}
deriving (Subscribe -> Subscribe -> Bool
(Subscribe -> Subscribe -> Bool)
-> (Subscribe -> Subscribe -> Bool) -> Eq Subscribe
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Subscribe -> Subscribe -> Bool
$c/= :: Subscribe -> Subscribe -> Bool
== :: Subscribe -> Subscribe -> Bool
$c== :: Subscribe -> Subscribe -> Bool
Prelude.Eq, ReadPrec [Subscribe]
ReadPrec Subscribe
Int -> ReadS Subscribe
ReadS [Subscribe]
(Int -> ReadS Subscribe)
-> ReadS [Subscribe]
-> ReadPrec Subscribe
-> ReadPrec [Subscribe]
-> Read Subscribe
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Subscribe]
$creadListPrec :: ReadPrec [Subscribe]
readPrec :: ReadPrec Subscribe
$creadPrec :: ReadPrec Subscribe
readList :: ReadS [Subscribe]
$creadList :: ReadS [Subscribe]
readsPrec :: Int -> ReadS Subscribe
$creadsPrec :: Int -> ReadS Subscribe
Prelude.Read, Int -> Subscribe -> ShowS
[Subscribe] -> ShowS
Subscribe -> String
(Int -> Subscribe -> ShowS)
-> (Subscribe -> String)
-> ([Subscribe] -> ShowS)
-> Show Subscribe
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Subscribe] -> ShowS
$cshowList :: [Subscribe] -> ShowS
show :: Subscribe -> String
$cshow :: Subscribe -> String
showsPrec :: Int -> Subscribe -> ShowS
$cshowsPrec :: Int -> Subscribe -> ShowS
Prelude.Show, (forall x. Subscribe -> Rep Subscribe x)
-> (forall x. Rep Subscribe x -> Subscribe) -> Generic Subscribe
forall x. Rep Subscribe x -> Subscribe
forall x. Subscribe -> Rep Subscribe x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Subscribe x -> Subscribe
$cfrom :: forall x. Subscribe -> Rep Subscribe x
Prelude.Generic)
newSubscribe ::
Prelude.Text ->
Prelude.Text ->
Subscribe
newSubscribe :: Text -> Text -> Subscribe
newSubscribe Text
pTopicArn_ Text
pProtocol_ =
Subscribe' :: Maybe Bool
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Text
-> Text
-> Subscribe
Subscribe'
{ $sel:returnSubscriptionArn:Subscribe' :: Maybe Bool
returnSubscriptionArn = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:attributes:Subscribe' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:endpoint:Subscribe' :: Maybe Text
endpoint = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:topicArn:Subscribe' :: Text
topicArn = Text
pTopicArn_,
$sel:protocol:Subscribe' :: Text
protocol = Text
pProtocol_
}
subscribe_returnSubscriptionArn :: Lens.Lens' Subscribe (Prelude.Maybe Prelude.Bool)
subscribe_returnSubscriptionArn :: (Maybe Bool -> f (Maybe Bool)) -> Subscribe -> f Subscribe
subscribe_returnSubscriptionArn = (Subscribe -> Maybe Bool)
-> (Subscribe -> Maybe Bool -> Subscribe)
-> Lens Subscribe Subscribe (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscribe' {Maybe Bool
returnSubscriptionArn :: Maybe Bool
$sel:returnSubscriptionArn:Subscribe' :: Subscribe -> Maybe Bool
returnSubscriptionArn} -> Maybe Bool
returnSubscriptionArn) (\s :: Subscribe
s@Subscribe' {} Maybe Bool
a -> Subscribe
s {$sel:returnSubscriptionArn:Subscribe' :: Maybe Bool
returnSubscriptionArn = Maybe Bool
a} :: Subscribe)
subscribe_attributes :: Lens.Lens' Subscribe (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
subscribe_attributes :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Subscribe -> f Subscribe
subscribe_attributes = (Subscribe -> Maybe (HashMap Text Text))
-> (Subscribe -> Maybe (HashMap Text Text) -> Subscribe)
-> Lens
Subscribe
Subscribe
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscribe' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:Subscribe' :: Subscribe -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: Subscribe
s@Subscribe' {} Maybe (HashMap Text Text)
a -> Subscribe
s {$sel:attributes:Subscribe' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: Subscribe) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Subscribe -> f Subscribe)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Subscribe
-> f Subscribe
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text 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 Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
subscribe_endpoint :: Lens.Lens' Subscribe (Prelude.Maybe Prelude.Text)
subscribe_endpoint :: (Maybe Text -> f (Maybe Text)) -> Subscribe -> f Subscribe
subscribe_endpoint = (Subscribe -> Maybe Text)
-> (Subscribe -> Maybe Text -> Subscribe)
-> Lens Subscribe Subscribe (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscribe' {Maybe Text
endpoint :: Maybe Text
$sel:endpoint:Subscribe' :: Subscribe -> Maybe Text
endpoint} -> Maybe Text
endpoint) (\s :: Subscribe
s@Subscribe' {} Maybe Text
a -> Subscribe
s {$sel:endpoint:Subscribe' :: Maybe Text
endpoint = Maybe Text
a} :: Subscribe)
subscribe_topicArn :: Lens.Lens' Subscribe Prelude.Text
subscribe_topicArn :: (Text -> f Text) -> Subscribe -> f Subscribe
subscribe_topicArn = (Subscribe -> Text)
-> (Subscribe -> Text -> Subscribe)
-> Lens Subscribe Subscribe Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscribe' {Text
topicArn :: Text
$sel:topicArn:Subscribe' :: Subscribe -> Text
topicArn} -> Text
topicArn) (\s :: Subscribe
s@Subscribe' {} Text
a -> Subscribe
s {$sel:topicArn:Subscribe' :: Text
topicArn = Text
a} :: Subscribe)
subscribe_protocol :: Lens.Lens' Subscribe Prelude.Text
subscribe_protocol :: (Text -> f Text) -> Subscribe -> f Subscribe
subscribe_protocol = (Subscribe -> Text)
-> (Subscribe -> Text -> Subscribe)
-> Lens Subscribe Subscribe Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscribe' {Text
protocol :: Text
$sel:protocol:Subscribe' :: Subscribe -> Text
protocol} -> Text
protocol) (\s :: Subscribe
s@Subscribe' {} Text
a -> Subscribe
s {$sel:protocol:Subscribe' :: Text
protocol = Text
a} :: Subscribe)
instance Core.AWSRequest Subscribe where
type AWSResponse Subscribe = SubscribeResponse
request :: Subscribe -> Request Subscribe
request = Service -> Subscribe -> Request Subscribe
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
response :: Logger
-> Service
-> Proxy Subscribe
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Subscribe)))
response =
Text
-> (Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse Subscribe))
-> Logger
-> Service
-> Proxy Subscribe
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Subscribe)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
-> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
Text
"SubscribeResult"
( \Int
s ResponseHeaders
h [Node]
x ->
Maybe Text -> Int -> SubscribeResponse
SubscribeResponse'
(Maybe Text -> Int -> SubscribeResponse)
-> Either String (Maybe Text)
-> Either String (Int -> SubscribeResponse)
forall (f :: * -> *) a b. Functor 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
"SubscriptionArn")
Either String (Int -> SubscribeResponse)
-> Either String Int -> Either String SubscribeResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable Subscribe
instance Prelude.NFData Subscribe
instance Core.ToHeaders Subscribe where
toHeaders :: Subscribe -> ResponseHeaders
toHeaders = ResponseHeaders -> Subscribe -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath Subscribe where
toPath :: Subscribe -> ByteString
toPath = ByteString -> Subscribe -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery Subscribe where
toQuery :: Subscribe -> QueryString
toQuery Subscribe' {Maybe Bool
Maybe Text
Maybe (HashMap Text Text)
Text
protocol :: Text
topicArn :: Text
endpoint :: Maybe Text
attributes :: Maybe (HashMap Text Text)
returnSubscriptionArn :: Maybe Bool
$sel:protocol:Subscribe' :: Subscribe -> Text
$sel:topicArn:Subscribe' :: Subscribe -> Text
$sel:endpoint:Subscribe' :: Subscribe -> Maybe Text
$sel:attributes:Subscribe' :: Subscribe -> Maybe (HashMap Text Text)
$sel:returnSubscriptionArn:Subscribe' :: Subscribe -> Maybe Bool
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"Action"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"Subscribe" :: Prelude.ByteString),
ByteString
"Version"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
ByteString
"ReturnSubscriptionArn"
ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
returnSubscriptionArn,
ByteString
"Attributes"
ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
( ByteString
-> ByteString -> ByteString -> HashMap Text Text -> QueryString
forall k v.
(ToQuery k, ToQuery v) =>
ByteString
-> ByteString -> ByteString -> HashMap k v -> QueryString
Core.toQueryMap ByteString
"entry" ByteString
"key" ByteString
"value"
(HashMap Text Text -> QueryString)
-> Maybe (HashMap Text Text) -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
attributes
),
ByteString
"Endpoint" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
endpoint,
ByteString
"TopicArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
topicArn,
ByteString
"Protocol" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
protocol
]
data SubscribeResponse = SubscribeResponse'
{
SubscribeResponse -> Maybe Text
subscriptionArn :: Prelude.Maybe Prelude.Text,
SubscribeResponse -> Int
httpStatus :: Prelude.Int
}
deriving (SubscribeResponse -> SubscribeResponse -> Bool
(SubscribeResponse -> SubscribeResponse -> Bool)
-> (SubscribeResponse -> SubscribeResponse -> Bool)
-> Eq SubscribeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubscribeResponse -> SubscribeResponse -> Bool
$c/= :: SubscribeResponse -> SubscribeResponse -> Bool
== :: SubscribeResponse -> SubscribeResponse -> Bool
$c== :: SubscribeResponse -> SubscribeResponse -> Bool
Prelude.Eq, ReadPrec [SubscribeResponse]
ReadPrec SubscribeResponse
Int -> ReadS SubscribeResponse
ReadS [SubscribeResponse]
(Int -> ReadS SubscribeResponse)
-> ReadS [SubscribeResponse]
-> ReadPrec SubscribeResponse
-> ReadPrec [SubscribeResponse]
-> Read SubscribeResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SubscribeResponse]
$creadListPrec :: ReadPrec [SubscribeResponse]
readPrec :: ReadPrec SubscribeResponse
$creadPrec :: ReadPrec SubscribeResponse
readList :: ReadS [SubscribeResponse]
$creadList :: ReadS [SubscribeResponse]
readsPrec :: Int -> ReadS SubscribeResponse
$creadsPrec :: Int -> ReadS SubscribeResponse
Prelude.Read, Int -> SubscribeResponse -> ShowS
[SubscribeResponse] -> ShowS
SubscribeResponse -> String
(Int -> SubscribeResponse -> ShowS)
-> (SubscribeResponse -> String)
-> ([SubscribeResponse] -> ShowS)
-> Show SubscribeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubscribeResponse] -> ShowS
$cshowList :: [SubscribeResponse] -> ShowS
show :: SubscribeResponse -> String
$cshow :: SubscribeResponse -> String
showsPrec :: Int -> SubscribeResponse -> ShowS
$cshowsPrec :: Int -> SubscribeResponse -> ShowS
Prelude.Show, (forall x. SubscribeResponse -> Rep SubscribeResponse x)
-> (forall x. Rep SubscribeResponse x -> SubscribeResponse)
-> Generic SubscribeResponse
forall x. Rep SubscribeResponse x -> SubscribeResponse
forall x. SubscribeResponse -> Rep SubscribeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SubscribeResponse x -> SubscribeResponse
$cfrom :: forall x. SubscribeResponse -> Rep SubscribeResponse x
Prelude.Generic)
newSubscribeResponse ::
Prelude.Int ->
SubscribeResponse
newSubscribeResponse :: Int -> SubscribeResponse
newSubscribeResponse Int
pHttpStatus_ =
SubscribeResponse' :: Maybe Text -> Int -> SubscribeResponse
SubscribeResponse'
{ $sel:subscriptionArn:SubscribeResponse' :: Maybe Text
subscriptionArn =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:SubscribeResponse' :: Int
httpStatus = Int
pHttpStatus_
}
subscribeResponse_subscriptionArn :: Lens.Lens' SubscribeResponse (Prelude.Maybe Prelude.Text)
subscribeResponse_subscriptionArn :: (Maybe Text -> f (Maybe Text))
-> SubscribeResponse -> f SubscribeResponse
subscribeResponse_subscriptionArn = (SubscribeResponse -> Maybe Text)
-> (SubscribeResponse -> Maybe Text -> SubscribeResponse)
-> Lens
SubscribeResponse SubscribeResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubscribeResponse' {Maybe Text
subscriptionArn :: Maybe Text
$sel:subscriptionArn:SubscribeResponse' :: SubscribeResponse -> Maybe Text
subscriptionArn} -> Maybe Text
subscriptionArn) (\s :: SubscribeResponse
s@SubscribeResponse' {} Maybe Text
a -> SubscribeResponse
s {$sel:subscriptionArn:SubscribeResponse' :: Maybe Text
subscriptionArn = Maybe Text
a} :: SubscribeResponse)
subscribeResponse_httpStatus :: Lens.Lens' SubscribeResponse Prelude.Int
subscribeResponse_httpStatus :: (Int -> f Int) -> SubscribeResponse -> f SubscribeResponse
subscribeResponse_httpStatus = (SubscribeResponse -> Int)
-> (SubscribeResponse -> Int -> SubscribeResponse)
-> Lens SubscribeResponse SubscribeResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubscribeResponse' {Int
httpStatus :: Int
$sel:httpStatus:SubscribeResponse' :: SubscribeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SubscribeResponse
s@SubscribeResponse' {} Int
a -> SubscribeResponse
s {$sel:httpStatus:SubscribeResponse' :: Int
httpStatus = Int
a} :: SubscribeResponse)
instance Prelude.NFData SubscribeResponse