{-# 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.GetId
(
GetId (..),
newGetId,
getId_accountId,
getId_logins,
getId_identityPoolId,
GetIdResponse (..),
newGetIdResponse,
getIdResponse_identityId,
getIdResponse_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 GetId = GetId'
{
GetId -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
GetId -> Maybe (HashMap Text Text)
logins :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
GetId -> Text
identityPoolId :: Prelude.Text
}
deriving (GetId -> GetId -> Bool
(GetId -> GetId -> Bool) -> (GetId -> GetId -> Bool) -> Eq GetId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetId -> GetId -> Bool
$c/= :: GetId -> GetId -> Bool
== :: GetId -> GetId -> Bool
$c== :: GetId -> GetId -> Bool
Prelude.Eq, ReadPrec [GetId]
ReadPrec GetId
Int -> ReadS GetId
ReadS [GetId]
(Int -> ReadS GetId)
-> ReadS [GetId]
-> ReadPrec GetId
-> ReadPrec [GetId]
-> Read GetId
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetId]
$creadListPrec :: ReadPrec [GetId]
readPrec :: ReadPrec GetId
$creadPrec :: ReadPrec GetId
readList :: ReadS [GetId]
$creadList :: ReadS [GetId]
readsPrec :: Int -> ReadS GetId
$creadsPrec :: Int -> ReadS GetId
Prelude.Read, Int -> GetId -> ShowS
[GetId] -> ShowS
GetId -> String
(Int -> GetId -> ShowS)
-> (GetId -> String) -> ([GetId] -> ShowS) -> Show GetId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetId] -> ShowS
$cshowList :: [GetId] -> ShowS
show :: GetId -> String
$cshow :: GetId -> String
showsPrec :: Int -> GetId -> ShowS
$cshowsPrec :: Int -> GetId -> ShowS
Prelude.Show, (forall x. GetId -> Rep GetId x)
-> (forall x. Rep GetId x -> GetId) -> Generic GetId
forall x. Rep GetId x -> GetId
forall x. GetId -> Rep GetId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetId x -> GetId
$cfrom :: forall x. GetId -> Rep GetId x
Prelude.Generic)
newGetId ::
Prelude.Text ->
GetId
newGetId :: Text -> GetId
newGetId Text
pIdentityPoolId_ =
GetId' :: Maybe Text -> Maybe (HashMap Text Text) -> Text -> GetId
GetId'
{ $sel:accountId:GetId' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:logins:GetId' :: Maybe (HashMap Text Text)
logins = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:identityPoolId:GetId' :: Text
identityPoolId = Text
pIdentityPoolId_
}
getId_accountId :: Lens.Lens' GetId (Prelude.Maybe Prelude.Text)
getId_accountId :: (Maybe Text -> f (Maybe Text)) -> GetId -> f GetId
getId_accountId = (GetId -> Maybe Text)
-> (GetId -> Maybe Text -> GetId)
-> Lens GetId GetId (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetId' {Maybe Text
accountId :: Maybe Text
$sel:accountId:GetId' :: GetId -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: GetId
s@GetId' {} Maybe Text
a -> GetId
s {$sel:accountId:GetId' :: Maybe Text
accountId = Maybe Text
a} :: GetId)
getId_logins :: Lens.Lens' GetId (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
getId_logins :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> GetId -> f GetId
getId_logins = (GetId -> Maybe (HashMap Text Text))
-> (GetId -> Maybe (HashMap Text Text) -> GetId)
-> Lens
GetId GetId (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 (\GetId' {Maybe (HashMap Text Text)
logins :: Maybe (HashMap Text Text)
$sel:logins:GetId' :: GetId -> Maybe (HashMap Text Text)
logins} -> Maybe (HashMap Text Text)
logins) (\s :: GetId
s@GetId' {} Maybe (HashMap Text Text)
a -> GetId
s {$sel:logins:GetId' :: Maybe (HashMap Text Text)
logins = Maybe (HashMap Text Text)
a} :: GetId) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> GetId -> f GetId)
-> ((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)))
-> GetId
-> f GetId
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
getId_identityPoolId :: Lens.Lens' GetId Prelude.Text
getId_identityPoolId :: (Text -> f Text) -> GetId -> f GetId
getId_identityPoolId = (GetId -> Text)
-> (GetId -> Text -> GetId) -> Lens GetId GetId Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetId' {Text
identityPoolId :: Text
$sel:identityPoolId:GetId' :: GetId -> Text
identityPoolId} -> Text
identityPoolId) (\s :: GetId
s@GetId' {} Text
a -> GetId
s {$sel:identityPoolId:GetId' :: Text
identityPoolId = Text
a} :: GetId)
instance Core.AWSRequest GetId where
type AWSResponse GetId = GetIdResponse
request :: GetId -> Request GetId
request = Service -> GetId -> Request GetId
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetId
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetId)))
response =
(Int
-> ResponseHeaders -> Object -> Either String (AWSResponse GetId))
-> Logger
-> Service
-> Proxy GetId
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetId)))
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 -> Int -> GetIdResponse
GetIdResponse'
(Maybe Text -> Int -> GetIdResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetIdResponse)
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
"IdentityId")
Either String (Int -> GetIdResponse)
-> Either String Int -> Either String GetIdResponse
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 GetId
instance Prelude.NFData GetId
instance Core.ToHeaders GetId where
toHeaders :: GetId -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetId -> 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.GetId" ::
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 GetId where
toJSON :: GetId -> Value
toJSON GetId' {Maybe Text
Maybe (HashMap Text Text)
Text
identityPoolId :: Text
logins :: Maybe (HashMap Text Text)
accountId :: Maybe Text
$sel:identityPoolId:GetId' :: GetId -> Text
$sel:logins:GetId' :: GetId -> Maybe (HashMap Text Text)
$sel:accountId:GetId' :: GetId -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"AccountId" 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
accountId,
(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
"IdentityPoolId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
identityPoolId)
]
)
instance Core.ToPath GetId where
toPath :: GetId -> ByteString
toPath = ByteString -> GetId -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetId where
toQuery :: GetId -> QueryString
toQuery = QueryString -> GetId -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetIdResponse = GetIdResponse'
{
GetIdResponse -> Maybe Text
identityId :: Prelude.Maybe Prelude.Text,
GetIdResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetIdResponse -> GetIdResponse -> Bool
(GetIdResponse -> GetIdResponse -> Bool)
-> (GetIdResponse -> GetIdResponse -> Bool) -> Eq GetIdResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetIdResponse -> GetIdResponse -> Bool
$c/= :: GetIdResponse -> GetIdResponse -> Bool
== :: GetIdResponse -> GetIdResponse -> Bool
$c== :: GetIdResponse -> GetIdResponse -> Bool
Prelude.Eq, ReadPrec [GetIdResponse]
ReadPrec GetIdResponse
Int -> ReadS GetIdResponse
ReadS [GetIdResponse]
(Int -> ReadS GetIdResponse)
-> ReadS [GetIdResponse]
-> ReadPrec GetIdResponse
-> ReadPrec [GetIdResponse]
-> Read GetIdResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetIdResponse]
$creadListPrec :: ReadPrec [GetIdResponse]
readPrec :: ReadPrec GetIdResponse
$creadPrec :: ReadPrec GetIdResponse
readList :: ReadS [GetIdResponse]
$creadList :: ReadS [GetIdResponse]
readsPrec :: Int -> ReadS GetIdResponse
$creadsPrec :: Int -> ReadS GetIdResponse
Prelude.Read, Int -> GetIdResponse -> ShowS
[GetIdResponse] -> ShowS
GetIdResponse -> String
(Int -> GetIdResponse -> ShowS)
-> (GetIdResponse -> String)
-> ([GetIdResponse] -> ShowS)
-> Show GetIdResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetIdResponse] -> ShowS
$cshowList :: [GetIdResponse] -> ShowS
show :: GetIdResponse -> String
$cshow :: GetIdResponse -> String
showsPrec :: Int -> GetIdResponse -> ShowS
$cshowsPrec :: Int -> GetIdResponse -> ShowS
Prelude.Show, (forall x. GetIdResponse -> Rep GetIdResponse x)
-> (forall x. Rep GetIdResponse x -> GetIdResponse)
-> Generic GetIdResponse
forall x. Rep GetIdResponse x -> GetIdResponse
forall x. GetIdResponse -> Rep GetIdResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetIdResponse x -> GetIdResponse
$cfrom :: forall x. GetIdResponse -> Rep GetIdResponse x
Prelude.Generic)
newGetIdResponse ::
Prelude.Int ->
GetIdResponse
newGetIdResponse :: Int -> GetIdResponse
newGetIdResponse Int
pHttpStatus_ =
GetIdResponse' :: Maybe Text -> Int -> GetIdResponse
GetIdResponse'
{ $sel:identityId:GetIdResponse' :: Maybe Text
identityId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetIdResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getIdResponse_identityId :: Lens.Lens' GetIdResponse (Prelude.Maybe Prelude.Text)
getIdResponse_identityId :: (Maybe Text -> f (Maybe Text)) -> GetIdResponse -> f GetIdResponse
getIdResponse_identityId = (GetIdResponse -> Maybe Text)
-> (GetIdResponse -> Maybe Text -> GetIdResponse)
-> Lens GetIdResponse GetIdResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetIdResponse' {Maybe Text
identityId :: Maybe Text
$sel:identityId:GetIdResponse' :: GetIdResponse -> Maybe Text
identityId} -> Maybe Text
identityId) (\s :: GetIdResponse
s@GetIdResponse' {} Maybe Text
a -> GetIdResponse
s {$sel:identityId:GetIdResponse' :: Maybe Text
identityId = Maybe Text
a} :: GetIdResponse)
getIdResponse_httpStatus :: Lens.Lens' GetIdResponse Prelude.Int
getIdResponse_httpStatus :: (Int -> f Int) -> GetIdResponse -> f GetIdResponse
getIdResponse_httpStatus = (GetIdResponse -> Int)
-> (GetIdResponse -> Int -> GetIdResponse)
-> Lens GetIdResponse GetIdResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetIdResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetIdResponse' :: GetIdResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetIdResponse
s@GetIdResponse' {} Int
a -> GetIdResponse
s {$sel:httpStatus:GetIdResponse' :: Int
httpStatus = Int
a} :: GetIdResponse)
instance Prelude.NFData GetIdResponse