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

import Amazonka.AWSHealth.Types.EntityStatusCode
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

-- | Information about an entity that is affected by a Health event.
--
-- /See:/ 'newAffectedEntity' smart constructor.
data AffectedEntity = AffectedEntity'
  { -- | The 12-digit Amazon Web Services account number that contains the
    -- affected entity.
    AffectedEntity -> Maybe Text
awsAccountId :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the entity. Format:
    -- @arn:aws:health:@/@entity-region@/@:@/@aws-account@/@:entity\/@/@entity-id@/@ @.
    -- Example:
    -- @arn:aws:health:us-east-1:111222333444:entity\/AVh5GGT7ul1arKr1sE1K@
    AffectedEntity -> Maybe Text
entityArn :: Prelude.Maybe Prelude.Text,
    -- | The URL of the affected entity.
    AffectedEntity -> Maybe Text
entityUrl :: Prelude.Maybe Prelude.Text,
    -- | The ID of the affected entity.
    AffectedEntity -> Maybe Text
entityValue :: Prelude.Maybe Prelude.Text,
    -- | 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@
    AffectedEntity -> Maybe Text
eventArn :: Prelude.Maybe Prelude.Text,
    -- | The most recent time that the entity was updated.
    AffectedEntity -> Maybe POSIX
lastUpdatedTime :: Prelude.Maybe Data.POSIX,
    -- | The most recent status of the entity affected by the event. The possible
    -- values are @IMPAIRED@, @UNIMPAIRED@, and @UNKNOWN@.
    AffectedEntity -> Maybe EntityStatusCode
statusCode :: Prelude.Maybe EntityStatusCode,
    -- | A map of entity tags attached to the affected entity.
    --
    -- Currently, the @tags@ property isn\'t supported.
    AffectedEntity -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (AffectedEntity -> AffectedEntity -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AffectedEntity -> AffectedEntity -> Bool
$c/= :: AffectedEntity -> AffectedEntity -> Bool
== :: AffectedEntity -> AffectedEntity -> Bool
$c== :: AffectedEntity -> AffectedEntity -> Bool
Prelude.Eq, ReadPrec [AffectedEntity]
ReadPrec AffectedEntity
Int -> ReadS AffectedEntity
ReadS [AffectedEntity]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AffectedEntity]
$creadListPrec :: ReadPrec [AffectedEntity]
readPrec :: ReadPrec AffectedEntity
$creadPrec :: ReadPrec AffectedEntity
readList :: ReadS [AffectedEntity]
$creadList :: ReadS [AffectedEntity]
readsPrec :: Int -> ReadS AffectedEntity
$creadsPrec :: Int -> ReadS AffectedEntity
Prelude.Read, Int -> AffectedEntity -> ShowS
[AffectedEntity] -> ShowS
AffectedEntity -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AffectedEntity] -> ShowS
$cshowList :: [AffectedEntity] -> ShowS
show :: AffectedEntity -> String
$cshow :: AffectedEntity -> String
showsPrec :: Int -> AffectedEntity -> ShowS
$cshowsPrec :: Int -> AffectedEntity -> ShowS
Prelude.Show, forall x. Rep AffectedEntity x -> AffectedEntity
forall x. AffectedEntity -> Rep AffectedEntity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AffectedEntity x -> AffectedEntity
$cfrom :: forall x. AffectedEntity -> Rep AffectedEntity x
Prelude.Generic)

-- |
-- Create a value of 'AffectedEntity' 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:
--
-- 'awsAccountId', 'affectedEntity_awsAccountId' - The 12-digit Amazon Web Services account number that contains the
-- affected entity.
--
-- 'entityArn', 'affectedEntity_entityArn' - The unique identifier for the entity. Format:
-- @arn:aws:health:@/@entity-region@/@:@/@aws-account@/@:entity\/@/@entity-id@/@ @.
-- Example:
-- @arn:aws:health:us-east-1:111222333444:entity\/AVh5GGT7ul1arKr1sE1K@
--
-- 'entityUrl', 'affectedEntity_entityUrl' - The URL of the affected entity.
--
-- 'entityValue', 'affectedEntity_entityValue' - The ID of the affected entity.
--
-- 'eventArn', 'affectedEntity_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@
--
-- 'lastUpdatedTime', 'affectedEntity_lastUpdatedTime' - The most recent time that the entity was updated.
--
-- 'statusCode', 'affectedEntity_statusCode' - The most recent status of the entity affected by the event. The possible
-- values are @IMPAIRED@, @UNIMPAIRED@, and @UNKNOWN@.
--
-- 'tags', 'affectedEntity_tags' - A map of entity tags attached to the affected entity.
--
-- Currently, the @tags@ property isn\'t supported.
newAffectedEntity ::
  AffectedEntity
