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

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalyticsV2.Types.RecordColumn
import Amazonka.KinesisAnalyticsV2.Types.RecordFormat
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes updates for an SQL-based Kinesis Data Analytics application\'s
-- input schema.
--
-- /See:/ 'newInputSchemaUpdate' smart constructor.
data InputSchemaUpdate = InputSchemaUpdate'
  { -- | Specifies the format of the records on the streaming source.
    InputSchemaUpdate -> Maybe RecordFormat
recordFormatUpdate :: Prelude.Maybe RecordFormat,
    -- | Specifies the encoding of the records in the streaming source; for
    -- example, UTF-8.
    InputSchemaUpdate -> Maybe Text
recordEncodingUpdate :: Prelude.Maybe Prelude.Text,
    -- | 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)
  }
  deriving (InputSchemaUpdate -> InputSchemaUpdate -> Bool
(InputSchemaUpdate -> InputSchemaUpdate -> Bool)
-> (InputSchemaUpdate -> InputSchemaUpdate -> Bool)
-> Eq InputSchemaUpdate
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]
(Int -> ReadS InputSchemaUpdate)
-> ReadS [InputSchemaUpdate]
-> ReadPrec InputSchemaUpdate
-> ReadPrec [InputSchemaUpdate]
-> Read 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
(Int -> InputSchemaUpdate -> ShowS)
-> (InputSchemaUpdate -> String)
-> ([InputSchemaUpdate] -> ShowS)
-> Show InputSchemaUpdate
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. InputSchemaUpdate -> Rep InputSchemaUpdate x)
-> (forall x. Rep InputSchemaUpdate x -> InputSchemaUpdate)
-> Generic InputSchemaUpdate
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:
--
-- 'recordFormatUpdate', 'inputSchemaUpdate_recordFormatUpdate' - Specifies the format of the records on the streaming source.
--
-- 'recordEncodingUpdate', 'inputSchemaUpdate_recordEncodingUpdate' - Specifies the encoding of the records in the streaming source; for
-- example, UTF-8.
--
-- '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.
newInputSchemaUpdate ::
  InputSchemaUpdate
newInputSchemaUpdate :: InputSchemaUpdate
newInputSchemaUpdate =
  InputSchemaUpdate' :: Maybe RecordFormat
-> Maybe Text -> Maybe (NonEmpty RecordColumn) -> InputSchemaUpdate
InputSchemaUpdate'
    { $sel:recordFormatUpdate:InputSchemaUpdate' :: Maybe RecordFormat
recordFormatUpdate =
        Maybe RecordFormat
forall a. Maybe a
Prelude.Nothing,
      $sel:recordEncodingUpdate:InputSchemaUpdate' :: Maybe Text
recordEncodingUpdate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:recordColumnUpdates:InputSchemaUpdate' :: Maybe (NonEmpty RecordColumn)
recordColumnUpdates = Maybe (NonEmpty RecordColumn)
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the format of the records on the streaming source.
inputSchemaUpdate_recordFormatUpdate :: Lens.Lens' InputSchemaUpdate (Prelude.Maybe RecordFormat)
inputSchemaUpdate_recordFormatUpdate :: (Maybe RecordFormat -> f (Maybe RecordFormat))
-> InputSchemaUpdate -> f InputSchemaUpdate
inputSchemaUpdate_recordFormatUpdate = (InputSchemaUpdate -> Maybe RecordFormat)
-> (InputSchemaUpdate -> Maybe RecordFormat -> InputSchemaUpdate)
-> Lens
     InputSchemaUpdate
     InputSchemaUpdate
     (Maybe RecordFormat)
     (Maybe RecordFormat)
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)

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

-- | 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 :: (Maybe (NonEmpty RecordColumn)
 -> f (Maybe (NonEmpty RecordColumn)))
-> InputSchemaUpdate -> f InputSchemaUpdate
inputSchemaUpdate_recordColumnUpdates = (InputSchemaUpdate -> Maybe (NonEmpty RecordColumn))
-> (InputSchemaUpdate
    -> Maybe (NonEmpty RecordColumn) -> InputSchemaUpdate)
-> Lens
     InputSchemaUpdate
     InputSchemaUpdate
     (Maybe (NonEmpty RecordColumn))
     (Maybe (NonEmpty RecordColumn))
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) ((Maybe (NonEmpty RecordColumn)
  -> f (Maybe (NonEmpty RecordColumn)))
 -> InputSchemaUpdate -> f InputSchemaUpdate)
-> ((Maybe (NonEmpty RecordColumn)
     -> f (Maybe (NonEmpty RecordColumn)))
    -> Maybe (NonEmpty RecordColumn)
    -> f (Maybe (NonEmpty RecordColumn)))
-> (Maybe (NonEmpty RecordColumn)
    -> f (Maybe (NonEmpty RecordColumn)))
-> InputSchemaUpdate
-> f InputSchemaUpdate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty RecordColumn)
  (NonEmpty RecordColumn)
  (NonEmpty RecordColumn)
  (NonEmpty RecordColumn)
-> Iso
     (Maybe (NonEmpty RecordColumn))
     (Maybe (NonEmpty RecordColumn))
     (Maybe (NonEmpty RecordColumn))
     (Maybe (NonEmpty RecordColumn))
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 AnIso
  (NonEmpty RecordColumn)
  (NonEmpty RecordColumn)
  (NonEmpty RecordColumn)
  (NonEmpty RecordColumn)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable InputSchemaUpdate

instance Prelude.NFData InputSchemaUpdate

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