{-# 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.BasicCatalogTarget
-- 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.BasicCatalogTarget 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 a target that uses a Glue Data Catalog table.
--
-- /See:/ 'newBasicCatalogTarget' smart constructor.
data BasicCatalogTarget = BasicCatalogTarget'
  { -- | The name of your data target.
    BasicCatalogTarget -> Text
name :: Prelude.Text,
    -- | The nodes that are inputs to the data target.
    BasicCatalogTarget -> NonEmpty Text
inputs :: Prelude.NonEmpty Prelude.Text,
    -- | The database that contains the table you want to use as the target. This
    -- database must already exist in the Data Catalog.
    BasicCatalogTarget -> Text
database :: Prelude.Text,
    -- | The table that defines the schema of your output data. This table must
    -- already exist in the Data Catalog.
    BasicCatalogTarget -> Text
table :: Prelude.Text
  }
  deriving (BasicCatalogTarget -> BasicCatalogTarget -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BasicCatalogTarget -> BasicCatalogTarget -> Bool
$c/= :: BasicCatalogTarget -> BasicCatalogTarget -> Bool
== :: BasicCatalogTarget -> BasicCatalogTarget -> Bool
$c== :: BasicCatalogTarget -> BasicCatalogTarget -> Bool
Prelude.Eq, ReadPrec [BasicCatalogTarget]
ReadPrec BasicCatalogTarget
Int -> ReadS BasicCatalogTarget
ReadS [BasicCatalogTarget]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BasicCatalogTarget]
$creadListPrec :: ReadPrec [BasicCatalogTarget]
readPrec :: ReadPrec BasicCatalogTarget
$creadPrec :: ReadPrec BasicCatalogTarget
readList :: ReadS [BasicCatalogTarget]
$creadList :: ReadS [BasicCatalogTarget]
readsPrec :: Int -> ReadS BasicCatalogTarget
$creadsPrec :: Int -> ReadS BasicCatalogTarget
Prelude.Read, Int -> BasicCatalogTarget -> ShowS
[BasicCatalogTarget] -> ShowS
BasicCatalogTarget -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BasicCatalogTarget] -> ShowS
$cshowList :: [BasicCatalogTarget] -> ShowS
show :: BasicCatalogTarget -> String
$cshow :: BasicCatalogTarget -> String
showsPrec :: Int -> BasicCatalogTarget -> ShowS
$cshowsPrec :: Int -> BasicCatalogTarget -> ShowS
Prelude.Show, forall x. Rep BasicCatalogTarget x -> BasicCatalogTarget
forall x. BasicCatalogTarget -> Rep BasicCatalogTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BasicCatalogTarget x -> BasicCatalogTarget
$cfrom :: forall x. BasicCatalogTarget -> Rep BasicCatalogTarget x
Prelude.Generic)

-- |
-- Create a value of 'BasicCatalogTarget' 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:
--
-- 'name', 'basicCatalogTarget_name' - The name of your data target.
--
-- 'inputs', 'basicCatalogTarget_inputs' - The nodes that are inputs to the data target.
--
-- 'database', 'basicCatalogTarget_database' - The database that contains the table you want to use as the target. This
-- database must already exist in the Data Catalog.
--
-- 'table', 'basicCatalogTarget_table' - The table that defines the schema of your output data. This table must
-- already exist in the Data Catalog.
newBasicCatalogTarget ::
  -- | 'name'
  Prelude.Text ->
  -- | 'inputs'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'database'
  Prelude.Text ->
  -- | 'table'
  Prelude.Text ->
  BasicCatalogTarget
newBasicCatalogTarget :: Text -> NonEmpty Text -> Text -> Text -> BasicCatalogTarget
newBasicCatalogTarget
  Text
pName_
  NonEmpty Text
pInputs_
  Text
pDatabase_
  Text
pTable_ =
    BasicCatalogTarget'
      { $sel:name:BasicCatalogTarget' :: Text
name = Text
pName_,
        $sel:inputs:BasicCatalogTarget' :: NonEmpty Text
inputs = 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
pInputs_,
        $sel:database:BasicCatalogTarget' :: Text
database = Text
pDatabase_,
        $sel:table:BasicCatalogTarget' :: Text
table = Text
pTable_
      }

-- | The name of your data target.
basicCatalogTarget_name :: Lens.Lens' BasicCatalogTarget Prelude.Text
basicCatalogTarget_name :: Lens' BasicCatalogTarget Text
basicCatalogTarget_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BasicCatalogTarget' {Text
name :: Text
$sel:name:BasicCatalogTarget' :: BasicCatalogTarget -> Text
name} -> Text
name) (\s :: BasicCatalogTarget
s@BasicCatalogTarget' {} Text
a -> BasicCatalogTarget
s {$sel:name:BasicCatalogTarget' :: Text
name = Text
a} :: BasicCatalogTarget)

