{-# 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.EMRServerless.Types.NetworkConfiguration
-- 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.EMRServerless.Types.NetworkConfiguration 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 network configuration for customer VPC connectivity.
--
-- /See:/ 'newNetworkConfiguration' smart constructor.
data NetworkConfiguration = NetworkConfiguration'
  { -- | The array of security group Ids for customer VPC connectivity.
    NetworkConfiguration -> Maybe [Text]
securityGroupIds :: Prelude.Maybe [Prelude.Text],
    -- | The array of subnet Ids for customer VPC connectivity.
    NetworkConfiguration -> Maybe [Text]
subnetIds :: Prelude.Maybe [Prelude.Text]
  }
  deriving (NetworkConfiguration -> NetworkConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NetworkConfiguration -> NetworkConfiguration -> Bool
$c/= :: NetworkConfiguration -> NetworkConfiguration -> Bool
== :: NetworkConfiguration -> NetworkConfiguration -> Bool
$c== :: NetworkConfiguration -> NetworkConfiguration -> Bool
Prelude.Eq, ReadPrec [NetworkConfiguration]
ReadPrec NetworkConfiguration
Int -> ReadS NetworkConfiguration
ReadS [NetworkConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NetworkConfiguration]
$creadListPrec :: ReadPrec [NetworkConfiguration]
readPrec :: ReadPrec NetworkConfiguration
$creadPrec :: ReadPrec NetworkConfiguration
readList :: ReadS [NetworkConfiguration]
$creadList :: ReadS [NetworkConfiguration]
readsPrec :: Int -> ReadS NetworkConfiguration
$creadsPrec :: Int -> ReadS NetworkConfiguration
Prelude.Read, Int -> NetworkConfiguration -> ShowS
[NetworkConfiguration] -> ShowS
NetworkConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NetworkConfiguration] -> ShowS
$cshowList :: [NetworkConfiguration] -> ShowS
show :: NetworkConfiguration -> String
$cshow :: NetworkConfiguration -> String
showsPrec :: Int -> NetworkConfiguration -> ShowS
$cshowsPrec :: Int -> NetworkConfiguration -> ShowS
Prelude.Show, forall x. Rep NetworkConfiguration x -> NetworkConfiguration
forall x. NetworkConfiguration -> Rep NetworkConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NetworkConfiguration x -> NetworkConfiguration
$cfrom :: forall x. NetworkConfiguration -> Rep NetworkConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'NetworkConfiguration' 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', 'networkConfiguration_securityGroupIds' - The array of security group Ids for customer VPC connectivity.
--
-- 'subnetIds', 'networkConfiguration_subnetIds' - The array of subnet Ids for customer VPC connectivity.
newNetworkConfiguration ::
  NetworkConfiguration
newNetworkConfiguration :: NetworkConfiguration
newNetworkConfiguration =
  NetworkConfiguration'
    { $sel:securityGroupIds:NetworkConfiguration' :: Maybe [Text]
securityGroupIds =
        forall a. Maybe a
Prelude.Nothing,
      $sel:subnetIds:NetworkConfiguration' :: Maybe [Text]
subnetIds = forall a. Maybe a
Prelude.Nothing
    }

-- | The array of security group Ids for customer VPC connectivity.
networkConfiguration_securityGroupIds :: Lens.Lens' NetworkConfiguration (Prelude.Maybe [Prelude.Text])
networkConfiguration_securityGroupIds :: Lens' NetworkConfiguration (Maybe [Text])
networkConfiguration_securityGroupIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkConfiguration' {Maybe [Text]
securityGroupIds :: Maybe [Text]
$sel:securityGroupIds:NetworkConfiguration' :: NetworkConfiguration -> Maybe [Text]
securityGroupIds} -> Maybe [Text]
securityGroupIds) (\s :: NetworkConfiguration
s@NetworkConfiguration' {} Maybe [Text]
a -> NetworkConfiguration
s {$sel:securityGroupIds:NetworkConfiguration' :: Maybe [Text]
securityGroupIds = Maybe [Text]
a} :: NetworkConfiguration) 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 array of subnet Ids for customer VPC connectivity.
networkConfiguration_subnetIds :: Lens.Lens' NetworkConfiguration (Prelude.Maybe [Prelude.Text])
networkConfiguration_subnetIds :: Lens' NetworkConfiguration (Maybe [Text])
networkConfiguration_subnetIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkConfiguration' {Maybe [Text]
subnetIds :: Maybe [Text]
$sel:subnetIds:NetworkConfiguration' :: NetworkConfiguration -> Maybe [Text]
subnetIds} -> Maybe [Text]
subnetIds) (\s :: NetworkConfiguration
s@NetworkConfiguration' {} Maybe [Text]
a -> NetworkConfiguration
s {$sel:subnetIds:NetworkConfiguration' :: Maybe [Text]
subnetIds = Maybe [Text]
a} :: NetworkConfiguration) 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

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

instance Prelude.Hashable NetworkConfiguration where
  hashWithSalt :: Int -> NetworkConfiguration -> Int
hashWithSalt Int
_salt NetworkConfiguration' {Maybe [Text]
subnetIds :: Maybe [Text]
securityGroupIds :: Maybe [Text]
$sel:subnetIds:NetworkConfiguration' :: NetworkConfiguration -> Maybe [Text]
$sel:securityGroupIds:NetworkConfiguration' :: NetworkConfiguration -> 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

instance Prelude.NFData NetworkConfiguration where
  rnf :: NetworkConfiguration -> ()
rnf NetworkConfiguration' {Maybe [Text]
subnetIds :: Maybe [Text]
securityGroupIds :: Maybe [Text]
$sel:subnetIds:NetworkConfiguration' :: NetworkConfiguration -> Maybe [Text]
$sel:securityGroupIds:NetworkConfiguration' :: NetworkConfiguration -> 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

instance Data.ToJSON NetworkConfiguration where
  toJSON :: NetworkConfiguration -> Value
toJSON NetworkConfiguration' {Maybe [Text]
subnetIds :: Maybe [Text]
securityGroupIds :: Maybe [Text]
$sel:subnetIds:NetworkConfiguration' :: NetworkConfiguration -> Maybe [Text]
$sel:securityGroupIds:NetworkConfiguration' :: NetworkConfiguration -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"securityGroupIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
securityGroupIds,
            (Key
"subnetIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
subnetIds
          ]
      )