{-# 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.CognitoSync.RegisterDevice
(
RegisterDevice (..),
newRegisterDevice,
registerDevice_identityPoolId,
registerDevice_identityId,
registerDevice_platform,
registerDevice_token,
RegisterDeviceResponse (..),
newRegisterDeviceResponse,
registerDeviceResponse_deviceId,
registerDeviceResponse_httpStatus,
)
where
import Amazonka.CognitoSync.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data RegisterDevice = RegisterDevice'
{
RegisterDevice -> Text
identityPoolId :: Prelude.Text,
RegisterDevice -> Text
identityId :: Prelude.Text,
RegisterDevice -> Platform
platform :: Platform,
RegisterDevice -> Text
token :: Prelude.Text
}
deriving (RegisterDevice -> RegisterDevice -> Bool
(RegisterDevice -> RegisterDevice -> Bool)
-> (RegisterDevice -> RegisterDevice -> Bool) -> Eq RegisterDevice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterDevice -> RegisterDevice -> Bool
$c/= :: RegisterDevice -> RegisterDevice -> Bool
== :: RegisterDevice -> RegisterDevice -> Bool
$c== :: RegisterDevice -> RegisterDevice -> Bool
Prelude.Eq, ReadPrec [RegisterDevice]
ReadPrec RegisterDevice
Int -> ReadS RegisterDevice
ReadS [RegisterDevice]
(Int -> ReadS RegisterDevice)
-> ReadS [RegisterDevice]
-> ReadPrec RegisterDevice
-> ReadPrec [RegisterDevice]
-> Read RegisterDevice
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterDevice]
$creadListPrec :: ReadPrec [RegisterDevice]
readPrec :: ReadPrec RegisterDevice
$creadPrec :: ReadPrec RegisterDevice
readList :: ReadS [RegisterDevice]
$creadList :: ReadS [RegisterDevice]
readsPrec :: Int -> ReadS RegisterDevice
$creadsPrec :: Int -> ReadS RegisterDevice
Prelude.Read, Int -> RegisterDevice -> ShowS
[RegisterDevice] -> ShowS
RegisterDevice -> String
(Int -> RegisterDevice -> ShowS)
-> (RegisterDevice -> String)
-> ([RegisterDevice] -> ShowS)
-> Show RegisterDevice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterDevice] -> ShowS
$cshowList :: [RegisterDevice] -> ShowS
show :: RegisterDevice -> String
$cshow :: RegisterDevice -> String
showsPrec :: Int -> RegisterDevice -> ShowS
$cshowsPrec :: Int -> RegisterDevice -> ShowS
Prelude.Show, (forall x. RegisterDevice -> Rep RegisterDevice x)
-> (forall x. Rep RegisterDevice x -> RegisterDevice)
-> Generic RegisterDevice
forall x. Rep RegisterDevice x -> RegisterDevice
forall x. RegisterDevice -> Rep RegisterDevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegisterDevice x -> RegisterDevice
$cfrom :: forall x. RegisterDevice -> Rep RegisterDevice x
Prelude.Generic)
newRegisterDevice ::
Prelude.Text ->
Prelude.Text ->
Platform ->
Prelude.Text ->
RegisterDevice
newRegisterDevice :: Text -> Text -> Platform -> Text -> RegisterDevice
newRegisterDevice
Text
pIdentityPoolId_
Text
pIdentityId_
Platform
pPlatform_
Text
pToken_ =
RegisterDevice' :: Text -> Text -> Platform -> Text -> RegisterDevice
RegisterDevice'
{ $sel:identityPoolId:RegisterDevice' :: Text
identityPoolId = Text
pIdentityPoolId_,
$sel:identityId:RegisterDevice' :: Text
identityId = Text
pIdentityId_,
$sel:platform:RegisterDevice' :: Platform
platform = Platform
pPlatform_,
$sel:token:RegisterDevice' :: Text
token = Text
pToken_
}
registerDevice_identityPoolId :: Lens.Lens' RegisterDevice Prelude.Text
registerDevice_identityPoolId :: (Text -> f Text) -> RegisterDevice -> f RegisterDevice
registerDevice_identityPoolId = (RegisterDevice -> Text)
-> (RegisterDevice -> Text -> RegisterDevice)
-> Lens RegisterDevice RegisterDevice Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterDevice' {Text
identityPoolId :: Text
$sel:identityPoolId:RegisterDevice' :: RegisterDevice -> Text
identityPoolId} -> Text
identityPoolId) (\s :: RegisterDevice
s@RegisterDevice' {} Text
a -> RegisterDevice
s {$sel:identityPoolId:RegisterDevice' :: Text
identityPoolId = Text
a} :: RegisterDevice)
registerDevice_identityId :: Lens.Lens' RegisterDevice Prelude.Text
registerDevice_identityId :: (Text -> f Text) -> RegisterDevice -> f RegisterDevice
registerDevice_identityId = (RegisterDevice -> Text)
-> (RegisterDevice -> Text -> RegisterDevice)
-> Lens RegisterDevice RegisterDevice Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterDevice' {Text
identityId :: Text
$sel:identityId:RegisterDevice' :: RegisterDevice -> Text
identityId} -> Text
identityId) (\s :: RegisterDevice
s@RegisterDevice' {} Text
a -> RegisterDevice
s {$sel:identityId:RegisterDevice' :: Text
identityId = Text
a} :: RegisterDevice)
registerDevice_platform :: Lens.Lens' RegisterDevice Platform
registerDevice_platform :: (Platform -> f Platform) -> RegisterDevice -> f RegisterDevice
registerDevice_platform = (RegisterDevice -> Platform)
-> (RegisterDevice -> Platform -> RegisterDevice)
-> Lens RegisterDevice RegisterDevice Platform Platform
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterDevice' {Platform
platform :: Platform
$sel:platform:RegisterDevice' :: RegisterDevice -> Platform
platform} -> Platform
platform) (\s :: RegisterDevice
s@RegisterDevice' {} Platform
a -> RegisterDevice
s {$sel:platform:RegisterDevice' :: Platform
platform = Platform
a} :: RegisterDevice)
registerDevice_token :: Lens.Lens' RegisterDevice Prelude.Text
registerDevice_token :: (Text -> f Text) -> RegisterDevice -> f RegisterDevice
registerDevice_token = (RegisterDevice -> Text)
-> (RegisterDevice -> Text -> RegisterDevice)
-> Lens RegisterDevice RegisterDevice Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterDevice' {Text
token :: Text
$sel:token:RegisterDevice' :: RegisterDevice -> Text
token} -> Text
token) (\s :: RegisterDevice
s@RegisterDevice' {} Text
a -> RegisterDevice
s {$sel:token:RegisterDevice' :: Text
token = Text
a} :: RegisterDevice)
instance Core.AWSRequest RegisterDevice where
type
AWSResponse RegisterDevice =
RegisterDeviceResponse
request :: RegisterDevice -> Request RegisterDevice
request = Service -> RegisterDevice -> Request RegisterDevice
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy RegisterDevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RegisterDevice)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse RegisterDevice))
-> Logger
-> Service
-> Proxy RegisterDevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RegisterDevice)))
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 ->
Maybe Text -> Int -> RegisterDeviceResponse
RegisterDeviceResponse'
(Maybe Text -> Int -> RegisterDeviceResponse)
-> Either String (Maybe Text)
-> Either String (Int -> RegisterDeviceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DeviceId")
Either String (Int -> RegisterDeviceResponse)
-> Either String Int -> Either String RegisterDeviceResponse
forall (f :: * -> *) a b. Applicative f => 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))
)
instance Prelude.Hashable RegisterDevice
instance Prelude.NFData RegisterDevice
instance Core.ToHeaders RegisterDevice where
toHeaders :: RegisterDevice -> ResponseHeaders
toHeaders =
ResponseHeaders -> RegisterDevice -> 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 RegisterDevice where
toJSON :: RegisterDevice -> Value
toJSON RegisterDevice' {Text
Platform
token :: Text
platform :: Platform
identityId :: Text
identityPoolId :: Text
$sel:token:RegisterDevice' :: RegisterDevice -> Text
$sel:platform:RegisterDevice' :: RegisterDevice -> Platform
$sel:identityId:RegisterDevice' :: RegisterDevice -> Text
$sel:identityPoolId:RegisterDevice' :: RegisterDevice -> 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
"Platform" Text -> Platform -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Platform
platform),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Token" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
token)
]
)
instance Core.ToPath RegisterDevice where
toPath :: RegisterDevice -> ByteString
toPath RegisterDevice' {Text
Platform
token :: Text
platform :: Platform
identityId :: Text
identityPoolId :: Text
$sel:token:RegisterDevice' :: RegisterDevice -> Text
$sel:platform:RegisterDevice' :: RegisterDevice -> Platform
$sel:identityId:RegisterDevice' :: RegisterDevice -> Text
$sel:identityPoolId:RegisterDevice' :: RegisterDevice -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/identitypools/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
identityPoolId,
ByteString
"/identity/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
identityId,
ByteString
"/device"
]
instance Core.ToQuery RegisterDevice where
toQuery :: RegisterDevice -> QueryString
toQuery = QueryString -> RegisterDevice -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data RegisterDeviceResponse = RegisterDeviceResponse'
{
RegisterDeviceResponse -> Maybe Text
deviceId :: Prelude.Maybe Prelude.Text,
RegisterDeviceResponse -> Int
httpStatus :: Prelude.Int
}
deriving (RegisterDeviceResponse -> RegisterDeviceResponse -> Bool
(RegisterDeviceResponse -> RegisterDeviceResponse -> Bool)
-> (RegisterDeviceResponse -> RegisterDeviceResponse -> Bool)
-> Eq RegisterDeviceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterDeviceResponse -> RegisterDeviceResponse -> Bool
$c/= :: RegisterDeviceResponse -> RegisterDeviceResponse -> Bool
== :: RegisterDeviceResponse -> RegisterDeviceResponse -> Bool
$c== :: RegisterDeviceResponse -> RegisterDeviceResponse -> Bool
Prelude.Eq, ReadPrec [RegisterDeviceResponse]
ReadPrec RegisterDeviceResponse
Int -> ReadS RegisterDeviceResponse
ReadS [RegisterDeviceResponse]
(Int -> ReadS RegisterDeviceResponse)
-> ReadS [RegisterDeviceResponse]
-> ReadPrec RegisterDeviceResponse
-> ReadPrec [RegisterDeviceResponse]
-> Read RegisterDeviceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterDeviceResponse]
$creadListPrec :: ReadPrec [RegisterDeviceResponse]
readPrec :: ReadPrec RegisterDeviceResponse
$creadPrec :: ReadPrec RegisterDeviceResponse
readList :: ReadS [RegisterDeviceResponse]
$creadList :: ReadS [RegisterDeviceResponse]
readsPrec :: Int -> ReadS RegisterDeviceResponse
$creadsPrec :: Int -> ReadS RegisterDeviceResponse
Prelude.Read, Int -> RegisterDeviceResponse -> ShowS
[RegisterDeviceResponse] -> ShowS
RegisterDeviceResponse -> String
(Int -> RegisterDeviceResponse -> ShowS)
-> (RegisterDeviceResponse -> String)
-> ([RegisterDeviceResponse] -> ShowS)
-> Show RegisterDeviceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterDeviceResponse] -> ShowS
$cshowList :: [RegisterDeviceResponse] -> ShowS
show :: RegisterDeviceResponse -> String
$cshow :: RegisterDeviceResponse -> String
showsPrec :: Int -> RegisterDeviceResponse -> ShowS
$cshowsPrec :: Int -> RegisterDeviceResponse -> ShowS
Prelude.Show, (forall x. RegisterDeviceResponse -> Rep RegisterDeviceResponse x)
-> (forall x.
Rep RegisterDeviceResponse x -> RegisterDeviceResponse)
-> Generic RegisterDeviceResponse
forall x. Rep RegisterDeviceResponse x -> RegisterDeviceResponse
forall x. RegisterDeviceResponse -> Rep RegisterDeviceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegisterDeviceResponse x -> RegisterDeviceResponse
$cfrom :: forall x. RegisterDeviceResponse -> Rep RegisterDeviceResponse x
Prelude.Generic)
newRegisterDeviceResponse ::
Prelude.Int ->
RegisterDeviceResponse
newRegisterDeviceResponse :: Int -> RegisterDeviceResponse
newRegisterDeviceResponse Int
pHttpStatus_ =
RegisterDeviceResponse' :: Maybe Text -> Int -> RegisterDeviceResponse
RegisterDeviceResponse'
{ $sel:deviceId:RegisterDeviceResponse' :: Maybe Text
deviceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:RegisterDeviceResponse' :: Int
httpStatus = Int
pHttpStatus_
}
registerDeviceResponse_deviceId :: Lens.Lens' RegisterDeviceResponse (Prelude.Maybe Prelude.Text)
registerDeviceResponse_deviceId :: (Maybe Text -> f (Maybe Text))
-> RegisterDeviceResponse -> f RegisterDeviceResponse
registerDeviceResponse_deviceId = (RegisterDeviceResponse -> Maybe Text)
-> (RegisterDeviceResponse -> Maybe Text -> RegisterDeviceResponse)
-> Lens
RegisterDeviceResponse
RegisterDeviceResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterDeviceResponse' {Maybe Text
deviceId :: Maybe Text
$sel:deviceId:RegisterDeviceResponse' :: RegisterDeviceResponse -> Maybe Text
deviceId} -> Maybe Text
deviceId) (\s :: RegisterDeviceResponse
s@RegisterDeviceResponse' {} Maybe Text
a -> RegisterDeviceResponse
s {$sel:deviceId:RegisterDeviceResponse' :: Maybe Text
deviceId = Maybe Text
a} :: RegisterDeviceResponse)
registerDeviceResponse_httpStatus :: Lens.Lens' RegisterDeviceResponse Prelude.Int
registerDeviceResponse_httpStatus :: (Int -> f Int)
-> RegisterDeviceResponse -> f RegisterDeviceResponse
registerDeviceResponse_httpStatus = (RegisterDeviceResponse -> Int)
-> (RegisterDeviceResponse -> Int -> RegisterDeviceResponse)
-> Lens RegisterDeviceResponse RegisterDeviceResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterDeviceResponse' {Int
httpStatus :: Int
$sel:httpStatus:RegisterDeviceResponse' :: RegisterDeviceResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: RegisterDeviceResponse
s@RegisterDeviceResponse' {} Int
a -> RegisterDeviceResponse
s {$sel:httpStatus:RegisterDeviceResponse' :: Int
httpStatus = Int
a} :: RegisterDeviceResponse)
instance Prelude.NFData RegisterDeviceResponse