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

import Amazonka.Chime.Types.ErrorCode
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 user ID for which the action failed.
    UserError -> Maybe Text
userId :: Prelude.Maybe Prelude.Text,
    -- | The error code.
    UserError -> Maybe ErrorCode
errorCode :: Prelude.Maybe ErrorCode,
    -- | The error message.
    UserError -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text
  }
  deriving (UserError -> UserError -> Bool
(UserError -> UserError -> Bool)
-> (UserError -> UserError -> Bool) -> Eq UserError
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]
(Int -> ReadS UserError)
-> ReadS [UserError]
-> ReadPrec UserError
-> ReadPrec [UserError]
-> Read 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
(Int -> UserError -> ShowS)
-> (UserError -> String)
-> ([UserError] -> ShowS)
-> Show UserError
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. UserError -> Rep UserError x)
-> (forall x. Rep UserError x -> UserError) -> Generic UserError
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:
--
-- 'userId', 'userError_userId' - The user ID for which the action failed.
--
-- 'errorCode', 'userError_errorCode' - The error code.
--
-- 'errorMessage', 'userError_errorMessage' - The error message.
newUserError ::
  UserError
newUserError :: UserError
newUserError =
  UserError' :: Maybe Text -> Maybe ErrorCode -> Maybe Text -> UserError
UserError'
    { $sel:userId:UserError' :: Maybe Text
userId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorCode:UserError' :: Maybe ErrorCode
errorCode = Maybe ErrorCode
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:UserError' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The user ID for which the action failed.
userError_userId :: Lens.Lens' UserError (Prelude.Maybe Prelude.Text)
userError_userId :: (Maybe Text -> f (Maybe Text)) -> UserError -> f UserError
userError_userId = (UserError -> Maybe Text)
-> (UserError -> Maybe Text -> UserError)
-> Lens UserError UserError (Maybe Text) (Maybe Text)
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)

-- | The error code.
userError_errorCode :: Lens.Lens' UserError (Prelude.Maybe ErrorCode)
userError_errorCode :: (Maybe ErrorCode -> f (Maybe ErrorCode))
-> UserError -> f UserError
userError_errorCode = (UserError -> Maybe ErrorCode)
-> (UserError -> Maybe ErrorCode -> UserError)
-> Lens UserError UserError (Maybe ErrorCode) (Maybe 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 :: (Maybe Text -> f (Maybe Text)) -> UserError -> f UserError
userError_errorMessage = (UserError -> Maybe Text)
-> (UserError -> Maybe Text -> UserError)
-> Lens UserError UserError (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON UserError where
  parseJSON :: Value -> Parser UserError
parseJSON =
    String -> (Object -> Parser UserError) -> Value -> Parser UserError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UserError"
      ( \Object
x ->
          Maybe Text -> Maybe ErrorCode -> Maybe Text -> UserError
UserError'
            (Maybe Text -> Maybe ErrorCode -> Maybe Text -> UserError)
-> Parser (Maybe Text)
-> Parser (Maybe ErrorCode -> Maybe Text -> UserError)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UserId")
            Parser (Maybe ErrorCode -> Maybe Text -> UserError)
-> Parser (Maybe ErrorCode) -> Parser (Maybe Text -> UserError)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ErrorCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ErrorCode")
            Parser (Maybe Text -> UserError)
-> Parser (Maybe Text) -> Parser UserError
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ErrorMessage")
      )

instance Prelude.Hashable UserError

instance Prelude.NFData UserError