{-# 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.GetSegments
(
GetSegments (..),
newGetSegments,
getSegments_token,
getSegments_pageSize,
getSegments_applicationId,
GetSegmentsResponse (..),
newGetSegmentsResponse,
getSegmentsResponse_httpStatus,
getSegmentsResponse_segmentsResponse,
)
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 GetSegments = GetSegments'
{
GetSegments -> Maybe Text
token :: Prelude.Maybe Prelude.Text,
GetSegments -> Maybe Text
pageSize :: Prelude.Maybe Prelude.Text,
GetSegments -> Text
applicationId :: Prelude.Text
}
deriving (GetSegments -> GetSegments -> Bool
(GetSegments -> GetSegments -> Bool)
-> (GetSegments -> GetSegments -> Bool) -> Eq GetSegments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSegments -> GetSegments -> Bool
$c/= :: GetSegments -> GetSegments -> Bool
== :: GetSegments -> GetSegments -> Bool
$c== :: GetSegments -> GetSegments -> Bool
Prelude.Eq, ReadPrec [GetSegments]
ReadPrec GetSegments
Int -> ReadS GetSegments
ReadS [GetSegments]
(Int -> ReadS GetSegments)
-> ReadS [GetSegments]
-> ReadPrec GetSegments
-> ReadPrec [GetSegments]
-> Read GetSegments
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSegments]
$creadListPrec :: ReadPrec [GetSegments]
readPrec :: ReadPrec GetSegments
$creadPrec :: ReadPrec GetSegments
readList :: ReadS [GetSegments]
$creadList :: ReadS [GetSegments]
readsPrec :: Int -> ReadS GetSegments
$creadsPrec :: Int -> ReadS GetSegments
Prelude.Read, Int -> GetSegments -> ShowS
[GetSegments] -> ShowS
GetSegments -> String
(Int -> GetSegments -> ShowS)
-> (GetSegments -> String)
-> ([GetSegments] -> ShowS)
-> Show GetSegments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSegments] -> ShowS
$cshowList :: [GetSegments] -> ShowS
show :: GetSegments -> String
$cshow :: GetSegments -> String
showsPrec :: Int -> GetSegments -> ShowS
$cshowsPrec :: Int -> GetSegments -> ShowS
Prelude.Show, (forall x. GetSegments -> Rep GetSegments x)
-> (forall x. Rep GetSegments x -> GetSegments)
-> Generic GetSegments
forall x. Rep GetSegments x -> GetSegments
forall x. GetSegments -> Rep GetSegments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSegments x -> GetSegments
$cfrom :: forall x. GetSegments -> Rep GetSegments x
Prelude.Generic)
newGetSegments ::
Prelude.Text ->
GetSegments
newGetSegments :: Text -> GetSegments
newGetSegments Text
pApplicationId_ =
GetSegments' :: Maybe Text -> Maybe Text -> Text -> GetSegments
GetSegments'
{ $sel:token:GetSegments' :: Maybe Text
token = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:pageSize:GetSegments' :: Maybe Text
pageSize = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:applicationId:GetSegments' :: Text
applicationId = Text
pApplicationId_
}
getSegments_token :: Lens.Lens' GetSegments (Prelude.Maybe Prelude.Text)
getSegments_token :: (Maybe Text -> f (Maybe Text)) -> GetSegments -> f GetSegments
getSegments_token = (GetSegments -> Maybe Text)
-> (GetSegments -> Maybe Text -> GetSegments)
-> Lens GetSegments GetSegments (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSegments' {Maybe Text
token :: Maybe Text
$sel:token:GetSegments' :: GetSegments -> Maybe Text
token} -> Maybe Text
token) (\s :: GetSegments
s@GetSegments' {} Maybe Text
a -> GetSegments
s {$sel:token:GetSegments' :: Maybe Text
token = Maybe Text
a} :: GetSegments)
getSegments_pageSize :: Lens.Lens' GetSegments (Prelude.Maybe Prelude.Text)
getSegments_pageSize :: (Maybe Text -> f (Maybe Text)) -> GetSegments -> f GetSegments
getSegments_pageSize = (GetSegments -> Maybe Text)
-> (GetSegments -> Maybe Text -> GetSegments)
-> Lens GetSegments GetSegments (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSegments' {Maybe Text
pageSize :: Maybe Text
$sel:pageSize:GetSegments' :: GetSegments -> Maybe Text
pageSize} -> Maybe Text
pageSize) (\s :: GetSegments
s@GetSegments' {} Maybe Text
a -> GetSegments
s {$sel:pageSize:GetSegments' :: Maybe Text
pageSize = Maybe Text
a} :: GetSegments)
getSegments_applicationId :: Lens.Lens' GetSegments Prelude.Text
getSegments_applicationId :: (Text -> f Text) -> GetSegments -> f GetSegments
getSegments_applicationId = (GetSegments -> Text)
-> (GetSegments -> Text -> GetSegments)
-> Lens GetSegments GetSegments Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSegments' {Text
applicationId :: Text
$sel:applicationId:GetSegments' :: GetSegments -> Text
applicationId} -> Text
applicationId) (\s :: GetSegments
s@GetSegments' {} Text
a -> GetSegments
s {$sel:applicationId:GetSegments' :: Text
applicationId = Text
a} :: GetSegments)
instance Core.AWSRequest GetSegments where
type AWSResponse GetSegments = GetSegmentsResponse
request :: GetSegments -> Request GetSegments
request = Service -> GetSegments -> Request GetSegments
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy GetSegments
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSegments)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetSegments))
-> Logger
-> Service
-> Proxy GetSegments
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSegments)))
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 -> SegmentsResponse -> GetSegmentsResponse
GetSegmentsResponse'
(Int -> SegmentsResponse -> GetSegmentsResponse)
-> Either String Int
-> Either String (SegmentsResponse -> GetSegmentsResponse)
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 (SegmentsResponse -> GetSegmentsResponse)
-> Either String SegmentsResponse
-> Either String GetSegmentsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String SegmentsResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
)
instance Prelude.Hashable GetSegments
instance Prelude.NFData GetSegments
instance Core.ToHeaders GetSegments where
toHeaders :: GetSegments -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetSegments -> 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.ToPath GetSegments where
toPath :: GetSegments -> ByteString
toPath GetSegments' {Maybe Text
Text
applicationId :: Text
pageSize :: Maybe Text
token :: Maybe Text
$sel:applicationId:GetSegments' :: GetSegments -> Text
$sel:pageSize:GetSegments' :: GetSegments -> Maybe Text
$sel:token:GetSegments' :: GetSegments -> Maybe 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 GetSegments where
toQuery :: GetSegments -> QueryString
toQuery GetSegments' {Maybe Text
Text
applicationId :: Text
pageSize :: Maybe Text
token :: Maybe Text
$sel:applicationId:GetSegments' :: GetSegments -> Text
$sel:pageSize:GetSegments' :: GetSegments -> Maybe Text
$sel:token:GetSegments' :: GetSegments -> Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"token" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
token, ByteString
"page-size" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
pageSize]
data GetSegmentsResponse = GetSegmentsResponse'
{
GetSegmentsResponse -> Int
httpStatus :: Prelude.Int,
GetSegmentsResponse -> SegmentsResponse
segmentsResponse :: SegmentsResponse
}
deriving (GetSegmentsResponse -> GetSegmentsResponse -> Bool
(GetSegmentsResponse -> GetSegmentsResponse -> Bool)
-> (GetSegmentsResponse -> GetSegmentsResponse -> Bool)
-> Eq GetSegmentsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSegmentsResponse -> GetSegmentsResponse -> Bool
$c/= :: GetSegmentsResponse -> GetSegmentsResponse -> Bool
== :: GetSegmentsResponse -> GetSegmentsResponse -> Bool
$c== :: GetSegmentsResponse -> GetSegmentsResponse -> Bool
Prelude.Eq, ReadPrec [GetSegmentsResponse]
ReadPrec GetSegmentsResponse
Int -> ReadS GetSegmentsResponse
ReadS [GetSegmentsResponse]
(Int -> ReadS GetSegmentsResponse)
-> ReadS [GetSegmentsResponse]
-> ReadPrec GetSegmentsResponse
-> ReadPrec [GetSegmentsResponse]
-> Read GetSegmentsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSegmentsResponse]
$creadListPrec :: ReadPrec [GetSegmentsResponse]
readPrec :: ReadPrec GetSegmentsResponse
$creadPrec :: ReadPrec GetSegmentsResponse
readList :: ReadS [GetSegmentsResponse]
$creadList :: ReadS [GetSegmentsResponse]
readsPrec :: Int -> ReadS GetSegmentsResponse
$creadsPrec :: Int -> ReadS GetSegmentsResponse
Prelude.Read, Int -> GetSegmentsResponse -> ShowS
[GetSegmentsResponse] -> ShowS
GetSegmentsResponse -> String
(Int -> GetSegmentsResponse -> ShowS)
-> (GetSegmentsResponse -> String)
-> ([GetSegmentsResponse] -> ShowS)
-> Show GetSegmentsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSegmentsResponse] -> ShowS
$cshowList :: [GetSegmentsResponse] -> ShowS
show :: GetSegmentsResponse -> String
$cshow :: GetSegmentsResponse -> String
showsPrec :: Int -> GetSegmentsResponse -> ShowS
$cshowsPrec :: Int -> GetSegmentsResponse -> ShowS
Prelude.Show, (forall x. GetSegmentsResponse -> Rep GetSegmentsResponse x)
-> (forall x. Rep GetSegmentsResponse x -> GetSegmentsResponse)
-> Generic GetSegmentsResponse
forall x. Rep GetSegmentsResponse x -> GetSegmentsResponse
forall x. GetSegmentsResponse -> Rep GetSegmentsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSegmentsResponse x -> GetSegmentsResponse
$cfrom :: forall x. GetSegmentsResponse -> Rep GetSegmentsResponse x
Prelude.Generic)
newGetSegmentsResponse ::
Prelude.Int ->
SegmentsResponse ->
GetSegmentsResponse
newGetSegmentsResponse :: Int -> SegmentsResponse -> GetSegmentsResponse
newGetSegmentsResponse
Int
pHttpStatus_
SegmentsResponse
pSegmentsResponse_ =
GetSegmentsResponse' :: Int -> SegmentsResponse -> GetSegmentsResponse
GetSegmentsResponse'
{ $sel:httpStatus:GetSegmentsResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:segmentsResponse:GetSegmentsResponse' :: SegmentsResponse
segmentsResponse = SegmentsResponse
pSegmentsResponse_
}
getSegmentsResponse_httpStatus :: Lens.Lens' GetSegmentsResponse Prelude.Int
getSegmentsResponse_httpStatus :: (Int -> f Int) -> GetSegmentsResponse -> f GetSegmentsResponse
getSegmentsResponse_httpStatus = (GetSegmentsResponse -> Int)
-> (GetSegmentsResponse -> Int -> GetSegmentsResponse)
-> Lens GetSegmentsResponse GetSegmentsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSegmentsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetSegmentsResponse' :: GetSegmentsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetSegmentsResponse
s@GetSegmentsResponse' {} Int
a -> GetSegmentsResponse
s {$sel:httpStatus:GetSegmentsResponse' :: Int
httpStatus = Int
a} :: GetSegmentsResponse)
getSegmentsResponse_segmentsResponse :: Lens.Lens' GetSegmentsResponse SegmentsResponse
getSegmentsResponse_segmentsResponse :: (SegmentsResponse -> f SegmentsResponse)
-> GetSegmentsResponse -> f GetSegmentsResponse
getSegmentsResponse_segmentsResponse = (GetSegmentsResponse -> SegmentsResponse)
-> (GetSegmentsResponse -> SegmentsResponse -> GetSegmentsResponse)
-> Lens
GetSegmentsResponse
GetSegmentsResponse
SegmentsResponse
SegmentsResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSegmentsResponse' {SegmentsResponse
segmentsResponse :: SegmentsResponse
$sel:segmentsResponse:GetSegmentsResponse' :: GetSegmentsResponse -> SegmentsResponse
segmentsResponse} -> SegmentsResponse
segmentsResponse) (\s :: GetSegmentsResponse
s@GetSegmentsResponse' {} SegmentsResponse
a -> GetSegmentsResponse
s {$sel:segmentsResponse:GetSegmentsResponse' :: SegmentsResponse
segmentsResponse = SegmentsResponse
a} :: GetSegmentsResponse)
instance Prelude.NFData GetSegmentsResponse