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

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.AttributeValue
import qualified Amazonka.Lens as Lens
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
(ItemResponse -> ItemResponse -> Bool)
-> (ItemResponse -> ItemResponse -> Bool) -> Eq ItemResponse
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]
(Int -> ReadS ItemResponse)
-> ReadS [ItemResponse]
-> ReadPrec ItemResponse
-> ReadPrec [ItemResponse]
-> Read 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
(Int -> ItemResponse -> ShowS)
-> (ItemResponse -> String)
-> ([ItemResponse] -> ShowS)
-> Show ItemResponse
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. ItemResponse -> Rep ItemResponse x)
-> (forall x. Rep ItemResponse x -> ItemResponse)
-> Generic ItemResponse
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' :: Maybe (HashMap Text AttributeValue) -> ItemResponse
ItemResponse' {$sel:item:ItemResponse' :: Maybe (HashMap Text AttributeValue)
item = Maybe (HashMap Text AttributeValue)
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 :: (Maybe (HashMap Text AttributeValue)
 -> f (Maybe (HashMap Text AttributeValue)))
-> ItemResponse -> f ItemResponse
itemResponse_item = (ItemResponse -> Maybe (HashMap Text AttributeValue))
-> (ItemResponse
    -> Maybe (HashMap Text AttributeValue) -> ItemResponse)
-> Lens
     ItemResponse
     ItemResponse
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
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) ((Maybe (HashMap Text AttributeValue)
  -> f (Maybe (HashMap Text AttributeValue)))
 -> ItemResponse -> f ItemResponse)
-> ((Maybe (HashMap Text AttributeValue)
     -> f (Maybe (HashMap Text AttributeValue)))
    -> Maybe (HashMap Text AttributeValue)
    -> f (Maybe (HashMap Text AttributeValue)))
-> (Maybe (HashMap Text AttributeValue)
    -> f (Maybe (HashMap Text AttributeValue)))
-> ItemResponse
-> f ItemResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
-> Iso
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
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 AnIso
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable ItemResponse

instance Prelude.NFData ItemResponse