{-# 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.NeoVpcConfig
-- 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.NeoVpcConfig 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 VpcConfig configuration object that specifies the VPC that you want
-- the compilation jobs to connect to. For more information on controlling
-- access to your Amazon S3 buckets used for compilation job, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/neo-vpc.html Give Amazon SageMaker Compilation Jobs Access to Resources in Your Amazon VPC>.
--
-- /See:/ 'newNeoVpcConfig' smart constructor.
data NeoVpcConfig = NeoVpcConfig'
  { -- | The VPC security group IDs. IDs have the form of @sg-xxxxxxxx@. Specify
    -- the security groups for the VPC that is specified in the @Subnets@
    -- field.
    NeoVpcConfig -> NonEmpty Text
securityGroupIds :: Prelude.NonEmpty Prelude.Text,
    -- | The ID of the subnets in the VPC that you want to connect the
    -- compilation job to for accessing the model in Amazon S3.
    NeoVpcConfig -> NonEmpty Text
subnets :: Prelude.NonEmpty Prelude.Text
  }
  deriving (NeoVpcConfig -> NeoVpcConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NeoVpcConfig -> NeoVpcConfig -> Bool
$c/= :: NeoVpcConfig -> NeoVpcConfig -> Bool
== :: NeoVpcConfig -> NeoVpcConfig -> Bool
$c== :: NeoVpcConfig -> NeoVpcConfig -> Bool
Prelude.Eq, ReadPrec [NeoVpcConfig]
ReadPrec NeoVpcConfig
Int -> ReadS NeoVpcConfig
ReadS [NeoVpcConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NeoVpcConfig]
$creadListPrec :: ReadPrec [NeoVpcConfig]
readPrec :: ReadPrec NeoVpcConfig
$creadPrec :: ReadPrec NeoVpcConfig
readList :: ReadS [NeoVpcConfig]
$creadList :: ReadS [NeoVpcConfig]
readsPrec :: Int -> ReadS NeoVpcConfig
$creadsPrec :: Int -> ReadS NeoVpcConfig
Prelude.Read, Int -> NeoVpcConfig -> ShowS
[NeoVpcConfig] -> ShowS
NeoVpcConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NeoVpcConfig] -> ShowS
$cshowList :: [NeoVpcConfig] -> ShowS
show :: NeoVpcConfig -> String
$cshow :: NeoVpcConfig -> String
showsPrec :: Int -> NeoVpcConfig -> ShowS
$cshowsPrec :: Int -> NeoVpcConfig -> ShowS
Prelude.Show, forall x. Rep NeoVpcConfig x -> NeoVpcConfig
forall x. NeoVpcConfig -> Rep NeoVpcConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NeoVpcConfig x -> NeoVpcConfig
$cfrom :: forall x. NeoVpcConfig -> Rep NeoVpcConfig x
Prelude.Generic)

-- |
-- Create a value of 'NeoVpcConfig' 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', 'neoVpcConfig_securityGroupIds' - The VPC security group IDs. IDs have the form of @sg-xxxxxxxx@. Specify
-- the security groups for the VPC that is specified in the @Subnets@
-- field.
--
-- 'subnets', 'neoVpcConfig_subnets' - The ID of the subnets in the VPC that you want to connect the
-- compilation job to for accessing the model in Amazon S3.
newNeoVpcConfig ::
  -- | 'securityGroupIds'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'subnets'
  Prelude.NonEmpty Prelude.Text ->
  NeoVpcConfig
newNeoVpcConfig :: NonEmpty Text -> NonEmpty Text -> NeoVpcConfig
newNeoVpcConfig NonEmpty Text
pSecurityGroupIds_ NonEmpty Text
pSubnets_ =
  NeoVpcConfig'
    { $sel:securityGroupIds:NeoVpcConfig' :: NonEmpty Text
securityGroupIds =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pSecurityGroupIds_,
      $sel:subnets:NeoVpcConfig' :: NonEmpty Text
subnets = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pSubnets_
    }

