{-# 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.QuickSight.Types.NamespaceError
-- 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.QuickSight.Types.NamespaceError where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.QuickSight.Types.NamespaceErrorType

-- | Errors that occur during namespace creation.
--
-- /See:/ 'newNamespaceError' smart constructor.
data NamespaceError = NamespaceError'
  { -- | The error type.
    NamespaceError -> Maybe NamespaceErrorType
type' :: Prelude.Maybe NamespaceErrorType,
    -- | The message for the error.
    NamespaceError -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (NamespaceError -> NamespaceError -> Bool
(NamespaceError -> NamespaceError -> Bool)
-> (NamespaceError -> NamespaceError -> Bool) -> Eq NamespaceError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NamespaceError -> NamespaceError -> Bool
$c/= :: NamespaceError -> NamespaceError -> Bool
== :: NamespaceError -> NamespaceError -> Bool
$c== :: NamespaceError -> NamespaceError -> Bool
Prelude.Eq, ReadPrec [NamespaceError]
ReadPrec NamespaceError
Int -> ReadS NamespaceError
ReadS [NamespaceError]
(Int -> ReadS NamespaceError)
-> ReadS [NamespaceError]
-> ReadPrec NamespaceError
-> ReadPrec [NamespaceError]
-> Read NamespaceError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NamespaceError]
$creadListPrec :: ReadPrec [NamespaceError]
readPrec :: ReadPrec NamespaceError
$creadPrec :: ReadPrec NamespaceError
readList :: ReadS [NamespaceError]
$creadList :: ReadS [NamespaceError]
readsPrec :: Int -> ReadS NamespaceError
$creadsPrec :: Int -> ReadS NamespaceError
Prelude.Read, Int -> NamespaceError -> ShowS
[NamespaceError] -> ShowS
NamespaceError -> String
(Int -> NamespaceError -> ShowS)
-> (NamespaceError -> String)
-> ([NamespaceError] -> ShowS)
-> Show NamespaceError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NamespaceError] -> ShowS
$cshowList :: [NamespaceError] -> ShowS
show :: NamespaceError -> String
$cshow :: NamespaceError -> String
showsPrec :: Int -> NamespaceError -> ShowS
$cshowsPrec :: Int -> NamespaceError -> ShowS
Prelude.Show, (forall x. NamespaceError -> Rep NamespaceError x)
-> (forall x. Rep NamespaceError x -> NamespaceError)
-> Generic NamespaceError
forall x. Rep NamespaceError x -> NamespaceError
forall x. NamespaceError -> Rep NamespaceError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NamespaceError x -> NamespaceError
$cfrom :: forall x. NamespaceError -> Rep NamespaceError x
Prelude.Generic)

-- |
-- Create a value of 'NamespaceError' 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:
--
-- 'type'', 'namespaceError_type' - The error type.
--
-- 'message', 'namespaceError_message' - The message for the error.
newNamespaceError ::
  NamespaceError
newNamespaceError :: NamespaceError
newNamespaceError =
  NamespaceError' :: Maybe NamespaceErrorType -> Maybe Text -> NamespaceError
NamespaceError'
    { $sel:type':NamespaceError' :: Maybe NamespaceErrorType
type' = Maybe NamespaceErrorType
forall a. Maybe a
Prelude.Nothing,
      $sel:message:NamespaceError' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The error type.
namespaceError_type :: Lens.Lens' NamespaceError (Prelude.Maybe NamespaceErrorType)
namespaceError_type :: (Maybe NamespaceErrorType -> f (Maybe NamespaceErrorType))
-> NamespaceError -> f NamespaceError
namespaceError_type = (NamespaceError -> Maybe NamespaceErrorType)
-> (NamespaceError -> Maybe NamespaceErrorType -> NamespaceError)
-> Lens
     NamespaceError
     NamespaceError
     (Maybe NamespaceErrorType)
     (Maybe NamespaceErrorType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NamespaceError' {Maybe NamespaceErrorType
type' :: Maybe NamespaceErrorType
$sel:type':NamespaceError' :: NamespaceError -> Maybe NamespaceErrorType
type'} -> Maybe NamespaceErrorType
type') (\s :: NamespaceError
s@NamespaceError' {} Maybe NamespaceErrorType
a -> NamespaceError
s {$sel:type':NamespaceError' :: Maybe NamespaceErrorType
type' = Maybe NamespaceErrorType
a} :: NamespaceError)

-- | The message for the error.
namespaceError_message :: Lens.Lens' NamespaceError (Prelude.Maybe Prelude.Text)
namespaceError_message :: (Maybe Text -> f (Maybe Text))
-> NamespaceError -> f NamespaceError
namespaceError_message = (NamespaceError -> Maybe Text)
-> (NamespaceError -> Maybe Text -> NamespaceError)
-> Lens NamespaceError NamespaceError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NamespaceError' {Maybe Text
message :: Maybe Text
$sel:message:NamespaceError' :: NamespaceError -> Maybe Text
message} -> Maybe Text
message) (\s :: NamespaceError
s@NamespaceError' {} Maybe Text
a -> NamespaceError
s {$sel:message:NamespaceError' :: Maybe Text
message = Maybe Text
a} :: NamespaceError)

instance Core.FromJSON NamespaceError where
  parseJSON :: Value -> Parser NamespaceError
parseJSON =
    String
-> (Object -> Parser NamespaceError)
-> Value
-> Parser NamespaceError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NamespaceError"
      ( \Object
x ->
          Maybe NamespaceErrorType -> Maybe Text -> NamespaceError
NamespaceError'
            (Maybe NamespaceErrorType -> Maybe Text -> NamespaceError)
-> Parser (Maybe NamespaceErrorType)
-> Parser (Maybe Text -> NamespaceError)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe NamespaceErrorType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser (Maybe Text -> NamespaceError)
-> Parser (Maybe Text) -> Parser NamespaceError
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
"Message")
      )

instance Prelude.Hashable NamespaceError

instance Prelude.NFData NamespaceError