{-# 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.SageMaker.Types.NetworkConfig
-- 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.SageMaker.Types.NetworkConfig 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
import Amazonka.SageMaker.Types.VpcConfig

-- | Networking options for a job, such as network traffic encryption between
-- containers, whether to allow inbound and outbound network calls to and
-- from containers, and the VPC subnets and security groups to use for
-- VPC-enabled jobs.
--
-- /See:/ 'newNetworkConfig' smart constructor.
data NetworkConfig = NetworkConfig'
  { -- | Whether to encrypt all communications between distributed processing
    -- jobs. Choose @True@ to encrypt communications. Encryption provides
    -- greater security for distributed processing jobs, but the processing
    -- might take longer.
    NetworkConfig -> Maybe Bool
enableInterContainerTrafficEncryption :: Prelude.Maybe Prelude.Bool,
    -- | Whether to allow inbound and outbound network calls to and from the
    -- containers used for the processing job.
    NetworkConfig -> Maybe Bool
enableNetworkIsolation :: Prelude.Maybe Prelude.Bool,
    NetworkConfig -> Maybe VpcConfig
vpcConfig :: Prelude.Maybe VpcConfig
  }
  deriving (NetworkConfig -> NetworkConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NetworkConfig -> NetworkConfig -> Bool
$c/= :: NetworkConfig -> NetworkConfig -> Bool
== :: NetworkConfig -> NetworkConfig -> Bool
$c== :: NetworkConfig -> NetworkConfig -> Bool
Prelude.Eq, ReadPrec [NetworkConfig]
ReadPrec NetworkConfig
Int -> ReadS NetworkConfig
ReadS [NetworkConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NetworkConfig]
$creadListPrec :: ReadPrec [NetworkConfig]
readPrec :: ReadPrec NetworkConfig
$creadPrec :: ReadPrec NetworkConfig
readList :: ReadS [NetworkConfig]
$creadList :: ReadS [NetworkConfig]
readsPrec :: Int -> ReadS NetworkConfig
$creadsPrec :: Int -> ReadS NetworkConfig
Prelude.Read, Int -> NetworkConfig -> ShowS
[NetworkConfig] -> ShowS
NetworkConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NetworkConfig] -> ShowS
$cshowList :: [NetworkConfig] -> ShowS
show :: NetworkConfig -> String
$cshow :: NetworkConfig -> String
showsPrec :: Int -> NetworkConfig -> ShowS
$cshowsPrec :: Int -> NetworkConfig -> ShowS
Prelude.Show, forall x. Rep NetworkConfig x -> NetworkConfig
forall x. NetworkConfig -> Rep NetworkConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NetworkConfig x -> NetworkConfig
$cfrom :: forall x. NetworkConfig -> Rep NetworkConfig x
Prelude.Generic)

-- |
-- Create a value of 'NetworkConfig' 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:
--
-- 'enableInterContainerTrafficEncryption', 'networkConfig_enableInterContainerTrafficEncryption' - Whether to encrypt all communications between distributed processing
-- jobs. Choose @True@ to encrypt communications. Encryption provides
-- greater security for distributed processing jobs, but the processing
-- might take longer.
--
-- 'enableNetworkIsolation', 'networkConfig_enableNetworkIsolation' - Whether to allow inbound and outbound network calls to and from the
-- containers used for the processing job.
--
-- 'vpcConfig', 'networkConfig_vpcConfig' - Undocumented member.
newNetworkConfig ::
  NetworkConfig
newNetworkConfig :: NetworkConfig
newNetworkConfig =
  NetworkConfig'
    { $sel:enableInterContainerTrafficEncryption:NetworkConfig' :: Maybe Bool
enableInterContainerTrafficEncryption =
        forall a. Maybe a
Prelude.Nothing,
      $sel:enableNetworkIsolation:NetworkConfig' :: Maybe Bool
enableNetworkIsolation = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcConfig:NetworkConfig' :: Maybe VpcConfig
vpcConfig = forall a. Maybe a
Prelude.Nothing
    }

-- | Whether to encrypt all communications between distributed processing
-- jobs. Choose @True@ to encrypt communications. Encryption provides
-- greater security for distributed processing jobs, but the processing
-- might take longer.
networkConfig_enableInterContainerTrafficEncryption :: Lens.Lens' NetworkConfig (Prelude.Maybe Prelude.Bool)
networkConfig_enableInterContainerTrafficEncryption :: Lens' NetworkConfig (Maybe Bool)
networkConfig_enableInterContainerTrafficEncryption = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkConfig' {Maybe Bool
enableInterContainerTrafficEncryption :: Maybe Bool
$sel:enableInterContainerTrafficEncryption:NetworkConfig' :: NetworkConfig -> Maybe Bool
enableInterContainerTrafficEncryption} -> Maybe Bool
enableInterContainerTrafficEncryption) (\s :: NetworkConfig
s@NetworkConfig' {} Maybe Bool
a -> NetworkConfig
s {$sel:enableInterContainerTrafficEncryption:NetworkConfig' :: Maybe Bool
enableInterContainerTrafficEncryption = Maybe Bool
a} :: NetworkConfig)

