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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(BatchError -> BatchError -> Bool)
-> (BatchError -> BatchError -> Bool) -> Eq BatchError
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]
(Int -> ReadS BatchError)
-> ReadS [BatchError]
-> ReadPrec BatchError
-> ReadPrec [BatchError]
-> Read 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
(Int -> BatchError -> ShowS)
-> (BatchError -> String)
-> ([BatchError] -> ShowS)
-> Show BatchError
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. BatchError -> Rep BatchError x)
-> (forall x. Rep BatchError x -> BatchError) -> Generic BatchError
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' :: Maybe Text -> Maybe Text -> Maybe Text -> BatchError
BatchError'
    { $sel:arn:BatchError' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:code:BatchError' :: Maybe Text
code = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:message:BatchError' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Channel ARN.
batchError_arn :: Lens.Lens' BatchError (Prelude.Maybe Prelude.Text)
batchError_arn :: (Maybe Text -> f (Maybe Text)) -> BatchError -> f BatchError
batchError_arn = (BatchError -> Maybe Text)
-> (BatchError -> Maybe Text -> BatchError)
-> Lens BatchError BatchError (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> BatchError -> f BatchError
batchError_code = (BatchError -> Maybe Text)
-> (BatchError -> Maybe Text -> BatchError)
-> Lens BatchError BatchError (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> BatchError -> f BatchError
batchError_message = (BatchError -> Maybe Text)
-> (BatchError -> Maybe Text -> BatchError)
-> Lens BatchError BatchError (Maybe Text) (Maybe Text)
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 Core.FromJSON BatchError where
  parseJSON :: Value -> Parser BatchError
parseJSON =
    String
-> (Object -> Parser BatchError) -> Value -> Parser BatchError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BatchError"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> BatchError
BatchError'
            (Maybe Text -> Maybe Text -> Maybe Text -> BatchError)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> BatchError)
forall (f :: * -> *) a b. Functor 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
"arn")
            Parser (Maybe Text -> Maybe Text -> BatchError)
-> Parser (Maybe Text) -> Parser (Maybe Text -> BatchError)
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
"code")
            Parser (Maybe Text -> BatchError)
-> Parser (Maybe Text) -> Parser BatchError
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 BatchError

instance Prelude.NFData BatchError