{-# 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.Lambda.Types.SelfManagedEventSource
-- 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.Lambda.Types.SelfManagedEventSource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lambda.Types.EndPointType
import qualified Amazonka.Prelude as Prelude

-- | The self-managed Apache Kafka cluster for your event source.
--
-- /See:/ 'newSelfManagedEventSource' smart constructor.
data SelfManagedEventSource = SelfManagedEventSource'
  { -- | The list of bootstrap servers for your Kafka brokers in the following
    -- format:
    -- @\"KAFKA_BOOTSTRAP_SERVERS\": [\"abc.xyz.com:xxxx\",\"abc2.xyz.com:xxxx\"]@.
    SelfManagedEventSource
-> Maybe (HashMap EndPointType (NonEmpty Text))
endpoints :: Prelude.Maybe (Prelude.HashMap EndPointType (Prelude.NonEmpty Prelude.Text))
  }
  deriving (SelfManagedEventSource -> SelfManagedEventSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SelfManagedEventSource -> SelfManagedEventSource -> Bool
$c/= :: SelfManagedEventSource -> SelfManagedEventSource -> Bool
== :: SelfManagedEventSource -> SelfManagedEventSource -> Bool
$c== :: SelfManagedEventSource -> SelfManagedEventSource -> Bool
Prelude.Eq, ReadPrec [SelfManagedEventSource]
ReadPrec SelfManagedEventSource
Int -> ReadS SelfManagedEventSource
ReadS [SelfManagedEventSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SelfManagedEventSource]
$creadListPrec :: ReadPrec [SelfManagedEventSource]
readPrec :: ReadPrec SelfManagedEventSource
$creadPrec :: ReadPrec SelfManagedEventSource
readList :: ReadS [SelfManagedEventSource]
$creadList :: ReadS [SelfManagedEventSource]
readsPrec :: Int -> ReadS SelfManagedEventSource
$creadsPrec :: Int -> ReadS SelfManagedEventSource
Prelude.Read, Int -> SelfManagedEventSource -> ShowS
[SelfManagedEventSource] -> ShowS
SelfManagedEventSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SelfManagedEventSource] -> ShowS
$cshowList :: [SelfManagedEventSource] -> ShowS
show :: SelfManagedEventSource -> String
$cshow :: SelfManagedEventSource -> String
showsPrec :: Int -> SelfManagedEventSource -> ShowS
$cshowsPrec :: Int -> SelfManagedEventSource -> ShowS
Prelude.Show, forall x. Rep SelfManagedEventSource x -> SelfManagedEventSource
forall x. SelfManagedEventSource -> Rep SelfManagedEventSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SelfManagedEventSource x -> SelfManagedEventSource
$cfrom :: forall x. SelfManagedEventSource -> Rep SelfManagedEventSource x
Prelude.Generic)

-- |
-- Create a value of 'SelfManagedEventSource' 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:
--
-- 'endpoints', 'selfManagedEventSource_endpoints' - The list of bootstrap servers for your Kafka brokers in the following
-- format:
-- @\"KAFKA_BOOTSTRAP_SERVERS\": [\"abc.xyz.com:xxxx\",\"abc2.xyz.com:xxxx\"]@.
newSelfManagedEventSource ::
  SelfManagedEventSource
newSelfManagedEventSource :: SelfManagedEventSource
newSelfManagedEventSource =
  SelfManagedEventSource'
    { $sel:endpoints:SelfManagedEventSource' :: Maybe (HashMap EndPointType (NonEmpty Text))
endpoints =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The list of bootstrap servers for your Kafka brokers in the following
-- format:
-- @\"KAFKA_BOOTSTRAP_SERVERS\": [\"abc.xyz.com:xxxx\",\"abc2.xyz.com:xxxx\"]@.
selfManagedEventSource_endpoints :: Lens.Lens' SelfManagedEventSource (Prelude.Maybe (Prelude.HashMap EndPointType (Prelude.NonEmpty Prelude.Text)))
selfManagedEventSource_endpoints :: Lens'
  SelfManagedEventSource
  (Maybe (HashMap EndPointType (NonEmpty Text)))
selfManagedEventSource_endpoints = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelfManagedEventSource' {Maybe (HashMap EndPointType (NonEmpty Text))
endpoints :: Maybe (HashMap EndPointType (NonEmpty Text))
$sel:endpoints:SelfManagedEventSource' :: SelfManagedEventSource
-> Maybe (HashMap EndPointType (NonEmpty Text))
endpoints} -> Maybe (HashMap EndPointType (NonEmpty Text))
endpoints) (\s :: SelfManagedEventSource
s@SelfManagedEventSource' {} Maybe (HashMap EndPointType (NonEmpty Text))
a -> SelfManagedEventSource
s {$sel:endpoints:SelfManagedEventSource' :: Maybe (HashMap EndPointType (NonEmpty Text))
endpoints = Maybe (HashMap EndPointType (NonEmpty Text))
a} :: SelfManagedEventSource) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON SelfManagedEventSource where
  parseJSON :: Value -> Parser SelfManagedEventSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SelfManagedEventSource"
      ( \Object
x ->
          Maybe (HashMap EndPointType (NonEmpty Text))
-> SelfManagedEventSource
SelfManagedEventSource'
            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
"Endpoints" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SelfManagedEventSource where
  hashWithSalt :: Int -> SelfManagedEventSource -> Int
hashWithSalt Int
_salt SelfManagedEventSource' {Maybe (HashMap EndPointType (NonEmpty Text))
endpoints :: Maybe (HashMap EndPointType (NonEmpty Text))
$sel:endpoints:SelfManagedEventSource' :: SelfManagedEventSource
-> Maybe (HashMap EndPointType (NonEmpty Text))
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap EndPointType (NonEmpty Text))
endpoints

instance Prelude.NFData SelfManagedEventSource where
  rnf :: SelfManagedEventSource -> ()
rnf SelfManagedEventSource' {Maybe (HashMap EndPointType (NonEmpty Text))
endpoints :: Maybe (HashMap EndPointType (NonEmpty Text))
$sel:endpoints:SelfManagedEventSource' :: SelfManagedEventSource
-> Maybe (HashMap EndPointType (NonEmpty Text))
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap EndPointType (NonEmpty Text))
endpoints

instance Data.ToJSON SelfManagedEventSource where
  toJSON :: SelfManagedEventSource -> Value
toJSON SelfManagedEventSource' {Maybe (HashMap EndPointType (NonEmpty Text))
endpoints :: Maybe (HashMap EndPointType (NonEmpty Text))
$sel:endpoints:SelfManagedEventSource' :: SelfManagedEventSource
-> Maybe (HashMap EndPointType (NonEmpty Text))
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Endpoints" 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 (HashMap EndPointType (NonEmpty Text))
endpoints]
      )