{-# 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.SSM.Types.InventoryResultEntity
-- 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.SSM.Types.InventoryResultEntity where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSM.Types.InventoryResultItem

-- | Inventory query results.
--
-- /See:/ 'newInventoryResultEntity' smart constructor.
data InventoryResultEntity = InventoryResultEntity'
  { -- | The data section in the inventory result entity JSON.
    InventoryResultEntity -> Maybe (HashMap Text InventoryResultItem)
data' :: Prelude.Maybe (Prelude.HashMap Prelude.Text InventoryResultItem),
    -- | ID of the inventory result entity. For example, for managed instance
    -- inventory the result will be the managed instance ID. For EC2 instance
    -- inventory, the result will be the instance ID.
    InventoryResultEntity -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (InventoryResultEntity -> InventoryResultEntity -> Bool
(InventoryResultEntity -> InventoryResultEntity -> Bool)
-> (InventoryResultEntity -> InventoryResultEntity -> Bool)
-> Eq InventoryResultEntity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InventoryResultEntity -> InventoryResultEntity -> Bool
$c/= :: InventoryResultEntity -> InventoryResultEntity -> Bool
== :: InventoryResultEntity -> InventoryResultEntity -> Bool
$c== :: InventoryResultEntity -> InventoryResultEntity -> Bool
Prelude.Eq, ReadPrec [InventoryResultEntity]
ReadPrec InventoryResultEntity
Int -> ReadS InventoryResultEntity
ReadS [InventoryResultEntity]
(Int -> ReadS InventoryResultEntity)
-> ReadS [InventoryResultEntity]
-> ReadPrec InventoryResultEntity
-> ReadPrec [InventoryResultEntity]
-> Read InventoryResultEntity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InventoryResultEntity]
$creadListPrec :: ReadPrec [InventoryResultEntity]
readPrec :: ReadPrec InventoryResultEntity
$creadPrec :: ReadPrec InventoryResultEntity
readList :: ReadS [InventoryResultEntity]
$creadList :: ReadS [InventoryResultEntity]
readsPrec :: Int -> ReadS InventoryResultEntity
$creadsPrec :: Int -> ReadS InventoryResultEntity
Prelude.Read, Int -> InventoryResultEntity -> ShowS
[InventoryResultEntity] -> ShowS
InventoryResultEntity -> String
(Int -> InventoryResultEntity -> ShowS)
-> (InventoryResultEntity -> String)
-> ([InventoryResultEntity] -> ShowS)
-> Show InventoryResultEntity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InventoryResultEntity] -> ShowS
$cshowList :: [InventoryResultEntity] -> ShowS
show :: InventoryResultEntity -> String
$cshow :: InventoryResultEntity -> String
showsPrec :: Int -> InventoryResultEntity -> ShowS
$cshowsPrec :: Int -> InventoryResultEntity -> ShowS
Prelude.Show, (forall x. InventoryResultEntity -> Rep InventoryResultEntity x)
-> (forall x. Rep InventoryResultEntity x -> InventoryResultEntity)
-> Generic InventoryResultEntity
forall x. Rep InventoryResultEntity x -> InventoryResultEntity
forall x. InventoryResultEntity -> Rep InventoryResultEntity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InventoryResultEntity x -> InventoryResultEntity
$cfrom :: forall x. InventoryResultEntity -> Rep InventoryResultEntity x
Prelude.Generic)

-- |
-- Create a value of 'InventoryResultEntity' 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:
--
-- 'data'', 'inventoryResultEntity_data' - The data section in the inventory result entity JSON.
--
-- 'id', 'inventoryResultEntity_id' - ID of the inventory result entity. For example, for managed instance
-- inventory the result will be the managed instance ID. For EC2 instance
-- inventory, the result will be the instance ID.
newInventoryResultEntity ::
  InventoryResultEntity
newInventoryResultEntity :: InventoryResultEntity
newInventoryResultEntity =
  InventoryResultEntity' :: Maybe (HashMap Text InventoryResultItem)
