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

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalytics.Types.DestinationSchema
import Amazonka.KinesisAnalytics.Types.KinesisFirehoseOutputUpdate
import Amazonka.KinesisAnalytics.Types.KinesisStreamsOutputUpdate
import Amazonka.KinesisAnalytics.Types.LambdaOutputUpdate
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes updates to the output configuration identified by the
-- @OutputId@.
--
-- /See:/ 'newOutputUpdate' smart constructor.
data OutputUpdate = OutputUpdate'
  { -- | Describes an Amazon Kinesis stream as the destination for the output.
    OutputUpdate -> Maybe KinesisStreamsOutputUpdate
kinesisStreamsOutputUpdate :: Prelude.Maybe KinesisStreamsOutputUpdate,
    -- | Describes the data format when records are written to the destination.
    -- For more information, see
    -- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-output.html Configuring Application Output>.
    OutputUpdate -> Maybe DestinationSchema
destinationSchemaUpdate :: Prelude.Maybe DestinationSchema,
    -- | Describes an Amazon Kinesis Firehose delivery stream as the destination
    -- for the output.
    OutputUpdate -> Maybe KinesisFirehoseOutputUpdate
kinesisFirehoseOutputUpdate :: Prelude.Maybe KinesisFirehoseOutputUpdate,
    -- | If you want to specify a different in-application stream for this output
    -- configuration, use this field to specify the new in-application stream
    -- name.
    OutputUpdate -> Maybe Text
nameUpdate :: Prelude.Maybe Prelude.Text,
    -- | Describes an AWS Lambda function as the destination for the output.
    OutputUpdate -> Maybe LambdaOutputUpdate
lambdaOutputUpdate :: Prelude.Maybe LambdaOutputUpdate,
    -- | Identifies the specific output configuration that you want to update.
    OutputUpdate -> Text
outputId :: Prelude.Text
  }
  deriving (OutputUpdate -> OutputUpdate -> Bool
(OutputUpdate -> OutputUpdate -> Bool)
-> (OutputUpdate -> OutputUpdate -> Bool) -> Eq OutputUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputUpdate -> OutputUpdate -> Bool
$c/= :: OutputUpdate -> OutputUpdate -> Bool
== :: OutputUpdate -> OutputUpdate -> Bool
$c== :: OutputUpdate -> OutputUpdate -> Bool
Prelude.Eq, ReadPrec [OutputUpdate]
ReadPrec OutputUpdate
Int -> ReadS OutputUpdate
ReadS [OutputUpdate]
(Int -> ReadS OutputUpdate)
-> ReadS [OutputUpdate]
-> ReadPrec OutputUpdate
-> ReadPrec [OutputUpdate]
-> Read OutputUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OutputUpdate]
$creadListPrec :: ReadPrec [OutputUpdate]
readPrec :: ReadPrec OutputUpdate
$creadPrec :: ReadPrec OutputUpdate
readList :: ReadS [OutputUpdate]
$creadList :: ReadS [OutputUpdate]
readsPrec :: Int -> ReadS OutputUpdate
$creadsPrec :: Int -> ReadS OutputUpdate
Prelude.Read, Int -> OutputUpdate -> ShowS
[OutputUpdate] -> ShowS
OutputUpdate -> String
(Int -> OutputUpdate -> ShowS)
-> (OutputUpdate -> String)
-> ([OutputUpdate] -> ShowS)
-> Show OutputUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputUpdate] -> ShowS
$cshowList :: [OutputUpdate] -> ShowS
show :: OutputUpdate -> String
$cshow :: OutputUpdate -> String
showsPrec :: Int -> OutputUpdate -> ShowS
$cshowsPrec :: Int -> OutputUpdate -> ShowS
Prelude.Show, (forall x. OutputUpdate -> Rep OutputUpdate x)
-> (forall x. Rep OutputUpdate x -> OutputUpdate)
-> Generic OutputUpdate
forall x. Rep OutputUpdate x -> OutputUpdate
forall x. OutputUpdate -> Rep OutputUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OutputUpdate x -> OutputUpdate
$cfrom :: forall x. OutputUpdate -> Rep OutputUpdate x
Prelude.Generic)

