{-# 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.DataCatalogInputDefinition
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DataBrew.Types.DataCatalogInputDefinition where

import qualified Amazonka.Core as Core
import Amazonka.DataBrew.Types.S3Location
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents how metadata stored in the Glue Data Catalog is defined in a
-- DataBrew dataset.
--
-- /See:/ 'newDataCatalogInputDefinition' smart constructor.
data DataCatalogInputDefinition = DataCatalogInputDefinition'
  { -- | Represents an Amazon location where DataBrew can store intermediate
    -- results.
    DataCatalogInputDefinition -> Maybe S3Location
tempDirectory :: Prelude.Maybe S3Location,
    -- | The unique identifier of the Amazon Web Services account that holds the
    -- Data Catalog that stores the data.
    DataCatalogInputDefinition -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The name of a database in the Data Catalog.
    DataCatalogInputDefinition -> Text
databaseName :: Prelude.Text,
    -- | The name of a database table in the Data Catalog. This table corresponds
    -- to a DataBrew dataset.
    DataCatalogInputDefinition -> Text
tableName :: Prelude.Text
  }
  deriving (DataCatalogInputDefinition -> DataCatalogInputDefinition -> Bool
(DataCatalogInputDefinition -> DataCatalogInputDefinition -> Bool)
-> (DataCatalogInputDefinition
    -> DataCatalogInputDefinition -> Bool)
-> Eq DataCatalogInputDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataCatalogInputDefinition -> DataCatalogInputDefinition -> Bool
$c/= :: DataCatalogInputDefinition -> DataCatalogInputDefinition -> Bool
== :: DataCatalogInputDefinition -> DataCatalogInputDefinition -> Bool
$c== :: DataCatalogInputDefinition -> DataCatalogInputDefinition -> Bool
Prelude.Eq, ReadPrec [DataCatalogInputDefinition]
ReadPrec DataCatalogInputDefinition
Int -> ReadS DataCatalogInputDefinition
ReadS [DataCatalogInputDefinition]
(Int -> ReadS DataCatalogInputDefinition)
-> ReadS [DataCatalogInputDefinition]
-> ReadPrec DataCatalogInputDefinition
-> ReadPrec [DataCatalogInputDefinition]
-> Read DataCatalogInputDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataCatalogInputDefinition]
$creadListPrec :: ReadPrec [DataCatalogInputDefinition]
readPrec :: ReadPrec DataCatalogInputDefinition
$creadPrec :: ReadPrec DataCatalogInputDefinition
readList :: ReadS [DataCatalogInputDefinition]
$creadList :: ReadS [DataCatalogInputDefinition]
readsPrec :: Int -> ReadS DataCatalogInputDefinition
$creadsPrec :: Int -> ReadS DataCatalogInputDefinition
Prelude.Read, Int -> DataCatalogInputDefinition -> ShowS
[DataCatalogInputDefinition] -> ShowS
DataCatalogInputDefinition -> String
(Int -> DataCatalogInputDefinition -> ShowS)
-> (DataCatalogInputDefinition -> String)
-> ([DataCatalogInputDefinition] -> ShowS)
-> Show DataCatalogInputDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataCatalogInputDefinition] -> ShowS
$cshowList :: [DataCatalogInputDefinition] -> ShowS
show :: DataCatalogInputDefinition -> String
$cshow :: DataCatalogInputDefinition -> String
showsPrec :: Int -> DataCatalogInputDefinition -> ShowS
$cshowsPrec :: Int -> DataCatalogInputDefinition -> ShowS
Prelude.Show, (forall x.
 DataCatalogInputDefinition -> Rep DataCatalogInputDefinition x)
-> (forall x.
    Rep DataCatalogInputDefinition x -> DataCatalogInputDefinition)
-> Generic DataCatalogInputDefinition
forall x.
Rep DataCatalogInputDefinition x -> DataCatalogInputDefinition
forall x.
DataCatalogInputDefinition -> Rep DataCatalogInputDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DataCatalogInputDefinition x -> DataCatalogInputDefinition
$cfrom :: forall x.
DataCatalogInputDefinition -> Rep DataCatalogInputDefinition x
Prelude.Generic)

-- |
-- Create a value of 'DataCatalogInputDefinition' 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:
--
-- 'tempDirectory', 'dataCatalogInputDefinition_tempDirectory' - Represents an Amazon location where DataBrew can store intermediate
-- results.
--
-- 'catalogId', 'dataCatalogInputDefinition_catalogId' - The unique identifier of the Amazon Web Services account that holds the
-- Data Catalog that stores the data.
--
-- 'databaseName', 'dataCatalogInputDefinition_databaseName' - The name of a database in the Data Catalog.
--
-- 'tableName', 'dataCatalogInputDefinition_tableName' - The name of a database table in the Data Catalog. This table corresponds
-- to a DataBrew dataset.
newDataCatalogInputDefinition ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'tableName'
  Prelude.Text ->
  DataCatalogInputDefinition
newDataCatalogInputDefinition :: Text -> Text -> DataCatalogInputDefinition
newDataCatalogInputDefinition
  Text
pDatabaseName_
  Text
pTableName_ =
    DataCatalogInputDefinition' :: Maybe S3Location
