{-# 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.IVS.Types.BatchError
-- 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.IVS.Types.BatchError 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

-- | Error related to a specific channel, specified by its ARN.
--
-- /See:/ 'newBatchError' smart constructor.
data BatchError = BatchError'
  { -- | Channel ARN.
    BatchError -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | Error code.
    BatchError -> Maybe Text
code :: Prelude.Maybe Prelude.Text,
    -- | Error message, determined by the application.
    BatchError -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (BatchError -> BatchError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchError -> BatchError -> Bool
$c/= :: BatchError -> BatchError -> Bool
== :: BatchError -> BatchError -> Bool
$c== :: BatchError -> BatchError -> Bool
Prelude.Eq, ReadPrec [BatchError]
ReadPrec BatchError
Int -> ReadS BatchError
ReadS [BatchError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchError]
$creadListPrec :: ReadPrec [BatchError]
readPrec :: ReadPrec BatchError
$creadPrec :: ReadPrec BatchError
readList :: ReadS [BatchError]
$creadList :: ReadS [BatchError]
readsPrec :: Int -> ReadS BatchError
$creadsPrec :: Int -> ReadS BatchError
Prelude.Read, Int -> BatchError -> ShowS
[BatchError] -> ShowS
BatchError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchError] -> ShowS
$cshowList :: [BatchError] -> ShowS
show :: BatchError -> String
$cshow :: BatchError -> String
showsPrec :: Int -> BatchError -> ShowS
$cshowsPrec :: Int -> BatchError -> ShowS
Prelude.Show, forall x. Rep BatchError x -> BatchError
forall x. BatchError -> Rep BatchError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchError x -> BatchError
$cfrom :: forall x. BatchError -> Rep BatchError x
Prelude.Generic)

-- |
-- Create a value of 'BatchError' 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:
--
-- 'arn', 'batchError_arn' - Channel ARN.
--
-- 'code', 'batchError_code' - Error code.
--
-- 'message', 'batchError_message' - Error message, determined by the application.
newBatchError ::
  BatchError
newBatchError :: BatchError
newBatchError =
  BatchError'
    { $sel:arn:BatchError' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:code:BatchError' :: Maybe Text
code = forall a. Maybe a
Prelude.Nothing,
      $sel:message:BatchError' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | Channel ARN.
batchError_arn :: Lens.Lens' BatchError (Prelude.Maybe Prelude.Text)
batchError_arn :: Lens' BatchError (Maybe Text)
batchError_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchError' {Maybe Text
arn :: Maybe Text
$sel:arn:BatchError' :: BatchError -> Maybe Text
arn} -> Maybe Text
arn) (\s :: BatchError
s@BatchError' {} Maybe Text
a -> BatchError
s {$sel:arn:BatchError' :: Maybe Text
arn = Maybe Text
a} :: BatchError)

-- | Error code.
batchError_code :: Lens.Lens' BatchError (Prelude.Maybe Prelude.Text)
batchError_code :: Lens' BatchError (Maybe Text)
batchError_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchError' {Maybe Text
code :: Maybe Text
$sel:code:BatchError' :: BatchError -> Maybe Text
code} -> Maybe Text
code) (\s :: BatchError
s@BatchError' {} Maybe Text
a -> BatchError
s {$sel:code:BatchError' :: Maybe Text
code = Maybe Text
a} :: BatchError)

-- | Error message, determined by the application.
batchError_message :: Lens.Lens' BatchError (Prelude.Maybe Prelude.Text)
batchError_message :: Lens' BatchError (Maybe Text)
batchError_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchError' {Maybe Text
message :: Maybe Text
$sel:message:BatchError' :: BatchError -> Maybe Text
message} -> Maybe Text
message) (\s :: BatchError
s@BatchError' {} Maybe Text
a -> BatchError
s {$sel:message:BatchError' :: Maybe Text
message = Maybe Text
a} :: BatchError)

instance Data.FromJSON BatchError where
  parseJSON :: Value -> Parser BatchError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BatchError"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> BatchError
BatchError'
            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
"arn")
            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
"code")
            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
"message")
      )

instance Prelude.Hashable BatchError where
  hashWithSalt :: Int -> BatchError -> Int
hashWithSalt Int
_salt BatchError' {Maybe Text
message :: Maybe Text
code :: Maybe Text
arn :: Maybe Text
$sel:message:BatchError' :: BatchError -> Maybe Text
$sel:code:BatchError' :: BatchError -> Maybe Text
$sel:arn:BatchError' :: BatchError -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message

instance Prelude.NFData BatchError where
  rnf :: BatchError -> ()
rnf BatchError' {Maybe Text
message :: Maybe Text
code :: Maybe Text
arn :: Maybe Text
$sel:message:BatchError' :: BatchError -> Maybe Text
$sel:code:BatchError' :: BatchError -> Maybe Text
$sel:arn:BatchError' :: BatchError -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
code
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message