{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IdentityStore.DescribeUser
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the user metadata and attributes from @UserId@ in an identity
-- store.
module Amazonka.IdentityStore.DescribeUser
  ( -- * Creating a Request
    DescribeUser (..),
    newDescribeUser,

    -- * Request Lenses
    describeUser_identityStoreId,
    describeUser_userId,

    -- * Destructuring the Response
    DescribeUserResponse (..),
    newDescribeUserResponse,

    -- * Response Lenses
    describeUserResponse_httpStatus,
    describeUserResponse_userName,
    describeUserResponse_userId,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IdentityStore.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeUser' smart constructor.
data DescribeUser = DescribeUser'
  { -- | The globally unique identifier for the identity store, such as
    -- @d-1234567890@. In this example, @d-@ is a fixed prefix, and
    -- @1234567890@ is a randomly generated string that contains number and
    -- lower case letters. This value is generated at the time that a new
    -- identity store is created.
    DescribeUser -> Text
identityStoreId :: Prelude.Text,
    -- | The identifier for a user in the identity store.
    DescribeUser -> Text
userId :: Prelude.Text
  }
  deriving (DescribeUser -> DescribeUser -> Bool
(DescribeUser -> DescribeUser -> Bool)
-> (DescribeUser -> DescribeUser -> Bool) -> Eq DescribeUser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeUser -> DescribeUser -> Bool
$c/= :: DescribeUser -> DescribeUser -> Bool
== :: DescribeUser -> DescribeUser -> Bool
$c== :: DescribeUser -> DescribeUser -> Bool
Prelude.Eq, ReadPrec [DescribeUser]
ReadPrec DescribeUser
Int -> ReadS DescribeUser
ReadS [DescribeUser]
(Int -> ReadS DescribeUser)
-> ReadS [DescribeUser]
-> ReadPrec DescribeUser
-> ReadPrec [DescribeUser]
-> Read DescribeUser
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeUser]
$creadListPrec :: ReadPrec [DescribeUser]
readPrec :: ReadPrec DescribeUser
$creadPrec :: ReadPrec DescribeUser
readList :: ReadS [DescribeUser]
$creadList :: ReadS [DescribeUser]
readsPrec :: Int -> ReadS DescribeUser
$creadsPrec :: Int -> ReadS DescribeUser
Prelude.Read, Int -> DescribeUser -> ShowS
[DescribeUser] -> ShowS
DescribeUser -> String
(Int -> DescribeUser -> ShowS)
-> (DescribeUser -> String)
-> ([DescribeUser] -> ShowS)
-> Show DescribeUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeUser] -> ShowS
$cshowList :: [DescribeUser] -> ShowS
show :: DescribeUser -> String
$cshow :: DescribeUser -> String
showsPrec :: Int -> DescribeUser -> ShowS
$cshowsPrec :: Int -> DescribeUser -> ShowS
Prelude.Show, (forall x. DescribeUser -> Rep DescribeUser x)
-> (forall x. Rep DescribeUser x -> DescribeUser)
-> Generic DescribeUser
forall x. Rep DescribeUser x -> DescribeUser
forall x. DescribeUser -> Rep DescribeUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeUser x -> DescribeUser
$cfrom :: forall x. DescribeUser -> Rep DescribeUser x
Prelude.Generic)

-- |
-- Create a value of 'DescribeUser' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'identityStoreId', 'describeUser_identityStoreId' - The globally unique identifier for the identity store, such as
-- @d-1234567890@. In this example, @d-@ is a fixed prefix, and
-- @1234567890@ is a randomly generated string that contains number and
-- lower case letters. This value is generated at the time that a new
-- identity store is created.
--
-- 'userId', 'describeUser_userId' - The identifier for a user in the identity store.
newDescribeUser ::
  -- | 'identityStoreId'
  Prelude.Text ->
  -- | 'userId'
  Prelude.Text ->
  DescribeUser
newDescribeUser :: Text -> Text -> DescribeUser
newDescribeUser Text
pIdentityStoreId_ Text
pUserId_ =
  DescribeUser' :: Text -> Text -> DescribeUser
DescribeUser'
    { $sel:identityStoreId:DescribeUser' :: Text
identityStoreId = Text
pIdentityStoreId_,
      $sel:userId:DescribeUser' :: Text
userId = Text
pUserId_
    }

