{-# 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.Glue.Types.ConnectionInput
-- 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.Glue.Types.ConnectionInput where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types.ConnectionPropertyKey
import Amazonka.Glue.Types.ConnectionType
import Amazonka.Glue.Types.PhysicalConnectionRequirements
import qualified Amazonka.Prelude as Prelude

-- | A structure that is used to specify a connection to create or update.
--
-- /See:/ 'newConnectionInput' smart constructor.
data ConnectionInput = ConnectionInput'
  { -- | The description of the connection.
    ConnectionInput -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | A list of criteria that can be used in selecting this connection.
    ConnectionInput -> Maybe [Text]
matchCriteria :: Prelude.Maybe [Prelude.Text],
    -- | A map of physical connection requirements, such as virtual private cloud
    -- (VPC) and @SecurityGroup@, that are needed to successfully make this
    -- connection.
    ConnectionInput -> Maybe PhysicalConnectionRequirements
physicalConnectionRequirements :: Prelude.Maybe PhysicalConnectionRequirements,
    -- | The name of the connection.
    ConnectionInput -> Text
name :: Prelude.Text,
    -- | The type of the connection. Currently, these types are supported:
    --
    -- -   @JDBC@ - Designates a connection to a database through Java Database
    --     Connectivity (JDBC).
    --
    -- -   @KAFKA@ - Designates a connection to an Apache Kafka streaming
    --     platform.
    --
    -- -   @MONGODB@ - Designates a connection to a MongoDB document database.
    --
    -- -   @NETWORK@ - Designates a network connection to a data source within
    --     an Amazon Virtual Private Cloud environment (Amazon VPC).
    --
    -- -   @MARKETPLACE@ - Uses configuration settings contained in a connector
    --     purchased from Amazon Web Services Marketplace to read from and
    --     write to data stores that are not natively supported by Glue.
    --
    -- -   @CUSTOM@ - Uses configuration settings contained in a custom
    --     connector to read from and write to data stores that are not
    --     natively supported by Glue.
    --
    -- SFTP is not supported.
    ConnectionInput -> ConnectionType
connectionType :: ConnectionType,
    -- | These key-value pairs define parameters for the connection.
    ConnectionInput -> HashMap ConnectionPropertyKey Text
connectionProperties :: Prelude.HashMap ConnectionPropertyKey Prelude.Text
  }
  deriving (ConnectionInput -> ConnectionInput -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnectionInput -> ConnectionInput -> Bool
$c/= :: ConnectionInput -> ConnectionInput -> Bool
== :: ConnectionInput -> ConnectionInput -> Bool
$c== :: ConnectionInput -> ConnectionInput -> Bool
Prelude.Eq, ReadPrec [ConnectionInput]
ReadPrec ConnectionInput
Int -> ReadS ConnectionInput
ReadS [ConnectionInput]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConnectionInput]
$creadListPrec :: ReadPrec [ConnectionInput]
readPrec :: ReadPrec ConnectionInput
$creadPrec :: ReadPrec ConnectionInput
readList :: ReadS [ConnectionInput]
$creadList :: ReadS [ConnectionInput]
readsPrec :: Int -> ReadS ConnectionInput
$creadsPrec :: Int -> ReadS ConnectionInput
Prelude.Read, Int -> ConnectionInput -> ShowS
[ConnectionInput] -> ShowS
ConnectionInput -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConnectionInput] -> ShowS
$cshowList :: [ConnectionInput] -> ShowS
show :: ConnectionInput -> String
$cshow :: ConnectionInput -> String
showsPrec :: Int -> ConnectionInput -> ShowS
$cshowsPrec :: Int -> ConnectionInput -> ShowS
Prelude.Show, forall x. Rep ConnectionInput x -> ConnectionInput
forall x. ConnectionInput -> Rep ConnectionInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConnectionInput x -> ConnectionInput
$cfrom :: forall x. ConnectionInput -> Rep ConnectionInput x
Prelude.Generic)

