{-# 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.RecommendationJobVpcConfig
-- 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.RecommendationJobVpcConfig 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

-- | Inference Recommender provisions SageMaker endpoints with access to VPC
-- in the inference recommendation job.
--
-- /See:/ 'newRecommendationJobVpcConfig' smart constructor.
data RecommendationJobVpcConfig = RecommendationJobVpcConfig'
  { -- | 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.
    RecommendationJobVpcConfig -> NonEmpty Text
securityGroupIds :: Prelude.NonEmpty Prelude.Text,
    -- | The ID of the subnets in the VPC to which you want to connect your
    -- model.
    RecommendationJobVpcConfig -> NonEmpty Text
subnets :: Prelude.NonEmpty Prelude.Text
  }
  deriving (RecommendationJobVpcConfig -> RecommendationJobVpcConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecommendationJobVpcConfig -> RecommendationJobVpcConfig -> Bool
$c/= :: RecommendationJobVpcConfig -> RecommendationJobVpcConfig -> Bool
== :: RecommendationJobVpcConfig -> RecommendationJobVpcConfig -> Bool
$c== :: RecommendationJobVpcConfig -> RecommendationJobVpcConfig -> Bool
Prelude.Eq, ReadPrec [RecommendationJobVpcConfig]
ReadPrec RecommendationJobVpcConfig
Int -> ReadS RecommendationJobVpcConfig
ReadS [RecommendationJobVpcConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecommendationJobVpcConfig]
$creadListPrec :: ReadPrec [RecommendationJobVpcConfig]
readPrec :: ReadPrec RecommendationJobVpcConfig
$creadPrec :: ReadPrec RecommendationJobVpcConfig
readList :: ReadS [RecommendationJobVpcConfig]
$creadList :: ReadS [RecommendationJobVpcConfig]
readsPrec :: Int -> ReadS RecommendationJobVpcConfig
$creadsPrec :: Int -> ReadS RecommendationJobVpcConfig
Prelude.Read, Int -> RecommendationJobVpcConfig -> ShowS
[RecommendationJobVpcConfig] -> ShowS
RecommendationJobVpcConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecommendationJobVpcConfig] -> ShowS
$cshowList :: [RecommendationJobVpcConfig] -> ShowS
show :: RecommendationJobVpcConfig -> String
$cshow :: RecommendationJobVpcConfig -> String
showsPrec :: Int -> RecommendationJobVpcConfig -> ShowS
$cshowsPrec :: Int -> RecommendationJobVpcConfig -> ShowS
Prelude.Show, forall x.
Rep RecommendationJobVpcConfig x -> RecommendationJobVpcConfig
forall x.
RecommendationJobVpcConfig -> Rep RecommendationJobVpcConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RecommendationJobVpcConfig x -> RecommendationJobVpcConfig
$cfrom :: forall x.
RecommendationJobVpcConfig -> Rep RecommendationJobVpcConfig x
Prelude.Generic)

-- |
-- Create a value of 'RecommendationJobVpcConfig' 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', 'recommendationJobVpcConfig_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', 'recommendationJobVpcConfig_subnets' - The ID of the subnets in the VPC to which you want to connect your
-- model.
newRecommendationJobVpcConfig ::
  -- | 'securityGroupIds'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'subnets'
  Prelude.NonEmpty Prelude.Text ->
  RecommendationJobVpcConfig
newRecommendationJobVpcConfig :: NonEmpty Text -> NonEmpty Text -> RecommendationJobVpcConfig
newRecommendationJobVpcConfig
  NonEmpty Text
pSecurityGroupIds_
  NonEmpty Text
pSubnets_ =
    RecommendationJobVpcConfig'
      { $sel:securityGroupIds:RecommendationJobVpcConfig' :: 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:RecommendationJobVpcConfig' :: 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.
recommendationJobVpcConfig_securityGroupIds :: Lens.Lens' RecommendationJobVpcConfig (Prelude.NonEmpty Prelude.Text)
recommendationJobVpcConfig_securityGroupIds :: Lens' RecommendationJobVpcConfig (NonEmpty Text)
recommendationJobVpcConfig_securityGroupIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationJobVpcConfig' {NonEmpty Text
securityGroupIds :: NonEmpty Text
$sel:securityGroupIds:RecommendationJobVpcConfig' :: RecommendationJobVpcConfig -> NonEmpty Text
securityGroupIds} -> NonEmpty Text
securityGroupIds) (\s :: RecommendationJobVpcConfig
s@RecommendationJobVpcConfig' {} NonEmpty Text
a -> RecommendationJobVpcConfig
s {$sel:securityGroupIds:RecommendationJobVpcConfig' :: NonEmpty Text
securityGroupIds = NonEmpty Text
a} :: RecommendationJobVpcConfig) 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 to which you want to connect your
-- model.
recommendationJobVpcConfig_subnets :: Lens.Lens' RecommendationJobVpcConfig (Prelude.NonEmpty Prelude.Text)
recommendationJobVpcConfig_subnets :: Lens' RecommendationJobVpcConfig (NonEmpty Text)
recommendationJobVpcConfig_subnets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationJobVpcConfig' {NonEmpty Text
subnets :: NonEmpty Text
$sel:subnets:RecommendationJobVpcConfig' :: RecommendationJobVpcConfig -> NonEmpty Text
subnets} -> NonEmpty Text
subnets) (\s :: RecommendationJobVpcConfig
s@RecommendationJobVpcConfig' {} NonEmpty Text
a -> RecommendationJobVpcConfig
s {$sel:subnets:RecommendationJobVpcConfig' :: NonEmpty Text
subnets = NonEmpty Text
a} :: RecommendationJobVpcConfig) 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 RecommendationJobVpcConfig where
  parseJSON :: Value -> Parser RecommendationJobVpcConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RecommendationJobVpcConfig"
      ( \Object
x ->
          NonEmpty Text -> NonEmpty Text -> RecommendationJobVpcConfig
RecommendationJobVpcConfig'
            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 RecommendationJobVpcConfig where
  hashWithSalt :: Int -> RecommendationJobVpcConfig -> Int
hashWithSalt Int
_salt RecommendationJobVpcConfig' {NonEmpty Text
subnets :: NonEmpty Text
securityGroupIds :: NonEmpty Text
$sel:subnets:RecommendationJobVpcConfig' :: RecommendationJobVpcConfig -> NonEmpty Text
$sel:securityGroupIds:RecommendationJobVpcConfig' :: RecommendationJobVpcConfig -> 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 RecommendationJobVpcConfig where
  rnf :: RecommendationJobVpcConfig -> ()
rnf RecommendationJobVpcConfig' {NonEmpty Text
subnets :: NonEmpty Text
securityGroupIds :: NonEmpty Text
$sel:subnets:RecommendationJobVpcConfig' :: RecommendationJobVpcConfig -> NonEmpty Text
$sel:securityGroupIds:RecommendationJobVpcConfig' :: RecommendationJobVpcConfig -> 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 RecommendationJobVpcConfig where
  toJSON :: RecommendationJobVpcConfig -> Value
toJSON RecommendationJobVpcConfig' {NonEmpty Text
subnets :: NonEmpty Text
securityGroupIds :: NonEmpty Text
$sel:subnets:RecommendationJobVpcConfig' :: RecommendationJobVpcConfig -> NonEmpty Text
$sel:securityGroupIds:RecommendationJobVpcConfig' :: RecommendationJobVpcConfig -> 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)
          ]
      )