{-# 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.Chime.GetUser
-- 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 details for the specified user ID, such as primary email
-- address, license type,and personal meeting PIN.
--
-- To retrieve user details with an email address instead of a user ID, use
-- the ListUsers action, and then filter by email address.
module Amazonka.Chime.GetUser
  ( -- * Creating a Request
    GetUser (..),
    newGetUser,

    -- * Request Lenses
    getUser_accountId,
    getUser_userId,

    -- * Destructuring the Response
    GetUserResponse (..),
    newGetUserResponse,

    -- * Response Lenses
    getUserResponse_user,
    getUserResponse_httpStatus,
  )
where

import Amazonka.Chime.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:/ 'newGetUser' smart constructor.
data GetUser = GetUser'
  { -- | The Amazon Chime account ID.
    GetUser -> Text
accountId :: Prelude.Text,
    -- | The user ID.
    GetUser -> Text
userId :: Prelude.Text
  }
  deriving (GetUser -> GetUser -> Bool
(GetUser -> GetUser -> Bool)
-> (GetUser -> GetUser -> Bool) -> Eq GetUser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUser -> GetUser -> Bool
$c/= :: GetUser -> GetUser -> Bool
== :: GetUser -> GetUser -> Bool
$c== :: GetUser -> GetUser -> Bool
Prelude.Eq, ReadPrec [GetUser]
ReadPrec GetUser
Int -> ReadS GetUser
ReadS [GetUser]
(Int -> ReadS GetUser)
-> ReadS [GetUser]
-> ReadPrec GetUser
-> ReadPrec [GetUser]
-> Read GetUser
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetUser]
$creadListPrec :: ReadPrec [GetUser]
readPrec :: ReadPrec GetUser
$creadPrec :: ReadPrec GetUser
readList :: ReadS [GetUser]
$creadList :: ReadS [GetUser]
readsPrec :: Int -> ReadS GetUser
$creadsPrec :: Int -> ReadS GetUser
Prelude.Read, Int -> GetUser -> ShowS
[GetUser] -> ShowS
GetUser -> String
(Int -> GetUser -> ShowS)
-> (GetUser -> String) -> ([GetUser] -> ShowS) -> Show GetUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUser] -> ShowS
$cshowList :: [GetUser] -> ShowS
show :: GetUser -> String
$cshow :: GetUser -> String
showsPrec :: Int -> GetUser -> ShowS
$cshowsPrec :: Int -> GetUser -> ShowS
Prelude.Show, (forall x. GetUser -> Rep GetUser x)
-> (forall x. Rep GetUser x -> GetUser) -> Generic GetUser
forall x. Rep GetUser x -> GetUser
forall x. GetUser -> Rep GetUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetUser x -> GetUser
$cfrom :: forall x. GetUser -> Rep GetUser x
Prelude.Generic)

-- |
-- Create a value of 'GetUser' 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:
--
-- 'accountId', 'getUser_accountId' - The Amazon Chime account ID.
--
-- 'userId', 'getUser_userId' - The user ID.
newGetUser ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'userId'
  Prelude.Text ->
  GetUser
newGetUser :: Text -> Text -> GetUser
newGetUser Text
pAccountId_ Text
pUserId_ =
  GetUser' :: Text -> Text -> GetUser
GetUser'
    { $sel:accountId:GetUser' :: Text
accountId = Text
pAccountId_,
      $sel:userId:GetUser' :: Text
userId = Text
pUserId_
    }

-- | The Amazon Chime account ID.
getUser_accountId :: Lens.Lens' GetUser Prelude.Text
getUser_accountId :: (Text -> f Text) -> GetUser -> f GetUser
getUser_accountId = (GetUser -> Text)
-> (GetUser -> Text -> GetUser) -> Lens GetUser GetUser Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUser' {Text
accountId :: Text
$sel:accountId:GetUser' :: GetUser -> Text
accountId} -> Text
accountId) (\s :: GetUser
s@GetUser' {} Text
a -> GetUser
s {$sel:accountId:GetUser' :: Text
accountId = Text
a} :: GetUser)

-- | The user ID.
getUser_userId :: Lens.Lens' GetUser Prelude.Text
getUser_userId :: (Text -> f Text) -> GetUser -> f GetUser
getUser_userId = (GetUser -> Text)
-> (GetUser -> Text -> GetUser) -> Lens GetUser GetUser Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUser' {Text
userId :: Text
$sel:userId:GetUser' :: GetUser -> Text
userId} -> Text
userId) (\s :: GetUser
s@GetUser' {} Text
a -> GetUser
s {$sel:userId:GetUser' :: Text
userId = Text
a} :: GetUser)