-- | The nodes that are inputs to the data target.
basicCatalogTarget_inputs :: Lens.Lens' BasicCatalogTarget (Prelude.NonEmpty Prelude.Text)
basicCatalogTarget_inputs :: Lens' BasicCatalogTarget (NonEmpty Text)
basicCatalogTarget_inputs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BasicCatalogTarget' {NonEmpty Text
inputs :: NonEmpty Text
$sel:inputs:BasicCatalogTarget' :: BasicCatalogTarget -> NonEmpty Text
inputs} -> NonEmpty Text
inputs) (\s :: BasicCatalogTarget
s@BasicCatalogTarget' {} NonEmpty Text
a -> BasicCatalogTarget
s {$sel:inputs:BasicCatalogTarget' :: NonEmpty Text
inputs = NonEmpty Text
a} :: BasicCatalogTarget) 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

-- | The database that contains the table you want to use as the target. This
-- database must already exist in the Data Catalog.
basicCatalogTarget_database :: Lens.Lens' BasicCatalogTarget Prelude.Text
basicCatalogTarget_database :: Lens' BasicCatalogTarget Text
basicCatalogTarget_database = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BasicCatalogTarget' {Text
database :: Text
$sel:database:BasicCatalogTarget' :: BasicCatalogTarget -> Text
database} -> Text
database) (\s :: BasicCatalogTarget
s@BasicCatalogTarget' {} Text
a -> BasicCatalogTarget
s {$sel:database:BasicCatalogTarget' :: Text
database = Text
a} :: BasicCatalogTarget)

-- | The table that defines the schema of your output data. This table must
-- already exist in the Data Catalog.
basicCatalogTarget_table :: Lens.Lens' BasicCatalogTarget Prelude.Text
basicCatalogTarget_table :: Lens' BasicCatalogTarget Text
basicCatalogTarget_table = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BasicCatalogTarget' {Text
table :: Text
$sel:table:BasicCatalogTarget' :: BasicCatalogTarget -> Text
table} -> Text
table) (\s :: BasicCatalogTarget
s@BasicCatalogTarget' {} Text
a -> BasicCatalogTarget
s {$sel:table:BasicCatalogTarget' :: Text
table = Text
a} :: BasicCatalogTarget)

instance Data.FromJSON BasicCatalogTarget where
  parseJSON :: Value -> Parser BasicCatalogTarget
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BasicCatalogTarget"
      ( \Object
x ->
          Text -> NonEmpty Text -> Text -> Text -> BasicCatalogTarget
BasicCatalogTarget'
            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
"Name")
            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
"Inputs")
            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
"Database")
            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
"Table")
      )

instance Prelude.Hashable BasicCatalogTarget where
  hashWithSalt :: Int -> BasicCatalogTarget -> Int
hashWithSalt Int
_salt BasicCatalogTarget' {NonEmpty Text
Text
table :: Text
database :: Text
inputs :: NonEmpty Text
name :: Text
$sel:table:BasicCatalogTarget' :: BasicCatalogTarget -> Text
$sel:database:BasicCatalogTarget' :: BasicCatalogTarget -> Text
$sel:inputs:BasicCatalogTarget' :: BasicCatalogTarget -> NonEmpty Text
$sel:name:BasicCatalogTarget' :: BasicCatalogTarget -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
inputs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
database
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
table

instance Prelude.NFData BasicCatalogTarget where
  rnf :: BasicCatalogTarget -> ()
rnf BasicCatalogTarget' {NonEmpty Text
Text
table :: Text
database :: Text
inputs :: NonEmpty Text
name :: Text
$sel:table:BasicCatalogTarget' :: BasicCatalogTarget -> Text
$sel:database:BasicCatalogTarget' :: BasicCatalogTarget -> Text
$sel:inputs:BasicCatalogTarget' :: BasicCatalogTarget -> NonEmpty Text
$sel:name:BasicCatalogTarget' :: BasicCatalogTarget -> Text
..} =
    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 NonEmpty Text
inputs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
database
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
table

instance Data.ToJSON BasicCatalogTarget where
  toJSON :: BasicCatalogTarget -> Value
toJSON BasicCatalogTarget' {NonEmpty Text
Text
table :: Text
database :: Text
inputs :: NonEmpty Text
name :: Text
$sel:table:BasicCatalogTarget' :: BasicCatalogTarget -> Text
$sel:database:BasicCatalogTarget' :: BasicCatalogTarget -> Text
$sel:inputs:BasicCatalogTarget' :: BasicCatalogTarget -> NonEmpty Text
$sel:name:BasicCatalogTarget' :: BasicCatalogTarget -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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
"Inputs" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
inputs),
            forall a. a -> Maybe a
Prelude.Just (Key
"Database" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
database),
            forall a. a -> Maybe a
Prelude.Just (Key
"Table" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
table)
          ]
      )