-- | Whether to allow inbound and outbound network calls to and from the
-- containers used for the processing job.
networkConfig_enableNetworkIsolation :: Lens.Lens' NetworkConfig (Prelude.Maybe Prelude.Bool)
networkConfig_enableNetworkIsolation :: Lens' NetworkConfig (Maybe Bool)
networkConfig_enableNetworkIsolation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkConfig' {Maybe Bool
enableNetworkIsolation :: Maybe Bool
$sel:enableNetworkIsolation:NetworkConfig' :: NetworkConfig -> Maybe Bool
enableNetworkIsolation} -> Maybe Bool
enableNetworkIsolation) (\s :: NetworkConfig
s@NetworkConfig' {} Maybe Bool
a -> NetworkConfig
s {$sel:enableNetworkIsolation:NetworkConfig' :: Maybe Bool
enableNetworkIsolation = Maybe Bool
a} :: NetworkConfig)

-- | Undocumented member.
networkConfig_vpcConfig :: Lens.Lens' NetworkConfig (Prelude.Maybe VpcConfig)
networkConfig_vpcConfig :: Lens' NetworkConfig (Maybe VpcConfig)
networkConfig_vpcConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkConfig' {Maybe VpcConfig
vpcConfig :: Maybe VpcConfig
$sel:vpcConfig:NetworkConfig' :: NetworkConfig -> Maybe VpcConfig
vpcConfig} -> Maybe VpcConfig
vpcConfig) (\s :: NetworkConfig
s@NetworkConfig' {} Maybe VpcConfig
a -> NetworkConfig
s {$sel:vpcConfig:NetworkConfig' :: Maybe VpcConfig
vpcConfig = Maybe VpcConfig
a} :: NetworkConfig)

instance Data.FromJSON NetworkConfig where
  parseJSON :: Value -> Parser NetworkConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NetworkConfig"
      ( \Object
x ->
          Maybe Bool -> Maybe Bool -> Maybe VpcConfig -> NetworkConfig
NetworkConfig'
            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
"EnableInterContainerTrafficEncryption")
            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
"EnableNetworkIsolation")
            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
"VpcConfig")
      )

instance Prelude.Hashable NetworkConfig where
  hashWithSalt :: Int -> NetworkConfig -> Int
hashWithSalt Int
_salt NetworkConfig' {Maybe Bool
Maybe VpcConfig
vpcConfig :: Maybe VpcConfig
enableNetworkIsolation :: Maybe Bool
enableInterContainerTrafficEncryption :: Maybe Bool
$sel:vpcConfig:NetworkConfig' :: NetworkConfig -> Maybe VpcConfig
$sel:enableNetworkIsolation:NetworkConfig' :: NetworkConfig -> Maybe Bool
$sel:enableInterContainerTrafficEncryption:NetworkConfig' :: NetworkConfig -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enableInterContainerTrafficEncryption
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enableNetworkIsolation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VpcConfig
vpcConfig

instance Prelude.NFData NetworkConfig where
  rnf :: NetworkConfig -> ()
rnf NetworkConfig' {Maybe Bool
Maybe VpcConfig
vpcConfig :: Maybe VpcConfig
enableNetworkIsolation :: Maybe Bool
enableInterContainerTrafficEncryption :: Maybe Bool
$sel:vpcConfig:NetworkConfig' :: NetworkConfig -> Maybe VpcConfig
$sel:enableNetworkIsolation:NetworkConfig' :: NetworkConfig -> Maybe Bool
$sel:enableInterContainerTrafficEncryption:NetworkConfig' :: NetworkConfig -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enableInterContainerTrafficEncryption
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enableNetworkIsolation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VpcConfig
vpcConfig

instance Data.ToJSON NetworkConfig where
  toJSON :: NetworkConfig -> Value
toJSON NetworkConfig' {Maybe Bool
Maybe VpcConfig
vpcConfig :: Maybe VpcConfig
enableNetworkIsolation :: Maybe Bool
enableInterContainerTrafficEncryption :: Maybe Bool
$sel:vpcConfig:NetworkConfig' :: NetworkConfig -> Maybe VpcConfig
$sel:enableNetworkIsolation:NetworkConfig' :: NetworkConfig -> Maybe Bool
$sel:enableInterContainerTrafficEncryption:NetworkConfig' :: NetworkConfig -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"EnableInterContainerTrafficEncryption" 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 Bool
enableInterContainerTrafficEncryption,
            (Key
"EnableNetworkIsolation" 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 Bool
enableNetworkIsolation,
            (Key
"VpcConfig" 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 VpcConfig
vpcConfig
          ]
      )