{-# 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.DestinationSchema
-- 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.DestinationSchema where

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalyticsV2.Types.RecordFormatType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the data format when records are written to the destination in
-- a SQL-based Kinesis Data Analytics application.
--
-- /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
(DestinationSchema -> DestinationSchema -> Bool)
-> (DestinationSchema -> DestinationSchema -> Bool)
-> Eq DestinationSchema
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]
(Int -> ReadS DestinationSchema)
-> ReadS [DestinationSchema]
-> ReadPrec DestinationSchema
-> ReadPrec [DestinationSchema]
-> Read 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
(Int -> DestinationSchema -> ShowS)
-> (DestinationSchema -> String)
-> ([DestinationSchema] -> ShowS)
-> Show DestinationSchema
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. DestinationSchema -> Rep DestinationSchema x)
-> (forall x. Rep DestinationSchema x -> DestinationSchema)
-> Generic DestinationSchema
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' :: RecordFormatType -> DestinationSchema
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 :: (RecordFormatType -> f RecordFormatType)
-> DestinationSchema -> f DestinationSchema
destinationSchema_recordFormatType = (DestinationSchema -> RecordFormatType)
-> (DestinationSchema -> RecordFormatType -> DestinationSchema)
-> Lens
     DestinationSchema
     DestinationSchema
     RecordFormatType
     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 Core.FromJSON DestinationSchema where
  parseJSON :: Value -> Parser DestinationSchema
parseJSON =
    String
-> (Object -> Parser DestinationSchema)
-> Value
-> Parser DestinationSchema
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DestinationSchema"
      ( \Object
x ->
          RecordFormatType -> DestinationSchema
DestinationSchema'
            (RecordFormatType -> DestinationSchema)
-> Parser RecordFormatType -> Parser DestinationSchema
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser RecordFormatType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RecordFormatType")
      )

instance Prelude.Hashable DestinationSchema

instance Prelude.NFData DestinationSchema

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