{-# 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.AmplifyBackend.GetToken
(
GetToken (..),
newGetToken,
getToken_sessionId,
getToken_appId,
GetTokenResponse (..),
newGetTokenResponse,
getTokenResponse_ttl,
getTokenResponse_appId,
getTokenResponse_sessionId,
getTokenResponse_challengeCode,
getTokenResponse_httpStatus,
)
where
import Amazonka.AmplifyBackend.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 GetToken = GetToken'
{
GetToken -> Text
sessionId :: Prelude.Text,
GetToken -> Text
appId :: Prelude.Text
}
deriving (GetToken -> GetToken -> Bool
(GetToken -> GetToken -> Bool)
-> (GetToken -> GetToken -> Bool) -> Eq GetToken
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetToken -> GetToken -> Bool
$c/= :: GetToken -> GetToken -> Bool
== :: GetToken -> GetToken -> Bool
$c== :: GetToken -> GetToken -> Bool
Prelude.Eq, ReadPrec [GetToken]
ReadPrec GetToken
Int -> ReadS GetToken
ReadS [GetToken]
(Int -> ReadS GetToken)
-> ReadS [GetToken]
-> ReadPrec GetToken
-> ReadPrec [GetToken]
-> Read GetToken
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetToken]
$creadListPrec :: ReadPrec [GetToken]
readPrec :: ReadPrec GetToken
$creadPrec :: ReadPrec GetToken
readList :: ReadS [GetToken]
$creadList :: ReadS [GetToken]
readsPrec :: Int -> ReadS GetToken
$creadsPrec :: Int -> ReadS GetToken
Prelude.Read, Int -> GetToken -> ShowS
[GetToken] -> ShowS
GetToken -> String
(Int -> GetToken -> ShowS)
-> (GetToken -> String) -> ([GetToken] -> ShowS) -> Show GetToken
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetToken] -> ShowS
$cshowList :: [GetToken] -> ShowS
show :: GetToken -> String
$cshow :: GetToken -> String
showsPrec :: Int -> GetToken -> ShowS
$cshowsPrec :: Int -> GetToken -> ShowS
Prelude.Show, (forall x. GetToken -> Rep GetToken x)
-> (forall x. Rep GetToken x -> GetToken) -> Generic GetToken
forall x. Rep GetToken x -> GetToken
forall x. GetToken -> Rep GetToken x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetToken x -> GetToken
$cfrom :: forall x. GetToken -> Rep GetToken x
Prelude.Generic)
newGetToken ::
Prelude.Text ->
Prelude.Text ->
GetToken
newGetToken :: Text -> Text -> GetToken
newGetToken Text
pSessionId_ Text
pAppId_ =
GetToken' :: Text -> Text -> GetToken
GetToken' {$sel:sessionId:GetToken' :: Text
sessionId = Text
pSessionId_, $sel:appId:GetToken' :: Text
appId = Text
pAppId_}
getToken_sessionId :: Lens.Lens' GetToken Prelude.Text
getToken_sessionId :: (Text -> f Text) -> GetToken -> f GetToken
getToken_sessionId = (GetToken -> Text)
-> (GetToken -> Text -> GetToken)
-> Lens GetToken GetToken Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetToken' {Text
sessionId :: Text
$sel:sessionId:GetToken' :: GetToken -> Text
sessionId} -> Text
sessionId) (\s :: GetToken
s@GetToken' {} Text
a -> GetToken
s {$sel:sessionId:GetToken' :: Text
sessionId = Text
a} :: GetToken)
getToken_appId :: Lens.Lens' GetToken Prelude.Text
getToken_appId :: (Text -> f Text) -> GetToken -> f GetToken
getToken_appId = (GetToken -> Text)
-> (GetToken -> Text -> GetToken)
-> Lens GetToken GetToken Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetToken' {Text
appId :: Text
$sel:appId:GetToken' :: GetToken -> Text
appId} -> Text
appId) (\s :: GetToken
s@GetToken' {} Text
a -> GetToken
s {$sel:appId:GetToken' :: Text
appId = Text
a} :: GetToken)
instance Core.AWSRequest GetToken where
type AWSResponse GetToken = GetTokenResponse
request :: GetToken -> Request GetToken
request = Service -> GetToken -> Request GetToken
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy GetToken
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetToken)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetToken))
-> Logger
-> Service
-> Proxy GetToken
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetToken)))
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
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> GetTokenResponse
GetTokenResponse'
(Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> GetTokenResponse)
-> Either String (Maybe Text)
-> Either
String
(Maybe Text -> Maybe Text -> Maybe Text -> Int -> GetTokenResponse)
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
"ttl")
Either
String
(Maybe Text -> Maybe Text -> Maybe Text -> Int -> GetTokenResponse)
-> Either String (Maybe Text)
-> Either
String (Maybe Text -> Maybe Text -> Int -> GetTokenResponse)
forall (f :: * -> *) a b. Applicative f => 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
"appId")
Either String (Maybe Text -> Maybe Text -> Int -> GetTokenResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> GetTokenResponse)
forall (f :: * -> *) a b. Applicative f => 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
"sessionId")
Either String (Maybe Text -> Int -> GetTokenResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetTokenResponse)
forall (f :: * -> *) a b. Applicative f => 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
"challengeCode")
Either String (Int -> GetTokenResponse)
-> Either String Int -> Either String GetTokenResponse
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 GetToken
instance Prelude.NFData GetToken
instance Core.ToHeaders GetToken where
toHeaders :: GetToken -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetToken -> 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 GetToken where
toPath :: GetToken -> ByteString
toPath GetToken' {Text
appId :: Text
sessionId :: Text
$sel:appId:GetToken' :: GetToken -> Text
$sel:sessionId:GetToken' :: GetToken -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/backend/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
appId,
ByteString
"/challenge/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
sessionId
]
instance Core.ToQuery GetToken where
toQuery :: GetToken -> QueryString
toQuery = QueryString -> GetToken -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetTokenResponse = GetTokenResponse'
{
GetTokenResponse -> Maybe Text
ttl :: Prelude.Maybe Prelude.Text,
GetTokenResponse -> Maybe Text
appId :: Prelude.Maybe Prelude.Text,
GetTokenResponse -> Maybe Text
sessionId :: Prelude.Maybe Prelude.Text,
GetTokenResponse -> Maybe Text
challengeCode :: Prelude.Maybe Prelude.Text,
GetTokenResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetTokenResponse -> GetTokenResponse -> Bool
(GetTokenResponse -> GetTokenResponse -> Bool)
-> (GetTokenResponse -> GetTokenResponse -> Bool)
-> Eq GetTokenResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTokenResponse -> GetTokenResponse -> Bool
$c/= :: GetTokenResponse -> GetTokenResponse -> Bool
== :: GetTokenResponse -> GetTokenResponse -> Bool
$c== :: GetTokenResponse -> GetTokenResponse -> Bool
Prelude.Eq, ReadPrec [GetTokenResponse]
ReadPrec GetTokenResponse
Int -> ReadS GetTokenResponse
ReadS [GetTokenResponse]
(Int -> ReadS GetTokenResponse)
-> ReadS [GetTokenResponse]
-> ReadPrec GetTokenResponse
-> ReadPrec [GetTokenResponse]
-> Read GetTokenResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTokenResponse]
$creadListPrec :: ReadPrec [GetTokenResponse]
readPrec :: ReadPrec GetTokenResponse
$creadPrec :: ReadPrec GetTokenResponse
readList :: ReadS [GetTokenResponse]
$creadList :: ReadS [GetTokenResponse]
readsPrec :: Int -> ReadS GetTokenResponse
$creadsPrec :: Int -> ReadS GetTokenResponse
Prelude.Read, Int -> GetTokenResponse -> ShowS
[GetTokenResponse] -> ShowS
GetTokenResponse -> String
(Int -> GetTokenResponse -> ShowS)
-> (GetTokenResponse -> String)
-> ([GetTokenResponse] -> ShowS)
-> Show GetTokenResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTokenResponse] -> ShowS
$cshowList :: [GetTokenResponse] -> ShowS
show :: GetTokenResponse -> String
$cshow :: GetTokenResponse -> String
showsPrec :: Int -> GetTokenResponse -> ShowS
$cshowsPrec :: Int -> GetTokenResponse -> ShowS
Prelude.Show, (forall x. GetTokenResponse -> Rep GetTokenResponse x)
-> (forall x. Rep GetTokenResponse x -> GetTokenResponse)
-> Generic GetTokenResponse
forall x. Rep GetTokenResponse x -> GetTokenResponse
forall x. GetTokenResponse -> Rep GetTokenResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetTokenResponse x -> GetTokenResponse
$cfrom :: forall x. GetTokenResponse -> Rep GetTokenResponse x
Prelude.Generic)
newGetTokenResponse ::
Prelude.Int ->
GetTokenResponse
newGetTokenResponse :: Int -> GetTokenResponse
newGetTokenResponse Int
pHttpStatus_ =
GetTokenResponse' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> GetTokenResponse
GetTokenResponse'
{ $sel:ttl:GetTokenResponse' :: Maybe Text
ttl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:appId:GetTokenResponse' :: Maybe Text
appId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:sessionId:GetTokenResponse' :: Maybe Text
sessionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:challengeCode:GetTokenResponse' :: Maybe Text
challengeCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetTokenResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getTokenResponse_ttl :: Lens.Lens' GetTokenResponse (Prelude.Maybe Prelude.Text)
getTokenResponse_ttl :: (Maybe Text -> f (Maybe Text))
-> GetTokenResponse -> f GetTokenResponse
getTokenResponse_ttl = (GetTokenResponse -> Maybe Text)
-> (GetTokenResponse -> Maybe Text -> GetTokenResponse)
-> Lens GetTokenResponse GetTokenResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTokenResponse' {Maybe Text
ttl :: Maybe Text
$sel:ttl:GetTokenResponse' :: GetTokenResponse -> Maybe Text
ttl} -> Maybe Text
ttl) (\s :: GetTokenResponse
s@GetTokenResponse' {} Maybe Text
a -> GetTokenResponse
s {$sel:ttl:GetTokenResponse' :: Maybe Text
ttl = Maybe Text
a} :: GetTokenResponse)
getTokenResponse_appId :: Lens.Lens' GetTokenResponse (Prelude.Maybe Prelude.Text)
getTokenResponse_appId :: (Maybe Text -> f (Maybe Text))
-> GetTokenResponse -> f GetTokenResponse
getTokenResponse_appId = (GetTokenResponse -> Maybe Text)
-> (GetTokenResponse -> Maybe Text -> GetTokenResponse)
-> Lens GetTokenResponse GetTokenResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTokenResponse' {Maybe Text
appId :: Maybe Text
$sel:appId:GetTokenResponse' :: GetTokenResponse -> Maybe Text
appId} -> Maybe Text
appId) (\s :: GetTokenResponse
s@GetTokenResponse' {} Maybe Text
a -> GetTokenResponse
s {$sel:appId:GetTokenResponse' :: Maybe Text
appId = Maybe Text
a} :: GetTokenResponse)
getTokenResponse_sessionId :: Lens.Lens' GetTokenResponse (Prelude.Maybe Prelude.Text)
getTokenResponse_sessionId :: (Maybe Text -> f (Maybe Text))
-> GetTokenResponse -> f GetTokenResponse
getTokenResponse_sessionId = (GetTokenResponse -> Maybe Text)
-> (GetTokenResponse -> Maybe Text -> GetTokenResponse)
-> Lens GetTokenResponse GetTokenResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTokenResponse' {Maybe Text
sessionId :: Maybe Text
$sel:sessionId:GetTokenResponse' :: GetTokenResponse -> Maybe Text
sessionId} -> Maybe Text
sessionId) (\s :: GetTokenResponse
s@GetTokenResponse' {} Maybe Text
a -> GetTokenResponse
s {$sel:sessionId:GetTokenResponse' :: Maybe Text
sessionId = Maybe Text
a} :: GetTokenResponse)
getTokenResponse_challengeCode :: Lens.Lens' GetTokenResponse (Prelude.Maybe Prelude.Text)
getTokenResponse_challengeCode :: (Maybe Text -> f (Maybe Text))
-> GetTokenResponse -> f GetTokenResponse
getTokenResponse_challengeCode = (GetTokenResponse -> Maybe Text)
-> (GetTokenResponse -> Maybe Text -> GetTokenResponse)
-> Lens GetTokenResponse GetTokenResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTokenResponse' {Maybe Text
challengeCode :: Maybe Text
$sel:challengeCode:GetTokenResponse' :: GetTokenResponse -> Maybe Text
challengeCode} -> Maybe Text
challengeCode) (\s :: GetTokenResponse
s@GetTokenResponse' {} Maybe Text
a -> GetTokenResponse
s {$sel:challengeCode:GetTokenResponse' :: Maybe Text
challengeCode = Maybe Text
a} :: GetTokenResponse)
getTokenResponse_httpStatus :: Lens.Lens' GetTokenResponse Prelude.Int
getTokenResponse_httpStatus :: (Int -> f Int) -> GetTokenResponse -> f GetTokenResponse
getTokenResponse_httpStatus = (GetTokenResponse -> Int)
-> (GetTokenResponse -> Int -> GetTokenResponse)
-> Lens GetTokenResponse GetTokenResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTokenResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetTokenResponse' :: GetTokenResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetTokenResponse
s@GetTokenResponse' {} Int
a -> GetTokenResponse
s {$sel:httpStatus:GetTokenResponse' :: Int
httpStatus = Int
a} :: GetTokenResponse)
instance Prelude.NFData GetTokenResponse