{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $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 :: Lens' RegisterDevice Text
registerDevice_identityPoolId = 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 :: Lens' RegisterDevice Text
registerDevice_identityId = 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 :: Lens' RegisterDevice Platform
registerDevice_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 :: Lens' RegisterDevice Text
registerDevice_token = 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 :: (Service -> Service) -> RegisterDevice -> Request RegisterDevice
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy RegisterDevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RegisterDevice)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text -> Int -> RegisterDeviceResponse
RegisterDeviceResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"DeviceId")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable RegisterDevice where
hashWithSalt :: Int -> RegisterDevice -> Int
hashWithSalt Int
_salt 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
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
identityPoolId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
identityId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Platform
platform
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
token
instance Prelude.NFData RegisterDevice where
rnf :: RegisterDevice -> ()
rnf 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
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
identityPoolId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
identityId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Platform
platform
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
token
instance Data.ToHeaders RegisterDevice where
toHeaders :: RegisterDevice -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"Platform" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Platform
platform),
forall a. a -> Maybe a
Prelude.Just (Key
"Token" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
token)
]
)
instance Data.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
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/identitypools/",
forall a. ToByteString a => a -> ByteString
Data.toBS Text
identityPoolId,
ByteString
"/identity/",
forall a. ToByteString a => a -> ByteString
Data.toBS Text
identityId,
ByteString
"/device"
]
instance Data.ToQuery RegisterDevice where
toQuery :: RegisterDevice -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
{ $sel:deviceId:RegisterDeviceResponse' :: Maybe Text
deviceId = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:RegisterDeviceResponse' :: Int
httpStatus = Int
pHttpStatus_
}
registerDeviceResponse_deviceId :: Lens.Lens' RegisterDeviceResponse (Prelude.Maybe Prelude.Text)
registerDeviceResponse_deviceId :: Lens' RegisterDeviceResponse (Maybe Text)
registerDeviceResponse_deviceId = 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 :: Lens' RegisterDeviceResponse Int
registerDeviceResponse_httpStatus = 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 where
rnf :: RegisterDeviceResponse -> ()
rnf RegisterDeviceResponse' {Int
Maybe Text
httpStatus :: Int
deviceId :: Maybe Text
$sel:httpStatus:RegisterDeviceResponse' :: RegisterDeviceResponse -> Int
$sel:deviceId:RegisterDeviceResponse' :: RegisterDeviceResponse -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
deviceId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus