{-# 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.KinesisAnalytics.Types.InputSchemaUpdate
-- 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.KinesisAnalytics.Types.InputSchemaUpdate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KinesisAnalytics.Types.RecordColumn
import Amazonka.KinesisAnalytics.Types.RecordFormat
import qualified Amazonka.Prelude as Prelude

-- | Describes updates for the application\'s input schema.
--
-- /See:/ 'newInputSchemaUpdate' smart constructor.
data InputSchemaUpdate = InputSchemaUpdate'
  { -- | A list of @RecordColumn@ objects. Each object describes the mapping of
    -- the streaming source element to the corresponding column in the
    -- in-application stream.
    InputSchemaUpdate -> Maybe (NonEmpty RecordColumn)
recordColumnUpdates :: Prelude.Maybe (Prelude.NonEmpty RecordColumn),
    -- | Specifies the encoding of the records in the streaming source. For
    -- example, UTF-8.
    InputSchemaUpdate -> Maybe Text
recordEncodingUpdate :: Prelude.Maybe Prelude.Text,
    -- | Specifies the format of the records on the streaming source.
    InputSchemaUpdate -> Maybe RecordFormat
recordFormatUpdate :: Prelude.Maybe RecordFormat
  }
  deriving (InputSchemaUpdate -> InputSchemaUpdate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputSchemaUpdate -> InputSchemaUpdate -> Bool
$c/= :: InputSchemaUpdate -> InputSchemaUpdate -> Bool
== :: InputSchemaUpdate -> InputSchemaUpdate -> Bool
$c== :: InputSchemaUpdate -> InputSchemaUpdate -> Bool
Prelude.Eq, ReadPrec [InputSchemaUpdate]
ReadPrec InputSchemaUpdate
Int -> ReadS InputSchemaUpdate
ReadS [InputSchemaUpdate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputSchemaUpdate]
$creadListPrec :: ReadPrec [InputSchemaUpdate]
readPrec :: ReadPrec InputSchemaUpdate
$creadPrec :: ReadPrec InputSchemaUpdate
readList :: ReadS [InputSchemaUpdate]
$creadList :: ReadS [InputSchemaUpdate]
readsPrec :: Int -> ReadS InputSchemaUpdate
$creadsPrec :: Int -> ReadS InputSchemaUpdate
Prelude.Read, Int -> InputSchemaUpdate -> ShowS
[InputSchemaUpdate] -> ShowS
InputSchemaUpdate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputSchemaUpdate] -> ShowS
$cshowList :: [InputSchemaUpdate] -> ShowS
show :: InputSchemaUpdate -> String
$cshow :: InputSchemaUpdate -> String
showsPrec :: Int -> InputSchemaUpdate -> ShowS
$cshowsPrec :: Int -> InputSchemaUpdate -> ShowS
Prelude.Show, forall x. Rep InputSchemaUpdate x -> InputSchemaUpdate
forall x. InputSchemaUpdate -> Rep InputSchemaUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputSchemaUpdate x -> InputSchemaUpdate
$cfrom :: forall x. InputSchemaUpdate -> Rep InputSchemaUpdate x
Prelude.Generic)

-- |
-- Create a value of 'InputSchemaUpdate' 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:
--
-- 'recordColumnUpdates', 'inputSchemaUpdate_recordColumnUpdates' - A list of @RecordColumn@ objects. Each object describes the mapping of
-- the streaming source element to the corresponding column in the
-- in-application stream.
--
-- 'recordEncodingUpdate', 'inputSchemaUpdate_recordEncodingUpdate' - Specifies the encoding of the records in the streaming source. For
-- example, UTF-8.
--
-- 'recordFormatUpdate', 'inputSchemaUpdate_recordFormatUpdate' - Specifies the format of the records on the streaming source.
newInputSchemaUpdate ::
  InputSchemaUpdate
newInputSchemaUpdate :: InputSchemaUpdate
newInputSchemaUpdate =
  InputSchemaUpdate'
    { $sel:recordColumnUpdates:InputSchemaUpdate' :: Maybe (NonEmpty RecordColumn)
recordColumnUpdates =
        forall a. Maybe a
Prelude.Nothing,
      $sel:recordEncodingUpdate:InputSchemaUpdate' :: Maybe Text
recordEncodingUpdate = forall a. Maybe a
Prelude.Nothing,
      $sel:recordFormatUpdate:InputSchemaUpdate' :: Maybe RecordFormat
recordFormatUpdate = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of @RecordColumn@ objects. Each object describes the mapping of
-- the streaming source element to the corresponding column in the
-- in-application stream.
inputSchemaUpdate_recordColumnUpdates :: Lens.Lens' InputSchemaUpdate (Prelude.Maybe (Prelude.NonEmpty RecordColumn))
inputSchemaUpdate_recordColumnUpdates :: Lens' InputSchemaUpdate (Maybe (NonEmpty RecordColumn))
inputSchemaUpdate_recordColumnUpdates = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputSchemaUpdate' {Maybe (NonEmpty RecordColumn)
recordColumnUpdates :: Maybe (NonEmpty RecordColumn)
$sel:recordColumnUpdates:InputSchemaUpdate' :: InputSchemaUpdate -> Maybe (NonEmpty RecordColumn)
recordColumnUpdates} -> Maybe (NonEmpty RecordColumn)
recordColumnUpdates) (\s :: InputSchemaUpdate
s@InputSchemaUpdate' {} Maybe (NonEmpty RecordColumn)
a -> InputSchemaUpdate
s {$sel:recordColumnUpdates:InputSchemaUpdate' :: Maybe (NonEmpty RecordColumn)
recordColumnUpdates = Maybe (NonEmpty RecordColumn)
a} :: InputSchemaUpdate) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the encoding of the records in the streaming source. For
-- example, UTF-8.
inputSchemaUpdate_recordEncodingUpdate :: Lens.Lens' InputSchemaUpdate (Prelude.Maybe Prelude.Text)
inputSchemaUpdate_recordEncodingUpdate :: Lens' InputSchemaUpdate (Maybe Text)
inputSchemaUpdate_recordEncodingUpdate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputSchemaUpdate' {Maybe Text
recordEncodingUpdate :: Maybe Text
$sel:recordEncodingUpdate:InputSchemaUpdate' :: InputSchemaUpdate -> Maybe Text
recordEncodingUpdate} -> Maybe Text
recordEncodingUpdate) (\s :: InputSchemaUpdate
s@InputSchemaUpdate' {} Maybe Text
a -> InputSchemaUpdate
s {$sel:recordEncodingUpdate:InputSchemaUpdate' :: Maybe Text
recordEncodingUpdate = Maybe Text
a} :: InputSchemaUpdate)

