{-# 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-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.Chime.Types.EventsConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | Lambda function ARN that allows a bot to receive outgoing events.
    EventsConfiguration -> Maybe (Sensitive Text)
lambdaFunctionArn :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The bot ID.
    EventsConfiguration -> Maybe Text
botId :: Prelude.Maybe Prelude.Text,
    -- | HTTPS endpoint that allows a bot to receive outgoing events.
    EventsConfiguration -> Maybe (Sensitive Text)
outboundEventsHTTPSEndpoint :: Prelude.Maybe (Core.Sensitive Prelude.Text)
  }
  deriving (EventsConfiguration -> EventsConfiguration -> Bool
(EventsConfiguration -> EventsConfiguration -> Bool)
-> (EventsConfiguration -> EventsConfiguration -> Bool)
-> Eq EventsConfiguration
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
(Int -> EventsConfiguration -> ShowS)
-> (EventsConfiguration -> String)
-> ([EventsConfiguration] -> ShowS)
-> Show EventsConfiguration
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. EventsConfiguration -> Rep EventsConfiguration x)
-> (forall x. Rep EventsConfiguration x -> EventsConfiguration)
-> Generic EventsConfiguration
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:
--
-- 'lambdaFunctionArn', 'eventsConfiguration_lambdaFunctionArn' - Lambda function ARN that allows a bot to receive outgoing events.
--
-- 'botId', 'eventsConfiguration_botId' - The bot ID.
--
-- 'outboundEventsHTTPSEndpoint', 'eventsConfiguration_outboundEventsHTTPSEndpoint' - HTTPS endpoint that allows a bot to receive outgoing events.
newEventsConfiguration ::
  EventsConfiguration
newEventsConfiguration :: EventsConfiguration
newEventsConfiguration =
  EventsConfiguration' :: Maybe (Sensitive Text)
-> Maybe Text -> Maybe (Sensitive Text) -> EventsConfiguration
EventsConfiguration'
    { $sel:lambdaFunctionArn:EventsConfiguration' :: Maybe (Sensitive Text)
lambdaFunctionArn =
        Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:botId:EventsConfiguration' :: Maybe Text
botId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:outboundEventsHTTPSEndpoint:EventsConfiguration' :: Maybe (Sensitive Text)
outboundEventsHTTPSEndpoint = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | Lambda function ARN that allows a bot to receive outgoing events.
eventsConfiguration_lambdaFunctionArn :: Lens.Lens' EventsConfiguration (Prelude.Maybe Prelude.Text)
eventsConfiguration_lambdaFunctionArn :: (Maybe Text -> f (Maybe Text))
-> EventsConfiguration -> f EventsConfiguration
eventsConfiguration_lambdaFunctionArn = (EventsConfiguration -> Maybe (Sensitive Text))
-> (EventsConfiguration
    -> Maybe (Sensitive Text) -> EventsConfiguration)
-> Lens
     EventsConfiguration
     EventsConfiguration
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
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) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> EventsConfiguration -> f EventsConfiguration)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> EventsConfiguration
-> f EventsConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The bot ID.
eventsConfiguration_botId :: Lens.Lens' EventsConfiguration (Prelude.Maybe Prelude.Text)
eventsConfiguration_botId :: (Maybe Text -> f (Maybe Text))
-> EventsConfiguration -> f EventsConfiguration
eventsConfiguration_botId = (EventsConfiguration -> Maybe Text)
-> (EventsConfiguration -> Maybe Text -> EventsConfiguration)
-> Lens
     EventsConfiguration EventsConfiguration (Maybe Text) (Maybe Text)
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)

-- | HTTPS endpoint that allows a bot to receive outgoing events.
eventsConfiguration_outboundEventsHTTPSEndpoint :: Lens.Lens' EventsConfiguration (Prelude.Maybe Prelude.Text)
eventsConfiguration_outboundEventsHTTPSEndpoint :: (Maybe Text -> f (Maybe Text))
-> EventsConfiguration -> f EventsConfiguration
eventsConfiguration_outboundEventsHTTPSEndpoint = (EventsConfiguration -> Maybe (Sensitive Text))
-> (EventsConfiguration
    -> Maybe (Sensitive Text) -> EventsConfiguration)
-> Lens
     EventsConfiguration
     EventsConfiguration
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
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) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> EventsConfiguration -> f EventsConfiguration)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> EventsConfiguration
-> f EventsConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance Core.FromJSON EventsConfiguration where
  parseJSON :: Value -> Parser EventsConfiguration
parseJSON =
    String
-> (Object -> Parser EventsConfiguration)
-> Value
-> Parser EventsConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventsConfiguration"
      ( \Object
x ->
          Maybe (Sensitive Text)
-> Maybe Text -> Maybe (Sensitive Text) -> EventsConfiguration
EventsConfiguration'
            (Maybe (Sensitive Text)
 -> Maybe Text -> Maybe (Sensitive Text) -> EventsConfiguration)
-> Parser (Maybe (Sensitive Text))
-> Parser
     (Maybe Text -> Maybe (Sensitive Text) -> EventsConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LambdaFunctionArn")
            Parser
  (Maybe Text -> Maybe (Sensitive Text) -> EventsConfiguration)
-> Parser (Maybe Text)
-> Parser (Maybe (Sensitive Text) -> EventsConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BotId")
            Parser (Maybe (Sensitive Text) -> EventsConfiguration)
-> Parser (Maybe (Sensitive Text)) -> Parser EventsConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OutboundEventsHTTPSEndpoint")
      )

instance Prelude.Hashable EventsConfiguration

instance Prelude.NFData EventsConfiguration