{-# 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.SourceAccessConfiguration
-- 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.SourceAccessConfiguration 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.SourceAccessType
import qualified Amazonka.Prelude as Prelude

-- | To secure and define access to your event source, you can specify the
-- authentication protocol, VPC components, or virtual host.
--
-- /See:/ 'newSourceAccessConfiguration' smart constructor.
data SourceAccessConfiguration = SourceAccessConfiguration'
  { -- | The type of authentication protocol, VPC components, or virtual host for
    -- your event source. For example: @\"Type\":\"SASL_SCRAM_512_AUTH\"@.
    --
    -- -   @BASIC_AUTH@ - (Amazon MQ) The Secrets Manager secret that stores
    --     your broker credentials.
    --
    -- -   @BASIC_AUTH@ - (Self-managed Apache Kafka) The Secrets Manager ARN
    --     of your secret key used for SASL\/PLAIN authentication of your
    --     Apache Kafka brokers.
    --
    -- -   @VPC_SUBNET@ - (Self-managed Apache Kafka) The subnets associated
    --     with your VPC. Lambda connects to these subnets to fetch data from
    --     your self-managed Apache Kafka cluster.
    --
    -- -   @VPC_SECURITY_GROUP@ - (Self-managed Apache Kafka) The VPC security
    --     group used to manage access to your self-managed Apache Kafka
    --     brokers.
    --
    -- -   @SASL_SCRAM_256_AUTH@ - (Self-managed Apache Kafka) The Secrets
    --     Manager ARN of your secret key used for SASL SCRAM-256
    --     authentication of your self-managed Apache Kafka brokers.
    --
    -- -   @SASL_SCRAM_512_AUTH@ - (Amazon MSK, Self-managed Apache Kafka) The
    --     Secrets Manager ARN of your secret key used for SASL SCRAM-512
    --     authentication of your self-managed Apache Kafka brokers.
    --
    -- -   @VIRTUAL_HOST@ - (RabbitMQ) The name of the virtual host in your
    --     RabbitMQ broker. Lambda uses this RabbitMQ host as the event source.
    --     This property cannot be specified in an UpdateEventSourceMapping API
    --     call.
    --
    -- -   @CLIENT_CERTIFICATE_TLS_AUTH@ - (Amazon MSK, self-managed Apache
    --     Kafka) The Secrets Manager ARN of your secret key containing the
    --     certificate chain (X.509 PEM), private key (PKCS#8 PEM), and private
    --     key password (optional) used for mutual TLS authentication of your
    --     MSK\/Apache Kafka brokers.
    --
    -- -   @SERVER_ROOT_CA_CERTIFICATE@ - (Self-managed Apache Kafka) The
    --     Secrets Manager ARN of your secret key containing the root CA
    --     certificate (X.509 PEM) used for TLS encryption of your Apache Kafka
    --     brokers.
    SourceAccessConfiguration -> Maybe SourceAccessType
type' :: Prelude.Maybe SourceAccessType,
    -- | The value for your chosen configuration in @Type@. For example:
    -- @\"URI\": \"arn:aws:secretsmanager:us-east-1:01234567890:secret:MyBrokerSecretName\"@.
    SourceAccessConfiguration -> Maybe Text
uri :: Prelude.Maybe Prelude.Text
  }
  deriving (SourceAccessConfiguration -> SourceAccessConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceAccessConfiguration -> SourceAccessConfiguration -> Bool
$c/= :: SourceAccessConfiguration -> SourceAccessConfiguration -> Bool
== :: SourceAccessConfiguration -> SourceAccessConfiguration -> Bool
$c== :: SourceAccessConfiguration -> SourceAccessConfiguration -> Bool
Prelude.Eq, ReadPrec [SourceAccessConfiguration]
ReadPrec SourceAccessConfiguration
Int -> ReadS SourceAccessConfiguration
ReadS [SourceAccessConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceAccessConfiguration]
$creadListPrec :: ReadPrec [SourceAccessConfiguration]
readPrec :: ReadPrec SourceAccessConfiguration
$creadPrec :: ReadPrec SourceAccessConfiguration
readList :: ReadS [SourceAccessConfiguration]
$creadList :: ReadS [SourceAccessConfiguration]
readsPrec :: Int -> ReadS SourceAccessConfiguration
$creadsPrec :: Int -> ReadS SourceAccessConfiguration
Prelude.Read, Int -> SourceAccessConfiguration -> ShowS
[SourceAccessConfiguration] -> ShowS
SourceAccessConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceAccessConfiguration] -> ShowS
$cshowList :: [SourceAccessConfiguration] -> ShowS
show :: SourceAccessConfiguration -> String
$cshow :: SourceAccessConfiguration -> String
showsPrec :: Int -> SourceAccessConfiguration -> ShowS
$cshowsPrec :: Int -> SourceAccessConfiguration -> ShowS
Prelude.Show, forall x.
Rep SourceAccessConfiguration x -> SourceAccessConfiguration
forall x.
SourceAccessConfiguration -> Rep SourceAccessConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SourceAccessConfiguration x -> SourceAccessConfiguration
$cfrom :: forall x.
SourceAccessConfiguration -> Rep SourceAccessConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SourceAccessConfiguration' 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:
--
-- 'type'', 'sourceAccessConfiguration_type' - The type of authentication protocol, VPC components, or virtual host for
-- your event source. For example: @\"Type\":\"SASL_SCRAM_512_AUTH\"@.
--
-- -   @BASIC_AUTH@ - (Amazon MQ) The Secrets Manager secret that stores
--     your broker credentials.
--
-- -   @BASIC_AUTH@ - (Self-managed Apache Kafka) The Secrets Manager ARN
--     of your secret key used for SASL\/PLAIN authentication of your
--     Apache Kafka brokers.
--
-- -   @VPC_SUBNET@ - (Self-managed Apache Kafka) The subnets associated
--     with your VPC. Lambda connects to these subnets to fetch data from
--     your self-managed Apache Kafka cluster.
--
-- -   @VPC_SECURITY_GROUP@ - (Self-managed Apache Kafka) The VPC security
--     group used to manage access to your self-managed Apache Kafka
--     brokers.
--
-- -   @SASL_SCRAM_256_AUTH@ - (Self-managed Apache Kafka) The Secrets
--     Manager ARN of your secret key used for SASL SCRAM-256
--     authentication of your self-managed Apache Kafka brokers.
--
-- -   @SASL_SCRAM_512_AUTH@ - (Amazon MSK, Self-managed Apache Kafka) The
--     Secrets Manager ARN of your secret key used for SASL SCRAM-512
--     authentication of your self-managed Apache Kafka brokers.
--
-- -   @VIRTUAL_HOST@ - (RabbitMQ) The name of the virtual host in your
--     RabbitMQ broker. Lambda uses this RabbitMQ host as the event source.
--     This property cannot be specified in an UpdateEventSourceMapping API
--     call.
--
-- -   @CLIENT_CERTIFICATE_TLS_AUTH@ - (Amazon MSK, self-managed Apache
--     Kafka) The Secrets Manager ARN of your secret key containing the
--     certificate chain (X.509 PEM), private key (PKCS#8 PEM), and private
--     key password (optional) used for mutual TLS authentication of your
--     MSK\/Apache Kafka brokers.
--
-- -   @SERVER_ROOT_CA_CERTIFICATE@ - (Self-managed Apache Kafka) The
--     Secrets Manager ARN of your secret key containing the root CA
--     certificate (X.509 PEM) used for TLS encryption of your Apache Kafka
--     brokers.
--
-- 'uri', 'sourceAccessConfiguration_uri' - The value for your chosen configuration in @Type@. For example:
-- @\"URI\": \"arn:aws:secretsmanager:us-east-1:01234567890:secret:MyBrokerSecretName\"@.
newSourceAccessConfiguration ::
  SourceAccessConfiguration
newSourceAccessConfiguration :: SourceAccessConfiguration
newSourceAccessConfiguration =
  SourceAccessConfiguration'
    { $sel:type':SourceAccessConfiguration' :: Maybe SourceAccessType
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:uri:SourceAccessConfiguration' :: Maybe Text
uri = forall a. Maybe a
Prelude.Nothing
    }

-- | The type of authentication protocol, VPC components, or virtual host for
-- your event source. For example: @\"Type\":\"SASL_SCRAM_512_AUTH\"@.
--
-- -   @BASIC_AUTH@ - (Amazon MQ) The Secrets Manager secret that stores
--     your broker credentials.
--
-- -   @BASIC_AUTH@ - (Self-managed Apache Kafka) The Secrets Manager ARN
--     of your secret key used for SASL\/PLAIN authentication of your
--     Apache Kafka brokers.
--
-- -   @VPC_SUBNET@ - (Self-managed Apache Kafka) The subnets associated
--     with your VPC. Lambda connects to these subnets to fetch data from
--     your self-managed Apache Kafka cluster.
--
-- -   @VPC_SECURITY_GROUP@ - (Self-managed Apache Kafka) The VPC security
--     group used to manage access to your self-managed Apache Kafka
--     brokers.
--
-- -   @SASL_SCRAM_256_AUTH@ - (Self-managed Apache Kafka) The Secrets
--     Manager ARN of your secret key used for SASL SCRAM-256
--     authentication of your self-managed Apache Kafka brokers.
--
-- -   @SASL_SCRAM_512_AUTH@ - (Amazon MSK, Self-managed Apache Kafka) The
--     Secrets Manager ARN of your secret key used for SASL SCRAM-512
--     authentication of your self-managed Apache Kafka brokers.
--
-- -   @VIRTUAL_HOST@ - (RabbitMQ) The name of the virtual host in your
--     RabbitMQ broker. Lambda uses this RabbitMQ host as the event source.
--     This property cannot be specified in an UpdateEventSourceMapping API
--     call.
--
-- -   @CLIENT_CERTIFICATE_TLS_AUTH@ - (Amazon MSK, self-managed Apache
--     Kafka) The Secrets Manager ARN of your secret key containing the
--     certificate chain (X.509 PEM), private key (PKCS#8 PEM), and private
--     key password (optional) used for mutual TLS authentication of your
--     MSK\/Apache Kafka brokers.
--
-- -   @SERVER_ROOT_CA_CERTIFICATE@ - (Self-managed Apache Kafka) The
--     Secrets Manager ARN of your secret key containing the root CA
--     certificate (X.509 PEM) used for TLS encryption of your Apache Kafka
--     brokers.
sourceAccessConfiguration_type :: Lens.Lens' SourceAccessConfiguration (Prelude.Maybe SourceAccessType)
sourceAccessConfiguration_type :: Lens' SourceAccessConfiguration (Maybe SourceAccessType)
sourceAccessConfiguration_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceAccessConfiguration' {Maybe SourceAccessType
type' :: Maybe SourceAccessType
$sel:type':SourceAccessConfiguration' :: SourceAccessConfiguration -> Maybe SourceAccessType
type'} -> Maybe SourceAccessType
type') (\s :: SourceAccessConfiguration
s@SourceAccessConfiguration' {} Maybe SourceAccessType
a -> SourceAccessConfiguration
s {$sel:type':SourceAccessConfiguration' :: Maybe SourceAccessType
type' = Maybe SourceAccessType
a} :: SourceAccessConfiguration)

-- | The value for your chosen configuration in @Type@. For example:
-- @\"URI\": \"arn:aws:secretsmanager:us-east-1:01234567890:secret:MyBrokerSecretName\"@.
sourceAccessConfiguration_uri :: Lens.Lens' SourceAccessConfiguration (Prelude.Maybe Prelude.Text)
sourceAccessConfiguration_uri :: Lens' SourceAccessConfiguration (Maybe Text)
sourceAccessConfiguration_uri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceAccessConfiguration' {Maybe Text
uri :: Maybe Text
$sel:uri:SourceAccessConfiguration' :: SourceAccessConfiguration -> Maybe Text
uri} -> Maybe Text
uri) (\s :: SourceAccessConfiguration
s@SourceAccessConfiguration' {} Maybe Text
a -> SourceAccessConfiguration
s {$sel:uri:SourceAccessConfiguration' :: Maybe Text
uri = Maybe Text
a} :: SourceAccessConfiguration)

instance Data.FromJSON SourceAccessConfiguration where
  parseJSON :: Value -> Parser SourceAccessConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SourceAccessConfiguration"
      ( \Object
x ->
          Maybe SourceAccessType -> Maybe Text -> SourceAccessConfiguration
SourceAccessConfiguration'
            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
"Type")
            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
"URI")
      )

instance Prelude.Hashable SourceAccessConfiguration where
  hashWithSalt :: Int -> SourceAccessConfiguration -> Int
hashWithSalt Int
_salt SourceAccessConfiguration' {Maybe Text
Maybe SourceAccessType
uri :: Maybe Text
type' :: Maybe SourceAccessType
$sel:uri:SourceAccessConfiguration' :: SourceAccessConfiguration -> Maybe Text
$sel:type':SourceAccessConfiguration' :: SourceAccessConfiguration -> Maybe SourceAccessType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SourceAccessType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
uri

instance Prelude.NFData SourceAccessConfiguration where
  rnf :: SourceAccessConfiguration -> ()
rnf SourceAccessConfiguration' {Maybe Text
Maybe SourceAccessType
uri :: Maybe Text
type' :: Maybe SourceAccessType
$sel:uri:SourceAccessConfiguration' :: SourceAccessConfiguration -> Maybe Text
$sel:type':SourceAccessConfiguration' :: SourceAccessConfiguration -> Maybe SourceAccessType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SourceAccessType
type' seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
uri

instance Data.ToJSON SourceAccessConfiguration where
  toJSON :: SourceAccessConfiguration -> Value
toJSON SourceAccessConfiguration' {Maybe Text
Maybe SourceAccessType
uri :: Maybe Text
type' :: Maybe SourceAccessType
$sel:uri:SourceAccessConfiguration' :: SourceAccessConfiguration -> Maybe Text
$sel:type':SourceAccessConfiguration' :: SourceAccessConfiguration -> Maybe SourceAccessType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Type" 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 SourceAccessType
type',
            (Key
"URI" 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 Text
uri
          ]
      )