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

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.ConnectionPropertyKey
import Amazonka.Glue.Types.ConnectionType
import Amazonka.Glue.Types.PhysicalConnectionRequirements
import qualified Amazonka.Lens as Lens
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'
  { -- | 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 description of the connection.
    ConnectionInput -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | 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
(ConnectionInput -> ConnectionInput -> Bool)
-> (ConnectionInput -> ConnectionInput -> Bool)
-> Eq ConnectionInput
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]
(Int -> ReadS ConnectionInput)
-> ReadS [ConnectionInput]
-> ReadPrec ConnectionInput
-> ReadPrec [ConnectionInput]
-> Read 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
(Int -> ConnectionInput -> ShowS)
-> (ConnectionInput -> String)
-> ([ConnectionInput] -> ShowS)
-> Show ConnectionInput
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. ConnectionInput -> Rep ConnectionInput x)
-> (forall x. Rep ConnectionInput x -> ConnectionInput)
-> Generic ConnectionInput
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:
--
-- '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.
--
-- 'description', 'connectionInput_description' - The description of the 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' :: Maybe [Text]
-> Maybe PhysicalConnectionRequirements
-> Maybe Text
-> Text
-> ConnectionType
-> HashMap ConnectionPropertyKey Text
-> ConnectionInput
ConnectionInput'
    { $sel:matchCriteria:ConnectionInput' :: Maybe [Text]
matchCriteria = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:physicalConnectionRequirements:ConnectionInput' :: Maybe PhysicalConnectionRequirements
physicalConnectionRequirements = Maybe PhysicalConnectionRequirements
forall a. Maybe a
Prelude.Nothing,
      $sel:description:ConnectionInput' :: Maybe Text
description = Maybe Text
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 = HashMap ConnectionPropertyKey Text
forall a. Monoid a => a
Prelude.mempty
    }

-- | A list of criteria that can be used in selecting this connection.
connectionInput_matchCriteria :: Lens.Lens' ConnectionInput (Prelude.Maybe [Prelude.Text])
connectionInput_matchCriteria :: (Maybe [Text] -> f (Maybe [Text]))
-> ConnectionInput -> f ConnectionInput
connectionInput_matchCriteria = (ConnectionInput -> Maybe [Text])
-> (ConnectionInput -> Maybe [Text] -> ConnectionInput)
-> Lens
     ConnectionInput ConnectionInput (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> ConnectionInput -> f ConnectionInput)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ConnectionInput
-> f ConnectionInput
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: (Maybe PhysicalConnectionRequirements
 -> f (Maybe PhysicalConnectionRequirements))
-> ConnectionInput -> f ConnectionInput
connectionInput_physicalConnectionRequirements = (ConnectionInput -> Maybe PhysicalConnectionRequirements)
-> (ConnectionInput
    -> Maybe PhysicalConnectionRequirements -> ConnectionInput)
-> Lens
     ConnectionInput
     ConnectionInput
     (Maybe PhysicalConnectionRequirements)
     (Maybe 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 description of the connection.
connectionInput_description :: Lens.Lens' ConnectionInput (Prelude.Maybe Prelude.Text)
connectionInput_description :: (Maybe Text -> f (Maybe Text))
-> ConnectionInput -> f ConnectionInput
connectionInput_description = (ConnectionInput -> Maybe Text)
-> (ConnectionInput -> Maybe Text -> ConnectionInput)
-> Lens ConnectionInput ConnectionInput (Maybe Text) (Maybe Text)
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)

-- | The name of the connection.
connectionInput_name :: Lens.Lens' ConnectionInput Prelude.Text
connectionInput_name :: (Text -> f Text) -> ConnectionInput -> f ConnectionInput
connectionInput_name = (ConnectionInput -> Text)
-> (ConnectionInput -> Text -> ConnectionInput)
-> Lens ConnectionInput ConnectionInput Text Text
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 :: (ConnectionType -> f ConnectionType)
-> ConnectionInput -> f ConnectionInput
connectionInput_connectionType = (ConnectionInput -> ConnectionType)
-> (ConnectionInput -> ConnectionType -> ConnectionInput)
-> Lens
     ConnectionInput ConnectionInput ConnectionType 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 :: (HashMap ConnectionPropertyKey Text
 -> f (HashMap ConnectionPropertyKey Text))
-> ConnectionInput -> f ConnectionInput
connectionInput_connectionProperties = (ConnectionInput -> HashMap ConnectionPropertyKey Text)
-> (ConnectionInput
    -> HashMap ConnectionPropertyKey Text -> ConnectionInput)
-> Lens
     ConnectionInput
     ConnectionInput
     (HashMap ConnectionPropertyKey Text)
     (HashMap ConnectionPropertyKey Text)
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) ((HashMap ConnectionPropertyKey Text
  -> f (HashMap ConnectionPropertyKey Text))
 -> ConnectionInput -> f ConnectionInput)
-> ((HashMap ConnectionPropertyKey Text
     -> f (HashMap ConnectionPropertyKey Text))
    -> HashMap ConnectionPropertyKey Text
    -> f (HashMap ConnectionPropertyKey Text))
-> (HashMap ConnectionPropertyKey Text
    -> f (HashMap ConnectionPropertyKey Text))
-> ConnectionInput
-> f ConnectionInput
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap ConnectionPropertyKey Text
 -> f (HashMap ConnectionPropertyKey Text))
-> HashMap ConnectionPropertyKey Text
-> f (HashMap ConnectionPropertyKey Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable ConnectionInput

instance Prelude.NFData ConnectionInput

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