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

-- | Represents a target that failed to be added to a rule.
--
-- /See:/ 'newPutTargetsResultEntry' smart constructor.
data PutTargetsResultEntry = PutTargetsResultEntry'
  { -- | The error code that indicates why the target addition failed. If the
    -- value is @ConcurrentModificationException@, too many requests were made
    -- at the same time.
    PutTargetsResultEntry -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | The error message that explains why the target addition failed.
    PutTargetsResultEntry -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | The ID of the target.
    PutTargetsResultEntry -> Maybe Text
targetId :: Prelude.Maybe Prelude.Text
  }
  deriving (PutTargetsResultEntry -> PutTargetsResultEntry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutTargetsResultEntry -> PutTargetsResultEntry -> Bool
$c/= :: PutTargetsResultEntry -> PutTargetsResultEntry -> Bool
== :: PutTargetsResultEntry -> PutTargetsResultEntry -> Bool
$c== :: PutTargetsResultEntry -> PutTargetsResultEntry -> Bool
Prelude.Eq, ReadPrec [PutTargetsResultEntry]
ReadPrec PutTargetsResultEntry
Int -> ReadS PutTargetsResultEntry
ReadS [PutTargetsResultEntry]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutTargetsResultEntry]
$creadListPrec :: ReadPrec [PutTargetsResultEntry]
readPrec :: ReadPrec PutTargetsResultEntry
$creadPrec :: ReadPrec PutTargetsResultEntry
readList :: ReadS [PutTargetsResultEntry]
$creadList :: ReadS [PutTargetsResultEntry]
readsPrec :: Int -> ReadS PutTargetsResultEntry
$creadsPrec :: Int -> ReadS PutTargetsResultEntry
Prelude.Read, Int -> PutTargetsResultEntry -> ShowS
[PutTargetsResultEntry] -> ShowS
PutTargetsResultEntry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutTargetsResultEntry] -> ShowS
$cshowList :: [PutTargetsResultEntry] -> ShowS
show :: PutTargetsResultEntry -> String
$cshow :: PutTargetsResultEntry -> String
showsPrec :: Int -> PutTargetsResultEntry -> ShowS
$cshowsPrec :: Int -> PutTargetsResultEntry -> ShowS
Prelude.Show, forall x. Rep PutTargetsResultEntry x -> PutTargetsResultEntry
forall x. PutTargetsResultEntry -> Rep PutTargetsResultEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutTargetsResultEntry x -> PutTargetsResultEntry
$cfrom :: forall x. PutTargetsResultEntry -> Rep PutTargetsResultEntry x
Prelude.Generic)

-- |
-- Create a value of 'PutTargetsResultEntry' 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', 'putTargetsResultEntry_errorCode' - The error code that indicates why the target addition failed. If the
-- value is @ConcurrentModificationException@, too many requests were made
-- at the same time.
--
-- 'errorMessage', 'putTargetsResultEntry_errorMessage' - The error message that explains why the target addition failed.
--
-- 'targetId', 'putTargetsResultEntry_targetId' - The ID of the target.
newPutTargetsResultEntry ::
  PutTargetsResultEntry
newPutTargetsResultEntry :: PutTargetsResultEntry
newPutTargetsResultEntry =
  PutTargetsResultEntry'
    { $sel:errorCode:PutTargetsResultEntry' :: Maybe Text
errorCode = forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:PutTargetsResultEntry' :: Maybe Text
errorMessage = forall a. Maybe a
Prelude.Nothing,
      $sel:targetId:PutTargetsResultEntry' :: Maybe Text
targetId = forall a. Maybe a
Prelude.Nothing
    }

-- | The error code that indicates why the target addition failed. If the
-- value is @ConcurrentModificationException@, too many requests were made
-- at the same time.
putTargetsResultEntry_errorCode :: Lens.Lens' PutTargetsResultEntry (Prelude.Maybe Prelude.Text)
putTargetsResultEntry_errorCode :: Lens' PutTargetsResultEntry (Maybe Text)
putTargetsResultEntry_errorCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargetsResultEntry' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:PutTargetsResultEntry' :: PutTargetsResultEntry -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: PutTargetsResultEntry
s@PutTargetsResultEntry' {} Maybe Text
a -> PutTargetsResultEntry
s {$sel:errorCode:PutTargetsResultEntry' :: Maybe Text
errorCode = Maybe Text
a} :: PutTargetsResultEntry)

-- | The error message that explains why the target addition failed.
putTargetsResultEntry_errorMessage :: Lens.Lens' PutTargetsResultEntry (Prelude.Maybe Prelude.Text)
putTargetsResultEntry_errorMessage :: Lens' PutTargetsResultEntry (Maybe Text)
putTargetsResultEntry_errorMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargetsResultEntry' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:PutTargetsResultEntry' :: PutTargetsResultEntry -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: PutTargetsResultEntry
s@PutTargetsResultEntry' {} Maybe Text
a -> PutTargetsResultEntry
s {$sel:errorMessage:PutTargetsResultEntry' :: Maybe Text
errorMessage = Maybe Text
a} :: PutTargetsResultEntry)

-- | The ID of the target.
putTargetsResultEntry_targetId :: Lens.Lens' PutTargetsResultEntry (Prelude.Maybe Prelude.Text)
putTargetsResultEntry_targetId :: Lens' PutTargetsResultEntry (Maybe Text)
putTargetsResultEntry_targetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargetsResultEntry' {Maybe Text
targetId :: Maybe Text
$sel:targetId:PutTargetsResultEntry' :: PutTargetsResultEntry -> Maybe Text
targetId} -> Maybe Text
targetId) (\s :: PutTargetsResultEntry
s@PutTargetsResultEntry' {} Maybe Text
a -> PutTargetsResultEntry
s {$sel:targetId:PutTargetsResultEntry' :: Maybe Text
targetId = Maybe Text
a} :: PutTargetsResultEntry)

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

instance Prelude.Hashable PutTargetsResultEntry where
  hashWithSalt :: Int -> PutTargetsResultEntry -> Int
hashWithSalt Int
_salt PutTargetsResultEntry' {Maybe Text
targetId :: Maybe Text
errorMessage :: Maybe Text
errorCode :: Maybe Text
$sel:targetId:PutTargetsResultEntry' :: PutTargetsResultEntry -> Maybe Text
$sel:errorMessage:PutTargetsResultEntry' :: PutTargetsResultEntry -> Maybe Text
$sel:errorCode:PutTargetsResultEntry' :: PutTargetsResultEntry -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetId

instance Prelude.NFData PutTargetsResultEntry where
  rnf :: PutTargetsResultEntry -> ()
rnf PutTargetsResultEntry' {Maybe Text
targetId :: Maybe Text
errorMessage :: Maybe Text
errorCode :: Maybe Text
$sel:targetId:PutTargetsResultEntry' :: PutTargetsResultEntry -> Maybe Text
$sel:errorMessage:PutTargetsResultEntry' :: PutTargetsResultEntry -> Maybe Text
$sel:errorCode:PutTargetsResultEntry' :: PutTargetsResultEntry -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetId