{-# 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 #-}
module Amazonka.DynamoDB.Types.PutRequest where
import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.AttributeValue
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data PutRequest = PutRequest'
{
PutRequest -> HashMap Text AttributeValue
item :: Prelude.HashMap Prelude.Text AttributeValue
}
deriving (PutRequest -> PutRequest -> Bool
(PutRequest -> PutRequest -> Bool)
-> (PutRequest -> PutRequest -> Bool) -> Eq PutRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRequest -> PutRequest -> Bool
$c/= :: PutRequest -> PutRequest -> Bool
== :: PutRequest -> PutRequest -> Bool
$c== :: PutRequest -> PutRequest -> Bool
Prelude.Eq, ReadPrec [PutRequest]
ReadPrec PutRequest
Int -> ReadS PutRequest
ReadS [PutRequest]
(Int -> ReadS PutRequest)
-> ReadS [PutRequest]
-> ReadPrec PutRequest
-> ReadPrec [PutRequest]
-> Read PutRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRequest]
$creadListPrec :: ReadPrec [PutRequest]
readPrec :: ReadPrec PutRequest
$creadPrec :: ReadPrec PutRequest
readList :: ReadS [PutRequest]
$creadList :: ReadS [PutRequest]
readsPrec :: Int -> ReadS PutRequest
$creadsPrec :: Int -> ReadS PutRequest
Prelude.Read, Int -> PutRequest -> ShowS
[PutRequest] -> ShowS
PutRequest -> String
(Int -> PutRequest -> ShowS)
-> (PutRequest -> String)
-> ([PutRequest] -> ShowS)
-> Show PutRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRequest] -> ShowS
$cshowList :: [PutRequest] -> ShowS
show :: PutRequest -> String
$cshow :: PutRequest -> String
showsPrec :: Int -> PutRequest -> ShowS
$cshowsPrec :: Int -> PutRequest -> ShowS
Prelude.Show, (forall x. PutRequest -> Rep PutRequest x)
-> (forall x. Rep PutRequest x -> PutRequest) -> Generic PutRequest
forall x. Rep PutRequest x -> PutRequest
forall x. PutRequest -> Rep PutRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutRequest x -> PutRequest
$cfrom :: forall x. PutRequest -> Rep PutRequest x
Prelude.Generic)
newPutRequest ::
PutRequest
newPutRequest :: PutRequest
newPutRequest = PutRequest' :: HashMap Text AttributeValue -> PutRequest
PutRequest' {$sel:item:PutRequest' :: HashMap Text AttributeValue
item = HashMap Text AttributeValue
forall a. Monoid a => a
Prelude.mempty}
putRequest_item :: Lens.Lens' PutRequest (Prelude.HashMap Prelude.Text AttributeValue)
putRequest_item :: (HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
-> PutRequest -> f PutRequest
putRequest_item = (PutRequest -> HashMap Text AttributeValue)
-> (PutRequest -> HashMap Text AttributeValue -> PutRequest)
-> Lens
PutRequest
PutRequest
(HashMap Text AttributeValue)
(HashMap Text AttributeValue)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRequest' {HashMap Text AttributeValue
item :: HashMap Text AttributeValue
$sel:item:PutRequest' :: PutRequest -> HashMap Text AttributeValue
item} -> HashMap Text AttributeValue
item) (\s :: PutRequest
s@PutRequest' {} HashMap Text AttributeValue
a -> PutRequest
s {$sel:item:PutRequest' :: HashMap Text AttributeValue
item = HashMap Text AttributeValue
a} :: PutRequest) ((HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
-> PutRequest -> f PutRequest)
-> ((HashMap Text AttributeValue
-> f (HashMap Text AttributeValue))
-> HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
-> (HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
-> PutRequest
-> f PutRequest
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
-> HashMap Text AttributeValue -> f (HashMap Text AttributeValue)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON PutRequest where
parseJSON :: Value -> Parser PutRequest
parseJSON =
String
-> (Object -> Parser PutRequest) -> Value -> Parser PutRequest
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"PutRequest"
( \Object
x ->
HashMap Text AttributeValue -> PutRequest
PutRequest'
(HashMap Text AttributeValue -> PutRequest)
-> Parser (HashMap Text AttributeValue) -> Parser PutRequest
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (HashMap Text AttributeValue))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Item" Parser (Maybe (HashMap Text AttributeValue))
-> HashMap Text AttributeValue
-> Parser (HashMap Text AttributeValue)
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= HashMap Text AttributeValue
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable PutRequest
instance Prelude.NFData PutRequest
instance Core.ToJSON PutRequest where
toJSON :: PutRequest -> Value
toJSON PutRequest' {HashMap Text AttributeValue
item :: HashMap Text AttributeValue
$sel:item:PutRequest' :: PutRequest -> HashMap Text AttributeValue
..} =
[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
"Item" Text -> HashMap Text AttributeValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text AttributeValue
item)]
)