-> Maybe Text -> Text -> Text -> DataCatalogInputDefinition
DataCatalogInputDefinition'
      { $sel:tempDirectory:DataCatalogInputDefinition' :: Maybe S3Location
tempDirectory =
          Maybe S3Location
forall a. Maybe a
Prelude.Nothing,
        $sel:catalogId:DataCatalogInputDefinition' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:databaseName:DataCatalogInputDefinition' :: Text
databaseName = Text
pDatabaseName_,
        $sel:tableName:DataCatalogInputDefinition' :: Text
tableName = Text
pTableName_
      }

-- | Represents an Amazon location where DataBrew can store intermediate
-- results.
dataCatalogInputDefinition_tempDirectory :: Lens.Lens' DataCatalogInputDefinition (Prelude.Maybe S3Location)
dataCatalogInputDefinition_tempDirectory :: (Maybe S3Location -> f (Maybe S3Location))
-> DataCatalogInputDefinition -> f DataCatalogInputDefinition
dataCatalogInputDefinition_tempDirectory = (DataCatalogInputDefinition -> Maybe S3Location)
-> (DataCatalogInputDefinition
    -> Maybe S3Location -> DataCatalogInputDefinition)
-> Lens
     DataCatalogInputDefinition
     DataCatalogInputDefinition
     (Maybe S3Location)
     (Maybe S3Location)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataCatalogInputDefinition' {Maybe S3Location
tempDirectory :: Maybe S3Location
$sel:tempDirectory:DataCatalogInputDefinition' :: DataCatalogInputDefinition -> Maybe S3Location
tempDirectory} -> Maybe S3Location
tempDirectory) (\s :: DataCatalogInputDefinition
s@DataCatalogInputDefinition' {} Maybe S3Location
a -> DataCatalogInputDefinition
s {$sel:tempDirectory:DataCatalogInputDefinition' :: Maybe S3Location
tempDirectory = Maybe S3Location
a} :: DataCatalogInputDefinition)

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

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

-- | The name of a database table in the Data Catalog. This table corresponds
-- to a DataBrew dataset.
dataCatalogInputDefinition_tableName :: Lens.Lens' DataCatalogInputDefinition Prelude.Text
dataCatalogInputDefinition_tableName :: (Text -> f Text)
-> DataCatalogInputDefinition -> f DataCatalogInputDefinition
dataCatalogInputDefinition_tableName = (DataCatalogInputDefinition -> Text)
-> (DataCatalogInputDefinition
    -> Text -> DataCatalogInputDefinition)
-> Lens
     DataCatalogInputDefinition DataCatalogInputDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataCatalogInputDefinition' {Text
tableName :: Text
$sel:tableName:DataCatalogInputDefinition' :: DataCatalogInputDefinition -> Text
tableName} -> Text
tableName) (\s :: DataCatalogInputDefinition
s@DataCatalogInputDefinition' {} Text
a -> DataCatalogInputDefinition
s {$sel:tableName:DataCatalogInputDefinition' :: Text
tableName = Text
a} :: DataCatalogInputDefinition)

instance Core.FromJSON DataCatalogInputDefinition where
  parseJSON :: Value -> Parser DataCatalogInputDefinition
parseJSON =
    String
-> (Object -> Parser DataCatalogInputDefinition)
-> Value
-> Parser DataCatalogInputDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DataCatalogInputDefinition"
      ( \Object
x ->
          Maybe S3Location
-> Maybe Text -> Text -> Text -> DataCatalogInputDefinition
DataCatalogInputDefinition'
            (Maybe S3Location
 -> Maybe Text -> Text -> Text -> DataCatalogInputDefinition)
-> Parser (Maybe S3Location)
-> Parser
     (Maybe Text -> Text -> Text -> DataCatalogInputDefinition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe S3Location)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TempDirectory")
            Parser (Maybe Text -> Text -> Text -> DataCatalogInputDefinition)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> DataCatalogInputDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CatalogId")
            Parser (Text -> Text -> DataCatalogInputDefinition)
-> Parser Text -> Parser (Text -> DataCatalogInputDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DatabaseName")
            Parser (Text -> DataCatalogInputDefinition)
-> Parser Text -> Parser DataCatalogInputDefinition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TableName")
      )

instance Prelude.Hashable DataCatalogInputDefinition

instance Prelude.NFData DataCatalogInputDefinition

instance Core.ToJSON DataCatalogInputDefinition where
  toJSON :: DataCatalogInputDefinition -> Value
toJSON DataCatalogInputDefinition' {Maybe Text
Maybe S3Location
Text
tableName :: Text
databaseName :: Text
catalogId :: Maybe Text
tempDirectory :: Maybe S3Location
$sel:tableName:DataCatalogInputDefinition' :: DataCatalogInputDefinition -> Text
$sel:databaseName:DataCatalogInputDefinition' :: DataCatalogInputDefinition -> Text
$sel:catalogId:DataCatalogInputDefinition' :: DataCatalogInputDefinition -> Maybe Text
$sel:tempDirectory:DataCatalogInputDefinition' :: DataCatalogInputDefinition -> Maybe S3Location
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TempDirectory" Text -> S3Location -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (S3Location -> Pair) -> Maybe S3Location -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3Location
tempDirectory,
            (Text
"CatalogId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
catalogId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DatabaseName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
databaseName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TableName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tableName)
          ]
      )