{-# 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.OpsAggregator
-- 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.OpsAggregator 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.OpsFilter

-- | One or more aggregators for viewing counts of OpsData using different
-- dimensions such as @Source@, @CreatedTime@, or @Source and CreatedTime@,
-- to name a few.
--
-- /See:/ 'newOpsAggregator' smart constructor.
data OpsAggregator = OpsAggregator'
  { -- | Either a @Range@ or @Count@ aggregator for limiting an OpsData summary.
    OpsAggregator -> Maybe Text
aggregatorType :: Prelude.Maybe Prelude.Text,
    -- | A nested aggregator for viewing counts of OpsData.
    OpsAggregator -> Maybe (NonEmpty OpsAggregator)
aggregators :: Prelude.Maybe (Prelude.NonEmpty OpsAggregator),
    -- | The name of an OpsData attribute on which to limit the count of OpsData.
    OpsAggregator -> Maybe Text
attributeName :: Prelude.Maybe Prelude.Text,
    -- | The aggregator filters.
    OpsAggregator -> Maybe (NonEmpty OpsFilter)
filters :: Prelude.Maybe (Prelude.NonEmpty OpsFilter),
    -- | The data type name to use for viewing counts of OpsData.
    OpsAggregator -> Maybe Text
typeName :: Prelude.Maybe Prelude.Text,
    -- | The aggregator value.
    OpsAggregator -> Maybe (HashMap Text Text)
values :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (OpsAggregator -> OpsAggregator -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OpsAggregator -> OpsAggregator -> Bool
$c/= :: OpsAggregator -> OpsAggregator -> Bool
== :: OpsAggregator -> OpsAggregator -> Bool
$c== :: OpsAggregator -> OpsAggregator -> Bool
Prelude.Eq, ReadPrec [OpsAggregator]
ReadPrec OpsAggregator
Int -> ReadS OpsAggregator
ReadS [OpsAggregator]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OpsAggregator]
$creadListPrec :: ReadPrec [OpsAggregator]
readPrec :: ReadPrec OpsAggregator
$creadPrec :: ReadPrec OpsAggregator
readList :: ReadS [OpsAggregator]
$creadList :: ReadS [OpsAggregator]
readsPrec :: Int -> ReadS OpsAggregator
$creadsPrec :: Int -> ReadS OpsAggregator
Prelude.Read, Int -> OpsAggregator -> ShowS
[OpsAggregator] -> ShowS
OpsAggregator -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpsAggregator] -> ShowS
$cshowList :: [OpsAggregator] -> ShowS
show :: OpsAggregator -> String
$cshow :: OpsAggregator -> String
showsPrec :: Int -> OpsAggregator -> ShowS
$cshowsPrec :: Int -> OpsAggregator -> ShowS
Prelude.Show, forall x. Rep OpsAggregator x -> OpsAggregator
forall x. OpsAggregator -> Rep OpsAggregator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OpsAggregator x -> OpsAggregator
$cfrom :: forall x. OpsAggregator -> Rep OpsAggregator x
Prelude.Generic)

-- |
-- Create a value of 'OpsAggregator' 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:
--
-- 'aggregatorType', 'opsAggregator_aggregatorType' - Either a @Range@ or @Count@ aggregator for limiting an OpsData summary.
--
-- 'aggregators', 'opsAggregator_aggregators' - A nested aggregator for viewing counts of OpsData.
--
-- 'attributeName', 'opsAggregator_attributeName' - The name of an OpsData attribute on which to limit the count of OpsData.
--
-- 'filters', 'opsAggregator_filters' - The aggregator filters.
--
-- 'typeName', 'opsAggregator_typeName' - The data type name to use for viewing counts of OpsData.
--
-- 'values', 'opsAggregator_values' - The aggregator value.
newOpsAggregator ::
  OpsAggregator
newOpsAggregator :: OpsAggregator
newOpsAggregator =
  OpsAggregator'
    { $sel:aggregatorType:OpsAggregator' :: Maybe Text
aggregatorType = forall a. Maybe a
Prelude.Nothing,
      $sel:aggregators:OpsAggregator' :: Maybe (NonEmpty OpsAggregator)
aggregators = forall a. Maybe a
Prelude.Nothing,
      $sel:attributeName:OpsAggregator' :: Maybe Text
attributeName = forall a. Maybe a
Prelude.Nothing,
      $sel:filters:OpsAggregator' :: Maybe (NonEmpty OpsFilter)
filters = forall a. Maybe a
Prelude.Nothing,
      $sel:typeName:OpsAggregator' :: Maybe Text
typeName = forall a. Maybe a
Prelude.Nothing,
      $sel:values:OpsAggregator' :: Maybe (HashMap Text Text)
values = forall a. Maybe a
Prelude.Nothing
    }

