{-# 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.UserSummary
-- 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.UserSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MQ.Types.ChangeType
import qualified Amazonka.Prelude as Prelude

-- | Returns a list of all broker users. Does not apply to RabbitMQ brokers.
--
-- /See:/ 'newUserSummary' smart constructor.
data UserSummary = UserSummary'
  { -- | The type of change pending for the broker user.
    UserSummary -> Maybe ChangeType
pendingChange :: Prelude.Maybe ChangeType,
    -- | Required. The username of the broker user. This value can contain only
    -- alphanumeric characters, dashes, periods, underscores, and tildes (- . _
    -- ~). This value must be 2-100 characters long.
    UserSummary -> Text
username :: Prelude.Text
  }
  deriving (UserSummary -> UserSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserSummary -> UserSummary -> Bool
$c/= :: UserSummary -> UserSummary -> Bool
== :: UserSummary -> UserSummary -> Bool
$c== :: UserSummary -> UserSummary -> Bool
Prelude.Eq, ReadPrec [UserSummary]
ReadPrec UserSummary
Int -> ReadS UserSummary
ReadS [UserSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserSummary]
$creadListPrec :: ReadPrec [UserSummary]
readPrec :: ReadPrec UserSummary
$creadPrec :: ReadPrec UserSummary
readList :: ReadS [UserSummary]
$creadList :: ReadS [UserSummary]
readsPrec :: Int -> ReadS UserSummary
$creadsPrec :: Int -> ReadS UserSummary
Prelude.Read, Int -> UserSummary -> ShowS
[UserSummary] -> ShowS
UserSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserSummary] -> ShowS
$cshowList :: [UserSummary] -> ShowS
show :: UserSummary -> String
$cshow :: UserSummary -> String
showsPrec :: Int -> UserSummary -> ShowS
$cshowsPrec :: Int -> UserSummary -> ShowS
Prelude.Show, forall x. Rep UserSummary x -> UserSummary
forall x. UserSummary -> Rep UserSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserSummary x -> UserSummary
$cfrom :: forall x. UserSummary -> Rep UserSummary x
Prelude.Generic)

-- |
-- Create a value of 'UserSummary' 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:
--
-- 'pendingChange', 'userSummary_pendingChange' - The type of change pending for the broker user.
--
-- 'username', 'userSummary_username' - Required. The username of the broker user. This value can contain only
-- alphanumeric characters, dashes, periods, underscores, and tildes (- . _
-- ~). This value must be 2-100 characters long.
newUserSummary ::
  -- | 'username'
  Prelude.Text ->
  UserSummary
newUserSummary :: Text -> UserSummary
newUserSummary Text
pUsername_ =
  UserSummary'
    { $sel:pendingChange:UserSummary' :: Maybe ChangeType
pendingChange = forall a. Maybe a
Prelude.Nothing,
      $sel:username:UserSummary' :: Text
username = Text
pUsername_
    }

-- | The type of change pending for the broker user.
userSummary_pendingChange :: Lens.Lens' UserSummary (Prelude.Maybe ChangeType)
userSummary_pendingChange :: Lens' UserSummary (Maybe ChangeType)
userSummary_pendingChange = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserSummary' {Maybe ChangeType
pendingChange :: Maybe ChangeType
$sel:pendingChange:UserSummary' :: UserSummary -> Maybe ChangeType
pendingChange} -> Maybe ChangeType
pendingChange) (\s :: UserSummary
s@UserSummary' {} Maybe ChangeType
a -> UserSummary
s {$sel:pendingChange:UserSummary' :: Maybe ChangeType
pendingChange = Maybe ChangeType
a} :: UserSummary)

-- | Required. The username of the broker user. This value can contain only
-- alphanumeric characters, dashes, periods, underscores, and tildes (- . _
-- ~). This value must be 2-100 characters long.
userSummary_username :: Lens.Lens' UserSummary Prelude.Text
userSummary_username :: Lens' UserSummary Text
userSummary_username = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserSummary' {Text
username :: Text
$sel:username:UserSummary' :: UserSummary -> Text
username} -> Text
username) (\s :: UserSummary
s@UserSummary' {} Text
a -> UserSummary
s {$sel:username:UserSummary' :: Text
username = Text
a} :: UserSummary)

instance Data.FromJSON UserSummary where
  parseJSON :: Value -> Parser UserSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UserSummary"
      ( \Object
x ->
          Maybe ChangeType -> Text -> UserSummary
UserSummary'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"pendingChange")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"username")
      )

instance Prelude.Hashable UserSummary where
  hashWithSalt :: Int -> UserSummary -> Int
hashWithSalt Int
_salt UserSummary' {Maybe ChangeType
Text
username :: Text
pendingChange :: Maybe ChangeType
$sel:username:UserSummary' :: UserSummary -> Text
$sel:pendingChange:UserSummary' :: UserSummary -> Maybe ChangeType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ChangeType
pendingChange
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
username

instance Prelude.NFData UserSummary where
  rnf :: UserSummary -> ()
rnf UserSummary' {Maybe ChangeType
Text
username :: Text
pendingChange :: Maybe ChangeType
$sel:username:UserSummary' :: UserSummary -> Text
$sel:pendingChange:UserSummary' :: UserSummary -> Maybe ChangeType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ChangeType
pendingChange
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
username