{-# 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.ConnectCases.Types.EventBridgeConfiguration
-- 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.ConnectCases.Types.EventBridgeConfiguration where

import Amazonka.ConnectCases.Types.EventIncludedData
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

-- | Configuration to enable EventBridge case event delivery and determine
-- what data is delivered.
--
-- /See:/ 'newEventBridgeConfiguration' smart constructor.
data EventBridgeConfiguration = EventBridgeConfiguration'
  { -- | Details of what case and related item data is published through the case
    -- event stream.
    EventBridgeConfiguration -> Maybe EventIncludedData
includedData :: Prelude.Maybe EventIncludedData,
    -- | Indicates whether the to broadcast case event data to the customer.
    EventBridgeConfiguration -> Bool
enabled :: Prelude.Bool
  }
  deriving (EventBridgeConfiguration -> EventBridgeConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventBridgeConfiguration -> EventBridgeConfiguration -> Bool
$c/= :: EventBridgeConfiguration -> EventBridgeConfiguration -> Bool
== :: EventBridgeConfiguration -> EventBridgeConfiguration -> Bool
$c== :: EventBridgeConfiguration -> EventBridgeConfiguration -> Bool
Prelude.Eq, ReadPrec [EventBridgeConfiguration]
ReadPrec EventBridgeConfiguration
Int -> ReadS EventBridgeConfiguration
ReadS [EventBridgeConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventBridgeConfiguration]
$creadListPrec :: ReadPrec [EventBridgeConfiguration]
readPrec :: ReadPrec EventBridgeConfiguration
$creadPrec :: ReadPrec EventBridgeConfiguration
readList :: ReadS [EventBridgeConfiguration]
$creadList :: ReadS [EventBridgeConfiguration]
readsPrec :: Int -> ReadS EventBridgeConfiguration
$creadsPrec :: Int -> ReadS EventBridgeConfiguration
Prelude.Read, Int -> EventBridgeConfiguration -> ShowS
[EventBridgeConfiguration] -> ShowS
EventBridgeConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventBridgeConfiguration] -> ShowS
$cshowList :: [EventBridgeConfiguration] -> ShowS
show :: EventBridgeConfiguration -> String
$cshow :: EventBridgeConfiguration -> String
showsPrec :: Int -> EventBridgeConfiguration -> ShowS
$cshowsPrec :: Int -> EventBridgeConfiguration -> ShowS
Prelude.Show, forall x.
Rep EventBridgeConfiguration x -> EventBridgeConfiguration
forall x.
EventBridgeConfiguration -> Rep EventBridgeConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EventBridgeConfiguration x -> EventBridgeConfiguration
$cfrom :: forall x.
EventBridgeConfiguration -> Rep EventBridgeConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EventBridgeConfiguration' 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:
--
-- 'includedData', 'eventBridgeConfiguration_includedData' - Details of what case and related item data is published through the case
-- event stream.
--
-- 'enabled', 'eventBridgeConfiguration_enabled' - Indicates whether the to broadcast case event data to the customer.
newEventBridgeConfiguration ::
  -- | 'enabled'
  Prelude.Bool ->
  EventBridgeConfiguration
newEventBridgeConfiguration :: Bool -> EventBridgeConfiguration
newEventBridgeConfiguration Bool
pEnabled_ =
  EventBridgeConfiguration'
    { $sel:includedData:EventBridgeConfiguration' :: Maybe EventIncludedData
includedData =
        forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:EventBridgeConfiguration' :: Bool
enabled = Bool
pEnabled_
    }

-- | Details of what case and related item data is published through the case
-- event stream.
eventBridgeConfiguration_includedData :: Lens.Lens' EventBridgeConfiguration (Prelude.Maybe EventIncludedData)
eventBridgeConfiguration_includedData :: Lens' EventBridgeConfiguration (Maybe EventIncludedData)
eventBridgeConfiguration_includedData = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventBridgeConfiguration' {Maybe EventIncludedData
includedData :: Maybe EventIncludedData
$sel:includedData:EventBridgeConfiguration' :: EventBridgeConfiguration -> Maybe EventIncludedData
includedData} -> Maybe EventIncludedData
includedData) (\s :: EventBridgeConfiguration
s@EventBridgeConfiguration' {} Maybe EventIncludedData
a -> EventBridgeConfiguration
s {$sel:includedData:EventBridgeConfiguration' :: Maybe EventIncludedData
includedData = Maybe EventIncludedData
a} :: EventBridgeConfiguration)

-- | Indicates whether the to broadcast case event data to the customer.
eventBridgeConfiguration_enabled :: Lens.Lens' EventBridgeConfiguration Prelude.Bool
eventBridgeConfiguration_enabled :: Lens' EventBridgeConfiguration Bool
eventBridgeConfiguration_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventBridgeConfiguration' {Bool
enabled :: Bool
$sel:enabled:EventBridgeConfiguration' :: EventBridgeConfiguration -> Bool
enabled} -> Bool
enabled) (\s :: EventBridgeConfiguration
s@EventBridgeConfiguration' {} Bool
a -> EventBridgeConfiguration
s {$sel:enabled:EventBridgeConfiguration' :: Bool
enabled = Bool
a} :: EventBridgeConfiguration)

instance Data.FromJSON EventBridgeConfiguration where
  parseJSON :: Value -> Parser EventBridgeConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EventBridgeConfiguration"
      ( \Object
x ->
          Maybe EventIncludedData -> Bool -> EventBridgeConfiguration
EventBridgeConfiguration'
            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
"includedData")
            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
"enabled")
      )

instance Prelude.Hashable EventBridgeConfiguration where
  hashWithSalt :: Int -> EventBridgeConfiguration -> Int
hashWithSalt Int
_salt EventBridgeConfiguration' {Bool
Maybe EventIncludedData
enabled :: Bool
includedData :: Maybe EventIncludedData
$sel:enabled:EventBridgeConfiguration' :: EventBridgeConfiguration -> Bool
$sel:includedData:EventBridgeConfiguration' :: EventBridgeConfiguration -> Maybe EventIncludedData
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EventIncludedData
includedData
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
enabled

instance Prelude.NFData EventBridgeConfiguration where
  rnf :: EventBridgeConfiguration -> ()
rnf EventBridgeConfiguration' {Bool
Maybe EventIncludedData
enabled :: Bool
includedData :: Maybe EventIncludedData
$sel:enabled:EventBridgeConfiguration' :: EventBridgeConfiguration -> Bool
$sel:includedData:EventBridgeConfiguration' :: EventBridgeConfiguration -> Maybe EventIncludedData
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EventIncludedData
includedData
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
enabled

instance Data.ToJSON EventBridgeConfiguration where
  toJSON :: EventBridgeConfiguration -> Value
toJSON EventBridgeConfiguration' {Bool
Maybe EventIncludedData
enabled :: Bool
includedData :: Maybe EventIncludedData
$sel:enabled:EventBridgeConfiguration' :: EventBridgeConfiguration -> Bool
$sel:includedData:EventBridgeConfiguration' :: EventBridgeConfiguration -> Maybe EventIncludedData
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"includedData" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EventIncludedData
includedData,
            forall a. a -> Maybe a
Prelude.Just (Key
"enabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
enabled)
          ]
      )