{-# 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.MemoryDb.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 MemoryDB user. For more information, see -- . module Amazonka.MemoryDb.CreateUser ( -- * Creating a Request CreateUser (..), newCreateUser, -- * Request Lenses createUser_tags, createUser_userName, createUser_authenticationMode, createUser_accessString, -- * Destructuring the Response CreateUserResponse (..), newCreateUserResponse, -- * Response Lenses createUserResponse_user, createUserResponse_httpStatus, ) where import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import Amazonka.MemoryDb.Types import qualified Amazonka.Prelude as Prelude import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | /See:/ 'newCreateUser' smart constructor. data CreateUser = CreateUser' { -- | A list of tags to be added to this resource. A tag is a key-value pair. -- A tag key must be accompanied by a tag value, although null is accepted. tags :: Prelude.Maybe [Tag], -- | The name of the user. This value must be unique as it also serves as the -- user identifier. userName :: Prelude.Text, -- | Denotes the user\'s authentication properties, such as whether it -- requires a password to authenticate. authenticationMode :: AuthenticationMode, -- | Access permissions string used for this user. accessString :: Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'CreateUser' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'tags', 'createUser_tags' - A list of tags to be added to this resource. A tag is a key-value pair. -- A tag key must be accompanied by a tag value, although null is accepted. -- -- 'userName', 'createUser_userName' - The name of the user. This value must be unique as it also serves as the -- user identifier. -- -- 'authenticationMode', 'createUser_authenticationMode' - Denotes the user\'s authentication properties, such as whether it -- requires a password to authenticate. -- -- 'accessString', 'createUser_accessString' - Access permissions string used for this user. newCreateUser :: -- | 'userName' Prelude.Text -> -- | 'authenticationMode' AuthenticationMode -> -- | 'accessString' Prelude.Text -> CreateUser newCreateUser pUserName_ pAuthenticationMode_ pAccessString_ = CreateUser' { tags = Prelude.Nothing, userName = pUserName_, authenticationMode = pAuthenticationMode_, accessString = pAccessString_ } -- | A list of tags to be added to this resource. A tag is a key-value pair. -- A tag key must be accompanied by a tag value, although null is accepted. createUser_tags :: Lens.Lens' CreateUser (Prelude.Maybe [Tag]) createUser_tags = Lens.lens (\CreateUser' {tags} -> tags) (\s@CreateUser' {} a -> s {tags = a} :: CreateUser) Prelude.. Lens.mapping Lens.coerced -- | The name of the user. This value must be unique as it also serves as the -- user identifier. createUser_userName :: Lens.Lens' CreateUser Prelude.Text createUser_userName = Lens.lens (\CreateUser' {userName} -> userName) (\s@CreateUser' {} a -> s {userName = a} :: CreateUser) -- | Denotes the user\'s authentication properties, such as whether it -- requires a password to authenticate. createUser_authenticationMode :: Lens.Lens' CreateUser AuthenticationMode createUser_authenticationMode = Lens.lens (\CreateUser' {authenticationMode} -> authenticationMode) (\s@CreateUser' {} a -> s {authenticationMode = a} :: CreateUser) -- | Access permissions string used for this user. createUser_accessString :: Lens.Lens' CreateUser Prelude.Text createUser_accessString = Lens.lens (\CreateUser' {accessString} -> accessString) (\s@CreateUser' {} a -> s {accessString = a} :: CreateUser) instance Core.AWSRequest CreateUser where type AWSResponse CreateUser = CreateUserResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> CreateUserResponse' Prelude.<$> (x Data..?> "User") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable CreateUser where hashWithSalt _salt CreateUser' {..} = _salt `Prelude.hashWithSalt` tags `Prelude.hashWithSalt` userName `Prelude.hashWithSalt` authenticationMode `Prelude.hashWithSalt` accessString instance Prelude.NFData CreateUser where rnf CreateUser' {..} = Prelude.rnf tags `Prelude.seq` Prelude.rnf userName `Prelude.seq` Prelude.rnf authenticationMode `Prelude.seq` Prelude.rnf accessString instance Data.ToHeaders CreateUser where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ("AmazonMemoryDB.CreateUser" :: Prelude.ByteString), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON CreateUser where toJSON CreateUser' {..} = Data.object ( Prelude.catMaybes [ ("Tags" Data..=) Prelude.<$> tags, Prelude.Just ("UserName" Data..= userName), Prelude.Just ("AuthenticationMode" Data..= authenticationMode), Prelude.Just ("AccessString" Data..= accessString) ] ) instance Data.ToPath CreateUser where toPath = Prelude.const "/" instance Data.ToQuery CreateUser where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newCreateUserResponse' smart constructor. data CreateUserResponse = CreateUserResponse' { -- | The newly-created user. user :: Prelude.Maybe User, -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'CreateUserResponse' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'user', 'createUserResponse_user' - The newly-created user. -- -- 'httpStatus', 'createUserResponse_httpStatus' - The response's http status code. newCreateUserResponse :: -- | 'httpStatus' Prelude.Int -> CreateUserResponse newCreateUserResponse pHttpStatus_ = CreateUserResponse' { user = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | The newly-created user. createUserResponse_user :: Lens.Lens' CreateUserResponse (Prelude.Maybe User) createUserResponse_user = Lens.lens (\CreateUserResponse' {user} -> user) (\s@CreateUserResponse' {} a -> s {user = a} :: CreateUserResponse) -- | The response's http status code. createUserResponse_httpStatus :: Lens.Lens' CreateUserResponse Prelude.Int createUserResponse_httpStatus = Lens.lens (\CreateUserResponse' {httpStatus} -> httpStatus) (\s@CreateUserResponse' {} a -> s {httpStatus = a} :: CreateUserResponse) instance Prelude.NFData CreateUserResponse where rnf CreateUserResponse' {..} = Prelude.rnf user `Prelude.seq` Prelude.rnf httpStatus