{-# 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.AppFlow.Types.GlueDataCatalogConfig
-- 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.AppFlow.Types.GlueDataCatalogConfig 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 the configuration that Amazon AppFlow uses when it catalogs
-- your data with the Glue Data Catalog. When Amazon AppFlow catalogs your
-- data, it stores metadata in Data Catalog tables. This metadata
-- represents the data that\'s transferred by the flow that you configure
-- with these settings.
--
-- You can configure a flow with these settings only when the flow
-- destination is Amazon S3.
--
-- /See:/ 'newGlueDataCatalogConfig' smart constructor.
data GlueDataCatalogConfig = GlueDataCatalogConfig'
  { -- | The Amazon Resource Name (ARN) of an IAM role that grants Amazon AppFlow
    -- the permissions it needs to create Data Catalog tables, databases, and
    -- partitions.
    --
    -- For an example IAM policy that has the required permissions, see
    -- <https://docs.aws.amazon.com/appflow/latest/userguide/security_iam_id-based-policy-examples.html Identity-based policy examples for Amazon AppFlow>.
    GlueDataCatalogConfig -> Text
roleArn :: Prelude.Text,
    -- | The name of the Data Catalog database that stores the metadata tables
    -- that Amazon AppFlow creates in your Amazon Web Services account. These
    -- tables contain metadata for the data that\'s transferred by the flow
    -- that you configure with this parameter.
    --
    -- When you configure a new flow with this parameter, you must specify an
    -- existing database.
    GlueDataCatalogConfig -> Text
databaseName :: Prelude.Text,
    -- | A naming prefix for each Data Catalog table that Amazon AppFlow creates
    -- for the flow that you configure with this setting. Amazon AppFlow adds
    -- the prefix to the beginning of the each table name.
    GlueDataCatalogConfig -> Text
tablePrefix :: Prelude.Text
  }
  deriving (GlueDataCatalogConfig -> GlueDataCatalogConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GlueDataCatalogConfig -> GlueDataCatalogConfig -> Bool
$c/= :: GlueDataCatalogConfig -> GlueDataCatalogConfig -> Bool
== :: GlueDataCatalogConfig -> GlueDataCatalogConfig -> Bool
$c== :: GlueDataCatalogConfig -> GlueDataCatalogConfig -> Bool
Prelude.Eq, ReadPrec [GlueDataCatalogConfig]
ReadPrec GlueDataCatalogConfig
Int -> ReadS GlueDataCatalogConfig
ReadS [GlueDataCatalogConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GlueDataCatalogConfig]
$creadListPrec :: ReadPrec [GlueDataCatalogConfig]
readPrec :: ReadPrec GlueDataCatalogConfig
$creadPrec :: ReadPrec GlueDataCatalogConfig
readList :: ReadS [GlueDataCatalogConfig]
$creadList :: ReadS [GlueDataCatalogConfig]
readsPrec :: Int -> ReadS GlueDataCatalogConfig
$creadsPrec :: Int -> ReadS GlueDataCatalogConfig
Prelude.Read, Int -> GlueDataCatalogConfig -> ShowS
[GlueDataCatalogConfig] -> ShowS
GlueDataCatalogConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GlueDataCatalogConfig] -> ShowS
$cshowList :: [GlueDataCatalogConfig] -> ShowS
show :: GlueDataCatalogConfig -> String
$cshow :: GlueDataCatalogConfig -> String
showsPrec :: Int -> GlueDataCatalogConfig -> ShowS
$cshowsPrec :: Int -> GlueDataCatalogConfig -> ShowS
Prelude.Show, forall x. Rep GlueDataCatalogConfig x -> GlueDataCatalogConfig
forall x. GlueDataCatalogConfig -> Rep GlueDataCatalogConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GlueDataCatalogConfig x -> GlueDataCatalogConfig
$cfrom :: forall x. GlueDataCatalogConfig -> Rep GlueDataCatalogConfig x
Prelude.Generic)

-- |
-- Create a value of 'GlueDataCatalogConfig' 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:
--
-- 'roleArn', 'glueDataCatalogConfig_roleArn' - The Amazon Resource Name (ARN) of an IAM role that grants Amazon AppFlow
-- the permissions it needs to create Data Catalog tables, databases, and
-- partitions.
--
-- For an example IAM policy that has the required permissions, see
-- <https://docs.aws.amazon.com/appflow/latest/userguide/security_iam_id-based-policy-examples.html Identity-based policy examples for Amazon AppFlow>.
--
-- 'databaseName', 'glueDataCatalogConfig_databaseName' - The name of the Data Catalog database that stores the metadata tables
-- that Amazon AppFlow creates in your Amazon Web Services account. These
-- tables contain metadata for the data that\'s transferred by the flow
-- that you configure with this parameter.
--
-- When you configure a new flow with this parameter, you must specify an
-- existing database.
--
-- 'tablePrefix', 'glueDataCatalogConfig_tablePrefix' - A naming prefix for each Data Catalog table that Amazon AppFlow creates
-- for the flow that you configure with this setting. Amazon AppFlow adds
-- the prefix to the beginning of the each table name.
newGlueDataCatalogConfig ::
  -- | 'roleArn'
  Prelude.Text ->
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'tablePrefix'
  Prelude.Text ->
  GlueDataCatalogConfig
newGlueDataCatalogConfig :: Text -> Text -> Text -> GlueDataCatalogConfig
newGlueDataCatalogConfig
  Text
pRoleArn_
  Text
pDatabaseName_
  Text
