{-# 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-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.Firehose.Types.SchemaConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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,
    -- | The ID of the AWS Glue Data Catalog. If you don\'t supply this, the AWS
    -- account ID is used by default.
    SchemaConfiguration -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | Specifies the name of the AWS 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 AWS Region, the default is the current Region.
    SchemaConfiguration -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
    -- | Specifies the AWS 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,
    -- | The role that Kinesis Data Firehose can use to access AWS 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
  }
  deriving (SchemaConfiguration -> SchemaConfiguration -> Bool
(SchemaConfiguration -> SchemaConfiguration -> Bool)
-> (SchemaConfiguration -> SchemaConfiguration -> Bool)
-> Eq SchemaConfiguration
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]
(Int -> ReadS SchemaConfiguration)
-> ReadS [SchemaConfiguration]
-> ReadPrec SchemaConfiguration
-> ReadPrec [SchemaConfiguration]
-> Read 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
(Int -> SchemaConfiguration -> ShowS)
-> (SchemaConfiguration -> String)
-> ([SchemaConfiguration] -> ShowS)
-> Show SchemaConfiguration
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. SchemaConfiguration -> Rep SchemaConfiguration x)
-> (forall x. Rep SchemaConfiguration x -> SchemaConfiguration)
-> Generic SchemaConfiguration
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:
--
-- '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.
--
-- 'catalogId', 'schemaConfiguration_catalogId' - The ID of the AWS Glue Data Catalog. If you don\'t supply this, the AWS
-- account ID is used by default.
--
-- 'databaseName', 'schemaConfiguration_databaseName' - Specifies the name of the AWS 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 AWS Region, the default is the current Region.
--
-- 'tableName', 'schemaConfiguration_tableName' - Specifies the AWS 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.
--
-- 'roleARN', 'schemaConfiguration_roleARN' - The role that Kinesis Data Firehose can use to access AWS 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.
newSchemaConfiguration ::
  SchemaConfiguration
newSchemaConfiguration :: SchemaConfiguration
newSchemaConfiguration =
  SchemaConfiguration' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> SchemaConfiguration
SchemaConfiguration'
    { $sel:versionId:SchemaConfiguration' :: Maybe Text
versionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:catalogId:SchemaConfiguration' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:databaseName:SchemaConfiguration' :: Maybe Text
databaseName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:region:SchemaConfiguration' :: Maybe Text
region = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:SchemaConfiguration' :: Maybe Text
tableName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:roleARN:SchemaConfiguration' :: Maybe Text
roleARN = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> SchemaConfiguration -> f SchemaConfiguration
schemaConfiguration_versionId = (SchemaConfiguration -> Maybe Text)
-> (SchemaConfiguration -> Maybe Text -> SchemaConfiguration)
-> Lens
     SchemaConfiguration SchemaConfiguration (Maybe Text) (Maybe Text)
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)

-- | The ID of the AWS Glue Data Catalog. If you don\'t supply this, the AWS
-- account ID is used by default.
schemaConfiguration_catalogId :: Lens.Lens' SchemaConfiguration (Prelude.Maybe Prelude.Text)
schemaConfiguration_catalogId :: (Maybe Text -> f (Maybe Text))
-> SchemaConfiguration -> f SchemaConfiguration
schemaConfiguration_catalogId = (SchemaConfiguration -> Maybe Text)
-> (SchemaConfiguration -> Maybe Text -> SchemaConfiguration)
-> Lens
     SchemaConfiguration SchemaConfiguration (Maybe Text) (Maybe Text)
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 AWS 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 :: (Maybe Text -> f (Maybe Text))
-> SchemaConfiguration -> f SchemaConfiguration
schemaConfiguration_databaseName = (SchemaConfiguration -> Maybe Text)
-> (SchemaConfiguration -> Maybe Text -> SchemaConfiguration)
-> Lens
     SchemaConfiguration SchemaConfiguration (Maybe Text) (Maybe Text)
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 AWS Region, the default is the current Region.
schemaConfiguration_region :: Lens.Lens' SchemaConfiguration (Prelude.Maybe Prelude.Text)
schemaConfiguration_region :: (Maybe Text -> f (Maybe Text))
-> SchemaConfiguration -> f SchemaConfiguration
schemaConfiguration_region = (SchemaConfiguration -> Maybe Text)
-> (SchemaConfiguration -> Maybe Text -> SchemaConfiguration)
-> Lens
     SchemaConfiguration SchemaConfiguration (Maybe Text) (Maybe Text)
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)

-- | Specifies the AWS 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 :: (Maybe Text -> f (Maybe Text))
-> SchemaConfiguration -> f SchemaConfiguration
schemaConfiguration_tableName = (SchemaConfiguration -> Maybe Text)
-> (SchemaConfiguration -> Maybe Text -> SchemaConfiguration)
-> Lens
     SchemaConfiguration SchemaConfiguration (Maybe Text) (Maybe Text)
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)

-- | The role that Kinesis Data Firehose can use to access AWS 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 :: (Maybe Text -> f (Maybe Text))
-> SchemaConfiguration -> f SchemaConfiguration
schemaConfiguration_roleARN = (SchemaConfiguration -> Maybe Text)
-> (SchemaConfiguration -> Maybe Text -> SchemaConfiguration)
-> Lens
     SchemaConfiguration SchemaConfiguration (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable SchemaConfiguration

instance Prelude.NFData SchemaConfiguration

instance Core.ToJSON SchemaConfiguration where
  toJSON :: SchemaConfiguration -> Value
toJSON SchemaConfiguration' {Maybe Text
roleARN :: Maybe Text
tableName :: Maybe Text
region :: Maybe Text
databaseName :: Maybe Text
catalogId :: Maybe Text
versionId :: Maybe Text
$sel:roleARN:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:tableName:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:region:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:databaseName:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:catalogId:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
$sel:versionId:SchemaConfiguration' :: SchemaConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"VersionId" 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
versionId,
            (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,
            (Text
"DatabaseName" 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
databaseName,
            (Text
"Region" 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
region,
            (Text
"TableName" 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
tableName,
            (Text
"RoleARN" 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
roleARN
          ]
      )