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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies a JDBC data store to crawl.
--
-- /See:/ 'newJdbcTarget' smart constructor.
data JdbcTarget = JdbcTarget'
  { -- | The path of the JDBC target.
    JdbcTarget -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | The name of the connection to use to connect to the JDBC target.
    JdbcTarget -> Maybe Text
connectionName :: Prelude.Maybe Prelude.Text,
    -- | A list of glob patterns used to exclude from the crawl. For more
    -- information, see
    -- <https://docs.aws.amazon.com/glue/latest/dg/add-crawler.html Catalog Tables with a Crawler>.
    JdbcTarget -> Maybe [Text]
exclusions :: Prelude.Maybe [Prelude.Text]
  }
  deriving (JdbcTarget -> JdbcTarget -> Bool
(JdbcTarget -> JdbcTarget -> Bool)
-> (JdbcTarget -> JdbcTarget -> Bool) -> Eq JdbcTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JdbcTarget -> JdbcTarget -> Bool
$c/= :: JdbcTarget -> JdbcTarget -> Bool
== :: JdbcTarget -> JdbcTarget -> Bool
$c== :: JdbcTarget -> JdbcTarget -> Bool
Prelude.Eq, ReadPrec [JdbcTarget]
ReadPrec JdbcTarget
Int -> ReadS JdbcTarget
ReadS [JdbcTarget]
(Int -> ReadS JdbcTarget)
-> ReadS [JdbcTarget]
-> ReadPrec JdbcTarget
-> ReadPrec [JdbcTarget]
-> Read JdbcTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JdbcTarget]
$creadListPrec :: ReadPrec [JdbcTarget]
readPrec :: ReadPrec JdbcTarget
$creadPrec :: ReadPrec JdbcTarget
readList :: ReadS [JdbcTarget]
$creadList :: ReadS [JdbcTarget]
readsPrec :: Int -> ReadS JdbcTarget
$creadsPrec :: Int -> ReadS JdbcTarget
Prelude.Read, Int -> JdbcTarget -> ShowS
[JdbcTarget] -> ShowS
JdbcTarget -> String
(Int -> JdbcTarget -> ShowS)
-> (JdbcTarget -> String)
-> ([JdbcTarget] -> ShowS)
-> Show JdbcTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JdbcTarget] -> ShowS
$cshowList :: [JdbcTarget] -> ShowS
show :: JdbcTarget -> String
$cshow :: JdbcTarget -> String
showsPrec :: Int -> JdbcTarget -> ShowS
$cshowsPrec :: Int -> JdbcTarget -> ShowS
Prelude.Show, (forall x. JdbcTarget -> Rep JdbcTarget x)
-> (forall x. Rep JdbcTarget x -> JdbcTarget) -> Generic JdbcTarget
forall x. Rep JdbcTarget x -> JdbcTarget
forall x. JdbcTarget -> Rep JdbcTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JdbcTarget x -> JdbcTarget
$cfrom :: forall x. JdbcTarget -> Rep JdbcTarget x
Prelude.Generic)

-- |
-- Create a value of 'JdbcTarget' 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:
--
-- 'path', 'jdbcTarget_path' - The path of the JDBC target.
--
-- 'connectionName', 'jdbcTarget_connectionName' - The name of the connection to use to connect to the JDBC target.
--
-- 'exclusions', 'jdbcTarget_exclusions' - A list of glob patterns used to exclude from the crawl. For more
-- information, see
-- <https://docs.aws.amazon.com/glue/latest/dg/add-crawler.html Catalog Tables with a Crawler>.
newJdbcTarget ::
  JdbcTarget
newJdbcTarget :: JdbcTarget
newJdbcTarget =
  JdbcTarget' :: Maybe Text -> Maybe Text -> Maybe [Text] -> JdbcTarget
JdbcTarget'
    { $sel:path:JdbcTarget' :: Maybe Text
path = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionName:JdbcTarget' :: Maybe Text
connectionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:exclusions:JdbcTarget' :: Maybe [Text]
exclusions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The path of the JDBC target.
jdbcTarget_path :: Lens.Lens' JdbcTarget (Prelude.Maybe Prelude.Text)
jdbcTarget_path :: (Maybe Text -> f (Maybe Text)) -> JdbcTarget -> f JdbcTarget
jdbcTarget_path = (JdbcTarget -> Maybe Text)
-> (JdbcTarget -> Maybe Text -> JdbcTarget)
-> Lens JdbcTarget JdbcTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JdbcTarget' {Maybe Text
path :: Maybe Text
$sel:path:JdbcTarget' :: JdbcTarget -> Maybe Text
path} -> Maybe Text
path) (\s :: JdbcTarget
s@JdbcTarget' {} Maybe Text
a -> JdbcTarget
s {$sel:path:JdbcTarget' :: Maybe Text
path = Maybe Text
a} :: JdbcTarget)

