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

-- | Specifies an Glue Data Catalog target.
--
-- /See:/ 'newCatalogTarget' smart constructor.
data CatalogTarget = CatalogTarget'
  { -- | The name of the connection for an Amazon S3-backed Data Catalog table to
    -- be a target of the crawl when using a @Catalog@ connection type paired
    -- with a @NETWORK@ Connection type.
    CatalogTarget -> Maybe Text
connectionName :: Prelude.Maybe Prelude.Text,
    -- | A valid Amazon dead-letter SQS ARN. For example,
    -- @arn:aws:sqs:region:account:deadLetterQueue@.
    CatalogTarget -> Maybe Text
dlqEventQueueArn :: Prelude.Maybe Prelude.Text,
    -- | A valid Amazon SQS ARN. For example, @arn:aws:sqs:region:account:sqs@.
    CatalogTarget -> Maybe Text
eventQueueArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the database to be synchronized.
    CatalogTarget -> Text
databaseName :: Prelude.Text,
    -- | A list of the tables to be synchronized.
    CatalogTarget -> NonEmpty Text
tables :: Prelude.NonEmpty Prelude.Text
  }
  deriving (CatalogTarget -> CatalogTarget -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CatalogTarget -> CatalogTarget -> Bool
$c/= :: CatalogTarget -> CatalogTarget -> Bool
== :: CatalogTarget -> CatalogTarget -> Bool
$c== :: CatalogTarget -> CatalogTarget -> Bool
Prelude.Eq, ReadPrec [CatalogTarget]
ReadPrec CatalogTarget
Int -> ReadS CatalogTarget
ReadS [CatalogTarget]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CatalogTarget]
$creadListPrec :: ReadPrec [CatalogTarget]
readPrec :: ReadPrec CatalogTarget
$creadPrec :: ReadPrec CatalogTarget
readList :: ReadS [CatalogTarget]
$creadList :: ReadS [CatalogTarget]
readsPrec :: Int -> ReadS CatalogTarget
$creadsPrec :: Int -> ReadS CatalogTarget
Prelude.Read, Int -> CatalogTarget -> ShowS
[CatalogTarget] -> ShowS
CatalogTarget -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CatalogTarget] -> ShowS
$cshowList :: [CatalogTarget] -> ShowS
show :: CatalogTarget -> String
$cshow :: CatalogTarget -> String
showsPrec :: Int -> CatalogTarget -> ShowS
$cshowsPrec :: Int -> CatalogTarget -> ShowS
Prelude.Show, forall x. Rep CatalogTarget x -> CatalogTarget
forall x. CatalogTarget -> Rep CatalogTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CatalogTarget x -> CatalogTarget
$cfrom :: forall x. CatalogTarget -> Rep CatalogTarget x
Prelude.Generic)

-- |
-- Create a value of 'CatalogTarget' 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:
--
-- 'connectionName', 'catalogTarget_connectionName' - The name of the connection for an Amazon S3-backed Data Catalog table to
-- be a target of the crawl when using a @Catalog@ connection type paired
-- with a @NETWORK@ Connection type.
--
-- 'dlqEventQueueArn', 'catalogTarget_dlqEventQueueArn' - A valid Amazon dead-letter SQS ARN. For example,
-- @arn:aws:sqs:region:account:deadLetterQueue@.
--
-- 'eventQueueArn', 'catalogTarget_eventQueueArn' - A valid Amazon SQS ARN. For example, @arn:aws:sqs:region:account:sqs@.
--
-- 'databaseName', 'catalogTarget_databaseName' - The name of the database to be synchronized.
--
-- 'tables', 'catalogTarget_tables' - A list of the tables to be synchronized.
newCatalogTarget ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'tables'
  Prelude.NonEmpty Prelude.Text ->
  CatalogTarget
