{-# 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.InventoryItemSchema
-- 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.InventoryItemSchema 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
import Amazonka.SSM.Types.InventoryItemAttribute

-- | The inventory item schema definition. Users can use this to compose
-- inventory query filters.
--
-- /See:/ 'newInventoryItemSchema' smart constructor.
data InventoryItemSchema = InventoryItemSchema'
  { -- | The alias name of the inventory type. The alias name is used for display
    -- purposes.
    InventoryItemSchema -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | The schema version for the inventory item.
    InventoryItemSchema -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | The name of the inventory type. Default inventory item type names start
    -- with Amazon Web Services. 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@.
    InventoryItemSchema -> Text
typeName :: Prelude.Text,
    -- | The schema attributes for inventory. This contains data type and
    -- attribute name.
    InventoryItemSchema -> NonEmpty InventoryItemAttribute
attributes :: Prelude.NonEmpty InventoryItemAttribute
  }
  deriving (InventoryItemSchema -> InventoryItemSchema -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InventoryItemSchema -> InventoryItemSchema -> Bool
$c/= :: InventoryItemSchema -> InventoryItemSchema -> Bool
== :: InventoryItemSchema -> InventoryItemSchema -> Bool
$c== :: InventoryItemSchema -> InventoryItemSchema -> Bool
Prelude.Eq, ReadPrec [InventoryItemSchema]
ReadPrec InventoryItemSchema
Int -> ReadS InventoryItemSchema
ReadS [InventoryItemSchema]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InventoryItemSchema]
$creadListPrec :: ReadPrec [InventoryItemSchema]
readPrec :: ReadPrec InventoryItemSchema
$creadPrec :: ReadPrec InventoryItemSchema
readList :: ReadS [InventoryItemSchema]
$creadList :: ReadS [InventoryItemSchema]
readsPrec :: Int -> ReadS InventoryItemSchema
$creadsPrec :: Int -> ReadS InventoryItemSchema
Prelude.Read, Int -> InventoryItemSchema -> ShowS
[InventoryItemSchema] -> ShowS
InventoryItemSchema -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InventoryItemSchema] -> ShowS
$cshowList :: [InventoryItemSchema] -> ShowS
show :: InventoryItemSchema -> String
$cshow :: InventoryItemSchema -> String
showsPrec :: Int -> InventoryItemSchema -> ShowS
$cshowsPrec :: Int -> InventoryItemSchema -> ShowS
Prelude.Show, forall x. Rep InventoryItemSchema x -> InventoryItemSchema
forall x. InventoryItemSchema -> Rep InventoryItemSchema x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InventoryItemSchema x -> InventoryItemSchema
$cfrom :: forall x. InventoryItemSchema -> Rep InventoryItemSchema x
Prelude.Generic)

-- |
-- Create a value of 'InventoryItemSchema' 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:
--
-- 'displayName', 'inventoryItemSchema_displayName' - The alias name of the inventory type. The alias name is used for display
-- purposes.
--
-- 'version', 'inventoryItemSchema_version' - The schema version for the inventory item.
--
-- 'typeName', 'inventoryItemSchema_typeName' - The name of the inventory type. Default inventory item type names start
-- with Amazon Web Services. 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@.
--
-- 'attributes', 'inventoryItemSchema_attributes' - The schema attributes for inventory. This contains data type and
-- attribute name.
newInventoryItemSchema ::
  -- | 'typeName'
  Prelude.Text ->
  -- | 'attributes'
  Prelude.NonEmpty InventoryItemAttribute ->
  InventoryItemSchema
newInventoryItemSchema :: Text -> NonEmpty InventoryItemAttribute -> InventoryItemSchema
newInventoryItemSchema Text
pTypeName_ NonEmpty InventoryItemAttribute
pAttributes_ =
  InventoryItemSchema'
    { $sel:displayName:InventoryItemSchema' :: Maybe Text
displayName = forall a. Maybe a
Prelude.Nothing,
      $sel:version:InventoryItemSchema' :: Maybe Text
version = forall a. Maybe a
Prelude.Nothing,
      $sel:typeName:InventoryItemSchema' :: Text
typeName = Text
pTypeName_,
      $sel:attributes:InventoryItemSchema' :: NonEmpty InventoryItemAttribute
attributes = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty InventoryItemAttribute
pAttributes_
    }

