{-# 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.SecurityHub.Types.AwsLambdaFunctionVpcConfig
-- 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.SecurityHub.Types.AwsLambdaFunctionVpcConfig where

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

-- | The VPC security groups and subnets that are attached to a Lambda
-- function.
--
-- /See:/ 'newAwsLambdaFunctionVpcConfig' smart constructor.
data AwsLambdaFunctionVpcConfig = AwsLambdaFunctionVpcConfig'
  { -- | A list of VPC security groups IDs.
    AwsLambdaFunctionVpcConfig -> Maybe [Text]
securityGroupIds :: Prelude.Maybe [Prelude.Text],
    -- | A list of VPC subnet IDs.
    AwsLambdaFunctionVpcConfig -> Maybe [Text]
subnetIds :: Prelude.Maybe [Prelude.Text],
    -- | The ID of the VPC.
    AwsLambdaFunctionVpcConfig -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsLambdaFunctionVpcConfig -> AwsLambdaFunctionVpcConfig -> Bool
(AwsLambdaFunctionVpcConfig -> AwsLambdaFunctionVpcConfig -> Bool)
-> (AwsLambdaFunctionVpcConfig
    -> AwsLambdaFunctionVpcConfig -> Bool)
-> Eq AwsLambdaFunctionVpcConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsLambdaFunctionVpcConfig -> AwsLambdaFunctionVpcConfig -> Bool
$c/= :: AwsLambdaFunctionVpcConfig -> AwsLambdaFunctionVpcConfig -> Bool
== :: AwsLambdaFunctionVpcConfig -> AwsLambdaFunctionVpcConfig -> Bool
$c== :: AwsLambdaFunctionVpcConfig -> AwsLambdaFunctionVpcConfig -> Bool
Prelude.Eq, ReadPrec [AwsLambdaFunctionVpcConfig]
ReadPrec AwsLambdaFunctionVpcConfig
Int -> ReadS AwsLambdaFunctionVpcConfig
ReadS [AwsLambdaFunctionVpcConfig]
(Int -> ReadS AwsLambdaFunctionVpcConfig)
-> ReadS [AwsLambdaFunctionVpcConfig]
-> ReadPrec AwsLambdaFunctionVpcConfig
-> ReadPrec [AwsLambdaFunctionVpcConfig]
-> Read AwsLambdaFunctionVpcConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsLambdaFunctionVpcConfig]
$creadListPrec :: ReadPrec [AwsLambdaFunctionVpcConfig]
readPrec :: ReadPrec AwsLambdaFunctionVpcConfig
$creadPrec :: ReadPrec AwsLambdaFunctionVpcConfig
readList :: ReadS [AwsLambdaFunctionVpcConfig]
$creadList :: ReadS [AwsLambdaFunctionVpcConfig]
readsPrec :: Int -> ReadS AwsLambdaFunctionVpcConfig
$creadsPrec :: Int -> ReadS AwsLambdaFunctionVpcConfig
Prelude.Read, Int -> AwsLambdaFunctionVpcConfig -> ShowS
[AwsLambdaFunctionVpcConfig] -> ShowS
AwsLambdaFunctionVpcConfig -> String
(Int -> AwsLambdaFunctionVpcConfig -> ShowS)
-> (AwsLambdaFunctionVpcConfig -> String)
-> ([AwsLambdaFunctionVpcConfig] -> ShowS)
-> Show AwsLambdaFunctionVpcConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsLambdaFunctionVpcConfig] -> ShowS
$cshowList :: [AwsLambdaFunctionVpcConfig] -> ShowS
show :: AwsLambdaFunctionVpcConfig -> String
$cshow :: AwsLambdaFunctionVpcConfig -> String
showsPrec :: Int -> AwsLambdaFunctionVpcConfig -> ShowS
$cshowsPrec :: Int -> AwsLambdaFunctionVpcConfig -> ShowS
Prelude.Show, (forall x.
 AwsLambdaFunctionVpcConfig -> Rep AwsLambdaFunctionVpcConfig x)
