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

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

-- | Information collected from managed instances based on your inventory
-- policy document
--
-- /See:/ 'newInventoryItem' smart constructor.
data InventoryItem = 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 -> Maybe (HashMap Text Text)
context :: 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,
    -- | The inventory data of the inventory type.
    InventoryItem -> Maybe [HashMap Text Text]
content :: 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
(InventoryItem -> InventoryItem -> Bool)
-> (InventoryItem -> InventoryItem -> Bool) -> Eq InventoryItem
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]
(Int -> ReadS InventoryItem)
-> ReadS [InventoryItem]
-> ReadPrec InventoryItem
-> ReadPrec [InventoryItem]
-> Read 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
(Int -> InventoryItem -> ShowS)
-> (InventoryItem -> String)
-> ([InventoryItem] -> ShowS)
-> Show InventoryItem
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. InventoryItem -> Rep InventoryItem x)
-> (forall x. Rep InventoryItem x -> InventoryItem)
-> Generic InventoryItem
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:
--
-- '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.
--
-- '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.
--
-- 'content', 'inventoryItem_content' - The inventory data of the inventory 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' :: Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe [HashMap Text Text]
-> Text
-> Text
-> Text
-> InventoryItem
InventoryItem'
      { $sel:context:InventoryItem' :: Maybe (HashMap Text Text)
context = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:contentHash:InventoryItem' :: Maybe Text
contentHash = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:content:InventoryItem' :: Maybe [HashMap Text Text]
content = Maybe [HashMap Text Text]
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_
      }

-- | 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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> InventoryItem -> f InventoryItem
inventoryItem_context = (InventoryItem -> Maybe (HashMap Text Text))
-> (InventoryItem -> Maybe (HashMap Text Text) -> InventoryItem)
-> Lens
     InventoryItem
     InventoryItem
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> InventoryItem -> f InventoryItem)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> InventoryItem
-> f InventoryItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
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 :: (Maybe Text -> f (Maybe Text)) -> InventoryItem -> f InventoryItem
inventoryItem_contentHash = (InventoryItem -> Maybe Text)
-> (InventoryItem -> Maybe Text -> InventoryItem)
-> Lens InventoryItem InventoryItem (Maybe Text) (Maybe Text)
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)

-- | The inventory data of the inventory type.
inventoryItem_content :: Lens.Lens' InventoryItem (Prelude.Maybe [Prelude.HashMap Prelude.Text Prelude.Text])
inventoryItem_content :: (Maybe [HashMap Text Text] -> f (Maybe [HashMap Text Text]))
-> InventoryItem -> f InventoryItem
inventoryItem_content = (InventoryItem -> Maybe [HashMap Text Text])
-> (InventoryItem -> Maybe [HashMap Text Text] -> InventoryItem)
-> Lens
     InventoryItem
     InventoryItem
     (Maybe [HashMap Text Text])
     (Maybe [HashMap Text Text])
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) ((Maybe [HashMap Text Text] -> f (Maybe [HashMap Text Text]))
 -> InventoryItem -> f InventoryItem)
-> ((Maybe [HashMap Text Text] -> f (Maybe [HashMap Text Text]))
    -> Maybe [HashMap Text Text] -> f (Maybe [HashMap Text Text]))
-> (Maybe [HashMap Text Text] -> f (Maybe [HashMap Text Text]))
-> InventoryItem
-> f InventoryItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [HashMap Text Text]
  [HashMap Text Text]
  [HashMap Text Text]
  [HashMap Text Text]
-> Iso
     (Maybe [HashMap Text Text])
     (Maybe [HashMap Text Text])
     (Maybe [HashMap Text Text])
     (Maybe [HashMap Text Text])
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 Text]
  [HashMap Text Text]
  [HashMap Text Text]
  [HashMap Text Text]
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 :: (Text -> f Text) -> InventoryItem -> f InventoryItem
inventoryItem_typeName = (InventoryItem -> Text)
-> (InventoryItem -> Text -> InventoryItem)
-> Lens InventoryItem InventoryItem Text Text
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 :: (Text -> f Text) -> InventoryItem -> f InventoryItem
inventoryItem_schemaVersion = (InventoryItem -> Text)
-> (InventoryItem -> Text -> InventoryItem)
-> Lens InventoryItem InventoryItem Text Text
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 :: (Text -> f Text) -> InventoryItem -> f InventoryItem
inventoryItem_captureTime = (InventoryItem -> Text)
-> (InventoryItem -> Text -> InventoryItem)
-> Lens InventoryItem InventoryItem Text Text
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

instance Prelude.NFData InventoryItem

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