{-# 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.RobOMaker.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.RobOMaker.Types.VPCConfig where

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

-- | If your simulation job accesses resources in a VPC, you provide this
-- parameter identifying the list of security group IDs and subnet IDs.
-- These must belong to the same VPC. You must provide at least one
-- security group and two subnet IDs.
--
-- /See:/ 'newVPCConfig' smart constructor.
data VPCConfig = VPCConfig'
  { -- | A list of one or more security groups IDs in your VPC.
    VPCConfig -> Maybe (NonEmpty Text)
securityGroups :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | A boolean indicating whether to assign a public IP address.
    VPCConfig -> Maybe Bool
assignPublicIp :: Prelude.Maybe Prelude.Bool,
    -- | A list of one or more subnet IDs in your VPC.
    VPCConfig -> NonEmpty Text
subnets :: Prelude.NonEmpty 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:
--
-- 'securityGroups', 'vPCConfig_securityGroups' - A list of one or more security groups IDs in your VPC.
--
-- 'assignPublicIp', 'vPCConfig_assignPublicIp' - A boolean indicating whether to assign a public IP address.
--
-- 'subnets', 'vPCConfig_subnets' - A list of one or more subnet IDs in your VPC.
newVPCConfig ::
  -- | 'subnets'
  Prelude.NonEmpty Prelude.Text ->
  VPCConfig
newVPCConfig :: NonEmpty Text -> VPCConfig
newVPCConfig NonEmpty Text
pSubnets_ =
  VPCConfig' :: Maybe (NonEmpty Text) -> Maybe Bool -> NonEmpty Text -> VPCConfig
VPCConfig'
    { $sel:securityGroups:VPCConfig' :: Maybe (NonEmpty Text)
securityGroups = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:assignPublicIp:VPCConfig' :: Maybe Bool
assignPublicIp = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:subnets:VPCConfig' :: NonEmpty Text
subnets = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pSubnets_
    }

-- | A list of one or more security groups IDs in your VPC.
vPCConfig_securityGroups :: Lens.Lens' VPCConfig (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
vPCConfig_securityGroups :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> VPCConfig -> f VPCConfig
vPCConfig_securityGroups = (VPCConfig -> Maybe (NonEmpty Text))
-> (VPCConfig -> Maybe (NonEmpty Text) -> VPCConfig)
-> Lens
     VPCConfig VPCConfig (Maybe (NonEmpty Text)) (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VPCConfig' {Maybe (NonEmpty Text)
securityGroups :: Maybe (NonEmpty Text)
$sel:securityGroups:VPCConfig' :: VPCConfig -> Maybe (NonEmpty Text)
securityGroups} -> Maybe (NonEmpty Text)
securityGroups) (\s :: VPCConfig
s@VPCConfig' {} Maybe (NonEmpty Text)
a -> VPCConfig
s {$sel:securityGroups:VPCConfig' :: Maybe (NonEmpty Text)
securityGroups = Maybe (NonEmpty Text)
a} :: VPCConfig) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> VPCConfig -> f VPCConfig)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> VPCConfig
-> f VPCConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty 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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A boolean indicating whether to assign a public IP address.
vPCConfig_assignPublicIp :: Lens.Lens' VPCConfig (Prelude.Maybe Prelude.Bool)
vPCConfig_assignPublicIp :: (Maybe Bool -> f (Maybe Bool)) -> VPCConfig -> f VPCConfig
vPCConfig_assignPublicIp = (VPCConfig -> Maybe Bool)
-> (VPCConfig -> Maybe Bool -> VPCConfig)
-> Lens VPCConfig VPCConfig (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VPCConfig' {Maybe Bool
assignPublicIp :: Maybe Bool
$sel:assignPublicIp:VPCConfig' :: VPCConfig -> Maybe Bool
assignPublicIp} -> Maybe Bool
assignPublicIp) (\s :: VPCConfig
s@VPCConfig' {} Maybe Bool
a -> VPCConfig
s {$sel:assignPublicIp:VPCConfig' :: Maybe Bool
assignPublicIp = Maybe Bool
a} :: VPCConfig)

-- | A list of one or more subnet IDs in your VPC.
vPCConfig_subnets :: Lens.Lens' VPCConfig (Prelude.NonEmpty Prelude.Text)
vPCConfig_subnets :: (NonEmpty Text -> f (NonEmpty Text)) -> VPCConfig -> f VPCConfig
vPCConfig_subnets = (VPCConfig -> NonEmpty Text)
-> (VPCConfig -> NonEmpty Text -> VPCConfig)
-> Lens VPCConfig VPCConfig (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VPCConfig' {NonEmpty Text
subnets :: NonEmpty Text
$sel:subnets:VPCConfig' :: VPCConfig -> NonEmpty Text
subnets} -> NonEmpty Text
subnets) (\s :: VPCConfig
s@VPCConfig' {} NonEmpty Text
a -> VPCConfig
s {$sel:subnets:VPCConfig' :: NonEmpty Text
subnets = NonEmpty Text
a} :: VPCConfig) ((NonEmpty Text -> f (NonEmpty Text)) -> VPCConfig -> f VPCConfig)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> VPCConfig
-> f VPCConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty 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 (NonEmpty Text) -> Maybe Bool -> NonEmpty Text -> VPCConfig
VPCConfig'
            (Maybe (NonEmpty Text) -> Maybe Bool -> NonEmpty Text -> VPCConfig)
-> Parser (Maybe (NonEmpty Text))
-> Parser (Maybe Bool -> NonEmpty Text -> VPCConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"securityGroups")
            Parser (Maybe Bool -> NonEmpty Text -> VPCConfig)
-> Parser (Maybe Bool) -> Parser (NonEmpty Text -> VPCConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"assignPublicIp")
            Parser (NonEmpty Text -> VPCConfig)
-> Parser (NonEmpty Text) -> Parser VPCConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"subnets")
      )

instance Prelude.Hashable VPCConfig

instance Prelude.NFData VPCConfig

instance Core.ToJSON VPCConfig where
  toJSON :: VPCConfig -> Value
toJSON VPCConfig' {Maybe Bool
Maybe (NonEmpty Text)
NonEmpty Text
subnets :: NonEmpty Text
assignPublicIp :: Maybe Bool
securityGroups :: Maybe (NonEmpty Text)
$sel:subnets:VPCConfig' :: VPCConfig -> NonEmpty Text
$sel:assignPublicIp:VPCConfig' :: VPCConfig -> Maybe Bool
$sel:securityGroups:VPCConfig' :: VPCConfig -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"securityGroups" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
securityGroups,
            (Text
"assignPublicIp" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
assignPublicIp,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"subnets" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
subnets)
          ]
      )