{-# 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-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.SourceAccessConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.Lambda.Types.SourceAccessType
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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@ - The subnets associated with your VPC. Lambda connects
    --     to these subnets to fetch data from your self-managed Apache Kafka
    --     cluster.
    --
    -- -   @VPC_SECURITY_GROUP@ - The VPC security group used to manage access
    --     to your self-managed Apache Kafka brokers.
    --
    -- -   @SASL_SCRAM_256_AUTH@ - 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@ - The Secrets Manager ARN of your secret key
    --     used for SASL SCRAM-512 authentication of your self-managed Apache
    --     Kafka brokers.
    --
    -- -   @VIRTUAL_HOST@ - (Amazon MQ) The name of the virtual host in your
    --     RabbitMQ broker. Lambda uses this RabbitMQ host as the event source.
    SourceAccessConfiguration -> Maybe SourceAccessType
type' :: Prelude.Maybe SourceAccessType
  }
  deriving (SourceAccessConfiguration -> SourceAccessConfiguration -> Bool
(SourceAccessConfiguration -> SourceAccessConfiguration -> Bool)
-> (SourceAccessConfiguration -> SourceAccessConfiguration -> Bool)
-> Eq SourceAccessConfiguration
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]
(Int -> ReadS SourceAccessConfiguration)
-> ReadS [SourceAccessConfiguration]
-> ReadPrec SourceAccessConfiguration
-> ReadPrec [SourceAccessConfiguration]
-> Read 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
(Int -> SourceAccessConfiguration -> ShowS)
-> (SourceAccessConfiguration -> String)
-> ([SourceAccessConfiguration] -> ShowS)
-> Show SourceAccessConfiguration
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.
 SourceAccessConfiguration -> Rep SourceAccessConfiguration x)
-> (forall x.
    Rep SourceAccessConfiguration x -> SourceAccessConfiguration)
-> Generic SourceAccessConfiguration
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:
--
-- 'uri', 'sourceAccessConfiguration_uri' - The value for your chosen configuration in @Type@. For example:
-- @\"URI\": \"arn:aws:secretsmanager:us-east-1:01234567890:secret:MyBrokerSecretName\"@.
--
-- '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@ - The subnets associated with your VPC. Lambda connects
--     to these subnets to fetch data from your self-managed Apache Kafka
--     cluster.
--
-- -   @VPC_SECURITY_GROUP@ - The VPC security group used to manage access
--     to your self-managed Apache Kafka brokers.
--
-- -   @SASL_SCRAM_256_AUTH@ - 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@ - The Secrets Manager ARN of your secret key
--     used for SASL SCRAM-512 authentication of your self-managed Apache
--     Kafka brokers.
--
-- -   @VIRTUAL_HOST@ - (Amazon MQ) The name of the virtual host in your
--     RabbitMQ broker. Lambda uses this RabbitMQ host as the event source.
newSourceAccessConfiguration ::
  SourceAccessConfiguration
newSourceAccessConfiguration :: SourceAccessConfiguration
newSourceAccessConfiguration =
  SourceAccessConfiguration' :: Maybe Text -> Maybe SourceAccessType -> SourceAccessConfiguration
SourceAccessConfiguration'
    { $sel:uri:SourceAccessConfiguration' :: Maybe Text
uri = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':SourceAccessConfiguration' :: Maybe SourceAccessType
type' = Maybe SourceAccessType
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> SourceAccessConfiguration -> f SourceAccessConfiguration
sourceAccessConfiguration_uri = (SourceAccessConfiguration -> Maybe Text)
-> (SourceAccessConfiguration
    -> Maybe Text -> SourceAccessConfiguration)
-> Lens
     SourceAccessConfiguration
     SourceAccessConfiguration
     (Maybe Text)
     (Maybe Text)
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)

-- | 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@ - The subnets associated with your VPC. Lambda connects
--     to these subnets to fetch data from your self-managed Apache Kafka
--     cluster.
--
-- -   @VPC_SECURITY_GROUP@ - The VPC security group used to manage access
--     to your self-managed Apache Kafka brokers.
--
-- -   @SASL_SCRAM_256_AUTH@ - 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@ - The Secrets Manager ARN of your secret key
--     used for SASL SCRAM-512 authentication of your self-managed Apache
--     Kafka brokers.
--
-- -   @VIRTUAL_HOST@ - (Amazon MQ) The name of the virtual host in your
--     RabbitMQ broker. Lambda uses this RabbitMQ host as the event source.
sourceAccessConfiguration_type :: Lens.Lens' SourceAccessConfiguration (Prelude.Maybe SourceAccessType)
sourceAccessConfiguration_type :: (Maybe SourceAccessType -> f (Maybe SourceAccessType))
-> SourceAccessConfiguration -> f SourceAccessConfiguration
sourceAccessConfiguration_type = (SourceAccessConfiguration -> Maybe SourceAccessType)
-> (SourceAccessConfiguration
    -> Maybe SourceAccessType -> SourceAccessConfiguration)
-> Lens
     SourceAccessConfiguration
     SourceAccessConfiguration
     (Maybe SourceAccessType)
     (Maybe SourceAccessType)
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)

instance Core.FromJSON SourceAccessConfiguration where
  parseJSON :: Value -> Parser SourceAccessConfiguration
parseJSON =
    String
-> (Object -> Parser SourceAccessConfiguration)
-> Value
-> Parser SourceAccessConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SourceAccessConfiguration"
      ( \Object
x ->
          Maybe Text -> Maybe SourceAccessType -> SourceAccessConfiguration
SourceAccessConfiguration'
            (Maybe Text -> Maybe SourceAccessType -> SourceAccessConfiguration)
-> Parser (Maybe Text)
-> Parser (Maybe SourceAccessType -> SourceAccessConfiguration)
forall (f :: * -> *) a b. Functor 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
"URI") Parser (Maybe SourceAccessType -> SourceAccessConfiguration)
-> Parser (Maybe SourceAccessType)
-> Parser SourceAccessConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SourceAccessType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
      )

instance Prelude.Hashable SourceAccessConfiguration

instance Prelude.NFData SourceAccessConfiguration

instance Core.ToJSON SourceAccessConfiguration where
  toJSON :: SourceAccessConfiguration -> Value
toJSON SourceAccessConfiguration' {Maybe Text
Maybe SourceAccessType
type' :: Maybe SourceAccessType
uri :: Maybe Text
$sel:type':SourceAccessConfiguration' :: SourceAccessConfiguration -> Maybe SourceAccessType
$sel:uri:SourceAccessConfiguration' :: SourceAccessConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"URI" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
uri,
            (Text
"Type" Text -> SourceAccessType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SourceAccessType -> Pair) -> Maybe SourceAccessType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SourceAccessType
type'
          ]
      )