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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | The data type name to use for viewing counts of OpsData.
    OpsAggregator -> Maybe Text
typeName :: Prelude.Maybe Prelude.Text,
    -- | A nested aggregator for viewing counts of OpsData.
    OpsAggregator -> Maybe (NonEmpty OpsAggregator)
aggregators :: Prelude.Maybe (Prelude.NonEmpty OpsAggregator),
    -- | The aggregator value.
    OpsAggregator -> Maybe (HashMap Text Text)
values :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The aggregator filters.
    OpsAggregator -> Maybe (NonEmpty OpsFilter)
filters :: Prelude.Maybe (Prelude.NonEmpty OpsFilter),
    -- | The name of an OpsData attribute on which to limit the count of OpsData.
    OpsAggregator -> Maybe Text
attributeName :: Prelude.Maybe Prelude.Text,
    -- | Either a @Range@ or @Count@ aggregator for limiting an OpsData summary.
    OpsAggregator -> Maybe Text
aggregatorType :: Prelude.Maybe Prelude.Text
  }
  deriving (OpsAggregator -> OpsAggregator -> Bool
(OpsAggregator -> OpsAggregator -> Bool)
-> (OpsAggregator -> OpsAggregator -> Bool) -> Eq OpsAggregator
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]
(Int -> ReadS OpsAggregator)
-> ReadS [OpsAggregator]
-> ReadPrec OpsAggregator
-> ReadPrec [OpsAggregator]
-> Read 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
(Int -> OpsAggregator -> ShowS)
-> (OpsAggregator -> String)
-> ([OpsAggregator] -> ShowS)
-> Show OpsAggregator
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. OpsAggregator -> Rep OpsAggregator x)
-> (forall x. Rep OpsAggregator x -> OpsAggregator)
-> Generic OpsAggregator
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:
--
-- 'typeName', 'opsAggregator_typeName' - The data type name to use for viewing counts of OpsData.
--
-- 'aggregators', 'opsAggregator_aggregators' - A nested aggregator for viewing counts of OpsData.
--
-- 'values', 'opsAggregator_values' - The aggregator value.
--
-- 'filters', 'opsAggregator_filters' - The aggregator filters.
--
-- 'attributeName', 'opsAggregator_attributeName' - The name of an OpsData attribute on which to limit the count of OpsData.
--
-- 'aggregatorType', 'opsAggregator_aggregatorType' - Either a @Range@ or @Count@ aggregator for limiting an OpsData summary.
newOpsAggregator ::
  OpsAggregator
newOpsAggregator :: OpsAggregator
newOpsAggregator =
  OpsAggregator' :: Maybe Text
-> Maybe (NonEmpty OpsAggregator)
-> Maybe (HashMap Text Text)
-> Maybe (NonEmpty OpsFilter)
-> Maybe Text
-> Maybe Text
-> OpsAggregator
OpsAggregator'
    { $sel:typeName:OpsAggregator' :: Maybe Text
typeName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:aggregators:OpsAggregator' :: Maybe (NonEmpty OpsAggregator)
aggregators = Maybe (NonEmpty OpsAggregator)
forall a. Maybe a
Prelude.Nothing,
      $sel:values:OpsAggregator' :: Maybe (HashMap Text Text)
values = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:filters:OpsAggregator' :: Maybe (NonEmpty OpsFilter)
filters = Maybe (NonEmpty OpsFilter)
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeName:OpsAggregator' :: Maybe Text
attributeName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:aggregatorType:OpsAggregator' :: Maybe Text
aggregatorType = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The data type name to use for viewing counts of OpsData.
opsAggregator_typeName :: Lens.Lens' OpsAggregator (Prelude.Maybe Prelude.Text)
opsAggregator_typeName :: (Maybe Text -> f (Maybe Text)) -> OpsAggregator -> f OpsAggregator
opsAggregator_typeName = (OpsAggregator -> Maybe Text)
-> (OpsAggregator -> Maybe Text -> OpsAggregator)
-> Lens OpsAggregator OpsAggregator (Maybe Text) (Maybe Text)
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)

-- | A nested aggregator for viewing counts of OpsData.
opsAggregator_aggregators :: Lens.Lens' OpsAggregator (Prelude.Maybe (Prelude.NonEmpty OpsAggregator))
opsAggregator_aggregators :: (Maybe (NonEmpty OpsAggregator)
 -> f (Maybe (NonEmpty OpsAggregator)))
-> OpsAggregator -> f OpsAggregator
opsAggregator_aggregators = (OpsAggregator -> Maybe (NonEmpty OpsAggregator))
-> (OpsAggregator
    -> Maybe (NonEmpty OpsAggregator) -> OpsAggregator)