-- | Either a @Range@ or @Count@ aggregator for limiting an OpsData summary.
opsAggregator_aggregatorType :: Lens.Lens' OpsAggregator (Prelude.Maybe Prelude.Text)
opsAggregator_aggregatorType :: Lens' OpsAggregator (Maybe Text)
opsAggregator_aggregatorType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsAggregator' {Maybe Text
aggregatorType :: Maybe Text
$sel:aggregatorType:OpsAggregator' :: OpsAggregator -> Maybe Text
aggregatorType} -> Maybe Text
aggregatorType) (\s :: OpsAggregator
s@OpsAggregator' {} Maybe Text
a -> OpsAggregator
s {$sel:aggregatorType:OpsAggregator' :: Maybe Text
aggregatorType = Maybe Text
a} :: OpsAggregator)

-- | A nested aggregator for viewing counts of OpsData.
opsAggregator_aggregators :: Lens.Lens' OpsAggregator (Prelude.Maybe (Prelude.NonEmpty OpsAggregator))
opsAggregator_aggregators :: Lens' OpsAggregator (Maybe (NonEmpty OpsAggregator))
opsAggregator_aggregators = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsAggregator' {Maybe (NonEmpty OpsAggregator)
aggregators :: Maybe (NonEmpty OpsAggregator)
$sel:aggregators:OpsAggregator' :: OpsAggregator -> Maybe (NonEmpty OpsAggregator)
aggregators} -> Maybe (NonEmpty OpsAggregator)
aggregators) (\s :: OpsAggregator
s@OpsAggregator' {} Maybe (NonEmpty OpsAggregator)
a -> OpsAggregator
s {$sel:aggregators:OpsAggregator' :: Maybe (NonEmpty OpsAggregator)
aggregators = Maybe (NonEmpty OpsAggregator)
a} :: OpsAggregator) 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 name of an OpsData attribute on which to limit the count of OpsData.
opsAggregator_attributeName :: Lens.Lens' OpsAggregator (Prelude.Maybe Prelude.Text)
opsAggregator_attributeName :: Lens' OpsAggregator (Maybe Text)
opsAggregator_attributeName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsAggregator' {Maybe Text
attributeName :: Maybe Text
$sel:attributeName:OpsAggregator' :: OpsAggregator -> Maybe Text
attributeName} -> Maybe Text
attributeName) (\s :: OpsAggregator
s@OpsAggregator' {} Maybe Text
a -> OpsAggregator
s {$sel:attributeName:OpsAggregator' :: Maybe Text
attributeName = Maybe Text
a} :: OpsAggregator)

-- | The aggregator filters.
opsAggregator_filters :: Lens.Lens' OpsAggregator (Prelude.Maybe (Prelude.NonEmpty OpsFilter))
opsAggregator_filters :: Lens' OpsAggregator (Maybe (NonEmpty OpsFilter))
opsAggregator_filters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsAggregator' {Maybe (NonEmpty OpsFilter)
filters :: Maybe (NonEmpty OpsFilter)
$sel:filters:OpsAggregator' :: OpsAggregator -> Maybe (NonEmpty OpsFilter)
filters} -> Maybe (NonEmpty OpsFilter)
filters) (\s :: OpsAggregator
s@OpsAggregator' {} Maybe (NonEmpty OpsFilter)
a -> OpsAggregator
s {$sel:filters:OpsAggregator' :: Maybe (NonEmpty OpsFilter)
filters = Maybe (NonEmpty OpsFilter)
a} :: OpsAggregator) 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 data type name to use for viewing counts of OpsData.
opsAggregator_typeName :: Lens.Lens' OpsAggregator (Prelude.Maybe Prelude.Text)
opsAggregator_typeName :: Lens' OpsAggregator (Maybe Text)
opsAggregator_typeName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsAggregator' {Maybe Text
typeName :: Maybe Text
$sel:typeName:OpsAggregator' :: OpsAggregator -> Maybe Text
typeName} -> Maybe Text
typeName) (\s :: OpsAggregator
s@OpsAggregator' {} Maybe Text
a -> OpsAggregator
s {$sel:typeName:OpsAggregator' :: Maybe Text
typeName = Maybe Text
a} :: OpsAggregator)

