{-# 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.Inspector2.Types.LambdaVpcConfig
-- 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.Inspector2.Types.LambdaVpcConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The VPC security groups and subnets that are attached to an AWS Lambda
-- function. For more information, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html VPC Settings>.
--
-- /See:/ 'newLambdaVpcConfig' smart constructor.
data LambdaVpcConfig = LambdaVpcConfig'
  { -- | The VPC security groups and subnets that are attached to an AWS Lambda
    -- function. For more information, see
    -- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html VPC Settings>.
    LambdaVpcConfig -> Maybe [Text]
securityGroupIds :: Prelude.Maybe [Prelude.Text],
    -- | A list of VPC subnet IDs.
    LambdaVpcConfig -> Maybe [Text]
subnetIds :: Prelude.Maybe [Prelude.Text],
    -- | The ID of the VPC.
    LambdaVpcConfig -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text
  }
  deriving (LambdaVpcConfig -> LambdaVpcConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LambdaVpcConfig -> LambdaVpcConfig -> Bool
$c/= :: LambdaVpcConfig -> LambdaVpcConfig -> Bool
== :: LambdaVpcConfig -> LambdaVpcConfig -> Bool
$c== :: LambdaVpcConfig -> LambdaVpcConfig -> Bool
Prelude.Eq, ReadPrec [LambdaVpcConfig]
ReadPrec LambdaVpcConfig
Int -> ReadS LambdaVpcConfig
ReadS [LambdaVpcConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LambdaVpcConfig]
$creadListPrec :: ReadPrec [LambdaVpcConfig]
readPrec :: ReadPrec LambdaVpcConfig
$creadPrec :: ReadPrec LambdaVpcConfig
readList :: ReadS [LambdaVpcConfig]
$creadList :: ReadS [LambdaVpcConfig]
readsPrec :: Int -> ReadS LambdaVpcConfig
$creadsPrec :: Int -> ReadS LambdaVpcConfig
Prelude.Read, Int -> LambdaVpcConfig -> ShowS
[LambdaVpcConfig] -> ShowS
LambdaVpcConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LambdaVpcConfig] -> ShowS
$cshowList :: [LambdaVpcConfig] -> ShowS
show :: LambdaVpcConfig -> String
$cshow :: LambdaVpcConfig -> String
showsPrec :: Int -> LambdaVpcConfig -> ShowS
$cshowsPrec :: Int -> LambdaVpcConfig -> ShowS
Prelude.Show, forall x. Rep LambdaVpcConfig x -> LambdaVpcConfig
forall x. LambdaVpcConfig -> Rep LambdaVpcConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LambdaVpcConfig x -> LambdaVpcConfig
$cfrom :: forall x. LambdaVpcConfig -> Rep LambdaVpcConfig x
Prelude.Generic)

-- |
-- Create a value of 'LambdaVpcConfig' 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:
--
-- 'securityGroupIds', 'lambdaVpcConfig_securityGroupIds' - The VPC security groups and subnets that are attached to an AWS Lambda
-- function. For more information, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html VPC Settings>.
--
-- 'subnetIds', 'lambdaVpcConfig_subnetIds' - A list of VPC subnet IDs.
--
-- 'vpcId', 'lambdaVpcConfig_vpcId' - The ID of the VPC.
newLambdaVpcConfig ::
  LambdaVpcConfig
newLambdaVpcConfig :: LambdaVpcConfig
newLambdaVpcConfig =
  LambdaVpcConfig'
    { $sel:securityGroupIds:LambdaVpcConfig' :: Maybe [Text]
securityGroupIds =
        forall a. Maybe a
Prelude.Nothing,
      $sel:subnetIds:LambdaVpcConfig' :: Maybe [Text]
subnetIds = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:LambdaVpcConfig' :: Maybe Text
vpcId = forall a. Maybe a
Prelude.Nothing
    }

