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

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

-- | A user-defined set of one or more filters on which to aggregate
-- inventory data. Groups return a count of resources that match and don\'t
-- match the specified criteria.
--
-- /See:/ 'newInventoryGroup' smart constructor.
data InventoryGroup = InventoryGroup'
  { -- | The name of the group.
    InventoryGroup -> Text
name :: Prelude.Text,
    -- | Filters define the criteria for the group. The @matchingCount@ field
    -- displays the number of resources that match the criteria. The
    -- @notMatchingCount@ field displays the number of resources that don\'t
    -- match the criteria.
    InventoryGroup -> NonEmpty InventoryFilter
filters :: Prelude.NonEmpty InventoryFilter
  }
  deriving (InventoryGroup -> InventoryGroup -> Bool
(InventoryGroup -> InventoryGroup -> Bool)
-> (InventoryGroup -> InventoryGroup -> Bool) -> Eq InventoryGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InventoryGroup -> InventoryGroup -> Bool
$c/= :: InventoryGroup -> InventoryGroup -> Bool
== :: InventoryGroup -> InventoryGroup -> Bool
$c== :: InventoryGroup -> InventoryGroup -> Bool
Prelude.Eq, ReadPrec [InventoryGroup]
ReadPrec InventoryGroup
Int -> ReadS InventoryGroup
ReadS [InventoryGroup]
(Int -> ReadS InventoryGroup)
-> ReadS [InventoryGroup]
-> ReadPrec InventoryGroup
-> ReadPrec [InventoryGroup]
-> Read InventoryGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InventoryGroup]
$creadListPrec :: ReadPrec [InventoryGroup]
readPrec :: ReadPrec InventoryGroup
$creadPrec :: ReadPrec InventoryGroup
readList :: ReadS [InventoryGroup]
$creadList :: ReadS [InventoryGroup]
readsPrec :: Int -> ReadS InventoryGroup
$creadsPrec :: Int -> ReadS InventoryGroup
Prelude.Read, Int -> InventoryGroup -> ShowS
[InventoryGroup] -> ShowS
InventoryGroup -> String
(Int -> InventoryGroup -> ShowS)
-> (InventoryGroup -> String)
-> ([InventoryGroup] -> ShowS)
-> Show InventoryGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InventoryGroup] -> ShowS
$cshowList :: [InventoryGroup] -> ShowS
show :: InventoryGroup -> String
$cshow :: InventoryGroup -> String
showsPrec :: Int -> InventoryGroup -> ShowS
$cshowsPrec :: Int -> InventoryGroup -> ShowS
Prelude.Show, (forall x. InventoryGroup -> Rep InventoryGroup x)
-> (forall x. Rep InventoryGroup x -> InventoryGroup)
-> Generic InventoryGroup
forall x. Rep InventoryGroup x -> InventoryGroup
forall x. InventoryGroup -> Rep InventoryGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InventoryGroup x -> InventoryGroup
$cfrom :: forall x. InventoryGroup -> Rep InventoryGroup x
Prelude.Generic)

-- |
-- Create a value of 'InventoryGroup' 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:
--
-- 'name', 'inventoryGroup_name' - The name of the group.
--
-- 'filters', 'inventoryGroup_filters' - Filters define the criteria for the group. The @matchingCount@ field
-- displays the number of resources that match the criteria. The
-- @notMatchingCount@ field displays the number of resources that don\'t
-- match the criteria.
newInventoryGroup ::
  -- | 'name'
  Prelude.Text ->
  -- | 'filters'
  Prelude.NonEmpty InventoryFilter ->
  InventoryGroup
newInventoryGroup :: Text -> NonEmpty InventoryFilter -> InventoryGroup
newInventoryGroup Text
pName_ NonEmpty InventoryFilter
pFilters_ =
  InventoryGroup' :: Text -> NonEmpty InventoryFilter -> InventoryGroup
InventoryGroup'
    { $sel:name:InventoryGroup' :: Text
name = Text
pName_,
      $sel:filters:InventoryGroup' :: NonEmpty InventoryFilter
filters = Tagged
  (NonEmpty InventoryFilter) (Identity (NonEmpty InventoryFilter))
-> Tagged
     (NonEmpty InventoryFilter) (Identity (NonEmpty InventoryFilter))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty InventoryFilter) (Identity (NonEmpty InventoryFilter))
 -> Tagged
      (NonEmpty InventoryFilter) (Identity (NonEmpty InventoryFilter)))
-> NonEmpty InventoryFilter -> NonEmpty InventoryFilter
forall t b. AReview t b -> b -> t
Lens.# NonEmpty InventoryFilter
pFilters_
    }

-- | The name of the group.
inventoryGroup_name :: Lens.Lens' InventoryGroup Prelude.Text
inventoryGroup_name :: (Text -> f Text) -> InventoryGroup -> f InventoryGroup
inventoryGroup_name = (InventoryGroup -> Text)
-> (InventoryGroup -> Text -> InventoryGroup)
-> Lens InventoryGroup InventoryGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryGroup' {Text
name :: Text
$sel:name:InventoryGroup' :: InventoryGroup -> Text
name} -> Text
name) (\s :: InventoryGroup
s@InventoryGroup' {} Text
a -> InventoryGroup
s {$sel:name:InventoryGroup' :: Text
name = Text
a} :: InventoryGroup)

-- | Filters define the criteria for the group. The @matchingCount@ field
-- displays the number of resources that match the criteria. The
-- @notMatchingCount@ field displays the number of resources that don\'t
-- match the criteria.
inventoryGroup_filters :: Lens.Lens' InventoryGroup (Prelude.NonEmpty InventoryFilter)
inventoryGroup_filters :: (NonEmpty InventoryFilter -> f (NonEmpty InventoryFilter))
-> InventoryGroup -> f InventoryGroup
inventoryGroup_filters = (InventoryGroup -> NonEmpty InventoryFilter)
-> (InventoryGroup -> NonEmpty InventoryFilter -> InventoryGroup)
-> Lens
     InventoryGroup
     InventoryGroup
     (NonEmpty InventoryFilter)
     (NonEmpty InventoryFilter)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryGroup' {NonEmpty InventoryFilter
filters :: NonEmpty InventoryFilter
$sel:filters:InventoryGroup' :: InventoryGroup -> NonEmpty InventoryFilter
filters} -> NonEmpty InventoryFilter
filters) (\s :: InventoryGroup
s@InventoryGroup' {} NonEmpty InventoryFilter
a -> InventoryGroup
s {$sel:filters:InventoryGroup' :: NonEmpty InventoryFilter
filters = NonEmpty InventoryFilter
a} :: InventoryGroup) ((NonEmpty InventoryFilter -> f (NonEmpty InventoryFilter))
 -> InventoryGroup -> f InventoryGroup)
-> ((NonEmpty InventoryFilter -> f (NonEmpty InventoryFilter))
    -> NonEmpty InventoryFilter -> f (NonEmpty InventoryFilter))
-> (NonEmpty InventoryFilter -> f (NonEmpty InventoryFilter))
-> InventoryGroup
-> f InventoryGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty InventoryFilter -> f (NonEmpty InventoryFilter))
-> NonEmpty InventoryFilter -> f (NonEmpty InventoryFilter)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable InventoryGroup

instance Prelude.NFData InventoryGroup

instance Core.ToJSON InventoryGroup where
  toJSON :: InventoryGroup -> Value
toJSON InventoryGroup' {NonEmpty InventoryFilter
Text
filters :: NonEmpty InventoryFilter
name :: Text
$sel:filters:InventoryGroup' :: InventoryGroup -> NonEmpty InventoryFilter
$sel:name:InventoryGroup' :: InventoryGroup -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Filters" Text -> NonEmpty InventoryFilter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty InventoryFilter
filters)
          ]
      )