{-# 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.Kafka.Types.PrometheusInfo
-- 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.Kafka.Types.PrometheusInfo where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kafka.Types.JmxExporterInfo
import Amazonka.Kafka.Types.NodeExporterInfo
import qualified Amazonka.Prelude as Prelude

-- | Prometheus settings.
--
-- /See:/ 'newPrometheusInfo' smart constructor.
data PrometheusInfo = PrometheusInfo'
  { -- | Indicates whether you want to turn on or turn off the JMX Exporter.
    PrometheusInfo -> Maybe JmxExporterInfo
jmxExporter :: Prelude.Maybe JmxExporterInfo,
    -- | Indicates whether you want to turn on or turn off the Node Exporter.
    PrometheusInfo -> Maybe NodeExporterInfo
nodeExporter :: Prelude.Maybe NodeExporterInfo
  }
  deriving (PrometheusInfo -> PrometheusInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PrometheusInfo -> PrometheusInfo -> Bool
$c/= :: PrometheusInfo -> PrometheusInfo -> Bool
== :: PrometheusInfo -> PrometheusInfo -> Bool
$c== :: PrometheusInfo -> PrometheusInfo -> Bool
Prelude.Eq, ReadPrec [PrometheusInfo]
ReadPrec PrometheusInfo
Int -> ReadS PrometheusInfo
ReadS [PrometheusInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PrometheusInfo]
$creadListPrec :: ReadPrec [PrometheusInfo]
readPrec :: ReadPrec PrometheusInfo
$creadPrec :: ReadPrec PrometheusInfo
readList :: ReadS [PrometheusInfo]
$creadList :: ReadS [PrometheusInfo]
readsPrec :: Int -> ReadS PrometheusInfo
$creadsPrec :: Int -> ReadS PrometheusInfo
Prelude.Read, Int -> PrometheusInfo -> ShowS
[PrometheusInfo] -> ShowS
PrometheusInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PrometheusInfo] -> ShowS
$cshowList :: [PrometheusInfo] -> ShowS
show :: PrometheusInfo -> String
$cshow :: PrometheusInfo -> String
showsPrec :: Int -> PrometheusInfo -> ShowS
$cshowsPrec :: Int -> PrometheusInfo -> ShowS
Prelude.Show, forall x. Rep PrometheusInfo x -> PrometheusInfo
forall x. PrometheusInfo -> Rep PrometheusInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PrometheusInfo x -> PrometheusInfo
$cfrom :: forall x. PrometheusInfo -> Rep PrometheusInfo x
Prelude.Generic)

-- |
-- Create a value of 'PrometheusInfo' 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:
--
-- 'jmxExporter', 'prometheusInfo_jmxExporter' - Indicates whether you want to turn on or turn off the JMX Exporter.
--
-- 'nodeExporter', 'prometheusInfo_nodeExporter' - Indicates whether you want to turn on or turn off the Node Exporter.
newPrometheusInfo ::
  PrometheusInfo
newPrometheusInfo :: PrometheusInfo
newPrometheusInfo =
  PrometheusInfo'
    { $sel:jmxExporter:PrometheusInfo' :: Maybe JmxExporterInfo
jmxExporter = forall a. Maybe a
Prelude.Nothing,
      $sel:nodeExporter:PrometheusInfo' :: Maybe NodeExporterInfo
nodeExporter = forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether you want to turn on or turn off the JMX Exporter.
prometheusInfo_jmxExporter :: Lens.Lens' PrometheusInfo (Prelude.Maybe JmxExporterInfo)
prometheusInfo_jmxExporter :: Lens' PrometheusInfo (Maybe JmxExporterInfo)
prometheusInfo_jmxExporter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrometheusInfo' {Maybe JmxExporterInfo
jmxExporter :: Maybe JmxExporterInfo
$sel:jmxExporter:PrometheusInfo' :: PrometheusInfo -> Maybe JmxExporterInfo
jmxExporter} -> Maybe JmxExporterInfo
jmxExporter) (\s :: PrometheusInfo
s@PrometheusInfo' {} Maybe JmxExporterInfo
a -> PrometheusInfo
s {$sel:jmxExporter:PrometheusInfo' :: Maybe JmxExporterInfo
jmxExporter = Maybe JmxExporterInfo
a} :: PrometheusInfo)

-- | Indicates whether you want to turn on or turn off the Node Exporter.
prometheusInfo_nodeExporter :: Lens.Lens' PrometheusInfo (Prelude.Maybe NodeExporterInfo)
prometheusInfo_nodeExporter :: Lens' PrometheusInfo (Maybe NodeExporterInfo)
prometheusInfo_nodeExporter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrometheusInfo' {Maybe NodeExporterInfo
nodeExporter :: Maybe NodeExporterInfo
$sel:nodeExporter:PrometheusInfo' :: PrometheusInfo -> Maybe NodeExporterInfo
nodeExporter} -> Maybe NodeExporterInfo
nodeExporter) (\s :: PrometheusInfo
s@PrometheusInfo' {} Maybe NodeExporterInfo
a -> PrometheusInfo
s {$sel:nodeExporter:PrometheusInfo' :: Maybe NodeExporterInfo
nodeExporter = Maybe NodeExporterInfo
a} :: PrometheusInfo)

instance Data.FromJSON PrometheusInfo where
  parseJSON :: Value -> Parser PrometheusInfo
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PrometheusInfo"
      ( \Object
x ->
          Maybe JmxExporterInfo -> Maybe NodeExporterInfo -> PrometheusInfo
PrometheusInfo'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"jmxExporter")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"nodeExporter")
      )

instance Prelude.Hashable PrometheusInfo where
  hashWithSalt :: Int -> PrometheusInfo -> Int
hashWithSalt Int
_salt PrometheusInfo' {Maybe JmxExporterInfo
Maybe NodeExporterInfo
nodeExporter :: Maybe NodeExporterInfo
jmxExporter :: Maybe JmxExporterInfo
$sel:nodeExporter:PrometheusInfo' :: PrometheusInfo -> Maybe NodeExporterInfo
$sel:jmxExporter:PrometheusInfo' :: PrometheusInfo -> Maybe JmxExporterInfo
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe JmxExporterInfo
jmxExporter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NodeExporterInfo
nodeExporter

instance Prelude.NFData PrometheusInfo where
  rnf :: PrometheusInfo -> ()
rnf PrometheusInfo' {Maybe JmxExporterInfo
Maybe NodeExporterInfo
nodeExporter :: Maybe NodeExporterInfo
jmxExporter :: Maybe JmxExporterInfo
$sel:nodeExporter:PrometheusInfo' :: PrometheusInfo -> Maybe NodeExporterInfo
$sel:jmxExporter:PrometheusInfo' :: PrometheusInfo -> Maybe JmxExporterInfo
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe JmxExporterInfo
jmxExporter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NodeExporterInfo
nodeExporter

instance Data.ToJSON PrometheusInfo where
  toJSON :: PrometheusInfo -> Value
toJSON PrometheusInfo' {Maybe JmxExporterInfo
Maybe NodeExporterInfo
nodeExporter :: Maybe NodeExporterInfo
jmxExporter :: Maybe JmxExporterInfo
$sel:nodeExporter:PrometheusInfo' :: PrometheusInfo -> Maybe NodeExporterInfo
$sel:jmxExporter:PrometheusInfo' :: PrometheusInfo -> Maybe JmxExporterInfo
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"jmxExporter" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JmxExporterInfo
jmxExporter,
            (Key
"nodeExporter" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NodeExporterInfo
nodeExporter
          ]
      )