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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Information collected from managed nodes based on your inventory policy
-- document
--
-- /See:/ 'newInventoryItem' smart constructor.
data InventoryItem = InventoryItem'
  { -- | The inventory data of the inventory type.
    InventoryItem -> Maybe [HashMap Text Text]
content :: Prelude.Maybe [Prelude.HashMap Prelude.Text Prelude.Text],
    -- | MD5 hash of the inventory item type contents. The content hash is used
    -- to determine whether to update inventory information. The PutInventory
    -- API doesn\'t update the inventory item type contents if the MD5 hash
    -- hasn\'t changed since last update.
    InventoryItem -> Maybe Text
contentHash :: Prelude.Maybe Prelude.Text,
    -- | A map of associated properties for a specified inventory type. For
    -- example, with this attribute, you can specify the @ExecutionId@,
    -- @ExecutionType@, @ComplianceType@ properties of the @AWS:ComplianceItem@
    -- type.
    InventoryItem -> Maybe (HashMap Text Text)
context :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the inventory type. Default inventory item type names start
    -- with @AWS@. Custom inventory type names will start with Custom. Default
    -- inventory item types include the following: @AWS:AWSComponent@,
    -- @AWS:Application@, @AWS:InstanceInformation@, @AWS:Network@, and
    -- @AWS:WindowsUpdate@.
    InventoryItem -> Text
typeName :: Prelude.Text,
    -- | The schema version for the inventory item.
    InventoryItem -> Text
schemaVersion :: Prelude.Text,
    -- | The time the inventory information was collected.
    InventoryItem -> Text
captureTime :: Prelude.Text
  }
  deriving (InventoryItem -> InventoryItem -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InventoryItem -> InventoryItem -> Bool
$c/= :: InventoryItem -> InventoryItem -> Bool
== :: InventoryItem -> InventoryItem -> Bool
$c== :: InventoryItem -> InventoryItem -> Bool
Prelude.Eq, ReadPrec [InventoryItem]
ReadPrec InventoryItem
Int -> ReadS InventoryItem
ReadS [InventoryItem]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InventoryItem]
$creadListPrec :: ReadPrec [InventoryItem]
readPrec :: ReadPrec InventoryItem
$creadPrec :: ReadPrec InventoryItem
readList :: ReadS [InventoryItem]
$creadList :: ReadS [InventoryItem]
readsPrec :: Int -> ReadS InventoryItem
$creadsPrec :: Int -> ReadS InventoryItem
Prelude.Read, Int -> InventoryItem -> ShowS
[InventoryItem] -> ShowS
InventoryItem -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InventoryItem] -> ShowS
$cshowList :: [InventoryItem] -> ShowS
show :: InventoryItem -> String
$cshow :: InventoryItem -> String
showsPrec :: Int -> InventoryItem -> ShowS
$cshowsPrec :: Int -> InventoryItem -> ShowS
Prelude.Show, forall x. Rep InventoryItem x -> InventoryItem
forall x. InventoryItem -> Rep InventoryItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InventoryItem x -> InventoryItem
$cfrom :: forall x. InventoryItem -> Rep InventoryItem x
Prelude.Generic)

-- |
-- Create a value of 'InventoryItem' 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:
--
-- 'content', 'inventoryItem_content' - The inventory data of the inventory type.
--
-- 'contentHash', 'inventoryItem_contentHash' - MD5 hash of the inventory item type contents. The content hash is used
-- to determine whether to update inventory information. The PutInventory
-- API doesn\'t update the inventory item type contents if the MD5 hash
-- hasn\'t changed since last update.
--
-- 'context', 'inventoryItem_context' - A map of associated properties for a specified inventory type. For
-- example, with this attribute, you can specify the @ExecutionId@,
-- @ExecutionType@, @ComplianceType@ properties of the @AWS:ComplianceItem@
-- type.
--
-- 'typeName', 'inventoryItem_typeName' - The name of the inventory type. Default inventory item type names start
-- with @AWS@. Custom inventory type names will start with Custom. Default
-- inventory item types include the following: @AWS:AWSComponent@,
-- @AWS:Application@, @AWS:InstanceInformation@, @AWS:Network@, and
-- @AWS:WindowsUpdate@.
--
-- 'schemaVersion', 'inventoryItem_schemaVersion' - The schema version for the inventory item.
--
-- 'captureTime', 'inventoryItem_captureTime' - The time the inventory information was collected.
newInventoryItem ::
  -- | 'typeName'
  Prelude.Text ->
  -- | 'schemaVersion'
  Prelude.Text ->
  -- | 'captureTime'
  Prelude.Text ->
  InventoryItem
