{-# 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.AWSHealth.Types.EventAggregate
-- 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.AWSHealth.Types.EventAggregate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The number of events of each issue type. Returned by the
-- <https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeEventAggregates.html DescribeEventAggregates>
-- operation.
--
-- /See:/ 'newEventAggregate' smart constructor.
data EventAggregate = EventAggregate'
  { -- | The number of events of the associated issue type.
    EventAggregate -> Maybe Int
count :: Prelude.Maybe Prelude.Int,
    -- | The issue type for the associated count.
    EventAggregate -> Maybe Text
aggregateValue :: Prelude.Maybe Prelude.Text
  }
  deriving (EventAggregate -> EventAggregate -> Bool
(EventAggregate -> EventAggregate -> Bool)
-> (EventAggregate -> EventAggregate -> Bool) -> Eq EventAggregate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventAggregate -> EventAggregate -> Bool
$c/= :: EventAggregate -> EventAggregate -> Bool
== :: EventAggregate -> EventAggregate -> Bool
$c== :: EventAggregate -> EventAggregate -> Bool
Prelude.Eq, ReadPrec [EventAggregate]
ReadPrec EventAggregate
Int -> ReadS EventAggregate
ReadS [EventAggregate]
(Int -> ReadS EventAggregate)
-> ReadS [EventAggregate]
-> ReadPrec EventAggregate
-> ReadPrec [EventAggregate]
-> Read EventAggregate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventAggregate]
$creadListPrec :: ReadPrec [EventAggregate]
readPrec :: ReadPrec EventAggregate
$creadPrec :: ReadPrec EventAggregate
readList :: ReadS [EventAggregate]
$creadList :: ReadS [EventAggregate]
readsPrec :: Int -> ReadS EventAggregate
$creadsPrec :: Int -> ReadS EventAggregate
Prelude.Read, Int -> EventAggregate -> ShowS
[EventAggregate] -> ShowS
EventAggregate -> String
(Int -> EventAggregate -> ShowS)
-> (EventAggregate -> String)
-> ([EventAggregate] -> ShowS)
-> Show EventAggregate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventAggregate] -> ShowS
$cshowList :: [EventAggregate] -> ShowS
show :: EventAggregate -> String
$cshow :: EventAggregate -> String
showsPrec :: Int -> EventAggregate -> ShowS
$cshowsPrec :: Int -> EventAggregate -> ShowS
Prelude.Show, (forall x. EventAggregate -> Rep EventAggregate x)
-> (forall x. Rep EventAggregate x -> EventAggregate)
-> Generic EventAggregate
forall x. Rep EventAggregate x -> EventAggregate
forall x. EventAggregate -> Rep EventAggregate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventAggregate x -> EventAggregate
$cfrom :: forall x. EventAggregate -> Rep EventAggregate x
Prelude.Generic)

-- |
-- Create a value of 'EventAggregate' 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:
--
-- 'count', 'eventAggregate_count' - The number of events of the associated issue type.
--
-- 'aggregateValue', 'eventAggregate_aggregateValue' - The issue type for the associated count.
newEventAggregate ::
  EventAggregate
newEventAggregate :: EventAggregate
newEventAggregate =
  EventAggregate' :: Maybe Int -> Maybe Text -> EventAggregate
EventAggregate'
    { $sel:count:EventAggregate' :: Maybe Int
count = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:aggregateValue:EventAggregate' :: Maybe Text
aggregateValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of events of the associated issue type.
eventAggregate_count :: Lens.Lens' EventAggregate (Prelude.Maybe Prelude.Int)
eventAggregate_count :: (Maybe Int -> f (Maybe Int)) -> EventAggregate -> f EventAggregate
eventAggregate_count = (EventAggregate -> Maybe Int)
-> (EventAggregate -> Maybe Int -> EventAggregate)
-> Lens EventAggregate EventAggregate (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventAggregate' {Maybe Int
count :: Maybe Int
$sel:count:EventAggregate' :: EventAggregate -> Maybe Int
count} -> Maybe Int
count) (\s :: EventAggregate
s@EventAggregate' {} Maybe Int
a -> EventAggregate
s {$sel:count:EventAggregate' :: Maybe Int
count = Maybe Int
a} :: EventAggregate)

-- | The issue type for the associated count.
eventAggregate_aggregateValue :: Lens.Lens' EventAggregate (Prelude.Maybe Prelude.Text)
eventAggregate_aggregateValue :: (Maybe Text -> f (Maybe Text))
-> EventAggregate -> f EventAggregate
eventAggregate_aggregateValue = (EventAggregate -> Maybe Text)
-> (EventAggregate -> Maybe Text -> EventAggregate)
-> Lens EventAggregate EventAggregate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventAggregate' {Maybe Text
aggregateValue :: Maybe Text
$sel:aggregateValue:EventAggregate' :: EventAggregate -> Maybe Text
aggregateValue} -> Maybe Text
aggregateValue) (\s :: EventAggregate
s@EventAggregate' {} Maybe Text
a -> EventAggregate
s {$sel:aggregateValue:EventAggregate' :: Maybe Text
aggregateValue = Maybe Text
a} :: EventAggregate)

instance Core.FromJSON EventAggregate where
  parseJSON :: Value -> Parser EventAggregate
parseJSON =
    String
-> (Object -> Parser EventAggregate)
-> Value
-> Parser EventAggregate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventAggregate"
      ( \Object
x ->
          Maybe Int -> Maybe Text -> EventAggregate
EventAggregate'
            (Maybe Int -> Maybe Text -> EventAggregate)
-> Parser (Maybe Int) -> Parser (Maybe Text -> EventAggregate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"count")
            Parser (Maybe Text -> EventAggregate)
-> Parser (Maybe Text) -> Parser EventAggregate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"aggregateValue")
      )

instance Prelude.Hashable EventAggregate

instance Prelude.NFData EventAggregate