{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.MQ.Types.User
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MQ.Types.User 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

-- | A user associated with the broker. For RabbitMQ brokers, one and only
-- one administrative user is accepted and created when a broker is first
-- provisioned. All subsequent broker users are created by making RabbitMQ
-- API calls directly to brokers or via the RabbitMQ web console.
--
-- /See:/ 'newUser' smart constructor.
data User = User'
  { -- | Enables access to the ActiveMQ Web Console for the ActiveMQ user. Does
    -- not apply to RabbitMQ brokers.
    User -> Maybe Bool
consoleAccess :: Prelude.Maybe Prelude.Bool,
    -- | The list of groups (20 maximum) to which the ActiveMQ user belongs. This
    -- value can contain only alphanumeric characters, dashes, periods,
    -- underscores, and tildes (- . _ ~). This value must be 2-100 characters
    -- long. Does not apply to RabbitMQ brokers.
    User -> Maybe [Text]
groups :: Prelude.Maybe [Prelude.Text],
    -- | important>
    --
    -- Amazon MQ for ActiveMQ
    --
    -- For ActiveMQ brokers, this value can contain only alphanumeric
    -- characters, dashes, periods, underscores, and tildes (- . _ ~). This
    -- value must be 2-100 characters long.
    --
    -- \/important>
    --
    -- Amazon MQ for RabbitMQ
    --
    -- For RabbitMQ brokers, this value can contain only alphanumeric
    -- characters, dashes, periods, underscores (- . _). This value must not
    -- contain a tilde (~) character. Amazon MQ prohibts using guest as a valid
    -- usename. This value must be 2-100 characters long.
    User -> Text
username :: Prelude.Text,
    -- | Required. The password of the user. This value must be at least 12
    -- characters long, must contain at least 4 unique characters, and must not
    -- contain commas, colons, or equal signs (,:=).
    User -> Text
password :: Prelude.Text
  }
  deriving (User -> User -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: User -> User -> Bool
$c/= :: User -> User -> Bool
== :: User -> User -> Bool
$c== :: User -> User -> Bool
Prelude.Eq, ReadPrec [User]
ReadPrec User
Int -> ReadS User
ReadS [User]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [User]
$creadListPrec :: ReadPrec [User]
readPrec :: ReadPrec User
$creadPrec :: ReadPrec User
readList :: ReadS [User]
$creadList :: ReadS [User]
readsPrec :: Int -> ReadS User
$creadsPrec :: Int -> ReadS User
Prelude.Read, Int -> User -> ShowS
[User] -> ShowS
User -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [User] -> ShowS
$cshowList :: [User] -> ShowS
show :: User -> String
$cshow :: User -> String
showsPrec :: Int -> User -> ShowS
$cshowsPrec :: Int -> User -> ShowS
Prelude.Show, forall x. Rep User x -> User
forall x. User -> Rep User x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep User x -> User
$cfrom :: forall x. User -> Rep User x
Prelude.Generic)

-- |
-- Create a value of 'User' 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:
--
-- 'consoleAccess', 'user_consoleAccess' - Enables access to the ActiveMQ Web Console for the ActiveMQ user. Does
-- not apply to RabbitMQ brokers.
--
-- 'groups', 'user_groups' - The list of groups (20 maximum) to which the ActiveMQ user belongs. This
-- value can contain only alphanumeric characters, dashes, periods,
-- underscores, and tildes (- . _ ~). This value must be 2-100 characters
-- long. Does not apply to RabbitMQ brokers.
--
-- 'username', 'user_username' - important>
--
-- Amazon MQ for ActiveMQ
--
-- For ActiveMQ brokers, this value can contain only alphanumeric
-- characters, dashes, periods, underscores, and tildes (- . _ ~). This
-- value must be 2-100 characters long.
--
-- \/important>
--
-- Amazon MQ for RabbitMQ
--
-- For RabbitMQ brokers, this value can contain only alphanumeric
-- characters, dashes, periods, underscores (- . _). This value must not
-- contain a tilde (~) character. Amazon MQ prohibts using guest as a valid
-- usename. This value must be 2-100 characters long.
--
-- 'password', 'user_password' - Required. The password of the user. This value must be at least 12
-- characters long, must contain at least 4 unique characters, and must not
-- contain commas, colons, or equal signs (,:=).
newUser ::
  -- | 'username'
  Prelude.Text ->
  -- | 'password'
  Prelude.Text ->
  User
newUser :: Text -> Text -> User
newUser Text
pUsername_ Text
pPassword_ =
  User'
    { $sel:consoleAccess:User' :: Maybe Bool
consoleAccess = forall a. Maybe a
Prelude.Nothing,
      $sel:groups:User' :: Maybe [Text]
groups = forall a. Maybe a
Prelude.Nothing,
      $sel:username:User' :: Text
username = Text
pUsername_,
      $sel:password:User' :: Text
password = Text
pPassword_
    }

-- | Enables access to the ActiveMQ Web Console for the ActiveMQ user. Does
-- not apply to RabbitMQ brokers.
user_consoleAccess :: Lens.Lens' User (Prelude.Maybe Prelude.Bool)
user_consoleAccess :: Lens' User (Maybe Bool)
user_consoleAccess = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Maybe Bool
consoleAccess :: Maybe Bool
$sel:consoleAccess:User' :: User -> Maybe Bool
consoleAccess} -> Maybe Bool
consoleAccess) (\s :: User
s@User' {} Maybe Bool
a -> User
s {$sel:consoleAccess:User' :: Maybe Bool
consoleAccess = Maybe Bool
a} :: User)