-- |
-- Create a value of 'OutputUpdate' 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:
--
-- 'kinesisStreamsOutputUpdate', 'outputUpdate_kinesisStreamsOutputUpdate' - Describes an Amazon Kinesis stream as the destination for the output.
--
-- 'destinationSchemaUpdate', 'outputUpdate_destinationSchemaUpdate' - Describes the data format when records are written to the destination.
-- For more information, see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-output.html Configuring Application Output>.
--
-- 'kinesisFirehoseOutputUpdate', 'outputUpdate_kinesisFirehoseOutputUpdate' - Describes an Amazon Kinesis Firehose delivery stream as the destination
-- for the output.
--
-- 'nameUpdate', 'outputUpdate_nameUpdate' - If you want to specify a different in-application stream for this output
-- configuration, use this field to specify the new in-application stream
-- name.
--
-- 'lambdaOutputUpdate', 'outputUpdate_lambdaOutputUpdate' - Describes an AWS Lambda function as the destination for the output.
--
-- 'outputId', 'outputUpdate_outputId' - Identifies the specific output configuration that you want to update.
newOutputUpdate ::
  -- | 'outputId'
  Prelude.Text ->
  OutputUpdate
newOutputUpdate :: Text -> OutputUpdate
newOutputUpdate Text
pOutputId_ =
  OutputUpdate' :: Maybe KinesisStreamsOutputUpdate
-> Maybe DestinationSchema
-> Maybe KinesisFirehoseOutputUpdate
-> Maybe Text
-> Maybe LambdaOutputUpdate
-> Text
-> OutputUpdate
OutputUpdate'
    { $sel:kinesisStreamsOutputUpdate:OutputUpdate' :: Maybe KinesisStreamsOutputUpdate
kinesisStreamsOutputUpdate =
        Maybe KinesisStreamsOutputUpdate
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationSchemaUpdate:OutputUpdate' :: Maybe DestinationSchema
destinationSchemaUpdate = Maybe DestinationSchema
forall a. Maybe a
Prelude.Nothing,
      $sel:kinesisFirehoseOutputUpdate:OutputUpdate' :: Maybe KinesisFirehoseOutputUpdate
kinesisFirehoseOutputUpdate = Maybe KinesisFirehoseOutputUpdate
forall a. Maybe a
Prelude.Nothing,
      $sel:nameUpdate:OutputUpdate' :: Maybe Text
nameUpdate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lambdaOutputUpdate:OutputUpdate' :: Maybe LambdaOutputUpdate
lambdaOutputUpdate = Maybe LambdaOutputUpdate
forall a. Maybe a
Prelude.Nothing,
      $sel:outputId:OutputUpdate' :: Text
outputId = Text
pOutputId_
    }

-- | Describes an Amazon Kinesis stream as the destination for the output.
outputUpdate_kinesisStreamsOutputUpdate :: Lens.Lens' OutputUpdate (Prelude.Maybe KinesisStreamsOutputUpdate)
outputUpdate_kinesisStreamsOutputUpdate :: (Maybe KinesisStreamsOutputUpdate
 -> f (Maybe KinesisStreamsOutputUpdate))
-> OutputUpdate -> f OutputUpdate
outputUpdate_kinesisStreamsOutputUpdate = (OutputUpdate -> Maybe KinesisStreamsOutputUpdate)
-> (OutputUpdate
    -> Maybe KinesisStreamsOutputUpdate -> OutputUpdate)
-> Lens
     OutputUpdate
     OutputUpdate
     (Maybe KinesisStreamsOutputUpdate)
     (Maybe KinesisStreamsOutputUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputUpdate' {Maybe KinesisStreamsOutputUpdate
kinesisStreamsOutputUpdate :: Maybe KinesisStreamsOutputUpdate
$sel:kinesisStreamsOutputUpdate:OutputUpdate' :: OutputUpdate -> Maybe KinesisStreamsOutputUpdate
kinesisStreamsOutputUpdate} -> Maybe KinesisStreamsOutputUpdate
kinesisStreamsOutputUpdate) (\s :: OutputUpdate
s@OutputUpdate' {} Maybe KinesisStreamsOutputUpdate
a -> OutputUpdate
s {$sel:kinesisStreamsOutputUpdate:OutputUpdate' :: Maybe KinesisStreamsOutputUpdate
kinesisStreamsOutputUpdate = Maybe KinesisStreamsOutputUpdate
a} :: OutputUpdate)

