{-# 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.AppFlow.Types.EventBridgeDestinationProperties
-- 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.AppFlow.Types.EventBridgeDestinationProperties where

import Amazonka.AppFlow.Types.ErrorHandlingConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The properties that are applied when Amazon EventBridge is being used as
-- a destination.
--
-- /See:/ 'newEventBridgeDestinationProperties' smart constructor.
data EventBridgeDestinationProperties = EventBridgeDestinationProperties'
  { EventBridgeDestinationProperties -> Maybe ErrorHandlingConfig
errorHandlingConfig :: Prelude.Maybe ErrorHandlingConfig,
    -- | The object specified in the Amazon EventBridge flow destination.
    EventBridgeDestinationProperties -> Text
object' :: Prelude.Text
  }
  deriving (EventBridgeDestinationProperties
-> EventBridgeDestinationProperties -> Bool
(EventBridgeDestinationProperties
 -> EventBridgeDestinationProperties -> Bool)
-> (EventBridgeDestinationProperties
    -> EventBridgeDestinationProperties -> Bool)
-> Eq EventBridgeDestinationProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventBridgeDestinationProperties
-> EventBridgeDestinationProperties -> Bool
$c/= :: EventBridgeDestinationProperties
-> EventBridgeDestinationProperties -> Bool
== :: EventBridgeDestinationProperties
-> EventBridgeDestinationProperties -> Bool
$c== :: EventBridgeDestinationProperties
-> EventBridgeDestinationProperties -> Bool
Prelude.Eq, ReadPrec [EventBridgeDestinationProperties]
ReadPrec EventBridgeDestinationProperties
Int -> ReadS EventBridgeDestinationProperties
ReadS [EventBridgeDestinationProperties]
(Int -> ReadS EventBridgeDestinationProperties)
-> ReadS [EventBridgeDestinationProperties]
-> ReadPrec EventBridgeDestinationProperties
-> ReadPrec [EventBridgeDestinationProperties]
-> Read EventBridgeDestinationProperties
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventBridgeDestinationProperties]
$creadListPrec :: ReadPrec [EventBridgeDestinationProperties]
readPrec :: ReadPrec EventBridgeDestinationProperties
$creadPrec :: ReadPrec EventBridgeDestinationProperties
readList :: ReadS [EventBridgeDestinationProperties]
$creadList :: ReadS [EventBridgeDestinationProperties]
readsPrec :: Int -> ReadS EventBridgeDestinationProperties
$creadsPrec :: Int -> ReadS EventBridgeDestinationProperties
Prelude.Read, Int -> EventBridgeDestinationProperties -> ShowS
[EventBridgeDestinationProperties] -> ShowS
EventBridgeDestinationProperties -> String
(Int -> EventBridgeDestinationProperties -> ShowS)
-> (EventBridgeDestinationProperties -> String)
-> ([EventBridgeDestinationProperties] -> ShowS)
-> Show EventBridgeDestinationProperties
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventBridgeDestinationProperties] -> ShowS
$cshowList :: [EventBridgeDestinationProperties] -> ShowS
show :: EventBridgeDestinationProperties -> String
$cshow :: EventBridgeDestinationProperties -> String
showsPrec :: Int -> EventBridgeDestinationProperties -> ShowS
$cshowsPrec :: Int -> EventBridgeDestinationProperties -> ShowS
Prelude.Show, (forall x.
 EventBridgeDestinationProperties
 -> Rep EventBridgeDestinationProperties x)
-> (forall x.
    Rep EventBridgeDestinationProperties x
    -> EventBridgeDestinationProperties)
-> Generic EventBridgeDestinationProperties
forall x.
Rep EventBridgeDestinationProperties x
-> EventBridgeDestinationProperties
forall x.
EventBridgeDestinationProperties
-> Rep EventBridgeDestinationProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EventBridgeDestinationProperties x
-> EventBridgeDestinationProperties
$cfrom :: forall x.
EventBridgeDestinationProperties
-> Rep EventBridgeDestinationProperties x
Prelude.Generic)

-- |
-- Create a value of 'EventBridgeDestinationProperties' 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:
--
-- 'errorHandlingConfig', 'eventBridgeDestinationProperties_errorHandlingConfig' - Undocumented member.
--
-- 'object'', 'eventBridgeDestinationProperties_object' - The object specified in the Amazon EventBridge flow destination.
newEventBridgeDestinationProperties ::
  -- | 'object''
  Prelude.Text ->
  EventBridgeDestinationProperties
newEventBridgeDestinationProperties :: Text -> EventBridgeDestinationProperties
newEventBridgeDestinationProperties Text
pObject_ =
  EventBridgeDestinationProperties' :: Maybe ErrorHandlingConfig