-- | The VPC security groups and subnets that are attached to an AWS Lambda
-- function. For more information, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html VPC Settings>.
lambdaVpcConfig_securityGroupIds :: Lens.Lens' LambdaVpcConfig (Prelude.Maybe [Prelude.Text])
lambdaVpcConfig_securityGroupIds :: Lens' LambdaVpcConfig (Maybe [Text])
lambdaVpcConfig_securityGroupIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaVpcConfig' {Maybe [Text]
securityGroupIds :: Maybe [Text]
$sel:securityGroupIds:LambdaVpcConfig' :: LambdaVpcConfig -> Maybe [Text]
securityGroupIds} -> Maybe [Text]
securityGroupIds) (\s :: LambdaVpcConfig
s@LambdaVpcConfig' {} Maybe [Text]
a -> LambdaVpcConfig
s {$sel:securityGroupIds:LambdaVpcConfig' :: Maybe [Text]
securityGroupIds = Maybe [Text]
a} :: LambdaVpcConfig) 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

-- | A list of VPC subnet IDs.
lambdaVpcConfig_subnetIds :: Lens.Lens' LambdaVpcConfig (Prelude.Maybe [Prelude.Text])
lambdaVpcConfig_subnetIds :: Lens' LambdaVpcConfig (Maybe [Text])
lambdaVpcConfig_subnetIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaVpcConfig' {Maybe [Text]
subnetIds :: Maybe [Text]
$sel:subnetIds:LambdaVpcConfig' :: LambdaVpcConfig -> Maybe [Text]
subnetIds} -> Maybe [Text]
subnetIds) (\s :: LambdaVpcConfig
s@LambdaVpcConfig' {} Maybe [Text]
a -> LambdaVpcConfig
s {$sel:subnetIds:LambdaVpcConfig' :: Maybe [Text]
subnetIds = Maybe [Text]
a} :: LambdaVpcConfig) 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

-- | The ID of the VPC.
lambdaVpcConfig_vpcId :: Lens.Lens' LambdaVpcConfig (Prelude.Maybe Prelude.Text)
lambdaVpcConfig_vpcId :: Lens' LambdaVpcConfig (Maybe Text)
lambdaVpcConfig_vpcId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaVpcConfig' {Maybe Text
vpcId :: Maybe Text
$sel:vpcId:LambdaVpcConfig' :: LambdaVpcConfig -> Maybe Text
vpcId} -> Maybe Text
vpcId) (\s :: LambdaVpcConfig
s@LambdaVpcConfig' {} Maybe Text
a -> LambdaVpcConfig
s {$sel:vpcId:LambdaVpcConfig' :: Maybe Text
vpcId = Maybe Text
a} :: LambdaVpcConfig)

instance Data.FromJSON LambdaVpcConfig where
  parseJSON :: Value -> Parser LambdaVpcConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LambdaVpcConfig"
      ( \Object
x ->
          Maybe [Text] -> Maybe [Text] -> Maybe Text -> LambdaVpcConfig
LambdaVpcConfig'
            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
"securityGroupIds"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"subnetIds" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"vpcId")
      )

instance Prelude.Hashable LambdaVpcConfig where
  hashWithSalt :: Int -> LambdaVpcConfig -> Int
hashWithSalt Int
_salt LambdaVpcConfig' {Maybe [Text]
Maybe Text
vpcId :: Maybe Text
subnetIds :: Maybe [Text]
securityGroupIds :: Maybe [Text]
$sel:vpcId:LambdaVpcConfig' :: LambdaVpcConfig -> Maybe Text
$sel:subnetIds:LambdaVpcConfig' :: LambdaVpcConfig -> Maybe [Text]
$sel:securityGroupIds:LambdaVpcConfig' :: LambdaVpcConfig -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
securityGroupIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
subnetIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcId

instance Prelude.NFData LambdaVpcConfig where
  rnf :: LambdaVpcConfig -> ()
rnf LambdaVpcConfig' {Maybe [Text]
Maybe Text
vpcId :: Maybe Text
subnetIds :: Maybe [Text]
securityGroupIds :: Maybe [Text]
$sel:vpcId:LambdaVpcConfig' :: LambdaVpcConfig -> Maybe Text
$sel:subnetIds:LambdaVpcConfig' :: LambdaVpcConfig -> Maybe [Text]
$sel:securityGroupIds:LambdaVpcConfig' :: LambdaVpcConfig -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
securityGroupIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
subnetIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vpcId