{-# 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.CreateToken
(
CreateToken (..),
newCreateToken,
createToken_appId,
CreateTokenResponse (..),
newCreateTokenResponse,
createTokenResponse_ttl,
createTokenResponse_appId,
createTokenResponse_sessionId,
createTokenResponse_challengeCode,
createTokenResponse_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 CreateToken = CreateToken'
{
CreateToken -> Text
appId :: Prelude.Text
}
deriving (CreateToken -> CreateToken -> Bool
(CreateToken -> CreateToken -> Bool)
-> (CreateToken -> CreateToken -> Bool) -> Eq CreateToken
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateToken -> CreateToken -> Bool
$c/= :: CreateToken -> CreateToken -> Bool
== :: CreateToken -> CreateToken -> Bool
$c== :: CreateToken -> CreateToken -> Bool
Prelude.Eq, ReadPrec [CreateToken]
ReadPrec CreateToken
Int -> ReadS CreateToken
ReadS [CreateToken]
(Int -> ReadS CreateToken)
-> ReadS [CreateToken]
-> ReadPrec CreateToken
-> ReadPrec [CreateToken]
-> Read CreateToken
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateToken]
$creadListPrec :: ReadPrec [CreateToken]
readPrec :: ReadPrec CreateToken
$creadPrec :: ReadPrec CreateToken
readList :: ReadS [CreateToken]
$creadList :: ReadS [CreateToken]
readsPrec :: Int -> ReadS CreateToken
$creadsPrec :: Int -> ReadS CreateToken
Prelude.Read, Int -> CreateToken -> ShowS
[CreateToken] -> ShowS
CreateToken -> String
(Int -> CreateToken -> ShowS)
-> (CreateToken -> String)
-> ([CreateToken] -> ShowS)
-> Show CreateToken
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateToken] -> ShowS
$cshowList :: [CreateToken] -> ShowS
show :: CreateToken -> String
$cshow :: CreateToken -> String
showsPrec :: Int -> CreateToken -> ShowS
$cshowsPrec :: Int -> CreateToken -> ShowS
Prelude.Show, (forall x. CreateToken -> Rep CreateToken x)
-> (forall x. Rep CreateToken x -> CreateToken)
-> Generic CreateToken
forall x. Rep CreateToken x -> CreateToken
forall x. CreateToken -> Rep CreateToken x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateToken x -> CreateToken
$cfrom :: forall x. CreateToken -> Rep CreateToken x
Prelude.Generic)
newCreateToken ::
Prelude.Text ->
CreateToken
newCreateToken :: Text -> CreateToken
newCreateToken Text
pAppId_ =
CreateToken' :: Text -> CreateToken
CreateToken' {$sel:appId:CreateToken' :: Text
appId = Text
pAppId_}
createToken_appId :: Lens.Lens' CreateToken Prelude.Text
createToken_appId :: (Text -> f Text) -> CreateToken -> f CreateToken
createToken_appId = (CreateToken -> Text)
-> (CreateToken -> Text -> CreateToken)
-> Lens CreateToken CreateToken Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateToken' {Text
appId :: Text
$sel:appId:CreateToken' :: CreateToken -> Text
appId} -> Text
appId) (\s :: CreateToken
s@CreateToken' {} Text
a -> CreateToken
s {$sel:appId:CreateToken' :: Text
appId = Text
a} :: CreateToken)
instance Core.AWSRequest CreateToken where
type AWSResponse CreateToken = CreateTokenResponse
request :: CreateToken -> Request CreateToken
request = Service -> CreateToken -> Request CreateToken
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateToken
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateToken)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateToken))
-> Logger
-> Service
-> Proxy CreateToken
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateToken)))
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
-> CreateTokenResponse
CreateTokenResponse'
(Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> CreateTokenResponse)
-> Either String (Maybe Text)
-> Either
String
(Maybe Text
-> Maybe Text -> Maybe Text -> Int -> CreateTokenResponse)
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 -> CreateTokenResponse)
-> Either String (Maybe Text)
-> Either
String (Maybe Text -> Maybe Text -> Int -> CreateTokenResponse)
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 -> CreateTokenResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CreateTokenResponse)
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 -> CreateTokenResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateTokenResponse)
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 -> CreateTokenResponse)
-> Either String Int -> Either String CreateTokenResponse
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 CreateToken
instance Prelude.NFData CreateToken
instance Core.ToHeaders CreateToken where
toHeaders :: CreateToken -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateToken -> 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 CreateToken where
toJSON :: CreateToken -> Value
toJSON = Value -> CreateToken -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)
instance Core.ToPath CreateToken where
toPath :: CreateToken -> ByteString
toPath CreateToken' {Text
appId :: Text
$sel:appId:CreateToken' :: CreateToken -> 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"]
instance Core.ToQuery CreateToken where
toQuery :: CreateToken -> QueryString
toQuery = QueryString -> CreateToken -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateTokenResponse = CreateTokenResponse'
{
CreateTokenResponse -> Maybe Text
ttl :: Prelude.Maybe Prelude.Text,
CreateTokenResponse -> Maybe Text
appId :: Prelude.Maybe Prelude.Text,
CreateTokenResponse -> Maybe Text
sessionId :: Prelude.Maybe Prelude.Text,
CreateTokenResponse -> Maybe Text
challengeCode :: Prelude.Maybe Prelude.Text,
CreateTokenResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateTokenResponse -> CreateTokenResponse -> Bool
(CreateTokenResponse -> CreateTokenResponse -> Bool)
-> (CreateTokenResponse -> CreateTokenResponse -> Bool)
-> Eq CreateTokenResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTokenResponse -> CreateTokenResponse -> Bool
$c/= :: CreateTokenResponse -> CreateTokenResponse -> Bool
== :: CreateTokenResponse -> CreateTokenResponse -> Bool
$c== :: CreateTokenResponse -> CreateTokenResponse -> Bool
Prelude.Eq, ReadPrec [CreateTokenResponse]
ReadPrec CreateTokenResponse
Int -> ReadS CreateTokenResponse
ReadS [CreateTokenResponse]
(Int -> ReadS CreateTokenResponse)
-> ReadS [CreateTokenResponse]
-> ReadPrec CreateTokenResponse
-> ReadPrec [CreateTokenResponse]
-> Read CreateTokenResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTokenResponse]
$creadListPrec :: ReadPrec [CreateTokenResponse]
readPrec :: ReadPrec CreateTokenResponse
$creadPrec :: ReadPrec CreateTokenResponse
readList :: ReadS [CreateTokenResponse]
$creadList :: ReadS [CreateTokenResponse]
readsPrec :: Int -> ReadS CreateTokenResponse
$creadsPrec :: Int -> ReadS CreateTokenResponse
Prelude.Read, Int -> CreateTokenResponse -> ShowS
[CreateTokenResponse] -> ShowS
CreateTokenResponse -> String
(Int -> CreateTokenResponse -> ShowS)
-> (CreateTokenResponse -> String)
-> ([CreateTokenResponse] -> ShowS)
-> Show CreateTokenResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTokenResponse] -> ShowS
$cshowList :: [CreateTokenResponse] -> ShowS
show :: CreateTokenResponse -> String
$cshow :: CreateTokenResponse -> String
showsPrec :: Int -> CreateTokenResponse -> ShowS
$cshowsPrec :: Int -> CreateTokenResponse -> ShowS
Prelude.Show, (forall x. CreateTokenResponse -> Rep CreateTokenResponse x)
-> (forall x. Rep CreateTokenResponse x -> CreateTokenResponse)
-> Generic CreateTokenResponse
forall x. Rep CreateTokenResponse x -> CreateTokenResponse
forall x. CreateTokenResponse -> Rep CreateTokenResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTokenResponse x -> CreateTokenResponse
$cfrom :: forall x. CreateTokenResponse -> Rep CreateTokenResponse x
Prelude.Generic)
newCreateTokenResponse ::
Prelude.Int ->
CreateTokenResponse
newCreateTokenResponse :: Int -> CreateTokenResponse
newCreateTokenResponse Int
pHttpStatus_ =
CreateTokenResponse' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> CreateTokenResponse
CreateTokenResponse'
{ $sel:ttl:CreateTokenResponse' :: Maybe Text
ttl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:appId:CreateTokenResponse' :: Maybe Text
appId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:sessionId:CreateTokenResponse' :: Maybe Text
sessionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:challengeCode:CreateTokenResponse' :: Maybe Text
challengeCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateTokenResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createTokenResponse_ttl :: Lens.Lens' CreateTokenResponse (Prelude.Maybe Prelude.Text)
createTokenResponse_ttl :: (Maybe Text -> f (Maybe Text))
-> CreateTokenResponse -> f CreateTokenResponse
createTokenResponse_ttl = (CreateTokenResponse -> Maybe Text)
-> (CreateTokenResponse -> Maybe Text -> CreateTokenResponse)
-> Lens
CreateTokenResponse CreateTokenResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTokenResponse' {Maybe Text
ttl :: Maybe Text
$sel:ttl:CreateTokenResponse' :: CreateTokenResponse -> Maybe Text
ttl} -> Maybe Text
ttl) (\s :: CreateTokenResponse
s@CreateTokenResponse' {} Maybe Text
a -> CreateTokenResponse
s {$sel:ttl:CreateTokenResponse' :: Maybe Text
ttl = Maybe Text
a} :: CreateTokenResponse)
createTokenResponse_appId :: Lens.Lens' CreateTokenResponse (Prelude.Maybe Prelude.Text)
createTokenResponse_appId :: (Maybe Text -> f (Maybe Text))
-> CreateTokenResponse -> f CreateTokenResponse
createTokenResponse_appId = (CreateTokenResponse -> Maybe Text)
-> (CreateTokenResponse -> Maybe Text -> CreateTokenResponse)
-> Lens
CreateTokenResponse CreateTokenResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTokenResponse' {Maybe Text
appId :: Maybe Text
$sel:appId:CreateTokenResponse' :: CreateTokenResponse -> Maybe Text
appId} -> Maybe Text
appId) (\s :: CreateTokenResponse
s@CreateTokenResponse' {} Maybe Text
a -> CreateTokenResponse
s {$sel:appId:CreateTokenResponse' :: Maybe Text
appId = Maybe Text
a} :: CreateTokenResponse)
createTokenResponse_sessionId :: Lens.Lens' CreateTokenResponse (Prelude.Maybe Prelude.Text)
createTokenResponse_sessionId :: (Maybe Text -> f (Maybe Text))
-> CreateTokenResponse -> f CreateTokenResponse
createTokenResponse_sessionId = (CreateTokenResponse -> Maybe Text)
-> (CreateTokenResponse -> Maybe Text -> CreateTokenResponse)
-> Lens
CreateTokenResponse CreateTokenResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTokenResponse' {Maybe Text
sessionId :: Maybe Text
$sel:sessionId:CreateTokenResponse' :: CreateTokenResponse -> Maybe Text
sessionId} -> Maybe Text
sessionId) (\s :: CreateTokenResponse
s@CreateTokenResponse' {} Maybe Text
a -> CreateTokenResponse
s {$sel:sessionId:CreateTokenResponse' :: Maybe Text
sessionId = Maybe Text
a} :: CreateTokenResponse)
createTokenResponse_challengeCode :: Lens.Lens' CreateTokenResponse (Prelude.Maybe Prelude.Text)
createTokenResponse_challengeCode :: (Maybe Text -> f (Maybe Text))
-> CreateTokenResponse -> f CreateTokenResponse
createTokenResponse_challengeCode = (CreateTokenResponse -> Maybe Text)
-> (CreateTokenResponse -> Maybe Text -> CreateTokenResponse)
-> Lens
CreateTokenResponse CreateTokenResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTokenResponse' {Maybe Text
challengeCode :: Maybe Text
$sel:challengeCode:CreateTokenResponse' :: CreateTokenResponse -> Maybe Text
challengeCode} -> Maybe Text
challengeCode) (\s :: CreateTokenResponse
s@CreateTokenResponse' {} Maybe Text
a -> CreateTokenResponse
s {$sel:challengeCode:CreateTokenResponse' :: Maybe Text
challengeCode = Maybe Text
a} :: CreateTokenResponse)
createTokenResponse_httpStatus :: Lens.Lens' CreateTokenResponse Prelude.Int
createTokenResponse_httpStatus :: (Int -> f Int) -> CreateTokenResponse -> f CreateTokenResponse
createTokenResponse_httpStatus = (CreateTokenResponse -> Int)
-> (CreateTokenResponse -> Int -> CreateTokenResponse)
-> Lens CreateTokenResponse CreateTokenResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTokenResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateTokenResponse' :: CreateTokenResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateTokenResponse
s@CreateTokenResponse' {} Int
a -> CreateTokenResponse
s {$sel:httpStatus:CreateTokenResponse' :: Int
httpStatus = Int
a} :: CreateTokenResponse)
instance Prelude.NFData CreateTokenResponse