-> Lens
     OpsAggregator
     OpsAggregator
     (Maybe (NonEmpty OpsAggregator))
     (Maybe (NonEmpty OpsAggregator))
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) ((Maybe (NonEmpty OpsAggregator)
  -> f (Maybe (NonEmpty OpsAggregator)))
 -> OpsAggregator -> f OpsAggregator)
-> ((Maybe (NonEmpty OpsAggregator)
     -> f (Maybe (NonEmpty OpsAggregator)))
    -> Maybe (NonEmpty OpsAggregator)
    -> f (Maybe (NonEmpty OpsAggregator)))
-> (Maybe (NonEmpty OpsAggregator)
    -> f (Maybe (NonEmpty OpsAggregator)))
-> OpsAggregator
-> f OpsAggregator
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty OpsAggregator)
  (NonEmpty OpsAggregator)
  (NonEmpty OpsAggregator)
  (NonEmpty OpsAggregator)
-> Iso
     (Maybe (NonEmpty OpsAggregator))
     (Maybe (NonEmpty OpsAggregator))
     (Maybe (NonEmpty OpsAggregator))
     (Maybe (NonEmpty OpsAggregator))
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 OpsAggregator)
  (NonEmpty OpsAggregator)
  (NonEmpty OpsAggregator)
  (NonEmpty OpsAggregator)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The aggregator value.
opsAggregator_values :: Lens.Lens' OpsAggregator (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
opsAggregator_values :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> OpsAggregator -> f OpsAggregator
opsAggregator_values = (OpsAggregator -> Maybe (HashMap Text Text))
-> (OpsAggregator -> Maybe (HashMap Text Text) -> OpsAggregator)
-> Lens
     OpsAggregator
     OpsAggregator
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> OpsAggregator -> f OpsAggregator)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> OpsAggregator
-> f OpsAggregator
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The aggregator filters.
opsAggregator_filters :: Lens.Lens' OpsAggregator (Prelude.Maybe (Prelude.NonEmpty OpsFilter))
opsAggregator_filters :: (Maybe (NonEmpty OpsFilter) -> f (Maybe (NonEmpty OpsFilter)))
-> OpsAggregator -> f OpsAggregator
opsAggregator_filters = (OpsAggregator -> Maybe (NonEmpty OpsFilter))
-> (OpsAggregator -> Maybe (NonEmpty OpsFilter) -> OpsAggregator)
-> Lens
     OpsAggregator
     OpsAggregator
     (Maybe (NonEmpty OpsFilter))
     (Maybe (NonEmpty OpsFilter))
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) ((Maybe (NonEmpty OpsFilter) -> f (Maybe (NonEmpty OpsFilter)))
 -> OpsAggregator -> f OpsAggregator)
-> ((Maybe (NonEmpty OpsFilter) -> f (Maybe (NonEmpty OpsFilter)))
    -> Maybe (NonEmpty OpsFilter) -> f (Maybe (NonEmpty OpsFilter)))
-> (Maybe (NonEmpty OpsFilter) -> f (Maybe (NonEmpty OpsFilter)))
-> OpsAggregator
-> f OpsAggregator
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty OpsFilter)
  (NonEmpty OpsFilter)
  (NonEmpty OpsFilter)
  (NonEmpty OpsFilter)
-> Iso
     (Maybe (NonEmpty OpsFilter))
     (Maybe (NonEmpty OpsFilter))
     (Maybe (NonEmpty OpsFilter))
     (Maybe (NonEmpty OpsFilter))
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 OpsFilter)
  (NonEmpty OpsFilter)
  (NonEmpty OpsFilter)
  (NonEmpty OpsFilter)
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 :: (Maybe Text -> f (Maybe Text)) -> OpsAggregator -> f OpsAggregator
opsAggregator_attributeName = (OpsAggregator -> Maybe Text)
-> (OpsAggregator -> Maybe Text -> OpsAggregator)
-> Lens OpsAggregator OpsAggregator (Maybe Text) (Maybe Text)
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)

-- | Either a @Range@ or @Count@ aggregator for limiting an OpsData summary.
opsAggregator_aggregatorType :: Lens.Lens' OpsAggregator (Prelude.Maybe Prelude.Text)
opsAggregator_aggregatorType :: (Maybe Text -> f (Maybe Text)) -> OpsAggregator -> f OpsAggregator
opsAggregator_aggregatorType = (OpsAggregator -> Maybe Text)
-> (OpsAggregator -> Maybe Text -> OpsAggregator)
-> Lens OpsAggregator OpsAggregator (Maybe Text) (Maybe Text)
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)

instance Prelude.Hashable OpsAggregator

instance Prelude.NFData OpsAggregator

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