{-# 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.CloudWatchEvents.Types.PutEventsResultEntry
-- 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.CloudWatchEvents.Types.PutEventsResultEntry where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents an event that failed to be submitted.
--
-- /See:/ 'newPutEventsResultEntry' smart constructor.
data PutEventsResultEntry = PutEventsResultEntry'
  { -- | The error code that indicates why the event submission failed.
    PutEventsResultEntry -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | The error message that explains why the event submission failed.
    PutEventsResultEntry -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | The ID of the event.
    PutEventsResultEntry -> Maybe Text
eventId :: Prelude.Maybe Prelude.Text
  }
  deriving (PutEventsResultEntry -> PutEventsResultEntry -> Bool
(PutEventsResultEntry -> PutEventsResultEntry -> Bool)
-> (PutEventsResultEntry -> PutEventsResultEntry -> Bool)
-> Eq PutEventsResultEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutEventsResultEntry -> PutEventsResultEntry -> Bool
$c/= :: PutEventsResultEntry -> PutEventsResultEntry -> Bool
== :: PutEventsResultEntry -> PutEventsResultEntry -> Bool
$c== :: PutEventsResultEntry -> PutEventsResultEntry -> Bool
Prelude.Eq, ReadPrec [PutEventsResultEntry]
ReadPrec PutEventsResultEntry
Int -> ReadS PutEventsResultEntry
ReadS [PutEventsResultEntry]
(Int -> ReadS PutEventsResultEntry)
-> ReadS [PutEventsResultEntry]
-> ReadPrec PutEventsResultEntry
-> ReadPrec [PutEventsResultEntry]
-> Read PutEventsResultEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutEventsResultEntry]
$creadListPrec :: ReadPrec [PutEventsResultEntry]
readPrec :: ReadPrec PutEventsResultEntry
$creadPrec :: ReadPrec PutEventsResultEntry
readList :: ReadS [PutEventsResultEntry]
$creadList :: ReadS [PutEventsResultEntry]
readsPrec :: Int -> ReadS PutEventsResultEntry
$creadsPrec :: Int -> ReadS PutEventsResultEntry
Prelude.Read, Int -> PutEventsResultEntry -> ShowS
[PutEventsResultEntry] -> ShowS
PutEventsResultEntry -> String
(Int -> PutEventsResultEntry -> ShowS)
-> (PutEventsResultEntry -> String)
-> ([PutEventsResultEntry] -> ShowS)
-> Show PutEventsResultEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutEventsResultEntry] -> ShowS
$cshowList :: [PutEventsResultEntry] -> ShowS
show :: PutEventsResultEntry -> String
$cshow :: PutEventsResultEntry -> String
showsPrec :: Int -> PutEventsResultEntry -> ShowS
$cshowsPrec :: Int -> PutEventsResultEntry -> ShowS
Prelude.Show, (forall x. PutEventsResultEntry -> Rep PutEventsResultEntry x)
-> (forall x. Rep PutEventsResultEntry x -> PutEventsResultEntry)
-> Generic PutEventsResultEntry
forall x. Rep PutEventsResultEntry x -> PutEventsResultEntry
forall x. PutEventsResultEntry -> Rep PutEventsResultEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutEventsResultEntry x -> PutEventsResultEntry
$cfrom :: forall x. PutEventsResultEntry -> Rep PutEventsResultEntry x
Prelude.Generic)

-- |
-- Create a value of 'PutEventsResultEntry' 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:
--
-- 'errorCode', 'putEventsResultEntry_errorCode' - The error code that indicates why the event submission failed.
--
-- 'errorMessage', 'putEventsResultEntry_errorMessage' - The error message that explains why the event submission failed.
--
-- 'eventId', 'putEventsResultEntry_eventId' - The ID of the event.
newPutEventsResultEntry ::
  PutEventsResultEntry
newPutEventsResultEntry :: PutEventsResultEntry
newPutEventsResultEntry =
  PutEventsResultEntry' :: Maybe Text -> Maybe Text -> Maybe Text -> PutEventsResultEntry