newInventoryItem :: Text -> Text -> Text -> InventoryItem
newInventoryItem
  Text
pTypeName_
  Text
pSchemaVersion_
  Text
pCaptureTime_ =
    InventoryItem'
      { $sel:content:InventoryItem' :: Maybe [HashMap Text Text]
content = forall a. Maybe a
Prelude.Nothing,
        $sel:contentHash:InventoryItem' :: Maybe Text
contentHash = forall a. Maybe a
Prelude.Nothing,
        $sel:context:InventoryItem' :: Maybe (HashMap Text Text)
context = forall a. Maybe a
Prelude.Nothing,
        $sel:typeName:InventoryItem' :: Text
typeName = Text
pTypeName_,
        $sel:schemaVersion:InventoryItem' :: Text
schemaVersion = Text
pSchemaVersion_,
        $sel:captureTime:InventoryItem' :: Text
captureTime = Text
pCaptureTime_
      }

-- | The inventory data of the inventory type.
inventoryItem_content :: Lens.Lens' InventoryItem (Prelude.Maybe [Prelude.HashMap Prelude.Text Prelude.Text])
inventoryItem_content :: Lens' InventoryItem (Maybe [HashMap Text Text])
inventoryItem_content = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryItem' {Maybe [HashMap Text Text]
content :: Maybe [HashMap Text Text]
$sel:content:InventoryItem' :: InventoryItem -> Maybe [HashMap Text Text]
content} -> Maybe [HashMap Text Text]
content) (\s :: InventoryItem
s@InventoryItem' {} Maybe [HashMap Text Text]
a -> InventoryItem
s {$sel:content:InventoryItem' :: Maybe [HashMap Text Text]
content = Maybe [HashMap Text Text]
a} :: InventoryItem) 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

-- | MD5 hash of the inventory item type contents. The content hash is used
-- to determine whether to update inventory information. The PutInventory
-- API doesn\'t update the inventory item type contents if the MD5 hash
-- hasn\'t changed since last update.
inventoryItem_contentHash :: Lens.Lens' InventoryItem (Prelude.Maybe Prelude.Text)
inventoryItem_contentHash :: Lens' InventoryItem (Maybe Text)
inventoryItem_contentHash = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryItem' {Maybe Text
contentHash :: Maybe Text
$sel:contentHash:InventoryItem' :: InventoryItem -> Maybe Text
contentHash} -> Maybe Text
contentHash) (\s :: InventoryItem
s@InventoryItem' {} Maybe Text
a -> InventoryItem
s {$sel:contentHash:InventoryItem' :: Maybe Text
contentHash = Maybe Text
a} :: InventoryItem)

-- | A map of associated properties for a specified inventory type. For
-- example, with this attribute, you can specify the @ExecutionId@,
-- @ExecutionType@, @ComplianceType@ properties of the @AWS:ComplianceItem@
-- type.
inventoryItem_context :: Lens.Lens' InventoryItem (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
inventoryItem_context :: Lens' InventoryItem (Maybe (HashMap Text Text))
inventoryItem_context = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryItem' {Maybe (HashMap Text Text)
context :: Maybe (HashMap Text Text)
$sel:context:InventoryItem' :: InventoryItem -> Maybe (HashMap Text Text)
context} -> Maybe (HashMap Text Text)
context) (\s :: InventoryItem
s@InventoryItem' {} Maybe (HashMap Text Text)
a -> InventoryItem
s {$sel:context:InventoryItem' :: Maybe (HashMap Text Text)
context = Maybe (HashMap Text Text)
a} :: InventoryItem) 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

-- | The name of the inventory type. Default inventory item type names start
-- with @AWS@. Custom inventory type names will start with Custom. Default
-- inventory item types include the following: @AWS:AWSComponent@,
-- @AWS:Application@, @AWS:InstanceInformation@, @AWS:Network@, and
-- @AWS:WindowsUpdate@.
inventoryItem_typeName :: Lens.Lens' InventoryItem Prelude.Text
inventoryItem_typeName :: Lens' InventoryItem Text
inventoryItem_typeName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryItem' {Text
typeName :: Text
$sel:typeName:InventoryItem' :: InventoryItem -> Text
typeName} -> Text
typeName) (\s :: InventoryItem
s@InventoryItem' {} Text
a -> InventoryItem
s {$sel:typeName:InventoryItem' :: Text
typeName = Text
a} :: InventoryItem)

