{-# 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.Chime.Types.UserError
-- 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.Chime.Types.UserError where

import Amazonka.Chime.Types.ErrorCode
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

-- | The list of errors returned when errors are encountered during the
-- BatchSuspendUser, BatchUnsuspendUser, or BatchUpdateUser actions. This
-- includes user IDs, error codes, and error messages.
--
-- /See:/ 'newUserError' smart constructor.
data UserError = UserError'
  { -- | The error code.
    UserError -> Maybe ErrorCode
errorCode :: Prelude.Maybe ErrorCode,
    -- | The error message.
    UserError -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | The user ID for which the action failed.
    UserError -> Maybe Text
userId :: Prelude.Maybe Prelude.Text
  }
  deriving (UserError -> UserError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserError -> UserError -> Bool
$c/= :: UserError -> UserError -> Bool
== :: UserError -> UserError -> Bool
$c== :: UserError -> UserError -> Bool
Prelude.Eq, ReadPrec [UserError]
ReadPrec UserError
Int -> ReadS UserError
ReadS [UserError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserError]
$creadListPrec :: ReadPrec [UserError]
readPrec :: ReadPrec UserError
$creadPrec :: ReadPrec UserError
readList :: ReadS [UserError]
$creadList :: ReadS [UserError]
readsPrec :: Int -> ReadS UserError
$creadsPrec :: Int -> ReadS UserError
Prelude.Read, Int -> UserError -> ShowS
[UserError] -> ShowS
UserError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserError] -> ShowS
$cshowList :: [UserError] -> ShowS
show :: UserError -> String
$cshow :: UserError -> String
showsPrec :: Int -> UserError -> ShowS
$cshowsPrec :: Int -> UserError -> ShowS
Prelude.Show, forall x. Rep UserError x -> UserError
forall x. UserError -> Rep UserError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserError x -> UserError
$cfrom :: forall x. UserError -> Rep UserError x
Prelude.Generic)

-- |
-- Create a value of 'UserError' 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:
--
-- 'errorCode', 'userError_errorCode' - The error code.
--
-- 'errorMessage', 'userError_errorMessage' - The error message.
--
-- 'userId', 'userError_userId' - The user ID for which the action failed.
newUserError ::
  UserError
newUserError :: UserError
newUserError =
  UserError'
    { $sel:errorCode:UserError' :: Maybe ErrorCode
errorCode = forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:UserError' :: Maybe Text
errorMessage = forall a. Maybe a
Prelude.Nothing,
      $sel:userId:UserError' :: Maybe Text
userId = forall a. Maybe a
Prelude.Nothing
    }

-- | The error code.
userError_errorCode :: Lens.Lens' UserError (Prelude.Maybe ErrorCode)
userError_errorCode :: Lens' UserError (Maybe ErrorCode)
userError_errorCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserError' {Maybe ErrorCode
errorCode :: Maybe ErrorCode
$sel:errorCode:UserError' :: UserError -> Maybe ErrorCode
errorCode} -> Maybe ErrorCode
errorCode) (\s :: UserError
s@UserError' {} Maybe ErrorCode
a -> UserError
s {$sel:errorCode:UserError' :: Maybe ErrorCode
errorCode = Maybe ErrorCode
a} :: UserError)

-- | The error message.
userError_errorMessage :: Lens.Lens' UserError (Prelude.Maybe Prelude.Text)
userError_errorMessage :: Lens' UserError (Maybe Text)
userError_errorMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserError' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:UserError' :: UserError -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: UserError
s@UserError' {} Maybe Text
a -> UserError
s {$sel:errorMessage:UserError' :: Maybe Text
errorMessage = Maybe Text
a} :: UserError)

-- | The user ID for which the action failed.
userError_userId :: Lens.Lens' UserError (Prelude.Maybe Prelude.Text)
userError_userId :: Lens' UserError (Maybe Text)
userError_userId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserError' {Maybe Text
userId :: Maybe Text
$sel:userId:UserError' :: UserError -> Maybe Text
userId} -> Maybe Text
userId) (\s :: UserError
s@UserError' {} Maybe Text
a -> UserError
s {$sel:userId:UserError' :: Maybe Text
userId = Maybe Text
a} :: UserError)

instance Data.FromJSON UserError where
  parseJSON :: Value -> Parser UserError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UserError"
      ( \Object
x ->
          Maybe ErrorCode -> Maybe Text -> Maybe Text -> UserError
UserError'
            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
"ErrorCode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ErrorMessage")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"UserId")
      )

instance Prelude.Hashable UserError where
  hashWithSalt :: Int -> UserError -> Int
hashWithSalt Int
_salt UserError' {Maybe Text
Maybe ErrorCode
userId :: Maybe Text
errorMessage :: Maybe Text
errorCode :: Maybe ErrorCode
$sel:userId:UserError' :: UserError -> Maybe Text
$sel:errorMessage:UserError' :: UserError -> Maybe Text
$sel:errorCode:UserError' :: UserError -> Maybe ErrorCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ErrorCode
errorCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userId

instance Prelude.NFData UserError where
  rnf :: UserError -> ()
rnf UserError' {Maybe Text
Maybe ErrorCode
userId :: Maybe Text
errorMessage :: Maybe Text
errorCode :: Maybe ErrorCode
$sel:userId:UserError' :: UserError -> Maybe Text
$sel:errorMessage:UserError' :: UserError -> Maybe Text
$sel:errorCode:UserError' :: UserError -> Maybe ErrorCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ErrorCode
errorCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userId