PutEventsResultEntry'
    { $sel:errorCode:PutEventsResultEntry' :: Maybe Text
errorCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:PutEventsResultEntry' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eventId:PutEventsResultEntry' :: Maybe Text
eventId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The error code that indicates why the event submission failed.
putEventsResultEntry_errorCode :: Lens.Lens' PutEventsResultEntry (Prelude.Maybe Prelude.Text)
putEventsResultEntry_errorCode :: (Maybe Text -> f (Maybe Text))
-> PutEventsResultEntry -> f PutEventsResultEntry
putEventsResultEntry_errorCode = (PutEventsResultEntry -> Maybe Text)
-> (PutEventsResultEntry -> Maybe Text -> PutEventsResultEntry)
-> Lens
     PutEventsResultEntry PutEventsResultEntry (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventsResultEntry' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:PutEventsResultEntry' :: PutEventsResultEntry -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: PutEventsResultEntry
s@PutEventsResultEntry' {} Maybe Text
a -> PutEventsResultEntry
s {$sel:errorCode:PutEventsResultEntry' :: Maybe Text
errorCode = Maybe Text
a} :: PutEventsResultEntry)

-- | The error message that explains why the event submission failed.
putEventsResultEntry_errorMessage :: Lens.Lens' PutEventsResultEntry (Prelude.Maybe Prelude.Text)
putEventsResultEntry_errorMessage :: (Maybe Text -> f (Maybe Text))
-> PutEventsResultEntry -> f PutEventsResultEntry
putEventsResultEntry_errorMessage = (PutEventsResultEntry -> Maybe Text)
-> (PutEventsResultEntry -> Maybe Text -> PutEventsResultEntry)
-> Lens
     PutEventsResultEntry PutEventsResultEntry (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventsResultEntry' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:PutEventsResultEntry' :: PutEventsResultEntry -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: PutEventsResultEntry
s@PutEventsResultEntry' {} Maybe Text
a -> PutEventsResultEntry
s {$sel:errorMessage:PutEventsResultEntry' :: Maybe Text
errorMessage = Maybe Text
a} :: PutEventsResultEntry)

-- | The ID of the event.
putEventsResultEntry_eventId :: Lens.Lens' PutEventsResultEntry (Prelude.Maybe Prelude.Text)
putEventsResultEntry_eventId :: (Maybe Text -> f (Maybe Text))
-> PutEventsResultEntry -> f PutEventsResultEntry
putEventsResultEntry_eventId = (PutEventsResultEntry -> Maybe Text)
-> (PutEventsResultEntry -> Maybe Text -> PutEventsResultEntry)
-> Lens
     PutEventsResultEntry PutEventsResultEntry (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventsResultEntry' {Maybe Text
eventId :: Maybe Text
$sel:eventId:PutEventsResultEntry' :: PutEventsResultEntry -> Maybe Text
eventId} -> Maybe Text
eventId) (\s :: PutEventsResultEntry
s@PutEventsResultEntry' {} Maybe Text
a -> PutEventsResultEntry
s {$sel:eventId:PutEventsResultEntry' :: Maybe Text
eventId = Maybe Text
a} :: PutEventsResultEntry)

instance Core.FromJSON PutEventsResultEntry where
  parseJSON :: Value -> Parser PutEventsResultEntry
parseJSON =
    String
-> (Object -> Parser PutEventsResultEntry)
-> Value
-> Parser PutEventsResultEntry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PutEventsResultEntry"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> PutEventsResultEntry
PutEventsResultEntry'
            (Maybe Text -> Maybe Text -> Maybe Text -> PutEventsResultEntry)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> PutEventsResultEntry)
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
"ErrorCode")
            Parser (Maybe Text -> Maybe Text -> PutEventsResultEntry)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> PutEventsResultEntry)
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
"ErrorMessage")
            Parser (Maybe Text -> PutEventsResultEntry)
-> Parser (Maybe Text) -> Parser PutEventsResultEntry
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
"EventId")
      )

instance Prelude.Hashable PutEventsResultEntry

instance Prelude.NFData PutEventsResultEntry