instance Core.AWSRequest GetUser where
  type AWSResponse GetUser = GetUserResponse
  request :: GetUser -> Request GetUser
request = Service -> GetUser -> Request GetUser
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetUser)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetUser))
-> Logger
-> Service
-> Proxy GetUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetUser)))
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 -> GetUserResponse
GetUserResponse'
            (Maybe User -> Int -> GetUserResponse)
-> Either String (Maybe User)
-> Either String (Int -> GetUserResponse)
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 -> GetUserResponse)
-> Either String Int -> Either String GetUserResponse
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 GetUser

instance Prelude.NFData GetUser

instance Core.ToHeaders GetUser where
  toHeaders :: GetUser -> ResponseHeaders
toHeaders = ResponseHeaders -> GetUser -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath GetUser where
  toPath :: GetUser -> ByteString
toPath GetUser' {Text
userId :: Text
accountId :: Text
$sel:userId:GetUser' :: GetUser -> Text
$sel:accountId:GetUser' :: GetUser -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
accountId,
        ByteString
"/users/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
userId
      ]

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

-- | /See:/ 'newGetUserResponse' smart constructor.
data GetUserResponse = GetUserResponse'
  { -- | The user details.
    GetUserResponse -> Maybe User
user :: Prelude.Maybe User,
    -- | The response's http status code.
    GetUserResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetUserResponse -> GetUserResponse -> Bool
(GetUserResponse -> GetUserResponse -> Bool)
-> (GetUserResponse -> GetUserResponse -> Bool)
-> Eq GetUserResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUserResponse -> GetUserResponse -> Bool
$c/= :: GetUserResponse -> GetUserResponse -> Bool
== :: GetUserResponse -> GetUserResponse -> Bool
$c== :: GetUserResponse -> GetUserResponse -> Bool
Prelude.Eq, Int -> GetUserResponse -> ShowS
[GetUserResponse] -> ShowS
GetUserResponse -> String
(Int -> GetUserResponse -> ShowS)
-> (GetUserResponse -> String)
-> ([GetUserResponse] -> ShowS)
-> Show GetUserResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUserResponse] -> ShowS
$cshowList :: [GetUserResponse] -> ShowS
show :: GetUserResponse -> String
$cshow :: GetUserResponse -> String
showsPrec :: Int -> GetUserResponse -> ShowS
$cshowsPrec :: Int -> GetUserResponse -> ShowS
Prelude.Show, (forall x. GetUserResponse -> Rep GetUserResponse x)
-> (forall x. Rep GetUserResponse x -> GetUserResponse)
-> Generic GetUserResponse
forall x. Rep GetUserResponse x -> GetUserResponse
forall x. GetUserResponse -> Rep GetUserResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetUserResponse x -> GetUserResponse
$cfrom :: forall x. GetUserResponse -> Rep GetUserResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetUserResponse' 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', 'getUserResponse_user' - The user details.
--
-- 'httpStatus', 'getUserResponse_httpStatus' - The response's http status code.
newGetUserResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetUserResponse
newGetUserResponse :: Int -> GetUserResponse
newGetUserResponse Int
pHttpStatus_ =
  GetUserResponse' :: Maybe User -> Int -> GetUserResponse
GetUserResponse'
    { $sel:user:GetUserResponse' :: Maybe User
user = Maybe User
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetUserResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The user details.
getUserResponse_user :: Lens.Lens' GetUserResponse (Prelude.Maybe User)
getUserResponse_user :: (Maybe User -> f (Maybe User))
-> GetUserResponse -> f GetUserResponse
getUserResponse_user = (GetUserResponse -> Maybe User)
-> (GetUserResponse -> Maybe User -> GetUserResponse)
-> Lens GetUserResponse GetUserResponse (Maybe User) (Maybe User)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUserResponse' {Maybe User
user :: Maybe User
$sel:user:GetUserResponse' :: GetUserResponse -> Maybe User
user} -> Maybe User
user) (\s :: GetUserResponse
s@GetUserResponse' {} Maybe User
a -> GetUserResponse
s {$sel:user:GetUserResponse' :: Maybe User
user = Maybe User
a} :: GetUserResponse)

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

instance Prelude.NFData GetUserResponse