-- |
-- Create a value of 'ConnectionInput' 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:
--
-- 'description', 'connectionInput_description' - The description of the connection.
--
-- 'matchCriteria', 'connectionInput_matchCriteria' - A list of criteria that can be used in selecting this connection.
--
-- 'physicalConnectionRequirements', 'connectionInput_physicalConnectionRequirements' - A map of physical connection requirements, such as virtual private cloud
-- (VPC) and @SecurityGroup@, that are needed to successfully make this
-- connection.
--
-- 'name', 'connectionInput_name' - The name of the connection.
--
-- 'connectionType', 'connectionInput_connectionType' - The type of the connection. Currently, these types are supported:
--
-- -   @JDBC@ - Designates a connection to a database through Java Database
--     Connectivity (JDBC).
--
-- -   @KAFKA@ - Designates a connection to an Apache Kafka streaming
--     platform.
--
-- -   @MONGODB@ - Designates a connection to a MongoDB document database.
--
-- -   @NETWORK@ - Designates a network connection to a data source within
--     an Amazon Virtual Private Cloud environment (Amazon VPC).
--
-- -   @MARKETPLACE@ - Uses configuration settings contained in a connector
--     purchased from Amazon Web Services Marketplace to read from and
--     write to data stores that are not natively supported by Glue.
--
-- -   @CUSTOM@ - Uses configuration settings contained in a custom
--     connector to read from and write to data stores that are not
--     natively supported by Glue.
--
-- SFTP is not supported.
--
-- 'connectionProperties', 'connectionInput_connectionProperties' - These key-value pairs define parameters for the connection.
newConnectionInput ::
  -- | 'name'
  Prelude.Text ->
  -- | 'connectionType'
  ConnectionType ->
  ConnectionInput
newConnectionInput :: Text -> ConnectionType -> ConnectionInput
newConnectionInput Text
pName_ ConnectionType
pConnectionType_ =
  ConnectionInput'
    { $sel:description:ConnectionInput' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:matchCriteria:ConnectionInput' :: Maybe [Text]
matchCriteria = forall a. Maybe a
Prelude.Nothing,
      $sel:physicalConnectionRequirements:ConnectionInput' :: Maybe PhysicalConnectionRequirements
physicalConnectionRequirements = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ConnectionInput' :: Text
name = Text
pName_,
      $sel:connectionType:ConnectionInput' :: ConnectionType
connectionType = ConnectionType
pConnectionType_,
      $sel:connectionProperties:ConnectionInput' :: HashMap ConnectionPropertyKey Text
connectionProperties = forall a. Monoid a => a
Prelude.mempty
    }

-- | The description of the connection.
connectionInput_description :: Lens.Lens' ConnectionInput (Prelude.Maybe Prelude.Text)
connectionInput_description :: Lens' ConnectionInput (Maybe Text)
connectionInput_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionInput' {Maybe Text
description :: Maybe Text
$sel:description:ConnectionInput' :: ConnectionInput -> Maybe Text
description} -> Maybe Text
description) (\s :: ConnectionInput
s@ConnectionInput' {} Maybe Text
a -> ConnectionInput
s {$sel:description:ConnectionInput' :: Maybe Text
description = Maybe Text
a} :: ConnectionInput)