newCatalogTarget :: Text -> NonEmpty Text -> CatalogTarget
newCatalogTarget Text
pDatabaseName_ NonEmpty Text
pTables_ =
  CatalogTarget'
    { $sel:connectionName:CatalogTarget' :: Maybe Text
connectionName = forall a. Maybe a
Prelude.Nothing,
      $sel:dlqEventQueueArn:CatalogTarget' :: Maybe Text
dlqEventQueueArn = forall a. Maybe a
Prelude.Nothing,
      $sel:eventQueueArn:CatalogTarget' :: Maybe Text
eventQueueArn = forall a. Maybe a
Prelude.Nothing,
      $sel:databaseName:CatalogTarget' :: Text
databaseName = Text
pDatabaseName_,
      $sel:tables:CatalogTarget' :: NonEmpty Text
tables = 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
pTables_
    }

-- | The name of the connection for an Amazon S3-backed Data Catalog table to
-- be a target of the crawl when using a @Catalog@ connection type paired
-- with a @NETWORK@ Connection type.
catalogTarget_connectionName :: Lens.Lens' CatalogTarget (Prelude.Maybe Prelude.Text)
catalogTarget_connectionName :: Lens' CatalogTarget (Maybe Text)
catalogTarget_connectionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogTarget' {Maybe Text
connectionName :: Maybe Text
$sel:connectionName:CatalogTarget' :: CatalogTarget -> Maybe Text
connectionName} -> Maybe Text
connectionName) (\s :: CatalogTarget
s@CatalogTarget' {} Maybe Text
a -> CatalogTarget
s {$sel:connectionName:CatalogTarget' :: Maybe Text
connectionName = Maybe Text
a} :: CatalogTarget)

-- | A valid Amazon dead-letter SQS ARN. For example,
-- @arn:aws:sqs:region:account:deadLetterQueue@.
catalogTarget_dlqEventQueueArn :: Lens.Lens' CatalogTarget (Prelude.Maybe Prelude.Text)
catalogTarget_dlqEventQueueArn :: Lens' CatalogTarget (Maybe Text)
catalogTarget_dlqEventQueueArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogTarget' {Maybe Text
dlqEventQueueArn :: Maybe Text
$sel:dlqEventQueueArn:CatalogTarget' :: CatalogTarget -> Maybe Text
dlqEventQueueArn} -> Maybe Text
dlqEventQueueArn) (\s :: CatalogTarget
s@CatalogTarget' {} Maybe Text
a -> CatalogTarget
s {$sel:dlqEventQueueArn:CatalogTarget' :: Maybe Text
dlqEventQueueArn = Maybe Text
a} :: CatalogTarget)

-- | A valid Amazon SQS ARN. For example, @arn:aws:sqs:region:account:sqs@.
catalogTarget_eventQueueArn :: Lens.Lens' CatalogTarget (Prelude.Maybe Prelude.Text)
catalogTarget_eventQueueArn :: Lens' CatalogTarget (Maybe Text)
catalogTarget_eventQueueArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogTarget' {Maybe Text
eventQueueArn :: Maybe Text
$sel:eventQueueArn:CatalogTarget' :: CatalogTarget -> Maybe Text
eventQueueArn} -> Maybe Text
eventQueueArn) (\s :: CatalogTarget
s@CatalogTarget' {} Maybe Text
a -> CatalogTarget
s {$sel:eventQueueArn:CatalogTarget' :: Maybe Text
eventQueueArn = Maybe Text
a} :: CatalogTarget)

-- | The name of the database to be synchronized.
catalogTarget_databaseName :: Lens.Lens' CatalogTarget Prelude.Text
catalogTarget_databaseName :: Lens' CatalogTarget Text
catalogTarget_databaseName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogTarget' {Text
databaseName :: Text
$sel:databaseName:CatalogTarget' :: CatalogTarget -> Text
databaseName} -> Text
databaseName) (\s :: CatalogTarget
s@CatalogTarget' {} Text
a -> CatalogTarget
s {$sel:databaseName:CatalogTarget' :: Text
databaseName = Text
a} :: CatalogTarget)

