{-# 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.Firehose.Types.SchemaConfiguration
-- 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.Firehose.Types.SchemaConfiguration 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 schema to which you want Kinesis Data Firehose to
-- configure your data before it writes it to Amazon S3. This parameter is
-- required if @Enabled@ is set to true.
--
-- /See:/ 'newSchemaConfiguration' smart constructor.
data SchemaConfiguration = SchemaConfiguration'
  { -- | The ID of the Amazon Web Services Glue Data Catalog. If you don\'t
    -- supply this, the Amazon Web Services account ID is used by default.
    SchemaConfiguration -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | Specifies the name of the Amazon Web Services Glue database that
    -- contains the schema for the output data.
    --
    -- If the @SchemaConfiguration@ request parameter is used as part of
    -- invoking the @CreateDeliveryStream@ API, then the @DatabaseName@
    -- property is required and its value must be specified.
    SchemaConfiguration -> Maybe Text
databaseName :: Prelude.Maybe Prelude.Text,
    -- | If you don\'t specify an Amazon Web Services Region, the default is the
    -- current Region.
    SchemaConfiguration -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
    -- | The role that Kinesis Data Firehose can use to access Amazon Web
    -- Services Glue. This role must be in the same account you use for Kinesis
    -- Data Firehose. Cross-account roles aren\'t allowed.
    --
    -- If the @SchemaConfiguration@ request parameter is used as part of
    -- invoking the @CreateDeliveryStream@ API, then the @RoleARN@ property is
    -- required and its value must be specified.
    SchemaConfiguration -> Maybe Text
roleARN :: Prelude.Maybe Prelude.Text,
    -- | Specifies the Amazon Web Services Glue table that contains the column
    -- information that constitutes your data schema.
    --
    -- If the @SchemaConfiguration@ request parameter is used as part of
    -- invoking the @CreateDeliveryStream@ API, then the @TableName@ property
    -- is required and its value must be specified.
    SchemaConfiguration -> Maybe Text
tableName :: Prelude.Maybe Prelude.Text,
    -- | Specifies the table version for the output data schema. If you don\'t
    -- specify this version ID, or if you set it to @LATEST@, Kinesis Data
    -- Firehose uses the most recent version. This means that any updates to
    -- the table are automatically picked up.
    SchemaConfiguration -> Maybe Text
versionId :: Prelude.Maybe Prelude.Text
  }
  deriving (SchemaConfiguration -> SchemaConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SchemaConfiguration -> SchemaConfiguration -> Bool
$c/= :: SchemaConfiguration -> SchemaConfiguration -> Bool
== :: SchemaConfiguration -> SchemaConfiguration -> Bool
$c== :: SchemaConfiguration -> SchemaConfiguration -> Bool
Prelude.Eq, ReadPrec [SchemaConfiguration]
ReadPrec SchemaConfiguration
Int -> ReadS SchemaConfiguration
ReadS [SchemaConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SchemaConfiguration]
$creadListPrec :: ReadPrec [SchemaConfiguration]
readPrec :: ReadPrec SchemaConfiguration
$creadPrec :: ReadPrec SchemaConfiguration
readList :: ReadS [SchemaConfiguration]
$creadList :: ReadS [SchemaConfiguration]
readsPrec :: Int -> ReadS SchemaConfiguration
$creadsPrec :: Int -> ReadS SchemaConfiguration
Prelude.Read, Int -> SchemaConfiguration -> ShowS
[SchemaConfiguration] -> ShowS
SchemaConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SchemaConfiguration] -> ShowS
$cshowList :: [SchemaConfiguration] -> ShowS
show :: SchemaConfiguration -> String
$cshow :: SchemaConfiguration -> String
showsPrec :: Int -> SchemaConfiguration -> ShowS
$cshowsPrec :: Int -> SchemaConfiguration -> ShowS
Prelude.Show, forall x. Rep SchemaConfiguration x -> SchemaConfiguration
forall x. SchemaConfiguration -> Rep SchemaConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SchemaConfiguration x -> SchemaConfiguration
$cfrom :: forall x. SchemaConfiguration -> Rep SchemaConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SchemaConfiguration' 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', 'schemaConfiguration_catalogId' - The ID of the Amazon Web Services Glue Data Catalog. If you don\'t
-- supply this, the Amazon Web Services account ID is used by default.
--
-- 'databaseName', 'schemaConfiguration_databaseName' - Specifies the name of the Amazon Web Services Glue database that
-- contains the schema for the output data.
--
-- If the @SchemaConfiguration@ request parameter is used as part of
-- invoking the @CreateDeliveryStream@ API, then the @DatabaseName@
-- property is required and its value must be specified.
--
-- 'region', 'schemaConfiguration_region' - If you don\'t specify an Amazon Web Services Region, the default is the
-- current Region.
--
-- 'roleARN', 'schemaConfiguration_roleARN' - The role that Kinesis Data Firehose can use to access Amazon Web
-- Services Glue. This role must be in the same account you use for Kinesis
-- Data Firehose. Cross-account roles aren\'t allowed.
--
-- If the @SchemaConfiguration@ request parameter is used as part of
-- invoking the @CreateDeliveryStream@ API, then the @RoleARN@ property is
-- required and its value must be specified.
--
-- 'tableName', 'schemaConfiguration_tableName' - Specifies the Amazon Web Services Glue table that contains the column
-- information that constitutes your data schema.
--
-- If the @SchemaConfiguration@ request parameter is used as part of
-- invoking the @CreateDeliveryStream@ API, then the @TableName@ property
-- is required and its value must be specified.
--
-- 'versionId', 'schemaConfiguration_versionId' - Specifies the table version for the output data schema. If you don\'t
-- specify this version ID, or if you set it to @LATEST@, Kinesis Data
-- Firehose uses the most recent version. This means that any updates to
-- the table are automatically picked up.
newSchemaConfiguration ::
  SchemaConfiguration
newSchemaConfiguration :: SchemaConfiguration
newSchemaConfiguration =
  SchemaConfiguration'
    { $sel:catalogId:SchemaConfiguration' :: Maybe Text
catalogId = forall a. Maybe a
Prelude.Nothing,
      $sel:databaseName:SchemaConfiguration' :: Maybe Text
databaseName = forall a. Maybe a
Prelude.Nothing,
      $sel:region:SchemaConfiguration' :: Maybe Text
region = forall a. Maybe a
Prelude.Nothing,
      $sel:roleARN:SchemaConfiguration' :: Maybe Text
roleARN = forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:SchemaConfiguration' :: Maybe Text
tableName = forall a. Maybe a
Prelude.Nothing,
      $sel:versionId:SchemaConfiguration' :: Maybe Text
versionId = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the Amazon Web Services Glue Data Catalog. If you don\'t
-- supply this, the Amazon Web Services account ID is used by default.
schemaConfiguration_catalogId :: Lens.Lens' SchemaConfiguration (Prelude.Maybe Prelude.Text)
schemaConfiguration_catalogId :: Lens' SchemaConfiguration (Maybe Text)
schemaConfiguration_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaConfiguration' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: SchemaConfiguration
s@SchemaConfiguration' {} Maybe Text
a -> SchemaConfiguration
s {$sel:catalogId:SchemaConfiguration' :: Maybe Text
catalogId = Maybe Text
a} :: SchemaConfiguration)

-- | Specifies the name of the Amazon Web Services Glue database that
-- contains the schema for the output data.
--
-- If the @SchemaConfiguration@ request parameter is used as part of
-- invoking the @CreateDeliveryStream@ API, then the @DatabaseName@
-- property is required and its value must be specified.
schemaConfiguration_databaseName :: Lens.Lens' SchemaConfiguration (Prelude.Maybe Prelude.Text)
schemaConfiguration_databaseName :: Lens' SchemaConfiguration (Maybe Text)
schemaConfiguration_databaseName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaConfiguration' {Maybe Text
databaseName :: Maybe Text
$sel:databaseName:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
databaseName} -> Maybe Text
databaseName) (\s :: SchemaConfiguration
s@SchemaConfiguration' {} Maybe Text
a -> SchemaConfiguration
s {$sel:databaseName:SchemaConfiguration' :: Maybe Text
databaseName = Maybe Text
a} :: SchemaConfiguration)