-> Text -> EventBridgeDestinationProperties
EventBridgeDestinationProperties'
    { $sel:errorHandlingConfig:EventBridgeDestinationProperties' :: Maybe ErrorHandlingConfig
errorHandlingConfig =
        Maybe ErrorHandlingConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:object':EventBridgeDestinationProperties' :: Text
object' = Text
pObject_
    }

-- | Undocumented member.
eventBridgeDestinationProperties_errorHandlingConfig :: Lens.Lens' EventBridgeDestinationProperties (Prelude.Maybe ErrorHandlingConfig)
eventBridgeDestinationProperties_errorHandlingConfig :: (Maybe ErrorHandlingConfig -> f (Maybe ErrorHandlingConfig))
-> EventBridgeDestinationProperties
-> f EventBridgeDestinationProperties
eventBridgeDestinationProperties_errorHandlingConfig = (EventBridgeDestinationProperties -> Maybe ErrorHandlingConfig)
-> (EventBridgeDestinationProperties
    -> Maybe ErrorHandlingConfig -> EventBridgeDestinationProperties)
-> Lens
     EventBridgeDestinationProperties
     EventBridgeDestinationProperties
     (Maybe ErrorHandlingConfig)
     (Maybe ErrorHandlingConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventBridgeDestinationProperties' {Maybe ErrorHandlingConfig
errorHandlingConfig :: Maybe ErrorHandlingConfig
$sel:errorHandlingConfig:EventBridgeDestinationProperties' :: EventBridgeDestinationProperties -> Maybe ErrorHandlingConfig
errorHandlingConfig} -> Maybe ErrorHandlingConfig
errorHandlingConfig) (\s :: EventBridgeDestinationProperties
s@EventBridgeDestinationProperties' {} Maybe ErrorHandlingConfig
a -> EventBridgeDestinationProperties
s {$sel:errorHandlingConfig:EventBridgeDestinationProperties' :: Maybe ErrorHandlingConfig
errorHandlingConfig = Maybe ErrorHandlingConfig
a} :: EventBridgeDestinationProperties)

-- | The object specified in the Amazon EventBridge flow destination.
eventBridgeDestinationProperties_object :: Lens.Lens' EventBridgeDestinationProperties Prelude.Text
eventBridgeDestinationProperties_object :: (Text -> f Text)
-> EventBridgeDestinationProperties
-> f EventBridgeDestinationProperties
eventBridgeDestinationProperties_object = (EventBridgeDestinationProperties -> Text)
-> (EventBridgeDestinationProperties
    -> Text -> EventBridgeDestinationProperties)
-> Lens
     EventBridgeDestinationProperties
     EventBridgeDestinationProperties
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventBridgeDestinationProperties' {Text
object' :: Text
$sel:object':EventBridgeDestinationProperties' :: EventBridgeDestinationProperties -> Text
object'} -> Text
object') (\s :: EventBridgeDestinationProperties
s@EventBridgeDestinationProperties' {} Text
a -> EventBridgeDestinationProperties
s {$sel:object':EventBridgeDestinationProperties' :: Text
object' = Text
a} :: EventBridgeDestinationProperties)

instance
  Core.FromJSON
    EventBridgeDestinationProperties
  where
  parseJSON :: Value -> Parser EventBridgeDestinationProperties
parseJSON =
    String
-> (Object -> Parser EventBridgeDestinationProperties)
-> Value
-> Parser EventBridgeDestinationProperties
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventBridgeDestinationProperties"
      ( \Object
x ->
          Maybe ErrorHandlingConfig
-> Text -> EventBridgeDestinationProperties
EventBridgeDestinationProperties'
            (Maybe ErrorHandlingConfig
 -> Text -> EventBridgeDestinationProperties)
-> Parser (Maybe ErrorHandlingConfig)
-> Parser (Text -> EventBridgeDestinationProperties)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ErrorHandlingConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"errorHandlingConfig")
            Parser (Text -> EventBridgeDestinationProperties)
-> Parser Text -> Parser EventBridgeDestinationProperties
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"object")
      )

instance
  Prelude.Hashable
    EventBridgeDestinationProperties

instance
  Prelude.NFData
    EventBridgeDestinationProperties

instance Core.ToJSON EventBridgeDestinationProperties where
  toJSON :: EventBridgeDestinationProperties -> Value
toJSON EventBridgeDestinationProperties' {Maybe ErrorHandlingConfig
Text
object' :: Text
errorHandlingConfig :: Maybe ErrorHandlingConfig
$sel:object':EventBridgeDestinationProperties' :: EventBridgeDestinationProperties -> Text
$sel:errorHandlingConfig:EventBridgeDestinationProperties' :: EventBridgeDestinationProperties -> Maybe ErrorHandlingConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"errorHandlingConfig" Text -> ErrorHandlingConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ErrorHandlingConfig -> Pair)
-> Maybe ErrorHandlingConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ErrorHandlingConfig
errorHandlingConfig,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"object" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
object')
          ]
      )