-- | A list of the tables to be synchronized.
catalogTarget_tables :: Lens.Lens' CatalogTarget (Prelude.NonEmpty Prelude.Text)
catalogTarget_tables :: Lens' CatalogTarget (NonEmpty Text)
catalogTarget_tables = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogTarget' {NonEmpty Text
tables :: NonEmpty Text
$sel:tables:CatalogTarget' :: CatalogTarget -> NonEmpty Text
tables} -> NonEmpty Text
tables) (\s :: CatalogTarget
s@CatalogTarget' {} NonEmpty Text
a -> CatalogTarget
s {$sel:tables:CatalogTarget' :: NonEmpty Text
tables = NonEmpty Text
a} :: CatalogTarget) 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 CatalogTarget where
  parseJSON :: Value -> Parser CatalogTarget
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CatalogTarget"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> NonEmpty Text
-> CatalogTarget
CatalogTarget'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ConnectionName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DlqEventQueueArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"EventQueueArn")
            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
"DatabaseName")
            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
"Tables")
      )

instance Prelude.Hashable CatalogTarget where
  hashWithSalt :: Int -> CatalogTarget -> Int
hashWithSalt Int
_salt CatalogTarget' {Maybe Text
NonEmpty Text
Text
tables :: NonEmpty Text
databaseName :: Text
eventQueueArn :: Maybe Text
dlqEventQueueArn :: Maybe Text
connectionName :: Maybe Text
$sel:tables:CatalogTarget' :: CatalogTarget -> NonEmpty Text
$sel:databaseName:CatalogTarget' :: CatalogTarget -> Text
$sel:eventQueueArn:CatalogTarget' :: CatalogTarget -> Maybe Text
$sel:dlqEventQueueArn:CatalogTarget' :: CatalogTarget -> Maybe Text
$sel:connectionName:CatalogTarget' :: CatalogTarget -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
connectionName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dlqEventQueueArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
eventQueueArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
databaseName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
tables

instance Prelude.NFData CatalogTarget where
  rnf :: CatalogTarget -> ()
rnf CatalogTarget' {Maybe Text
NonEmpty Text
Text
tables :: NonEmpty Text
databaseName :: Text
eventQueueArn :: Maybe Text
dlqEventQueueArn :: Maybe Text
connectionName :: Maybe Text
$sel:tables:CatalogTarget' :: CatalogTarget -> NonEmpty Text
$sel:databaseName:CatalogTarget' :: CatalogTarget -> Text
$sel:eventQueueArn:CatalogTarget' :: CatalogTarget -> Maybe Text
$sel:dlqEventQueueArn:CatalogTarget' :: CatalogTarget -> Maybe Text
$sel:connectionName:CatalogTarget' :: CatalogTarget -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
connectionName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dlqEventQueueArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eventQueueArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
databaseName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
tables

instance Data.ToJSON CatalogTarget where
  toJSON :: CatalogTarget -> Value
toJSON CatalogTarget' {Maybe Text
NonEmpty Text
Text
tables :: NonEmpty Text
databaseName :: Text
eventQueueArn :: Maybe Text
dlqEventQueueArn :: Maybe Text
connectionName :: Maybe Text
$sel:tables:CatalogTarget' :: CatalogTarget -> NonEmpty Text
$sel:databaseName:CatalogTarget' :: CatalogTarget -> Text
$sel:eventQueueArn:CatalogTarget' :: CatalogTarget -> Maybe Text
$sel:dlqEventQueueArn:CatalogTarget' :: CatalogTarget -> Maybe Text
$sel:connectionName:CatalogTarget' :: CatalogTarget -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ConnectionName" 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
connectionName,
            (Key
"DlqEventQueueArn" 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
dlqEventQueueArn,
            (Key
"EventQueueArn" 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
eventQueueArn,
            forall a. a -> Maybe a
Prelude.Just (Key
"DatabaseName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
databaseName),
            forall a. a -> Maybe a
Prelude.Just (Key
"Tables" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
tables)
          ]
      )