{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoT.Types.PutItemInput where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$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 :: Lens' PutItemInput Text
putItemInput_tableName = 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 Data.FromJSON PutItemInput where
  parseJSON :: Value -> Parser PutItemInput
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PutItemInput"
      ( \Object
x ->
          Text -> PutItemInput
PutItemInput' 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
"tableName")
      )

instance Prelude.Hashable PutItemInput where
  hashWithSalt :: Int -> PutItemInput -> Int
hashWithSalt Int
_salt PutItemInput' {Text
tableName :: Text
$sel:tableName:PutItemInput' :: PutItemInput -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tableName

instance Prelude.NFData PutItemInput where
  rnf :: PutItemInput -> ()
rnf PutItemInput' {Text
tableName :: Text
$sel:tableName:PutItemInput' :: PutItemInput -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
tableName

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