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

-- | Specifies the inventory type and attribute for the aggregation
-- execution.
--
-- /See:/ 'newInventoryAggregator' smart constructor.
data InventoryAggregator = InventoryAggregator'
  { -- | Nested aggregators to further refine aggregation for an inventory type.
    InventoryAggregator -> Maybe (NonEmpty InventoryAggregator)
aggregators :: Prelude.Maybe (Prelude.NonEmpty InventoryAggregator),
    -- | The inventory type and attribute name for aggregation.
    InventoryAggregator -> Maybe Text
expression :: Prelude.Maybe Prelude.Text,
    -- | 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.
    InventoryAggregator -> Maybe (NonEmpty InventoryGroup)
groups :: Prelude.Maybe (Prelude.NonEmpty InventoryGroup)
  }
  deriving (InventoryAggregator -> InventoryAggregator -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InventoryAggregator -> InventoryAggregator -> Bool
$c/= :: InventoryAggregator -> InventoryAggregator -> Bool
== :: InventoryAggregator -> InventoryAggregator -> Bool
$c== :: InventoryAggregator -> InventoryAggregator -> Bool
Prelude.Eq, ReadPrec [InventoryAggregator]
ReadPrec InventoryAggregator
Int -> ReadS InventoryAggregator
ReadS [InventoryAggregator]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InventoryAggregator]
$creadListPrec :: ReadPrec [InventoryAggregator]
readPrec :: ReadPrec InventoryAggregator
$creadPrec :: ReadPrec InventoryAggregator
readList :: ReadS [InventoryAggregator]
$creadList :: ReadS [InventoryAggregator]
readsPrec :: Int -> ReadS InventoryAggregator
$creadsPrec :: Int -> ReadS InventoryAggregator
Prelude.Read, Int -> InventoryAggregator -> ShowS
[InventoryAggregator] -> ShowS
InventoryAggregator -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InventoryAggregator] -> ShowS
$cshowList :: [InventoryAggregator] -> ShowS
show :: InventoryAggregator -> String
$cshow :: InventoryAggregator -> String
showsPrec :: Int -> InventoryAggregator -> ShowS
$cshowsPrec :: Int -> InventoryAggregator -> ShowS
Prelude.Show, forall x. Rep InventoryAggregator x -> InventoryAggregator
forall x. InventoryAggregator -> Rep InventoryAggregator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InventoryAggregator x -> InventoryAggregator
$cfrom :: forall x. InventoryAggregator -> Rep InventoryAggregator x
Prelude.Generic)

-- |
-- Create a value of 'InventoryAggregator' 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:
--
-- 'aggregators', 'inventoryAggregator_aggregators' - Nested aggregators to further refine aggregation for an inventory type.
--
-- 'expression', 'inventoryAggregator_expression' - The inventory type and attribute name for aggregation.
--
-- 'groups', 'inventoryAggregator_groups' - 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.
newInventoryAggregator ::
  InventoryAggregator
newInventoryAggregator :: InventoryAggregator
newInventoryAggregator =
  InventoryAggregator'
    { $sel:aggregators:InventoryAggregator' :: Maybe (NonEmpty InventoryAggregator)
aggregators = forall a. Maybe a
Prelude.Nothing,
      $sel:expression:InventoryAggregator' :: Maybe Text
expression = forall a. Maybe a
Prelude.Nothing,
      $sel:groups:InventoryAggregator' :: Maybe (NonEmpty InventoryGroup)
groups = forall a. Maybe a
Prelude.Nothing
    }

-- | Nested aggregators to further refine aggregation for an inventory type.
inventoryAggregator_aggregators :: Lens.Lens' InventoryAggregator (Prelude.Maybe (Prelude.NonEmpty InventoryAggregator))
inventoryAggregator_aggregators :: Lens' InventoryAggregator (Maybe (NonEmpty InventoryAggregator))
inventoryAggregator_aggregators = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryAggregator' {Maybe (NonEmpty InventoryAggregator)
aggregators :: Maybe (NonEmpty InventoryAggregator)
$sel:aggregators:InventoryAggregator' :: InventoryAggregator -> Maybe (NonEmpty InventoryAggregator)
aggregators} -> Maybe (NonEmpty InventoryAggregator)
aggregators) (\s :: InventoryAggregator
s@InventoryAggregator' {} Maybe (NonEmpty InventoryAggregator)
a -> InventoryAggregator
s {$sel:aggregators:InventoryAggregator' :: Maybe (NonEmpty InventoryAggregator)
aggregators = Maybe (NonEmpty InventoryAggregator)
a} :: InventoryAggregator) 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 inventory type and attribute name for aggregation.
inventoryAggregator_expression :: Lens.Lens' InventoryAggregator (Prelude.Maybe Prelude.Text)
inventoryAggregator_expression :: Lens' InventoryAggregator (Maybe Text)
inventoryAggregator_expression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryAggregator' {Maybe Text
expression :: Maybe Text
$sel:expression:InventoryAggregator' :: InventoryAggregator -> Maybe Text
expression} -> Maybe Text
expression) (\s :: InventoryAggregator
s@InventoryAggregator' {} Maybe Text
a -> InventoryAggregator
s {$sel:expression:InventoryAggregator' :: Maybe Text
expression = Maybe Text
a} :: InventoryAggregator)

