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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(UserSummary -> UserSummary -> Bool)
-> (UserSummary -> UserSummary -> Bool) -> Eq UserSummary
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]
(Int -> ReadS UserSummary)
-> ReadS [UserSummary]
-> ReadPrec UserSummary
-> ReadPrec [UserSummary]
-> Read 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
(Int -> UserSummary -> ShowS)
-> (UserSummary -> String)
-> ([UserSummary] -> ShowS)
-> Show UserSummary
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. UserSummary -> Rep UserSummary x)
-> (forall x. Rep UserSummary x -> UserSummary)
-> Generic UserSummary
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' :: Maybe ChangeType -> Text -> UserSummary
UserSummary'
    { $sel:pendingChange:UserSummary' :: Maybe ChangeType
pendingChange = Maybe ChangeType
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 :: (Maybe ChangeType -> f (Maybe ChangeType))
-> UserSummary -> f UserSummary
userSummary_pendingChange = (UserSummary -> Maybe ChangeType)
-> (UserSummary -> Maybe ChangeType -> UserSummary)
-> Lens
     UserSummary UserSummary (Maybe ChangeType) (Maybe ChangeType)
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 :: (Text -> f Text) -> UserSummary -> f UserSummary
userSummary_username = (UserSummary -> Text)
-> (UserSummary -> Text -> UserSummary)
-> Lens UserSummary UserSummary Text Text
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 Core.FromJSON UserSummary where
  parseJSON :: Value -> Parser UserSummary
parseJSON =
    String
-> (Object -> Parser UserSummary) -> Value -> Parser UserSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UserSummary"
      ( \Object
x ->
          Maybe ChangeType -> Text -> UserSummary
UserSummary'
            (Maybe ChangeType -> Text -> UserSummary)
-> Parser (Maybe ChangeType) -> Parser (Text -> UserSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ChangeType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"pendingChange")
            Parser (Text -> UserSummary) -> Parser Text -> Parser UserSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"username")
      )

instance Prelude.Hashable UserSummary

instance Prelude.NFData UserSummary