-- | Specifies the format of the records on the streaming source.
inputSchemaUpdate_recordFormatUpdate :: Lens.Lens' InputSchemaUpdate (Prelude.Maybe RecordFormat)
inputSchemaUpdate_recordFormatUpdate :: Lens' InputSchemaUpdate (Maybe RecordFormat)
inputSchemaUpdate_recordFormatUpdate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputSchemaUpdate' {Maybe RecordFormat
recordFormatUpdate :: Maybe RecordFormat
$sel:recordFormatUpdate:InputSchemaUpdate' :: InputSchemaUpdate -> Maybe RecordFormat
recordFormatUpdate} -> Maybe RecordFormat
recordFormatUpdate) (\s :: InputSchemaUpdate
s@InputSchemaUpdate' {} Maybe RecordFormat
a -> InputSchemaUpdate
s {$sel:recordFormatUpdate:InputSchemaUpdate' :: Maybe RecordFormat
recordFormatUpdate = Maybe RecordFormat
a} :: InputSchemaUpdate)

instance Prelude.Hashable InputSchemaUpdate where
  hashWithSalt :: Int -> InputSchemaUpdate -> Int
hashWithSalt Int
_salt InputSchemaUpdate' {Maybe (NonEmpty RecordColumn)
Maybe Text
Maybe RecordFormat
recordFormatUpdate :: Maybe RecordFormat
recordEncodingUpdate :: Maybe Text
recordColumnUpdates :: Maybe (NonEmpty RecordColumn)
$sel:recordFormatUpdate:InputSchemaUpdate' :: InputSchemaUpdate -> Maybe RecordFormat
$sel:recordEncodingUpdate:InputSchemaUpdate' :: InputSchemaUpdate -> Maybe Text
$sel:recordColumnUpdates:InputSchemaUpdate' :: InputSchemaUpdate -> Maybe (NonEmpty RecordColumn)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty RecordColumn)
recordColumnUpdates
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
recordEncodingUpdate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RecordFormat
recordFormatUpdate

instance Prelude.NFData InputSchemaUpdate where
  rnf :: InputSchemaUpdate -> ()
rnf InputSchemaUpdate' {Maybe (NonEmpty RecordColumn)
Maybe Text
Maybe RecordFormat
recordFormatUpdate :: Maybe RecordFormat
recordEncodingUpdate :: Maybe Text
recordColumnUpdates :: Maybe (NonEmpty RecordColumn)
$sel:recordFormatUpdate:InputSchemaUpdate' :: InputSchemaUpdate -> Maybe RecordFormat
$sel:recordEncodingUpdate:InputSchemaUpdate' :: InputSchemaUpdate -> Maybe Text
$sel:recordColumnUpdates:InputSchemaUpdate' :: InputSchemaUpdate -> Maybe (NonEmpty RecordColumn)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty RecordColumn)
recordColumnUpdates
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
recordEncodingUpdate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RecordFormat
recordFormatUpdate

instance Data.ToJSON InputSchemaUpdate where
  toJSON :: InputSchemaUpdate -> Value
toJSON InputSchemaUpdate' {Maybe (NonEmpty RecordColumn)
Maybe Text
Maybe RecordFormat
recordFormatUpdate :: Maybe RecordFormat
recordEncodingUpdate :: Maybe Text
recordColumnUpdates :: Maybe (NonEmpty RecordColumn)
$sel:recordFormatUpdate:InputSchemaUpdate' :: InputSchemaUpdate -> Maybe RecordFormat
$sel:recordEncodingUpdate:InputSchemaUpdate' :: InputSchemaUpdate -> Maybe Text
$sel:recordColumnUpdates:InputSchemaUpdate' :: InputSchemaUpdate -> Maybe (NonEmpty RecordColumn)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"RecordColumnUpdates" 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 (NonEmpty RecordColumn)
recordColumnUpdates,
            (Key
"RecordEncodingUpdate" 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
recordEncodingUpdate,
            (Key
"RecordFormatUpdate" 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 RecordFormat
recordFormatUpdate
          ]
      )