{-# 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.AutoScaling.Types.InstanceMonitoring
-- 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.AutoScaling.Types.InstanceMonitoring where

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

-- | Describes whether detailed monitoring is enabled for the Auto Scaling
-- instances.
--
-- /See:/ 'newInstanceMonitoring' smart constructor.
data InstanceMonitoring = InstanceMonitoring'
  { -- | If @true@, detailed monitoring is enabled. Otherwise, basic monitoring
    -- is enabled.
    InstanceMonitoring -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (InstanceMonitoring -> InstanceMonitoring -> Bool
(InstanceMonitoring -> InstanceMonitoring -> Bool)
-> (InstanceMonitoring -> InstanceMonitoring -> Bool)
-> Eq InstanceMonitoring
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceMonitoring -> InstanceMonitoring -> Bool
$c/= :: InstanceMonitoring -> InstanceMonitoring -> Bool
== :: InstanceMonitoring -> InstanceMonitoring -> Bool
$c== :: InstanceMonitoring -> InstanceMonitoring -> Bool
Prelude.Eq, ReadPrec [InstanceMonitoring]
ReadPrec InstanceMonitoring
Int -> ReadS InstanceMonitoring
ReadS [InstanceMonitoring]
(Int -> ReadS InstanceMonitoring)
-> ReadS [InstanceMonitoring]
-> ReadPrec InstanceMonitoring
-> ReadPrec [InstanceMonitoring]
-> Read InstanceMonitoring
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceMonitoring]
$creadListPrec :: ReadPrec [InstanceMonitoring]
readPrec :: ReadPrec InstanceMonitoring
$creadPrec :: ReadPrec InstanceMonitoring
readList :: ReadS [InstanceMonitoring]
$creadList :: ReadS [InstanceMonitoring]
readsPrec :: Int -> ReadS InstanceMonitoring
$creadsPrec :: Int -> ReadS InstanceMonitoring
Prelude.Read, Int -> InstanceMonitoring -> ShowS
[InstanceMonitoring] -> ShowS
InstanceMonitoring -> String
(Int -> InstanceMonitoring -> ShowS)
-> (InstanceMonitoring -> String)
-> ([InstanceMonitoring] -> ShowS)
-> Show InstanceMonitoring
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceMonitoring] -> ShowS
$cshowList :: [InstanceMonitoring] -> ShowS
show :: InstanceMonitoring -> String
$cshow :: InstanceMonitoring -> String
showsPrec :: Int -> InstanceMonitoring -> ShowS
$cshowsPrec :: Int -> InstanceMonitoring -> ShowS
Prelude.Show, (forall x. InstanceMonitoring -> Rep InstanceMonitoring x)
-> (forall x. Rep InstanceMonitoring x -> InstanceMonitoring)
-> Generic InstanceMonitoring
forall x. Rep InstanceMonitoring x -> InstanceMonitoring
forall x. InstanceMonitoring -> Rep InstanceMonitoring x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceMonitoring x -> InstanceMonitoring
$cfrom :: forall x. InstanceMonitoring -> Rep InstanceMonitoring x
Prelude.Generic)

-- |
-- Create a value of 'InstanceMonitoring' 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:
--
-- 'enabled', 'instanceMonitoring_enabled' - If @true@, detailed monitoring is enabled. Otherwise, basic monitoring
-- is enabled.
newInstanceMonitoring ::
  InstanceMonitoring
newInstanceMonitoring :: InstanceMonitoring
newInstanceMonitoring =
  InstanceMonitoring' :: Maybe Bool -> InstanceMonitoring
InstanceMonitoring' {$sel:enabled:InstanceMonitoring' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing}

-- | If @true@, detailed monitoring is enabled. Otherwise, basic monitoring
-- is enabled.
instanceMonitoring_enabled :: Lens.Lens' InstanceMonitoring (Prelude.Maybe Prelude.Bool)
instanceMonitoring_enabled :: (Maybe Bool -> f (Maybe Bool))
-> InstanceMonitoring -> f InstanceMonitoring
instanceMonitoring_enabled = (InstanceMonitoring -> Maybe Bool)
-> (InstanceMonitoring -> Maybe Bool -> InstanceMonitoring)
-> Lens
     InstanceMonitoring InstanceMonitoring (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceMonitoring' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:InstanceMonitoring' :: InstanceMonitoring -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: InstanceMonitoring
s@InstanceMonitoring' {} Maybe Bool
a -> InstanceMonitoring
s {$sel:enabled:InstanceMonitoring' :: Maybe Bool
enabled = Maybe Bool
a} :: InstanceMonitoring)

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

instance Prelude.Hashable InstanceMonitoring

instance Prelude.NFData InstanceMonitoring

instance Core.ToQuery InstanceMonitoring where
  toQuery :: InstanceMonitoring -> QueryString
toQuery InstanceMonitoring' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:InstanceMonitoring' :: InstanceMonitoring -> Maybe Bool
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"Enabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
enabled]