{-# 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.Pinpoint.UpdatePushTemplate
(
UpdatePushTemplate (..),
newUpdatePushTemplate,
updatePushTemplate_version,
updatePushTemplate_createNewVersion,
updatePushTemplate_templateName,
updatePushTemplate_pushNotificationTemplateRequest,
UpdatePushTemplateResponse (..),
newUpdatePushTemplateResponse,
updatePushTemplateResponse_httpStatus,
updatePushTemplateResponse_messageBody,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data UpdatePushTemplate = UpdatePushTemplate'
{
UpdatePushTemplate -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
UpdatePushTemplate -> Maybe Bool
createNewVersion :: Prelude.Maybe Prelude.Bool,
UpdatePushTemplate -> Text
templateName :: Prelude.Text,
UpdatePushTemplate -> PushNotificationTemplateRequest
pushNotificationTemplateRequest :: PushNotificationTemplateRequest
}
deriving (UpdatePushTemplate -> UpdatePushTemplate -> Bool
(UpdatePushTemplate -> UpdatePushTemplate -> Bool)
-> (UpdatePushTemplate -> UpdatePushTemplate -> Bool)
-> Eq UpdatePushTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePushTemplate -> UpdatePushTemplate -> Bool
$c/= :: UpdatePushTemplate -> UpdatePushTemplate -> Bool
== :: UpdatePushTemplate -> UpdatePushTemplate -> Bool
$c== :: UpdatePushTemplate -> UpdatePushTemplate -> Bool
Prelude.Eq, ReadPrec [UpdatePushTemplate]
ReadPrec UpdatePushTemplate
Int -> ReadS UpdatePushTemplate
ReadS [UpdatePushTemplate]
(Int -> ReadS UpdatePushTemplate)
-> ReadS [UpdatePushTemplate]
-> ReadPrec UpdatePushTemplate
-> ReadPrec [UpdatePushTemplate]
-> Read UpdatePushTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePushTemplate]
$creadListPrec :: ReadPrec [UpdatePushTemplate]
readPrec :: ReadPrec UpdatePushTemplate
$creadPrec :: ReadPrec UpdatePushTemplate
readList :: ReadS [UpdatePushTemplate]
$creadList :: ReadS [UpdatePushTemplate]
readsPrec :: Int -> ReadS UpdatePushTemplate
$creadsPrec :: Int -> ReadS UpdatePushTemplate
Prelude.Read, Int -> UpdatePushTemplate -> ShowS
[UpdatePushTemplate] -> ShowS
UpdatePushTemplate -> String
(Int -> UpdatePushTemplate -> ShowS)
-> (UpdatePushTemplate -> String)
-> ([UpdatePushTemplate] -> ShowS)
-> Show UpdatePushTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePushTemplate] -> ShowS
$cshowList :: [UpdatePushTemplate] -> ShowS
show :: UpdatePushTemplate -> String
$cshow :: UpdatePushTemplate -> String
showsPrec :: Int -> UpdatePushTemplate -> ShowS
$cshowsPrec :: Int -> UpdatePushTemplate -> ShowS
Prelude.Show, (forall x. UpdatePushTemplate -> Rep UpdatePushTemplate x)
-> (forall x. Rep UpdatePushTemplate x -> UpdatePushTemplate)
-> Generic UpdatePushTemplate
forall x. Rep UpdatePushTemplate x -> UpdatePushTemplate
forall x. UpdatePushTemplate -> Rep UpdatePushTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdatePushTemplate x -> UpdatePushTemplate
$cfrom :: forall x. UpdatePushTemplate -> Rep UpdatePushTemplate x
Prelude.Generic)
newUpdatePushTemplate ::
Prelude.Text ->
PushNotificationTemplateRequest ->
UpdatePushTemplate
newUpdatePushTemplate :: Text -> PushNotificationTemplateRequest -> UpdatePushTemplate
newUpdatePushTemplate
Text
pTemplateName_
PushNotificationTemplateRequest
pPushNotificationTemplateRequest_ =
UpdatePushTemplate' :: Maybe Text
-> Maybe Bool
-> Text
-> PushNotificationTemplateRequest
-> UpdatePushTemplate
UpdatePushTemplate'
{ $sel:version:UpdatePushTemplate' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:createNewVersion:UpdatePushTemplate' :: Maybe Bool
createNewVersion = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:templateName:UpdatePushTemplate' :: Text
templateName = Text
pTemplateName_,
$sel:pushNotificationTemplateRequest:UpdatePushTemplate' :: PushNotificationTemplateRequest
pushNotificationTemplateRequest =
PushNotificationTemplateRequest
pPushNotificationTemplateRequest_
}
updatePushTemplate_version :: Lens.Lens' UpdatePushTemplate (Prelude.Maybe Prelude.Text)
updatePushTemplate_version :: (Maybe Text -> f (Maybe Text))
-> UpdatePushTemplate -> f UpdatePushTemplate
updatePushTemplate_version = (UpdatePushTemplate -> Maybe Text)
-> (UpdatePushTemplate -> Maybe Text -> UpdatePushTemplate)
-> Lens
UpdatePushTemplate UpdatePushTemplate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePushTemplate' {Maybe Text
version :: Maybe Text
$sel:version:UpdatePushTemplate' :: UpdatePushTemplate -> Maybe Text
version} -> Maybe Text
version) (\s :: UpdatePushTemplate
s@UpdatePushTemplate' {} Maybe Text
a -> UpdatePushTemplate
s {$sel:version:UpdatePushTemplate' :: Maybe Text
version = Maybe Text
a} :: UpdatePushTemplate)
updatePushTemplate_createNewVersion :: Lens.Lens' UpdatePushTemplate (Prelude.Maybe Prelude.Bool)
updatePushTemplate_createNewVersion :: (Maybe Bool -> f (Maybe Bool))
-> UpdatePushTemplate -> f UpdatePushTemplate
updatePushTemplate_createNewVersion = (UpdatePushTemplate -> Maybe Bool)
-> (UpdatePushTemplate -> Maybe Bool -> UpdatePushTemplate)
-> Lens
UpdatePushTemplate UpdatePushTemplate (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePushTemplate' {Maybe Bool
createNewVersion :: Maybe Bool
$sel:createNewVersion:UpdatePushTemplate' :: UpdatePushTemplate -> Maybe Bool
createNewVersion} -> Maybe Bool
createNewVersion) (\s :: UpdatePushTemplate
s@UpdatePushTemplate' {} Maybe Bool
a -> UpdatePushTemplate
s {$sel:createNewVersion:UpdatePushTemplate' :: Maybe Bool
createNewVersion = Maybe Bool
a} :: UpdatePushTemplate)
updatePushTemplate_templateName :: Lens.Lens' UpdatePushTemplate Prelude.Text
updatePushTemplate_templateName :: (Text -> f Text) -> UpdatePushTemplate -> f UpdatePushTemplate
updatePushTemplate_templateName = (UpdatePushTemplate -> Text)
-> (UpdatePushTemplate -> Text -> UpdatePushTemplate)
-> Lens UpdatePushTemplate UpdatePushTemplate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePushTemplate' {Text
templateName :: Text
$sel:templateName:UpdatePushTemplate' :: UpdatePushTemplate -> Text
templateName} -> Text
templateName) (\s :: UpdatePushTemplate
s@UpdatePushTemplate' {} Text
a -> UpdatePushTemplate
s {$sel:templateName:UpdatePushTemplate' :: Text
templateName = Text
a} :: UpdatePushTemplate)
updatePushTemplate_pushNotificationTemplateRequest :: Lens.Lens' UpdatePushTemplate PushNotificationTemplateRequest
updatePushTemplate_pushNotificationTemplateRequest :: (PushNotificationTemplateRequest
-> f PushNotificationTemplateRequest)
-> UpdatePushTemplate -> f UpdatePushTemplate
updatePushTemplate_pushNotificationTemplateRequest = (UpdatePushTemplate -> PushNotificationTemplateRequest)
-> (UpdatePushTemplate
-> PushNotificationTemplateRequest -> UpdatePushTemplate)
-> Lens
UpdatePushTemplate
UpdatePushTemplate
PushNotificationTemplateRequest
PushNotificationTemplateRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePushTemplate' {PushNotificationTemplateRequest
pushNotificationTemplateRequest :: PushNotificationTemplateRequest
$sel:pushNotificationTemplateRequest:UpdatePushTemplate' :: UpdatePushTemplate -> PushNotificationTemplateRequest
pushNotificationTemplateRequest} -> PushNotificationTemplateRequest
pushNotificationTemplateRequest) (\s :: UpdatePushTemplate
s@UpdatePushTemplate' {} PushNotificationTemplateRequest
a -> UpdatePushTemplate
s {$sel:pushNotificationTemplateRequest:UpdatePushTemplate' :: PushNotificationTemplateRequest
pushNotificationTemplateRequest = PushNotificationTemplateRequest
a} :: UpdatePushTemplate)
instance Core.AWSRequest UpdatePushTemplate where
type
AWSResponse UpdatePushTemplate =
UpdatePushTemplateResponse
request :: UpdatePushTemplate -> Request UpdatePushTemplate
request = Service -> UpdatePushTemplate -> Request UpdatePushTemplate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
response :: Logger
-> Service
-> Proxy UpdatePushTemplate
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse UpdatePushTemplate)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse UpdatePushTemplate))
-> Logger
-> Service
-> Proxy UpdatePushTemplate
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse UpdatePushTemplate)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Int -> MessageBody -> UpdatePushTemplateResponse
UpdatePushTemplateResponse'
(Int -> MessageBody -> UpdatePushTemplateResponse)
-> Either String Int
-> Either String (MessageBody -> UpdatePushTemplateResponse)
forall (f :: * -> *) a b. Functor 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))
Either String (MessageBody -> UpdatePushTemplateResponse)
-> Either String MessageBody
-> Either String UpdatePushTemplateResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String MessageBody
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
)
instance Prelude.Hashable UpdatePushTemplate
instance Prelude.NFData UpdatePushTemplate
instance Core.ToHeaders UpdatePushTemplate where
toHeaders :: UpdatePushTemplate -> ResponseHeaders
toHeaders =
ResponseHeaders -> UpdatePushTemplate -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON UpdatePushTemplate where
toJSON :: UpdatePushTemplate -> Value
toJSON UpdatePushTemplate' {Maybe Bool
Maybe Text
Text
PushNotificationTemplateRequest
pushNotificationTemplateRequest :: PushNotificationTemplateRequest
templateName :: Text
createNewVersion :: Maybe Bool
version :: Maybe Text
$sel:pushNotificationTemplateRequest:UpdatePushTemplate' :: UpdatePushTemplate -> PushNotificationTemplateRequest
$sel:templateName:UpdatePushTemplate' :: UpdatePushTemplate -> Text
$sel:createNewVersion:UpdatePushTemplate' :: UpdatePushTemplate -> Maybe Bool
$sel:version:UpdatePushTemplate' :: UpdatePushTemplate -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
( Text
"PushNotificationTemplateRequest"
Text -> PushNotificationTemplateRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PushNotificationTemplateRequest
pushNotificationTemplateRequest
)
]
)
instance Core.ToPath UpdatePushTemplate where
toPath :: UpdatePushTemplate -> ByteString
toPath UpdatePushTemplate' {Maybe Bool
Maybe Text
Text
PushNotificationTemplateRequest
pushNotificationTemplateRequest :: PushNotificationTemplateRequest
templateName :: Text
createNewVersion :: Maybe Bool
version :: Maybe Text
$sel:pushNotificationTemplateRequest:UpdatePushTemplate' :: UpdatePushTemplate -> PushNotificationTemplateRequest
$sel:templateName:UpdatePushTemplate' :: UpdatePushTemplate -> Text
$sel:createNewVersion:UpdatePushTemplate' :: UpdatePushTemplate -> Maybe Bool
$sel:version:UpdatePushTemplate' :: UpdatePushTemplate -> Maybe Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/v1/templates/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
templateName, ByteString
"/push"]
instance Core.ToQuery UpdatePushTemplate where
toQuery :: UpdatePushTemplate -> QueryString
toQuery UpdatePushTemplate' {Maybe Bool
Maybe Text
Text
PushNotificationTemplateRequest
pushNotificationTemplateRequest :: PushNotificationTemplateRequest
templateName :: Text
createNewVersion :: Maybe Bool
version :: Maybe Text
$sel:pushNotificationTemplateRequest:UpdatePushTemplate' :: UpdatePushTemplate -> PushNotificationTemplateRequest
$sel:templateName:UpdatePushTemplate' :: UpdatePushTemplate -> Text
$sel:createNewVersion:UpdatePushTemplate' :: UpdatePushTemplate -> Maybe Bool
$sel:version:UpdatePushTemplate' :: UpdatePushTemplate -> Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"version" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
version,
ByteString
"create-new-version" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
createNewVersion
]
data UpdatePushTemplateResponse = UpdatePushTemplateResponse'
{
UpdatePushTemplateResponse -> Int
httpStatus :: Prelude.Int,
UpdatePushTemplateResponse -> MessageBody
messageBody :: MessageBody
}
deriving (UpdatePushTemplateResponse -> UpdatePushTemplateResponse -> Bool
(UpdatePushTemplateResponse -> UpdatePushTemplateResponse -> Bool)
-> (UpdatePushTemplateResponse
-> UpdatePushTemplateResponse -> Bool)
-> Eq UpdatePushTemplateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePushTemplateResponse -> UpdatePushTemplateResponse -> Bool
$c/= :: UpdatePushTemplateResponse -> UpdatePushTemplateResponse -> Bool
== :: UpdatePushTemplateResponse -> UpdatePushTemplateResponse -> Bool
$c== :: UpdatePushTemplateResponse -> UpdatePushTemplateResponse -> Bool
Prelude.Eq, ReadPrec [UpdatePushTemplateResponse]
ReadPrec UpdatePushTemplateResponse
Int -> ReadS UpdatePushTemplateResponse
ReadS [UpdatePushTemplateResponse]
(Int -> ReadS UpdatePushTemplateResponse)
-> ReadS [UpdatePushTemplateResponse]
-> ReadPrec UpdatePushTemplateResponse
-> ReadPrec [UpdatePushTemplateResponse]
-> Read UpdatePushTemplateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePushTemplateResponse]
$creadListPrec :: ReadPrec [UpdatePushTemplateResponse]
readPrec :: ReadPrec UpdatePushTemplateResponse
$creadPrec :: ReadPrec UpdatePushTemplateResponse
readList :: ReadS [UpdatePushTemplateResponse]
$creadList :: ReadS [UpdatePushTemplateResponse]
readsPrec :: Int -> ReadS UpdatePushTemplateResponse
$creadsPrec :: Int -> ReadS UpdatePushTemplateResponse
Prelude.Read, Int -> UpdatePushTemplateResponse -> ShowS
[UpdatePushTemplateResponse] -> ShowS
UpdatePushTemplateResponse -> String
(Int -> UpdatePushTemplateResponse -> ShowS)
-> (UpdatePushTemplateResponse -> String)
-> ([UpdatePushTemplateResponse] -> ShowS)
-> Show UpdatePushTemplateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePushTemplateResponse] -> ShowS
$cshowList :: [UpdatePushTemplateResponse] -> ShowS
show :: UpdatePushTemplateResponse -> String
$cshow :: UpdatePushTemplateResponse -> String
showsPrec :: Int -> UpdatePushTemplateResponse -> ShowS
$cshowsPrec :: Int -> UpdatePushTemplateResponse -> ShowS
Prelude.Show, (forall x.
UpdatePushTemplateResponse -> Rep UpdatePushTemplateResponse x)
-> (forall x.
Rep UpdatePushTemplateResponse x -> UpdatePushTemplateResponse)
-> Generic UpdatePushTemplateResponse
forall x.
Rep UpdatePushTemplateResponse x -> UpdatePushTemplateResponse
forall x.
UpdatePushTemplateResponse -> Rep UpdatePushTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdatePushTemplateResponse x -> UpdatePushTemplateResponse
$cfrom :: forall x.
UpdatePushTemplateResponse -> Rep UpdatePushTemplateResponse x
Prelude.Generic)
newUpdatePushTemplateResponse ::
Prelude.Int ->
MessageBody ->
UpdatePushTemplateResponse
newUpdatePushTemplateResponse :: Int -> MessageBody -> UpdatePushTemplateResponse
newUpdatePushTemplateResponse
Int
pHttpStatus_
MessageBody
pMessageBody_ =
UpdatePushTemplateResponse' :: Int -> MessageBody -> UpdatePushTemplateResponse
UpdatePushTemplateResponse'
{ $sel:httpStatus:UpdatePushTemplateResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:messageBody:UpdatePushTemplateResponse' :: MessageBody
messageBody = MessageBody
pMessageBody_
}
updatePushTemplateResponse_httpStatus :: Lens.Lens' UpdatePushTemplateResponse Prelude.Int
updatePushTemplateResponse_httpStatus :: (Int -> f Int)
-> UpdatePushTemplateResponse -> f UpdatePushTemplateResponse
updatePushTemplateResponse_httpStatus = (UpdatePushTemplateResponse -> Int)
-> (UpdatePushTemplateResponse
-> Int -> UpdatePushTemplateResponse)
-> Lens
UpdatePushTemplateResponse UpdatePushTemplateResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePushTemplateResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdatePushTemplateResponse' :: UpdatePushTemplateResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdatePushTemplateResponse
s@UpdatePushTemplateResponse' {} Int
a -> UpdatePushTemplateResponse
s {$sel:httpStatus:UpdatePushTemplateResponse' :: Int
httpStatus = Int
a} :: UpdatePushTemplateResponse)
updatePushTemplateResponse_messageBody :: Lens.Lens' UpdatePushTemplateResponse MessageBody
updatePushTemplateResponse_messageBody :: (MessageBody -> f MessageBody)
-> UpdatePushTemplateResponse -> f UpdatePushTemplateResponse
updatePushTemplateResponse_messageBody = (UpdatePushTemplateResponse -> MessageBody)
-> (UpdatePushTemplateResponse
-> MessageBody -> UpdatePushTemplateResponse)
-> Lens
UpdatePushTemplateResponse
UpdatePushTemplateResponse
MessageBody
MessageBody
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePushTemplateResponse' {MessageBody
messageBody :: MessageBody
$sel:messageBody:UpdatePushTemplateResponse' :: UpdatePushTemplateResponse -> MessageBody
messageBody} -> MessageBody
messageBody) (\s :: UpdatePushTemplateResponse
s@UpdatePushTemplateResponse' {} MessageBody
a -> UpdatePushTemplateResponse
s {$sel:messageBody:UpdatePushTemplateResponse' :: MessageBody
messageBody = MessageBody
a} :: UpdatePushTemplateResponse)
instance Prelude.NFData UpdatePushTemplateResponse