{-# 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.Kendra.Types.DataSourceVpcConfiguration
-- 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.Kendra.Types.DataSourceVpcConfiguration 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

-- | Provides the configuration information to connect to an Amazon VPC.
--
-- /See:/ 'newDataSourceVpcConfiguration' smart constructor.
data DataSourceVpcConfiguration = DataSourceVpcConfiguration'
  { -- | A list of identifiers for subnets within your Amazon VPC. The subnets
    -- should be able to connect to each other in the VPC, and they should have
    -- outgoing access to the Internet through a NAT device.
    DataSourceVpcConfiguration -> NonEmpty Text
subnetIds :: Prelude.NonEmpty Prelude.Text,
    -- | A list of identifiers of security groups within your Amazon VPC. The
    -- security groups should enable Amazon Kendra to connect to the data
    -- source.
    DataSourceVpcConfiguration -> NonEmpty Text
securityGroupIds :: Prelude.NonEmpty Prelude.Text
  }
  deriving (DataSourceVpcConfiguration -> DataSourceVpcConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataSourceVpcConfiguration -> DataSourceVpcConfiguration -> Bool
$c/= :: DataSourceVpcConfiguration -> DataSourceVpcConfiguration -> Bool
== :: DataSourceVpcConfiguration -> DataSourceVpcConfiguration -> Bool
$c== :: DataSourceVpcConfiguration -> DataSourceVpcConfiguration -> Bool
Prelude.Eq, ReadPrec [DataSourceVpcConfiguration]
ReadPrec DataSourceVpcConfiguration
Int -> ReadS DataSourceVpcConfiguration
ReadS [DataSourceVpcConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataSourceVpcConfiguration]
$creadListPrec :: ReadPrec [DataSourceVpcConfiguration]
readPrec :: ReadPrec DataSourceVpcConfiguration
$creadPrec :: ReadPrec DataSourceVpcConfiguration
readList :: ReadS [DataSourceVpcConfiguration]
$creadList :: ReadS [DataSourceVpcConfiguration]
readsPrec :: Int -> ReadS DataSourceVpcConfiguration
$creadsPrec :: Int -> ReadS DataSourceVpcConfiguration
Prelude.Read, Int -> DataSourceVpcConfiguration -> ShowS
[DataSourceVpcConfiguration] -> ShowS
DataSourceVpcConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataSourceVpcConfiguration] -> ShowS
$cshowList :: [DataSourceVpcConfiguration] -> ShowS
show :: DataSourceVpcConfiguration -> String
$cshow :: DataSourceVpcConfiguration -> String
showsPrec :: Int -> DataSourceVpcConfiguration -> ShowS
$cshowsPrec :: Int -> DataSourceVpcConfiguration -> ShowS
Prelude.Show, forall x.
Rep DataSourceVpcConfiguration x -> DataSourceVpcConfiguration
forall x.
DataSourceVpcConfiguration -> Rep DataSourceVpcConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DataSourceVpcConfiguration x -> DataSourceVpcConfiguration
$cfrom :: forall x.
DataSourceVpcConfiguration -> Rep DataSourceVpcConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'DataSourceVpcConfiguration' 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:
--
-- 'subnetIds', 'dataSourceVpcConfiguration_subnetIds' - A list of identifiers for subnets within your Amazon VPC. The subnets
-- should be able to connect to each other in the VPC, and they should have
-- outgoing access to the Internet through a NAT device.
--
-- 'securityGroupIds', 'dataSourceVpcConfiguration_securityGroupIds' - A list of identifiers of security groups within your Amazon VPC. The
-- security groups should enable Amazon Kendra to connect to the data
-- source.
newDataSourceVpcConfiguration ::
  -- | 'subnetIds'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'securityGroupIds'
  Prelude.NonEmpty Prelude.Text ->
  DataSourceVpcConfiguration
newDataSourceVpcConfiguration :: NonEmpty Text -> NonEmpty Text -> DataSourceVpcConfiguration
newDataSourceVpcConfiguration
  NonEmpty Text
pSubnetIds_
  NonEmpty Text
pSecurityGroupIds_ =
    DataSourceVpcConfiguration'
      { $sel:subnetIds:DataSourceVpcConfiguration' :: NonEmpty Text
subnetIds =
          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
pSubnetIds_,
        $sel:securityGroupIds:DataSourceVpcConfiguration' :: 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_
      }

-- | A list of identifiers for subnets within your Amazon VPC. The subnets
-- should be able to connect to each other in the VPC, and they should have
-- outgoing access to the Internet through a NAT device.
dataSourceVpcConfiguration_subnetIds :: Lens.Lens' DataSourceVpcConfiguration (Prelude.NonEmpty Prelude.Text)
dataSourceVpcConfiguration_subnetIds :: Lens' DataSourceVpcConfiguration (NonEmpty Text)
dataSourceVpcConfiguration_subnetIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSourceVpcConfiguration' {NonEmpty Text
subnetIds :: NonEmpty Text
$sel:subnetIds:DataSourceVpcConfiguration' :: DataSourceVpcConfiguration -> NonEmpty Text
subnetIds} -> NonEmpty Text
subnetIds) (\s :: DataSourceVpcConfiguration
s@DataSourceVpcConfiguration' {} NonEmpty Text
a -> DataSourceVpcConfiguration
s {$sel:subnetIds:DataSourceVpcConfiguration' :: NonEmpty Text
subnetIds = NonEmpty Text
a} :: DataSourceVpcConfiguration) 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

-- | A list of identifiers of security groups within your Amazon VPC. The
-- security groups should enable Amazon Kendra to connect to the data
-- source.
dataSourceVpcConfiguration_securityGroupIds :: Lens.Lens' DataSourceVpcConfiguration (Prelude.NonEmpty Prelude.Text)
dataSourceVpcConfiguration_securityGroupIds :: Lens' DataSourceVpcConfiguration (NonEmpty Text)
dataSourceVpcConfiguration_securityGroupIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSourceVpcConfiguration' {NonEmpty Text
securityGroupIds :: NonEmpty Text
$sel:securityGroupIds:DataSourceVpcConfiguration' :: DataSourceVpcConfiguration -> NonEmpty Text
securityGroupIds} -> NonEmpty Text
securityGroupIds) (\s :: DataSourceVpcConfiguration
s@DataSourceVpcConfiguration' {} NonEmpty Text
a -> DataSourceVpcConfiguration
s {$sel:securityGroupIds:DataSourceVpcConfiguration' :: NonEmpty Text
securityGroupIds = NonEmpty Text
a} :: DataSourceVpcConfiguration) 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 DataSourceVpcConfiguration where
  parseJSON :: Value -> Parser DataSourceVpcConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataSourceVpcConfiguration"
      ( \Object
x ->
          NonEmpty Text -> NonEmpty Text -> DataSourceVpcConfiguration
DataSourceVpcConfiguration'
            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
"SubnetIds")
            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
"SecurityGroupIds")
      )

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

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

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