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

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

-- | List of errors that occurred when the template version creation failed.
--
-- /See:/ 'newTemplateError' smart constructor.
data TemplateError = TemplateError'
  { -- | Type of error.
    TemplateError -> Maybe TemplateErrorType
type' :: Prelude.Maybe TemplateErrorType,
    -- | Description of the error type.
    TemplateError -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (TemplateError -> TemplateError -> Bool
(TemplateError -> TemplateError -> Bool)
-> (TemplateError -> TemplateError -> Bool) -> Eq TemplateError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TemplateError -> TemplateError -> Bool
$c/= :: TemplateError -> TemplateError -> Bool
== :: TemplateError -> TemplateError -> Bool
$c== :: TemplateError -> TemplateError -> Bool
Prelude.Eq, ReadPrec [TemplateError]
ReadPrec TemplateError
Int -> ReadS TemplateError
ReadS [TemplateError]
(Int -> ReadS TemplateError)
-> ReadS [TemplateError]
-> ReadPrec TemplateError
-> ReadPrec [TemplateError]
-> Read TemplateError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TemplateError]
$creadListPrec :: ReadPrec [TemplateError]
readPrec :: ReadPrec TemplateError
$creadPrec :: ReadPrec TemplateError
readList :: ReadS [TemplateError]
$creadList :: ReadS [TemplateError]
readsPrec :: Int -> ReadS TemplateError
$creadsPrec :: Int -> ReadS TemplateError
Prelude.Read, Int -> TemplateError -> ShowS
[TemplateError] -> ShowS
TemplateError -> String
(Int -> TemplateError -> ShowS)
-> (TemplateError -> String)
-> ([TemplateError] -> ShowS)
-> Show TemplateError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TemplateError] -> ShowS
$cshowList :: [TemplateError] -> ShowS
show :: TemplateError -> String
$cshow :: TemplateError -> String
showsPrec :: Int -> TemplateError -> ShowS
$cshowsPrec :: Int -> TemplateError -> ShowS
Prelude.Show, (forall x. TemplateError -> Rep TemplateError x)
-> (forall x. Rep TemplateError x -> TemplateError)
-> Generic TemplateError
forall x. Rep TemplateError x -> TemplateError
forall x. TemplateError -> Rep TemplateError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TemplateError x -> TemplateError
$cfrom :: forall x. TemplateError -> Rep TemplateError x
Prelude.Generic)

-- |
-- Create a value of 'TemplateError' 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'', 'templateError_type' - Type of error.
--
-- 'message', 'templateError_message' - Description of the error type.
newTemplateError ::
  TemplateError
newTemplateError :: TemplateError
newTemplateError =
  TemplateError' :: Maybe TemplateErrorType -> Maybe Text -> TemplateError
TemplateError'
    { $sel:type':TemplateError' :: Maybe TemplateErrorType
type' = Maybe TemplateErrorType
forall a. Maybe a
Prelude.Nothing,
      $sel:message:TemplateError' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Type of error.
templateError_type :: Lens.Lens' TemplateError (Prelude.Maybe TemplateErrorType)
templateError_type :: (Maybe TemplateErrorType -> f (Maybe TemplateErrorType))
-> TemplateError -> f TemplateError
templateError_type = (TemplateError -> Maybe TemplateErrorType)
-> (TemplateError -> Maybe TemplateErrorType -> TemplateError)
-> Lens
     TemplateError
     TemplateError
     (Maybe TemplateErrorType)
     (Maybe TemplateErrorType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplateError' {Maybe TemplateErrorType
type' :: Maybe TemplateErrorType
$sel:type':TemplateError' :: TemplateError -> Maybe TemplateErrorType
type'} -> Maybe TemplateErrorType
type') (\s :: TemplateError
s@TemplateError' {} Maybe TemplateErrorType
a -> TemplateError
s {$sel:type':TemplateError' :: Maybe TemplateErrorType
type' = Maybe TemplateErrorType
a} :: TemplateError)

-- | Description of the error type.
templateError_message :: Lens.Lens' TemplateError (Prelude.Maybe Prelude.Text)
templateError_message :: (Maybe Text -> f (Maybe Text)) -> TemplateError -> f TemplateError
templateError_message = (TemplateError -> Maybe Text)
-> (TemplateError -> Maybe Text -> TemplateError)
-> Lens TemplateError TemplateError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplateError' {Maybe Text
message :: Maybe Text
$sel:message:TemplateError' :: TemplateError -> Maybe Text
message} -> Maybe Text
message) (\s :: TemplateError
s@TemplateError' {} Maybe Text
a -> TemplateError
s {$sel:message:TemplateError' :: Maybe Text
message = Maybe Text
a} :: TemplateError)

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

instance Prelude.NFData TemplateError