{-# 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.OracleSQLCatalogTarget
-- 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.OracleSQLCatalogTarget 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 Oracle SQL.
--
-- /See:/ 'newOracleSQLCatalogTarget' smart constructor.
data OracleSQLCatalogTarget = OracleSQLCatalogTarget'
  { -- | The name of the data target.
    OracleSQLCatalogTarget -> Text
name :: Prelude.Text,
    -- | The nodes that are inputs to the data target.
    OracleSQLCatalogTarget -> NonEmpty Text
inputs :: Prelude.NonEmpty Prelude.Text,
    -- | The name of the database to write to.
    OracleSQLCatalogTarget -> Text
database :: Prelude.Text,
    -- | The name of the table in the database to write to.
    OracleSQLCatalogTarget -> Text
table :: Prelude.Text
  }
  deriving (OracleSQLCatalogTarget -> OracleSQLCatalogTarget -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OracleSQLCatalogTarget -> OracleSQLCatalogTarget -> Bool
$c/= :: OracleSQLCatalogTarget -> OracleSQLCatalogTarget -> Bool
== :: OracleSQLCatalogTarget -> OracleSQLCatalogTarget -> Bool
$c== :: OracleSQLCatalogTarget -> OracleSQLCatalogTarget -> Bool
Prelude.Eq, ReadPrec [OracleSQLCatalogTarget]
ReadPrec OracleSQLCatalogTarget
Int -> ReadS OracleSQLCatalogTarget
ReadS [OracleSQLCatalogTarget]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OracleSQLCatalogTarget]
$creadListPrec :: ReadPrec [OracleSQLCatalogTarget]
readPrec :: ReadPrec OracleSQLCatalogTarget
$creadPrec :: ReadPrec OracleSQLCatalogTarget
readList :: ReadS [OracleSQLCatalogTarget]
$creadList :: ReadS [OracleSQLCatalogTarget]
readsPrec :: Int -> ReadS OracleSQLCatalogTarget
$creadsPrec :: Int -> ReadS OracleSQLCatalogTarget
Prelude.Read, Int -> OracleSQLCatalogTarget -> ShowS
[OracleSQLCatalogTarget] -> ShowS
OracleSQLCatalogTarget -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OracleSQLCatalogTarget] -> ShowS
$cshowList :: [OracleSQLCatalogTarget] -> ShowS
show :: OracleSQLCatalogTarget -> String
$cshow :: OracleSQLCatalogTarget -> String
showsPrec :: Int -> OracleSQLCatalogTarget -> ShowS
$cshowsPrec :: Int -> OracleSQLCatalogTarget -> ShowS
Prelude.Show, forall x. Rep OracleSQLCatalogTarget x -> OracleSQLCatalogTarget
forall x. OracleSQLCatalogTarget -> Rep OracleSQLCatalogTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OracleSQLCatalogTarget x -> OracleSQLCatalogTarget
$cfrom :: forall x. OracleSQLCatalogTarget -> Rep OracleSQLCatalogTarget x
Prelude.Generic)

-- |
-- Create a value of 'OracleSQLCatalogTarget' 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', 'oracleSQLCatalogTarget_name' - The name of the data target.
--
-- 'inputs', 'oracleSQLCatalogTarget_inputs' - The nodes that are inputs to the data target.
--
-- 'database', 'oracleSQLCatalogTarget_database' - The name of the database to write to.
--
-- 'table', 'oracleSQLCatalogTarget_table' - The name of the table in the database to write to.
newOracleSQLCatalogTarget ::
  -- | 'name'
  Prelude.Text ->
  -- | 'inputs'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'database'
  Prelude.Text ->
  -- | 'table'
  Prelude.Text ->
  OracleSQLCatalogTarget
newOracleSQLCatalogTarget :: Text -> NonEmpty Text -> Text -> Text -> OracleSQLCatalogTarget
newOracleSQLCatalogTarget
  Text
pName_
  NonEmpty Text
pInputs_
  Text
pDatabase_
  Text
pTable_ =
    OracleSQLCatalogTarget'
      { $sel:name:OracleSQLCatalogTarget' :: Text
name = Text
pName_,
        $sel:inputs:OracleSQLCatalogTarget' :: 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:OracleSQLCatalogTarget' :: Text
database = Text
pDatabase_,
        $sel:table:OracleSQLCatalogTarget' :: Text
table = Text
pTable_
      }

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

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

-- | The name of the table in the database to write to.
oracleSQLCatalogTarget_table :: Lens.Lens' OracleSQLCatalogTarget Prelude.Text
oracleSQLCatalogTarget_table :: Lens' OracleSQLCatalogTarget Text
oracleSQLCatalogTarget_table = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OracleSQLCatalogTarget' {Text
table :: Text
$sel:table:OracleSQLCatalogTarget' :: OracleSQLCatalogTarget -> Text
table} -> Text
table) (\s :: OracleSQLCatalogTarget
s@OracleSQLCatalogTarget' {} Text
a -> OracleSQLCatalogTarget
s {$sel:table:OracleSQLCatalogTarget' :: Text
table = Text
a} :: OracleSQLCatalogTarget)

instance Data.FromJSON OracleSQLCatalogTarget where
  parseJSON :: Value -> Parser OracleSQLCatalogTarget
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OracleSQLCatalogTarget"
      ( \Object
x ->
          Text -> NonEmpty Text -> Text -> Text -> OracleSQLCatalogTarget
OracleSQLCatalogTarget'
            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 OracleSQLCatalogTarget where
  hashWithSalt :: Int -> OracleSQLCatalogTarget -> Int
hashWithSalt Int
_salt OracleSQLCatalogTarget' {NonEmpty Text
Text
table :: Text
database :: Text
inputs :: NonEmpty Text
name :: Text
$sel:table:OracleSQLCatalogTarget' :: OracleSQLCatalogTarget -> Text
$sel:database:OracleSQLCatalogTarget' :: OracleSQLCatalogTarget -> Text
$sel:inputs:OracleSQLCatalogTarget' :: OracleSQLCatalogTarget -> NonEmpty Text
$sel:name:OracleSQLCatalogTarget' :: OracleSQLCatalogTarget -> 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 OracleSQLCatalogTarget where
  rnf :: OracleSQLCatalogTarget -> ()
rnf OracleSQLCatalogTarget' {NonEmpty Text
Text
table :: Text
database :: Text
inputs :: NonEmpty Text
name :: Text
$sel:table:OracleSQLCatalogTarget' :: OracleSQLCatalogTarget -> Text
$sel:database:OracleSQLCatalogTarget' :: OracleSQLCatalogTarget -> Text
$sel:inputs:OracleSQLCatalogTarget' :: OracleSQLCatalogTarget -> NonEmpty Text
$sel:name:OracleSQLCatalogTarget' :: OracleSQLCatalogTarget -> 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 OracleSQLCatalogTarget where
  toJSON :: OracleSQLCatalogTarget -> Value
toJSON OracleSQLCatalogTarget' {NonEmpty Text
Text
table :: Text
database :: Text
inputs :: NonEmpty Text
name :: Text
$sel:table:OracleSQLCatalogTarget' :: OracleSQLCatalogTarget -> Text
$sel:database:OracleSQLCatalogTarget' :: OracleSQLCatalogTarget -> Text
$sel:inputs:OracleSQLCatalogTarget' :: OracleSQLCatalogTarget -> NonEmpty Text
$sel:name:OracleSQLCatalogTarget' :: OracleSQLCatalogTarget -> 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)
          ]
      )