{-# 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.Lightsail.Types.MonitoredResourceInfo
-- 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.Lightsail.Types.MonitoredResourceInfo where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types.ResourceType
import qualified Amazonka.Prelude as Prelude

-- | Describes resource being monitored by an alarm.
--
-- An alarm is a way to monitor your Amazon Lightsail resource metrics. For
-- more information, see
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-alarms Alarms in Amazon Lightsail>.
--
-- /See:/ 'newMonitoredResourceInfo' smart constructor.
data MonitoredResourceInfo = MonitoredResourceInfo'
  { -- | The Lightsail resource type of the resource being monitored.
    --
    -- Instances, load balancers, and relational databases are the only
    -- Lightsail resources that can currently be monitored by alarms.
    MonitoredResourceInfo -> Maybe ResourceType
resourceType :: Prelude.Maybe ResourceType,
    -- | The Amazon Resource Name (ARN) of the resource being monitored.
    MonitoredResourceInfo -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The name of the Lightsail resource being monitored.
    MonitoredResourceInfo -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (MonitoredResourceInfo -> MonitoredResourceInfo -> Bool
(MonitoredResourceInfo -> MonitoredResourceInfo -> Bool)
-> (MonitoredResourceInfo -> MonitoredResourceInfo -> Bool)
-> Eq MonitoredResourceInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MonitoredResourceInfo -> MonitoredResourceInfo -> Bool
$c/= :: MonitoredResourceInfo -> MonitoredResourceInfo -> Bool
== :: MonitoredResourceInfo -> MonitoredResourceInfo -> Bool
$c== :: MonitoredResourceInfo -> MonitoredResourceInfo -> Bool
Prelude.Eq, ReadPrec [MonitoredResourceInfo]
ReadPrec MonitoredResourceInfo
Int -> ReadS MonitoredResourceInfo
ReadS [MonitoredResourceInfo]
(Int -> ReadS MonitoredResourceInfo)
-> ReadS [MonitoredResourceInfo]
-> ReadPrec MonitoredResourceInfo
-> ReadPrec [MonitoredResourceInfo]
-> Read MonitoredResourceInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MonitoredResourceInfo]
$creadListPrec :: ReadPrec [MonitoredResourceInfo]
readPrec :: ReadPrec MonitoredResourceInfo
$creadPrec :: ReadPrec MonitoredResourceInfo
readList :: ReadS [MonitoredResourceInfo]
$creadList :: ReadS [MonitoredResourceInfo]
readsPrec :: Int -> ReadS MonitoredResourceInfo
$creadsPrec :: Int -> ReadS MonitoredResourceInfo
Prelude.Read, Int -> MonitoredResourceInfo -> ShowS
[MonitoredResourceInfo] -> ShowS
MonitoredResourceInfo -> String
(Int -> MonitoredResourceInfo -> ShowS)
-> (MonitoredResourceInfo -> String)
-> ([MonitoredResourceInfo] -> ShowS)
-> Show MonitoredResourceInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MonitoredResourceInfo] -> ShowS
$cshowList :: [MonitoredResourceInfo] -> ShowS
show :: MonitoredResourceInfo -> String
$cshow :: MonitoredResourceInfo -> String
showsPrec :: Int -> MonitoredResourceInfo -> ShowS
$cshowsPrec :: Int -> MonitoredResourceInfo -> ShowS
Prelude.Show, (forall x. MonitoredResourceInfo -> Rep MonitoredResourceInfo x)
-> (forall x. Rep MonitoredResourceInfo x -> MonitoredResourceInfo)
-> Generic MonitoredResourceInfo
forall x. Rep MonitoredResourceInfo x -> MonitoredResourceInfo
forall x. MonitoredResourceInfo -> Rep MonitoredResourceInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MonitoredResourceInfo x -> MonitoredResourceInfo
$cfrom :: forall x. MonitoredResourceInfo -> Rep MonitoredResourceInfo x
Prelude.Generic)

-- |
-- Create a value of 'MonitoredResourceInfo' 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:
--
-- 'resourceType', 'monitoredResourceInfo_resourceType' - The Lightsail resource type of the resource being monitored.
--
-- Instances, load balancers, and relational databases are the only
-- Lightsail resources that can currently be monitored by alarms.
--
-- 'arn', 'monitoredResourceInfo_arn' - The Amazon Resource Name (ARN) of the resource being monitored.
--
-- 'name', 'monitoredResourceInfo_name' - The name of the Lightsail resource being monitored.
newMonitoredResourceInfo ::
  MonitoredResourceInfo
newMonitoredResourceInfo :: MonitoredResourceInfo
newMonitoredResourceInfo =
  MonitoredResourceInfo' :: Maybe ResourceType
