{-# 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.UpdateSegment
(
UpdateSegment (..),
newUpdateSegment,
updateSegment_segmentId,
updateSegment_applicationId,
updateSegment_writeSegmentRequest,
UpdateSegmentResponse (..),
newUpdateSegmentResponse,
updateSegmentResponse_httpStatus,
updateSegmentResponse_segmentResponse,
)
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 UpdateSegment = UpdateSegment'
{
UpdateSegment -> Text
segmentId :: Prelude.Text,
UpdateSegment -> Text
applicationId :: Prelude.Text,
UpdateSegment -> WriteSegmentRequest
writeSegmentRequest :: WriteSegmentRequest
}
deriving (UpdateSegment -> UpdateSegment -> Bool
(UpdateSegment -> UpdateSegment -> Bool)
-> (UpdateSegment -> UpdateSegment -> Bool) -> Eq UpdateSegment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSegment -> UpdateSegment -> Bool
$c/= :: UpdateSegment -> UpdateSegment -> Bool
== :: UpdateSegment -> UpdateSegment -> Bool
$c== :: UpdateSegment -> UpdateSegment -> Bool
Prelude.Eq, ReadPrec [UpdateSegment]
ReadPrec UpdateSegment
Int -> ReadS UpdateSegment
ReadS [UpdateSegment]
(Int -> ReadS UpdateSegment)
-> ReadS [UpdateSegment]
-> ReadPrec UpdateSegment
-> ReadPrec [UpdateSegment]
-> Read UpdateSegment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSegment]
$creadListPrec :: ReadPrec [UpdateSegment]
readPrec :: ReadPrec UpdateSegment
$creadPrec :: ReadPrec UpdateSegment
readList :: ReadS [UpdateSegment]
$creadList :: ReadS [UpdateSegment]
readsPrec :: Int -> ReadS UpdateSegment
$creadsPrec :: Int -> ReadS UpdateSegment
Prelude.Read, Int -> UpdateSegment -> ShowS
[UpdateSegment] -> ShowS
UpdateSegment -> String
(Int -> UpdateSegment -> ShowS)
-> (UpdateSegment -> String)
-> ([UpdateSegment] -> ShowS)
-> Show UpdateSegment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSegment] -> ShowS
$cshowList :: [UpdateSegment] -> ShowS
show :: UpdateSegment -> String
$cshow :: UpdateSegment -> String
showsPrec :: Int -> UpdateSegment -> ShowS
$cshowsPrec :: Int -> UpdateSegment -> ShowS
Prelude.Show, (forall x. UpdateSegment -> Rep UpdateSegment x)
-> (forall x. Rep UpdateSegment x -> UpdateSegment)
-> Generic UpdateSegment
forall x. Rep UpdateSegment x -> UpdateSegment
forall x. UpdateSegment -> Rep UpdateSegment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateSegment x -> UpdateSegment
$cfrom :: forall x. UpdateSegment -> Rep UpdateSegment x
Prelude.Generic)
newUpdateSegment ::
Prelude.Text ->
Prelude.Text ->
WriteSegmentRequest ->
UpdateSegment
newUpdateSegment :: Text -> Text -> WriteSegmentRequest -> UpdateSegment
newUpdateSegment
Text
pSegmentId_
Text
pApplicationId_
WriteSegmentRequest
pWriteSegmentRequest_ =
UpdateSegment' :: Text -> Text -> WriteSegmentRequest -> UpdateSegment
UpdateSegment'
{ $sel:segmentId:UpdateSegment' :: Text
segmentId = Text
pSegmentId_,
$sel:applicationId:UpdateSegment' :: Text
applicationId = Text
pApplicationId_,
$sel:writeSegmentRequest:UpdateSegment' :: WriteSegmentRequest
writeSegmentRequest = WriteSegmentRequest
pWriteSegmentRequest_
}
updateSegment_segmentId :: Lens.Lens' UpdateSegment Prelude.Text
updateSegment_segmentId :: (Text -> f Text) -> UpdateSegment -> f UpdateSegment
updateSegment_segmentId = (UpdateSegment -> Text)
-> (UpdateSegment -> Text -> UpdateSegment)
-> Lens UpdateSegment UpdateSegment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSegment' {Text
segmentId :: Text
$sel:segmentId:UpdateSegment' :: UpdateSegment -> Text
segmentId} -> Text
segmentId) (\s :: UpdateSegment
s@UpdateSegment' {} Text
a -> UpdateSegment
s {$sel:segmentId:UpdateSegment' :: Text
segmentId = Text
a} :: UpdateSegment)
updateSegment_applicationId :: Lens.Lens' UpdateSegment Prelude.Text
updateSegment_applicationId :: (Text -> f Text) -> UpdateSegment -> f UpdateSegment
updateSegment_applicationId = (UpdateSegment -> Text)
-> (UpdateSegment -> Text -> UpdateSegment)
-> Lens UpdateSegment UpdateSegment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSegment' {Text
applicationId :: Text
$sel:applicationId:UpdateSegment' :: UpdateSegment -> Text
applicationId} -> Text
applicationId) (\s :: UpdateSegment
s@UpdateSegment' {} Text
a -> UpdateSegment
s {$sel:applicationId:UpdateSegment' :: Text
applicationId = Text
a} :: UpdateSegment)
updateSegment_writeSegmentRequest :: Lens.Lens' UpdateSegment WriteSegmentRequest
updateSegment_writeSegmentRequest :: (WriteSegmentRequest -> f WriteSegmentRequest)
-> UpdateSegment -> f UpdateSegment
updateSegment_writeSegmentRequest = (UpdateSegment -> WriteSegmentRequest)
-> (UpdateSegment -> WriteSegmentRequest -> UpdateSegment)
-> Lens
UpdateSegment UpdateSegment WriteSegmentRequest WriteSegmentRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSegment' {WriteSegmentRequest
writeSegmentRequest :: WriteSegmentRequest
$sel:writeSegmentRequest:UpdateSegment' :: UpdateSegment -> WriteSegmentRequest
writeSegmentRequest} -> WriteSegmentRequest
writeSegmentRequest) (\s :: UpdateSegment
s@UpdateSegment' {} WriteSegmentRequest
a -> UpdateSegment
s {$sel:writeSegmentRequest:UpdateSegment' :: WriteSegmentRequest
writeSegmentRequest = WriteSegmentRequest
a} :: UpdateSegment)
instance Core.AWSRequest UpdateSegment where
type
AWSResponse UpdateSegment =
UpdateSegmentResponse
request :: UpdateSegment -> Request UpdateSegment
request = Service -> UpdateSegment -> Request UpdateSegment
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
response :: Logger
-> Service
-> Proxy UpdateSegment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateSegment)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse UpdateSegment))
-> Logger
-> Service
-> Proxy UpdateSegment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateSegment)))
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 -> SegmentResponse -> UpdateSegmentResponse
UpdateSegmentResponse'
(Int -> SegmentResponse -> UpdateSegmentResponse)
-> Either String Int
-> Either String (SegmentResponse -> UpdateSegmentResponse)
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 (SegmentResponse -> UpdateSegmentResponse)
-> Either String SegmentResponse
-> Either String UpdateSegmentResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String SegmentResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
)
instance Prelude.Hashable UpdateSegment
instance Prelude.NFData UpdateSegment
instance Core.ToHeaders UpdateSegment where
toHeaders :: UpdateSegment -> ResponseHeaders
toHeaders =
ResponseHeaders -> UpdateSegment -> 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 UpdateSegment where
toJSON :: UpdateSegment -> Value
toJSON UpdateSegment' {Text
WriteSegmentRequest
writeSegmentRequest :: WriteSegmentRequest
applicationId :: Text
segmentId :: Text
$sel:writeSegmentRequest:UpdateSegment' :: UpdateSegment -> WriteSegmentRequest
$sel:applicationId:UpdateSegment' :: UpdateSegment -> Text
$sel:segmentId:UpdateSegment' :: UpdateSegment -> 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
"WriteSegmentRequest" Text -> WriteSegmentRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= WriteSegmentRequest
writeSegmentRequest)
]
)
instance Core.ToPath UpdateSegment where
toPath :: UpdateSegment -> ByteString
toPath UpdateSegment' {Text
WriteSegmentRequest
writeSegmentRequest :: WriteSegmentRequest
applicationId :: Text
segmentId :: Text
$sel:writeSegmentRequest:UpdateSegment' :: UpdateSegment -> WriteSegmentRequest
$sel:applicationId:UpdateSegment' :: UpdateSegment -> Text
$sel:segmentId:UpdateSegment' :: UpdateSegment -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/v1/apps/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId,
ByteString
"/segments/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
segmentId
]
instance Core.ToQuery UpdateSegment where
toQuery :: UpdateSegment -> QueryString
toQuery = QueryString -> UpdateSegment -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data UpdateSegmentResponse = UpdateSegmentResponse'
{
UpdateSegmentResponse -> Int
httpStatus :: Prelude.Int,
UpdateSegmentResponse -> SegmentResponse
segmentResponse :: SegmentResponse
}
deriving (UpdateSegmentResponse -> UpdateSegmentResponse -> Bool
(UpdateSegmentResponse -> UpdateSegmentResponse -> Bool)
-> (UpdateSegmentResponse -> UpdateSegmentResponse -> Bool)
-> Eq UpdateSegmentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSegmentResponse -> UpdateSegmentResponse -> Bool
$c/= :: UpdateSegmentResponse -> UpdateSegmentResponse -> Bool
== :: UpdateSegmentResponse -> UpdateSegmentResponse -> Bool
$c== :: UpdateSegmentResponse -> UpdateSegmentResponse -> Bool
Prelude.Eq, ReadPrec [UpdateSegmentResponse]
ReadPrec UpdateSegmentResponse
Int -> ReadS UpdateSegmentResponse
ReadS [UpdateSegmentResponse]
(Int -> ReadS UpdateSegmentResponse)
-> ReadS [UpdateSegmentResponse]
-> ReadPrec UpdateSegmentResponse
-> ReadPrec [UpdateSegmentResponse]
-> Read UpdateSegmentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSegmentResponse]
$creadListPrec :: ReadPrec [UpdateSegmentResponse]
readPrec :: ReadPrec UpdateSegmentResponse
$creadPrec :: ReadPrec UpdateSegmentResponse
readList :: ReadS [UpdateSegmentResponse]
$creadList :: ReadS [UpdateSegmentResponse]
readsPrec :: Int -> ReadS UpdateSegmentResponse
$creadsPrec :: Int -> ReadS UpdateSegmentResponse
Prelude.Read, Int -> UpdateSegmentResponse -> ShowS
[UpdateSegmentResponse] -> ShowS
UpdateSegmentResponse -> String
(Int -> UpdateSegmentResponse -> ShowS)
-> (UpdateSegmentResponse -> String)
-> ([UpdateSegmentResponse] -> ShowS)
-> Show UpdateSegmentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSegmentResponse] -> ShowS
$cshowList :: [UpdateSegmentResponse] -> ShowS
show :: UpdateSegmentResponse -> String
$cshow :: UpdateSegmentResponse -> String
showsPrec :: Int -> UpdateSegmentResponse -> ShowS
$cshowsPrec :: Int -> UpdateSegmentResponse -> ShowS
Prelude.Show, (forall x. UpdateSegmentResponse -> Rep UpdateSegmentResponse x)
-> (forall x. Rep UpdateSegmentResponse x -> UpdateSegmentResponse)
-> Generic UpdateSegmentResponse
forall x. Rep UpdateSegmentResponse x -> UpdateSegmentResponse
forall x. UpdateSegmentResponse -> Rep UpdateSegmentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateSegmentResponse x -> UpdateSegmentResponse
$cfrom :: forall x. UpdateSegmentResponse -> Rep UpdateSegmentResponse x
Prelude.Generic)
newUpdateSegmentResponse ::
Prelude.Int ->
SegmentResponse ->
UpdateSegmentResponse
newUpdateSegmentResponse :: Int -> SegmentResponse -> UpdateSegmentResponse
newUpdateSegmentResponse
Int
pHttpStatus_
SegmentResponse
pSegmentResponse_ =
UpdateSegmentResponse' :: Int -> SegmentResponse -> UpdateSegmentResponse
UpdateSegmentResponse'
{ $sel:httpStatus:UpdateSegmentResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:segmentResponse:UpdateSegmentResponse' :: SegmentResponse
segmentResponse = SegmentResponse
pSegmentResponse_
}
updateSegmentResponse_httpStatus :: Lens.Lens' UpdateSegmentResponse Prelude.Int
updateSegmentResponse_httpStatus :: (Int -> f Int) -> UpdateSegmentResponse -> f UpdateSegmentResponse
updateSegmentResponse_httpStatus = (UpdateSegmentResponse -> Int)
-> (UpdateSegmentResponse -> Int -> UpdateSegmentResponse)
-> Lens UpdateSegmentResponse UpdateSegmentResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSegmentResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateSegmentResponse' :: UpdateSegmentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateSegmentResponse
s@UpdateSegmentResponse' {} Int
a -> UpdateSegmentResponse
s {$sel:httpStatus:UpdateSegmentResponse' :: Int
httpStatus = Int
a} :: UpdateSegmentResponse)
updateSegmentResponse_segmentResponse :: Lens.Lens' UpdateSegmentResponse SegmentResponse
updateSegmentResponse_segmentResponse :: (SegmentResponse -> f SegmentResponse)
-> UpdateSegmentResponse -> f UpdateSegmentResponse
updateSegmentResponse_segmentResponse = (UpdateSegmentResponse -> SegmentResponse)
-> (UpdateSegmentResponse
-> SegmentResponse -> UpdateSegmentResponse)
-> Lens
UpdateSegmentResponse
UpdateSegmentResponse
SegmentResponse
SegmentResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSegmentResponse' {SegmentResponse
segmentResponse :: SegmentResponse
$sel:segmentResponse:UpdateSegmentResponse' :: UpdateSegmentResponse -> SegmentResponse
segmentResponse} -> SegmentResponse
segmentResponse) (\s :: UpdateSegmentResponse
s@UpdateSegmentResponse' {} SegmentResponse
a -> UpdateSegmentResponse
s {$sel:segmentResponse:UpdateSegmentResponse' :: SegmentResponse
segmentResponse = SegmentResponse
a} :: UpdateSegmentResponse)
instance Prelude.NFData UpdateSegmentResponse