{-# 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.IoT.Types.PutItemInput
-- 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.IoT.Types.PutItemInput where

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

-- | The input for the DynamoActionVS action that specifies the DynamoDB
-- table to which the message data will be written.
--
-- /See:/ 'newPutItemInput' smart constructor.
data PutItemInput = PutItemInput'
  { -- | The table where the message data will be written.
    PutItemInput -> Text
tableName :: Prelude.Text
  }
  deriving (PutItemInput -> PutItemInput -> Bool
(PutItemInput -> PutItemInput -> Bool)
-> (PutItemInput -> PutItemInput -> Bool) -> Eq PutItemInput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutItemInput -> PutItemInput -> Bool
$c/= :: PutItemInput -> PutItemInput -> Bool
== :: PutItemInput -> PutItemInput -> Bool
$c== :: PutItemInput -> PutItemInput -> Bool
Prelude.Eq, ReadPrec [PutItemInput]
ReadPrec PutItemInput
Int -> ReadS PutItemInput
ReadS [PutItemInput]
(Int -> ReadS PutItemInput)
-> ReadS [PutItemInput]
-> ReadPrec PutItemInput
-> ReadPrec [PutItemInput]
-> Read PutItemInput
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutItemInput]
$creadListPrec :: ReadPrec [PutItemInput]
readPrec :: ReadPrec PutItemInput
$creadPrec :: ReadPrec PutItemInput
readList :: ReadS [PutItemInput]
$creadList :: ReadS [PutItemInput]
readsPrec :: Int -> ReadS PutItemInput
$creadsPrec :: Int -> ReadS PutItemInput
Prelude.Read, Int -> PutItemInput -> ShowS
[PutItemInput] -> ShowS
PutItemInput -> String
(Int -> PutItemInput -> ShowS)
-> (PutItemInput -> String)
-> ([PutItemInput] -> ShowS)
-> Show PutItemInput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutItemInput] -> ShowS
$cshowList :: [PutItemInput] -> ShowS
show :: PutItemInput -> String
$cshow :: PutItemInput -> String
showsPrec :: Int -> PutItemInput -> ShowS
$cshowsPrec :: Int -> PutItemInput -> ShowS
Prelude.Show, (forall x. PutItemInput -> Rep PutItemInput x)
-> (forall x. Rep PutItemInput x -> PutItemInput)
-> Generic PutItemInput
forall x. Rep PutItemInput x -> PutItemInput
forall x. PutItemInput -> Rep PutItemInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutItemInput x -> PutItemInput
$cfrom :: forall x. PutItemInput -> Rep PutItemInput x
Prelude.Generic)

-- |
-- Create a value of 'PutItemInput' 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:
--
-- 'tableName', 'putItemInput_tableName' - The table where the message data will be written.
newPutItemInput ::
  -- | 'tableName'
  Prelude.Text ->
  PutItemInput
newPutItemInput :: Text -> PutItemInput
newPutItemInput Text
pTableName_ =
  PutItemInput' :: Text -> PutItemInput
PutItemInput' {$sel:tableName:PutItemInput' :: Text
tableName = Text
pTableName_}

-- | The table where the message data will be written.
putItemInput_tableName :: Lens.Lens' PutItemInput Prelude.Text
putItemInput_tableName :: (Text -> f Text) -> PutItemInput -> f PutItemInput
putItemInput_tableName = (PutItemInput -> Text)
-> (PutItemInput -> Text -> PutItemInput)
-> Lens PutItemInput PutItemInput Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutItemInput' {Text
tableName :: Text
$sel:tableName:PutItemInput' :: PutItemInput -> Text
tableName} -> Text
tableName) (\s :: PutItemInput
s@PutItemInput' {} Text
a -> PutItemInput
s {$sel:tableName:PutItemInput' :: Text
tableName = Text
a} :: PutItemInput)

instance Core.FromJSON PutItemInput where
  parseJSON :: Value -> Parser PutItemInput
parseJSON =
    String
-> (Object -> Parser PutItemInput) -> Value -> Parser PutItemInput
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PutItemInput"
      ( \Object
x ->
          Text -> PutItemInput
PutItemInput' (Text -> PutItemInput) -> Parser Text -> Parser PutItemInput
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
"tableName")
      )

instance Prelude.Hashable PutItemInput

instance Prelude.NFData PutItemInput

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