-> (forall x.
    Rep AwsLambdaFunctionVpcConfig x -> AwsLambdaFunctionVpcConfig)
-> Generic AwsLambdaFunctionVpcConfig
forall x.
Rep AwsLambdaFunctionVpcConfig x -> AwsLambdaFunctionVpcConfig
forall x.
AwsLambdaFunctionVpcConfig -> Rep AwsLambdaFunctionVpcConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsLambdaFunctionVpcConfig x -> AwsLambdaFunctionVpcConfig
$cfrom :: forall x.
AwsLambdaFunctionVpcConfig -> Rep AwsLambdaFunctionVpcConfig x
Prelude.Generic)

-- |
-- Create a value of 'AwsLambdaFunctionVpcConfig' 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', 'awsLambdaFunctionVpcConfig_securityGroupIds' - A list of VPC security groups IDs.
--
-- 'subnetIds', 'awsLambdaFunctionVpcConfig_subnetIds' - A list of VPC subnet IDs.
--
-- 'vpcId', 'awsLambdaFunctionVpcConfig_vpcId' - The ID of the VPC.
newAwsLambdaFunctionVpcConfig ::
  AwsLambdaFunctionVpcConfig
newAwsLambdaFunctionVpcConfig :: AwsLambdaFunctionVpcConfig
newAwsLambdaFunctionVpcConfig =
  AwsLambdaFunctionVpcConfig' :: Maybe [Text]
