{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.QuickSight.Types.TemplateError where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.QuickSight.Types.Entity
import Amazonka.QuickSight.Types.TemplateErrorType

-- | List of errors that occurred when the template version creation failed.
--
-- /See:/ 'newTemplateError' smart constructor.
data TemplateError = TemplateError'
  { -- | Description of the error type.
    TemplateError -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | Type of error.
    TemplateError -> Maybe TemplateErrorType
type' :: Prelude.Maybe TemplateErrorType,
    TemplateError -> Maybe [Entity]
violatedEntities :: Prelude.Maybe [Entity]
  }
  deriving (TemplateError -> TemplateError -> Bool
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]
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
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. 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:
--
-- 'message', 'templateError_message' - Description of the error type.
--
-- 'type'', 'templateError_type' - Type of error.
--
-- 'violatedEntities', 'templateError_violatedEntities' -
newTemplateError ::
  TemplateError
newTemplateError :: TemplateError
newTemplateError =
  TemplateError'
    { $sel:message:TemplateError' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing,
      $sel:type':TemplateError' :: Maybe TemplateErrorType
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:violatedEntities:TemplateError' :: Maybe [Entity]
violatedEntities = forall a. Maybe a
Prelude.Nothing
    }

-- | Description of the error type.
templateError_message :: Lens.Lens' TemplateError (Prelude.Maybe Prelude.Text)
templateError_message :: Lens' TemplateError (Maybe Text)
templateError_message = 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)

-- | Type of error.
templateError_type :: Lens.Lens' TemplateError (Prelude.Maybe TemplateErrorType)
templateError_type :: Lens' TemplateError (Maybe TemplateErrorType)
templateError_type = 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)

templateError_violatedEntities :: Lens.Lens' TemplateError (Prelude.Maybe [Entity])
templateError_violatedEntities :: Lens' TemplateError (Maybe [Entity])
templateError_violatedEntities = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplateError' {Maybe [Entity]
violatedEntities :: Maybe [Entity]
$sel:violatedEntities:TemplateError' :: TemplateError -> Maybe [Entity]
violatedEntities} -> Maybe [Entity]
violatedEntities) (\s :: TemplateError
s@TemplateError' {} Maybe [Entity]
a -> TemplateError
s {$sel:violatedEntities:TemplateError' :: Maybe [Entity]
violatedEntities = Maybe [Entity]
a} :: TemplateError) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON TemplateError where
  parseJSON :: Value -> Parser TemplateError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TemplateError"
      ( \Object
x ->
          Maybe Text
-> Maybe TemplateErrorType -> Maybe [Entity] -> TemplateError
TemplateError'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Message")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Type")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ViolatedEntities"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable TemplateError where
  hashWithSalt :: Int -> TemplateError -> Int
hashWithSalt Int
_salt TemplateError' {Maybe [Entity]
Maybe Text
Maybe TemplateErrorType
violatedEntities :: Maybe [Entity]
type' :: Maybe TemplateErrorType
message :: Maybe Text
$sel:violatedEntities:TemplateError' :: TemplateError -> Maybe [Entity]
$sel:type':TemplateError' :: TemplateError -> Maybe TemplateErrorType
$sel:message:TemplateError' :: TemplateError -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TemplateErrorType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Entity]
violatedEntities

instance Prelude.NFData TemplateError where
  rnf :: TemplateError -> ()
rnf TemplateError' {Maybe [Entity]
Maybe Text
Maybe TemplateErrorType
violatedEntities :: Maybe [Entity]
type' :: Maybe TemplateErrorType
message :: Maybe Text
$sel:violatedEntities:TemplateError' :: TemplateError -> Maybe [Entity]
$sel:type':TemplateError' :: TemplateError -> Maybe TemplateErrorType
$sel:message:TemplateError' :: TemplateError -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TemplateErrorType
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Entity]
violatedEntities