{-# 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-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.SageMaker.Types.NetworkConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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
  }
  deriving (NetworkConfig -> NetworkConfig -> Bool
(NetworkConfig -> NetworkConfig -> Bool)
-> (NetworkConfig -> NetworkConfig -> Bool) -> Eq NetworkConfig
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]
(Int -> ReadS NetworkConfig)
-> ReadS [NetworkConfig]
-> ReadPrec NetworkConfig
-> ReadPrec [NetworkConfig]
-> Read 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
(Int -> NetworkConfig -> ShowS)
-> (NetworkConfig -> String)
-> ([NetworkConfig] -> ShowS)
-> Show NetworkConfig
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. NetworkConfig -> Rep NetworkConfig x)
-> (forall x. Rep NetworkConfig x -> NetworkConfig)
-> Generic NetworkConfig
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:
--
-- '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.
--
-- '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.
newNetworkConfig ::
  NetworkConfig
newNetworkConfig :: NetworkConfig
newNetworkConfig =
  NetworkConfig' :: Maybe Bool -> Maybe VpcConfig -> Maybe Bool -> NetworkConfig
NetworkConfig'
    { $sel:enableNetworkIsolation:NetworkConfig' :: Maybe Bool
enableNetworkIsolation =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:vpcConfig:NetworkConfig' :: Maybe VpcConfig
vpcConfig = Maybe VpcConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:enableInterContainerTrafficEncryption:NetworkConfig' :: Maybe Bool
enableInterContainerTrafficEncryption =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Bool -> f (Maybe Bool)) -> NetworkConfig -> f NetworkConfig
networkConfig_enableNetworkIsolation = (NetworkConfig -> Maybe Bool)
-> (NetworkConfig -> Maybe Bool -> NetworkConfig)
-> Lens NetworkConfig NetworkConfig (Maybe Bool) (Maybe Bool)
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 :: (Maybe VpcConfig -> f (Maybe VpcConfig))
-> NetworkConfig -> f NetworkConfig
networkConfig_vpcConfig = (NetworkConfig -> Maybe VpcConfig)
-> (NetworkConfig -> Maybe VpcConfig -> NetworkConfig)
-> Lens
     NetworkConfig NetworkConfig (Maybe VpcConfig) (Maybe 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)

-- | 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 :: (Maybe Bool -> f (Maybe Bool)) -> NetworkConfig -> f NetworkConfig
networkConfig_enableInterContainerTrafficEncryption = (NetworkConfig -> Maybe Bool)
-> (NetworkConfig -> Maybe Bool -> NetworkConfig)
-> Lens NetworkConfig NetworkConfig (Maybe Bool) (Maybe Bool)
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)

instance Core.FromJSON NetworkConfig where
  parseJSON :: Value -> Parser NetworkConfig
parseJSON =
    String
-> (Object -> Parser NetworkConfig)
-> Value
-> Parser NetworkConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NetworkConfig"
      ( \Object
x ->
          Maybe Bool -> Maybe VpcConfig -> Maybe Bool -> NetworkConfig
NetworkConfig'
            (Maybe Bool -> Maybe VpcConfig -> Maybe Bool -> NetworkConfig)
-> Parser (Maybe Bool)
-> Parser (Maybe VpcConfig -> Maybe Bool -> NetworkConfig)
forall (f :: * -> *) a b. Functor 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
"EnableNetworkIsolation")
            Parser (Maybe VpcConfig -> Maybe Bool -> NetworkConfig)
-> Parser (Maybe VpcConfig) -> Parser (Maybe Bool -> NetworkConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe VpcConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"VpcConfig")
            Parser (Maybe Bool -> NetworkConfig)
-> Parser (Maybe Bool) -> Parser NetworkConfig
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
"EnableInterContainerTrafficEncryption")
      )

instance Prelude.Hashable NetworkConfig

instance Prelude.NFData NetworkConfig

instance Core.ToJSON NetworkConfig where
  toJSON :: NetworkConfig -> Value
toJSON NetworkConfig' {Maybe Bool
Maybe VpcConfig
enableInterContainerTrafficEncryption :: Maybe Bool
vpcConfig :: Maybe VpcConfig
enableNetworkIsolation :: Maybe Bool
$sel:enableInterContainerTrafficEncryption:NetworkConfig' :: NetworkConfig -> Maybe Bool
$sel:vpcConfig:NetworkConfig' :: NetworkConfig -> Maybe VpcConfig
$sel:enableNetworkIsolation:NetworkConfig' :: NetworkConfig -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EnableNetworkIsolation" 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
enableNetworkIsolation,
            (Text
"VpcConfig" Text -> VpcConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VpcConfig -> Pair) -> Maybe VpcConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VpcConfig
vpcConfig,
            (Text
"EnableInterContainerTrafficEncryption" 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
enableInterContainerTrafficEncryption
          ]
      )