-- | The globally unique identifier for the identity store, such as
-- @d-1234567890@. In this example, @d-@ is a fixed prefix, and
-- @1234567890@ is a randomly generated string that contains number and
-- lower case letters. This value is generated at the time that a new
-- identity store is created.
describeUser_identityStoreId :: Lens.Lens' DescribeUser Prelude.Text
describeUser_identityStoreId :: (Text -> f Text) -> DescribeUser -> f DescribeUser
describeUser_identityStoreId = (DescribeUser -> Text)
-> (DescribeUser -> Text -> DescribeUser)
-> Lens DescribeUser DescribeUser Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUser' {Text
identityStoreId :: Text
$sel:identityStoreId:DescribeUser' :: DescribeUser -> Text
identityStoreId} -> Text
identityStoreId) (\s :: DescribeUser
s@DescribeUser' {} Text
a -> DescribeUser
s {$sel:identityStoreId:DescribeUser' :: Text
identityStoreId = Text
a} :: DescribeUser)

-- | The identifier for a user in the identity store.
describeUser_userId :: Lens.Lens' DescribeUser Prelude.Text
describeUser_userId :: (Text -> f Text) -> DescribeUser -> f DescribeUser
describeUser_userId = (DescribeUser -> Text)
-> (DescribeUser -> Text -> DescribeUser)
-> Lens DescribeUser DescribeUser Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUser' {Text
userId :: Text
$sel:userId:DescribeUser' :: DescribeUser -> Text
userId} -> Text
userId) (\s :: DescribeUser
s@DescribeUser' {} Text
a -> DescribeUser
s {$sel:userId:DescribeUser' :: Text
userId = Text
a} :: DescribeUser)

instance Core.AWSRequest DescribeUser where
  type AWSResponse DescribeUser = DescribeUserResponse
  request :: DescribeUser -> Request DescribeUser
request = Service -> DescribeUser -> Request DescribeUser
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeUser)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeUser))
-> Logger
-> Service
-> Proxy DescribeUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeUser)))
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 ->
          Int -> Sensitive Text -> Text -> DescribeUserResponse
DescribeUserResponse'
            (Int -> Sensitive Text -> Text -> DescribeUserResponse)
-> Either String Int
-> Either String (Sensitive Text -> Text -> DescribeUserResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (Sensitive Text -> Text -> DescribeUserResponse)
-> Either String (Sensitive Text)
-> Either String (Text -> DescribeUserResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"UserName")
            Either String (Text -> DescribeUserResponse)
-> Either String Text -> Either String DescribeUserResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"UserId")
      )

instance Prelude.Hashable DescribeUser

instance Prelude.NFData DescribeUser

instance Core.ToHeaders DescribeUser where
  toHeaders :: DescribeUser -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeUser -> 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
"AWSIdentityStore.DescribeUser" ::
                          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 DescribeUser where
  toJSON :: DescribeUser -> Value
toJSON DescribeUser' {Text
userId :: Text
identityStoreId :: Text
$sel:userId:DescribeUser' :: DescribeUser -> Text
$sel:identityStoreId:DescribeUser' :: DescribeUser -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"IdentityStoreId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
identityStoreId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UserId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userId)
          ]
      )

instance Core.ToPath DescribeUser where
  toPath :: DescribeUser -> ByteString
toPath = ByteString -> DescribeUser -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DescribeUser where
  toQuery :: DescribeUser -> QueryString
toQuery = QueryString -> DescribeUser -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newDescribeUserResponse' smart constructor.
data DescribeUserResponse = DescribeUserResponse'
  { -- | The response's http status code.
    DescribeUserResponse -> Int
httpStatus :: Prelude.Int,
    -- | Contains the user’s user name value. The length limit is 128 characters.
    -- This value can consist of letters, accented characters, symbols,
    -- numbers, and punctuation. The characters @\<>;:%@ are excluded. This
    -- value is specified at the time the user is created and stored as an
    -- attribute of the user object in the identity store.
    DescribeUserResponse -> Sensitive Text
userName :: Core.Sensitive Prelude.Text,
    -- | The identifier for a user in the identity store.
    DescribeUserResponse -> Text
userId :: Prelude.Text
  }
  deriving (DescribeUserResponse -> DescribeUserResponse -> Bool
(DescribeUserResponse -> DescribeUserResponse -> Bool)
-> (DescribeUserResponse -> DescribeUserResponse -> Bool)
-> Eq DescribeUserResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeUserResponse -> DescribeUserResponse -> Bool
$c/= :: DescribeUserResponse -> DescribeUserResponse -> Bool
== :: DescribeUserResponse -> DescribeUserResponse -> Bool
$c== :: DescribeUserResponse -> DescribeUserResponse -> Bool
Prelude.Eq, Int -> DescribeUserResponse -> ShowS
[DescribeUserResponse] -> ShowS
DescribeUserResponse -> String
(Int -> DescribeUserResponse -> ShowS)
-> (DescribeUserResponse -> String)
-> ([DescribeUserResponse] -> ShowS)
-> Show DescribeUserResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeUserResponse] -> ShowS
$cshowList :: [DescribeUserResponse] -> ShowS
show :: DescribeUserResponse -> String
$cshow :: DescribeUserResponse -> String
showsPrec :: Int -> DescribeUserResponse -> ShowS
$cshowsPrec :: Int -> DescribeUserResponse -> ShowS
Prelude.Show, (forall x. DescribeUserResponse -> Rep DescribeUserResponse x)
-> (forall x. Rep DescribeUserResponse x -> DescribeUserResponse)
-> Generic DescribeUserResponse
forall x. Rep DescribeUserResponse x -> DescribeUserResponse
forall x. DescribeUserResponse -> Rep DescribeUserResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeUserResponse x -> DescribeUserResponse
$cfrom :: forall x. DescribeUserResponse -> Rep DescribeUserResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeUserResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'httpStatus', 'describeUserResponse_httpStatus' - The response's http status code.
--
-- 'userName', 'describeUserResponse_userName' - Contains the user’s user name value. The length limit is 128 characters.
-- This value can consist of letters, accented characters, symbols,
-- numbers, and punctuation. The characters @\<>;:%@ are excluded. This
-- value is specified at the time the user is created and stored as an
-- attribute of the user object in the identity store.
--
-- 'userId', 'describeUserResponse_userId' - The identifier for a user in the identity store.
newDescribeUserResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'userName'
  Prelude.Text ->
  -- | 'userId'
  Prelude.Text ->
  DescribeUserResponse