-- | A list of criteria that can be used in selecting this connection.
connectionInput_matchCriteria :: Lens.Lens' ConnectionInput (Prelude.Maybe [Prelude.Text])
connectionInput_matchCriteria :: Lens' ConnectionInput (Maybe [Text])
connectionInput_matchCriteria = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionInput' {Maybe [Text]
matchCriteria :: Maybe [Text]
$sel:matchCriteria:ConnectionInput' :: ConnectionInput -> Maybe [Text]
matchCriteria} -> Maybe [Text]
matchCriteria) (\s :: ConnectionInput
s@ConnectionInput' {} Maybe [Text]
a -> ConnectionInput
s {$sel:matchCriteria:ConnectionInput' :: Maybe [Text]
matchCriteria = Maybe [Text]
a} :: ConnectionInput) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A map of physical connection requirements, such as virtual private cloud
-- (VPC) and @SecurityGroup@, that are needed to successfully make this
-- connection.
connectionInput_physicalConnectionRequirements :: Lens.Lens' ConnectionInput (Prelude.Maybe PhysicalConnectionRequirements)
connectionInput_physicalConnectionRequirements :: Lens' ConnectionInput (Maybe PhysicalConnectionRequirements)
connectionInput_physicalConnectionRequirements = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionInput' {Maybe PhysicalConnectionRequirements
physicalConnectionRequirements :: Maybe PhysicalConnectionRequirements
$sel:physicalConnectionRequirements:ConnectionInput' :: ConnectionInput -> Maybe PhysicalConnectionRequirements
physicalConnectionRequirements} -> Maybe PhysicalConnectionRequirements
physicalConnectionRequirements) (\s :: ConnectionInput
s@ConnectionInput' {} Maybe PhysicalConnectionRequirements
a -> ConnectionInput
s {$sel:physicalConnectionRequirements:ConnectionInput' :: Maybe PhysicalConnectionRequirements
physicalConnectionRequirements = Maybe PhysicalConnectionRequirements
a} :: ConnectionInput)

-- | The name of the connection.
connectionInput_name :: Lens.Lens' ConnectionInput Prelude.Text
connectionInput_name :: Lens' ConnectionInput Text
connectionInput_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionInput' {Text
name :: Text
$sel:name:ConnectionInput' :: ConnectionInput -> Text
name} -> Text
name) (\s :: ConnectionInput
s@ConnectionInput' {} Text
a -> ConnectionInput
s {$sel:name:ConnectionInput' :: Text
name = Text
a} :: ConnectionInput)

-- | The type of the connection. Currently, these types are supported:
--
-- -   @JDBC@ - Designates a connection to a database through Java Database
--     Connectivity (JDBC).
--
-- -   @KAFKA@ - Designates a connection to an Apache Kafka streaming
--     platform.
--
-- -   @MONGODB@ - Designates a connection to a MongoDB document database.
--
-- -   @NETWORK@ - Designates a network connection to a data source within
--     an Amazon Virtual Private Cloud environment (Amazon VPC).
--
-- -   @MARKETPLACE@ - Uses configuration settings contained in a connector
--     purchased from Amazon Web Services Marketplace to read from and
--     write to data stores that are not natively supported by Glue.
--
-- -   @CUSTOM@ - Uses configuration settings contained in a custom
--     connector to read from and write to data stores that are not
--     natively supported by Glue.
--
-- SFTP is not supported.
connectionInput_connectionType :: Lens.Lens' ConnectionInput ConnectionType
connectionInput_connectionType :: Lens' ConnectionInput ConnectionType
connectionInput_connectionType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionInput' {ConnectionType
connectionType :: ConnectionType
$sel:connectionType:ConnectionInput' :: ConnectionInput -> ConnectionType
connectionType} -> ConnectionType
connectionType) (\s :: ConnectionInput
s@ConnectionInput' {} ConnectionType
a -> ConnectionInput
s {$sel:connectionType:ConnectionInput' :: ConnectionType
connectionType = ConnectionType
a} :: ConnectionInput)

-- | These key-value pairs define parameters for the connection.
connectionInput_connectionProperties :: Lens.Lens' ConnectionInput (Prelude.HashMap ConnectionPropertyKey Prelude.Text)
connectionInput_connectionProperties :: Lens' ConnectionInput (HashMap ConnectionPropertyKey Text)
connectionInput_connectionProperties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionInput' {HashMap ConnectionPropertyKey Text
connectionProperties :: HashMap ConnectionPropertyKey Text
$sel:connectionProperties:ConnectionInput' :: ConnectionInput -> HashMap ConnectionPropertyKey Text
connectionProperties} -> HashMap ConnectionPropertyKey Text
connectionProperties) (\s :: ConnectionInput
s@ConnectionInput' {} HashMap ConnectionPropertyKey Text
a -> ConnectionInput
s {$sel:connectionProperties:ConnectionInput' :: HashMap ConnectionPropertyKey Text
connectionProperties = HashMap ConnectionPropertyKey Text
a} :: ConnectionInput) 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 Prelude.Hashable ConnectionInput where
  hashWithSalt :: Int -> ConnectionInput -> Int