-> Maybe [Text] -> Maybe Text -> AwsLambdaFunctionVpcConfig
AwsLambdaFunctionVpcConfig'
    { $sel:securityGroupIds:AwsLambdaFunctionVpcConfig' :: Maybe [Text]
securityGroupIds =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:subnetIds:AwsLambdaFunctionVpcConfig' :: Maybe [Text]
subnetIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:AwsLambdaFunctionVpcConfig' :: Maybe Text
vpcId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of VPC security groups IDs.
awsLambdaFunctionVpcConfig_securityGroupIds :: Lens.Lens' AwsLambdaFunctionVpcConfig (Prelude.Maybe [Prelude.Text])
awsLambdaFunctionVpcConfig_securityGroupIds :: (Maybe [Text] -> f (Maybe [Text]))
-> AwsLambdaFunctionVpcConfig -> f AwsLambdaFunctionVpcConfig
awsLambdaFunctionVpcConfig_securityGroupIds = (AwsLambdaFunctionVpcConfig -> Maybe [Text])
-> (AwsLambdaFunctionVpcConfig
    -> Maybe [Text] -> AwsLambdaFunctionVpcConfig)
-> Lens
     AwsLambdaFunctionVpcConfig
     AwsLambdaFunctionVpcConfig
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsLambdaFunctionVpcConfig' {Maybe [Text]
securityGroupIds :: Maybe [Text]
$sel:securityGroupIds:AwsLambdaFunctionVpcConfig' :: AwsLambdaFunctionVpcConfig -> Maybe [Text]
securityGroupIds} -> Maybe [Text]
securityGroupIds) (\s :: AwsLambdaFunctionVpcConfig
s@AwsLambdaFunctionVpcConfig' {} Maybe [Text]
a -> AwsLambdaFunctionVpcConfig
s {$sel:securityGroupIds:AwsLambdaFunctionVpcConfig' :: Maybe [Text]
securityGroupIds = Maybe [Text]
a} :: AwsLambdaFunctionVpcConfig) ((Maybe [Text] -> f (Maybe [Text]))
 -> AwsLambdaFunctionVpcConfig -> f AwsLambdaFunctionVpcConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AwsLambdaFunctionVpcConfig
-> f AwsLambdaFunctionVpcConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of VPC subnet IDs.
awsLambdaFunctionVpcConfig_subnetIds :: Lens.Lens' AwsLambdaFunctionVpcConfig (Prelude.Maybe [Prelude.Text])
awsLambdaFunctionVpcConfig_subnetIds :: (Maybe [Text] -> f (Maybe [Text]))
-> AwsLambdaFunctionVpcConfig -> f AwsLambdaFunctionVpcConfig
awsLambdaFunctionVpcConfig_subnetIds = (AwsLambdaFunctionVpcConfig -> Maybe [Text])
-> (AwsLambdaFunctionVpcConfig
    -> Maybe [Text] -> AwsLambdaFunctionVpcConfig)
-> Lens
     AwsLambdaFunctionVpcConfig
     AwsLambdaFunctionVpcConfig
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsLambdaFunctionVpcConfig' {Maybe [Text]
subnetIds :: Maybe [Text]
$sel:subnetIds:AwsLambdaFunctionVpcConfig' :: AwsLambdaFunctionVpcConfig -> Maybe [Text]
subnetIds} -> Maybe [Text]
subnetIds) (\s :: AwsLambdaFunctionVpcConfig
s@AwsLambdaFunctionVpcConfig' {} Maybe [Text]
a -> AwsLambdaFunctionVpcConfig
s {$sel:subnetIds:AwsLambdaFunctionVpcConfig' :: Maybe [Text]
subnetIds = Maybe [Text]
a} :: AwsLambdaFunctionVpcConfig) ((Maybe [Text] -> f (Maybe [Text]))
 -> AwsLambdaFunctionVpcConfig -> f AwsLambdaFunctionVpcConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AwsLambdaFunctionVpcConfig
-> f AwsLambdaFunctionVpcConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Core.FromJSON AwsLambdaFunctionVpcConfig where
  parseJSON :: Value -> Parser AwsLambdaFunctionVpcConfig
parseJSON =
    String
-> (Object -> Parser AwsLambdaFunctionVpcConfig)
-> Value
-> Parser AwsLambdaFunctionVpcConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsLambdaFunctionVpcConfig"
      ( \Object
x ->
          Maybe [Text]
-> Maybe [Text] -> Maybe Text -> AwsLambdaFunctionVpcConfig
AwsLambdaFunctionVpcConfig'
            (Maybe [Text]
 -> Maybe [Text] -> Maybe Text -> AwsLambdaFunctionVpcConfig)
-> Parser (Maybe [Text])
-> Parser
     (Maybe [Text] -> Maybe Text -> AwsLambdaFunctionVpcConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SecurityGroupIds"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe [Text] -> Maybe Text -> AwsLambdaFunctionVpcConfig)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> AwsLambdaFunctionVpcConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SubnetIds" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> AwsLambdaFunctionVpcConfig)
-> Parser (Maybe Text) -> Parser AwsLambdaFunctionVpcConfig
forall (f :: * -> *) a b. Applicative f => 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
"VpcId")
      )

instance Prelude.Hashable AwsLambdaFunctionVpcConfig

instance Prelude.NFData AwsLambdaFunctionVpcConfig

instance Core.ToJSON AwsLambdaFunctionVpcConfig where
  toJSON :: AwsLambdaFunctionVpcConfig -> Value
toJSON AwsLambdaFunctionVpcConfig' {Maybe [Text]
Maybe Text
vpcId :: Maybe Text
subnetIds :: Maybe [Text]
securityGroupIds :: Maybe [Text]
$sel:vpcId:AwsLambdaFunctionVpcConfig' :: AwsLambdaFunctionVpcConfig -> Maybe Text
$sel:subnetIds:AwsLambdaFunctionVpcConfig' :: AwsLambdaFunctionVpcConfig -> Maybe [Text]
$sel:securityGroupIds:AwsLambdaFunctionVpcConfig' :: AwsLambdaFunctionVpcConfig -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SecurityGroupIds" 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]
securityGroupIds,
            (Text
"SubnetIds" 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]
subnetIds,
            (Text
"VpcId" 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
vpcId
          ]
      )