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

import qualified Amazonka.Core as Core
import Amazonka.Lambda.Types.EndPointType
import qualified Amazonka.Lens as Lens
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
(SelfManagedEventSource -> SelfManagedEventSource -> Bool)
-> (SelfManagedEventSource -> SelfManagedEventSource -> Bool)
-> Eq SelfManagedEventSource
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]
(Int -> ReadS SelfManagedEventSource)
-> ReadS [SelfManagedEventSource]
-> ReadPrec SelfManagedEventSource
-> ReadPrec [SelfManagedEventSource]
-> Read 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
(Int -> SelfManagedEventSource -> ShowS)
-> (SelfManagedEventSource -> String)
-> ([SelfManagedEventSource] -> ShowS)
-> Show SelfManagedEventSource
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. SelfManagedEventSource -> Rep SelfManagedEventSource x)
-> (forall x.
    Rep SelfManagedEventSource x -> SelfManagedEventSource)
-> Generic SelfManagedEventSource
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' :: Maybe (HashMap EndPointType (NonEmpty Text))
-> SelfManagedEventSource
SelfManagedEventSource'
    { $sel:endpoints:SelfManagedEventSource' :: Maybe (HashMap EndPointType (NonEmpty Text))
endpoints =
        Maybe (HashMap EndPointType (NonEmpty Text))
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 :: (Maybe (HashMap EndPointType (NonEmpty Text))
 -> f (Maybe (HashMap EndPointType (NonEmpty Text))))
-> SelfManagedEventSource -> f SelfManagedEventSource
selfManagedEventSource_endpoints = (SelfManagedEventSource
 -> Maybe (HashMap EndPointType (NonEmpty Text)))
-> (SelfManagedEventSource
    -> Maybe (HashMap EndPointType (NonEmpty Text))
    -> SelfManagedEventSource)
-> Lens
     SelfManagedEventSource
     SelfManagedEventSource
     (Maybe (HashMap EndPointType (NonEmpty Text)))
     (Maybe (HashMap EndPointType (NonEmpty Text)))
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) ((Maybe (HashMap EndPointType (NonEmpty Text))
  -> f (Maybe (HashMap EndPointType (NonEmpty Text))))
 -> SelfManagedEventSource -> f SelfManagedEventSource)
-> ((Maybe (HashMap EndPointType (NonEmpty Text))
     -> f (Maybe (HashMap EndPointType (NonEmpty Text))))
    -> Maybe (HashMap EndPointType (NonEmpty Text))
    -> f (Maybe (HashMap EndPointType (NonEmpty Text))))
-> (Maybe (HashMap EndPointType (NonEmpty Text))
    -> f (Maybe (HashMap EndPointType (NonEmpty Text))))
-> SelfManagedEventSource
-> f SelfManagedEventSource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap EndPointType (NonEmpty Text))
  (HashMap EndPointType (NonEmpty Text))
  (HashMap EndPointType (NonEmpty Text))
  (HashMap EndPointType (NonEmpty Text))
-> Iso
     (Maybe (HashMap EndPointType (NonEmpty Text)))
     (Maybe (HashMap EndPointType (NonEmpty Text)))
     (Maybe (HashMap EndPointType (NonEmpty Text)))
     (Maybe (HashMap EndPointType (NonEmpty 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
  (HashMap EndPointType (NonEmpty Text))
  (HashMap EndPointType (NonEmpty Text))
  (HashMap EndPointType (NonEmpty Text))
  (HashMap EndPointType (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON SelfManagedEventSource where
  parseJSON :: Value -> Parser SelfManagedEventSource
parseJSON =
    String
-> (Object -> Parser SelfManagedEventSource)
-> Value
-> Parser SelfManagedEventSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SelfManagedEventSource"
      ( \Object
x ->
          Maybe (HashMap EndPointType (NonEmpty Text))
-> SelfManagedEventSource
SelfManagedEventSource'
            (Maybe (HashMap EndPointType (NonEmpty Text))
 -> SelfManagedEventSource)
-> Parser (Maybe (HashMap EndPointType (NonEmpty Text)))
-> Parser SelfManagedEventSource
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text
-> Parser (Maybe (Maybe (HashMap EndPointType (NonEmpty Text))))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Endpoints" Parser (Maybe (Maybe (HashMap EndPointType (NonEmpty Text))))
-> Maybe (HashMap EndPointType (NonEmpty Text))
-> Parser (Maybe (HashMap EndPointType (NonEmpty Text)))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap EndPointType (NonEmpty Text))
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SelfManagedEventSource

instance Prelude.NFData SelfManagedEventSource

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Endpoints" Text -> HashMap EndPointType (NonEmpty Text) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap EndPointType (NonEmpty Text) -> Pair)
-> Maybe (HashMap EndPointType (NonEmpty Text)) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap EndPointType (NonEmpty Text))
endpoints]
      )