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

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

-- | Information about the VPC configuration that CodeBuild accesses.
--
-- /See:/ 'newAwsCodeBuildProjectVpcConfig' smart constructor.
data AwsCodeBuildProjectVpcConfig = AwsCodeBuildProjectVpcConfig'
  { -- | A list of one or more security group IDs in your VPC.
    AwsCodeBuildProjectVpcConfig -> Maybe [Text]
securityGroupIds :: Prelude.Maybe [Prelude.Text],
    -- | The ID of the VPC.
    AwsCodeBuildProjectVpcConfig -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text,
    -- | A list of one or more subnet IDs in your VPC.
    AwsCodeBuildProjectVpcConfig -> Maybe [Text]
subnets :: Prelude.Maybe [Prelude.Text]
  }
  deriving (AwsCodeBuildProjectVpcConfig
-> AwsCodeBuildProjectVpcConfig -> Bool
(AwsCodeBuildProjectVpcConfig
 -> AwsCodeBuildProjectVpcConfig -> Bool)
-> (AwsCodeBuildProjectVpcConfig
    -> AwsCodeBuildProjectVpcConfig -> Bool)
-> Eq AwsCodeBuildProjectVpcConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsCodeBuildProjectVpcConfig
-> AwsCodeBuildProjectVpcConfig -> Bool
$c/= :: AwsCodeBuildProjectVpcConfig
-> AwsCodeBuildProjectVpcConfig -> Bool
== :: AwsCodeBuildProjectVpcConfig
-> AwsCodeBuildProjectVpcConfig -> Bool
$c== :: AwsCodeBuildProjectVpcConfig
-> AwsCodeBuildProjectVpcConfig -> Bool
Prelude.Eq, ReadPrec [AwsCodeBuildProjectVpcConfig]
ReadPrec AwsCodeBuildProjectVpcConfig
Int -> ReadS AwsCodeBuildProjectVpcConfig
ReadS [AwsCodeBuildProjectVpcConfig]
(Int -> ReadS AwsCodeBuildProjectVpcConfig)
-> ReadS [AwsCodeBuildProjectVpcConfig]
-> ReadPrec AwsCodeBuildProjectVpcConfig
-> ReadPrec [AwsCodeBuildProjectVpcConfig]
-> Read AwsCodeBuildProjectVpcConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsCodeBuildProjectVpcConfig]
$creadListPrec :: ReadPrec [AwsCodeBuildProjectVpcConfig]
readPrec :: ReadPrec AwsCodeBuildProjectVpcConfig
$creadPrec :: ReadPrec AwsCodeBuildProjectVpcConfig
readList :: ReadS [AwsCodeBuildProjectVpcConfig]
$creadList :: ReadS [AwsCodeBuildProjectVpcConfig]
readsPrec :: Int -> ReadS AwsCodeBuildProjectVpcConfig
$creadsPrec :: Int -> ReadS AwsCodeBuildProjectVpcConfig
Prelude.Read, Int -> AwsCodeBuildProjectVpcConfig -> ShowS
[AwsCodeBuildProjectVpcConfig] -> ShowS
AwsCodeBuildProjectVpcConfig -> String
(Int -> AwsCodeBuildProjectVpcConfig -> ShowS)
-> (AwsCodeBuildProjectVpcConfig -> String)
-> ([AwsCodeBuildProjectVpcConfig] -> ShowS)
-> Show AwsCodeBuildProjectVpcConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsCodeBuildProjectVpcConfig] -> ShowS
$cshowList :: [AwsCodeBuildProjectVpcConfig] -> ShowS
show :: AwsCodeBuildProjectVpcConfig -> String
$cshow :: AwsCodeBuildProjectVpcConfig -> String
showsPrec :: Int -> AwsCodeBuildProjectVpcConfig -> ShowS
$cshowsPrec :: Int -> AwsCodeBuildProjectVpcConfig -> ShowS
Prelude.Show, (forall x.
 AwsCodeBuildProjectVpcConfig -> Rep AwsCodeBuildProjectVpcConfig x)
-> (forall x.
    Rep AwsCodeBuildProjectVpcConfig x -> AwsCodeBuildProjectVpcConfig)
