{-# 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.DynamoDB.Types.TransactGetItem
-- 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.DynamoDB.Types.TransactGetItem where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.Get
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies an item to be retrieved as part of the transaction.
--
-- /See:/ 'newTransactGetItem' smart constructor.
data TransactGetItem = TransactGetItem'
  { -- | Contains the primary key that identifies the item to get, together with
    -- the name of the table that contains the item, and optionally the
    -- specific attributes of the item to retrieve.
    TransactGetItem -> Get
get' :: Get
  }
  deriving (TransactGetItem -> TransactGetItem -> Bool
(TransactGetItem -> TransactGetItem -> Bool)
-> (TransactGetItem -> TransactGetItem -> Bool)
-> Eq TransactGetItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransactGetItem -> TransactGetItem -> Bool
$c/= :: TransactGetItem -> TransactGetItem -> Bool
== :: TransactGetItem -> TransactGetItem -> Bool
$c== :: TransactGetItem -> TransactGetItem -> Bool
Prelude.Eq, ReadPrec [TransactGetItem]
ReadPrec TransactGetItem
Int -> ReadS TransactGetItem
ReadS [TransactGetItem]
(Int -> ReadS TransactGetItem)
-> ReadS [TransactGetItem]
-> ReadPrec TransactGetItem
-> ReadPrec [TransactGetItem]
-> Read TransactGetItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TransactGetItem]
$creadListPrec :: ReadPrec [TransactGetItem]
readPrec :: ReadPrec TransactGetItem
$creadPrec :: ReadPrec TransactGetItem
readList :: ReadS [TransactGetItem]
$creadList :: ReadS [TransactGetItem]
readsPrec :: Int -> ReadS TransactGetItem
$creadsPrec :: Int -> ReadS TransactGetItem
Prelude.Read, Int -> TransactGetItem -> ShowS
[TransactGetItem] -> ShowS
TransactGetItem -> String
(Int -> TransactGetItem -> ShowS)
-> (TransactGetItem -> String)
-> ([TransactGetItem] -> ShowS)
-> Show TransactGetItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransactGetItem] -> ShowS
$cshowList :: [TransactGetItem] -> ShowS
show :: TransactGetItem -> String
$cshow :: TransactGetItem -> String
showsPrec :: Int -> TransactGetItem -> ShowS
$cshowsPrec :: Int -> TransactGetItem -> ShowS
Prelude.Show, (forall x. TransactGetItem -> Rep TransactGetItem x)
-> (forall x. Rep TransactGetItem x -> TransactGetItem)
-> Generic TransactGetItem
forall x. Rep TransactGetItem x -> TransactGetItem
forall x. TransactGetItem -> Rep TransactGetItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TransactGetItem x -> TransactGetItem
$cfrom :: forall x. TransactGetItem -> Rep TransactGetItem x
Prelude.Generic)

-- |
-- Create a value of 'TransactGetItem' 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:
--
-- 'get'', 'transactGetItem_get' - Contains the primary key that identifies the item to get, together with
-- the name of the table that contains the item, and optionally the
-- specific attributes of the item to retrieve.
newTransactGetItem ::
  -- | 'get''
  Get ->
  TransactGetItem
newTransactGetItem :: Get -> TransactGetItem
newTransactGetItem Get
pGet_ =
  TransactGetItem' :: Get -> TransactGetItem
TransactGetItem' {$sel:get':TransactGetItem' :: Get
get' = Get
pGet_}

-- | Contains the primary key that identifies the item to get, together with
-- the name of the table that contains the item, and optionally the
-- specific attributes of the item to retrieve.
transactGetItem_get :: Lens.Lens' TransactGetItem Get
transactGetItem_get :: (Get -> f Get) -> TransactGetItem -> f TransactGetItem
transactGetItem_get = (TransactGetItem -> Get)
-> (TransactGetItem -> Get -> TransactGetItem)
-> Lens TransactGetItem TransactGetItem Get Get
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransactGetItem' {Get
get' :: Get
$sel:get':TransactGetItem' :: TransactGetItem -> Get
get'} -> Get
get') (\s :: TransactGetItem
s@TransactGetItem' {} Get
a -> TransactGetItem
s {$sel:get':TransactGetItem' :: Get
get' = Get
a} :: TransactGetItem)

instance Prelude.Hashable TransactGetItem

instance Prelude.NFData TransactGetItem

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