-- | The aggregator value.
opsAggregator_values :: Lens.Lens' OpsAggregator (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
opsAggregator_values :: Lens' OpsAggregator (Maybe (HashMap Text Text))
opsAggregator_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsAggregator' {Maybe (HashMap Text Text)
values :: Maybe (HashMap Text Text)
$sel:values:OpsAggregator' :: OpsAggregator -> Maybe (HashMap Text Text)
values} -> Maybe (HashMap Text Text)
values) (\s :: OpsAggregator
s@OpsAggregator' {} Maybe (HashMap Text Text)
a -> OpsAggregator
s {$sel:values:OpsAggregator' :: Maybe (HashMap Text Text)
values = Maybe (HashMap Text Text)
a} :: OpsAggregator) 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 OpsAggregator where
  hashWithSalt :: Int -> OpsAggregator -> Int
hashWithSalt Int
_salt OpsAggregator' {Maybe (NonEmpty OpsFilter)
Maybe (NonEmpty OpsAggregator)
Maybe Text
Maybe (HashMap Text Text)
values :: Maybe (HashMap Text Text)
typeName :: Maybe Text
filters :: Maybe (NonEmpty OpsFilter)
attributeName :: Maybe Text
aggregators :: Maybe (NonEmpty OpsAggregator)
aggregatorType :: Maybe Text
$sel:values:OpsAggregator' :: OpsAggregator -> Maybe (HashMap Text Text)
$sel:typeName:OpsAggregator' :: OpsAggregator -> Maybe Text
$sel:filters:OpsAggregator' :: OpsAggregator -> Maybe (NonEmpty OpsFilter)
$sel:attributeName:OpsAggregator' :: OpsAggregator -> Maybe Text
$sel:aggregators:OpsAggregator' :: OpsAggregator -> Maybe (NonEmpty OpsAggregator)
$sel:aggregatorType:OpsAggregator' :: OpsAggregator -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
aggregatorType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty OpsAggregator)
aggregators
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
attributeName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty OpsFilter)
filters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
typeName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
values

instance Prelude.NFData OpsAggregator where
  rnf :: OpsAggregator -> ()
rnf OpsAggregator' {Maybe (NonEmpty OpsFilter)
Maybe (NonEmpty OpsAggregator)
Maybe Text
Maybe (HashMap Text Text)
values :: Maybe (HashMap Text Text)
typeName :: Maybe Text
filters :: Maybe (NonEmpty OpsFilter)
attributeName :: Maybe Text
aggregators :: Maybe (NonEmpty OpsAggregator)
aggregatorType :: Maybe Text
$sel:values:OpsAggregator' :: OpsAggregator -> Maybe (HashMap Text Text)
$sel:typeName:OpsAggregator' :: OpsAggregator -> Maybe Text
$sel:filters:OpsAggregator' :: OpsAggregator -> Maybe (NonEmpty OpsFilter)
$sel:attributeName:OpsAggregator' :: OpsAggregator -> Maybe Text
$sel:aggregators:OpsAggregator' :: OpsAggregator -> Maybe (NonEmpty OpsAggregator)
$sel:aggregatorType:OpsAggregator' :: OpsAggregator -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
aggregatorType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty OpsAggregator)
aggregators
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
attributeName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty OpsFilter)
filters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
typeName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
values

instance Data.ToJSON OpsAggregator where
  toJSON :: OpsAggregator -> Value
toJSON OpsAggregator' {Maybe (NonEmpty OpsFilter)
Maybe (NonEmpty OpsAggregator)
Maybe Text
Maybe (HashMap Text Text)
values :: Maybe (HashMap Text Text)
typeName :: Maybe Text
filters :: Maybe (NonEmpty OpsFilter)
attributeName :: Maybe Text
aggregators :: Maybe (NonEmpty OpsAggregator)
aggregatorType :: Maybe Text
$sel:values:OpsAggregator' :: OpsAggregator -> Maybe (HashMap Text Text)
$sel:typeName:OpsAggregator' :: OpsAggregator -> Maybe Text
$sel:filters:OpsAggregator' :: OpsAggregator -> Maybe (NonEmpty OpsFilter)
$sel:attributeName:OpsAggregator' :: OpsAggregator -> Maybe Text
$sel:aggregators:OpsAggregator' :: OpsAggregator -> Maybe (NonEmpty OpsAggregator)
$sel:aggregatorType:OpsAggregator' :: OpsAggregator -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AggregatorType" 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
aggregatorType,
            (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 OpsAggregator)
aggregators,
            (Key
"AttributeName" 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
attributeName,
            (Key
"Filters" 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 OpsFilter)
filters,
            (Key
"TypeName" 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
typeName,
            (Key
"Values" 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 (HashMap Text Text)
values
          ]
      )