-- | If you don\'t specify an Amazon Web Services Region, the default is the
-- current Region.
schemaConfiguration_region :: Lens.Lens' SchemaConfiguration (Prelude.Maybe Prelude.Text)
schemaConfiguration_region :: Lens' SchemaConfiguration (Maybe Text)
schemaConfiguration_region = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaConfiguration' {Maybe Text
region :: Maybe Text
$sel:region:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
region} -> Maybe Text
region) (\s :: SchemaConfiguration
s@SchemaConfiguration' {} Maybe Text
a -> SchemaConfiguration
s {$sel:region:SchemaConfiguration' :: Maybe Text
region = Maybe Text
a} :: SchemaConfiguration)

-- | The role that Kinesis Data Firehose can use to access Amazon Web
-- Services Glue. This role must be in the same account you use for Kinesis
-- Data Firehose. Cross-account roles aren\'t allowed.
--
-- If the @SchemaConfiguration@ request parameter is used as part of
-- invoking the @CreateDeliveryStream@ API, then the @RoleARN@ property is
-- required and its value must be specified.
schemaConfiguration_roleARN :: Lens.Lens' SchemaConfiguration (Prelude.Maybe Prelude.Text)
schemaConfiguration_roleARN :: Lens' SchemaConfiguration (Maybe Text)
schemaConfiguration_roleARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaConfiguration' {Maybe Text
roleARN :: Maybe Text
$sel:roleARN:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
roleARN} -> Maybe Text
roleARN) (\s :: SchemaConfiguration
s@SchemaConfiguration' {} Maybe Text
a -> SchemaConfiguration
s {$sel:roleARN:SchemaConfiguration' :: Maybe Text
roleARN = Maybe Text
a} :: SchemaConfiguration)