-- | Describes the data format when records are written to the destination.
-- For more information, see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-output.html Configuring Application Output>.
outputUpdate_destinationSchemaUpdate :: Lens.Lens' OutputUpdate (Prelude.Maybe DestinationSchema)
outputUpdate_destinationSchemaUpdate :: (Maybe DestinationSchema -> f (Maybe DestinationSchema))
-> OutputUpdate -> f OutputUpdate
outputUpdate_destinationSchemaUpdate = (OutputUpdate -> Maybe DestinationSchema)
-> (OutputUpdate -> Maybe DestinationSchema -> OutputUpdate)
-> Lens
     OutputUpdate
     OutputUpdate
     (Maybe DestinationSchema)
     (Maybe DestinationSchema)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputUpdate' {Maybe DestinationSchema
destinationSchemaUpdate :: Maybe DestinationSchema
$sel:destinationSchemaUpdate:OutputUpdate' :: OutputUpdate -> Maybe DestinationSchema
destinationSchemaUpdate} -> Maybe DestinationSchema
destinationSchemaUpdate) (\s :: OutputUpdate
s@OutputUpdate' {} Maybe DestinationSchema
a -> OutputUpdate
s {$sel:destinationSchemaUpdate:OutputUpdate' :: Maybe DestinationSchema
destinationSchemaUpdate = Maybe DestinationSchema
a} :: OutputUpdate)

-- | Describes an Amazon Kinesis Firehose delivery stream as the destination
-- for the output.
outputUpdate_kinesisFirehoseOutputUpdate :: Lens.Lens' OutputUpdate (Prelude.Maybe KinesisFirehoseOutputUpdate)
outputUpdate_kinesisFirehoseOutputUpdate :: (Maybe KinesisFirehoseOutputUpdate
 -> f (Maybe KinesisFirehoseOutputUpdate))
-> OutputUpdate -> f OutputUpdate
outputUpdate_kinesisFirehoseOutputUpdate = (OutputUpdate -> Maybe KinesisFirehoseOutputUpdate)
-> (OutputUpdate
    -> Maybe KinesisFirehoseOutputUpdate -> OutputUpdate)
-> Lens
     OutputUpdate
     OutputUpdate
     (Maybe KinesisFirehoseOutputUpdate)
     (Maybe KinesisFirehoseOutputUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputUpdate' {Maybe KinesisFirehoseOutputUpdate
kinesisFirehoseOutputUpdate :: Maybe KinesisFirehoseOutputUpdate
$sel:kinesisFirehoseOutputUpdate:OutputUpdate' :: OutputUpdate -> Maybe KinesisFirehoseOutputUpdate
kinesisFirehoseOutputUpdate} -> Maybe KinesisFirehoseOutputUpdate
kinesisFirehoseOutputUpdate) (\s :: OutputUpdate
s@OutputUpdate' {} Maybe KinesisFirehoseOutputUpdate
a -> OutputUpdate
s {$sel:kinesisFirehoseOutputUpdate:OutputUpdate' :: Maybe KinesisFirehoseOutputUpdate
kinesisFirehoseOutputUpdate = Maybe KinesisFirehoseOutputUpdate
a} :: OutputUpdate)

-- | If you want to specify a different in-application stream for this output
-- configuration, use this field to specify the new in-application stream
-- name.
outputUpdate_nameUpdate :: Lens.Lens' OutputUpdate (Prelude.Maybe Prelude.Text)
outputUpdate_nameUpdate :: (Maybe Text -> f (Maybe Text)) -> OutputUpdate -> f OutputUpdate
outputUpdate_nameUpdate = (OutputUpdate -> Maybe Text)
-> (OutputUpdate -> Maybe Text -> OutputUpdate)
-> Lens OutputUpdate OutputUpdate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputUpdate' {Maybe Text
nameUpdate :: Maybe Text
$sel:nameUpdate:OutputUpdate' :: OutputUpdate -> Maybe Text
nameUpdate} -> Maybe Text
nameUpdate) (\s :: OutputUpdate
s@OutputUpdate' {} Maybe Text
a -> OutputUpdate
s {$sel:nameUpdate:OutputUpdate' :: Maybe Text
nameUpdate = Maybe Text
a} :: OutputUpdate)