-- | The list of groups (20 maximum) to which the ActiveMQ user belongs. This
-- value can contain only alphanumeric characters, dashes, periods,
-- underscores, and tildes (- . _ ~). This value must be 2-100 characters
-- long. Does not apply to RabbitMQ brokers.
user_groups :: Lens.Lens' User (Prelude.Maybe [Prelude.Text])
user_groups :: Lens' User (Maybe [Text])
user_groups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Maybe [Text]
groups :: Maybe [Text]
$sel:groups:User' :: User -> Maybe [Text]
groups} -> Maybe [Text]
groups) (\s :: User
s@User' {} Maybe [Text]
a -> User
s {$sel:groups:User' :: Maybe [Text]
groups = Maybe [Text]
a} :: User) 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

-- | important>
--
-- Amazon MQ for ActiveMQ
--
-- For ActiveMQ brokers, this value can contain only alphanumeric
-- characters, dashes, periods, underscores, and tildes (- . _ ~). This
-- value must be 2-100 characters long.
--
-- \/important>
--
-- Amazon MQ for RabbitMQ
--
-- For RabbitMQ brokers, this value can contain only alphanumeric
-- characters, dashes, periods, underscores (- . _). This value must not
-- contain a tilde (~) character. Amazon MQ prohibts using guest as a valid
-- usename. This value must be 2-100 characters long.
user_username :: Lens.Lens' User Prelude.Text
user_username :: Lens' User Text
user_username = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Text
username :: Text
$sel:username:User' :: User -> Text
username} -> Text
username) (\s :: User
s@User' {} Text
a -> User
s {$sel:username:User' :: Text
username = Text
a} :: User)

-- | Required. The password of the user. This value must be at least 12
-- characters long, must contain at least 4 unique characters, and must not
-- contain commas, colons, or equal signs (,:=).
user_password :: Lens.Lens' User Prelude.Text
user_password :: Lens' User Text
user_password = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Text
password :: Text
$sel:password:User' :: User -> Text
password} -> Text
password) (\s :: User
s@User' {} Text
a -> User
s {$sel:password:User' :: Text
password = Text
a} :: User)

instance Prelude.Hashable User where
  hashWithSalt :: Int -> User -> Int
hashWithSalt Int
_salt User' {Maybe Bool
Maybe [Text]
Text
password :: Text
username :: Text
groups :: Maybe [Text]
consoleAccess :: Maybe Bool
$sel:password:User' :: User -> Text
$sel:username:User' :: User -> Text
$sel:groups:User' :: User -> Maybe [Text]
$sel:consoleAccess:User' :: User -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
consoleAccess
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
groups
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
username
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
password

instance Prelude.NFData User where
  rnf :: User -> ()
rnf User' {Maybe Bool
Maybe [Text]
Text
password :: Text
username :: Text
groups :: Maybe [Text]
consoleAccess :: Maybe Bool
$sel:password:User' :: User -> Text
$sel:username:User' :: User -> Text
$sel:groups:User' :: User -> Maybe [Text]
$sel:consoleAccess:User' :: User -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
consoleAccess
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
groups
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
username
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
password

instance Data.ToJSON User where
  toJSON :: User -> Value
toJSON User' {Maybe Bool
Maybe [Text]
Text
password :: Text
username :: Text
groups :: Maybe [Text]
consoleAccess :: Maybe Bool
$sel:password:User' :: User -> Text
$sel:username:User' :: User -> Text
$sel:groups:User' :: User -> Maybe [Text]
$sel:consoleAccess:User' :: User -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"consoleAccess" 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 Bool
consoleAccess,
            (Key
"groups" 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]
groups,
            forall a. a -> Maybe a
Prelude.Just (Key
"username" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
username),
            forall a. a -> Maybe a
Prelude.Just (Key
"password" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
password)
          ]
      )