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

-- |
-- Create a value of 'MySQLCatalogTarget' 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', 'mySQLCatalogTarget_name' - The name of the data target.
--
-- 'inputs', 'mySQLCatalogTarget_inputs' - The nodes that are inputs to the data target.
--
-- 'database', 'mySQLCatalogTarget_database' - The name of the database to write to.
--
-- 'table', 'mySQLCatalogTarget_table' - The name of the table in the database to write to.
newMySQLCatalogTarget ::
  -- | 'name'
  Prelude.Text ->
  -- | 'inputs'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'database'
  Prelude.Text ->
  -- | 'table'
  Prelude.Text ->
  MySQLCatalogTarget
newMySQLCatalogTarget :: Text -> NonEmpty Text -> Text -> Text -> MySQLCatalogTarget
newMySQLCatalogTarget
  Text
pName_
  NonEmpty Text
pInputs_
  Text
pDatabase_
  Text
pTable_ =
    MySQLCatalogTarget'
      { $sel:name:MySQLCatalogTarget' :: Text
name = Text
pName_,
        $sel:inputs:MySQLCatalogTarget' :: 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:MySQLCatalogTarget' :: Text
database = Text
pDatabase_,
        $sel:table:MySQLCatalogTarget' :: Text
table = Text
pTable_
      }

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

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

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

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