{-# 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.Chime.Types.EventsConfiguration
-- 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.Chime.Types.EventsConfiguration 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 configuration that allows a bot to receive outgoing events. Can be
-- either an HTTPS endpoint or a Lambda function ARN.
--
-- /See:/ 'newEventsConfiguration' smart constructor.
data EventsConfiguration = EventsConfiguration'
  { -- | The bot ID.
    EventsConfiguration -> Maybe Text
botId :: Prelude.Maybe Prelude.Text,
    -- | Lambda function ARN that allows a bot to receive outgoing events.
    EventsConfiguration -> Maybe (Sensitive Text)
lambdaFunctionArn :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | HTTPS endpoint that allows a bot to receive outgoing events.
    EventsConfiguration -> Maybe (Sensitive Text)
outboundEventsHTTPSEndpoint :: Prelude.Maybe (Data.Sensitive Prelude.Text)
  }
  deriving (EventsConfiguration -> EventsConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventsConfiguration -> EventsConfiguration -> Bool
$c/= :: EventsConfiguration -> EventsConfiguration -> Bool
== :: EventsConfiguration -> EventsConfiguration -> Bool
$c== :: EventsConfiguration -> EventsConfiguration -> Bool
Prelude.Eq, Int -> EventsConfiguration -> ShowS
[EventsConfiguration] -> ShowS
EventsConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventsConfiguration] -> ShowS
$cshowList :: [EventsConfiguration] -> ShowS
show :: EventsConfiguration -> String
$cshow :: EventsConfiguration -> String
showsPrec :: Int -> EventsConfiguration -> ShowS
$cshowsPrec :: Int -> EventsConfiguration -> ShowS
Prelude.Show, forall x. Rep EventsConfiguration x -> EventsConfiguration
forall x. EventsConfiguration -> Rep EventsConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventsConfiguration x -> EventsConfiguration
$cfrom :: forall x. EventsConfiguration -> Rep EventsConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EventsConfiguration' 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:
--
-- 'botId', 'eventsConfiguration_botId' - The bot ID.
--
-- 'lambdaFunctionArn', 'eventsConfiguration_lambdaFunctionArn' - Lambda function ARN that allows a bot to receive outgoing events.
--
-- 'outboundEventsHTTPSEndpoint', 'eventsConfiguration_outboundEventsHTTPSEndpoint' - HTTPS endpoint that allows a bot to receive outgoing events.
newEventsConfiguration ::
  EventsConfiguration
newEventsConfiguration :: EventsConfiguration
newEventsConfiguration =
  EventsConfiguration'
    { $sel:botId:EventsConfiguration' :: Maybe Text
botId = forall a. Maybe a
Prelude.Nothing,
      $sel:lambdaFunctionArn:EventsConfiguration' :: Maybe (Sensitive Text)
lambdaFunctionArn = forall a. Maybe a
Prelude.Nothing,
      $sel:outboundEventsHTTPSEndpoint:EventsConfiguration' :: Maybe (Sensitive Text)
outboundEventsHTTPSEndpoint = forall a. Maybe a
Prelude.Nothing
    }

-- | The bot ID.
eventsConfiguration_botId :: Lens.Lens' EventsConfiguration (Prelude.Maybe Prelude.Text)
eventsConfiguration_botId :: Lens' EventsConfiguration (Maybe Text)
eventsConfiguration_botId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventsConfiguration' {Maybe Text
botId :: Maybe Text
$sel:botId:EventsConfiguration' :: EventsConfiguration -> Maybe Text
botId} -> Maybe Text
botId) (\s :: EventsConfiguration
s@EventsConfiguration' {} Maybe Text
a -> EventsConfiguration
s {$sel:botId:EventsConfiguration' :: Maybe Text
botId = Maybe Text
a} :: EventsConfiguration)

