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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides additional mapping information when JSON is the record format
-- on the streaming source.
--
-- /See:/ 'newJSONMappingParameters' smart constructor.
data JSONMappingParameters = JSONMappingParameters'
  { -- | Path to the top-level parent that contains the records.
    JSONMappingParameters -> Text
recordRowPath :: Prelude.Text
  }
  deriving (JSONMappingParameters -> JSONMappingParameters -> Bool
(JSONMappingParameters -> JSONMappingParameters -> Bool)
-> (JSONMappingParameters -> JSONMappingParameters -> Bool)
-> Eq JSONMappingParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JSONMappingParameters -> JSONMappingParameters -> Bool
$c/= :: JSONMappingParameters -> JSONMappingParameters -> Bool
== :: JSONMappingParameters -> JSONMappingParameters -> Bool
$c== :: JSONMappingParameters -> JSONMappingParameters -> Bool
Prelude.Eq, ReadPrec [JSONMappingParameters]
ReadPrec JSONMappingParameters
Int -> ReadS JSONMappingParameters
ReadS [JSONMappingParameters]
(Int -> ReadS JSONMappingParameters)
-> ReadS [JSONMappingParameters]
-> ReadPrec JSONMappingParameters
-> ReadPrec [JSONMappingParameters]
-> Read JSONMappingParameters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JSONMappingParameters]
$creadListPrec :: ReadPrec [JSONMappingParameters]
readPrec :: ReadPrec JSONMappingParameters
$creadPrec :: ReadPrec JSONMappingParameters
readList :: ReadS [JSONMappingParameters]
$creadList :: ReadS [JSONMappingParameters]
readsPrec :: Int -> ReadS JSONMappingParameters
$creadsPrec :: Int -> ReadS JSONMappingParameters
Prelude.Read, Int -> JSONMappingParameters -> ShowS
[JSONMappingParameters] -> ShowS
JSONMappingParameters -> String
(Int -> JSONMappingParameters -> ShowS)
-> (JSONMappingParameters -> String)
-> ([JSONMappingParameters] -> ShowS)
-> Show JSONMappingParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JSONMappingParameters] -> ShowS
$cshowList :: [JSONMappingParameters] -> ShowS
show :: JSONMappingParameters -> String
$cshow :: JSONMappingParameters -> String
showsPrec :: Int -> JSONMappingParameters -> ShowS
$cshowsPrec :: Int -> JSONMappingParameters -> ShowS
Prelude.Show, (forall x. JSONMappingParameters -> Rep JSONMappingParameters x)
-> (forall x. Rep JSONMappingParameters x -> JSONMappingParameters)
-> Generic JSONMappingParameters
forall x. Rep JSONMappingParameters x -> JSONMappingParameters
forall x. JSONMappingParameters -> Rep JSONMappingParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JSONMappingParameters x -> JSONMappingParameters
$cfrom :: forall x. JSONMappingParameters -> Rep JSONMappingParameters x
Prelude.Generic)

-- |
-- Create a value of 'JSONMappingParameters' 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:
--
-- 'recordRowPath', 'jSONMappingParameters_recordRowPath' - Path to the top-level parent that contains the records.
newJSONMappingParameters ::
  -- | 'recordRowPath'
  Prelude.Text ->
  JSONMappingParameters
newJSONMappingParameters :: Text -> JSONMappingParameters
newJSONMappingParameters Text
pRecordRowPath_ =
  JSONMappingParameters' :: Text -> JSONMappingParameters
JSONMappingParameters'
    { $sel:recordRowPath:JSONMappingParameters' :: Text
recordRowPath =
        Text
pRecordRowPath_
    }

-- | Path to the top-level parent that contains the records.
jSONMappingParameters_recordRowPath :: Lens.Lens' JSONMappingParameters Prelude.Text
jSONMappingParameters_recordRowPath :: (Text -> f Text)
-> JSONMappingParameters -> f JSONMappingParameters
jSONMappingParameters_recordRowPath = (JSONMappingParameters -> Text)
-> (JSONMappingParameters -> Text -> JSONMappingParameters)
-> Lens JSONMappingParameters JSONMappingParameters Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JSONMappingParameters' {Text
recordRowPath :: Text
$sel:recordRowPath:JSONMappingParameters' :: JSONMappingParameters -> Text
recordRowPath} -> Text
recordRowPath) (\s :: JSONMappingParameters
s@JSONMappingParameters' {} Text
a -> JSONMappingParameters
s {$sel:recordRowPath:JSONMappingParameters' :: Text
recordRowPath = Text
a} :: JSONMappingParameters)

instance Core.FromJSON JSONMappingParameters where
  parseJSON :: Value -> Parser JSONMappingParameters
parseJSON =
    String
-> (Object -> Parser JSONMappingParameters)
-> Value
-> Parser JSONMappingParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"JSONMappingParameters"
      ( \Object
x ->
          Text -> JSONMappingParameters
JSONMappingParameters'
            (Text -> JSONMappingParameters)
-> Parser Text -> Parser JSONMappingParameters
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RecordRowPath")
      )

instance Prelude.Hashable JSONMappingParameters

instance Prelude.NFData JSONMappingParameters

instance Core.ToJSON JSONMappingParameters where
  toJSON :: JSONMappingParameters -> Value
toJSON JSONMappingParameters' {Text
recordRowPath :: Text
$sel:recordRowPath:JSONMappingParameters' :: JSONMappingParameters -> Text
..} =
    [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
"RecordRowPath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
recordRowPath)
          ]
      )