-- | The VPC security group IDs. IDs have the form of @sg-xxxxxxxx@. Specify
-- the security groups for the VPC that is specified in the @Subnets@
-- field.
neoVpcConfig_securityGroupIds :: Lens.Lens' NeoVpcConfig (Prelude.NonEmpty Prelude.Text)
neoVpcConfig_securityGroupIds :: Lens' NeoVpcConfig (NonEmpty Text)
neoVpcConfig_securityGroupIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NeoVpcConfig' {NonEmpty Text
securityGroupIds :: NonEmpty Text
$sel:securityGroupIds:NeoVpcConfig' :: NeoVpcConfig -> NonEmpty Text
securityGroupIds} -> NonEmpty Text
securityGroupIds) (\s :: NeoVpcConfig
s@NeoVpcConfig' {} NonEmpty Text
a -> NeoVpcConfig
s {$sel:securityGroupIds:NeoVpcConfig' :: NonEmpty Text
securityGroupIds = NonEmpty Text
a} :: NeoVpcConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the subnets in the VPC that you want to connect the
-- compilation job to for accessing the model in Amazon S3.
neoVpcConfig_subnets :: Lens.Lens' NeoVpcConfig (Prelude.NonEmpty Prelude.Text)
neoVpcConfig_subnets :: Lens' NeoVpcConfig (NonEmpty Text)
neoVpcConfig_subnets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NeoVpcConfig' {NonEmpty Text
subnets :: NonEmpty Text
$sel:subnets:NeoVpcConfig' :: NeoVpcConfig -> NonEmpty Text
subnets} -> NonEmpty Text
subnets) (\s :: NeoVpcConfig
s@NeoVpcConfig' {} NonEmpty Text
a -> NeoVpcConfig
s {$sel:subnets:NeoVpcConfig' :: NonEmpty Text
subnets = NonEmpty Text
a} :: NeoVpcConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON NeoVpcConfig where
  parseJSON :: Value -> Parser NeoVpcConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NeoVpcConfig"
      ( \Object
x ->
          NonEmpty Text -> NonEmpty Text -> NeoVpcConfig
NeoVpcConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"SecurityGroupIds")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Subnets")
      )

instance Prelude.Hashable NeoVpcConfig where
  hashWithSalt :: Int -> NeoVpcConfig -> Int
hashWithSalt Int
_salt NeoVpcConfig' {NonEmpty Text
subnets :: NonEmpty Text
securityGroupIds :: NonEmpty Text
$sel:subnets:NeoVpcConfig' :: NeoVpcConfig -> NonEmpty Text
$sel:securityGroupIds:NeoVpcConfig' :: NeoVpcConfig -> NonEmpty Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
securityGroupIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
subnets

instance Prelude.NFData NeoVpcConfig where
  rnf :: NeoVpcConfig -> ()
rnf NeoVpcConfig' {NonEmpty Text
subnets :: NonEmpty Text
securityGroupIds :: NonEmpty Text
$sel:subnets:NeoVpcConfig' :: NeoVpcConfig -> NonEmpty Text
$sel:securityGroupIds:NeoVpcConfig' :: NeoVpcConfig -> NonEmpty Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
securityGroupIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
subnets

instance Data.ToJSON NeoVpcConfig where
  toJSON :: NeoVpcConfig -> Value
toJSON NeoVpcConfig' {NonEmpty Text
subnets :: NonEmpty Text
securityGroupIds :: NonEmpty Text
$sel:subnets:NeoVpcConfig' :: NeoVpcConfig -> NonEmpty Text
$sel:securityGroupIds:NeoVpcConfig' :: NeoVpcConfig -> NonEmpty Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"SecurityGroupIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
securityGroupIds),
            forall a. a -> Maybe a
Prelude.Just (Key
"Subnets" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
subnets)
          ]
      )