-> Maybe Text -> Maybe Text -> MonitoredResourceInfo
MonitoredResourceInfo'
    { $sel:resourceType:MonitoredResourceInfo' :: Maybe ResourceType
resourceType =
        Maybe ResourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:MonitoredResourceInfo' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:MonitoredResourceInfo' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Lightsail resource type of the resource being monitored.
--
-- Instances, load balancers, and relational databases are the only
-- Lightsail resources that can currently be monitored by alarms.
monitoredResourceInfo_resourceType :: Lens.Lens' MonitoredResourceInfo (Prelude.Maybe ResourceType)
monitoredResourceInfo_resourceType :: (Maybe ResourceType -> f (Maybe ResourceType))
-> MonitoredResourceInfo -> f MonitoredResourceInfo
monitoredResourceInfo_resourceType = (MonitoredResourceInfo -> Maybe ResourceType)
-> (MonitoredResourceInfo
    -> Maybe ResourceType -> MonitoredResourceInfo)
-> Lens
     MonitoredResourceInfo
     MonitoredResourceInfo
     (Maybe ResourceType)
     (Maybe ResourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MonitoredResourceInfo' {Maybe ResourceType
resourceType :: Maybe ResourceType
$sel:resourceType:MonitoredResourceInfo' :: MonitoredResourceInfo -> Maybe ResourceType
resourceType} -> Maybe ResourceType
resourceType) (\s :: MonitoredResourceInfo
s@MonitoredResourceInfo' {} Maybe ResourceType
a -> MonitoredResourceInfo
s {$sel:resourceType:MonitoredResourceInfo' :: Maybe ResourceType
resourceType = Maybe ResourceType
a} :: MonitoredResourceInfo)

-- | The Amazon Resource Name (ARN) of the resource being monitored.
monitoredResourceInfo_arn :: Lens.Lens' MonitoredResourceInfo (Prelude.Maybe Prelude.Text)
monitoredResourceInfo_arn :: (Maybe Text -> f (Maybe Text))
-> MonitoredResourceInfo -> f MonitoredResourceInfo
monitoredResourceInfo_arn = (MonitoredResourceInfo -> Maybe Text)
-> (MonitoredResourceInfo -> Maybe Text -> MonitoredResourceInfo)
-> Lens
     MonitoredResourceInfo
     MonitoredResourceInfo
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MonitoredResourceInfo' {Maybe Text
arn :: Maybe Text
$sel:arn:MonitoredResourceInfo' :: MonitoredResourceInfo -> Maybe Text
arn} -> Maybe Text
arn) (\s :: MonitoredResourceInfo
s@MonitoredResourceInfo' {} Maybe Text
a -> MonitoredResourceInfo
s {$sel:arn:MonitoredResourceInfo' :: Maybe Text
arn = Maybe Text
a} :: MonitoredResourceInfo)

-- | The name of the Lightsail resource being monitored.
monitoredResourceInfo_name :: Lens.Lens' MonitoredResourceInfo (Prelude.Maybe Prelude.Text)
monitoredResourceInfo_name :: (Maybe Text -> f (Maybe Text))
-> MonitoredResourceInfo -> f MonitoredResourceInfo
monitoredResourceInfo_name = (MonitoredResourceInfo -> Maybe Text)
-> (MonitoredResourceInfo -> Maybe Text -> MonitoredResourceInfo)
-> Lens
     MonitoredResourceInfo
     MonitoredResourceInfo
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MonitoredResourceInfo' {Maybe Text
name :: Maybe Text
$sel:name:MonitoredResourceInfo' :: MonitoredResourceInfo -> Maybe Text
name} -> Maybe Text
name) (\s :: MonitoredResourceInfo
s@MonitoredResourceInfo' {} Maybe Text
a -> MonitoredResourceInfo
s {$sel:name:MonitoredResourceInfo' :: Maybe Text
name = Maybe Text
a} :: MonitoredResourceInfo)

instance Core.FromJSON MonitoredResourceInfo where
  parseJSON :: Value -> Parser MonitoredResourceInfo
parseJSON =
    String
-> (Object -> Parser MonitoredResourceInfo)
-> Value
-> Parser MonitoredResourceInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MonitoredResourceInfo"
      ( \Object
x ->
          Maybe ResourceType
-> Maybe Text -> Maybe Text -> MonitoredResourceInfo
MonitoredResourceInfo'
            (Maybe ResourceType
 -> Maybe Text -> Maybe Text -> MonitoredResourceInfo)
-> Parser (Maybe ResourceType)
-> Parser (Maybe Text -> Maybe Text -> MonitoredResourceInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ResourceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"resourceType")
            Parser (Maybe Text -> Maybe Text -> MonitoredResourceInfo)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> MonitoredResourceInfo)
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
"arn")
            Parser (Maybe Text -> MonitoredResourceInfo)
-> Parser (Maybe Text) -> Parser MonitoredResourceInfo
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")
      )

instance Prelude.Hashable MonitoredResourceInfo

instance Prelude.NFData MonitoredResourceInfo