{-# 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.KinesisAnalyticsV2.Types.MonitoringConfiguration
-- 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.KinesisAnalyticsV2.Types.MonitoringConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalyticsV2.Types.ConfigurationType
import Amazonka.KinesisAnalyticsV2.Types.LogLevel
import Amazonka.KinesisAnalyticsV2.Types.MetricsLevel
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes configuration parameters for Amazon CloudWatch logging for an
-- application. For more information about CloudWatch logging, see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/java/monitoring-overview.html Monitoring>.
--
-- /See:/ 'newMonitoringConfiguration' smart constructor.
data MonitoringConfiguration = MonitoringConfiguration'
  { -- | Describes the verbosity of the CloudWatch Logs for an application.
    MonitoringConfiguration -> Maybe LogLevel
logLevel :: Prelude.Maybe LogLevel,
    -- | Describes the granularity of the CloudWatch Logs for an application. The
    -- @Parallelism@ level is not recommended for applications with a
    -- Parallelism over 64 due to excessive costs.
    MonitoringConfiguration -> Maybe MetricsLevel
metricsLevel :: Prelude.Maybe MetricsLevel,
    -- | Describes whether to use the default CloudWatch logging configuration
    -- for an application. You must set this property to @CUSTOM@ in order to
    -- set the @LogLevel@ or @MetricsLevel@ parameters.
    MonitoringConfiguration -> ConfigurationType
configurationType :: ConfigurationType
  }
  deriving (MonitoringConfiguration -> MonitoringConfiguration -> Bool
(MonitoringConfiguration -> MonitoringConfiguration -> Bool)
-> (MonitoringConfiguration -> MonitoringConfiguration -> Bool)
-> Eq MonitoringConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MonitoringConfiguration -> MonitoringConfiguration -> Bool
$c/= :: MonitoringConfiguration -> MonitoringConfiguration -> Bool
== :: MonitoringConfiguration -> MonitoringConfiguration -> Bool
$c== :: MonitoringConfiguration -> MonitoringConfiguration -> Bool
Prelude.Eq, ReadPrec [MonitoringConfiguration]
ReadPrec MonitoringConfiguration
Int -> ReadS MonitoringConfiguration
ReadS [MonitoringConfiguration]
(Int -> ReadS MonitoringConfiguration)
-> ReadS [MonitoringConfiguration]
-> ReadPrec MonitoringConfiguration
-> ReadPrec [MonitoringConfiguration]
-> Read MonitoringConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MonitoringConfiguration]
$creadListPrec :: ReadPrec [MonitoringConfiguration]
readPrec :: ReadPrec MonitoringConfiguration
$creadPrec :: ReadPrec MonitoringConfiguration
readList :: ReadS [MonitoringConfiguration]
$creadList :: ReadS [MonitoringConfiguration]
readsPrec :: Int -> ReadS MonitoringConfiguration
$creadsPrec :: Int -> ReadS MonitoringConfiguration
Prelude.Read, Int -> MonitoringConfiguration -> ShowS
[MonitoringConfiguration] -> ShowS
MonitoringConfiguration -> String
(Int -> MonitoringConfiguration -> ShowS)
-> (MonitoringConfiguration -> String)
-> ([MonitoringConfiguration] -> ShowS)
-> Show MonitoringConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MonitoringConfiguration] -> ShowS
$cshowList :: [MonitoringConfiguration] -> ShowS
show :: MonitoringConfiguration -> String
$cshow :: MonitoringConfiguration -> String
showsPrec :: Int -> MonitoringConfiguration -> ShowS
$cshowsPrec :: Int -> MonitoringConfiguration -> ShowS
Prelude.Show, (forall x.
 MonitoringConfiguration -> Rep MonitoringConfiguration x)
-> (forall x.
    Rep MonitoringConfiguration x -> MonitoringConfiguration)
-> Generic MonitoringConfiguration
forall x. Rep MonitoringConfiguration x -> MonitoringConfiguration
forall x. MonitoringConfiguration -> Rep MonitoringConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MonitoringConfiguration x -> MonitoringConfiguration
$cfrom :: forall x. MonitoringConfiguration -> Rep MonitoringConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'MonitoringConfiguration' 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:
--
-- 'logLevel', 'monitoringConfiguration_logLevel' - Describes the verbosity of the CloudWatch Logs for an application.
--
-- 'metricsLevel', 'monitoringConfiguration_metricsLevel' - Describes the granularity of the CloudWatch Logs for an application. The
-- @Parallelism@ level is not recommended for applications with a
-- Parallelism over 64 due to excessive costs.
--
-- 'configurationType', 'monitoringConfiguration_configurationType' - Describes whether to use the default CloudWatch logging configuration
-- for an application. You must set this property to @CUSTOM@ in order to
-- set the @LogLevel@ or @MetricsLevel@ parameters.
newMonitoringConfiguration ::
  -- | 'configurationType'
  ConfigurationType ->
  MonitoringConfiguration
newMonitoringConfiguration :: ConfigurationType -> MonitoringConfiguration
newMonitoringConfiguration ConfigurationType
pConfigurationType_ =
  MonitoringConfiguration' :: Maybe LogLevel
-> Maybe MetricsLevel
-> ConfigurationType
-> MonitoringConfiguration
MonitoringConfiguration'
    { $sel:logLevel:MonitoringConfiguration' :: Maybe LogLevel
logLevel =
        Maybe LogLevel
forall a. Maybe a
Prelude.Nothing,
      $sel:metricsLevel:MonitoringConfiguration' :: Maybe MetricsLevel
metricsLevel = Maybe MetricsLevel
forall a. Maybe a
Prelude.Nothing,
      $sel:configurationType:MonitoringConfiguration' :: ConfigurationType
configurationType = ConfigurationType
pConfigurationType_
    }