-- | Lambda function ARN that allows a bot to receive outgoing events.
eventsConfiguration_lambdaFunctionArn :: Lens.Lens' EventsConfiguration (Prelude.Maybe Prelude.Text)
eventsConfiguration_lambdaFunctionArn :: Lens' EventsConfiguration (Maybe Text)
eventsConfiguration_lambdaFunctionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventsConfiguration' {Maybe (Sensitive Text)
lambdaFunctionArn :: Maybe (Sensitive Text)
$sel:lambdaFunctionArn:EventsConfiguration' :: EventsConfiguration -> Maybe (Sensitive Text)
lambdaFunctionArn} -> Maybe (Sensitive Text)
lambdaFunctionArn) (\s :: EventsConfiguration
s@EventsConfiguration' {} Maybe (Sensitive Text)
a -> EventsConfiguration
s {$sel:lambdaFunctionArn:EventsConfiguration' :: Maybe (Sensitive Text)
lambdaFunctionArn = Maybe (Sensitive Text)
a} :: EventsConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | HTTPS endpoint that allows a bot to receive outgoing events.
eventsConfiguration_outboundEventsHTTPSEndpoint :: Lens.Lens' EventsConfiguration (Prelude.Maybe Prelude.Text)
eventsConfiguration_outboundEventsHTTPSEndpoint :: Lens' EventsConfiguration (Maybe Text)
eventsConfiguration_outboundEventsHTTPSEndpoint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventsConfiguration' {Maybe (Sensitive Text)
outboundEventsHTTPSEndpoint :: Maybe (Sensitive Text)
$sel:outboundEventsHTTPSEndpoint:EventsConfiguration' :: EventsConfiguration -> Maybe (Sensitive Text)
outboundEventsHTTPSEndpoint} -> Maybe (Sensitive Text)
outboundEventsHTTPSEndpoint) (\s :: EventsConfiguration
s@EventsConfiguration' {} Maybe (Sensitive Text)
a -> EventsConfiguration
s {$sel:outboundEventsHTTPSEndpoint:EventsConfiguration' :: Maybe (Sensitive Text)
outboundEventsHTTPSEndpoint = Maybe (Sensitive Text)
a} :: EventsConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Data.FromJSON EventsConfiguration where
  parseJSON :: Value -> Parser EventsConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EventsConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe (Sensitive Text)
-> Maybe (Sensitive Text)
-> EventsConfiguration
EventsConfiguration'
            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
"BotId")
            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
"LambdaFunctionArn")
            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
"OutboundEventsHTTPSEndpoint")
      )

instance Prelude.Hashable EventsConfiguration where
  hashWithSalt :: Int -> EventsConfiguration -> Int
hashWithSalt Int
_salt EventsConfiguration' {Maybe Text
Maybe (Sensitive Text)
outboundEventsHTTPSEndpoint :: Maybe (Sensitive Text)
lambdaFunctionArn :: Maybe (Sensitive Text)
botId :: Maybe Text
$sel:outboundEventsHTTPSEndpoint:EventsConfiguration' :: EventsConfiguration -> Maybe (Sensitive Text)
$sel:lambdaFunctionArn:EventsConfiguration' :: EventsConfiguration -> Maybe (Sensitive Text)
$sel:botId:EventsConfiguration' :: EventsConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
botId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
lambdaFunctionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
outboundEventsHTTPSEndpoint

instance Prelude.NFData EventsConfiguration where
  rnf :: EventsConfiguration -> ()
rnf EventsConfiguration' {Maybe Text
Maybe (Sensitive Text)
outboundEventsHTTPSEndpoint :: Maybe (Sensitive Text)
lambdaFunctionArn :: Maybe (Sensitive Text)
botId :: Maybe Text
$sel:outboundEventsHTTPSEndpoint:EventsConfiguration' :: EventsConfiguration -> Maybe (Sensitive Text)
$sel:lambdaFunctionArn:EventsConfiguration' :: EventsConfiguration -> Maybe (Sensitive Text)
$sel:botId:EventsConfiguration' :: EventsConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
botId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
lambdaFunctionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
outboundEventsHTTPSEndpoint