newDescribeUserResponse :: Int -> Text -> Text -> DescribeUserResponse
newDescribeUserResponse
  Int
pHttpStatus_
  Text
pUserName_
  Text
pUserId_ =
    DescribeUserResponse' :: Int -> Sensitive Text -> Text -> DescribeUserResponse
DescribeUserResponse'
      { $sel:httpStatus:DescribeUserResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:userName:DescribeUserResponse' :: Sensitive Text
userName = 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
pUserName_,
        $sel:userId:DescribeUserResponse' :: Text
userId = Text
pUserId_
      }

-- | The response's http status code.
describeUserResponse_httpStatus :: Lens.Lens' DescribeUserResponse Prelude.Int
describeUserResponse_httpStatus :: (Int -> f Int) -> DescribeUserResponse -> f DescribeUserResponse
describeUserResponse_httpStatus = (DescribeUserResponse -> Int)
-> (DescribeUserResponse -> Int -> DescribeUserResponse)
-> Lens DescribeUserResponse DescribeUserResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUserResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeUserResponse' :: DescribeUserResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeUserResponse
s@DescribeUserResponse' {} Int
a -> DescribeUserResponse
s {$sel:httpStatus:DescribeUserResponse' :: Int
httpStatus = Int
a} :: DescribeUserResponse)

-- | Contains the user’s user name value. The length limit is 128 characters.
-- This value can consist of letters, accented characters, symbols,
-- numbers, and punctuation. The characters @\<>;:%@ are excluded. This
-- value is specified at the time the user is created and stored as an
-- attribute of the user object in the identity store.
describeUserResponse_userName :: Lens.Lens' DescribeUserResponse Prelude.Text
describeUserResponse_userName :: (Text -> f Text) -> DescribeUserResponse -> f DescribeUserResponse
describeUserResponse_userName = (DescribeUserResponse -> Sensitive Text)
-> (DescribeUserResponse -> Sensitive Text -> DescribeUserResponse)
-> Lens
     DescribeUserResponse
     DescribeUserResponse
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUserResponse' {Sensitive Text
userName :: Sensitive Text
$sel:userName:DescribeUserResponse' :: DescribeUserResponse -> Sensitive Text
userName} -> Sensitive Text
userName) (\s :: DescribeUserResponse
s@DescribeUserResponse' {} Sensitive Text
a -> DescribeUserResponse
s {$sel:userName:DescribeUserResponse' :: Sensitive Text
userName = Sensitive Text
a} :: DescribeUserResponse) ((Sensitive Text -> f (Sensitive Text))
 -> DescribeUserResponse -> f DescribeUserResponse)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> DescribeUserResponse
-> f DescribeUserResponse
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

-- | The identifier for a user in the identity store.
describeUserResponse_userId :: Lens.Lens' DescribeUserResponse Prelude.Text
describeUserResponse_userId :: (Text -> f Text) -> DescribeUserResponse -> f DescribeUserResponse
describeUserResponse_userId = (DescribeUserResponse -> Text)
-> (DescribeUserResponse -> Text -> DescribeUserResponse)
-> Lens DescribeUserResponse DescribeUserResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUserResponse' {Text
userId :: Text
$sel:userId:DescribeUserResponse' :: DescribeUserResponse -> Text
userId} -> Text
userId) (\s :: DescribeUserResponse
s@DescribeUserResponse' {} Text
a -> DescribeUserResponse
s {$sel:userId:DescribeUserResponse' :: Text
userId = Text
a} :: DescribeUserResponse)

instance Prelude.NFData DescribeUserResponse