{-# 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-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.NeoVpcConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(NeoVpcConfig -> NeoVpcConfig -> Bool)
-> (NeoVpcConfig -> NeoVpcConfig -> Bool) -> Eq NeoVpcConfig
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]
(Int -> ReadS NeoVpcConfig)
-> ReadS [NeoVpcConfig]
-> ReadPrec NeoVpcConfig
-> ReadPrec [NeoVpcConfig]
-> Read 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
(Int -> NeoVpcConfig -> ShowS)
-> (NeoVpcConfig -> String)
-> ([NeoVpcConfig] -> ShowS)
-> Show NeoVpcConfig
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. NeoVpcConfig -> Rep NeoVpcConfig x)
-> (forall x. Rep NeoVpcConfig x -> NeoVpcConfig)
-> Generic NeoVpcConfig
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' :: NonEmpty Text -> NonEmpty Text -> NeoVpcConfig
NeoVpcConfig'
    { $sel:securityGroupIds:NeoVpcConfig' :: NonEmpty Text
securityGroupIds =
        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
pSecurityGroupIds_,
      $sel:subnets:NeoVpcConfig' :: 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_
    }

-- | 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 :: (NonEmpty Text -> f (NonEmpty Text))
-> NeoVpcConfig -> f NeoVpcConfig
neoVpcConfig_securityGroupIds = (NeoVpcConfig -> NonEmpty Text)
-> (NeoVpcConfig -> NonEmpty Text -> NeoVpcConfig)
-> Lens NeoVpcConfig NeoVpcConfig (NonEmpty Text) (NonEmpty Text)
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) ((NonEmpty Text -> f (NonEmpty Text))
 -> NeoVpcConfig -> f NeoVpcConfig)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> NeoVpcConfig
-> f NeoVpcConfig
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

-- | 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 :: (NonEmpty Text -> f (NonEmpty Text))
-> NeoVpcConfig -> f NeoVpcConfig
neoVpcConfig_subnets = (NeoVpcConfig -> NonEmpty Text)
-> (NeoVpcConfig -> NonEmpty Text -> NeoVpcConfig)
-> Lens NeoVpcConfig NeoVpcConfig (NonEmpty Text) (NonEmpty Text)
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) ((NonEmpty Text -> f (NonEmpty Text))
 -> NeoVpcConfig -> f NeoVpcConfig)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> NeoVpcConfig
-> f NeoVpcConfig
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 NeoVpcConfig where
  parseJSON :: Value -> Parser NeoVpcConfig
parseJSON =
    String
-> (Object -> Parser NeoVpcConfig) -> Value -> Parser NeoVpcConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NeoVpcConfig"
      ( \Object
x ->
          NonEmpty Text -> NonEmpty Text -> NeoVpcConfig
NeoVpcConfig'
            (NonEmpty Text -> NonEmpty Text -> NeoVpcConfig)
-> Parser (NonEmpty Text) -> Parser (NonEmpty Text -> NeoVpcConfig)
forall (f :: * -> *) a b. Functor 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
"SecurityGroupIds")
            Parser (NonEmpty Text -> NeoVpcConfig)
-> Parser (NonEmpty Text) -> Parser NeoVpcConfig
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 NeoVpcConfig

instance Prelude.NFData NeoVpcConfig

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"SecurityGroupIds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
securityGroupIds),
            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)
          ]
      )