{-# 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-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)
module Amazonka.MQ.Types.User where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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],
    -- | 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,
    -- | 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
(User -> User -> Bool) -> (User -> User -> Bool) -> Eq User
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]
(Int -> ReadS User)
-> ReadS [User] -> ReadPrec User -> ReadPrec [User] -> Read 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
(Int -> User -> ShowS)
-> (User -> String) -> ([User] -> ShowS) -> Show User
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. User -> Rep User x)
-> (forall x. Rep User x -> User) -> Generic User
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:
--
-- '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.
--
-- 'consoleAccess', 'user_consoleAccess' - Enables access to the ActiveMQ Web Console for the ActiveMQ user. 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' :: Maybe [Text] -> Maybe Bool -> Text -> Text -> User
User'
    { $sel:groups:User' :: Maybe [Text]
groups = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:consoleAccess:User' :: Maybe Bool
consoleAccess = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:username:User' :: Text
username = Text
pUsername_,
      $sel:password:User' :: Text
password = Text
pPassword_
    }

-- | 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 :: (Maybe [Text] -> f (Maybe [Text])) -> User -> f User
user_groups = (User -> Maybe [Text])
-> (User -> Maybe [Text] -> User)
-> Lens User User (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text])) -> User -> f User)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> User
-> f User
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Bool -> f (Maybe Bool)) -> User -> f User
user_consoleAccess = (User -> Maybe Bool)
-> (User -> Maybe Bool -> User)
-> Lens User User (Maybe Bool) (Maybe Bool)
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)

-- | 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 :: (Text -> f Text) -> User -> f User
user_username = (User -> Text)
-> (User -> Text -> User) -> Lens User User Text Text
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 :: (Text -> f Text) -> User -> f User
user_password = (User -> Text)
-> (User -> Text -> User) -> Lens User User Text Text
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

instance Prelude.NFData User

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