-> Maybe Text -> InventoryResultEntity
InventoryResultEntity'
    { $sel:data':InventoryResultEntity' :: Maybe (HashMap Text InventoryResultItem)
data' = Maybe (HashMap Text InventoryResultItem)
forall a. Maybe a
Prelude.Nothing,
      $sel:id:InventoryResultEntity' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The data section in the inventory result entity JSON.
inventoryResultEntity_data :: Lens.Lens' InventoryResultEntity (Prelude.Maybe (Prelude.HashMap Prelude.Text InventoryResultItem))
inventoryResultEntity_data :: (Maybe (HashMap Text InventoryResultItem)
 -> f (Maybe (HashMap Text InventoryResultItem)))
-> InventoryResultEntity -> f InventoryResultEntity
inventoryResultEntity_data = (InventoryResultEntity -> Maybe (HashMap Text InventoryResultItem))
-> (InventoryResultEntity
    -> Maybe (HashMap Text InventoryResultItem)
    -> InventoryResultEntity)
-> Lens
     InventoryResultEntity
     InventoryResultEntity
     (Maybe (HashMap Text InventoryResultItem))
     (Maybe (HashMap Text InventoryResultItem))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryResultEntity' {Maybe (HashMap Text InventoryResultItem)
data' :: Maybe (HashMap Text InventoryResultItem)
$sel:data':InventoryResultEntity' :: InventoryResultEntity -> Maybe (HashMap Text InventoryResultItem)
data'} -> Maybe (HashMap Text InventoryResultItem)
data') (\s :: InventoryResultEntity
s@InventoryResultEntity' {} Maybe (HashMap Text InventoryResultItem)
a -> InventoryResultEntity
s {$sel:data':InventoryResultEntity' :: Maybe (HashMap Text InventoryResultItem)
data' = Maybe (HashMap Text InventoryResultItem)
a} :: InventoryResultEntity) ((Maybe (HashMap Text InventoryResultItem)
  -> f (Maybe (HashMap Text InventoryResultItem)))
 -> InventoryResultEntity -> f InventoryResultEntity)
-> ((Maybe (HashMap Text InventoryResultItem)
     -> f (Maybe (HashMap Text InventoryResultItem)))
    -> Maybe (HashMap Text InventoryResultItem)
    -> f (Maybe (HashMap Text InventoryResultItem)))
-> (Maybe (HashMap Text InventoryResultItem)
    -> f (Maybe (HashMap Text InventoryResultItem)))
-> InventoryResultEntity
-> f InventoryResultEntity
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text InventoryResultItem)
  (HashMap Text InventoryResultItem)
  (HashMap Text InventoryResultItem)
  (HashMap Text InventoryResultItem)
-> Iso
     (Maybe (HashMap Text InventoryResultItem))
     (Maybe (HashMap Text InventoryResultItem))
     (Maybe (HashMap Text InventoryResultItem))
     (Maybe (HashMap Text InventoryResultItem))
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 InventoryResultItem)
  (HashMap Text InventoryResultItem)
  (HashMap Text InventoryResultItem)
  (HashMap Text InventoryResultItem)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | ID of the inventory result entity. For example, for managed instance
-- inventory the result will be the managed instance ID. For EC2 instance
-- inventory, the result will be the instance ID.
inventoryResultEntity_id :: Lens.Lens' InventoryResultEntity (Prelude.Maybe Prelude.Text)
inventoryResultEntity_id :: (Maybe Text -> f (Maybe Text))
-> InventoryResultEntity -> f InventoryResultEntity
inventoryResultEntity_id = (InventoryResultEntity -> Maybe Text)
-> (InventoryResultEntity -> Maybe Text -> InventoryResultEntity)
-> Lens
     InventoryResultEntity
     InventoryResultEntity
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryResultEntity' {Maybe Text
id :: Maybe Text
$sel:id:InventoryResultEntity' :: InventoryResultEntity -> Maybe Text
id} -> Maybe Text
id) (\s :: InventoryResultEntity
s@InventoryResultEntity' {} Maybe Text
a -> InventoryResultEntity
s {$sel:id:InventoryResultEntity' :: Maybe Text
id = Maybe Text
a} :: InventoryResultEntity)

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

instance Prelude.Hashable InventoryResultEntity

instance Prelude.NFData InventoryResultEntity