{-# 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.IoTAnalytics.Types.GlueConfiguration
-- 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.IoTAnalytics.Types.GlueConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration information for coordination with Glue, a fully managed
-- extract, transform and load (ETL) service.
--
-- /See:/ 'newGlueConfiguration' smart constructor.
data GlueConfiguration = GlueConfiguration'
  { -- | The name of the table in your Glue Data Catalog that is used to perform
    -- the ETL operations. An Glue Data Catalog table contains partitioned data
    -- and descriptions of data sources and targets.
    GlueConfiguration -> Text
tableName :: Prelude.Text,
    -- | The name of the database in your Glue Data Catalog in which the table is
    -- located. An Glue Data Catalog database contains metadata tables.
    GlueConfiguration -> Text
databaseName :: Prelude.Text
  }
  deriving (GlueConfiguration -> GlueConfiguration -> Bool
(GlueConfiguration -> GlueConfiguration -> Bool)
-> (GlueConfiguration -> GlueConfiguration -> Bool)
-> Eq GlueConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GlueConfiguration -> GlueConfiguration -> Bool
$c/= :: GlueConfiguration -> GlueConfiguration -> Bool
== :: GlueConfiguration -> GlueConfiguration -> Bool
$c== :: GlueConfiguration -> GlueConfiguration -> Bool
Prelude.Eq, ReadPrec [GlueConfiguration]
ReadPrec GlueConfiguration
Int -> ReadS GlueConfiguration
ReadS [GlueConfiguration]
(Int -> ReadS GlueConfiguration)
-> ReadS [GlueConfiguration]
-> ReadPrec GlueConfiguration
-> ReadPrec [GlueConfiguration]
-> Read GlueConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GlueConfiguration]
$creadListPrec :: ReadPrec [GlueConfiguration]
readPrec :: ReadPrec GlueConfiguration
$creadPrec :: ReadPrec GlueConfiguration
readList :: ReadS [GlueConfiguration]
$creadList :: ReadS [GlueConfiguration]
readsPrec :: Int -> ReadS GlueConfiguration
$creadsPrec :: Int -> ReadS GlueConfiguration
Prelude.Read, Int -> GlueConfiguration -> ShowS
[GlueConfiguration] -> ShowS
GlueConfiguration -> String
(Int -> GlueConfiguration -> ShowS)
-> (GlueConfiguration -> String)
-> ([GlueConfiguration] -> ShowS)
-> Show GlueConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GlueConfiguration] -> ShowS
$cshowList :: [GlueConfiguration] -> ShowS
show :: GlueConfiguration -> String
$cshow :: GlueConfiguration -> String
showsPrec :: Int -> GlueConfiguration -> ShowS
$cshowsPrec :: Int -> GlueConfiguration -> ShowS
Prelude.Show, (forall x. GlueConfiguration -> Rep GlueConfiguration x)
-> (forall x. Rep GlueConfiguration x -> GlueConfiguration)
-> Generic GlueConfiguration
forall x. Rep GlueConfiguration x -> GlueConfiguration
forall x. GlueConfiguration -> Rep GlueConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GlueConfiguration x -> GlueConfiguration
$cfrom :: forall x. GlueConfiguration -> Rep GlueConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'GlueConfiguration' 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:
--
-- 'tableName', 'glueConfiguration_tableName' - The name of the table in your Glue Data Catalog that is used to perform
-- the ETL operations. An Glue Data Catalog table contains partitioned data
-- and descriptions of data sources and targets.
--
-- 'databaseName', 'glueConfiguration_databaseName' - The name of the database in your Glue Data Catalog in which the table is
-- located. An Glue Data Catalog database contains metadata tables.
newGlueConfiguration ::
  -- | 'tableName'
  Prelude.Text ->
  -- | 'databaseName'
  Prelude.Text ->
  GlueConfiguration
newGlueConfiguration :: Text -> Text -> GlueConfiguration
newGlueConfiguration Text
pTableName_ Text
pDatabaseName_ =
  GlueConfiguration' :: Text -> Text -> GlueConfiguration
GlueConfiguration'
    { $sel:tableName:GlueConfiguration' :: Text
tableName = Text
pTableName_,
      $sel:databaseName:GlueConfiguration' :: Text
databaseName = Text
pDatabaseName_
    }

-- | The name of the table in your Glue Data Catalog that is used to perform
-- the ETL operations. An Glue Data Catalog table contains partitioned data
-- and descriptions of data sources and targets.
glueConfiguration_tableName :: Lens.Lens' GlueConfiguration Prelude.Text
glueConfiguration_tableName :: (Text -> f Text) -> GlueConfiguration -> f GlueConfiguration
glueConfiguration_tableName = (GlueConfiguration -> Text)
-> (GlueConfiguration -> Text -> GlueConfiguration)
-> Lens GlueConfiguration GlueConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlueConfiguration' {Text
tableName :: Text
$sel:tableName:GlueConfiguration' :: GlueConfiguration -> Text
tableName} -> Text
tableName) (\s :: GlueConfiguration
s@GlueConfiguration' {} Text
a -> GlueConfiguration
s {$sel:tableName:GlueConfiguration' :: Text
tableName = Text
a} :: GlueConfiguration)

-- | The name of the database in your Glue Data Catalog in which the table is
-- located. An Glue Data Catalog database contains metadata tables.
glueConfiguration_databaseName :: Lens.Lens' GlueConfiguration Prelude.Text
glueConfiguration_databaseName :: (Text -> f Text) -> GlueConfiguration -> f GlueConfiguration
glueConfiguration_databaseName = (GlueConfiguration -> Text)
-> (GlueConfiguration -> Text -> GlueConfiguration)
-> Lens GlueConfiguration GlueConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlueConfiguration' {Text
databaseName :: Text
$sel:databaseName:GlueConfiguration' :: GlueConfiguration -> Text
databaseName} -> Text
databaseName) (\s :: GlueConfiguration
s@GlueConfiguration' {} Text
a -> GlueConfiguration
s {$sel:databaseName:GlueConfiguration' :: Text
databaseName = Text
a} :: GlueConfiguration)

instance Core.FromJSON GlueConfiguration where
  parseJSON :: Value -> Parser GlueConfiguration
parseJSON =
    String
-> (Object -> Parser GlueConfiguration)
-> Value
-> Parser GlueConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GlueConfiguration"
      ( \Object
x ->
          Text -> Text -> GlueConfiguration
GlueConfiguration'
            (Text -> Text -> GlueConfiguration)
-> Parser Text -> Parser (Text -> GlueConfiguration)
forall (f :: * -> *) a b. Functor 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")
            Parser (Text -> GlueConfiguration)
-> Parser Text -> Parser GlueConfiguration
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")
      )

instance Prelude.Hashable GlueConfiguration

instance Prelude.NFData GlueConfiguration

instance Core.ToJSON GlueConfiguration where
  toJSON :: GlueConfiguration -> Value
toJSON GlueConfiguration' {Text
databaseName :: Text
tableName :: Text
$sel:databaseName:GlueConfiguration' :: GlueConfiguration -> Text
$sel:tableName:GlueConfiguration' :: GlueConfiguration -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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),
            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)
          ]
      )