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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(EntityAggregate -> EntityAggregate -> Bool)
-> (EntityAggregate -> EntityAggregate -> Bool)
-> Eq EntityAggregate
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]
(Int -> ReadS EntityAggregate)
-> ReadS [EntityAggregate]
-> ReadPrec EntityAggregate
-> ReadPrec [EntityAggregate]
-> Read 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
(Int -> EntityAggregate -> ShowS)
-> (EntityAggregate -> String)
-> ([EntityAggregate] -> ShowS)
-> Show EntityAggregate
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. EntityAggregate -> Rep EntityAggregate x)
-> (forall x. Rep EntityAggregate x -> EntityAggregate)
-> Generic EntityAggregate
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' :: Maybe Int -> Maybe Text -> EntityAggregate
EntityAggregate'
    { $sel:count:EntityAggregate' :: Maybe Int
count = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:eventArn:EntityAggregate' :: Maybe Text
eventArn = Maybe Text
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 :: (Maybe Int -> f (Maybe Int))
-> EntityAggregate -> f EntityAggregate
entityAggregate_count = (EntityAggregate -> Maybe Int)
-> (EntityAggregate -> Maybe Int -> EntityAggregate)
-> Lens EntityAggregate EntityAggregate (Maybe Int) (Maybe Int)
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 :: (Maybe Text -> f (Maybe Text))
-> EntityAggregate -> f EntityAggregate
entityAggregate_eventArn = (EntityAggregate -> Maybe Text)
-> (EntityAggregate -> Maybe Text -> EntityAggregate)
-> Lens EntityAggregate EntityAggregate (Maybe Text) (Maybe Text)
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 Core.FromJSON EntityAggregate where
  parseJSON :: Value -> Parser EntityAggregate
parseJSON =
    String
-> (Object -> Parser EntityAggregate)
-> Value
-> Parser EntityAggregate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EntityAggregate"
      ( \Object
x ->
          Maybe Int -> Maybe Text -> EntityAggregate
EntityAggregate'
            (Maybe Int -> Maybe Text -> EntityAggregate)
-> Parser (Maybe Int) -> Parser (Maybe Text -> EntityAggregate)
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 -> EntityAggregate)
-> Parser (Maybe Text) -> Parser EntityAggregate
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
"eventArn")
      )

instance Prelude.Hashable EntityAggregate

instance Prelude.NFData EntityAggregate