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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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),
    -- | 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
  }
  deriving (InventoryAggregator -> InventoryAggregator -> Bool
(InventoryAggregator -> InventoryAggregator -> Bool)
-> (InventoryAggregator -> InventoryAggregator -> Bool)
-> Eq InventoryAggregator
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]
(Int -> ReadS InventoryAggregator)
-> ReadS [InventoryAggregator]
-> ReadPrec InventoryAggregator
-> ReadPrec [InventoryAggregator]
-> Read 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
(Int -> InventoryAggregator -> ShowS)
-> (InventoryAggregator -> String)
-> ([InventoryAggregator] -> ShowS)
-> Show InventoryAggregator
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. InventoryAggregator -> Rep InventoryAggregator x)
-> (forall x. Rep InventoryAggregator x -> InventoryAggregator)
-> Generic InventoryAggregator
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:
--
-- '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.
--
-- 'aggregators', 'inventoryAggregator_aggregators' - Nested aggregators to further refine aggregation for an inventory type.
--
-- 'expression', 'inventoryAggregator_expression' - The inventory type and attribute name for aggregation.
newInventoryAggregator ::
  InventoryAggregator
newInventoryAggregator :: InventoryAggregator
newInventoryAggregator =
  InventoryAggregator' :: Maybe (NonEmpty InventoryGroup)
-> Maybe (NonEmpty InventoryAggregator)
-> Maybe Text
-> InventoryAggregator
InventoryAggregator'
    { $sel:groups:InventoryAggregator' :: Maybe (NonEmpty InventoryGroup)
groups = Maybe (NonEmpty InventoryGroup)
forall a. Maybe a
Prelude.Nothing,
      $sel:aggregators:InventoryAggregator' :: Maybe (NonEmpty InventoryAggregator)
aggregators = Maybe (NonEmpty InventoryAggregator)
forall a. Maybe a
Prelude.Nothing,
      $sel:expression:InventoryAggregator' :: Maybe Text
expression = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe (NonEmpty InventoryGroup)
 -> f (Maybe (NonEmpty InventoryGroup)))
-> InventoryAggregator -> f InventoryAggregator
inventoryAggregator_groups = (InventoryAggregator -> Maybe (NonEmpty InventoryGroup))
-> (InventoryAggregator
    -> Maybe (NonEmpty InventoryGroup) -> InventoryAggregator)
-> Lens
     InventoryAggregator
     InventoryAggregator
     (Maybe (NonEmpty InventoryGroup))
     (Maybe (NonEmpty InventoryGroup))
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) ((Maybe (NonEmpty InventoryGroup)
  -> f (Maybe (NonEmpty InventoryGroup)))
 -> InventoryAggregator -> f InventoryAggregator)
-> ((Maybe (NonEmpty InventoryGroup)
     -> f (Maybe (NonEmpty InventoryGroup)))
    -> Maybe (NonEmpty InventoryGroup)
    -> f (Maybe (NonEmpty InventoryGroup)))
-> (Maybe (NonEmpty InventoryGroup)
    -> f (Maybe (NonEmpty InventoryGroup)))
-> InventoryAggregator
-> f InventoryAggregator
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty InventoryGroup)
  (NonEmpty InventoryGroup)
  (NonEmpty InventoryGroup)
  (NonEmpty InventoryGroup)
-> Iso
     (Maybe (NonEmpty InventoryGroup))
     (Maybe (NonEmpty InventoryGroup))
     (Maybe (NonEmpty InventoryGroup))
     (Maybe (NonEmpty InventoryGroup))
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
  (NonEmpty InventoryGroup)
  (NonEmpty InventoryGroup)
  (NonEmpty InventoryGroup)
  (NonEmpty InventoryGroup)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Nested aggregators to further refine aggregation for an inventory type.
inventoryAggregator_aggregators :: Lens.Lens' InventoryAggregator (Prelude.Maybe (Prelude.NonEmpty InventoryAggregator))
inventoryAggregator_aggregators :: (Maybe (NonEmpty InventoryAggregator)
 -> f (Maybe (NonEmpty InventoryAggregator)))
-> InventoryAggregator -> f InventoryAggregator
inventoryAggregator_aggregators = (InventoryAggregator -> Maybe (NonEmpty InventoryAggregator))
-> (InventoryAggregator
    -> Maybe (NonEmpty InventoryAggregator) -> InventoryAggregator)
-> Lens
     InventoryAggregator
     InventoryAggregator
     (Maybe (NonEmpty InventoryAggregator))
     (Maybe (NonEmpty InventoryAggregator))
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) ((Maybe (NonEmpty InventoryAggregator)
  -> f (Maybe (NonEmpty InventoryAggregator)))
 -> InventoryAggregator -> f InventoryAggregator)
-> ((Maybe (NonEmpty InventoryAggregator)
     -> f (Maybe (NonEmpty InventoryAggregator)))
    -> Maybe (NonEmpty InventoryAggregator)
    -> f (Maybe (NonEmpty InventoryAggregator)))
-> (Maybe (NonEmpty InventoryAggregator)
    -> f (Maybe (NonEmpty InventoryAggregator)))
-> InventoryAggregator
-> f InventoryAggregator
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty InventoryAggregator)
  (NonEmpty InventoryAggregator)
  (NonEmpty InventoryAggregator)
  (NonEmpty InventoryAggregator)
-> Iso
     (Maybe (NonEmpty InventoryAggregator))
     (Maybe (NonEmpty InventoryAggregator))
     (Maybe (NonEmpty InventoryAggregator))
     (Maybe (NonEmpty InventoryAggregator))
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
  (NonEmpty InventoryAggregator)
  (NonEmpty InventoryAggregator)
  (NonEmpty InventoryAggregator)
  (NonEmpty InventoryAggregator)
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 :: (Maybe Text -> f (Maybe Text))
-> InventoryAggregator -> f InventoryAggregator
inventoryAggregator_expression = (InventoryAggregator -> Maybe Text)
-> (InventoryAggregator -> Maybe Text -> InventoryAggregator)
-> Lens
     InventoryAggregator InventoryAggregator (Maybe Text) (Maybe Text)
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)

instance Prelude.Hashable InventoryAggregator

instance Prelude.NFData InventoryAggregator

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