{-# 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.Grafana.Types.UpdateError
-- 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.Grafana.Types.UpdateError where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Grafana.Types.UpdateInstruction
import qualified Amazonka.Prelude as Prelude

-- | A structure containing information about one error encountered while
-- performing an
-- <https://docs.aws.amazon.com/grafana/latest/APIReference/API_UpdatePermissions.html UpdatePermissions>
-- operation.
--
-- /See:/ 'newUpdateError' smart constructor.
data UpdateError = UpdateError'
  { -- | Specifies which permission update caused the error.
    UpdateError -> UpdateInstruction
causedBy :: UpdateInstruction,
    -- | The error code.
    UpdateError -> Natural
code :: Prelude.Natural,
    -- | The message for this error.
    UpdateError -> Text
message :: Prelude.Text
  }
  deriving (UpdateError -> UpdateError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateError -> UpdateError -> Bool
$c/= :: UpdateError -> UpdateError -> Bool
== :: UpdateError -> UpdateError -> Bool
$c== :: UpdateError -> UpdateError -> Bool
Prelude.Eq, ReadPrec [UpdateError]
ReadPrec UpdateError
Int -> ReadS UpdateError
ReadS [UpdateError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateError]
$creadListPrec :: ReadPrec [UpdateError]
readPrec :: ReadPrec UpdateError
$creadPrec :: ReadPrec UpdateError
readList :: ReadS [UpdateError]
$creadList :: ReadS [UpdateError]
readsPrec :: Int -> ReadS UpdateError
$creadsPrec :: Int -> ReadS UpdateError
Prelude.Read, Int -> UpdateError -> ShowS
[UpdateError] -> ShowS
UpdateError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateError] -> ShowS
$cshowList :: [UpdateError] -> ShowS
show :: UpdateError -> String
$cshow :: UpdateError -> String
showsPrec :: Int -> UpdateError -> ShowS
$cshowsPrec :: Int -> UpdateError -> ShowS
Prelude.Show, forall x. Rep UpdateError x -> UpdateError
forall x. UpdateError -> Rep UpdateError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateError x -> UpdateError
$cfrom :: forall x. UpdateError -> Rep UpdateError x
Prelude.Generic)

-- |
-- Create a value of 'UpdateError' 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:
--
-- 'causedBy', 'updateError_causedBy' - Specifies which permission update caused the error.
--
-- 'code', 'updateError_code' - The error code.
--
-- 'message', 'updateError_message' - The message for this error.
newUpdateError ::
  -- | 'causedBy'
  UpdateInstruction ->
  -- | 'code'
  Prelude.Natural ->
  -- | 'message'
  Prelude.Text ->
  UpdateError
newUpdateError :: UpdateInstruction -> Natural -> Text -> UpdateError
newUpdateError UpdateInstruction
pCausedBy_ Natural
pCode_ Text
pMessage_ =
  UpdateError'
    { $sel:causedBy:UpdateError' :: UpdateInstruction
causedBy = UpdateInstruction
pCausedBy_,
      $sel:code:UpdateError' :: Natural
code = Natural
pCode_,
      $sel:message:UpdateError' :: Text
message = Text
pMessage_
    }

-- | Specifies which permission update caused the error.
updateError_causedBy :: Lens.Lens' UpdateError UpdateInstruction
updateError_causedBy :: Lens' UpdateError UpdateInstruction
updateError_causedBy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateError' {UpdateInstruction
causedBy :: UpdateInstruction
$sel:causedBy:UpdateError' :: UpdateError -> UpdateInstruction
causedBy} -> UpdateInstruction
causedBy) (\s :: UpdateError
s@UpdateError' {} UpdateInstruction
a -> UpdateError
s {$sel:causedBy:UpdateError' :: UpdateInstruction
causedBy = UpdateInstruction
a} :: UpdateError)

-- | The error code.
updateError_code :: Lens.Lens' UpdateError Prelude.Natural
updateError_code :: Lens' UpdateError Natural
updateError_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateError' {Natural
code :: Natural
$sel:code:UpdateError' :: UpdateError -> Natural
code} -> Natural
code) (\s :: UpdateError
s@UpdateError' {} Natural
a -> UpdateError
s {$sel:code:UpdateError' :: Natural
code = Natural
a} :: UpdateError)

-- | The message for this error.
updateError_message :: Lens.Lens' UpdateError Prelude.Text
updateError_message :: Lens' UpdateError Text
updateError_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateError' {Text
message :: Text
$sel:message:UpdateError' :: UpdateError -> Text
message} -> Text
message) (\s :: UpdateError
s@UpdateError' {} Text
a -> UpdateError
s {$sel:message:UpdateError' :: Text
message = Text
a} :: UpdateError)

instance Data.FromJSON UpdateError where
  parseJSON :: Value -> Parser UpdateError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UpdateError"
      ( \Object
x ->
          UpdateInstruction -> Natural -> Text -> UpdateError
UpdateError'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"causedBy")
            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
"code")
            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
"message")
      )

instance Prelude.Hashable UpdateError where
  hashWithSalt :: Int -> UpdateError -> Int
hashWithSalt Int
_salt UpdateError' {Natural
Text
UpdateInstruction
message :: Text
code :: Natural
causedBy :: UpdateInstruction
$sel:message:UpdateError' :: UpdateError -> Text
$sel:code:UpdateError' :: UpdateError -> Natural
$sel:causedBy:UpdateError' :: UpdateError -> UpdateInstruction
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` UpdateInstruction
causedBy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
message

instance Prelude.NFData UpdateError where
  rnf :: UpdateError -> ()
rnf UpdateError' {Natural
Text
UpdateInstruction
message :: Text
code :: Natural
causedBy :: UpdateInstruction
$sel:message:UpdateError' :: UpdateError -> Text
$sel:code:UpdateError' :: UpdateError -> Natural
$sel:causedBy:UpdateError' :: UpdateError -> UpdateInstruction
..} =
    forall a. NFData a => a -> ()
Prelude.rnf UpdateInstruction
causedBy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
code
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
message