-> Generic AwsCodeBuildProjectVpcConfig
forall x.
Rep AwsCodeBuildProjectVpcConfig x -> AwsCodeBuildProjectVpcConfig
forall x.
AwsCodeBuildProjectVpcConfig -> Rep AwsCodeBuildProjectVpcConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsCodeBuildProjectVpcConfig x -> AwsCodeBuildProjectVpcConfig
$cfrom :: forall x.
AwsCodeBuildProjectVpcConfig -> Rep AwsCodeBuildProjectVpcConfig x
Prelude.Generic)

-- |
-- Create a value of 'AwsCodeBuildProjectVpcConfig' 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', 'awsCodeBuildProjectVpcConfig_securityGroupIds' - A list of one or more security group IDs in your VPC.
--
-- 'vpcId', 'awsCodeBuildProjectVpcConfig_vpcId' - The ID of the VPC.
--
-- 'subnets', 'awsCodeBuildProjectVpcConfig_subnets' - A list of one or more subnet IDs in your VPC.
newAwsCodeBuildProjectVpcConfig ::
  AwsCodeBuildProjectVpcConfig
newAwsCodeBuildProjectVpcConfig :: AwsCodeBuildProjectVpcConfig
newAwsCodeBuildProjectVpcConfig =
  AwsCodeBuildProjectVpcConfig' :: Maybe [Text]
-> Maybe Text -> Maybe [Text] -> AwsCodeBuildProjectVpcConfig
AwsCodeBuildProjectVpcConfig'
    { $sel:securityGroupIds:AwsCodeBuildProjectVpcConfig' :: Maybe [Text]
securityGroupIds =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:AwsCodeBuildProjectVpcConfig' :: Maybe Text
vpcId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subnets:AwsCodeBuildProjectVpcConfig' :: Maybe [Text]
subnets = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of one or more security group IDs in your VPC.
awsCodeBuildProjectVpcConfig_securityGroupIds :: Lens.Lens' AwsCodeBuildProjectVpcConfig (Prelude.Maybe [Prelude.Text])
awsCodeBuildProjectVpcConfig_securityGroupIds :: (Maybe [Text] -> f (Maybe [Text]))
-> AwsCodeBuildProjectVpcConfig -> f AwsCodeBuildProjectVpcConfig
awsCodeBuildProjectVpcConfig_securityGroupIds = (AwsCodeBuildProjectVpcConfig -> Maybe [Text])
-> (AwsCodeBuildProjectVpcConfig
    -> Maybe [Text] -> AwsCodeBuildProjectVpcConfig)
-> Lens
     AwsCodeBuildProjectVpcConfig
     AwsCodeBuildProjectVpcConfig
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCodeBuildProjectVpcConfig' {Maybe [Text]
securityGroupIds :: Maybe [Text]
$sel:securityGroupIds:AwsCodeBuildProjectVpcConfig' :: AwsCodeBuildProjectVpcConfig -> Maybe [Text]
securityGroupIds} -> Maybe [Text]
securityGroupIds) (\s :: AwsCodeBuildProjectVpcConfig
s@AwsCodeBuildProjectVpcConfig' {} Maybe [Text]
a -> AwsCodeBuildProjectVpcConfig
s {$sel:securityGroupIds:AwsCodeBuildProjectVpcConfig' :: Maybe [Text]
securityGroupIds = Maybe [Text]
a} :: AwsCodeBuildProjectVpcConfig) ((Maybe [Text] -> f (Maybe [Text]))
 -> AwsCodeBuildProjectVpcConfig -> f AwsCodeBuildProjectVpcConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AwsCodeBuildProjectVpcConfig
-> f AwsCodeBuildProjectVpcConfig
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.
awsCodeBuildProjectVpcConfig_vpcId :: Lens.Lens' AwsCodeBuildProjectVpcConfig (Prelude.Maybe Prelude.Text)
awsCodeBuildProjectVpcConfig_vpcId :: (Maybe Text -> f (Maybe Text))
-> AwsCodeBuildProjectVpcConfig -> f AwsCodeBuildProjectVpcConfig
awsCodeBuildProjectVpcConfig_vpcId = (AwsCodeBuildProjectVpcConfig -> Maybe Text)
-> (AwsCodeBuildProjectVpcConfig
    -> Maybe Text -> AwsCodeBuildProjectVpcConfig)
-> Lens
     AwsCodeBuildProjectVpcConfig
     AwsCodeBuildProjectVpcConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCodeBuildProjectVpcConfig' {Maybe Text
vpcId :: Maybe Text
$sel:vpcId:AwsCodeBuildProjectVpcConfig' :: AwsCodeBuildProjectVpcConfig -> Maybe Text
vpcId} -> Maybe Text
vpcId) (\s :: AwsCodeBuildProjectVpcConfig
s@AwsCodeBuildProjectVpcConfig' {} Maybe Text
a -> AwsCodeBuildProjectVpcConfig
s {$sel:vpcId:AwsCodeBuildProjectVpcConfig' :: Maybe Text
vpcId = Maybe Text
a} :: AwsCodeBuildProjectVpcConfig)

-- | A list of one or more subnet IDs in your VPC.
awsCodeBuildProjectVpcConfig_subnets :: Lens.Lens' AwsCodeBuildProjectVpcConfig (Prelude.Maybe [Prelude.Text])
awsCodeBuildProjectVpcConfig_subnets :: (Maybe [Text] -> f (Maybe [Text]))
-> AwsCodeBuildProjectVpcConfig -> f AwsCodeBuildProjectVpcConfig
awsCodeBuildProjectVpcConfig_subnets = (AwsCodeBuildProjectVpcConfig -> Maybe [Text])
-> (AwsCodeBuildProjectVpcConfig
    -> Maybe [Text] -> AwsCodeBuildProjectVpcConfig)
-> Lens
     AwsCodeBuildProjectVpcConfig
     AwsCodeBuildProjectVpcConfig
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCodeBuildProjectVpcConfig' {Maybe [Text]
subnets :: Maybe [Text]
$sel:subnets:AwsCodeBuildProjectVpcConfig' :: AwsCodeBuildProjectVpcConfig -> Maybe [Text]
subnets} -> Maybe [Text]
subnets) (\s :: AwsCodeBuildProjectVpcConfig
s@AwsCodeBuildProjectVpcConfig' {} Maybe [Text]
a -> AwsCodeBuildProjectVpcConfig
s {$sel:subnets:AwsCodeBuildProjectVpcConfig' :: Maybe [Text]
subnets = Maybe [Text]
a} :: AwsCodeBuildProjectVpcConfig) ((Maybe [Text] -> f (Maybe [Text]))
 -> AwsCodeBuildProjectVpcConfig -> f AwsCodeBuildProjectVpcConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AwsCodeBuildProjectVpcConfig
-> f AwsCodeBuildProjectVpcConfig
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

instance Core.FromJSON AwsCodeBuildProjectVpcConfig where
  parseJSON :: Value -> Parser AwsCodeBuildProjectVpcConfig
parseJSON =
    String
-> (Object -> Parser AwsCodeBuildProjectVpcConfig)
-> Value
-> Parser AwsCodeBuildProjectVpcConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsCodeBuildProjectVpcConfig"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Text -> Maybe [Text] -> AwsCodeBuildProjectVpcConfig
AwsCodeBuildProjectVpcConfig'
            (Maybe [Text]
 -> Maybe Text -> Maybe [Text] -> AwsCodeBuildProjectVpcConfig)
-> Parser (Maybe [Text])
-> Parser
     (Maybe Text -> Maybe [Text] -> AwsCodeBuildProjectVpcConfig)
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] -> AwsCodeBuildProjectVpcConfig)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> AwsCodeBuildProjectVpcConfig)
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")
            Parser (Maybe [Text] -> AwsCodeBuildProjectVpcConfig)
-> Parser (Maybe [Text]) -> Parser AwsCodeBuildProjectVpcConfig
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
"Subnets" 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)
      )

instance
  Prelude.Hashable
    AwsCodeBuildProjectVpcConfig

instance Prelude.NFData AwsCodeBuildProjectVpcConfig

instance Core.ToJSON AwsCodeBuildProjectVpcConfig where
  toJSON :: AwsCodeBuildProjectVpcConfig -> Value
toJSON AwsCodeBuildProjectVpcConfig' {Maybe [Text]
Maybe Text
subnets :: Maybe [Text]
vpcId :: Maybe Text
securityGroupIds :: Maybe [Text]
$sel:subnets:AwsCodeBuildProjectVpcConfig' :: AwsCodeBuildProjectVpcConfig -> Maybe [Text]
$sel:vpcId:AwsCodeBuildProjectVpcConfig' :: AwsCodeBuildProjectVpcConfig -> Maybe Text
$sel:securityGroupIds:AwsCodeBuildProjectVpcConfig' :: AwsCodeBuildProjectVpcConfig -> 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
"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,
            (Text
"Subnets" 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]
subnets
          ]
      )