-- | Describes an AWS Lambda function as the destination for the output.
outputUpdate_lambdaOutputUpdate :: Lens.Lens' OutputUpdate (Prelude.Maybe LambdaOutputUpdate)
outputUpdate_lambdaOutputUpdate :: (Maybe LambdaOutputUpdate -> f (Maybe LambdaOutputUpdate))
-> OutputUpdate -> f OutputUpdate
outputUpdate_lambdaOutputUpdate = (OutputUpdate -> Maybe LambdaOutputUpdate)
-> (OutputUpdate -> Maybe LambdaOutputUpdate -> OutputUpdate)
-> Lens
     OutputUpdate
     OutputUpdate
     (Maybe LambdaOutputUpdate)
     (Maybe LambdaOutputUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputUpdate' {Maybe LambdaOutputUpdate
lambdaOutputUpdate :: Maybe LambdaOutputUpdate
$sel:lambdaOutputUpdate:OutputUpdate' :: OutputUpdate -> Maybe LambdaOutputUpdate
lambdaOutputUpdate} -> Maybe LambdaOutputUpdate
lambdaOutputUpdate) (\s :: OutputUpdate
s@OutputUpdate' {} Maybe LambdaOutputUpdate
a -> OutputUpdate
s {$sel:lambdaOutputUpdate:OutputUpdate' :: Maybe LambdaOutputUpdate
lambdaOutputUpdate = Maybe LambdaOutputUpdate
a} :: OutputUpdate)

-- | Identifies the specific output configuration that you want to update.
outputUpdate_outputId :: Lens.Lens' OutputUpdate Prelude.Text
outputUpdate_outputId :: (Text -> f Text) -> OutputUpdate -> f OutputUpdate
outputUpdate_outputId = (OutputUpdate -> Text)
-> (OutputUpdate -> Text -> OutputUpdate)
-> Lens OutputUpdate OutputUpdate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputUpdate' {Text
outputId :: Text
$sel:outputId:OutputUpdate' :: OutputUpdate -> Text
outputId} -> Text
outputId) (\s :: OutputUpdate
s@OutputUpdate' {} Text
a -> OutputUpdate
s {$sel:outputId:OutputUpdate' :: Text
outputId = Text
a} :: OutputUpdate)

instance Prelude.Hashable OutputUpdate

instance Prelude.NFData OutputUpdate

instance Core.ToJSON OutputUpdate where
  toJSON :: OutputUpdate -> Value
toJSON OutputUpdate' {Maybe Text
Maybe KinesisFirehoseOutputUpdate
Maybe KinesisStreamsOutputUpdate
Maybe LambdaOutputUpdate
Maybe DestinationSchema
Text
outputId :: Text
lambdaOutputUpdate :: Maybe LambdaOutputUpdate
nameUpdate :: Maybe Text
kinesisFirehoseOutputUpdate :: Maybe KinesisFirehoseOutputUpdate
destinationSchemaUpdate :: Maybe DestinationSchema
kinesisStreamsOutputUpdate :: Maybe KinesisStreamsOutputUpdate
$sel:outputId:OutputUpdate' :: OutputUpdate -> Text
$sel:lambdaOutputUpdate:OutputUpdate' :: OutputUpdate -> Maybe LambdaOutputUpdate
$sel:nameUpdate:OutputUpdate' :: OutputUpdate -> Maybe Text
$sel:kinesisFirehoseOutputUpdate:OutputUpdate' :: OutputUpdate -> Maybe KinesisFirehoseOutputUpdate
$sel:destinationSchemaUpdate:OutputUpdate' :: OutputUpdate -> Maybe DestinationSchema
$sel:kinesisStreamsOutputUpdate:OutputUpdate' :: OutputUpdate -> Maybe KinesisStreamsOutputUpdate
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"KinesisStreamsOutputUpdate" Text -> KinesisStreamsOutputUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (KinesisStreamsOutputUpdate -> Pair)
-> Maybe KinesisStreamsOutputUpdate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe KinesisStreamsOutputUpdate
kinesisStreamsOutputUpdate,
            (Text
"DestinationSchemaUpdate" Text -> DestinationSchema -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DestinationSchema -> Pair)
-> Maybe DestinationSchema -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DestinationSchema
destinationSchemaUpdate,
            (Text
"KinesisFirehoseOutputUpdate" Text -> KinesisFirehoseOutputUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (KinesisFirehoseOutputUpdate -> Pair)
-> Maybe KinesisFirehoseOutputUpdate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe KinesisFirehoseOutputUpdate
kinesisFirehoseOutputUpdate,
            (Text
"NameUpdate" 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
nameUpdate,
            (Text
"LambdaOutputUpdate" Text -> LambdaOutputUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (LambdaOutputUpdate -> Pair)
-> Maybe LambdaOutputUpdate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LambdaOutputUpdate
lambdaOutputUpdate,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"OutputId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
outputId)
          ]
      )