-- | Describes the verbosity of the CloudWatch Logs for an application.
monitoringConfiguration_logLevel :: Lens.Lens' MonitoringConfiguration (Prelude.Maybe LogLevel)
monitoringConfiguration_logLevel :: (Maybe LogLevel -> f (Maybe LogLevel))
-> MonitoringConfiguration -> f MonitoringConfiguration
monitoringConfiguration_logLevel = (MonitoringConfiguration -> Maybe LogLevel)
-> (MonitoringConfiguration
    -> Maybe LogLevel -> MonitoringConfiguration)
-> Lens
     MonitoringConfiguration
     MonitoringConfiguration
     (Maybe LogLevel)
     (Maybe LogLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MonitoringConfiguration' {Maybe LogLevel
logLevel :: Maybe LogLevel
$sel:logLevel:MonitoringConfiguration' :: MonitoringConfiguration -> Maybe LogLevel
logLevel} -> Maybe LogLevel
logLevel) (\s :: MonitoringConfiguration
s@MonitoringConfiguration' {} Maybe LogLevel
a -> MonitoringConfiguration
s {$sel:logLevel:MonitoringConfiguration' :: Maybe LogLevel
logLevel = Maybe LogLevel
a} :: MonitoringConfiguration)

-- | Describes the granularity of the CloudWatch Logs for an application. The
-- @Parallelism@ level is not recommended for applications with a
-- Parallelism over 64 due to excessive costs.
monitoringConfiguration_metricsLevel :: Lens.Lens' MonitoringConfiguration (Prelude.Maybe MetricsLevel)
monitoringConfiguration_metricsLevel :: (Maybe MetricsLevel -> f (Maybe MetricsLevel))
-> MonitoringConfiguration -> f MonitoringConfiguration
monitoringConfiguration_metricsLevel = (MonitoringConfiguration -> Maybe MetricsLevel)
-> (MonitoringConfiguration
    -> Maybe MetricsLevel -> MonitoringConfiguration)
-> Lens
     MonitoringConfiguration
     MonitoringConfiguration
     (Maybe MetricsLevel)
     (Maybe MetricsLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MonitoringConfiguration' {Maybe MetricsLevel
metricsLevel :: Maybe MetricsLevel
$sel:metricsLevel:MonitoringConfiguration' :: MonitoringConfiguration -> Maybe MetricsLevel
metricsLevel} -> Maybe MetricsLevel
metricsLevel) (\s :: MonitoringConfiguration
s@MonitoringConfiguration' {} Maybe MetricsLevel
a -> MonitoringConfiguration
s {$sel:metricsLevel:MonitoringConfiguration' :: Maybe MetricsLevel
metricsLevel = Maybe MetricsLevel
a} :: MonitoringConfiguration)

-- | Describes whether to use the default CloudWatch logging configuration
-- for an application. You must set this property to @CUSTOM@ in order to
-- set the @LogLevel@ or @MetricsLevel@ parameters.
monitoringConfiguration_configurationType :: Lens.Lens' MonitoringConfiguration ConfigurationType
monitoringConfiguration_configurationType :: (ConfigurationType -> f ConfigurationType)
-> MonitoringConfiguration -> f MonitoringConfiguration
monitoringConfiguration_configurationType = (MonitoringConfiguration -> ConfigurationType)
-> (MonitoringConfiguration
    -> ConfigurationType -> MonitoringConfiguration)
-> Lens
     MonitoringConfiguration
     MonitoringConfiguration
     ConfigurationType
     ConfigurationType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MonitoringConfiguration' {ConfigurationType
configurationType :: ConfigurationType
$sel:configurationType:MonitoringConfiguration' :: MonitoringConfiguration -> ConfigurationType
configurationType} -> ConfigurationType
configurationType) (\s :: MonitoringConfiguration
s@MonitoringConfiguration' {} ConfigurationType
a -> MonitoringConfiguration
s {$sel:configurationType:MonitoringConfiguration' :: ConfigurationType
configurationType = ConfigurationType
a} :: MonitoringConfiguration)

instance Prelude.Hashable MonitoringConfiguration

instance Prelude.NFData MonitoringConfiguration

instance Core.ToJSON MonitoringConfiguration where
  toJSON :: MonitoringConfiguration -> Value
toJSON MonitoringConfiguration' {Maybe LogLevel
Maybe MetricsLevel
ConfigurationType
configurationType :: ConfigurationType
metricsLevel :: Maybe MetricsLevel
logLevel :: Maybe LogLevel
$sel:configurationType:MonitoringConfiguration' :: MonitoringConfiguration -> ConfigurationType
$sel:metricsLevel:MonitoringConfiguration' :: MonitoringConfiguration -> Maybe MetricsLevel
$sel:logLevel:MonitoringConfiguration' :: MonitoringConfiguration -> Maybe LogLevel
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"LogLevel" Text -> LogLevel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LogLevel -> Pair) -> Maybe LogLevel -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LogLevel
logLevel,
            (Text
"MetricsLevel" Text -> MetricsLevel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (MetricsLevel -> Pair) -> Maybe MetricsLevel -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MetricsLevel
metricsLevel,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ConfigurationType" Text -> ConfigurationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ConfigurationType
configurationType)
          ]
      )