{-# 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.CreateSegment
(
CreateSegment (..),
newCreateSegment,
createSegment_applicationId,
createSegment_writeSegmentRequest,
CreateSegmentResponse (..),
newCreateSegmentResponse,
createSegmentResponse_httpStatus,
createSegmentResponse_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 CreateSegment = CreateSegment'
{
CreateSegment -> Text
applicationId :: Prelude.Text,
CreateSegment -> WriteSegmentRequest
writeSegmentRequest :: WriteSegmentRequest
}
deriving (CreateSegment -> CreateSegment -> Bool
(CreateSegment -> CreateSegment -> Bool)
-> (CreateSegment -> CreateSegment -> Bool) -> Eq CreateSegment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSegment -> CreateSegment -> Bool
$c/= :: CreateSegment -> CreateSegment -> Bool
== :: CreateSegment -> CreateSegment -> Bool
$c== :: CreateSegment -> CreateSegment -> Bool
Prelude.Eq, ReadPrec [CreateSegment]
ReadPrec CreateSegment
Int -> ReadS CreateSegment
ReadS [CreateSegment]
(Int -> ReadS CreateSegment)
-> ReadS [CreateSegment]
-> ReadPrec CreateSegment
-> ReadPrec [CreateSegment]
-> Read CreateSegment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSegment]
$creadListPrec :: ReadPrec [CreateSegment]
readPrec :: ReadPrec CreateSegment
$creadPrec :: ReadPrec CreateSegment
readList :: ReadS [CreateSegment]
$creadList :: ReadS [CreateSegment]
readsPrec :: Int -> ReadS CreateSegment
$creadsPrec :: Int -> ReadS CreateSegment
Prelude.Read, Int -> CreateSegment -> ShowS
[CreateSegment] -> ShowS
CreateSegment -> String
(Int -> CreateSegment -> ShowS)
-> (CreateSegment -> String)
-> ([CreateSegment] -> ShowS)
-> Show CreateSegment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSegment] -> ShowS
$cshowList :: [CreateSegment] -> ShowS
show :: CreateSegment -> String
$cshow :: CreateSegment -> String
showsPrec :: Int -> CreateSegment -> ShowS
$cshowsPrec :: Int -> CreateSegment -> ShowS
Prelude.Show, (forall x. CreateSegment -> Rep CreateSegment x)
-> (forall x. Rep CreateSegment x -> CreateSegment)
-> Generic CreateSegment
forall x. Rep CreateSegment x -> CreateSegment
forall x. CreateSegment -> Rep CreateSegment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSegment x -> CreateSegment
$cfrom :: forall x. CreateSegment -> Rep CreateSegment x
Prelude.Generic)
newCreateSegment ::
Prelude.Text ->
WriteSegmentRequest ->
CreateSegment
newCreateSegment :: Text -> WriteSegmentRequest -> CreateSegment
newCreateSegment
Text
pApplicationId_
WriteSegmentRequest
pWriteSegmentRequest_ =
CreateSegment' :: Text -> WriteSegmentRequest -> CreateSegment
CreateSegment'
{ $sel:applicationId:CreateSegment' :: Text
applicationId = Text
pApplicationId_,
$sel:writeSegmentRequest:CreateSegment' :: WriteSegmentRequest
writeSegmentRequest = WriteSegmentRequest
pWriteSegmentRequest_
}
createSegment_applicationId :: Lens.Lens' CreateSegment Prelude.Text
createSegment_applicationId :: (Text -> f Text) -> CreateSegment -> f CreateSegment
createSegment_applicationId = (CreateSegment -> Text)
-> (CreateSegment -> Text -> CreateSegment)
-> Lens CreateSegment CreateSegment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSegment' {Text
applicationId :: Text
$sel:applicationId:CreateSegment' :: CreateSegment -> Text
applicationId} -> Text
applicationId) (\s :: CreateSegment
s@CreateSegment' {} Text
a -> CreateSegment
s {$sel:applicationId:CreateSegment' :: Text
applicationId = Text
a} :: CreateSegment)
createSegment_writeSegmentRequest :: Lens.Lens' CreateSegment WriteSegmentRequest
createSegment_writeSegmentRequest :: (WriteSegmentRequest -> f WriteSegmentRequest)
-> CreateSegment -> f CreateSegment
createSegment_writeSegmentRequest = (CreateSegment -> WriteSegmentRequest)
-> (CreateSegment -> WriteSegmentRequest -> CreateSegment)
-> Lens
CreateSegment CreateSegment WriteSegmentRequest WriteSegmentRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSegment' {WriteSegmentRequest
writeSegmentRequest :: WriteSegmentRequest
$sel:writeSegmentRequest:CreateSegment' :: CreateSegment -> WriteSegmentRequest
writeSegmentRequest} -> WriteSegmentRequest
writeSegmentRequest) (\s :: CreateSegment
s@CreateSegment' {} WriteSegmentRequest
a -> CreateSegment
s {$sel:writeSegmentRequest:CreateSegment' :: WriteSegmentRequest
writeSegmentRequest = WriteSegmentRequest
a} :: CreateSegment)
instance Core.AWSRequest CreateSegment where
type
AWSResponse CreateSegment =
CreateSegmentResponse
request :: CreateSegment -> Request CreateSegment
request = Service -> CreateSegment -> Request CreateSegment
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateSegment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateSegment)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateSegment))
-> Logger
-> Service
-> Proxy CreateSegment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateSegment)))
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 -> CreateSegmentResponse
CreateSegmentResponse'
(Int -> SegmentResponse -> CreateSegmentResponse)
-> Either String Int
-> Either String (SegmentResponse -> CreateSegmentResponse)
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 -> CreateSegmentResponse)
-> Either String SegmentResponse
-> Either String CreateSegmentResponse
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 CreateSegment
instance Prelude.NFData CreateSegment
instance Core.ToHeaders CreateSegment where
toHeaders :: CreateSegment -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateSegment -> 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 CreateSegment where
toJSON :: CreateSegment -> Value
toJSON CreateSegment' {Text
WriteSegmentRequest
writeSegmentRequest :: WriteSegmentRequest
applicationId :: Text
$sel:writeSegmentRequest:CreateSegment' :: CreateSegment -> WriteSegmentRequest
$sel:applicationId:CreateSegment' :: CreateSegment -> 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 CreateSegment where
toPath :: CreateSegment -> ByteString
toPath CreateSegment' {Text
WriteSegmentRequest
writeSegmentRequest :: WriteSegmentRequest
applicationId :: Text
$sel:writeSegmentRequest:CreateSegment' :: CreateSegment -> WriteSegmentRequest
$sel:applicationId:CreateSegment' :: CreateSegment -> 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"]
instance Core.ToQuery CreateSegment where
toQuery :: CreateSegment -> QueryString
toQuery = QueryString -> CreateSegment -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateSegmentResponse = CreateSegmentResponse'
{
CreateSegmentResponse -> Int
httpStatus :: Prelude.Int,
CreateSegmentResponse -> SegmentResponse
segmentResponse :: SegmentResponse
}
deriving (CreateSegmentResponse -> CreateSegmentResponse -> Bool
(CreateSegmentResponse -> CreateSegmentResponse -> Bool)
-> (CreateSegmentResponse -> CreateSegmentResponse -> Bool)
-> Eq CreateSegmentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSegmentResponse -> CreateSegmentResponse -> Bool
$c/= :: CreateSegmentResponse -> CreateSegmentResponse -> Bool
== :: CreateSegmentResponse -> CreateSegmentResponse -> Bool
$c== :: CreateSegmentResponse -> CreateSegmentResponse -> Bool
Prelude.Eq, ReadPrec [CreateSegmentResponse]
ReadPrec CreateSegmentResponse
Int -> ReadS CreateSegmentResponse
ReadS [CreateSegmentResponse]
(Int -> ReadS CreateSegmentResponse)
-> ReadS [CreateSegmentResponse]
-> ReadPrec CreateSegmentResponse
-> ReadPrec [CreateSegmentResponse]
-> Read CreateSegmentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSegmentResponse]
$creadListPrec :: ReadPrec [CreateSegmentResponse]
readPrec :: ReadPrec CreateSegmentResponse
$creadPrec :: ReadPrec CreateSegmentResponse
readList :: ReadS [CreateSegmentResponse]
$creadList :: ReadS [CreateSegmentResponse]
readsPrec :: Int -> ReadS CreateSegmentResponse
$creadsPrec :: Int -> ReadS CreateSegmentResponse
Prelude.Read, Int -> CreateSegmentResponse -> ShowS
[CreateSegmentResponse] -> ShowS
CreateSegmentResponse -> String
(Int -> CreateSegmentResponse -> ShowS)
-> (CreateSegmentResponse -> String)
-> ([CreateSegmentResponse] -> ShowS)
-> Show CreateSegmentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSegmentResponse] -> ShowS
$cshowList :: [CreateSegmentResponse] -> ShowS
show :: CreateSegmentResponse -> String
$cshow :: CreateSegmentResponse -> String
showsPrec :: Int -> CreateSegmentResponse -> ShowS
$cshowsPrec :: Int -> CreateSegmentResponse -> ShowS
Prelude.Show, (forall x. CreateSegmentResponse -> Rep CreateSegmentResponse x)
-> (forall x. Rep CreateSegmentResponse x -> CreateSegmentResponse)
-> Generic CreateSegmentResponse
forall x. Rep CreateSegmentResponse x -> CreateSegmentResponse
forall x. CreateSegmentResponse -> Rep CreateSegmentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSegmentResponse x -> CreateSegmentResponse
$cfrom :: forall x. CreateSegmentResponse -> Rep CreateSegmentResponse x
Prelude.Generic)
newCreateSegmentResponse ::
Prelude.Int ->
SegmentResponse ->
CreateSegmentResponse
newCreateSegmentResponse :: Int -> SegmentResponse -> CreateSegmentResponse
newCreateSegmentResponse
Int
pHttpStatus_
SegmentResponse
pSegmentResponse_ =
CreateSegmentResponse' :: Int -> SegmentResponse -> CreateSegmentResponse
CreateSegmentResponse'
{ $sel:httpStatus:CreateSegmentResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:segmentResponse:CreateSegmentResponse' :: SegmentResponse
segmentResponse = SegmentResponse
pSegmentResponse_
}
createSegmentResponse_httpStatus :: Lens.Lens' CreateSegmentResponse Prelude.Int
createSegmentResponse_httpStatus :: (Int -> f Int) -> CreateSegmentResponse -> f CreateSegmentResponse
createSegmentResponse_httpStatus = (CreateSegmentResponse -> Int)
-> (CreateSegmentResponse -> Int -> CreateSegmentResponse)
-> Lens CreateSegmentResponse CreateSegmentResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSegmentResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateSegmentResponse' :: CreateSegmentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateSegmentResponse
s@CreateSegmentResponse' {} Int
a -> CreateSegmentResponse
s {$sel:httpStatus:CreateSegmentResponse' :: Int
httpStatus = Int
a} :: CreateSegmentResponse)
createSegmentResponse_segmentResponse :: Lens.Lens' CreateSegmentResponse SegmentResponse
createSegmentResponse_segmentResponse :: (SegmentResponse -> f SegmentResponse)
-> CreateSegmentResponse -> f CreateSegmentResponse
createSegmentResponse_segmentResponse = (CreateSegmentResponse -> SegmentResponse)
-> (CreateSegmentResponse
-> SegmentResponse -> CreateSegmentResponse)
-> Lens
CreateSegmentResponse
CreateSegmentResponse
SegmentResponse
SegmentResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSegmentResponse' {SegmentResponse
segmentResponse :: SegmentResponse
$sel:segmentResponse:CreateSegmentResponse' :: CreateSegmentResponse -> SegmentResponse
segmentResponse} -> SegmentResponse
segmentResponse) (\s :: CreateSegmentResponse
s@CreateSegmentResponse' {} SegmentResponse
a -> CreateSegmentResponse
s {$sel:segmentResponse:CreateSegmentResponse' :: SegmentResponse
segmentResponse = SegmentResponse
a} :: CreateSegmentResponse)
instance Prelude.NFData CreateSegmentResponse