{-# 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.Transfer.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 user assigned to the specific file transfer
-- protocol-enabled server, as identified by its @ServerId@ property.
--
-- The response from this call returns the properties of the user
-- associated with the @ServerId@ value that was specified.
module Amazonka.Transfer.DescribeUser
  ( -- * Creating a Request
    DescribeUser (..),
    newDescribeUser,

    -- * Request Lenses
    describeUser_serverId,
    describeUser_userName,

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

    -- * Response Lenses
    describeUserResponse_httpStatus,
    describeUserResponse_serverId,
    describeUserResponse_user,
  )
where

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
import Amazonka.Transfer.Types

-- | /See:/ 'newDescribeUser' smart constructor.
data DescribeUser = DescribeUser'
  { -- | A system-assigned unique identifier for a server that has this user
    -- assigned.
    DescribeUser -> Text
serverId :: Prelude.Text,
    -- | The name of the user assigned to one or more servers. User names are
    -- part of the sign-in credentials to use the Amazon Web Services Transfer
    -- Family service and perform file transfer tasks.
    DescribeUser -> Text
userName :: 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:
--
-- 'serverId', 'describeUser_serverId' - A system-assigned unique identifier for a server that has this user
-- assigned.
--
-- 'userName', 'describeUser_userName' - The name of the user assigned to one or more servers. User names are
-- part of the sign-in credentials to use the Amazon Web Services Transfer
-- Family service and perform file transfer tasks.
newDescribeUser ::
  -- | 'serverId'
  Prelude.Text ->
  -- | 'userName'
  Prelude.Text ->
  DescribeUser
newDescribeUser :: Text -> Text -> DescribeUser
newDescribeUser Text
pServerId_ Text
pUserName_ =
  DescribeUser' :: Text -> Text -> DescribeUser
DescribeUser'
    { $sel:serverId:DescribeUser' :: Text
serverId = Text
pServerId_,
      $sel:userName:DescribeUser' :: Text
userName = Text
pUserName_
    }

-- | A system-assigned unique identifier for a server that has this user
-- assigned.
describeUser_serverId :: Lens.Lens' DescribeUser Prelude.Text
describeUser_serverId :: (Text -> f Text) -> DescribeUser -> f DescribeUser
describeUser_serverId = (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
serverId :: Text
$sel:serverId:DescribeUser' :: DescribeUser -> Text
serverId} -> Text
serverId) (\s :: DescribeUser
s@DescribeUser' {} Text
a -> DescribeUser
s {$sel:serverId:DescribeUser' :: Text
serverId = Text
a} :: DescribeUser)

-- | The name of the user assigned to one or more servers. User names are
-- part of the sign-in credentials to use the Amazon Web Services Transfer
-- Family service and perform file transfer tasks.
describeUser_userName :: Lens.Lens' DescribeUser Prelude.Text
describeUser_userName :: (Text -> f Text) -> DescribeUser -> f DescribeUser
describeUser_userName = (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
userName :: Text
$sel:userName:DescribeUser' :: DescribeUser -> Text
userName} -> Text
userName) (\s :: DescribeUser
s@DescribeUser' {} Text
a -> DescribeUser
s {$sel:userName:DescribeUser' :: Text
userName = 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 -> Text -> DescribedUser -> DescribeUserResponse
DescribeUserResponse'
            (Int -> Text -> DescribedUser -> DescribeUserResponse)
-> Either String Int
-> Either String (Text -> DescribedUser -> 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 (Text -> DescribedUser -> DescribeUserResponse)
-> Either String Text
-> Either String (DescribedUser -> 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
"ServerId")
            Either String (DescribedUser -> DescribeUserResponse)
-> Either String DescribedUser
-> Either String DescribeUserResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String DescribedUser
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"User")
      )

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
"TransferService.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
userName :: Text
serverId :: Text
$sel:userName:DescribeUser' :: DescribeUser -> Text
$sel:serverId: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
"ServerId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serverId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UserName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userName)
          ]
      )

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,
    -- | A system-assigned unique identifier for a server that has this user
    -- assigned.
    DescribeUserResponse -> Text
serverId :: Prelude.Text,
    -- | An array containing the properties of the user account for the
    -- @ServerID@ value that you specified.
    DescribeUserResponse -> DescribedUser
user :: DescribedUser
  }
  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:
--
-- 'httpStatus', 'describeUserResponse_httpStatus' - The response's http status code.
--
-- 'serverId', 'describeUserResponse_serverId' - A system-assigned unique identifier for a server that has this user
-- assigned.
--
-- 'user', 'describeUserResponse_user' - An array containing the properties of the user account for the
-- @ServerID@ value that you specified.
newDescribeUserResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'serverId'
  Prelude.Text ->
  -- | 'user'
  DescribedUser ->
  DescribeUserResponse
newDescribeUserResponse :: Int -> Text -> DescribedUser -> DescribeUserResponse
newDescribeUserResponse
  Int
pHttpStatus_
  Text
pServerId_
  DescribedUser
pUser_ =
    DescribeUserResponse' :: Int -> Text -> DescribedUser -> DescribeUserResponse
DescribeUserResponse'
      { $sel:httpStatus:DescribeUserResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:serverId:DescribeUserResponse' :: Text
serverId = Text
pServerId_,
        $sel:user:DescribeUserResponse' :: DescribedUser
user = DescribedUser
pUser_
      }

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

-- | A system-assigned unique identifier for a server that has this user
-- assigned.
describeUserResponse_serverId :: Lens.Lens' DescribeUserResponse Prelude.Text
describeUserResponse_serverId :: (Text -> f Text) -> DescribeUserResponse -> f DescribeUserResponse
describeUserResponse_serverId = (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
serverId :: Text
$sel:serverId:DescribeUserResponse' :: DescribeUserResponse -> Text
serverId} -> Text
serverId) (\s :: DescribeUserResponse
s@DescribeUserResponse' {} Text
a -> DescribeUserResponse
s {$sel:serverId:DescribeUserResponse' :: Text
serverId = Text
a} :: DescribeUserResponse)

-- | An array containing the properties of the user account for the
-- @ServerID@ value that you specified.
describeUserResponse_user :: Lens.Lens' DescribeUserResponse DescribedUser
describeUserResponse_user :: (DescribedUser -> f DescribedUser)
-> DescribeUserResponse -> f DescribeUserResponse
describeUserResponse_user = (DescribeUserResponse -> DescribedUser)
-> (DescribeUserResponse -> DescribedUser -> DescribeUserResponse)
-> Lens
     DescribeUserResponse
     DescribeUserResponse
     DescribedUser
     DescribedUser
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUserResponse' {DescribedUser
user :: DescribedUser
$sel:user:DescribeUserResponse' :: DescribeUserResponse -> DescribedUser
user} -> DescribedUser
user) (\s :: DescribeUserResponse
s@DescribeUserResponse' {} DescribedUser
a -> DescribeUserResponse
s {$sel:user:DescribeUserResponse' :: DescribedUser
user = DescribedUser
a} :: DescribeUserResponse)

instance Prelude.NFData DescribeUserResponse