{-# 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.CognitoIdentity.GetOpenIdToken
(
GetOpenIdToken (..),
newGetOpenIdToken,
getOpenIdToken_logins,
getOpenIdToken_identityId,
GetOpenIdTokenResponse (..),
newGetOpenIdTokenResponse,
getOpenIdTokenResponse_token,
getOpenIdTokenResponse_identityId,
getOpenIdTokenResponse_httpStatus,
)
where
import Amazonka.CognitoIdentity.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 GetOpenIdToken = GetOpenIdToken'
{
GetOpenIdToken -> Maybe (HashMap Text Text)
logins :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
GetOpenIdToken -> Text
identityId :: Prelude.Text
}
deriving (GetOpenIdToken -> GetOpenIdToken -> Bool
(GetOpenIdToken -> GetOpenIdToken -> Bool)
-> (GetOpenIdToken -> GetOpenIdToken -> Bool) -> Eq GetOpenIdToken
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetOpenIdToken -> GetOpenIdToken -> Bool
$c/= :: GetOpenIdToken -> GetOpenIdToken -> Bool
== :: GetOpenIdToken -> GetOpenIdToken -> Bool
$c== :: GetOpenIdToken -> GetOpenIdToken -> Bool
Prelude.Eq, ReadPrec [GetOpenIdToken]
ReadPrec GetOpenIdToken
Int -> ReadS GetOpenIdToken
ReadS [GetOpenIdToken]
(Int -> ReadS GetOpenIdToken)
-> ReadS [GetOpenIdToken]
-> ReadPrec GetOpenIdToken
-> ReadPrec [GetOpenIdToken]
-> Read GetOpenIdToken
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetOpenIdToken]
$creadListPrec :: ReadPrec [GetOpenIdToken]
readPrec :: ReadPrec GetOpenIdToken
$creadPrec :: ReadPrec GetOpenIdToken
readList :: ReadS [GetOpenIdToken]
$creadList :: ReadS [GetOpenIdToken]
readsPrec :: Int -> ReadS GetOpenIdToken
$creadsPrec :: Int -> ReadS GetOpenIdToken
Prelude.Read, Int -> GetOpenIdToken -> ShowS
[GetOpenIdToken] -> ShowS
GetOpenIdToken -> String
(Int -> GetOpenIdToken -> ShowS)
-> (GetOpenIdToken -> String)
-> ([GetOpenIdToken] -> ShowS)
-> Show GetOpenIdToken
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetOpenIdToken] -> ShowS
$cshowList :: [GetOpenIdToken] -> ShowS
show :: GetOpenIdToken -> String
$cshow :: GetOpenIdToken -> String
showsPrec :: Int -> GetOpenIdToken -> ShowS
$cshowsPrec :: Int -> GetOpenIdToken -> ShowS
Prelude.Show, (forall x. GetOpenIdToken -> Rep GetOpenIdToken x)
-> (forall x. Rep GetOpenIdToken x -> GetOpenIdToken)
-> Generic GetOpenIdToken
forall x. Rep GetOpenIdToken x -> GetOpenIdToken
forall x. GetOpenIdToken -> Rep GetOpenIdToken x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetOpenIdToken x -> GetOpenIdToken
$cfrom :: forall x. GetOpenIdToken -> Rep GetOpenIdToken x
Prelude.Generic)
newGetOpenIdToken ::
Prelude.Text ->
GetOpenIdToken
newGetOpenIdToken :: Text -> GetOpenIdToken
newGetOpenIdToken Text
pIdentityId_ =
GetOpenIdToken' :: Maybe (HashMap Text Text) -> Text -> GetOpenIdToken
GetOpenIdToken'
{ $sel:logins:GetOpenIdToken' :: Maybe (HashMap Text Text)
logins = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:identityId:GetOpenIdToken' :: Text
identityId = Text
pIdentityId_
}
getOpenIdToken_logins :: Lens.Lens' GetOpenIdToken (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
getOpenIdToken_logins :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> GetOpenIdToken -> f GetOpenIdToken
getOpenIdToken_logins = (GetOpenIdToken -> Maybe (HashMap Text Text))
-> (GetOpenIdToken -> Maybe (HashMap Text Text) -> GetOpenIdToken)
-> Lens
GetOpenIdToken
GetOpenIdToken
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOpenIdToken' {Maybe (HashMap Text Text)
logins :: Maybe (HashMap Text Text)
$sel:logins:GetOpenIdToken' :: GetOpenIdToken -> Maybe (HashMap Text Text)
logins} -> Maybe (HashMap Text Text)
logins) (\s :: GetOpenIdToken
s@GetOpenIdToken' {} Maybe (HashMap Text Text)
a -> GetOpenIdToken
s {$sel:logins:GetOpenIdToken' :: Maybe (HashMap Text Text)
logins = Maybe (HashMap Text Text)
a} :: GetOpenIdToken) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> GetOpenIdToken -> f GetOpenIdToken)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> GetOpenIdToken
-> f GetOpenIdToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getOpenIdToken_identityId :: Lens.Lens' GetOpenIdToken Prelude.Text
getOpenIdToken_identityId :: (Text -> f Text) -> GetOpenIdToken -> f GetOpenIdToken
getOpenIdToken_identityId = (GetOpenIdToken -> Text)
-> (GetOpenIdToken -> Text -> GetOpenIdToken)
-> Lens GetOpenIdToken GetOpenIdToken Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOpenIdToken' {Text
identityId :: Text
$sel:identityId:GetOpenIdToken' :: GetOpenIdToken -> Text
identityId} -> Text
identityId) (\s :: GetOpenIdToken
s@GetOpenIdToken' {} Text
a -> GetOpenIdToken
s {$sel:identityId:GetOpenIdToken' :: Text
identityId = Text
a} :: GetOpenIdToken)
instance Core.AWSRequest GetOpenIdToken where
type
AWSResponse GetOpenIdToken =
GetOpenIdTokenResponse
request :: GetOpenIdToken -> Request GetOpenIdToken
request = Service -> GetOpenIdToken -> Request GetOpenIdToken
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetOpenIdToken
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetOpenIdToken)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetOpenIdToken))
-> Logger
-> Service
-> Proxy GetOpenIdToken
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetOpenIdToken)))
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 -> Int -> GetOpenIdTokenResponse
GetOpenIdTokenResponse'
(Maybe Text -> Maybe Text -> Int -> GetOpenIdTokenResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> GetOpenIdTokenResponse)
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
"Token")
Either String (Maybe Text -> Int -> GetOpenIdTokenResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetOpenIdTokenResponse)
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
"IdentityId")
Either String (Int -> GetOpenIdTokenResponse)
-> Either String Int -> Either String GetOpenIdTokenResponse
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 GetOpenIdToken
instance Prelude.NFData GetOpenIdToken
instance Core.ToHeaders GetOpenIdToken where
toHeaders :: GetOpenIdToken -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetOpenIdToken -> 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
"AWSCognitoIdentityService.GetOpenIdToken" ::
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 GetOpenIdToken where
toJSON :: GetOpenIdToken -> Value
toJSON GetOpenIdToken' {Maybe (HashMap Text Text)
Text
identityId :: Text
logins :: Maybe (HashMap Text Text)
$sel:identityId:GetOpenIdToken' :: GetOpenIdToken -> Text
$sel:logins:GetOpenIdToken' :: GetOpenIdToken -> Maybe (HashMap Text Text)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Logins" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
logins,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"IdentityId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
identityId)
]
)
instance Core.ToPath GetOpenIdToken where
toPath :: GetOpenIdToken -> ByteString
toPath = ByteString -> GetOpenIdToken -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetOpenIdToken where
toQuery :: GetOpenIdToken -> QueryString
toQuery = QueryString -> GetOpenIdToken -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetOpenIdTokenResponse = GetOpenIdTokenResponse'
{
GetOpenIdTokenResponse -> Maybe Text
token :: Prelude.Maybe Prelude.Text,
GetOpenIdTokenResponse -> Maybe Text
identityId :: Prelude.Maybe Prelude.Text,
GetOpenIdTokenResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetOpenIdTokenResponse -> GetOpenIdTokenResponse -> Bool
(GetOpenIdTokenResponse -> GetOpenIdTokenResponse -> Bool)
-> (GetOpenIdTokenResponse -> GetOpenIdTokenResponse -> Bool)
-> Eq GetOpenIdTokenResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetOpenIdTokenResponse -> GetOpenIdTokenResponse -> Bool
$c/= :: GetOpenIdTokenResponse -> GetOpenIdTokenResponse -> Bool
== :: GetOpenIdTokenResponse -> GetOpenIdTokenResponse -> Bool
$c== :: GetOpenIdTokenResponse -> GetOpenIdTokenResponse -> Bool
Prelude.Eq, ReadPrec [GetOpenIdTokenResponse]
ReadPrec GetOpenIdTokenResponse
Int -> ReadS GetOpenIdTokenResponse
ReadS [GetOpenIdTokenResponse]
(Int -> ReadS GetOpenIdTokenResponse)
-> ReadS [GetOpenIdTokenResponse]
-> ReadPrec GetOpenIdTokenResponse
-> ReadPrec [GetOpenIdTokenResponse]
-> Read GetOpenIdTokenResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetOpenIdTokenResponse]
$creadListPrec :: ReadPrec [GetOpenIdTokenResponse]
readPrec :: ReadPrec GetOpenIdTokenResponse
$creadPrec :: ReadPrec GetOpenIdTokenResponse
readList :: ReadS [GetOpenIdTokenResponse]
$creadList :: ReadS [GetOpenIdTokenResponse]
readsPrec :: Int -> ReadS GetOpenIdTokenResponse
$creadsPrec :: Int -> ReadS GetOpenIdTokenResponse
Prelude.Read, Int -> GetOpenIdTokenResponse -> ShowS
[GetOpenIdTokenResponse] -> ShowS
GetOpenIdTokenResponse -> String
(Int -> GetOpenIdTokenResponse -> ShowS)
-> (GetOpenIdTokenResponse -> String)
-> ([GetOpenIdTokenResponse] -> ShowS)
-> Show GetOpenIdTokenResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetOpenIdTokenResponse] -> ShowS
$cshowList :: [GetOpenIdTokenResponse] -> ShowS
show :: GetOpenIdTokenResponse -> String
$cshow :: GetOpenIdTokenResponse -> String
showsPrec :: Int -> GetOpenIdTokenResponse -> ShowS
$cshowsPrec :: Int -> GetOpenIdTokenResponse -> ShowS
Prelude.Show, (forall x. GetOpenIdTokenResponse -> Rep GetOpenIdTokenResponse x)
-> (forall x.
Rep GetOpenIdTokenResponse x -> GetOpenIdTokenResponse)
-> Generic GetOpenIdTokenResponse
forall x. Rep GetOpenIdTokenResponse x -> GetOpenIdTokenResponse
forall x. GetOpenIdTokenResponse -> Rep GetOpenIdTokenResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetOpenIdTokenResponse x -> GetOpenIdTokenResponse
$cfrom :: forall x. GetOpenIdTokenResponse -> Rep GetOpenIdTokenResponse x
Prelude.Generic)
newGetOpenIdTokenResponse ::
Prelude.Int ->
GetOpenIdTokenResponse
newGetOpenIdTokenResponse :: Int -> GetOpenIdTokenResponse
newGetOpenIdTokenResponse Int
pHttpStatus_ =
GetOpenIdTokenResponse' :: Maybe Text -> Maybe Text -> Int -> GetOpenIdTokenResponse
GetOpenIdTokenResponse'
{ $sel:token:GetOpenIdTokenResponse' :: Maybe Text
token = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:identityId:GetOpenIdTokenResponse' :: Maybe Text
identityId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetOpenIdTokenResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getOpenIdTokenResponse_token :: Lens.Lens' GetOpenIdTokenResponse (Prelude.Maybe Prelude.Text)
getOpenIdTokenResponse_token :: (Maybe Text -> f (Maybe Text))
-> GetOpenIdTokenResponse -> f GetOpenIdTokenResponse
getOpenIdTokenResponse_token = (GetOpenIdTokenResponse -> Maybe Text)
-> (GetOpenIdTokenResponse -> Maybe Text -> GetOpenIdTokenResponse)
-> Lens
GetOpenIdTokenResponse
GetOpenIdTokenResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOpenIdTokenResponse' {Maybe Text
token :: Maybe Text
$sel:token:GetOpenIdTokenResponse' :: GetOpenIdTokenResponse -> Maybe Text
token} -> Maybe Text
token) (\s :: GetOpenIdTokenResponse
s@GetOpenIdTokenResponse' {} Maybe Text
a -> GetOpenIdTokenResponse
s {$sel:token:GetOpenIdTokenResponse' :: Maybe Text
token = Maybe Text
a} :: GetOpenIdTokenResponse)
getOpenIdTokenResponse_identityId :: Lens.Lens' GetOpenIdTokenResponse (Prelude.Maybe Prelude.Text)
getOpenIdTokenResponse_identityId :: (Maybe Text -> f (Maybe Text))
-> GetOpenIdTokenResponse -> f GetOpenIdTokenResponse
getOpenIdTokenResponse_identityId = (GetOpenIdTokenResponse -> Maybe Text)
-> (GetOpenIdTokenResponse -> Maybe Text -> GetOpenIdTokenResponse)
-> Lens
GetOpenIdTokenResponse
GetOpenIdTokenResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOpenIdTokenResponse' {Maybe Text
identityId :: Maybe Text
$sel:identityId:GetOpenIdTokenResponse' :: GetOpenIdTokenResponse -> Maybe Text
identityId} -> Maybe Text
identityId) (\s :: GetOpenIdTokenResponse
s@GetOpenIdTokenResponse' {} Maybe Text
a -> GetOpenIdTokenResponse
s {$sel:identityId:GetOpenIdTokenResponse' :: Maybe Text
identityId = Maybe Text
a} :: GetOpenIdTokenResponse)
getOpenIdTokenResponse_httpStatus :: Lens.Lens' GetOpenIdTokenResponse Prelude.Int
getOpenIdTokenResponse_httpStatus :: (Int -> f Int)
-> GetOpenIdTokenResponse -> f GetOpenIdTokenResponse
getOpenIdTokenResponse_httpStatus = (GetOpenIdTokenResponse -> Int)
-> (GetOpenIdTokenResponse -> Int -> GetOpenIdTokenResponse)
-> Lens GetOpenIdTokenResponse GetOpenIdTokenResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOpenIdTokenResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetOpenIdTokenResponse' :: GetOpenIdTokenResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetOpenIdTokenResponse
s@GetOpenIdTokenResponse' {} Int
a -> GetOpenIdTokenResponse
s {$sel:httpStatus:GetOpenIdTokenResponse' :: Int
httpStatus = Int
a} :: GetOpenIdTokenResponse)
instance Prelude.NFData GetOpenIdTokenResponse