{-# 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.Connect.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)
--
-- Describes the specified user account. You can find the instance ID in
-- the console (it’s the final part of the ARN). The console does not
-- display the user IDs. Instead, list the users and note the IDs provided
-- in the output.
module Amazonka.Connect.DescribeUser
  ( -- * Creating a Request
    DescribeUser (..),
    newDescribeUser,

    -- * Request Lenses
    describeUser_userId,
    describeUser_instanceId,

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

    -- * Response Lenses
    describeUserResponse_user,
    describeUserResponse_httpStatus,
  )
where

import Amazonka.Connect.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

-- | /See:/ 'newDescribeUser' smart constructor.
data DescribeUser = DescribeUser'
  { -- | The identifier of the user account.
    DescribeUser -> Text
userId :: Prelude.Text,
    -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    DescribeUser -> Text
instanceId :: 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:
--
-- 'userId', 'describeUser_userId' - The identifier of the user account.
--
-- 'instanceId', 'describeUser_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
newDescribeUser ::
  -- | 'userId'
  Prelude.Text ->
  -- | 'instanceId'
  Prelude.Text ->
  DescribeUser
newDescribeUser :: Text -> Text -> DescribeUser
newDescribeUser Text
pUserId_ Text
pInstanceId_ =
  DescribeUser' :: Text -> Text -> DescribeUser
DescribeUser'
    { $sel:userId:DescribeUser' :: Text
userId = Text
pUserId_,
      $sel:instanceId:DescribeUser' :: Text
instanceId = Text
pInstanceId_
    }

-- | The identifier of the user account.
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)

-- | The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
describeUser_instanceId :: Lens.Lens' DescribeUser Prelude.Text
describeUser_instanceId :: (Text -> f Text) -> DescribeUser -> f DescribeUser
describeUser_instanceId = (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
instanceId :: Text
$sel:instanceId:DescribeUser' :: DescribeUser -> Text
instanceId} -> Text
instanceId) (\s :: DescribeUser
s@DescribeUser' {} Text
a -> DescribeUser
s {$sel:instanceId:DescribeUser' :: Text
instanceId = 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 => Service -> a -> Request a
Request.get 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 ->
          Maybe User -> Int -> DescribeUserResponse
DescribeUserResponse'
            (Maybe User -> Int -> DescribeUserResponse)
-> Either String (Maybe User)
-> Either String (Int -> DescribeUserResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe User)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"User")
            Either String (Int -> DescribeUserResponse)
-> Either String Int -> Either String DescribeUserResponse
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 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
"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 DescribeUser where
  toPath :: DescribeUser -> ByteString
toPath DescribeUser' {Text
instanceId :: Text
userId :: Text
$sel:instanceId:DescribeUser' :: DescribeUser -> Text
$sel:userId:DescribeUser' :: DescribeUser -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/users/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
instanceId,
        ByteString
"/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
userId
      ]

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'
  { -- | Information about the user account and configuration settings.
    DescribeUserResponse -> Maybe User
user :: Prelude.Maybe User,
    -- | The response's http status code.
    DescribeUserResponse -> Int
httpStatus :: Prelude.Int
  }
  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, ReadPrec [DescribeUserResponse]
ReadPrec DescribeUserResponse
Int -> ReadS DescribeUserResponse
ReadS [DescribeUserResponse]
(Int -> ReadS DescribeUserResponse)
-> ReadS [DescribeUserResponse]
-> ReadPrec DescribeUserResponse
-> ReadPrec [DescribeUserResponse]
-> Read DescribeUserResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeUserResponse]
$creadListPrec :: ReadPrec [DescribeUserResponse]
readPrec :: ReadPrec DescribeUserResponse
$creadPrec :: ReadPrec DescribeUserResponse
readList :: ReadS [DescribeUserResponse]
$creadList :: ReadS [DescribeUserResponse]
readsPrec :: Int -> ReadS DescribeUserResponse
$creadsPrec :: Int -> ReadS DescribeUserResponse
Prelude.Read, 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:
--
-- 'user', 'describeUserResponse_user' - Information about the user account and configuration settings.
--
-- 'httpStatus', 'describeUserResponse_httpStatus' - The response's http status code.
newDescribeUserResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeUserResponse
newDescribeUserResponse :: Int -> DescribeUserResponse
newDescribeUserResponse Int
pHttpStatus_ =
  DescribeUserResponse' :: Maybe User -> Int -> DescribeUserResponse
DescribeUserResponse'
    { $sel:user:DescribeUserResponse' :: Maybe User
user = Maybe User
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeUserResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the user account and configuration settings.
describeUserResponse_user :: Lens.Lens' DescribeUserResponse (Prelude.Maybe User)
describeUserResponse_user :: (Maybe User -> f (Maybe User))
-> DescribeUserResponse -> f DescribeUserResponse
describeUserResponse_user = (DescribeUserResponse -> Maybe User)
-> (DescribeUserResponse -> Maybe User -> DescribeUserResponse)
-> Lens
     DescribeUserResponse DescribeUserResponse (Maybe User) (Maybe User)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUserResponse' {Maybe User
user :: Maybe User
$sel:user:DescribeUserResponse' :: DescribeUserResponse -> Maybe User
user} -> Maybe User
user) (\s :: DescribeUserResponse
s@DescribeUserResponse' {} Maybe User
a -> DescribeUserResponse
s {$sel:user:DescribeUserResponse' :: Maybe User
user = Maybe User
a} :: DescribeUserResponse)

-- | 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)

instance Prelude.NFData DescribeUserResponse