newAffectedEntity :: AffectedEntity
newAffectedEntity =
  AffectedEntity'
    { $sel:awsAccountId:AffectedEntity' :: Maybe Text
awsAccountId = forall a. Maybe a
Prelude.Nothing,
      $sel:entityArn:AffectedEntity' :: Maybe Text
entityArn = forall a. Maybe a
Prelude.Nothing,
      $sel:entityUrl:AffectedEntity' :: Maybe Text
entityUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:entityValue:AffectedEntity' :: Maybe Text
entityValue = forall a. Maybe a
Prelude.Nothing,
      $sel:eventArn:AffectedEntity' :: Maybe Text
eventArn = forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdatedTime:AffectedEntity' :: Maybe POSIX
lastUpdatedTime = forall a. Maybe a
Prelude.Nothing,
      $sel:statusCode:AffectedEntity' :: Maybe EntityStatusCode
statusCode = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:AffectedEntity' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing
    }

-- | The 12-digit Amazon Web Services account number that contains the
-- affected entity.
affectedEntity_awsAccountId :: Lens.Lens' AffectedEntity (Prelude.Maybe Prelude.Text)
affectedEntity_awsAccountId :: Lens' AffectedEntity (Maybe Text)
affectedEntity_awsAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AffectedEntity' {Maybe Text
awsAccountId :: Maybe Text
$sel:awsAccountId:AffectedEntity' :: AffectedEntity -> Maybe Text
awsAccountId} -> Maybe Text
awsAccountId) (\s :: AffectedEntity
s@AffectedEntity' {} Maybe Text
a -> AffectedEntity
s {$sel:awsAccountId:AffectedEntity' :: Maybe Text
awsAccountId = Maybe Text
a} :: AffectedEntity)

-- | The unique identifier for the entity. Format:
-- @arn:aws:health:@/@entity-region@/@:@/@aws-account@/@:entity\/@/@entity-id@/@ @.
-- Example:
-- @arn:aws:health:us-east-1:111222333444:entity\/AVh5GGT7ul1arKr1sE1K@
affectedEntity_entityArn :: Lens.Lens' AffectedEntity (Prelude.Maybe Prelude.Text)
affectedEntity_entityArn :: Lens' AffectedEntity (Maybe Text)
affectedEntity_entityArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AffectedEntity' {Maybe Text
entityArn :: Maybe Text
$sel:entityArn:AffectedEntity' :: AffectedEntity -> Maybe Text
entityArn} -> Maybe Text
entityArn) (\s :: AffectedEntity
s@AffectedEntity' {} Maybe Text
a -> AffectedEntity
s {$sel:entityArn:AffectedEntity' :: Maybe Text
entityArn = Maybe Text
a} :: AffectedEntity)

-- | The URL of the affected entity.
affectedEntity_entityUrl :: Lens.Lens' AffectedEntity (Prelude.Maybe Prelude.Text)
affectedEntity_entityUrl :: Lens' AffectedEntity (Maybe Text)
affectedEntity_entityUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AffectedEntity' {Maybe Text
entityUrl :: Maybe Text
$sel:entityUrl:AffectedEntity' :: AffectedEntity -> Maybe Text
entityUrl} -> Maybe Text
entityUrl) (\s :: AffectedEntity
s@AffectedEntity' {} Maybe Text
a -> AffectedEntity
s {$sel:entityUrl:AffectedEntity' :: Maybe Text
entityUrl = Maybe Text
a} :: AffectedEntity)

-- | The ID of the affected entity.
affectedEntity_entityValue :: Lens.Lens' AffectedEntity (Prelude.Maybe Prelude.Text)
affectedEntity_entityValue :: Lens' AffectedEntity (Maybe Text)
affectedEntity_entityValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AffectedEntity' {Maybe Text
entityValue :: Maybe Text
$sel:entityValue:AffectedEntity' :: AffectedEntity -> Maybe Text
entityValue} -> Maybe Text
entityValue) (\s :: AffectedEntity
s@AffectedEntity' {} Maybe Text
a -> AffectedEntity
s {$sel:entityValue:AffectedEntity' :: Maybe Text
entityValue = Maybe Text
a} :: AffectedEntity)

-- | 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@
affectedEntity_eventArn :: Lens.Lens' AffectedEntity (Prelude.Maybe Prelude.Text)
affectedEntity_eventArn :: Lens' AffectedEntity (Maybe Text)
affectedEntity_eventArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AffectedEntity' {Maybe Text
eventArn :: Maybe Text
$sel:eventArn:AffectedEntity' :: AffectedEntity -> Maybe Text
eventArn} -> Maybe Text
eventArn) (\s :: AffectedEntity
s@AffectedEntity' {} Maybe Text
a -> AffectedEntity
s {$sel:eventArn:AffectedEntity' :: Maybe Text
eventArn = Maybe Text
a} :: AffectedEntity)