-- | The alias name of the inventory type. The alias name is used for display
-- purposes.
inventoryItemSchema_displayName :: Lens.Lens' InventoryItemSchema (Prelude.Maybe Prelude.Text)
inventoryItemSchema_displayName :: Lens' InventoryItemSchema (Maybe Text)
inventoryItemSchema_displayName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryItemSchema' {Maybe Text
displayName :: Maybe Text
$sel:displayName:InventoryItemSchema' :: InventoryItemSchema -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: InventoryItemSchema
s@InventoryItemSchema' {} Maybe Text
a -> InventoryItemSchema
s {$sel:displayName:InventoryItemSchema' :: Maybe Text
displayName = Maybe Text
a} :: InventoryItemSchema)

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

-- | The name of the inventory type. Default inventory item type names start
-- with Amazon Web Services. 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@.
inventoryItemSchema_typeName :: Lens.Lens' InventoryItemSchema Prelude.Text
inventoryItemSchema_typeName :: Lens' InventoryItemSchema Text
inventoryItemSchema_typeName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryItemSchema' {Text
typeName :: Text
$sel:typeName:InventoryItemSchema' :: InventoryItemSchema -> Text
typeName} -> Text
typeName) (\s :: InventoryItemSchema
s@InventoryItemSchema' {} Text
a -> InventoryItemSchema
s {$sel:typeName:InventoryItemSchema' :: Text
typeName = Text
a} :: InventoryItemSchema)

-- | The schema attributes for inventory. This contains data type and
-- attribute name.
inventoryItemSchema_attributes :: Lens.Lens' InventoryItemSchema (Prelude.NonEmpty InventoryItemAttribute)
inventoryItemSchema_attributes :: Lens' InventoryItemSchema (NonEmpty InventoryItemAttribute)
inventoryItemSchema_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryItemSchema' {NonEmpty InventoryItemAttribute
attributes :: NonEmpty InventoryItemAttribute
$sel:attributes:InventoryItemSchema' :: InventoryItemSchema -> NonEmpty InventoryItemAttribute
attributes} -> NonEmpty InventoryItemAttribute
attributes) (\s :: InventoryItemSchema
s@InventoryItemSchema' {} NonEmpty InventoryItemAttribute
a -> InventoryItemSchema
s {$sel:attributes:InventoryItemSchema' :: NonEmpty InventoryItemAttribute
attributes = NonEmpty InventoryItemAttribute
a} :: InventoryItemSchema) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON InventoryItemSchema where
  parseJSON :: Value -> Parser InventoryItemSchema
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InventoryItemSchema"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Text
-> NonEmpty InventoryItemAttribute
-> InventoryItemSchema
InventoryItemSchema'
            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
"DisplayName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Version")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"TypeName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Attributes")
      )

instance Prelude.Hashable InventoryItemSchema where
  hashWithSalt :: Int -> InventoryItemSchema -> Int
hashWithSalt Int
_salt InventoryItemSchema' {Maybe Text
NonEmpty InventoryItemAttribute
Text
attributes :: NonEmpty InventoryItemAttribute
typeName :: Text
version :: Maybe Text
displayName :: Maybe Text
$sel:attributes:InventoryItemSchema' :: InventoryItemSchema -> NonEmpty InventoryItemAttribute
$sel:typeName:InventoryItemSchema' :: InventoryItemSchema -> Text
$sel:version:InventoryItemSchema' :: InventoryItemSchema -> Maybe Text
$sel:displayName:InventoryItemSchema' :: InventoryItemSchema -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
displayName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
version
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
typeName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty InventoryItemAttribute
attributes

instance Prelude.NFData InventoryItemSchema where
  rnf :: InventoryItemSchema -> ()
rnf InventoryItemSchema' {Maybe Text
NonEmpty InventoryItemAttribute
Text
attributes :: NonEmpty InventoryItemAttribute
typeName :: Text
version :: Maybe Text
displayName :: Maybe Text
$sel:attributes:InventoryItemSchema' :: InventoryItemSchema -> NonEmpty InventoryItemAttribute
$sel:typeName:InventoryItemSchema' :: InventoryItemSchema -> Text
$sel:version:InventoryItemSchema' :: InventoryItemSchema -> Maybe Text
$sel:displayName:InventoryItemSchema' :: InventoryItemSchema -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
displayName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
version
      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 NonEmpty InventoryItemAttribute
attributes