{-# 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.DestinationSchema
-- 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.DestinationSchema 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.RecordFormatType
import qualified Amazonka.Prelude as Prelude

-- | 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>.
--
-- /See:/ 'newDestinationSchema' smart constructor.
data DestinationSchema = DestinationSchema'
  { -- | Specifies the format of the records on the output stream.
    DestinationSchema -> RecordFormatType
recordFormatType :: RecordFormatType
  }
  deriving (DestinationSchema -> DestinationSchema -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DestinationSchema -> DestinationSchema -> Bool
$c/= :: DestinationSchema -> DestinationSchema -> Bool
== :: DestinationSchema -> DestinationSchema -> Bool
$c== :: DestinationSchema -> DestinationSchema -> Bool
Prelude.Eq, ReadPrec [DestinationSchema]
ReadPrec DestinationSchema
Int -> ReadS DestinationSchema
ReadS [DestinationSchema]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DestinationSchema]
$creadListPrec :: ReadPrec [DestinationSchema]
readPrec :: ReadPrec DestinationSchema
$creadPrec :: ReadPrec DestinationSchema
readList :: ReadS [DestinationSchema]
$creadList :: ReadS [DestinationSchema]
readsPrec :: Int -> ReadS DestinationSchema
$creadsPrec :: Int -> ReadS DestinationSchema
Prelude.Read, Int -> DestinationSchema -> ShowS
[DestinationSchema] -> ShowS
DestinationSchema -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DestinationSchema] -> ShowS
$cshowList :: [DestinationSchema] -> ShowS
show :: DestinationSchema -> String
$cshow :: DestinationSchema -> String
showsPrec :: Int -> DestinationSchema -> ShowS
$cshowsPrec :: Int -> DestinationSchema -> ShowS
Prelude.Show, forall x. Rep DestinationSchema x -> DestinationSchema
forall x. DestinationSchema -> Rep DestinationSchema x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DestinationSchema x -> DestinationSchema
$cfrom :: forall x. DestinationSchema -> Rep DestinationSchema x
Prelude.Generic)

-- |
-- Create a value of 'DestinationSchema' 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:
--
-- 'recordFormatType', 'destinationSchema_recordFormatType' - Specifies the format of the records on the output stream.
newDestinationSchema ::
  -- | 'recordFormatType'
  RecordFormatType ->
  DestinationSchema
newDestinationSchema :: RecordFormatType -> DestinationSchema
newDestinationSchema RecordFormatType
pRecordFormatType_ =
  DestinationSchema'
    { $sel:recordFormatType:DestinationSchema' :: RecordFormatType
recordFormatType =
        RecordFormatType
pRecordFormatType_
    }

-- | Specifies the format of the records on the output stream.
destinationSchema_recordFormatType :: Lens.Lens' DestinationSchema RecordFormatType
destinationSchema_recordFormatType :: Lens' DestinationSchema RecordFormatType
destinationSchema_recordFormatType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationSchema' {RecordFormatType
recordFormatType :: RecordFormatType
$sel:recordFormatType:DestinationSchema' :: DestinationSchema -> RecordFormatType
recordFormatType} -> RecordFormatType
recordFormatType) (\s :: DestinationSchema
s@DestinationSchema' {} RecordFormatType
a -> DestinationSchema
s {$sel:recordFormatType:DestinationSchema' :: RecordFormatType
recordFormatType = RecordFormatType
a} :: DestinationSchema)

instance Data.FromJSON DestinationSchema where
  parseJSON :: Value -> Parser DestinationSchema
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DestinationSchema"
      ( \Object
x ->
          RecordFormatType -> DestinationSchema
DestinationSchema'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"RecordFormatType")
      )

instance Prelude.Hashable DestinationSchema where
  hashWithSalt :: Int -> DestinationSchema -> Int
hashWithSalt Int
_salt DestinationSchema' {RecordFormatType
recordFormatType :: RecordFormatType
$sel:recordFormatType:DestinationSchema' :: DestinationSchema -> RecordFormatType
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RecordFormatType
recordFormatType

instance Prelude.NFData DestinationSchema where
  rnf :: DestinationSchema -> ()
rnf DestinationSchema' {RecordFormatType
recordFormatType :: RecordFormatType
$sel:recordFormatType:DestinationSchema' :: DestinationSchema -> RecordFormatType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf RecordFormatType
recordFormatType

instance Data.ToJSON DestinationSchema where
  toJSON :: DestinationSchema -> Value
toJSON DestinationSchema' {RecordFormatType
recordFormatType :: RecordFormatType
$sel:recordFormatType:DestinationSchema' :: DestinationSchema -> RecordFormatType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"RecordFormatType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RecordFormatType
recordFormatType)
          ]
      )