-- | The most recent time that the entity was updated.
affectedEntity_lastUpdatedTime :: Lens.Lens' AffectedEntity (Prelude.Maybe Prelude.UTCTime)
affectedEntity_lastUpdatedTime :: Lens' AffectedEntity (Maybe UTCTime)
affectedEntity_lastUpdatedTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AffectedEntity' {Maybe POSIX
lastUpdatedTime :: Maybe POSIX
$sel:lastUpdatedTime:AffectedEntity' :: AffectedEntity -> Maybe POSIX
lastUpdatedTime} -> Maybe POSIX
lastUpdatedTime) (\s :: AffectedEntity
s@AffectedEntity' {} Maybe POSIX
a -> AffectedEntity
s {$sel:lastUpdatedTime:AffectedEntity' :: Maybe POSIX
lastUpdatedTime = Maybe POSIX
a} :: AffectedEntity) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The most recent status of the entity affected by the event. The possible
-- values are @IMPAIRED@, @UNIMPAIRED@, and @UNKNOWN@.
affectedEntity_statusCode :: Lens.Lens' AffectedEntity (Prelude.Maybe EntityStatusCode)
affectedEntity_statusCode :: Lens' AffectedEntity (Maybe EntityStatusCode)
affectedEntity_statusCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AffectedEntity' {Maybe EntityStatusCode
statusCode :: Maybe EntityStatusCode
$sel:statusCode:AffectedEntity' :: AffectedEntity -> Maybe EntityStatusCode
statusCode} -> Maybe EntityStatusCode
statusCode) (\s :: AffectedEntity
s@AffectedEntity' {} Maybe EntityStatusCode
a -> AffectedEntity
s {$sel:statusCode:AffectedEntity' :: Maybe EntityStatusCode
statusCode = Maybe EntityStatusCode
a} :: AffectedEntity)

-- | A map of entity tags attached to the affected entity.
--
-- Currently, the @tags@ property isn\'t supported.
affectedEntity_tags :: Lens.Lens' AffectedEntity (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
affectedEntity_tags :: Lens' AffectedEntity (Maybe (HashMap Text Text))
affectedEntity_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AffectedEntity' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:AffectedEntity' :: AffectedEntity -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: AffectedEntity
s@AffectedEntity' {} Maybe (HashMap Text Text)
a -> AffectedEntity
s {$sel:tags:AffectedEntity' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: AffectedEntity) 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 Data.FromJSON AffectedEntity where
  parseJSON :: Value -> Parser AffectedEntity
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AffectedEntity"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe EntityStatusCode
-> Maybe (HashMap Text Text)
-> AffectedEntity
AffectedEntity'
            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
"awsAccountId")
            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
"entityArn")
            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
"entityUrl")
            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
"entityValue")
            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")
            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
"lastUpdatedTime")
            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
"statusCode")
            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
"tags" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AffectedEntity where
  hashWithSalt :: Int -> AffectedEntity -> Int
hashWithSalt Int
_salt AffectedEntity' {Maybe Text
Maybe (HashMap Text Text)
Maybe POSIX
Maybe EntityStatusCode
tags :: Maybe (HashMap Text Text)
statusCode :: Maybe EntityStatusCode
lastUpdatedTime :: Maybe POSIX
eventArn :: Maybe Text
entityValue :: Maybe Text
entityUrl :: Maybe Text
entityArn :: Maybe Text
awsAccountId :: Maybe Text
$sel:tags:AffectedEntity' :: AffectedEntity -> Maybe (HashMap Text Text)
$sel:statusCode:AffectedEntity' :: AffectedEntity -> Maybe EntityStatusCode
$sel:lastUpdatedTime:AffectedEntity' :: AffectedEntity -> Maybe POSIX
$sel:eventArn:AffectedEntity' :: AffectedEntity -> Maybe Text
$sel:entityValue:AffectedEntity' :: AffectedEntity -> Maybe Text
$sel:entityUrl:AffectedEntity' :: AffectedEntity -> Maybe Text
$sel:entityArn:AffectedEntity' :: AffectedEntity -> Maybe Text
$sel:awsAccountId:AffectedEntity' :: AffectedEntity -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
awsAccountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
entityArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
entityUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
entityValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
eventArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastUpdatedTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EntityStatusCode
statusCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags

instance Prelude.NFData AffectedEntity where
  rnf :: AffectedEntity -> ()
rnf AffectedEntity' {Maybe Text
Maybe (HashMap Text Text)
Maybe POSIX
Maybe EntityStatusCode
tags :: Maybe (HashMap Text Text)
statusCode :: Maybe EntityStatusCode
lastUpdatedTime :: Maybe POSIX
eventArn :: Maybe Text
entityValue :: Maybe Text
entityUrl :: Maybe Text
entityArn :: Maybe Text
awsAccountId :: Maybe Text
$sel:tags:AffectedEntity' :: AffectedEntity -> Maybe (HashMap Text Text)
$sel:statusCode:AffectedEntity' :: AffectedEntity -> Maybe EntityStatusCode
$sel:lastUpdatedTime:AffectedEntity' :: AffectedEntity -> Maybe POSIX
$sel:eventArn:AffectedEntity' :: AffectedEntity -> Maybe Text
$sel:entityValue:AffectedEntity' :: AffectedEntity -> Maybe Text
$sel:entityUrl:AffectedEntity' :: AffectedEntity -> Maybe Text
$sel:entityArn:AffectedEntity' :: AffectedEntity -> Maybe Text
$sel:awsAccountId:AffectedEntity' :: AffectedEntity -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
awsAccountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
entityArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
entityUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
entityValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eventArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastUpdatedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EntityStatusCode
statusCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags