{-# 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_attributes,
subscribe_endpoint,
subscribe_returnSubscriptionArn,
subscribe_topicArn,
subscribe_protocol,
SubscribeResponse (..),
newSubscribeResponse,
subscribeResponse_subscriptionArn,
subscribeResponse_httpStatus,
)
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SNS.Types
data Subscribe = Subscribe'
{
Subscribe -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
Subscribe -> Maybe Text
endpoint :: Prelude.Maybe Prelude.Text,
Subscribe -> Maybe Bool
returnSubscriptionArn :: Prelude.Maybe Prelude.Bool,
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
$c== :: Subscribe -> Subscribe -> Bool
== :: Subscribe -> Subscribe -> Bool
$c/= :: Subscribe -> Subscribe -> Bool
/= :: 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
$creadsPrec :: Int -> ReadS Subscribe
readsPrec :: Int -> ReadS Subscribe
$creadList :: ReadS [Subscribe]
readList :: ReadS [Subscribe]
$creadPrec :: ReadPrec Subscribe
readPrec :: ReadPrec Subscribe
$creadListPrec :: ReadPrec [Subscribe]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> Subscribe -> ShowS
showsPrec :: Int -> Subscribe -> ShowS
$cshow :: Subscribe -> String
show :: Subscribe -> String
$cshowList :: [Subscribe] -> ShowS
showList :: [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
$cfrom :: forall x. Subscribe -> Rep Subscribe x
from :: forall x. Subscribe -> Rep Subscribe x
$cto :: forall x. Rep Subscribe x -> Subscribe
to :: forall x. Rep Subscribe x -> Subscribe
Prelude.Generic)
newSubscribe ::
Prelude.Text ->
Prelude.Text ->
Subscribe
newSubscribe :: Text -> Text -> Subscribe
newSubscribe Text
pTopicArn_ Text
pProtocol_ =
Subscribe'
{ attributes :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
endpoint :: Maybe Text
endpoint = Maybe Text
forall a. Maybe a
Prelude.Nothing,
returnSubscriptionArn :: Maybe Bool
returnSubscriptionArn = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
topicArn :: Text
topicArn = Text
pTopicArn_,
protocol :: Text
protocol = Text
pProtocol_
}
subscribe_attributes :: Lens.Lens' Subscribe (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
subscribe_attributes :: Lens' Subscribe (Maybe (HashMap Text Text))
subscribe_attributes = (Subscribe -> Maybe (HashMap Text Text))
-> (Subscribe -> Maybe (HashMap Text Text) -> Subscribe)
-> Lens' Subscribe (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 :: Subscribe -> Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: Subscribe
s@Subscribe' {} Maybe (HashMap Text Text)
a -> Subscribe
s {attributes = 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
Iso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
Lens.coerced
subscribe_endpoint :: Lens.Lens' Subscribe (Prelude.Maybe Prelude.Text)
subscribe_endpoint :: Lens' Subscribe (Maybe Text)
subscribe_endpoint = (Subscribe -> Maybe Text)
-> (Subscribe -> Maybe Text -> Subscribe)
-> Lens' Subscribe (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscribe' {Maybe Text
endpoint :: Subscribe -> Maybe Text
endpoint :: Maybe Text
endpoint} -> Maybe Text
endpoint) (\s :: Subscribe
s@Subscribe' {} Maybe Text
a -> Subscribe
s {endpoint = a} :: Subscribe)
subscribe_returnSubscriptionArn :: Lens.Lens' Subscribe (Prelude.Maybe Prelude.Bool)
subscribe_returnSubscriptionArn :: Lens' Subscribe (Maybe Bool)
subscribe_returnSubscriptionArn = (Subscribe -> Maybe Bool)
-> (Subscribe -> Maybe Bool -> Subscribe)
-> Lens' Subscribe (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscribe' {Maybe Bool
returnSubscriptionArn :: Subscribe -> Maybe Bool
returnSubscriptionArn :: Maybe Bool
returnSubscriptionArn} -> Maybe Bool
returnSubscriptionArn) (\s :: Subscribe
s@Subscribe' {} Maybe Bool
a -> Subscribe
s {returnSubscriptionArn = a} :: Subscribe)
subscribe_topicArn :: Lens.Lens' Subscribe Prelude.Text
subscribe_topicArn :: Lens' Subscribe Text
subscribe_topicArn = (Subscribe -> Text)
-> (Subscribe -> Text -> Subscribe) -> Lens' Subscribe Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscribe' {Text
topicArn :: Subscribe -> Text
topicArn :: Text
topicArn} -> Text
topicArn) (\s :: Subscribe
s@Subscribe' {} Text
a -> Subscribe
s {topicArn = a} :: Subscribe)
subscribe_protocol :: Lens.Lens' Subscribe Prelude.Text
subscribe_protocol :: Lens' Subscribe Text
subscribe_protocol = (Subscribe -> Text)
-> (Subscribe -> Text -> Subscribe) -> Lens' Subscribe Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscribe' {Text
protocol :: Subscribe -> Text
protocol :: Text
protocol} -> Text
protocol) (\s :: Subscribe
s@Subscribe' {} Text
a -> Subscribe
s {protocol = a} :: Subscribe)
instance Core.AWSRequest Subscribe where
type AWSResponse Subscribe = SubscribeResponse
request :: (Service -> Service) -> Subscribe -> Request Subscribe
request Service -> Service
overrides =
Service -> Subscribe -> Request Subscribe
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy Subscribe
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Subscribe)))
response =
Text
-> (Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse Subscribe))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy Subscribe
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Subscribe)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
-> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> 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)
Data..@? Text
"SubscriptionArn")
Either String (Int -> SubscribeResponse)
-> Either String Int -> Either String SubscribeResponse
forall a b.
Either String (a -> b) -> Either String a -> Either String b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall a. a -> Either String a
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 where
hashWithSalt :: Int -> Subscribe -> Int
hashWithSalt Int
_salt Subscribe' {Maybe Bool
Maybe Text
Maybe (HashMap Text Text)
Text
attributes :: Subscribe -> Maybe (HashMap Text Text)
endpoint :: Subscribe -> Maybe Text
returnSubscriptionArn :: Subscribe -> Maybe Bool
topicArn :: Subscribe -> Text
protocol :: Subscribe -> Text
attributes :: Maybe (HashMap Text Text)
endpoint :: Maybe Text
returnSubscriptionArn :: Maybe Bool
topicArn :: Text
protocol :: Text
..} =
Int
_salt
Int -> Maybe (HashMap Text Text) -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
attributes
Int -> Maybe Text -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
endpoint
Int -> Maybe Bool -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
returnSubscriptionArn
Int -> Text -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
topicArn
Int -> Text -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
protocol
instance Prelude.NFData Subscribe where
rnf :: Subscribe -> ()
rnf Subscribe' {Maybe Bool
Maybe Text
Maybe (HashMap Text Text)
Text
attributes :: Subscribe -> Maybe (HashMap Text Text)
endpoint :: Subscribe -> Maybe Text
returnSubscriptionArn :: Subscribe -> Maybe Bool
topicArn :: Subscribe -> Text
protocol :: Subscribe -> Text
attributes :: Maybe (HashMap Text Text)
endpoint :: Maybe Text
returnSubscriptionArn :: Maybe Bool
topicArn :: Text
protocol :: Text
..} =
Maybe (HashMap Text Text) -> ()
forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
attributes () -> () -> ()
forall a b. a -> b -> b
`Prelude.seq`
Maybe Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
endpoint () -> () -> ()
forall a b. a -> b -> b
`Prelude.seq`
Maybe Bool -> ()
forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
returnSubscriptionArn () -> () -> ()
forall a b. a -> b -> b
`Prelude.seq`
Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf Text
topicArn () -> () -> ()
forall a b. a -> b -> b
`Prelude.seq`
Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf Text
protocol
instance Data.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 Data.ToPath Subscribe where
toPath :: Subscribe -> ByteString
toPath = ByteString -> Subscribe -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery Subscribe where
toQuery :: Subscribe -> QueryString
toQuery Subscribe' {Maybe Bool
Maybe Text
Maybe (HashMap Text Text)
Text
attributes :: Subscribe -> Maybe (HashMap Text Text)
endpoint :: Subscribe -> Maybe Text
returnSubscriptionArn :: Subscribe -> Maybe Bool
topicArn :: Subscribe -> Text
protocol :: Subscribe -> Text
attributes :: Maybe (HashMap Text Text)
endpoint :: Maybe Text
returnSubscriptionArn :: Maybe Bool
topicArn :: Text
protocol :: Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"Action"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"Subscribe" :: Prelude.ByteString),
ByteString
"Version"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
ByteString
"Attributes"
ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Data.toQuery
( ByteString
-> ByteString -> ByteString -> HashMap Text Text -> QueryString
forall k v.
(ToQuery k, ToQuery v) =>
ByteString
-> ByteString -> ByteString -> HashMap k v -> QueryString
Data.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
Data.=: Maybe Text
endpoint,
ByteString
"ReturnSubscriptionArn"
ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
returnSubscriptionArn,
ByteString
"TopicArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
topicArn,
ByteString
"Protocol" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: 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
$c== :: SubscribeResponse -> SubscribeResponse -> Bool
== :: SubscribeResponse -> SubscribeResponse -> Bool
$c/= :: SubscribeResponse -> SubscribeResponse -> Bool
/= :: 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
$creadsPrec :: Int -> ReadS SubscribeResponse
readsPrec :: Int -> ReadS SubscribeResponse
$creadList :: ReadS [SubscribeResponse]
readList :: ReadS [SubscribeResponse]
$creadPrec :: ReadPrec SubscribeResponse
readPrec :: ReadPrec SubscribeResponse
$creadListPrec :: ReadPrec [SubscribeResponse]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> SubscribeResponse -> ShowS
showsPrec :: Int -> SubscribeResponse -> ShowS
$cshow :: SubscribeResponse -> String
show :: SubscribeResponse -> String
$cshowList :: [SubscribeResponse] -> ShowS
showList :: [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
$cfrom :: forall x. SubscribeResponse -> Rep SubscribeResponse x
from :: forall x. SubscribeResponse -> Rep SubscribeResponse x
$cto :: forall x. Rep SubscribeResponse x -> SubscribeResponse
to :: forall x. Rep SubscribeResponse x -> SubscribeResponse
Prelude.Generic)
newSubscribeResponse ::
Prelude.Int ->
SubscribeResponse
newSubscribeResponse :: Int -> SubscribeResponse
newSubscribeResponse Int
pHttpStatus_ =
SubscribeResponse'
{ subscriptionArn :: Maybe Text
subscriptionArn =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
httpStatus :: Int
httpStatus = Int
pHttpStatus_
}
subscribeResponse_subscriptionArn :: Lens.Lens' SubscribeResponse (Prelude.Maybe Prelude.Text)
subscribeResponse_subscriptionArn :: Lens' SubscribeResponse (Maybe Text)
subscribeResponse_subscriptionArn = (SubscribeResponse -> Maybe Text)
-> (SubscribeResponse -> Maybe Text -> SubscribeResponse)
-> Lens' SubscribeResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubscribeResponse' {Maybe Text
subscriptionArn :: SubscribeResponse -> Maybe Text
subscriptionArn :: Maybe Text
subscriptionArn} -> Maybe Text
subscriptionArn) (\s :: SubscribeResponse
s@SubscribeResponse' {} Maybe Text
a -> SubscribeResponse
s {subscriptionArn = a} :: SubscribeResponse)
subscribeResponse_httpStatus :: Lens.Lens' SubscribeResponse Prelude.Int
subscribeResponse_httpStatus :: Lens' SubscribeResponse Int
subscribeResponse_httpStatus = (SubscribeResponse -> Int)
-> (SubscribeResponse -> Int -> SubscribeResponse)
-> Lens' SubscribeResponse Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubscribeResponse' {Int
httpStatus :: SubscribeResponse -> Int
httpStatus :: Int
httpStatus} -> Int
httpStatus) (\s :: SubscribeResponse
s@SubscribeResponse' {} Int
a -> SubscribeResponse
s {httpStatus = a} :: SubscribeResponse)
instance Prelude.NFData SubscribeResponse where
rnf :: SubscribeResponse -> ()
rnf SubscribeResponse' {Int
Maybe Text
subscriptionArn :: SubscribeResponse -> Maybe Text
httpStatus :: SubscribeResponse -> Int
subscriptionArn :: Maybe Text
httpStatus :: Int
..} =
Maybe Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
subscriptionArn () -> () -> ()
forall a b. a -> b -> b
`Prelude.seq`
Int -> ()
forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus