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

import Amazonka.AWSHealth.Types.EventTypeCategory
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the metadata about a type of event that is reported by AWS
-- Health. The @EventType@ shows the category, service, and the event type
-- code of the event. For example, an @issue@ might be the category, @EC2@
-- the service, and @AWS_EC2_SYSTEM_MAINTENANCE_EVENT@ the event type code.
--
-- You can use the
-- <https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeEventTypes.html DescribeEventTypes>
-- API operation to return this information about an event.
--
-- You can also use the Amazon CloudWatch Events console to create a rule
-- so that you can get notified or take action when AWS Health delivers a
-- specific event to your AWS account. For more information, see
-- <https://docs.aws.amazon.com/health/latest/ug/cloudwatch-events-health.html Monitor for AWS Health events with Amazon CloudWatch Events>
-- in the /AWS Health User Guide/.
--
-- /See:/ 'newEventType' smart constructor.
data EventType = EventType'
  { -- | The AWS service that is affected by the event. For example, @EC2@,
    -- @RDS@.
    EventType -> Maybe Text
service :: Prelude.Maybe Prelude.Text,
    -- | A list of event type category codes (@issue@, @scheduledChange@, or
    -- @accountNotification@).
    EventType -> Maybe EventTypeCategory
category :: Prelude.Maybe EventTypeCategory,
    -- | The unique identifier for the event type. The format is
    -- @AWS_SERVICE_DESCRIPTION @; for example,
    -- @AWS_EC2_SYSTEM_MAINTENANCE_EVENT@.
    EventType -> Maybe Text
code :: Prelude.Maybe Prelude.Text
  }
  deriving (EventType -> EventType -> Bool
(EventType -> EventType -> Bool)
-> (EventType -> EventType -> Bool) -> Eq EventType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventType -> EventType -> Bool
$c/= :: EventType -> EventType -> Bool
== :: EventType -> EventType -> Bool
$c== :: EventType -> EventType -> Bool
Prelude.Eq, ReadPrec [EventType]
ReadPrec EventType
Int -> ReadS EventType
ReadS [EventType]
(Int -> ReadS EventType)
-> ReadS [EventType]
-> ReadPrec EventType
-> ReadPrec [EventType]
-> Read EventType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventType]
$creadListPrec :: ReadPrec [EventType]
readPrec :: ReadPrec EventType
$creadPrec :: ReadPrec EventType
readList :: ReadS [EventType]
$creadList :: ReadS [EventType]
readsPrec :: Int -> ReadS EventType
$creadsPrec :: Int -> ReadS EventType
Prelude.Read, Int -> EventType -> ShowS
[EventType] -> ShowS
EventType -> String
(Int -> EventType -> ShowS)
-> (EventType -> String)
-> ([EventType] -> ShowS)
-> Show EventType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventType] -> ShowS
$cshowList :: [EventType] -> ShowS
show :: EventType -> String
$cshow :: EventType -> String
showsPrec :: Int -> EventType -> ShowS
$cshowsPrec :: Int -> EventType -> ShowS
Prelude.Show, (forall x. EventType -> Rep EventType x)
-> (forall x. Rep EventType x -> EventType) -> Generic EventType
forall x. Rep EventType x -> EventType
forall x. EventType -> Rep EventType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventType x -> EventType
$cfrom :: forall x. EventType -> Rep EventType x
Prelude.Generic)

-- |
-- Create a value of 'EventType' 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:
--
-- 'service', 'eventType_service' - The AWS service that is affected by the event. For example, @EC2@,
-- @RDS@.
--
-- 'category', 'eventType_category' - A list of event type category codes (@issue@, @scheduledChange@, or
-- @accountNotification@).
--
-- 'code', 'eventType_code' - The unique identifier for the event type. The format is
-- @AWS_SERVICE_DESCRIPTION @; for example,
-- @AWS_EC2_SYSTEM_MAINTENANCE_EVENT@.
newEventType ::
  EventType
newEventType :: EventType
newEventType =
  EventType' :: Maybe Text -> Maybe EventTypeCategory -> Maybe Text -> EventType
EventType'
    { $sel:service:EventType' :: Maybe Text
service = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:category:EventType' :: Maybe EventTypeCategory
category = Maybe EventTypeCategory
forall a. Maybe a
Prelude.Nothing,
      $sel:code:EventType' :: Maybe Text
code = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The AWS service that is affected by the event. For example, @EC2@,
-- @RDS@.
eventType_service :: Lens.Lens' EventType (Prelude.Maybe Prelude.Text)
eventType_service :: (Maybe Text -> f (Maybe Text)) -> EventType -> f EventType
eventType_service = (EventType -> Maybe Text)
-> (EventType -> Maybe Text -> EventType)
-> Lens EventType EventType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventType' {Maybe Text
service :: Maybe Text
$sel:service:EventType' :: EventType -> Maybe Text
service} -> Maybe Text
service) (\s :: EventType
s@EventType' {} Maybe Text
a -> EventType
s {$sel:service:EventType' :: Maybe Text
service = Maybe Text
a} :: EventType)

-- | A list of event type category codes (@issue@, @scheduledChange@, or
-- @accountNotification@).
eventType_category :: Lens.Lens' EventType (Prelude.Maybe EventTypeCategory)
eventType_category :: (Maybe EventTypeCategory -> f (Maybe EventTypeCategory))
-> EventType -> f EventType
eventType_category = (EventType -> Maybe EventTypeCategory)
-> (EventType -> Maybe EventTypeCategory -> EventType)
-> Lens
     EventType
     EventType
     (Maybe EventTypeCategory)
     (Maybe EventTypeCategory)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventType' {Maybe EventTypeCategory
category :: Maybe EventTypeCategory
$sel:category:EventType' :: EventType -> Maybe EventTypeCategory
category} -> Maybe EventTypeCategory
category) (\s :: EventType
s@EventType' {} Maybe EventTypeCategory
a -> EventType
s {$sel:category:EventType' :: Maybe EventTypeCategory
category = Maybe EventTypeCategory
a} :: EventType)

-- | The unique identifier for the event type. The format is
-- @AWS_SERVICE_DESCRIPTION @; for example,
-- @AWS_EC2_SYSTEM_MAINTENANCE_EVENT@.
eventType_code :: Lens.Lens' EventType (Prelude.Maybe Prelude.Text)
eventType_code :: (Maybe Text -> f (Maybe Text)) -> EventType -> f EventType
eventType_code = (EventType -> Maybe Text)
-> (EventType -> Maybe Text -> EventType)
-> Lens EventType EventType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventType' {Maybe Text
code :: Maybe Text
$sel:code:EventType' :: EventType -> Maybe Text
code} -> Maybe Text
code) (\s :: EventType
s@EventType' {} Maybe Text
a -> EventType
s {$sel:code:EventType' :: Maybe Text
code = Maybe Text
a} :: EventType)

instance Core.FromJSON EventType where
  parseJSON :: Value -> Parser EventType
parseJSON =
    String -> (Object -> Parser EventType) -> Value -> Parser EventType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventType"
      ( \Object
x ->
          Maybe Text -> Maybe EventTypeCategory -> Maybe Text -> EventType
EventType'
            (Maybe Text -> Maybe EventTypeCategory -> Maybe Text -> EventType)
-> Parser (Maybe Text)
-> Parser (Maybe EventTypeCategory -> Maybe Text -> EventType)
forall (f :: * -> *) a b. Functor 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
"service")
            Parser (Maybe EventTypeCategory -> Maybe Text -> EventType)
-> Parser (Maybe EventTypeCategory)
-> Parser (Maybe Text -> EventType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EventTypeCategory)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"category")
            Parser (Maybe Text -> EventType)
-> Parser (Maybe Text) -> Parser EventType
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
"code")
      )

instance Prelude.Hashable EventType

instance Prelude.NFData EventType