{-# 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.CodeBuild.Types.VpcConfig
-- 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.CodeBuild.Types.VpcConfig 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:/ 'newVpcConfig' smart constructor.
data VpcConfig = VpcConfig'
  { -- | A list of one or more security groups IDs in your Amazon VPC.
    VpcConfig -> Maybe [Text]
securityGroupIds :: Prelude.Maybe [Prelude.Text],
    -- | The ID of the Amazon VPC.
    VpcConfig -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text,
    -- | A list of one or more subnet IDs in your Amazon VPC.
    VpcConfig -> Maybe [Text]
subnets :: Prelude.Maybe [Prelude.Text]
  }
  deriving (VpcConfig -> VpcConfig -> Bool
(VpcConfig -> VpcConfig -> Bool)
-> (VpcConfig -> VpcConfig -> Bool) -> Eq VpcConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VpcConfig -> VpcConfig -> Bool
$c/= :: VpcConfig -> VpcConfig -> Bool
== :: VpcConfig -> VpcConfig -> Bool
$c== :: VpcConfig -> VpcConfig -> Bool
Prelude.Eq, ReadPrec [VpcConfig]
ReadPrec VpcConfig
Int -> ReadS VpcConfig
ReadS [VpcConfig]
(Int -> ReadS VpcConfig)
-> ReadS [VpcConfig]
-> ReadPrec VpcConfig
-> ReadPrec [VpcConfig]
-> Read VpcConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VpcConfig]
$creadListPrec :: ReadPrec [VpcConfig]
readPrec :: ReadPrec VpcConfig
$creadPrec :: ReadPrec VpcConfig
readList :: ReadS [VpcConfig]
$creadList :: ReadS [VpcConfig]
readsPrec :: Int -> ReadS VpcConfig
$creadsPrec :: Int -> ReadS VpcConfig
Prelude.Read, Int -> VpcConfig -> ShowS
[VpcConfig] -> ShowS
VpcConfig -> String
(Int -> VpcConfig -> ShowS)
-> (VpcConfig -> String)
-> ([VpcConfig] -> ShowS)
-> Show VpcConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VpcConfig] -> ShowS
$cshowList :: [VpcConfig] -> ShowS
show :: VpcConfig -> String
$cshow :: VpcConfig -> String
showsPrec :: Int -> VpcConfig -> ShowS
$cshowsPrec :: Int -> VpcConfig -> ShowS
Prelude.Show, (forall x. VpcConfig -> Rep VpcConfig x)
-> (forall x. Rep VpcConfig x -> VpcConfig) -> Generic VpcConfig
forall x. Rep VpcConfig x -> VpcConfig
forall x. VpcConfig -> Rep VpcConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VpcConfig x -> VpcConfig
$cfrom :: forall x. VpcConfig -> Rep VpcConfig x
Prelude.Generic)

-- |
-- Create a value of 'VpcConfig' 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', 'vpcConfig_securityGroupIds' - A list of one or more security groups IDs in your Amazon VPC.
--
-- 'vpcId', 'vpcConfig_vpcId' - The ID of the Amazon VPC.
--
-- 'subnets', 'vpcConfig_subnets' - A list of one or more subnet IDs in your Amazon VPC.
newVpcConfig ::
  VpcConfig
newVpcConfig :: VpcConfig
newVpcConfig =
  VpcConfig' :: Maybe [Text] -> Maybe Text -> Maybe [Text] -> VpcConfig
VpcConfig'
    { $sel:securityGroupIds:VpcConfig' :: Maybe [Text]
securityGroupIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:VpcConfig' :: Maybe Text
vpcId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subnets:VpcConfig' :: Maybe [Text]
subnets = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

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

-- | A list of one or more subnet IDs in your Amazon VPC.
vpcConfig_subnets :: Lens.Lens' VpcConfig (Prelude.Maybe [Prelude.Text])
vpcConfig_subnets :: (Maybe [Text] -> f (Maybe [Text])) -> VpcConfig -> f VpcConfig
vpcConfig_subnets = (VpcConfig -> Maybe [Text])
-> (VpcConfig -> Maybe [Text] -> VpcConfig)
-> Lens VpcConfig VpcConfig (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VpcConfig' {Maybe [Text]
subnets :: Maybe [Text]
$sel:subnets:VpcConfig' :: VpcConfig -> Maybe [Text]
subnets} -> Maybe [Text]
subnets) (\s :: VpcConfig
s@VpcConfig' {} Maybe [Text]
a -> VpcConfig
s {$sel:subnets:VpcConfig' :: Maybe [Text]
subnets = Maybe [Text]
a} :: VpcConfig) ((Maybe [Text] -> f (Maybe [Text])) -> VpcConfig -> f VpcConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> VpcConfig
-> f VpcConfig
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 VpcConfig where
  parseJSON :: Value -> Parser VpcConfig
parseJSON =
    String -> (Object -> Parser VpcConfig) -> Value -> Parser VpcConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VpcConfig"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> Maybe [Text] -> VpcConfig
VpcConfig'
            (Maybe [Text] -> Maybe Text -> Maybe [Text] -> VpcConfig)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> Maybe [Text] -> VpcConfig)
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] -> VpcConfig)
-> Parser (Maybe Text) -> Parser (Maybe [Text] -> VpcConfig)
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] -> VpcConfig)
-> Parser (Maybe [Text]) -> Parser VpcConfig
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 VpcConfig

instance Prelude.NFData VpcConfig

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