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

-- | The number of entities that are affected by one or more events. Returned
-- by the
-- <https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeEntityAggregates.html DescribeEntityAggregates>
-- operation.
--
-- /See:/ 'newEntityAggregate' smart constructor.
data EntityAggregate = EntityAggregate'
  { -- | The number of entities that match the criteria for the specified events.
    EntityAggregate -> Maybe Int
count :: Prelude.Maybe Prelude.Int,
    -- | The unique identifier for the event. The event ARN has the
    -- @arn:aws:health:@/@event-region@/@::event\/@/@SERVICE@/@\/@/@EVENT_TYPE_CODE@/@\/@/@EVENT_TYPE_PLUS_ID@/@ @
    -- format.
    --
    -- For example, an event ARN might look like the following:
    --
    -- @arn:aws:health:us-east-1::event\/EC2\/EC2_INSTANCE_RETIREMENT_SCHEDULED\/EC2_INSTANCE_RETIREMENT_SCHEDULED_ABC123-DEF456@
    EntityAggregate -> Maybe Text
eventArn :: Prelude.Maybe Prelude.Text
  }
  deriving (EntityAggregate -> EntityAggregate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntityAggregate -> EntityAggregate -> Bool
$c/= :: EntityAggregate -> EntityAggregate -> Bool
== :: EntityAggregate -> EntityAggregate -> Bool
$c== :: EntityAggregate -> EntityAggregate -> Bool
Prelude.Eq, ReadPrec [EntityAggregate]
ReadPrec EntityAggregate
Int -> ReadS EntityAggregate
ReadS [EntityAggregate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EntityAggregate]
$creadListPrec :: ReadPrec [EntityAggregate]
readPrec :: ReadPrec EntityAggregate
$creadPrec :: ReadPrec EntityAggregate
readList :: ReadS [EntityAggregate]
$creadList :: ReadS [EntityAggregate]
readsPrec :: Int -> ReadS EntityAggregate
$creadsPrec :: Int -> ReadS EntityAggregate
Prelude.Read, Int -> EntityAggregate -> ShowS
[EntityAggregate] -> ShowS
EntityAggregate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntityAggregate] -> ShowS
$cshowList :: [EntityAggregate] -> ShowS
show :: EntityAggregate -> String
$cshow :: EntityAggregate -> String
showsPrec :: Int -> EntityAggregate -> ShowS
$cshowsPrec :: Int -> EntityAggregate -> ShowS
Prelude.Show, forall x. Rep EntityAggregate x -> EntityAggregate
forall x. EntityAggregate -> Rep EntityAggregate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EntityAggregate x -> EntityAggregate
$cfrom :: forall x. EntityAggregate -> Rep EntityAggregate x
Prelude.Generic)

-- |
-- Create a value of 'EntityAggregate' 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', 'entityAggregate_count' - The number of entities that match the criteria for the specified events.
--
-- 'eventArn', 'entityAggregate_eventArn' - The unique identifier for the event. The event ARN has the
-- @arn:aws:health:@/@event-region@/@::event\/@/@SERVICE@/@\/@/@EVENT_TYPE_CODE@/@\/@/@EVENT_TYPE_PLUS_ID@/@ @
-- format.
--
-- For example, an event ARN might look like the following:
--
-- @arn:aws:health:us-east-1::event\/EC2\/EC2_INSTANCE_RETIREMENT_SCHEDULED\/EC2_INSTANCE_RETIREMENT_SCHEDULED_ABC123-DEF456@
newEntityAggregate ::
  EntityAggregate
newEntityAggregate :: EntityAggregate
newEntityAggregate =
  EntityAggregate'
    { $sel:count:EntityAggregate' :: Maybe Int
count = forall a. Maybe a
Prelude.Nothing,
      $sel:eventArn:EntityAggregate' :: Maybe Text
eventArn = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of entities that match the criteria for the specified events.
entityAggregate_count :: Lens.Lens' EntityAggregate (Prelude.Maybe Prelude.Int)
entityAggregate_count :: Lens' EntityAggregate (Maybe Int)
entityAggregate_count = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityAggregate' {Maybe Int
count :: Maybe Int
$sel:count:EntityAggregate' :: EntityAggregate -> Maybe Int
count} -> Maybe Int
count) (\s :: EntityAggregate
s@EntityAggregate' {} Maybe Int
a -> EntityAggregate
s {$sel:count:EntityAggregate' :: Maybe Int
count = Maybe Int
a} :: EntityAggregate)

-- | The unique identifier for the event. The event ARN has the
-- @arn:aws:health:@/@event-region@/@::event\/@/@SERVICE@/@\/@/@EVENT_TYPE_CODE@/@\/@/@EVENT_TYPE_PLUS_ID@/@ @
-- format.
--
-- For example, an event ARN might look like the following:
--
-- @arn:aws:health:us-east-1::event\/EC2\/EC2_INSTANCE_RETIREMENT_SCHEDULED\/EC2_INSTANCE_RETIREMENT_SCHEDULED_ABC123-DEF456@
entityAggregate_eventArn :: Lens.Lens' EntityAggregate (Prelude.Maybe Prelude.Text)
entityAggregate_eventArn :: Lens' EntityAggregate (Maybe Text)
entityAggregate_eventArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityAggregate' {Maybe Text
eventArn :: Maybe Text
$sel:eventArn:EntityAggregate' :: EntityAggregate -> Maybe Text
eventArn} -> Maybe Text
eventArn) (\s :: EntityAggregate
s@EntityAggregate' {} Maybe Text
a -> EntityAggregate
s {$sel:eventArn:EntityAggregate' :: Maybe Text
eventArn = Maybe Text
a} :: EntityAggregate)

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

instance Prelude.Hashable EntityAggregate where
  hashWithSalt :: Int -> EntityAggregate -> Int
hashWithSalt Int
_salt EntityAggregate' {Maybe Int
Maybe Text
eventArn :: Maybe Text
count :: Maybe Int
$sel:eventArn:EntityAggregate' :: EntityAggregate -> Maybe Text
$sel:count:EntityAggregate' :: EntityAggregate -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
count
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
eventArn

instance Prelude.NFData EntityAggregate where
  rnf :: EntityAggregate -> ()
rnf EntityAggregate' {Maybe Int
Maybe Text
eventArn :: Maybe Text
count :: Maybe Int
$sel:eventArn:EntityAggregate' :: EntityAggregate -> Maybe Text
$sel:count:EntityAggregate' :: EntityAggregate -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
count
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eventArn