{-# 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.Scheduler.Types.EventBridgeParameters
-- 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.Scheduler.Types.EventBridgeParameters 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

-- | The templated target type for the EventBridge
-- <https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutEvents.html PutEvents>
-- API operation.
--
-- /See:/ 'newEventBridgeParameters' smart constructor.
data EventBridgeParameters = EventBridgeParameters'
  { -- | A free-form string, with a maximum of 128 characters, used to decide
    -- what fields to expect in the event detail.
    EventBridgeParameters -> Text
detailType :: Prelude.Text,
    -- | The source of the event.
    EventBridgeParameters -> Text
source :: Prelude.Text
  }
  deriving (EventBridgeParameters -> EventBridgeParameters -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventBridgeParameters -> EventBridgeParameters -> Bool
$c/= :: EventBridgeParameters -> EventBridgeParameters -> Bool
== :: EventBridgeParameters -> EventBridgeParameters -> Bool
$c== :: EventBridgeParameters -> EventBridgeParameters -> Bool
Prelude.Eq, ReadPrec [EventBridgeParameters]
ReadPrec EventBridgeParameters
Int -> ReadS EventBridgeParameters
ReadS [EventBridgeParameters]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventBridgeParameters]
$creadListPrec :: ReadPrec [EventBridgeParameters]
readPrec :: ReadPrec EventBridgeParameters
$creadPrec :: ReadPrec EventBridgeParameters
readList :: ReadS [EventBridgeParameters]
$creadList :: ReadS [EventBridgeParameters]
readsPrec :: Int -> ReadS EventBridgeParameters
$creadsPrec :: Int -> ReadS EventBridgeParameters
Prelude.Read, Int -> EventBridgeParameters -> ShowS
[EventBridgeParameters] -> ShowS
EventBridgeParameters -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventBridgeParameters] -> ShowS
$cshowList :: [EventBridgeParameters] -> ShowS
show :: EventBridgeParameters -> String
$cshow :: EventBridgeParameters -> String
showsPrec :: Int -> EventBridgeParameters -> ShowS
$cshowsPrec :: Int -> EventBridgeParameters -> ShowS
Prelude.Show, forall x. Rep EventBridgeParameters x -> EventBridgeParameters
forall x. EventBridgeParameters -> Rep EventBridgeParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventBridgeParameters x -> EventBridgeParameters
$cfrom :: forall x. EventBridgeParameters -> Rep EventBridgeParameters x
Prelude.Generic)

-- |
-- Create a value of 'EventBridgeParameters' 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:
--
-- 'detailType', 'eventBridgeParameters_detailType' - A free-form string, with a maximum of 128 characters, used to decide
-- what fields to expect in the event detail.
--
-- 'source', 'eventBridgeParameters_source' - The source of the event.
newEventBridgeParameters ::
  -- | 'detailType'
  Prelude.Text ->
  -- | 'source'
  Prelude.Text ->
  EventBridgeParameters
newEventBridgeParameters :: Text -> Text -> EventBridgeParameters
newEventBridgeParameters Text
pDetailType_ Text
pSource_ =
  EventBridgeParameters'
    { $sel:detailType:EventBridgeParameters' :: Text
detailType = Text
pDetailType_,
      $sel:source:EventBridgeParameters' :: Text
source = Text
pSource_
    }

-- | A free-form string, with a maximum of 128 characters, used to decide
-- what fields to expect in the event detail.
eventBridgeParameters_detailType :: Lens.Lens' EventBridgeParameters Prelude.Text
eventBridgeParameters_detailType :: Lens' EventBridgeParameters Text
eventBridgeParameters_detailType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventBridgeParameters' {Text
detailType :: Text
$sel:detailType:EventBridgeParameters' :: EventBridgeParameters -> Text
detailType} -> Text
detailType) (\s :: EventBridgeParameters
s@EventBridgeParameters' {} Text
a -> EventBridgeParameters
s {$sel:detailType:EventBridgeParameters' :: Text
detailType = Text
a} :: EventBridgeParameters)

-- | The source of the event.
eventBridgeParameters_source :: Lens.Lens' EventBridgeParameters Prelude.Text
eventBridgeParameters_source :: Lens' EventBridgeParameters Text
eventBridgeParameters_source = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventBridgeParameters' {Text
source :: Text
$sel:source:EventBridgeParameters' :: EventBridgeParameters -> Text
source} -> Text
source) (\s :: EventBridgeParameters
s@EventBridgeParameters' {} Text
a -> EventBridgeParameters
s {$sel:source:EventBridgeParameters' :: Text
source = Text
a} :: EventBridgeParameters)

instance Data.FromJSON EventBridgeParameters where
  parseJSON :: Value -> Parser EventBridgeParameters
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EventBridgeParameters"
      ( \Object
x ->
          Text -> Text -> EventBridgeParameters
EventBridgeParameters'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DetailType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Source")
      )

instance Prelude.Hashable EventBridgeParameters where
  hashWithSalt :: Int -> EventBridgeParameters -> Int
hashWithSalt Int
_salt EventBridgeParameters' {Text
source :: Text
detailType :: Text
$sel:source:EventBridgeParameters' :: EventBridgeParameters -> Text
$sel:detailType:EventBridgeParameters' :: EventBridgeParameters -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
detailType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
source

instance Prelude.NFData EventBridgeParameters where
  rnf :: EventBridgeParameters -> ()
rnf EventBridgeParameters' {Text
source :: Text
detailType :: Text
$sel:source:EventBridgeParameters' :: EventBridgeParameters -> Text
$sel:detailType:EventBridgeParameters' :: EventBridgeParameters -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
detailType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
source

instance Data.ToJSON EventBridgeParameters where
  toJSON :: EventBridgeParameters -> Value
toJSON EventBridgeParameters' {Text
source :: Text
detailType :: Text
$sel:source:EventBridgeParameters' :: EventBridgeParameters -> Text
$sel:detailType:EventBridgeParameters' :: EventBridgeParameters -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"DetailType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
detailType),
            forall a. a -> Maybe a
Prelude.Just (Key
"Source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
source)
          ]
      )