-- | 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.
inventoryAggregator_groups :: Lens.Lens' InventoryAggregator (Prelude.Maybe (Prelude.NonEmpty InventoryGroup))
inventoryAggregator_groups :: Lens' InventoryAggregator (Maybe (NonEmpty InventoryGroup))
inventoryAggregator_groups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryAggregator' {Maybe (NonEmpty InventoryGroup)
groups :: Maybe (NonEmpty InventoryGroup)
$sel:groups:InventoryAggregator' :: InventoryAggregator -> Maybe (NonEmpty InventoryGroup)
groups} -> Maybe (NonEmpty InventoryGroup)
groups) (\s :: InventoryAggregator
s@InventoryAggregator' {} Maybe (NonEmpty InventoryGroup)
a -> InventoryAggregator
s {$sel:groups:InventoryAggregator' :: Maybe (NonEmpty InventoryGroup)
groups = Maybe (NonEmpty InventoryGroup)
a} :: InventoryAggregator) 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

instance Prelude.Hashable InventoryAggregator where
  hashWithSalt :: Int -> InventoryAggregator -> Int
hashWithSalt Int
_salt InventoryAggregator' {Maybe (NonEmpty InventoryGroup)
Maybe (NonEmpty InventoryAggregator)
Maybe Text
groups :: Maybe (NonEmpty InventoryGroup)
expression :: Maybe Text
aggregators :: Maybe (NonEmpty InventoryAggregator)
$sel:groups:InventoryAggregator' :: InventoryAggregator -> Maybe (NonEmpty InventoryGroup)
$sel:expression:InventoryAggregator' :: InventoryAggregator -> Maybe Text
$sel:aggregators:InventoryAggregator' :: InventoryAggregator -> Maybe (NonEmpty InventoryAggregator)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty InventoryAggregator)
aggregators
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
expression
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty InventoryGroup)
groups

instance Prelude.NFData InventoryAggregator where
  rnf :: InventoryAggregator -> ()
rnf InventoryAggregator' {Maybe (NonEmpty InventoryGroup)
Maybe (NonEmpty InventoryAggregator)
Maybe Text
groups :: Maybe (NonEmpty InventoryGroup)
expression :: Maybe Text
aggregators :: Maybe (NonEmpty InventoryAggregator)
$sel:groups:InventoryAggregator' :: InventoryAggregator -> Maybe (NonEmpty InventoryGroup)
$sel:expression:InventoryAggregator' :: InventoryAggregator -> Maybe Text
$sel:aggregators:InventoryAggregator' :: InventoryAggregator -> Maybe (NonEmpty InventoryAggregator)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty InventoryAggregator)
aggregators
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
expression
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty InventoryGroup)
groups

instance Data.ToJSON InventoryAggregator where
  toJSON :: InventoryAggregator -> Value
toJSON InventoryAggregator' {Maybe (NonEmpty InventoryGroup)
Maybe (NonEmpty InventoryAggregator)
Maybe Text
groups :: Maybe (NonEmpty InventoryGroup)
expression :: Maybe Text
aggregators :: Maybe (NonEmpty InventoryAggregator)
$sel:groups:InventoryAggregator' :: InventoryAggregator -> Maybe (NonEmpty InventoryGroup)
$sel:expression:InventoryAggregator' :: InventoryAggregator -> Maybe Text
$sel:aggregators:InventoryAggregator' :: InventoryAggregator -> Maybe (NonEmpty InventoryAggregator)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Aggregators" 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 (NonEmpty InventoryAggregator)
aggregators,
            (Key
"Expression" 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
expression,
            (Key
"Groups" 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 (NonEmpty InventoryGroup)
groups
          ]
      )