hashWithSalt Int
_salt ConnectionInput' {Maybe [Text]
Maybe Text
Maybe PhysicalConnectionRequirements
Text
HashMap ConnectionPropertyKey Text
ConnectionType
connectionProperties :: HashMap ConnectionPropertyKey Text
connectionType :: ConnectionType
name :: Text
physicalConnectionRequirements :: Maybe PhysicalConnectionRequirements
matchCriteria :: Maybe [Text]
description :: Maybe Text
$sel:connectionProperties:ConnectionInput' :: ConnectionInput -> HashMap ConnectionPropertyKey Text
$sel:connectionType:ConnectionInput' :: ConnectionInput -> ConnectionType
$sel:name:ConnectionInput' :: ConnectionInput -> Text
$sel:physicalConnectionRequirements:ConnectionInput' :: ConnectionInput -> Maybe PhysicalConnectionRequirements
$sel:matchCriteria:ConnectionInput' :: ConnectionInput -> Maybe [Text]
$sel:description:ConnectionInput' :: ConnectionInput -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
matchCriteria
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PhysicalConnectionRequirements
physicalConnectionRequirements
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ConnectionType
connectionType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap ConnectionPropertyKey Text
connectionProperties

instance Prelude.NFData ConnectionInput where
  rnf :: ConnectionInput -> ()
rnf ConnectionInput' {Maybe [Text]
Maybe Text
Maybe PhysicalConnectionRequirements
Text
HashMap ConnectionPropertyKey Text
ConnectionType
connectionProperties :: HashMap ConnectionPropertyKey Text
connectionType :: ConnectionType
name :: Text
physicalConnectionRequirements :: Maybe PhysicalConnectionRequirements
matchCriteria :: Maybe [Text]
description :: Maybe Text
$sel:connectionProperties:ConnectionInput' :: ConnectionInput -> HashMap ConnectionPropertyKey Text
$sel:connectionType:ConnectionInput' :: ConnectionInput -> ConnectionType
$sel:name:ConnectionInput' :: ConnectionInput -> Text
$sel:physicalConnectionRequirements:ConnectionInput' :: ConnectionInput -> Maybe PhysicalConnectionRequirements
$sel:matchCriteria:ConnectionInput' :: ConnectionInput -> Maybe [Text]
$sel:description:ConnectionInput' :: ConnectionInput -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
matchCriteria
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PhysicalConnectionRequirements
physicalConnectionRequirements
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ConnectionType
connectionType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap ConnectionPropertyKey Text
connectionProperties

instance Data.ToJSON ConnectionInput where
  toJSON :: ConnectionInput -> Value
toJSON ConnectionInput' {Maybe [Text]
Maybe Text
Maybe PhysicalConnectionRequirements
Text
HashMap ConnectionPropertyKey Text
ConnectionType
connectionProperties :: HashMap ConnectionPropertyKey Text
connectionType :: ConnectionType
name :: Text
physicalConnectionRequirements :: Maybe PhysicalConnectionRequirements
matchCriteria :: Maybe [Text]
description :: Maybe Text
$sel:connectionProperties:ConnectionInput' :: ConnectionInput -> HashMap ConnectionPropertyKey Text
$sel:connectionType:ConnectionInput' :: ConnectionInput -> ConnectionType
$sel:name:ConnectionInput' :: ConnectionInput -> Text
$sel:physicalConnectionRequirements:ConnectionInput' :: ConnectionInput -> Maybe PhysicalConnectionRequirements
$sel:matchCriteria:ConnectionInput' :: ConnectionInput -> Maybe [Text]
$sel:description:ConnectionInput' :: ConnectionInput -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Key
"MatchCriteria" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
matchCriteria,
            (Key
"PhysicalConnectionRequirements" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PhysicalConnectionRequirements
physicalConnectionRequirements,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ConnectionType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ConnectionType
connectionType),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"ConnectionProperties"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= HashMap ConnectionPropertyKey Text
connectionProperties
              )
          ]
      )