-- | The name of the connection to use to connect to the JDBC target.
jdbcTarget_connectionName :: Lens.Lens' JdbcTarget (Prelude.Maybe Prelude.Text)
jdbcTarget_connectionName :: (Maybe Text -> f (Maybe Text)) -> JdbcTarget -> f JdbcTarget
jdbcTarget_connectionName = (JdbcTarget -> Maybe Text)
-> (JdbcTarget -> Maybe Text -> JdbcTarget)
-> Lens JdbcTarget JdbcTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JdbcTarget' {Maybe Text
connectionName :: Maybe Text
$sel:connectionName:JdbcTarget' :: JdbcTarget -> Maybe Text
connectionName} -> Maybe Text
connectionName) (\s :: JdbcTarget
s@JdbcTarget' {} Maybe Text
a -> JdbcTarget
s {$sel:connectionName:JdbcTarget' :: Maybe Text
connectionName = Maybe Text
a} :: JdbcTarget)

-- | A list of glob patterns used to exclude from the crawl. For more
-- information, see
-- <https://docs.aws.amazon.com/glue/latest/dg/add-crawler.html Catalog Tables with a Crawler>.
jdbcTarget_exclusions :: Lens.Lens' JdbcTarget (Prelude.Maybe [Prelude.Text])
jdbcTarget_exclusions :: (Maybe [Text] -> f (Maybe [Text])) -> JdbcTarget -> f JdbcTarget
jdbcTarget_exclusions = (JdbcTarget -> Maybe [Text])
-> (JdbcTarget -> Maybe [Text] -> JdbcTarget)
-> Lens JdbcTarget JdbcTarget (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JdbcTarget' {Maybe [Text]
exclusions :: Maybe [Text]
$sel:exclusions:JdbcTarget' :: JdbcTarget -> Maybe [Text]
exclusions} -> Maybe [Text]
exclusions) (\s :: JdbcTarget
s@JdbcTarget' {} Maybe [Text]
a -> JdbcTarget
s {$sel:exclusions:JdbcTarget' :: Maybe [Text]
exclusions = Maybe [Text]
a} :: JdbcTarget) ((Maybe [Text] -> f (Maybe [Text])) -> JdbcTarget -> f JdbcTarget)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> JdbcTarget
-> f JdbcTarget
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

instance Core.FromJSON JdbcTarget where
  parseJSON :: Value -> Parser JdbcTarget
parseJSON =
    String
-> (Object -> Parser JdbcTarget) -> Value -> Parser JdbcTarget
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"JdbcTarget"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe [Text] -> JdbcTarget
JdbcTarget'
            (Maybe Text -> Maybe Text -> Maybe [Text] -> JdbcTarget)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe [Text] -> JdbcTarget)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Path")
            Parser (Maybe Text -> Maybe [Text] -> JdbcTarget)
-> Parser (Maybe Text) -> Parser (Maybe [Text] -> JdbcTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConnectionName")
            Parser (Maybe [Text] -> JdbcTarget)
-> Parser (Maybe [Text]) -> Parser JdbcTarget
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Exclusions" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable JdbcTarget

instance Prelude.NFData JdbcTarget

instance Core.ToJSON JdbcTarget where
  toJSON :: JdbcTarget -> Value
toJSON JdbcTarget' {Maybe [Text]
Maybe Text
exclusions :: Maybe [Text]
connectionName :: Maybe Text
path :: Maybe Text
$sel:exclusions:JdbcTarget' :: JdbcTarget -> Maybe [Text]
$sel:connectionName:JdbcTarget' :: JdbcTarget -> Maybe Text
$sel:path:JdbcTarget' :: JdbcTarget -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Path" 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
path,
            (Text
"ConnectionName" 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
connectionName,
            (Text
"Exclusions" 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]
exclusions
          ]
      )