-- | Specifies the Amazon Web Services Glue table that contains the column
-- information that constitutes your data schema.
--
-- If the @SchemaConfiguration@ request parameter is used as part of
-- invoking the @CreateDeliveryStream@ API, then the @TableName@ property
-- is required and its value must be specified.
schemaConfiguration_tableName :: Lens.Lens' SchemaConfiguration (Prelude.Maybe Prelude.Text)
schemaConfiguration_tableName :: Lens' SchemaConfiguration (Maybe Text)
schemaConfiguration_tableName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaConfiguration' {Maybe Text
tableName :: Maybe Text
$sel:tableName:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
tableName} -> Maybe Text
tableName) (\s :: SchemaConfiguration
s@SchemaConfiguration' {} Maybe Text
a -> SchemaConfiguration
s {$sel:tableName:SchemaConfiguration' :: Maybe Text
tableName = Maybe Text
a} :: SchemaConfiguration)

-- | Specifies the table version for the output data schema. If you don\'t
-- specify this version ID, or if you set it to @LATEST@, Kinesis Data
-- Firehose uses the most recent version. This means that any updates to
-- the table are automatically picked up.
schemaConfiguration_versionId :: Lens.Lens' SchemaConfiguration (Prelude.Maybe Prelude.Text)
schemaConfiguration_versionId :: Lens' SchemaConfiguration (Maybe Text)
schemaConfiguration_versionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaConfiguration' {Maybe Text
versionId :: Maybe Text
$sel:versionId:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
versionId} -> Maybe Text
versionId) (\s :: SchemaConfiguration
s@SchemaConfiguration' {} Maybe Text
a -> SchemaConfiguration
s {$sel:versionId:SchemaConfiguration' :: Maybe Text
versionId = Maybe Text
a} :: SchemaConfiguration)

instance Data.FromJSON SchemaConfiguration where
  parseJSON :: Value -> Parser SchemaConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SchemaConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> SchemaConfiguration
SchemaConfiguration'
            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
"DatabaseName")
            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
"Region")
            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
"RoleARN")
            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
"TableName")
            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
"VersionId")
      )

instance Prelude.Hashable SchemaConfiguration where
  hashWithSalt :: Int -> SchemaConfiguration -> Int
hashWithSalt Int
_salt SchemaConfiguration' {Maybe Text
versionId :: Maybe Text
tableName :: Maybe Text
roleARN :: Maybe Text
region :: Maybe Text
databaseName :: Maybe Text
catalogId :: Maybe Text
$sel:versionId:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:tableName:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:roleARN:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:region:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:databaseName:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:catalogId:SchemaConfiguration' :: SchemaConfiguration -> 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 Text
databaseName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
region
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
tableName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
versionId

instance Prelude.NFData SchemaConfiguration where
  rnf :: SchemaConfiguration -> ()
rnf SchemaConfiguration' {Maybe Text
versionId :: Maybe Text
tableName :: Maybe Text
roleARN :: Maybe Text
region :: Maybe Text
databaseName :: Maybe Text
catalogId :: Maybe Text
$sel:versionId:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:tableName:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:roleARN:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:region:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:databaseName:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:catalogId:SchemaConfiguration' :: SchemaConfiguration -> 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 Text
databaseName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
region
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
tableName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
versionId

instance Data.ToJSON SchemaConfiguration where
  toJSON :: SchemaConfiguration -> Value
toJSON SchemaConfiguration' {Maybe Text
versionId :: Maybe Text
tableName :: Maybe Text
roleARN :: Maybe Text
region :: Maybe Text
databaseName :: Maybe Text
catalogId :: Maybe Text
$sel:versionId:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:tableName:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:roleARN:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:region:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:databaseName:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:catalogId:SchemaConfiguration' :: SchemaConfiguration -> 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
"DatabaseName" 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
databaseName,
            (Key
"Region" 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
region,
            (Key
"RoleARN" 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
roleARN,
            (Key
"TableName" 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
tableName,
            (Key
"VersionId" 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
versionId
          ]
      )