{-# 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.DataBrew.Types.DataCatalogOutput
-- 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.DataBrew.Types.DataCatalogOutput where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataBrew.Types.DatabaseTableOutputOptions
import Amazonka.DataBrew.Types.S3TableOutputOptions
import qualified Amazonka.Prelude as Prelude

-- | Represents options that specify how and where in the Glue Data Catalog
-- DataBrew writes the output generated by recipe jobs.
--
-- /See:/ 'newDataCatalogOutput' smart constructor.
data DataCatalogOutput = DataCatalogOutput'
  { -- | The unique identifier of the Amazon Web Services account that holds the
    -- Data Catalog that stores the data.
    DataCatalogOutput -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | Represents options that specify how and where DataBrew writes the
    -- database output generated by recipe jobs.
    DataCatalogOutput -> Maybe DatabaseTableOutputOptions
databaseOptions :: Prelude.Maybe DatabaseTableOutputOptions,
    -- | A value that, if true, means that any data in the location specified for
    -- output is overwritten with new output. Not supported with
    -- DatabaseOptions.
    DataCatalogOutput -> Maybe Bool
overwrite :: Prelude.Maybe Prelude.Bool,
    -- | Represents options that specify how and where DataBrew writes the Amazon
    -- S3 output generated by recipe jobs.
    DataCatalogOutput -> Maybe S3TableOutputOptions
s3Options :: Prelude.Maybe S3TableOutputOptions,
    -- | The name of a database in the Data Catalog.
    DataCatalogOutput -> Text
databaseName :: Prelude.Text,
    -- | The name of a table in the Data Catalog.
    DataCatalogOutput -> Text
tableName :: Prelude.Text
  }
  deriving (DataCatalogOutput -> DataCatalogOutput -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataCatalogOutput -> DataCatalogOutput -> Bool
$c/= :: DataCatalogOutput -> DataCatalogOutput -> Bool
== :: DataCatalogOutput -> DataCatalogOutput -> Bool
$c== :: DataCatalogOutput -> DataCatalogOutput -> Bool
Prelude.Eq, ReadPrec [DataCatalogOutput]
ReadPrec DataCatalogOutput
Int -> ReadS DataCatalogOutput
ReadS [DataCatalogOutput]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataCatalogOutput]
$creadListPrec :: ReadPrec [DataCatalogOutput]
readPrec :: ReadPrec DataCatalogOutput
$creadPrec :: ReadPrec DataCatalogOutput
readList :: ReadS [DataCatalogOutput]
$creadList :: ReadS [DataCatalogOutput]
readsPrec :: Int -> ReadS DataCatalogOutput
$creadsPrec :: Int -> ReadS DataCatalogOutput
Prelude.Read, Int -> DataCatalogOutput -> ShowS
[DataCatalogOutput] -> ShowS
DataCatalogOutput -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataCatalogOutput] -> ShowS
$cshowList :: [DataCatalogOutput] -> ShowS
show :: DataCatalogOutput -> String
$cshow :: DataCatalogOutput -> String
showsPrec :: Int -> DataCatalogOutput -> ShowS
$cshowsPrec :: Int -> DataCatalogOutput -> ShowS
Prelude.Show, forall x. Rep DataCatalogOutput x -> DataCatalogOutput
forall x. DataCatalogOutput -> Rep DataCatalogOutput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataCatalogOutput x -> DataCatalogOutput
$cfrom :: forall x. DataCatalogOutput -> Rep DataCatalogOutput x
Prelude.Generic)

-- |
-- Create a value of 'DataCatalogOutput' 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:
--
-- 'catalogId', 'dataCatalogOutput_catalogId' - The unique identifier of the Amazon Web Services account that holds the
-- Data Catalog that stores the data.
--
-- 'databaseOptions', 'dataCatalogOutput_databaseOptions' - Represents options that specify how and where DataBrew writes the
-- database output generated by recipe jobs.
--
-- 'overwrite', 'dataCatalogOutput_overwrite' - A value that, if true, means that any data in the location specified for
-- output is overwritten with new output. Not supported with
-- DatabaseOptions.
--
-- 's3Options', 'dataCatalogOutput_s3Options' - Represents options that specify how and where DataBrew writes the Amazon
-- S3 output generated by recipe jobs.
--
-- 'databaseName', 'dataCatalogOutput_databaseName' - The name of a database in the Data Catalog.
--
-- 'tableName', 'dataCatalogOutput_tableName' - The name of a table in the Data Catalog.
newDataCatalogOutput ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'tableName'
  Prelude.Text ->
  DataCatalogOutput
