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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 schema version for the inventory item.
    InventoryItemSchema -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | The alias name of the inventory type. The alias name is used for display
    -- purposes.
    InventoryItemSchema -> Maybe Text
displayName :: 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
(InventoryItemSchema -> InventoryItemSchema -> Bool)
-> (InventoryItemSchema -> InventoryItemSchema -> Bool)
-> Eq InventoryItemSchema
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]
(Int -> ReadS InventoryItemSchema)
-> ReadS [InventoryItemSchema]
-> ReadPrec InventoryItemSchema
-> ReadPrec [InventoryItemSchema]
-> Read 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
(Int -> InventoryItemSchema -> ShowS)
-> (InventoryItemSchema -> String)
-> ([InventoryItemSchema] -> ShowS)
-> Show InventoryItemSchema
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. InventoryItemSchema -> Rep InventoryItemSchema x)
-> (forall x. Rep InventoryItemSchema x -> InventoryItemSchema)
-> Generic InventoryItemSchema
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:
--
-- 'version', 'inventoryItemSchema_version' - The schema version for the inventory item.
--
-- 'displayName', 'inventoryItemSchema_displayName' - The alias name of the inventory type. The alias name is used for display
-- purposes.
--
-- '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' :: Maybe Text
-> Maybe Text
-> Text
-> NonEmpty InventoryItemAttribute
-> InventoryItemSchema
InventoryItemSchema'
    { $sel:version:InventoryItemSchema' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:displayName:InventoryItemSchema' :: Maybe Text
displayName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:typeName:InventoryItemSchema' :: Text
typeName = Text
pTypeName_,
      $sel:attributes:InventoryItemSchema' :: NonEmpty InventoryItemAttribute
attributes = Tagged
  (NonEmpty InventoryItemAttribute)
  (Identity (NonEmpty InventoryItemAttribute))
-> Tagged
     (NonEmpty InventoryItemAttribute)
     (Identity (NonEmpty InventoryItemAttribute))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty InventoryItemAttribute)
   (Identity (NonEmpty InventoryItemAttribute))
 -> Tagged
      (NonEmpty InventoryItemAttribute)
      (Identity (NonEmpty InventoryItemAttribute)))
-> NonEmpty InventoryItemAttribute
-> NonEmpty InventoryItemAttribute
forall t b. AReview t b -> b -> t
Lens.# NonEmpty InventoryItemAttribute
pAttributes_
    }

-- | The schema version for the inventory item.
inventoryItemSchema_version :: Lens.Lens' InventoryItemSchema (Prelude.Maybe Prelude.Text)
inventoryItemSchema_version :: (Maybe Text -> f (Maybe Text))
-> InventoryItemSchema -> f InventoryItemSchema
inventoryItemSchema_version = (InventoryItemSchema -> Maybe Text)
-> (InventoryItemSchema -> Maybe Text -> InventoryItemSchema)
-> Lens
     InventoryItemSchema InventoryItemSchema (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text))
-> InventoryItemSchema -> f InventoryItemSchema
inventoryItemSchema_displayName = (InventoryItemSchema -> Maybe Text)
-> (InventoryItemSchema -> Maybe Text -> InventoryItemSchema)
-> Lens
     InventoryItemSchema InventoryItemSchema (Maybe Text) (Maybe Text)
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 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 :: (Text -> f Text) -> InventoryItemSchema -> f InventoryItemSchema
inventoryItemSchema_typeName = (InventoryItemSchema -> Text)
-> (InventoryItemSchema -> Text -> InventoryItemSchema)
-> Lens InventoryItemSchema InventoryItemSchema Text Text
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 :: (NonEmpty InventoryItemAttribute
 -> f (NonEmpty InventoryItemAttribute))
-> InventoryItemSchema -> f InventoryItemSchema
inventoryItemSchema_attributes = (InventoryItemSchema -> NonEmpty InventoryItemAttribute)
-> (InventoryItemSchema
    -> NonEmpty InventoryItemAttribute -> InventoryItemSchema)
-> Lens
     InventoryItemSchema
     InventoryItemSchema
     (NonEmpty InventoryItemAttribute)
     (NonEmpty InventoryItemAttribute)
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) ((NonEmpty InventoryItemAttribute
  -> f (NonEmpty InventoryItemAttribute))
 -> InventoryItemSchema -> f InventoryItemSchema)
-> ((NonEmpty InventoryItemAttribute
     -> f (NonEmpty InventoryItemAttribute))
    -> NonEmpty InventoryItemAttribute
    -> f (NonEmpty InventoryItemAttribute))
-> (NonEmpty InventoryItemAttribute
    -> f (NonEmpty InventoryItemAttribute))
-> InventoryItemSchema
-> f InventoryItemSchema
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty InventoryItemAttribute
 -> f (NonEmpty InventoryItemAttribute))
-> NonEmpty InventoryItemAttribute
-> f (NonEmpty InventoryItemAttribute)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable InventoryItemSchema

instance Prelude.NFData InventoryItemSchema