{-# 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.CognitoIdentityProvider.ConfirmDevice
(
ConfirmDevice (..),
newConfirmDevice,
confirmDevice_deviceSecretVerifierConfig,
confirmDevice_deviceName,
confirmDevice_accessToken,
confirmDevice_deviceKey,
ConfirmDeviceResponse (..),
newConfirmDeviceResponse,
confirmDeviceResponse_userConfirmationNecessary,
confirmDeviceResponse_httpStatus,
)
where
import Amazonka.CognitoIdentityProvider.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 ConfirmDevice = ConfirmDevice'
{
ConfirmDevice -> Maybe DeviceSecretVerifierConfigType
deviceSecretVerifierConfig :: Prelude.Maybe DeviceSecretVerifierConfigType,
ConfirmDevice -> Maybe Text
deviceName :: Prelude.Maybe Prelude.Text,
ConfirmDevice -> Sensitive Text
accessToken :: Core.Sensitive Prelude.Text,
ConfirmDevice -> Text
deviceKey :: Prelude.Text
}
deriving (ConfirmDevice -> ConfirmDevice -> Bool
(ConfirmDevice -> ConfirmDevice -> Bool)
-> (ConfirmDevice -> ConfirmDevice -> Bool) -> Eq ConfirmDevice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfirmDevice -> ConfirmDevice -> Bool
$c/= :: ConfirmDevice -> ConfirmDevice -> Bool
== :: ConfirmDevice -> ConfirmDevice -> Bool
$c== :: ConfirmDevice -> ConfirmDevice -> Bool
Prelude.Eq, Int -> ConfirmDevice -> ShowS
[ConfirmDevice] -> ShowS
ConfirmDevice -> String
(Int -> ConfirmDevice -> ShowS)
-> (ConfirmDevice -> String)
-> ([ConfirmDevice] -> ShowS)
-> Show ConfirmDevice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfirmDevice] -> ShowS
$cshowList :: [ConfirmDevice] -> ShowS
show :: ConfirmDevice -> String
$cshow :: ConfirmDevice -> String
showsPrec :: Int -> ConfirmDevice -> ShowS
$cshowsPrec :: Int -> ConfirmDevice -> ShowS
Prelude.Show, (forall x. ConfirmDevice -> Rep ConfirmDevice x)
-> (forall x. Rep ConfirmDevice x -> ConfirmDevice)
-> Generic ConfirmDevice
forall x. Rep ConfirmDevice x -> ConfirmDevice
forall x. ConfirmDevice -> Rep ConfirmDevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfirmDevice x -> ConfirmDevice
$cfrom :: forall x. ConfirmDevice -> Rep ConfirmDevice x
Prelude.Generic)
newConfirmDevice ::
Prelude.Text ->
Prelude.Text ->
ConfirmDevice
newConfirmDevice :: Text -> Text -> ConfirmDevice
newConfirmDevice Text
pAccessToken_ Text
pDeviceKey_ =
ConfirmDevice' :: Maybe DeviceSecretVerifierConfigType
-> Maybe Text -> Sensitive Text -> Text -> ConfirmDevice
ConfirmDevice'
{ $sel:deviceSecretVerifierConfig:ConfirmDevice' :: Maybe DeviceSecretVerifierConfigType
deviceSecretVerifierConfig =
Maybe DeviceSecretVerifierConfigType
forall a. Maybe a
Prelude.Nothing,
$sel:deviceName:ConfirmDevice' :: Maybe Text
deviceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:accessToken:ConfirmDevice' :: Sensitive Text
accessToken = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pAccessToken_,
$sel:deviceKey:ConfirmDevice' :: Text
deviceKey = Text
pDeviceKey_
}
confirmDevice_deviceSecretVerifierConfig :: Lens.Lens' ConfirmDevice (Prelude.Maybe DeviceSecretVerifierConfigType)
confirmDevice_deviceSecretVerifierConfig :: (Maybe DeviceSecretVerifierConfigType
-> f (Maybe DeviceSecretVerifierConfigType))
-> ConfirmDevice -> f ConfirmDevice
confirmDevice_deviceSecretVerifierConfig = (ConfirmDevice -> Maybe DeviceSecretVerifierConfigType)
-> (ConfirmDevice
-> Maybe DeviceSecretVerifierConfigType -> ConfirmDevice)
-> Lens
ConfirmDevice
ConfirmDevice
(Maybe DeviceSecretVerifierConfigType)
(Maybe DeviceSecretVerifierConfigType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfirmDevice' {Maybe DeviceSecretVerifierConfigType
deviceSecretVerifierConfig :: Maybe DeviceSecretVerifierConfigType
$sel:deviceSecretVerifierConfig:ConfirmDevice' :: ConfirmDevice -> Maybe DeviceSecretVerifierConfigType
deviceSecretVerifierConfig} -> Maybe DeviceSecretVerifierConfigType
deviceSecretVerifierConfig) (\s :: ConfirmDevice
s@ConfirmDevice' {} Maybe DeviceSecretVerifierConfigType
a -> ConfirmDevice
s {$sel:deviceSecretVerifierConfig:ConfirmDevice' :: Maybe DeviceSecretVerifierConfigType
deviceSecretVerifierConfig = Maybe DeviceSecretVerifierConfigType
a} :: ConfirmDevice)
confirmDevice_deviceName :: Lens.Lens' ConfirmDevice (Prelude.Maybe Prelude.Text)
confirmDevice_deviceName :: (Maybe Text -> f (Maybe Text)) -> ConfirmDevice -> f ConfirmDevice
confirmDevice_deviceName = (ConfirmDevice -> Maybe Text)
-> (ConfirmDevice -> Maybe Text -> ConfirmDevice)
-> Lens ConfirmDevice ConfirmDevice (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfirmDevice' {Maybe Text
deviceName :: Maybe Text
$sel:deviceName:ConfirmDevice' :: ConfirmDevice -> Maybe Text
deviceName} -> Maybe Text
deviceName) (\s :: ConfirmDevice
s@ConfirmDevice' {} Maybe Text
a -> ConfirmDevice
s {$sel:deviceName:ConfirmDevice' :: Maybe Text
deviceName = Maybe Text
a} :: ConfirmDevice)
confirmDevice_accessToken :: Lens.Lens' ConfirmDevice Prelude.Text
confirmDevice_accessToken :: (Text -> f Text) -> ConfirmDevice -> f ConfirmDevice
confirmDevice_accessToken = (ConfirmDevice -> Sensitive Text)
-> (ConfirmDevice -> Sensitive Text -> ConfirmDevice)
-> Lens
ConfirmDevice ConfirmDevice (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfirmDevice' {Sensitive Text
accessToken :: Sensitive Text
$sel:accessToken:ConfirmDevice' :: ConfirmDevice -> Sensitive Text
accessToken} -> Sensitive Text
accessToken) (\s :: ConfirmDevice
s@ConfirmDevice' {} Sensitive Text
a -> ConfirmDevice
s {$sel:accessToken:ConfirmDevice' :: Sensitive Text
accessToken = Sensitive Text
a} :: ConfirmDevice) ((Sensitive Text -> f (Sensitive Text))
-> ConfirmDevice -> f ConfirmDevice)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> ConfirmDevice
-> f ConfirmDevice
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive
confirmDevice_deviceKey :: Lens.Lens' ConfirmDevice Prelude.Text
confirmDevice_deviceKey :: (Text -> f Text) -> ConfirmDevice -> f ConfirmDevice
confirmDevice_deviceKey = (ConfirmDevice -> Text)
-> (ConfirmDevice -> Text -> ConfirmDevice)
-> Lens ConfirmDevice ConfirmDevice Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfirmDevice' {Text
deviceKey :: Text
$sel:deviceKey:ConfirmDevice' :: ConfirmDevice -> Text
deviceKey} -> Text
deviceKey) (\s :: ConfirmDevice
s@ConfirmDevice' {} Text
a -> ConfirmDevice
s {$sel:deviceKey:ConfirmDevice' :: Text
deviceKey = Text
a} :: ConfirmDevice)
instance Core.AWSRequest ConfirmDevice where
type
AWSResponse ConfirmDevice =
ConfirmDeviceResponse
request :: ConfirmDevice -> Request ConfirmDevice
request = Service -> ConfirmDevice -> Request ConfirmDevice
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy ConfirmDevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ConfirmDevice)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse ConfirmDevice))
-> Logger
-> Service
-> Proxy ConfirmDevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ConfirmDevice)))
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 Bool -> Int -> ConfirmDeviceResponse
ConfirmDeviceResponse'
(Maybe Bool -> Int -> ConfirmDeviceResponse)
-> Either String (Maybe Bool)
-> Either String (Int -> ConfirmDeviceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"UserConfirmationNecessary")
Either String (Int -> ConfirmDeviceResponse)
-> Either String Int -> Either String ConfirmDeviceResponse
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 ConfirmDevice
instance Prelude.NFData ConfirmDevice
instance Core.ToHeaders ConfirmDevice where
toHeaders :: ConfirmDevice -> ResponseHeaders
toHeaders =
ResponseHeaders -> ConfirmDevice -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSCognitoIdentityProviderService.ConfirmDevice" ::
Prelude.ByteString
),
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 ConfirmDevice where
toJSON :: ConfirmDevice -> Value
toJSON ConfirmDevice' {Maybe Text
Maybe DeviceSecretVerifierConfigType
Text
Sensitive Text
deviceKey :: Text
accessToken :: Sensitive Text
deviceName :: Maybe Text
deviceSecretVerifierConfig :: Maybe DeviceSecretVerifierConfigType
$sel:deviceKey:ConfirmDevice' :: ConfirmDevice -> Text
$sel:accessToken:ConfirmDevice' :: ConfirmDevice -> Sensitive Text
$sel:deviceName:ConfirmDevice' :: ConfirmDevice -> Maybe Text
$sel:deviceSecretVerifierConfig:ConfirmDevice' :: ConfirmDevice -> Maybe DeviceSecretVerifierConfigType
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"DeviceSecretVerifierConfig" Text -> DeviceSecretVerifierConfigType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(DeviceSecretVerifierConfigType -> Pair)
-> Maybe DeviceSecretVerifierConfigType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeviceSecretVerifierConfigType
deviceSecretVerifierConfig,
(Text
"DeviceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
deviceName,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AccessToken" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
accessToken),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DeviceKey" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
deviceKey)
]
)
instance Core.ToPath ConfirmDevice where
toPath :: ConfirmDevice -> ByteString
toPath = ByteString -> ConfirmDevice -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery ConfirmDevice where
toQuery :: ConfirmDevice -> QueryString
toQuery = QueryString -> ConfirmDevice -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data ConfirmDeviceResponse = ConfirmDeviceResponse'
{
ConfirmDeviceResponse -> Maybe Bool
userConfirmationNecessary :: Prelude.Maybe Prelude.Bool,
ConfirmDeviceResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ConfirmDeviceResponse -> ConfirmDeviceResponse -> Bool
(ConfirmDeviceResponse -> ConfirmDeviceResponse -> Bool)
-> (ConfirmDeviceResponse -> ConfirmDeviceResponse -> Bool)
-> Eq ConfirmDeviceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfirmDeviceResponse -> ConfirmDeviceResponse -> Bool
$c/= :: ConfirmDeviceResponse -> ConfirmDeviceResponse -> Bool
== :: ConfirmDeviceResponse -> ConfirmDeviceResponse -> Bool
$c== :: ConfirmDeviceResponse -> ConfirmDeviceResponse -> Bool
Prelude.Eq, ReadPrec [ConfirmDeviceResponse]
ReadPrec ConfirmDeviceResponse
Int -> ReadS ConfirmDeviceResponse
ReadS [ConfirmDeviceResponse]
(Int -> ReadS ConfirmDeviceResponse)
-> ReadS [ConfirmDeviceResponse]
-> ReadPrec ConfirmDeviceResponse
-> ReadPrec [ConfirmDeviceResponse]
-> Read ConfirmDeviceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfirmDeviceResponse]
$creadListPrec :: ReadPrec [ConfirmDeviceResponse]
readPrec :: ReadPrec ConfirmDeviceResponse
$creadPrec :: ReadPrec ConfirmDeviceResponse
readList :: ReadS [ConfirmDeviceResponse]
$creadList :: ReadS [ConfirmDeviceResponse]
readsPrec :: Int -> ReadS ConfirmDeviceResponse
$creadsPrec :: Int -> ReadS ConfirmDeviceResponse
Prelude.Read, Int -> ConfirmDeviceResponse -> ShowS
[ConfirmDeviceResponse] -> ShowS
ConfirmDeviceResponse -> String
(Int -> ConfirmDeviceResponse -> ShowS)
-> (ConfirmDeviceResponse -> String)
-> ([ConfirmDeviceResponse] -> ShowS)
-> Show ConfirmDeviceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfirmDeviceResponse] -> ShowS
$cshowList :: [ConfirmDeviceResponse] -> ShowS
show :: ConfirmDeviceResponse -> String
$cshow :: ConfirmDeviceResponse -> String
showsPrec :: Int -> ConfirmDeviceResponse -> ShowS
$cshowsPrec :: Int -> ConfirmDeviceResponse -> ShowS
Prelude.Show, (forall x. ConfirmDeviceResponse -> Rep ConfirmDeviceResponse x)
-> (forall x. Rep ConfirmDeviceResponse x -> ConfirmDeviceResponse)
-> Generic ConfirmDeviceResponse
forall x. Rep ConfirmDeviceResponse x -> ConfirmDeviceResponse
forall x. ConfirmDeviceResponse -> Rep ConfirmDeviceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfirmDeviceResponse x -> ConfirmDeviceResponse
$cfrom :: forall x. ConfirmDeviceResponse -> Rep ConfirmDeviceResponse x
Prelude.Generic)
newConfirmDeviceResponse ::
Prelude.Int ->
ConfirmDeviceResponse
newConfirmDeviceResponse :: Int -> ConfirmDeviceResponse
newConfirmDeviceResponse Int
pHttpStatus_ =
ConfirmDeviceResponse' :: Maybe Bool -> Int -> ConfirmDeviceResponse
ConfirmDeviceResponse'
{ $sel:userConfirmationNecessary:ConfirmDeviceResponse' :: Maybe Bool
userConfirmationNecessary =
Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ConfirmDeviceResponse' :: Int
httpStatus = Int
pHttpStatus_
}
confirmDeviceResponse_userConfirmationNecessary :: Lens.Lens' ConfirmDeviceResponse (Prelude.Maybe Prelude.Bool)
confirmDeviceResponse_userConfirmationNecessary :: (Maybe Bool -> f (Maybe Bool))
-> ConfirmDeviceResponse -> f ConfirmDeviceResponse
confirmDeviceResponse_userConfirmationNecessary = (ConfirmDeviceResponse -> Maybe Bool)
-> (ConfirmDeviceResponse -> Maybe Bool -> ConfirmDeviceResponse)
-> Lens
ConfirmDeviceResponse
ConfirmDeviceResponse
(Maybe Bool)
(Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfirmDeviceResponse' {Maybe Bool
userConfirmationNecessary :: Maybe Bool
$sel:userConfirmationNecessary:ConfirmDeviceResponse' :: ConfirmDeviceResponse -> Maybe Bool
userConfirmationNecessary} -> Maybe Bool
userConfirmationNecessary) (\s :: ConfirmDeviceResponse
s@ConfirmDeviceResponse' {} Maybe Bool
a -> ConfirmDeviceResponse
s {$sel:userConfirmationNecessary:ConfirmDeviceResponse' :: Maybe Bool
userConfirmationNecessary = Maybe Bool
a} :: ConfirmDeviceResponse)
confirmDeviceResponse_httpStatus :: Lens.Lens' ConfirmDeviceResponse Prelude.Int
confirmDeviceResponse_httpStatus :: (Int -> f Int) -> ConfirmDeviceResponse -> f ConfirmDeviceResponse
confirmDeviceResponse_httpStatus = (ConfirmDeviceResponse -> Int)
-> (ConfirmDeviceResponse -> Int -> ConfirmDeviceResponse)
-> Lens ConfirmDeviceResponse ConfirmDeviceResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfirmDeviceResponse' {Int
httpStatus :: Int
$sel:httpStatus:ConfirmDeviceResponse' :: ConfirmDeviceResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ConfirmDeviceResponse
s@ConfirmDeviceResponse' {} Int
a -> ConfirmDeviceResponse
s {$sel:httpStatus:ConfirmDeviceResponse' :: Int
httpStatus = Int
a} :: ConfirmDeviceResponse)
instance Prelude.NFData ConfirmDeviceResponse