newDataCatalogOutput :: Text -> Text -> DataCatalogOutput
newDataCatalogOutput Text
pDatabaseName_ Text
pTableName_ =
  DataCatalogOutput'
    { $sel:catalogId:DataCatalogOutput' :: Maybe Text
catalogId = forall a. Maybe a
Prelude.Nothing,
      $sel:databaseOptions:DataCatalogOutput' :: Maybe DatabaseTableOutputOptions
databaseOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:overwrite:DataCatalogOutput' :: Maybe Bool
overwrite = forall a. Maybe a
Prelude.Nothing,
      $sel:s3Options:DataCatalogOutput' :: Maybe S3TableOutputOptions
s3Options = forall a. Maybe a
Prelude.Nothing,
      $sel:databaseName:DataCatalogOutput' :: Text
databaseName = Text
pDatabaseName_,
      $sel:tableName:DataCatalogOutput' :: Text
tableName = Text
pTableName_
    }

-- | The unique identifier of the Amazon Web Services account that holds the
-- Data Catalog that stores the data.
dataCatalogOutput_catalogId :: Lens.Lens' DataCatalogOutput (Prelude.Maybe Prelude.Text)
dataCatalogOutput_catalogId :: Lens' DataCatalogOutput (Maybe Text)
dataCatalogOutput_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataCatalogOutput' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:DataCatalogOutput' :: DataCatalogOutput -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: DataCatalogOutput
s@DataCatalogOutput' {} Maybe Text
a -> DataCatalogOutput
s {$sel:catalogId:DataCatalogOutput' :: Maybe Text
catalogId = Maybe Text
a} :: DataCatalogOutput)

-- | Represents options that specify how and where DataBrew writes the
-- database output generated by recipe jobs.
dataCatalogOutput_databaseOptions :: Lens.Lens' DataCatalogOutput (Prelude.Maybe DatabaseTableOutputOptions)
dataCatalogOutput_databaseOptions :: Lens' DataCatalogOutput (Maybe DatabaseTableOutputOptions)
dataCatalogOutput_databaseOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataCatalogOutput' {Maybe DatabaseTableOutputOptions
databaseOptions :: Maybe DatabaseTableOutputOptions
$sel:databaseOptions:DataCatalogOutput' :: DataCatalogOutput -> Maybe DatabaseTableOutputOptions
databaseOptions} -> Maybe DatabaseTableOutputOptions
databaseOptions) (\s :: DataCatalogOutput
s@DataCatalogOutput' {} Maybe DatabaseTableOutputOptions
a -> DataCatalogOutput
s {$sel:databaseOptions:DataCatalogOutput' :: Maybe DatabaseTableOutputOptions
databaseOptions = Maybe DatabaseTableOutputOptions
a} :: DataCatalogOutput)

-- | A value that, if true, means that any data in the location specified for
-- output is overwritten with new output. Not supported with
-- DatabaseOptions.
dataCatalogOutput_overwrite :: Lens.Lens' DataCatalogOutput (Prelude.Maybe Prelude.Bool)
dataCatalogOutput_overwrite :: Lens' DataCatalogOutput (Maybe Bool)
dataCatalogOutput_overwrite = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataCatalogOutput' {Maybe Bool
overwrite :: Maybe Bool
$sel:overwrite:DataCatalogOutput' :: DataCatalogOutput -> Maybe Bool
overwrite} -> Maybe Bool
overwrite) (\s :: DataCatalogOutput
s@DataCatalogOutput' {} Maybe Bool
a -> DataCatalogOutput
s {$sel:overwrite:DataCatalogOutput' :: Maybe Bool
overwrite = Maybe Bool
a} :: DataCatalogOutput)

-- | Represents options that specify how and where DataBrew writes the Amazon
-- S3 output generated by recipe jobs.
dataCatalogOutput_s3Options :: Lens.Lens' DataCatalogOutput (Prelude.Maybe S3TableOutputOptions)
dataCatalogOutput_s3Options :: Lens' DataCatalogOutput (Maybe S3TableOutputOptions)
dataCatalogOutput_s3Options = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataCatalogOutput' {Maybe S3TableOutputOptions
s3Options :: Maybe S3TableOutputOptions
$sel:s3Options:DataCatalogOutput' :: DataCatalogOutput -> Maybe S3TableOutputOptions
s3Options} -> Maybe S3TableOutputOptions
s3Options) (\s :: DataCatalogOutput
s@DataCatalogOutput' {} Maybe S3TableOutputOptions
a -> DataCatalogOutput
s {$sel:s3Options:DataCatalogOutput' :: Maybe S3TableOutputOptions
s3Options = Maybe S3TableOutputOptions
a} :: DataCatalogOutput)

-- | The name of a database in the Data Catalog.
dataCatalogOutput_databaseName :: Lens.Lens' DataCatalogOutput Prelude.Text
dataCatalogOutput_databaseName :: Lens' DataCatalogOutput Text
dataCatalogOutput_databaseName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataCatalogOutput' {Text
databaseName :: Text
$sel:databaseName:DataCatalogOutput' :: DataCatalogOutput -> Text
databaseName} -> Text
databaseName) (\s :: DataCatalogOutput
s@DataCatalogOutput' {} Text
a -> DataCatalogOutput
s {$sel:databaseName:DataCatalogOutput' :: Text
databaseName = Text
a} :: DataCatalogOutput)

