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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DynamoDB.Types.AttributeValue
import Amazonka.DynamoDB.Types.WriteRequest
import qualified Amazonka.Prelude as Prelude

-- | Details for the requested item.
--
-- /See:/ 'newItemResponse' smart constructor.
data ItemResponse = ItemResponse'
  { -- | Map of attribute data consisting of the data type and attribute value.
    ItemResponse -> Maybe (HashMap Text AttributeValue)
item :: Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue)
  }
  deriving (ItemResponse -> ItemResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ItemResponse -> ItemResponse -> Bool
$c/= :: ItemResponse -> ItemResponse -> Bool
== :: ItemResponse -> ItemResponse -> Bool
$c== :: ItemResponse -> ItemResponse -> Bool
Prelude.Eq, ReadPrec [ItemResponse]
ReadPrec ItemResponse
Int -> ReadS ItemResponse
ReadS [ItemResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ItemResponse]
$creadListPrec :: ReadPrec [ItemResponse]
readPrec :: ReadPrec ItemResponse
$creadPrec :: ReadPrec ItemResponse
readList :: ReadS [ItemResponse]
$creadList :: ReadS [ItemResponse]
readsPrec :: Int -> ReadS ItemResponse
$creadsPrec :: Int -> ReadS ItemResponse
Prelude.Read, Int -> ItemResponse -> ShowS
[ItemResponse] -> ShowS
ItemResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ItemResponse] -> ShowS
$cshowList :: [ItemResponse] -> ShowS
show :: ItemResponse -> String
$cshow :: ItemResponse -> String
showsPrec :: Int -> ItemResponse -> ShowS
$cshowsPrec :: Int -> ItemResponse -> ShowS
Prelude.Show, forall x. Rep ItemResponse x -> ItemResponse
forall x. ItemResponse -> Rep ItemResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ItemResponse x -> ItemResponse
$cfrom :: forall x. ItemResponse -> Rep ItemResponse x
Prelude.Generic)

-- |
-- Create a value of 'ItemResponse' 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:
--
-- 'item', 'itemResponse_item' - Map of attribute data consisting of the data type and attribute value.
newItemResponse ::
  ItemResponse
newItemResponse :: ItemResponse
newItemResponse =
  ItemResponse' {$sel:item:ItemResponse' :: Maybe (HashMap Text AttributeValue)
item = forall a. Maybe a
Prelude.Nothing}

-- | Map of attribute data consisting of the data type and attribute value.
itemResponse_item :: Lens.Lens' ItemResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue))
itemResponse_item :: Lens' ItemResponse (Maybe (HashMap Text AttributeValue))
itemResponse_item = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ItemResponse' {Maybe (HashMap Text AttributeValue)
item :: Maybe (HashMap Text AttributeValue)
$sel:item:ItemResponse' :: ItemResponse -> Maybe (HashMap Text AttributeValue)
item} -> Maybe (HashMap Text AttributeValue)
item) (\s :: ItemResponse
s@ItemResponse' {} Maybe (HashMap Text AttributeValue)
a -> ItemResponse
s {$sel:item:ItemResponse' :: Maybe (HashMap Text AttributeValue)
item = Maybe (HashMap Text AttributeValue)
a} :: ItemResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ItemResponse where
  parseJSON :: Value -> Parser ItemResponse
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ItemResponse"
      ( \Object
x ->
          Maybe (HashMap Text AttributeValue) -> ItemResponse
ItemResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Item" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ItemResponse where
  hashWithSalt :: Int -> ItemResponse -> Int
hashWithSalt Int
_salt ItemResponse' {Maybe (HashMap Text AttributeValue)
item :: Maybe (HashMap Text AttributeValue)
$sel:item:ItemResponse' :: ItemResponse -> Maybe (HashMap Text AttributeValue)
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text AttributeValue)
item

instance Prelude.NFData ItemResponse where
  rnf :: ItemResponse -> ()
rnf ItemResponse' {Maybe (HashMap Text AttributeValue)
item :: Maybe (HashMap Text AttributeValue)
$sel:item:ItemResponse' :: ItemResponse -> Maybe (HashMap Text AttributeValue)
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text AttributeValue)
item