{-# 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.EC2.Types.Monitoring
-- 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.EC2.Types.Monitoring where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.MonitoringState
import qualified Amazonka.Prelude as Prelude

-- | Describes the monitoring of an instance.
--
-- /See:/ 'newMonitoring' smart constructor.
data Monitoring = Monitoring'
  { -- | Indicates whether detailed monitoring is enabled. Otherwise, basic
    -- monitoring is enabled.
    Monitoring -> Maybe MonitoringState
state :: Prelude.Maybe MonitoringState
  }
  deriving (Monitoring -> Monitoring -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Monitoring -> Monitoring -> Bool
$c/= :: Monitoring -> Monitoring -> Bool
== :: Monitoring -> Monitoring -> Bool
$c== :: Monitoring -> Monitoring -> Bool
Prelude.Eq, ReadPrec [Monitoring]
ReadPrec Monitoring
Int -> ReadS Monitoring
ReadS [Monitoring]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Monitoring]
$creadListPrec :: ReadPrec [Monitoring]
readPrec :: ReadPrec Monitoring
$creadPrec :: ReadPrec Monitoring
readList :: ReadS [Monitoring]
$creadList :: ReadS [Monitoring]
readsPrec :: Int -> ReadS Monitoring
$creadsPrec :: Int -> ReadS Monitoring
Prelude.Read, Int -> Monitoring -> ShowS
[Monitoring] -> ShowS
Monitoring -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Monitoring] -> ShowS
$cshowList :: [Monitoring] -> ShowS
show :: Monitoring -> String
$cshow :: Monitoring -> String
showsPrec :: Int -> Monitoring -> ShowS
$cshowsPrec :: Int -> Monitoring -> ShowS
Prelude.Show, forall x. Rep Monitoring x -> Monitoring
forall x. Monitoring -> Rep Monitoring x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Monitoring x -> Monitoring
$cfrom :: forall x. Monitoring -> Rep Monitoring x
Prelude.Generic)

-- |
-- Create a value of 'Monitoring' 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:
--
-- 'state', 'monitoring_state' - Indicates whether detailed monitoring is enabled. Otherwise, basic
-- monitoring is enabled.
newMonitoring ::
  Monitoring
newMonitoring :: Monitoring
newMonitoring = Monitoring' {$sel:state:Monitoring' :: Maybe MonitoringState
state = forall a. Maybe a
Prelude.Nothing}

-- | Indicates whether detailed monitoring is enabled. Otherwise, basic
-- monitoring is enabled.
monitoring_state :: Lens.Lens' Monitoring (Prelude.Maybe MonitoringState)
monitoring_state :: Lens' Monitoring (Maybe MonitoringState)
monitoring_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Monitoring' {Maybe MonitoringState
state :: Maybe MonitoringState
$sel:state:Monitoring' :: Monitoring -> Maybe MonitoringState
state} -> Maybe MonitoringState
state) (\s :: Monitoring
s@Monitoring' {} Maybe MonitoringState
a -> Monitoring
s {$sel:state:Monitoring' :: Maybe MonitoringState
state = Maybe MonitoringState
a} :: Monitoring)

instance Data.FromXML Monitoring where
  parseXML :: [Node] -> Either String Monitoring
parseXML [Node]
x =
    Maybe MonitoringState -> Monitoring
Monitoring' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"state")

instance Prelude.Hashable Monitoring where
  hashWithSalt :: Int -> Monitoring -> Int
hashWithSalt Int
_salt Monitoring' {Maybe MonitoringState
state :: Maybe MonitoringState
$sel:state:Monitoring' :: Monitoring -> Maybe MonitoringState
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MonitoringState
state

instance Prelude.NFData Monitoring where
  rnf :: Monitoring -> ()
rnf Monitoring' {Maybe MonitoringState
state :: Maybe MonitoringState
$sel:state:Monitoring' :: Monitoring -> Maybe MonitoringState
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe MonitoringState
state