pTablePrefix_ =
    GlueDataCatalogConfig'
      { $sel:roleArn:GlueDataCatalogConfig' :: Text
roleArn = Text
pRoleArn_,
        $sel:databaseName:GlueDataCatalogConfig' :: Text
databaseName = Text
pDatabaseName_,
        $sel:tablePrefix:GlueDataCatalogConfig' :: Text
tablePrefix = Text
pTablePrefix_
      }

-- | The Amazon Resource Name (ARN) of an IAM role that grants Amazon AppFlow
-- the permissions it needs to create Data Catalog tables, databases, and
-- partitions.
--
-- For an example IAM policy that has the required permissions, see
-- <https://docs.aws.amazon.com/appflow/latest/userguide/security_iam_id-based-policy-examples.html Identity-based policy examples for Amazon AppFlow>.
glueDataCatalogConfig_roleArn :: Lens.Lens' GlueDataCatalogConfig Prelude.Text
glueDataCatalogConfig_roleArn :: Lens' GlueDataCatalogConfig Text
glueDataCatalogConfig_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlueDataCatalogConfig' {Text
roleArn :: Text
$sel:roleArn:GlueDataCatalogConfig' :: GlueDataCatalogConfig -> Text
roleArn} -> Text
roleArn) (\s :: GlueDataCatalogConfig
s@GlueDataCatalogConfig' {} Text
a -> GlueDataCatalogConfig
s {$sel:roleArn:GlueDataCatalogConfig' :: Text
roleArn = Text
a} :: GlueDataCatalogConfig)

-- | The name of the Data Catalog database that stores the metadata tables
-- that Amazon AppFlow creates in your Amazon Web Services account. These
-- tables contain metadata for the data that\'s transferred by the flow
-- that you configure with this parameter.
--
-- When you configure a new flow with this parameter, you must specify an
-- existing database.
glueDataCatalogConfig_databaseName :: Lens.Lens' GlueDataCatalogConfig Prelude.Text
glueDataCatalogConfig_databaseName :: Lens' GlueDataCatalogConfig Text
glueDataCatalogConfig_databaseName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlueDataCatalogConfig' {Text
databaseName :: Text
$sel:databaseName:GlueDataCatalogConfig' :: GlueDataCatalogConfig -> Text
databaseName} -> Text
databaseName) (\s :: GlueDataCatalogConfig
s@GlueDataCatalogConfig' {} Text
a -> GlueDataCatalogConfig
s {$sel:databaseName:GlueDataCatalogConfig' :: Text
databaseName = Text
a} :: GlueDataCatalogConfig)

-- | A naming prefix for each Data Catalog table that Amazon AppFlow creates
-- for the flow that you configure with this setting. Amazon AppFlow adds
-- the prefix to the beginning of the each table name.
glueDataCatalogConfig_tablePrefix :: Lens.Lens' GlueDataCatalogConfig Prelude.Text
glueDataCatalogConfig_tablePrefix :: Lens' GlueDataCatalogConfig Text
glueDataCatalogConfig_tablePrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlueDataCatalogConfig' {Text
tablePrefix :: Text
$sel:tablePrefix:GlueDataCatalogConfig' :: GlueDataCatalogConfig -> Text
tablePrefix} -> Text
tablePrefix) (\s :: GlueDataCatalogConfig
s@GlueDataCatalogConfig' {} Text
a -> GlueDataCatalogConfig
s {$sel:tablePrefix:GlueDataCatalogConfig' :: Text
tablePrefix = Text
a} :: GlueDataCatalogConfig)

instance Data.FromJSON GlueDataCatalogConfig where
  parseJSON :: Value -> Parser GlueDataCatalogConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GlueDataCatalogConfig"
      ( \Object
x ->
          Text -> Text -> Text -> GlueDataCatalogConfig
GlueDataCatalogConfig'
            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
"roleArn")
            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
"tablePrefix")
      )

instance Prelude.Hashable GlueDataCatalogConfig where
  hashWithSalt :: Int -> GlueDataCatalogConfig -> Int
hashWithSalt Int
_salt GlueDataCatalogConfig' {Text
tablePrefix :: Text
databaseName :: Text
roleArn :: Text
$sel:tablePrefix:GlueDataCatalogConfig' :: GlueDataCatalogConfig -> Text
$sel:databaseName:GlueDataCatalogConfig' :: GlueDataCatalogConfig -> Text
$sel:roleArn:GlueDataCatalogConfig' :: GlueDataCatalogConfig -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
databaseName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tablePrefix

instance Prelude.NFData GlueDataCatalogConfig where
  rnf :: GlueDataCatalogConfig -> ()
rnf GlueDataCatalogConfig' {Text
tablePrefix :: Text
databaseName :: Text
roleArn :: Text
$sel:tablePrefix:GlueDataCatalogConfig' :: GlueDataCatalogConfig -> Text
$sel:databaseName:GlueDataCatalogConfig' :: GlueDataCatalogConfig -> Text
$sel:roleArn:GlueDataCatalogConfig' :: GlueDataCatalogConfig -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
roleArn
      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
tablePrefix

instance Data.ToJSON GlueDataCatalogConfig where
  toJSON :: GlueDataCatalogConfig -> Value
toJSON GlueDataCatalogConfig' {Text
tablePrefix :: Text
databaseName :: Text
roleArn :: Text
$sel:tablePrefix:GlueDataCatalogConfig' :: GlueDataCatalogConfig -> Text
$sel:databaseName:GlueDataCatalogConfig' :: GlueDataCatalogConfig -> Text
$sel:roleArn:GlueDataCatalogConfig' :: GlueDataCatalogConfig -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"roleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
roleArn),
            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
"tablePrefix" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tablePrefix)
          ]
      )