-- | The schema version for the inventory item.
inventoryItem_schemaVersion :: Lens.Lens' InventoryItem Prelude.Text
inventoryItem_schemaVersion :: Lens' InventoryItem Text
inventoryItem_schemaVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryItem' {Text
schemaVersion :: Text
$sel:schemaVersion:InventoryItem' :: InventoryItem -> Text
schemaVersion} -> Text
schemaVersion) (\s :: InventoryItem
s@InventoryItem' {} Text
a -> InventoryItem
s {$sel:schemaVersion:InventoryItem' :: Text
schemaVersion = Text
a} :: InventoryItem)

-- | The time the inventory information was collected.
inventoryItem_captureTime :: Lens.Lens' InventoryItem Prelude.Text
inventoryItem_captureTime :: Lens' InventoryItem Text
inventoryItem_captureTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryItem' {Text
captureTime :: Text
$sel:captureTime:InventoryItem' :: InventoryItem -> Text
captureTime} -> Text
captureTime) (\s :: InventoryItem
s@InventoryItem' {} Text
a -> InventoryItem
s {$sel:captureTime:InventoryItem' :: Text
captureTime = Text
a} :: InventoryItem)

instance Prelude.Hashable InventoryItem where
  hashWithSalt :: Int -> InventoryItem -> Int
hashWithSalt Int
_salt InventoryItem' {Maybe [HashMap Text Text]
Maybe Text
Maybe (HashMap Text Text)
Text
captureTime :: Text
schemaVersion :: Text
typeName :: Text
context :: Maybe (HashMap Text Text)
contentHash :: Maybe Text
content :: Maybe [HashMap Text Text]
$sel:captureTime:InventoryItem' :: InventoryItem -> Text
$sel:schemaVersion:InventoryItem' :: InventoryItem -> Text
$sel:typeName:InventoryItem' :: InventoryItem -> Text
$sel:context:InventoryItem' :: InventoryItem -> Maybe (HashMap Text Text)
$sel:contentHash:InventoryItem' :: InventoryItem -> Maybe Text
$sel:content:InventoryItem' :: InventoryItem -> Maybe [HashMap Text Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [HashMap Text Text]
content
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
contentHash
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
context
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
typeName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
schemaVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
captureTime

instance Prelude.NFData InventoryItem where
  rnf :: InventoryItem -> ()
rnf InventoryItem' {Maybe [HashMap Text Text]
Maybe Text
Maybe (HashMap Text Text)
Text
captureTime :: Text
schemaVersion :: Text
typeName :: Text
context :: Maybe (HashMap Text Text)
contentHash :: Maybe Text
content :: Maybe [HashMap Text Text]
$sel:captureTime:InventoryItem' :: InventoryItem -> Text
$sel:schemaVersion:InventoryItem' :: InventoryItem -> Text
$sel:typeName:InventoryItem' :: InventoryItem -> Text
$sel:context:InventoryItem' :: InventoryItem -> Maybe (HashMap Text Text)
$sel:contentHash:InventoryItem' :: InventoryItem -> Maybe Text
$sel:content:InventoryItem' :: InventoryItem -> Maybe [HashMap Text Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [HashMap Text Text]
content
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contentHash
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
context
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
typeName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
schemaVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
captureTime

instance Data.ToJSON InventoryItem where
  toJSON :: InventoryItem -> Value
toJSON InventoryItem' {Maybe [HashMap Text Text]
Maybe Text
Maybe (HashMap Text Text)
Text
captureTime :: Text
schemaVersion :: Text
typeName :: Text
context :: Maybe (HashMap Text Text)
contentHash :: Maybe Text
content :: Maybe [HashMap Text Text]
$sel:captureTime:InventoryItem' :: InventoryItem -> Text
$sel:schemaVersion:InventoryItem' :: InventoryItem -> Text
$sel:typeName:InventoryItem' :: InventoryItem -> Text
$sel:context:InventoryItem' :: InventoryItem -> Maybe (HashMap Text Text)
$sel:contentHash:InventoryItem' :: InventoryItem -> Maybe Text
$sel:content:InventoryItem' :: InventoryItem -> Maybe [HashMap Text Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Content" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [HashMap Text Text]
content,
            (Key
"ContentHash" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
contentHash,
            (Key
"Context" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
context,
            forall a. a -> Maybe a
Prelude.Just (Key
"TypeName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
typeName),
            forall a. a -> Maybe a
Prelude.Just (Key
"SchemaVersion" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
schemaVersion),
            forall a. a -> Maybe a
Prelude.Just (Key
"CaptureTime" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
captureTime)
          ]
      )