{-# 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.WriteRequest where
import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.DeleteRequest
import Amazonka.DynamoDB.Types.PutRequest
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data WriteRequest = WriteRequest'
{
WriteRequest -> Maybe DeleteRequest
deleteRequest :: Prelude.Maybe DeleteRequest,
WriteRequest -> Maybe PutRequest
putRequest :: Prelude.Maybe PutRequest
}
deriving (WriteRequest -> WriteRequest -> Bool
(WriteRequest -> WriteRequest -> Bool)
-> (WriteRequest -> WriteRequest -> Bool) -> Eq WriteRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WriteRequest -> WriteRequest -> Bool
$c/= :: WriteRequest -> WriteRequest -> Bool
== :: WriteRequest -> WriteRequest -> Bool
$c== :: WriteRequest -> WriteRequest -> Bool
Prelude.Eq, ReadPrec [WriteRequest]
ReadPrec WriteRequest
Int -> ReadS WriteRequest
ReadS [WriteRequest]
(Int -> ReadS WriteRequest)
-> ReadS [WriteRequest]
-> ReadPrec WriteRequest
-> ReadPrec [WriteRequest]
-> Read WriteRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WriteRequest]
$creadListPrec :: ReadPrec [WriteRequest]
readPrec :: ReadPrec WriteRequest
$creadPrec :: ReadPrec WriteRequest
readList :: ReadS [WriteRequest]
$creadList :: ReadS [WriteRequest]
readsPrec :: Int -> ReadS WriteRequest
$creadsPrec :: Int -> ReadS WriteRequest
Prelude.Read, Int -> WriteRequest -> ShowS
[WriteRequest] -> ShowS
WriteRequest -> String
(Int -> WriteRequest -> ShowS)
-> (WriteRequest -> String)
-> ([WriteRequest] -> ShowS)
-> Show WriteRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WriteRequest] -> ShowS
$cshowList :: [WriteRequest] -> ShowS
show :: WriteRequest -> String
$cshow :: WriteRequest -> String
showsPrec :: Int -> WriteRequest -> ShowS
$cshowsPrec :: Int -> WriteRequest -> ShowS
Prelude.Show, (forall x. WriteRequest -> Rep WriteRequest x)
-> (forall x. Rep WriteRequest x -> WriteRequest)
-> Generic WriteRequest
forall x. Rep WriteRequest x -> WriteRequest
forall x. WriteRequest -> Rep WriteRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WriteRequest x -> WriteRequest
$cfrom :: forall x. WriteRequest -> Rep WriteRequest x
Prelude.Generic)
newWriteRequest ::
WriteRequest
newWriteRequest :: WriteRequest
newWriteRequest =
WriteRequest' :: Maybe DeleteRequest -> Maybe PutRequest -> WriteRequest
WriteRequest'
{ $sel:deleteRequest:WriteRequest' :: Maybe DeleteRequest
deleteRequest = Maybe DeleteRequest
forall a. Maybe a
Prelude.Nothing,
$sel:putRequest:WriteRequest' :: Maybe PutRequest
putRequest = Maybe PutRequest
forall a. Maybe a
Prelude.Nothing
}
writeRequest_deleteRequest :: Lens.Lens' WriteRequest (Prelude.Maybe DeleteRequest)
writeRequest_deleteRequest :: (Maybe DeleteRequest -> f (Maybe DeleteRequest))
-> WriteRequest -> f WriteRequest
writeRequest_deleteRequest = (WriteRequest -> Maybe DeleteRequest)
-> (WriteRequest -> Maybe DeleteRequest -> WriteRequest)
-> Lens
WriteRequest
WriteRequest
(Maybe DeleteRequest)
(Maybe DeleteRequest)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteRequest' {Maybe DeleteRequest
deleteRequest :: Maybe DeleteRequest
$sel:deleteRequest:WriteRequest' :: WriteRequest -> Maybe DeleteRequest
deleteRequest} -> Maybe DeleteRequest
deleteRequest) (\s :: WriteRequest
s@WriteRequest' {} Maybe DeleteRequest
a -> WriteRequest
s {$sel:deleteRequest:WriteRequest' :: Maybe DeleteRequest
deleteRequest = Maybe DeleteRequest
a} :: WriteRequest)
writeRequest_putRequest :: Lens.Lens' WriteRequest (Prelude.Maybe PutRequest)
writeRequest_putRequest :: (Maybe PutRequest -> f (Maybe PutRequest))
-> WriteRequest -> f WriteRequest
writeRequest_putRequest = (WriteRequest -> Maybe PutRequest)
-> (WriteRequest -> Maybe PutRequest -> WriteRequest)
-> Lens
WriteRequest WriteRequest (Maybe PutRequest) (Maybe PutRequest)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteRequest' {Maybe PutRequest
putRequest :: Maybe PutRequest
$sel:putRequest:WriteRequest' :: WriteRequest -> Maybe PutRequest
putRequest} -> Maybe PutRequest
putRequest) (\s :: WriteRequest
s@WriteRequest' {} Maybe PutRequest
a -> WriteRequest
s {$sel:putRequest:WriteRequest' :: Maybe PutRequest
putRequest = Maybe PutRequest
a} :: WriteRequest)
instance Core.FromJSON WriteRequest where
parseJSON :: Value -> Parser WriteRequest
parseJSON =
String
-> (Object -> Parser WriteRequest) -> Value -> Parser WriteRequest
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"WriteRequest"
( \Object
x ->
Maybe DeleteRequest -> Maybe PutRequest -> WriteRequest
WriteRequest'
(Maybe DeleteRequest -> Maybe PutRequest -> WriteRequest)
-> Parser (Maybe DeleteRequest)
-> Parser (Maybe PutRequest -> WriteRequest)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DeleteRequest)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeleteRequest")
Parser (Maybe PutRequest -> WriteRequest)
-> Parser (Maybe PutRequest) -> Parser WriteRequest
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe PutRequest)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PutRequest")
)
instance Prelude.Hashable WriteRequest
instance Prelude.NFData WriteRequest
instance Core.ToJSON WriteRequest where
toJSON :: WriteRequest -> Value
toJSON WriteRequest' {Maybe DeleteRequest
Maybe PutRequest
putRequest :: Maybe PutRequest
deleteRequest :: Maybe DeleteRequest
$sel:putRequest:WriteRequest' :: WriteRequest -> Maybe PutRequest
$sel:deleteRequest:WriteRequest' :: WriteRequest -> Maybe DeleteRequest
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"DeleteRequest" Text -> DeleteRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DeleteRequest -> Pair) -> Maybe DeleteRequest -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeleteRequest
deleteRequest,
(Text
"PutRequest" Text -> PutRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (PutRequest -> Pair) -> Maybe PutRequest -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PutRequest
putRequest
]
)