{-# 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.DevOpsGuru.Types.EventResource
-- 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.DevOpsGuru.Types.EventResource where

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

-- | The AWS resource that emitted an event. AWS resource events and metrics
-- are analyzed by DevOps Guru to find anomalous behavior and provide
-- recommendations to improve your operational solutions.
--
-- /See:/ 'newEventResource' smart constructor.
data EventResource = EventResource'
  { -- | The Amazon Resource Name (ARN) of the resource that emitted an event.
    EventResource -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The name of the resource that emitted an event.
    EventResource -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The type of resource that emitted an event.
    EventResource -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (EventResource -> EventResource -> Bool
(EventResource -> EventResource -> Bool)
-> (EventResource -> EventResource -> Bool) -> Eq EventResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventResource -> EventResource -> Bool
$c/= :: EventResource -> EventResource -> Bool
== :: EventResource -> EventResource -> Bool
$c== :: EventResource -> EventResource -> Bool
Prelude.Eq, ReadPrec [EventResource]
ReadPrec EventResource
Int -> ReadS EventResource
ReadS [EventResource]
(Int -> ReadS EventResource)
-> ReadS [EventResource]
-> ReadPrec EventResource
-> ReadPrec [EventResource]
-> Read EventResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventResource]
$creadListPrec :: ReadPrec [EventResource]
readPrec :: ReadPrec EventResource
$creadPrec :: ReadPrec EventResource
readList :: ReadS [EventResource]
$creadList :: ReadS [EventResource]
readsPrec :: Int -> ReadS EventResource
$creadsPrec :: Int -> ReadS EventResource
Prelude.Read, Int -> EventResource -> ShowS
[EventResource] -> ShowS
EventResource -> String
(Int -> EventResource -> ShowS)
-> (EventResource -> String)
-> ([EventResource] -> ShowS)
-> Show EventResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventResource] -> ShowS
$cshowList :: [EventResource] -> ShowS
show :: EventResource -> String
$cshow :: EventResource -> String
showsPrec :: Int -> EventResource -> ShowS
$cshowsPrec :: Int -> EventResource -> ShowS
Prelude.Show, (forall x. EventResource -> Rep EventResource x)
-> (forall x. Rep EventResource x -> EventResource)
-> Generic EventResource
forall x. Rep EventResource x -> EventResource
forall x. EventResource -> Rep EventResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventResource x -> EventResource
$cfrom :: forall x. EventResource -> Rep EventResource x
Prelude.Generic)

-- |
-- Create a value of 'EventResource' 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:
--
-- 'arn', 'eventResource_arn' - The Amazon Resource Name (ARN) of the resource that emitted an event.
--
-- 'name', 'eventResource_name' - The name of the resource that emitted an event.
--
-- 'type'', 'eventResource_type' - The type of resource that emitted an event.
newEventResource ::
  EventResource
newEventResource :: EventResource
newEventResource =
  EventResource' :: Maybe Text -> Maybe Text -> Maybe Text -> EventResource
EventResource'
    { $sel:arn:EventResource' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:EventResource' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':EventResource' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the resource that emitted an event.
eventResource_arn :: Lens.Lens' EventResource (Prelude.Maybe Prelude.Text)
eventResource_arn :: (Maybe Text -> f (Maybe Text)) -> EventResource -> f EventResource
eventResource_arn = (EventResource -> Maybe Text)
-> (EventResource -> Maybe Text -> EventResource)
-> Lens EventResource EventResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventResource' {Maybe Text
arn :: Maybe Text
$sel:arn:EventResource' :: EventResource -> Maybe Text
arn} -> Maybe Text
arn) (\s :: EventResource
s@EventResource' {} Maybe Text
a -> EventResource
s {$sel:arn:EventResource' :: Maybe Text
arn = Maybe Text
a} :: EventResource)

-- | The name of the resource that emitted an event.
eventResource_name :: Lens.Lens' EventResource (Prelude.Maybe Prelude.Text)
eventResource_name :: (Maybe Text -> f (Maybe Text)) -> EventResource -> f EventResource
eventResource_name = (EventResource -> Maybe Text)
-> (EventResource -> Maybe Text -> EventResource)
-> Lens EventResource EventResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventResource' {Maybe Text
name :: Maybe Text
$sel:name:EventResource' :: EventResource -> Maybe Text
name} -> Maybe Text
name) (\s :: EventResource
s@EventResource' {} Maybe Text
a -> EventResource
s {$sel:name:EventResource' :: Maybe Text
name = Maybe Text
a} :: EventResource)

-- | The type of resource that emitted an event.
eventResource_type :: Lens.Lens' EventResource (Prelude.Maybe Prelude.Text)
eventResource_type :: (Maybe Text -> f (Maybe Text)) -> EventResource -> f EventResource
eventResource_type = (EventResource -> Maybe Text)
-> (EventResource -> Maybe Text -> EventResource)
-> Lens EventResource EventResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventResource' {Maybe Text
type' :: Maybe Text
$sel:type':EventResource' :: EventResource -> Maybe Text
type'} -> Maybe Text
type') (\s :: EventResource
s@EventResource' {} Maybe Text
a -> EventResource
s {$sel:type':EventResource' :: Maybe Text
type' = Maybe Text
a} :: EventResource)

instance Core.FromJSON EventResource where
  parseJSON :: Value -> Parser EventResource
parseJSON =
    String
-> (Object -> Parser EventResource)
-> Value
-> Parser EventResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventResource"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> EventResource
EventResource'
            (Maybe Text -> Maybe Text -> Maybe Text -> EventResource)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> EventResource)
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
"Arn")
            Parser (Maybe Text -> Maybe Text -> EventResource)
-> Parser (Maybe Text) -> Parser (Maybe Text -> EventResource)
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
"Name")
            Parser (Maybe Text -> EventResource)
-> Parser (Maybe Text) -> Parser EventResource
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
"Type")
      )

instance Prelude.Hashable EventResource

instance Prelude.NFData EventResource