{-# 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.CreateUser
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a user and associates them with an existing file transfer
-- protocol-enabled server. You can only create and associate users with
-- servers that have the @IdentityProviderType@ set to @SERVICE_MANAGED@.
-- Using parameters for @CreateUser@, you can specify the user name, set
-- the home directory, store the user\'s public key, and assign the user\'s
-- Identity and Access Management (IAM) role. You can also optionally add a
-- session policy, and assign metadata with tags that can be used to group
-- and search for users.
module Amazonka.Transfer.CreateUser
  ( -- * Creating a Request
    CreateUser (..),
    newCreateUser,

    -- * Request Lenses
    createUser_homeDirectory,
    createUser_homeDirectoryMappings,
    createUser_homeDirectoryType,
    createUser_policy,
    createUser_posixProfile,
    createUser_sshPublicKeyBody,
    createUser_tags,
    createUser_role,
    createUser_serverId,
    createUser_userName,

    -- * Destructuring the Response
    CreateUserResponse (..),
    newCreateUserResponse,

    -- * Response Lenses
    createUserResponse_httpStatus,
    createUserResponse_serverId,
    createUserResponse_userName,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Transfer.Types

-- | /See:/ 'newCreateUser' smart constructor.
data CreateUser = CreateUser'
  { -- | The landing directory (folder) for a user when they log in to the server
    -- using the client.
    --
    -- A @HomeDirectory@ example is @\/bucket_name\/home\/mydirectory@.
    CreateUser -> Maybe Text
homeDirectory :: Prelude.Maybe Prelude.Text,
    -- | Logical directory mappings that specify what Amazon S3 or Amazon EFS
    -- paths and keys should be visible to your user and how you want to make
    -- them visible. You must specify the @Entry@ and @Target@ pair, where
    -- @Entry@ shows how the path is made visible and @Target@ is the actual
    -- Amazon S3 or Amazon EFS path. If you only specify a target, it is
    -- displayed as is. You also must ensure that your Identity and Access
    -- Management (IAM) role provides access to paths in @Target@. This value
    -- can be set only when @HomeDirectoryType@ is set to /LOGICAL/.
    --
    -- The following is an @Entry@ and @Target@ pair example.
    --
    -- @[ { \"Entry\": \"\/directory1\", \"Target\": \"\/bucket_name\/home\/mydirectory\" } ]@
    --
    -- In most cases, you can use this value instead of the session policy to
    -- lock your user down to the designated home directory (\"@chroot@\"). To
    -- do this, you can set @Entry@ to @\/@ and set @Target@ to the
    -- HomeDirectory parameter value.
    --
    -- The following is an @Entry@ and @Target@ pair example for @chroot@.
    --
    -- @[ { \"Entry\": \"\/\", \"Target\": \"\/bucket_name\/home\/mydirectory\" } ]@
    CreateUser -> Maybe (NonEmpty HomeDirectoryMapEntry)
homeDirectoryMappings :: Prelude.Maybe (Prelude.NonEmpty HomeDirectoryMapEntry),
    -- | The type of landing directory (folder) that you want your users\' home
    -- directory to be when they log in to the server. If you set it to @PATH@,
    -- the user will see the absolute Amazon S3 bucket or EFS paths as is in
    -- their file transfer protocol clients. If you set it @LOGICAL@, you need
    -- to provide mappings in the @HomeDirectoryMappings@ for how you want to
    -- make Amazon S3 or Amazon EFS paths visible to your users.
    CreateUser -> Maybe HomeDirectoryType
homeDirectoryType :: Prelude.Maybe HomeDirectoryType,
    -- | A session policy for your user so that you can use the same Identity and
    -- Access Management (IAM) role across multiple users. This policy scopes
    -- down a user\'s access to portions of their Amazon S3 bucket. Variables
    -- that you can use inside this policy include @${Transfer:UserName}@,
    -- @${Transfer:HomeDirectory}@, and @${Transfer:HomeBucket}@.
    --
    -- This policy applies only when the domain of @ServerId@ is Amazon S3.
    -- Amazon EFS does not use session policies.
    --
    -- For session policies, Transfer Family stores the policy as a JSON blob,
    -- instead of the Amazon Resource Name (ARN) of the policy. You save the
    -- policy as a JSON blob and pass it in the @Policy@ argument.
    --
    -- For an example of a session policy, see
    -- <https://docs.aws.amazon.com/transfer/latest/userguide/session-policy.html Example session policy>.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html AssumeRole>
    -- in the /Amazon Web Services Security Token Service API Reference/.
    CreateUser -> Maybe Text
policy :: Prelude.Maybe Prelude.Text,
    -- | Specifies the full POSIX identity, including user ID (@Uid@), group ID
    -- (@Gid@), and any secondary groups IDs (@SecondaryGids@), that controls
    -- your users\' access to your Amazon EFS file systems. The POSIX
    -- permissions that are set on files and directories in Amazon EFS
    -- determine the level of access your users get when transferring files
    -- into and out of your Amazon EFS file systems.
    CreateUser -> Maybe PosixProfile
posixProfile :: Prelude.Maybe PosixProfile,
    -- | The public portion of the Secure Shell (SSH) key used to authenticate
    -- the user to the server.
    --
    -- Transfer Family accepts RSA, ECDSA, and ED25519 keys.
    CreateUser -> Maybe Text
sshPublicKeyBody :: Prelude.Maybe Prelude.Text,
    -- | Key-value pairs that can be used to group and search for users. Tags are
    -- metadata attached to users for any purpose.
    CreateUser -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The Amazon Resource Name (ARN) of the Identity and Access Management
    -- (IAM) role that controls your users\' access to your Amazon S3 bucket or
    -- Amazon EFS file system. The policies attached to this role determine the
    -- level of access that you want to provide your users when transferring
    -- files into and out of your Amazon S3 bucket or Amazon EFS file system.
    -- The IAM role should also contain a trust relationship that allows the
    -- server to access your resources when servicing your users\' transfer
    -- requests.
    CreateUser -> Text
role' :: Prelude.Text,
    -- | A system-assigned unique identifier for a server instance. This is the
    -- specific server that you added your user to.
    CreateUser -> Text
serverId :: Prelude.Text,
    -- | A unique string that identifies a user and is associated with a
    -- @ServerId@. This user name must be a minimum of 3 and a maximum of 100
    -- characters long. The following are valid characters: a-z, A-Z, 0-9,
    -- underscore \'_\', hyphen \'-\', period \'.\', and at sign \'\@\'. The
    -- user name can\'t start with a hyphen, period, or at sign.
    CreateUser -> Text
userName :: Prelude.Text
  }
  deriving (CreateUser -> CreateUser -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateUser -> CreateUser -> Bool
$c/= :: CreateUser -> CreateUser -> Bool
== :: CreateUser -> CreateUser -> Bool
$c== :: CreateUser -> CreateUser -> Bool
Prelude.Eq, ReadPrec [CreateUser]
ReadPrec CreateUser
Int -> ReadS CreateUser
ReadS [CreateUser]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateUser]
$creadListPrec :: ReadPrec [CreateUser]
readPrec :: ReadPrec CreateUser
$creadPrec :: ReadPrec CreateUser
readList :: ReadS [CreateUser]
$creadList :: ReadS [CreateUser]
readsPrec :: Int -> ReadS CreateUser
$creadsPrec :: Int -> ReadS CreateUser
Prelude.Read, Int -> CreateUser -> ShowS
[CreateUser] -> ShowS
CreateUser -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateUser] -> ShowS
$cshowList :: [CreateUser] -> ShowS
show :: CreateUser -> String
$cshow :: CreateUser -> String
showsPrec :: Int -> CreateUser -> ShowS
$cshowsPrec :: Int -> CreateUser -> ShowS
Prelude.Show, forall x. Rep CreateUser x -> CreateUser
forall x. CreateUser -> Rep CreateUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateUser x -> CreateUser
$cfrom :: forall x. CreateUser -> Rep CreateUser x
Prelude.Generic)

-- |
-- Create a value of 'CreateUser' 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:
--
-- 'homeDirectory', 'createUser_homeDirectory' - The landing directory (folder) for a user when they log in to the server
-- using the client.
--
-- A @HomeDirectory@ example is @\/bucket_name\/home\/mydirectory@.
--
-- 'homeDirectoryMappings', 'createUser_homeDirectoryMappings' - Logical directory mappings that specify what Amazon S3 or Amazon EFS
-- paths and keys should be visible to your user and how you want to make
-- them visible. You must specify the @Entry@ and @Target@ pair, where
-- @Entry@ shows how the path is made visible and @Target@ is the actual
-- Amazon S3 or Amazon EFS path. If you only specify a target, it is
-- displayed as is. You also must ensure that your Identity and Access
-- Management (IAM) role provides access to paths in @Target@. This value
-- can be set only when @HomeDirectoryType@ is set to /LOGICAL/.
--
-- The following is an @Entry@ and @Target@ pair example.
--
-- @[ { \"Entry\": \"\/directory1\", \"Target\": \"\/bucket_name\/home\/mydirectory\" } ]@
--
-- In most cases, you can use this value instead of the session policy to
-- lock your user down to the designated home directory (\"@chroot@\"). To
-- do this, you can set @Entry@ to @\/@ and set @Target@ to the
-- HomeDirectory parameter value.
--
-- The following is an @Entry@ and @Target@ pair example for @chroot@.
--
-- @[ { \"Entry\": \"\/\", \"Target\": \"\/bucket_name\/home\/mydirectory\" } ]@
--
-- 'homeDirectoryType', 'createUser_homeDirectoryType' - The type of landing directory (folder) that you want your users\' home
-- directory to be when they log in to the server. If you set it to @PATH@,
-- the user will see the absolute Amazon S3 bucket or EFS paths as is in
-- their file transfer protocol clients. If you set it @LOGICAL@, you need
-- to provide mappings in the @HomeDirectoryMappings@ for how you want to
-- make Amazon S3 or Amazon EFS paths visible to your users.
--
-- 'policy', 'createUser_policy' - A session policy for your user so that you can use the same Identity and
-- Access Management (IAM) role across multiple users. This policy scopes
-- down a user\'s access to portions of their Amazon S3 bucket. Variables
-- that you can use inside this policy include @${Transfer:UserName}@,
-- @${Transfer:HomeDirectory}@, and @${Transfer:HomeBucket}@.
--
-- This policy applies only when the domain of @ServerId@ is Amazon S3.
-- Amazon EFS does not use session policies.
--
-- For session policies, Transfer Family stores the policy as a JSON blob,
-- instead of the Amazon Resource Name (ARN) of the policy. You save the
-- policy as a JSON blob and pass it in the @Policy@ argument.
--
-- For an example of a session policy, see
-- <https://docs.aws.amazon.com/transfer/latest/userguide/session-policy.html Example session policy>.
--
-- For more information, see
-- <https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html AssumeRole>
-- in the /Amazon Web Services Security Token Service API Reference/.
--
-- 'posixProfile', 'createUser_posixProfile' - Specifies the full POSIX identity, including user ID (@Uid@), group ID
-- (@Gid@), and any secondary groups IDs (@SecondaryGids@), that controls
-- your users\' access to your Amazon EFS file systems. The POSIX
-- permissions that are set on files and directories in Amazon EFS
-- determine the level of access your users get when transferring files
-- into and out of your Amazon EFS file systems.
--
-- 'sshPublicKeyBody', 'createUser_sshPublicKeyBody' - The public portion of the Secure Shell (SSH) key used to authenticate
-- the user to the server.
--
-- Transfer Family accepts RSA, ECDSA, and ED25519 keys.
--
-- 'tags', 'createUser_tags' - Key-value pairs that can be used to group and search for users. Tags are
-- metadata attached to users for any purpose.
--
-- 'role'', 'createUser_role' - The Amazon Resource Name (ARN) of the Identity and Access Management
-- (IAM) role that controls your users\' access to your Amazon S3 bucket or
-- Amazon EFS file system. The policies attached to this role determine the
-- level of access that you want to provide your users when transferring
-- files into and out of your Amazon S3 bucket or Amazon EFS file system.
-- The IAM role should also contain a trust relationship that allows the
-- server to access your resources when servicing your users\' transfer
-- requests.
--
-- 'serverId', 'createUser_serverId' - A system-assigned unique identifier for a server instance. This is the
-- specific server that you added your user to.
--
-- 'userName', 'createUser_userName' - A unique string that identifies a user and is associated with a
-- @ServerId@. This user name must be a minimum of 3 and a maximum of 100
-- characters long. The following are valid characters: a-z, A-Z, 0-9,
-- underscore \'_\', hyphen \'-\', period \'.\', and at sign \'\@\'. The
-- user name can\'t start with a hyphen, period, or at sign.
newCreateUser ::
  -- | 'role''
  Prelude.Text ->
  -- | 'serverId'
  Prelude.Text ->
  -- | 'userName'
  Prelude.Text ->
  CreateUser
newCreateUser :: Text -> Text -> Text -> CreateUser
newCreateUser Text
pRole_ Text
pServerId_ Text
pUserName_ =
  CreateUser'
    { $sel:homeDirectory:CreateUser' :: Maybe Text
homeDirectory = forall a. Maybe a
Prelude.Nothing,
      $sel:homeDirectoryMappings:CreateUser' :: Maybe (NonEmpty HomeDirectoryMapEntry)
homeDirectoryMappings = forall a. Maybe a
Prelude.Nothing,
      $sel:homeDirectoryType:CreateUser' :: Maybe HomeDirectoryType
homeDirectoryType = forall a. Maybe a
Prelude.Nothing,
      $sel:policy:CreateUser' :: Maybe Text
policy = forall a. Maybe a
Prelude.Nothing,
      $sel:posixProfile:CreateUser' :: Maybe PosixProfile
posixProfile = forall a. Maybe a
Prelude.Nothing,
      $sel:sshPublicKeyBody:CreateUser' :: Maybe Text
sshPublicKeyBody = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateUser' :: Maybe (NonEmpty Tag)
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:role':CreateUser' :: Text
role' = Text
pRole_,
      $sel:serverId:CreateUser' :: Text
serverId = Text
pServerId_,
      $sel:userName:CreateUser' :: Text
userName = Text
pUserName_
    }

-- | The landing directory (folder) for a user when they log in to the server
-- using the client.
--
-- A @HomeDirectory@ example is @\/bucket_name\/home\/mydirectory@.
createUser_homeDirectory :: Lens.Lens' CreateUser (Prelude.Maybe Prelude.Text)
createUser_homeDirectory :: Lens' CreateUser (Maybe Text)
createUser_homeDirectory = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUser' {Maybe Text
homeDirectory :: Maybe Text
$sel:homeDirectory:CreateUser' :: CreateUser -> Maybe Text
homeDirectory} -> Maybe Text
homeDirectory) (\s :: CreateUser
s@CreateUser' {} Maybe Text
a -> CreateUser
s {$sel:homeDirectory:CreateUser' :: Maybe Text
homeDirectory = Maybe Text
a} :: CreateUser)

-- | Logical directory mappings that specify what Amazon S3 or Amazon EFS
-- paths and keys should be visible to your user and how you want to make
-- them visible. You must specify the @Entry@ and @Target@ pair, where
-- @Entry@ shows how the path is made visible and @Target@ is the actual
-- Amazon S3 or Amazon EFS path. If you only specify a target, it is
-- displayed as is. You also must ensure that your Identity and Access
-- Management (IAM) role provides access to paths in @Target@. This value
-- can be set only when @HomeDirectoryType@ is set to /LOGICAL/.
--
-- The following is an @Entry@ and @Target@ pair example.
--
-- @[ { \"Entry\": \"\/directory1\", \"Target\": \"\/bucket_name\/home\/mydirectory\" } ]@
--
-- In most cases, you can use this value instead of the session policy to
-- lock your user down to the designated home directory (\"@chroot@\"). To
-- do this, you can set @Entry@ to @\/@ and set @Target@ to the
-- HomeDirectory parameter value.
--
-- The following is an @Entry@ and @Target@ pair example for @chroot@.
--
-- @[ { \"Entry\": \"\/\", \"Target\": \"\/bucket_name\/home\/mydirectory\" } ]@
createUser_homeDirectoryMappings :: Lens.Lens' CreateUser (Prelude.Maybe (Prelude.NonEmpty HomeDirectoryMapEntry))
createUser_homeDirectoryMappings :: Lens' CreateUser (Maybe (NonEmpty HomeDirectoryMapEntry))
createUser_homeDirectoryMappings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUser' {Maybe (NonEmpty HomeDirectoryMapEntry)
homeDirectoryMappings :: Maybe (NonEmpty HomeDirectoryMapEntry)
$sel:homeDirectoryMappings:CreateUser' :: CreateUser -> Maybe (NonEmpty HomeDirectoryMapEntry)
homeDirectoryMappings} -> Maybe (NonEmpty HomeDirectoryMapEntry)
homeDirectoryMappings) (\s :: CreateUser
s@CreateUser' {} Maybe (NonEmpty HomeDirectoryMapEntry)
a -> CreateUser
s {$sel:homeDirectoryMappings:CreateUser' :: Maybe (NonEmpty HomeDirectoryMapEntry)
homeDirectoryMappings = Maybe (NonEmpty HomeDirectoryMapEntry)
a} :: CreateUser) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The type of landing directory (folder) that you want your users\' home
-- directory to be when they log in to the server. If you set it to @PATH@,
-- the user will see the absolute Amazon S3 bucket or EFS paths as is in
-- their file transfer protocol clients. If you set it @LOGICAL@, you need
-- to provide mappings in the @HomeDirectoryMappings@ for how you want to
-- make Amazon S3 or Amazon EFS paths visible to your users.
createUser_homeDirectoryType :: Lens.Lens' CreateUser (Prelude.Maybe HomeDirectoryType)
createUser_homeDirectoryType :: Lens' CreateUser (Maybe HomeDirectoryType)
createUser_homeDirectoryType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUser' {Maybe HomeDirectoryType
homeDirectoryType :: Maybe HomeDirectoryType
$sel:homeDirectoryType:CreateUser' :: CreateUser -> Maybe HomeDirectoryType
homeDirectoryType} -> Maybe HomeDirectoryType
homeDirectoryType) (\s :: CreateUser
s@CreateUser' {} Maybe HomeDirectoryType
a -> CreateUser
s {$sel:homeDirectoryType:CreateUser' :: Maybe HomeDirectoryType
homeDirectoryType = Maybe HomeDirectoryType
a} :: CreateUser)

-- | A session policy for your user so that you can use the same Identity and
-- Access Management (IAM) role across multiple users. This policy scopes
-- down a user\'s access to portions of their Amazon S3 bucket. Variables
-- that you can use inside this policy include @${Transfer:UserName}@,
-- @${Transfer:HomeDirectory}@, and @${Transfer:HomeBucket}@.
--
-- This policy applies only when the domain of @ServerId@ is Amazon S3.
-- Amazon EFS does not use session policies.
--
-- For session policies, Transfer Family stores the policy as a JSON blob,
-- instead of the Amazon Resource Name (ARN) of the policy. You save the
-- policy as a JSON blob and pass it in the @Policy@ argument.
--
-- For an example of a session policy, see
-- <https://docs.aws.amazon.com/transfer/latest/userguide/session-policy.html Example session policy>.
--
-- For more information, see
-- <https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html AssumeRole>
-- in the /Amazon Web Services Security Token Service API Reference/.
createUser_policy :: Lens.Lens' CreateUser (Prelude.Maybe Prelude.Text)
createUser_policy :: Lens' CreateUser (Maybe Text)
createUser_policy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUser' {Maybe Text
policy :: Maybe Text
$sel:policy:CreateUser' :: CreateUser -> Maybe Text
policy} -> Maybe Text
policy) (\s :: CreateUser
s@CreateUser' {} Maybe Text
a -> CreateUser
s {$sel:policy:CreateUser' :: Maybe Text
policy = Maybe Text
a} :: CreateUser)

-- | Specifies the full POSIX identity, including user ID (@Uid@), group ID
-- (@Gid@), and any secondary groups IDs (@SecondaryGids@), that controls
-- your users\' access to your Amazon EFS file systems. The POSIX
-- permissions that are set on files and directories in Amazon EFS
-- determine the level of access your users get when transferring files
-- into and out of your Amazon EFS file systems.
createUser_posixProfile :: Lens.Lens' CreateUser (Prelude.Maybe PosixProfile)
createUser_posixProfile :: Lens' CreateUser (Maybe PosixProfile)
createUser_posixProfile = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUser' {Maybe PosixProfile
posixProfile :: Maybe PosixProfile
$sel:posixProfile:CreateUser' :: CreateUser -> Maybe PosixProfile
posixProfile} -> Maybe PosixProfile
posixProfile) (\s :: CreateUser
s@CreateUser' {} Maybe PosixProfile
a -> CreateUser
s {$sel:posixProfile:CreateUser' :: Maybe PosixProfile
posixProfile = Maybe PosixProfile
a} :: CreateUser)

-- | The public portion of the Secure Shell (SSH) key used to authenticate
-- the user to the server.
--
-- Transfer Family accepts RSA, ECDSA, and ED25519 keys.
createUser_sshPublicKeyBody :: Lens.Lens' CreateUser (Prelude.Maybe Prelude.Text)
createUser_sshPublicKeyBody :: Lens' CreateUser (Maybe Text)
createUser_sshPublicKeyBody = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUser' {Maybe Text
sshPublicKeyBody :: Maybe Text
$sel:sshPublicKeyBody:CreateUser' :: CreateUser -> Maybe Text
sshPublicKeyBody} -> Maybe Text
sshPublicKeyBody) (\s :: CreateUser
s@CreateUser' {} Maybe Text
a -> CreateUser
s {$sel:sshPublicKeyBody:CreateUser' :: Maybe Text
sshPublicKeyBody = Maybe Text
a} :: CreateUser)

-- | Key-value pairs that can be used to group and search for users. Tags are
-- metadata attached to users for any purpose.
createUser_tags :: Lens.Lens' CreateUser (Prelude.Maybe (Prelude.NonEmpty Tag))
createUser_tags :: Lens' CreateUser (Maybe (NonEmpty Tag))
createUser_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUser' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateUser' :: CreateUser -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateUser
s@CreateUser' {} Maybe (NonEmpty Tag)
a -> CreateUser
s {$sel:tags:CreateUser' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateUser) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of the Identity and Access Management
-- (IAM) role that controls your users\' access to your Amazon S3 bucket or
-- Amazon EFS file system. The policies attached to this role determine the
-- level of access that you want to provide your users when transferring
-- files into and out of your Amazon S3 bucket or Amazon EFS file system.
-- The IAM role should also contain a trust relationship that allows the
-- server to access your resources when servicing your users\' transfer
-- requests.
createUser_role :: Lens.Lens' CreateUser Prelude.Text
createUser_role :: Lens' CreateUser Text
createUser_role = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUser' {Text
role' :: Text
$sel:role':CreateUser' :: CreateUser -> Text
role'} -> Text
role') (\s :: CreateUser
s@CreateUser' {} Text
a -> CreateUser
s {$sel:role':CreateUser' :: Text
role' = Text
a} :: CreateUser)

-- | A system-assigned unique identifier for a server instance. This is the
-- specific server that you added your user to.
createUser_serverId :: Lens.Lens' CreateUser Prelude.Text
createUser_serverId :: Lens' CreateUser Text
createUser_serverId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUser' {Text
serverId :: Text
$sel:serverId:CreateUser' :: CreateUser -> Text
serverId} -> Text
serverId) (\s :: CreateUser
s@CreateUser' {} Text
a -> CreateUser
s {$sel:serverId:CreateUser' :: Text
serverId = Text
a} :: CreateUser)

-- | A unique string that identifies a user and is associated with a
-- @ServerId@. This user name must be a minimum of 3 and a maximum of 100
-- characters long. The following are valid characters: a-z, A-Z, 0-9,
-- underscore \'_\', hyphen \'-\', period \'.\', and at sign \'\@\'. The
-- user name can\'t start with a hyphen, period, or at sign.
createUser_userName :: Lens.Lens' CreateUser Prelude.Text
createUser_userName :: Lens' CreateUser Text
createUser_userName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUser' {Text
userName :: Text
$sel:userName:CreateUser' :: CreateUser -> Text
userName} -> Text
userName) (\s :: CreateUser
s@CreateUser' {} Text
a -> CreateUser
s {$sel:userName:CreateUser' :: Text
userName = Text
a} :: CreateUser)

instance Core.AWSRequest CreateUser where
  type AWSResponse CreateUser = CreateUserResponse
  request :: (Service -> Service) -> CreateUser -> Request CreateUser
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateUser)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Text -> Text -> CreateUserResponse
CreateUserResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"ServerId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"UserName")
      )

instance Prelude.Hashable CreateUser where
  hashWithSalt :: Int -> CreateUser -> Int
hashWithSalt Int
_salt CreateUser' {Maybe (NonEmpty HomeDirectoryMapEntry)
Maybe (NonEmpty Tag)
Maybe Text
Maybe HomeDirectoryType
Maybe PosixProfile
Text
userName :: Text
serverId :: Text
role' :: Text
tags :: Maybe (NonEmpty Tag)
sshPublicKeyBody :: Maybe Text
posixProfile :: Maybe PosixProfile
policy :: Maybe Text
homeDirectoryType :: Maybe HomeDirectoryType
homeDirectoryMappings :: Maybe (NonEmpty HomeDirectoryMapEntry)
homeDirectory :: Maybe Text
$sel:userName:CreateUser' :: CreateUser -> Text
$sel:serverId:CreateUser' :: CreateUser -> Text
$sel:role':CreateUser' :: CreateUser -> Text
$sel:tags:CreateUser' :: CreateUser -> Maybe (NonEmpty Tag)
$sel:sshPublicKeyBody:CreateUser' :: CreateUser -> Maybe Text
$sel:posixProfile:CreateUser' :: CreateUser -> Maybe PosixProfile
$sel:policy:CreateUser' :: CreateUser -> Maybe Text
$sel:homeDirectoryType:CreateUser' :: CreateUser -> Maybe HomeDirectoryType
$sel:homeDirectoryMappings:CreateUser' :: CreateUser -> Maybe (NonEmpty HomeDirectoryMapEntry)
$sel:homeDirectory:CreateUser' :: CreateUser -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
homeDirectory
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty HomeDirectoryMapEntry)
homeDirectoryMappings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe HomeDirectoryType
homeDirectoryType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
policy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PosixProfile
posixProfile
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sshPublicKeyBody
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Tag)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
role'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
serverId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userName

instance Prelude.NFData CreateUser where
  rnf :: CreateUser -> ()
rnf CreateUser' {Maybe (NonEmpty HomeDirectoryMapEntry)
Maybe (NonEmpty Tag)
Maybe Text
Maybe HomeDirectoryType
Maybe PosixProfile
Text
userName :: Text
serverId :: Text
role' :: Text
tags :: Maybe (NonEmpty Tag)
sshPublicKeyBody :: Maybe Text
posixProfile :: Maybe PosixProfile
policy :: Maybe Text
homeDirectoryType :: Maybe HomeDirectoryType
homeDirectoryMappings :: Maybe (NonEmpty HomeDirectoryMapEntry)
homeDirectory :: Maybe Text
$sel:userName:CreateUser' :: CreateUser -> Text
$sel:serverId:CreateUser' :: CreateUser -> Text
$sel:role':CreateUser' :: CreateUser -> Text
$sel:tags:CreateUser' :: CreateUser -> Maybe (NonEmpty Tag)
$sel:sshPublicKeyBody:CreateUser' :: CreateUser -> Maybe Text
$sel:posixProfile:CreateUser' :: CreateUser -> Maybe PosixProfile
$sel:policy:CreateUser' :: CreateUser -> Maybe Text
$sel:homeDirectoryType:CreateUser' :: CreateUser -> Maybe HomeDirectoryType
$sel:homeDirectoryMappings:CreateUser' :: CreateUser -> Maybe (NonEmpty HomeDirectoryMapEntry)
$sel:homeDirectory:CreateUser' :: CreateUser -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
homeDirectory
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty HomeDirectoryMapEntry)
homeDirectoryMappings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe HomeDirectoryType
homeDirectoryType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PosixProfile
posixProfile
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sshPublicKeyBody
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Tag)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
role'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
serverId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userName

instance Data.ToHeaders CreateUser where
  toHeaders :: CreateUser -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"TransferService.CreateUser" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON CreateUser where
  toJSON :: CreateUser -> Value
toJSON CreateUser' {Maybe (NonEmpty HomeDirectoryMapEntry)
Maybe (NonEmpty Tag)
Maybe Text
Maybe HomeDirectoryType
Maybe PosixProfile
Text
userName :: Text
serverId :: Text
role' :: Text
tags :: Maybe (NonEmpty Tag)
sshPublicKeyBody :: Maybe Text
posixProfile :: Maybe PosixProfile
policy :: Maybe Text
homeDirectoryType :: Maybe HomeDirectoryType
homeDirectoryMappings :: Maybe (NonEmpty HomeDirectoryMapEntry)
homeDirectory :: Maybe Text
$sel:userName:CreateUser' :: CreateUser -> Text
$sel:serverId:CreateUser' :: CreateUser -> Text
$sel:role':CreateUser' :: CreateUser -> Text
$sel:tags:CreateUser' :: CreateUser -> Maybe (NonEmpty Tag)
$sel:sshPublicKeyBody:CreateUser' :: CreateUser -> Maybe Text
$sel:posixProfile:CreateUser' :: CreateUser -> Maybe PosixProfile
$sel:policy:CreateUser' :: CreateUser -> Maybe Text
$sel:homeDirectoryType:CreateUser' :: CreateUser -> Maybe HomeDirectoryType
$sel:homeDirectoryMappings:CreateUser' :: CreateUser -> Maybe (NonEmpty HomeDirectoryMapEntry)
$sel:homeDirectory:CreateUser' :: CreateUser -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"HomeDirectory" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
homeDirectory,
            (Key
"HomeDirectoryMappings" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty HomeDirectoryMapEntry)
homeDirectoryMappings,
            (Key
"HomeDirectoryType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HomeDirectoryType
homeDirectoryType,
            (Key
"Policy" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
policy,
            (Key
"PosixProfile" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PosixProfile
posixProfile,
            (Key
"SshPublicKeyBody" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sshPublicKeyBody,
            (Key
"Tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
tags,
            forall a. a -> Maybe a
Prelude.Just (Key
"Role" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
role'),
            forall a. a -> Maybe a
Prelude.Just (Key
"ServerId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
serverId),
            forall a. a -> Maybe a
Prelude.Just (Key
"UserName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
userName)
          ]
      )

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

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

-- | /See:/ 'newCreateUserResponse' smart constructor.
data CreateUserResponse = CreateUserResponse'
  { -- | The response's http status code.
    CreateUserResponse -> Int
httpStatus :: Prelude.Int,
    -- | The identifier of the server that the user is attached to.
    CreateUserResponse -> Text
serverId :: Prelude.Text,
    -- | A unique string that identifies a user account associated with a server.
    CreateUserResponse -> Text
userName :: Prelude.Text
  }
  deriving (CreateUserResponse -> CreateUserResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateUserResponse -> CreateUserResponse -> Bool
$c/= :: CreateUserResponse -> CreateUserResponse -> Bool
== :: CreateUserResponse -> CreateUserResponse -> Bool
$c== :: CreateUserResponse -> CreateUserResponse -> Bool
Prelude.Eq, ReadPrec [CreateUserResponse]
ReadPrec CreateUserResponse
Int -> ReadS CreateUserResponse
ReadS [CreateUserResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateUserResponse]
$creadListPrec :: ReadPrec [CreateUserResponse]
readPrec :: ReadPrec CreateUserResponse
$creadPrec :: ReadPrec CreateUserResponse
readList :: ReadS [CreateUserResponse]
$creadList :: ReadS [CreateUserResponse]
readsPrec :: Int -> ReadS CreateUserResponse
$creadsPrec :: Int -> ReadS CreateUserResponse
Prelude.Read, Int -> CreateUserResponse -> ShowS
[CreateUserResponse] -> ShowS
CreateUserResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateUserResponse] -> ShowS
$cshowList :: [CreateUserResponse] -> ShowS
show :: CreateUserResponse -> String
$cshow :: CreateUserResponse -> String
showsPrec :: Int -> CreateUserResponse -> ShowS
$cshowsPrec :: Int -> CreateUserResponse -> ShowS
Prelude.Show, forall x. Rep CreateUserResponse x -> CreateUserResponse
forall x. CreateUserResponse -> Rep CreateUserResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateUserResponse x -> CreateUserResponse
$cfrom :: forall x. CreateUserResponse -> Rep CreateUserResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateUserResponse' 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', 'createUserResponse_httpStatus' - The response's http status code.
--
-- 'serverId', 'createUserResponse_serverId' - The identifier of the server that the user is attached to.
--
-- 'userName', 'createUserResponse_userName' - A unique string that identifies a user account associated with a server.
newCreateUserResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'serverId'
  Prelude.Text ->
  -- | 'userName'
  Prelude.Text ->
  CreateUserResponse
newCreateUserResponse :: Int -> Text -> Text -> CreateUserResponse
newCreateUserResponse
  Int
pHttpStatus_
  Text
pServerId_
  Text
pUserName_ =
    CreateUserResponse'
      { $sel:httpStatus:CreateUserResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:serverId:CreateUserResponse' :: Text
serverId = Text
pServerId_,
        $sel:userName:CreateUserResponse' :: Text
userName = Text
pUserName_
      }

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

-- | The identifier of the server that the user is attached to.
createUserResponse_serverId :: Lens.Lens' CreateUserResponse Prelude.Text
createUserResponse_serverId :: Lens' CreateUserResponse Text
createUserResponse_serverId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUserResponse' {Text
serverId :: Text
$sel:serverId:CreateUserResponse' :: CreateUserResponse -> Text
serverId} -> Text
serverId) (\s :: CreateUserResponse
s@CreateUserResponse' {} Text
a -> CreateUserResponse
s {$sel:serverId:CreateUserResponse' :: Text
serverId = Text
a} :: CreateUserResponse)

-- | A unique string that identifies a user account associated with a server.
createUserResponse_userName :: Lens.Lens' CreateUserResponse Prelude.Text
createUserResponse_userName :: Lens' CreateUserResponse Text
createUserResponse_userName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUserResponse' {Text
userName :: Text
$sel:userName:CreateUserResponse' :: CreateUserResponse -> Text
userName} -> Text
userName) (\s :: CreateUserResponse
s@CreateUserResponse' {} Text
a -> CreateUserResponse
s {$sel:userName:CreateUserResponse' :: Text
userName = Text
a} :: CreateUserResponse)

instance Prelude.NFData CreateUserResponse where
  rnf :: CreateUserResponse -> ()
rnf CreateUserResponse' {Int
Text
userName :: Text
serverId :: Text
httpStatus :: Int
$sel:userName:CreateUserResponse' :: CreateUserResponse -> Text
$sel:serverId:CreateUserResponse' :: CreateUserResponse -> Text
$sel:httpStatus:CreateUserResponse' :: CreateUserResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
serverId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userName