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

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

-- | Analysis error.
--
-- /See:/ 'newAnalysisError' smart constructor.
data AnalysisError = AnalysisError'
  { -- | The type of the analysis error.
    AnalysisError -> Maybe AnalysisErrorType
type' :: Prelude.Maybe AnalysisErrorType,
    -- | The message associated with the analysis error.
    AnalysisError -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (AnalysisError -> AnalysisError -> Bool
(AnalysisError -> AnalysisError -> Bool)
-> (AnalysisError -> AnalysisError -> Bool) -> Eq AnalysisError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnalysisError -> AnalysisError -> Bool
$c/= :: AnalysisError -> AnalysisError -> Bool
== :: AnalysisError -> AnalysisError -> Bool
$c== :: AnalysisError -> AnalysisError -> Bool
Prelude.Eq, ReadPrec [AnalysisError]
ReadPrec AnalysisError
Int -> ReadS AnalysisError
ReadS [AnalysisError]
(Int -> ReadS AnalysisError)
-> ReadS [AnalysisError]
-> ReadPrec AnalysisError
-> ReadPrec [AnalysisError]
-> Read AnalysisError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnalysisError]
$creadListPrec :: ReadPrec [AnalysisError]
readPrec :: ReadPrec AnalysisError
$creadPrec :: ReadPrec AnalysisError
readList :: ReadS [AnalysisError]
$creadList :: ReadS [AnalysisError]
readsPrec :: Int -> ReadS AnalysisError
$creadsPrec :: Int -> ReadS AnalysisError
Prelude.Read, Int -> AnalysisError -> ShowS
[AnalysisError] -> ShowS
AnalysisError -> String
(Int -> AnalysisError -> ShowS)
-> (AnalysisError -> String)
-> ([AnalysisError] -> ShowS)
-> Show AnalysisError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnalysisError] -> ShowS
$cshowList :: [AnalysisError] -> ShowS
show :: AnalysisError -> String
$cshow :: AnalysisError -> String
showsPrec :: Int -> AnalysisError -> ShowS
$cshowsPrec :: Int -> AnalysisError -> ShowS
Prelude.Show, (forall x. AnalysisError -> Rep AnalysisError x)
-> (forall x. Rep AnalysisError x -> AnalysisError)
-> Generic AnalysisError
forall x. Rep AnalysisError x -> AnalysisError
forall x. AnalysisError -> Rep AnalysisError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnalysisError x -> AnalysisError
$cfrom :: forall x. AnalysisError -> Rep AnalysisError x
Prelude.Generic)

-- |
-- Create a value of 'AnalysisError' 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'', 'analysisError_type' - The type of the analysis error.
--
-- 'message', 'analysisError_message' - The message associated with the analysis error.
newAnalysisError ::
  AnalysisError
newAnalysisError :: AnalysisError
newAnalysisError =
  AnalysisError' :: Maybe AnalysisErrorType -> Maybe Text -> AnalysisError
AnalysisError'
    { $sel:type':AnalysisError' :: Maybe AnalysisErrorType
type' = Maybe AnalysisErrorType
forall a. Maybe a
Prelude.Nothing,
      $sel:message:AnalysisError' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of the analysis error.
analysisError_type :: Lens.Lens' AnalysisError (Prelude.Maybe AnalysisErrorType)
analysisError_type :: (Maybe AnalysisErrorType -> f (Maybe AnalysisErrorType))
-> AnalysisError -> f AnalysisError
analysisError_type = (AnalysisError -> Maybe AnalysisErrorType)
-> (AnalysisError -> Maybe AnalysisErrorType -> AnalysisError)
-> Lens
     AnalysisError
     AnalysisError
     (Maybe AnalysisErrorType)
     (Maybe AnalysisErrorType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisError' {Maybe AnalysisErrorType
type' :: Maybe AnalysisErrorType
$sel:type':AnalysisError' :: AnalysisError -> Maybe AnalysisErrorType
type'} -> Maybe AnalysisErrorType
type') (\s :: AnalysisError
s@AnalysisError' {} Maybe AnalysisErrorType
a -> AnalysisError
s {$sel:type':AnalysisError' :: Maybe AnalysisErrorType
type' = Maybe AnalysisErrorType
a} :: AnalysisError)

-- | The message associated with the analysis error.
analysisError_message :: Lens.Lens' AnalysisError (Prelude.Maybe Prelude.Text)
analysisError_message :: (Maybe Text -> f (Maybe Text)) -> AnalysisError -> f AnalysisError
analysisError_message = (AnalysisError -> Maybe Text)
-> (AnalysisError -> Maybe Text -> AnalysisError)
-> Lens AnalysisError AnalysisError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisError' {Maybe Text
message :: Maybe Text
$sel:message:AnalysisError' :: AnalysisError -> Maybe Text
message} -> Maybe Text
message) (\s :: AnalysisError
s@AnalysisError' {} Maybe Text
a -> AnalysisError
s {$sel:message:AnalysisError' :: Maybe Text
message = Maybe Text
a} :: AnalysisError)

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

instance Prelude.NFData AnalysisError