-- | The name of a table in the Data Catalog.
dataCatalogOutput_tableName :: Lens.Lens' DataCatalogOutput Prelude.Text
dataCatalogOutput_tableName :: Lens' DataCatalogOutput Text
dataCatalogOutput_tableName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataCatalogOutput' {Text
tableName :: Text
$sel:tableName:DataCatalogOutput' :: DataCatalogOutput -> Text
tableName} -> Text
tableName) (\s :: DataCatalogOutput
s@DataCatalogOutput' {} Text
a -> DataCatalogOutput
s {$sel:tableName:DataCatalogOutput' :: Text
tableName = Text
a} :: DataCatalogOutput)

instance Data.FromJSON DataCatalogOutput where
  parseJSON :: Value -> Parser DataCatalogOutput
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataCatalogOutput"
      ( \Object
x ->
          Maybe Text
-> Maybe DatabaseTableOutputOptions
-> Maybe Bool
-> Maybe S3TableOutputOptions
-> Text
-> Text
-> DataCatalogOutput
DataCatalogOutput'
            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
"CatalogId")
            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
"DatabaseOptions")
            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
"Overwrite")
            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
"S3Options")
            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
"TableName")
      )

instance Prelude.Hashable DataCatalogOutput where
  hashWithSalt :: Int -> DataCatalogOutput -> Int
hashWithSalt Int
_salt DataCatalogOutput' {Maybe Bool
Maybe Text
Maybe DatabaseTableOutputOptions
Maybe S3TableOutputOptions
Text
tableName :: Text
databaseName :: Text
s3Options :: Maybe S3TableOutputOptions
overwrite :: Maybe Bool
databaseOptions :: Maybe DatabaseTableOutputOptions
catalogId :: Maybe Text
$sel:tableName:DataCatalogOutput' :: DataCatalogOutput -> Text
$sel:databaseName:DataCatalogOutput' :: DataCatalogOutput -> Text
$sel:s3Options:DataCatalogOutput' :: DataCatalogOutput -> Maybe S3TableOutputOptions
$sel:overwrite:DataCatalogOutput' :: DataCatalogOutput -> Maybe Bool
$sel:databaseOptions:DataCatalogOutput' :: DataCatalogOutput -> Maybe DatabaseTableOutputOptions
$sel:catalogId:DataCatalogOutput' :: DataCatalogOutput -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
catalogId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DatabaseTableOutputOptions
databaseOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
overwrite
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3TableOutputOptions
s3Options
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
databaseName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tableName

instance Prelude.NFData DataCatalogOutput where
  rnf :: DataCatalogOutput -> ()
rnf DataCatalogOutput' {Maybe Bool
Maybe Text
Maybe DatabaseTableOutputOptions
Maybe S3TableOutputOptions
Text
tableName :: Text
databaseName :: Text
s3Options :: Maybe S3TableOutputOptions
overwrite :: Maybe Bool
databaseOptions :: Maybe DatabaseTableOutputOptions
catalogId :: Maybe Text
$sel:tableName:DataCatalogOutput' :: DataCatalogOutput -> Text
$sel:databaseName:DataCatalogOutput' :: DataCatalogOutput -> Text
$sel:s3Options:DataCatalogOutput' :: DataCatalogOutput -> Maybe S3TableOutputOptions
$sel:overwrite:DataCatalogOutput' :: DataCatalogOutput -> Maybe Bool
$sel:databaseOptions:DataCatalogOutput' :: DataCatalogOutput -> Maybe DatabaseTableOutputOptions
$sel:catalogId:DataCatalogOutput' :: DataCatalogOutput -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
catalogId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DatabaseTableOutputOptions
databaseOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
overwrite
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe S3TableOutputOptions
s3Options
      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 Text
tableName

instance Data.ToJSON DataCatalogOutput where
  toJSON :: DataCatalogOutput -> Value
toJSON DataCatalogOutput' {Maybe Bool
Maybe Text
Maybe DatabaseTableOutputOptions
Maybe S3TableOutputOptions
Text
tableName :: Text
databaseName :: Text
s3Options :: Maybe S3TableOutputOptions
overwrite :: Maybe Bool
databaseOptions :: Maybe DatabaseTableOutputOptions
catalogId :: Maybe Text
$sel:tableName:DataCatalogOutput' :: DataCatalogOutput -> Text
$sel:databaseName:DataCatalogOutput' :: DataCatalogOutput -> Text
$sel:s3Options:DataCatalogOutput' :: DataCatalogOutput -> Maybe S3TableOutputOptions
$sel:overwrite:DataCatalogOutput' :: DataCatalogOutput -> Maybe Bool
$sel:databaseOptions:DataCatalogOutput' :: DataCatalogOutput -> Maybe DatabaseTableOutputOptions
$sel:catalogId:DataCatalogOutput' :: DataCatalogOutput -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CatalogId" 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
catalogId,
            (Key
"DatabaseOptions" 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 DatabaseTableOutputOptions
databaseOptions,
            (Key
"Overwrite" 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 Bool
overwrite,
            (Key
"S3Options" 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 S3TableOutputOptions
s3Options,
            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
"TableName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tableName)
          ]
      )