{-# 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.EMRContainers.Types.CloudWatchMonitoringConfiguration
-- 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.EMRContainers.Types.CloudWatchMonitoringConfiguration where

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

-- | A configuration for CloudWatch monitoring. You can configure your jobs
-- to send log information to CloudWatch Logs.
--
-- /See:/ 'newCloudWatchMonitoringConfiguration' smart constructor.
data CloudWatchMonitoringConfiguration = CloudWatchMonitoringConfiguration'
  { -- | The specified name prefix for log streams.
    CloudWatchMonitoringConfiguration -> Maybe Text
logStreamNamePrefix :: Prelude.Maybe Prelude.Text,
    -- | The name of the log group for log publishing.
    CloudWatchMonitoringConfiguration -> Text
logGroupName :: Prelude.Text
  }
  deriving (CloudWatchMonitoringConfiguration
-> CloudWatchMonitoringConfiguration -> Bool
(CloudWatchMonitoringConfiguration
 -> CloudWatchMonitoringConfiguration -> Bool)
-> (CloudWatchMonitoringConfiguration
    -> CloudWatchMonitoringConfiguration -> Bool)
-> Eq CloudWatchMonitoringConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudWatchMonitoringConfiguration
-> CloudWatchMonitoringConfiguration -> Bool
$c/= :: CloudWatchMonitoringConfiguration
-> CloudWatchMonitoringConfiguration -> Bool
== :: CloudWatchMonitoringConfiguration
-> CloudWatchMonitoringConfiguration -> Bool
$c== :: CloudWatchMonitoringConfiguration
-> CloudWatchMonitoringConfiguration -> Bool
Prelude.Eq, ReadPrec [CloudWatchMonitoringConfiguration]
ReadPrec CloudWatchMonitoringConfiguration
Int -> ReadS CloudWatchMonitoringConfiguration
ReadS [CloudWatchMonitoringConfiguration]
(Int -> ReadS CloudWatchMonitoringConfiguration)
-> ReadS [CloudWatchMonitoringConfiguration]
-> ReadPrec CloudWatchMonitoringConfiguration
-> ReadPrec [CloudWatchMonitoringConfiguration]
-> Read CloudWatchMonitoringConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudWatchMonitoringConfiguration]
$creadListPrec :: ReadPrec [CloudWatchMonitoringConfiguration]
readPrec :: ReadPrec CloudWatchMonitoringConfiguration
$creadPrec :: ReadPrec CloudWatchMonitoringConfiguration
readList :: ReadS [CloudWatchMonitoringConfiguration]
$creadList :: ReadS [CloudWatchMonitoringConfiguration]
readsPrec :: Int -> ReadS CloudWatchMonitoringConfiguration
$creadsPrec :: Int -> ReadS CloudWatchMonitoringConfiguration
Prelude.Read, Int -> CloudWatchMonitoringConfiguration -> ShowS
[CloudWatchMonitoringConfiguration] -> ShowS
CloudWatchMonitoringConfiguration -> String
(Int -> CloudWatchMonitoringConfiguration -> ShowS)
-> (CloudWatchMonitoringConfiguration -> String)
-> ([CloudWatchMonitoringConfiguration] -> ShowS)
-> Show CloudWatchMonitoringConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudWatchMonitoringConfiguration] -> ShowS
$cshowList :: [CloudWatchMonitoringConfiguration] -> ShowS
show :: CloudWatchMonitoringConfiguration -> String
$cshow :: CloudWatchMonitoringConfiguration -> String
showsPrec :: Int -> CloudWatchMonitoringConfiguration -> ShowS
$cshowsPrec :: Int -> CloudWatchMonitoringConfiguration -> ShowS
Prelude.Show, (forall x.
 CloudWatchMonitoringConfiguration
 -> Rep CloudWatchMonitoringConfiguration x)
-> (forall x.
    Rep CloudWatchMonitoringConfiguration x
    -> CloudWatchMonitoringConfiguration)
-> Generic CloudWatchMonitoringConfiguration
forall x.
Rep CloudWatchMonitoringConfiguration x
-> CloudWatchMonitoringConfiguration
forall x.
CloudWatchMonitoringConfiguration
-> Rep CloudWatchMonitoringConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CloudWatchMonitoringConfiguration x
-> CloudWatchMonitoringConfiguration
$cfrom :: forall x.
CloudWatchMonitoringConfiguration
-> Rep CloudWatchMonitoringConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'CloudWatchMonitoringConfiguration' 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:
--
-- 'logStreamNamePrefix', 'cloudWatchMonitoringConfiguration_logStreamNamePrefix' - The specified name prefix for log streams.
--
-- 'logGroupName', 'cloudWatchMonitoringConfiguration_logGroupName' - The name of the log group for log publishing.
newCloudWatchMonitoringConfiguration ::
  -- | 'logGroupName'
  Prelude.Text ->
  CloudWatchMonitoringConfiguration
newCloudWatchMonitoringConfiguration :: Text -> CloudWatchMonitoringConfiguration
newCloudWatchMonitoringConfiguration Text
pLogGroupName_ =
  CloudWatchMonitoringConfiguration' :: Maybe Text -> Text -> CloudWatchMonitoringConfiguration
CloudWatchMonitoringConfiguration'
    { $sel:logStreamNamePrefix:CloudWatchMonitoringConfiguration' :: Maybe Text
logStreamNamePrefix =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:logGroupName:CloudWatchMonitoringConfiguration' :: Text
logGroupName = Text
pLogGroupName_
    }

-- | The specified name prefix for log streams.
cloudWatchMonitoringConfiguration_logStreamNamePrefix :: Lens.Lens' CloudWatchMonitoringConfiguration (Prelude.Maybe Prelude.Text)
cloudWatchMonitoringConfiguration_logStreamNamePrefix :: (Maybe Text -> f (Maybe Text))
-> CloudWatchMonitoringConfiguration
-> f CloudWatchMonitoringConfiguration
cloudWatchMonitoringConfiguration_logStreamNamePrefix = (CloudWatchMonitoringConfiguration -> Maybe Text)
-> (CloudWatchMonitoringConfiguration
    -> Maybe Text -> CloudWatchMonitoringConfiguration)
-> Lens
     CloudWatchMonitoringConfiguration
     CloudWatchMonitoringConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchMonitoringConfiguration' {Maybe Text
logStreamNamePrefix :: Maybe Text
$sel:logStreamNamePrefix:CloudWatchMonitoringConfiguration' :: CloudWatchMonitoringConfiguration -> Maybe Text
logStreamNamePrefix} -> Maybe Text
logStreamNamePrefix) (\s :: CloudWatchMonitoringConfiguration
s@CloudWatchMonitoringConfiguration' {} Maybe Text
a -> CloudWatchMonitoringConfiguration
s {$sel:logStreamNamePrefix:CloudWatchMonitoringConfiguration' :: Maybe Text
logStreamNamePrefix = Maybe Text
a} :: CloudWatchMonitoringConfiguration)

-- | The name of the log group for log publishing.
cloudWatchMonitoringConfiguration_logGroupName :: Lens.Lens' CloudWatchMonitoringConfiguration Prelude.Text
cloudWatchMonitoringConfiguration_logGroupName :: (Text -> f Text)
-> CloudWatchMonitoringConfiguration
-> f CloudWatchMonitoringConfiguration
cloudWatchMonitoringConfiguration_logGroupName = (CloudWatchMonitoringConfiguration -> Text)
-> (CloudWatchMonitoringConfiguration
    -> Text -> CloudWatchMonitoringConfiguration)
-> Lens
     CloudWatchMonitoringConfiguration
     CloudWatchMonitoringConfiguration
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchMonitoringConfiguration' {Text
logGroupName :: Text
$sel:logGroupName:CloudWatchMonitoringConfiguration' :: CloudWatchMonitoringConfiguration -> Text
logGroupName} -> Text
logGroupName) (\s :: CloudWatchMonitoringConfiguration
s@CloudWatchMonitoringConfiguration' {} Text
a -> CloudWatchMonitoringConfiguration
s {$sel:logGroupName:CloudWatchMonitoringConfiguration' :: Text
logGroupName = Text
a} :: CloudWatchMonitoringConfiguration)

instance
  Core.FromJSON
    CloudWatchMonitoringConfiguration
  where
  parseJSON :: Value -> Parser CloudWatchMonitoringConfiguration
parseJSON =
    String
-> (Object -> Parser CloudWatchMonitoringConfiguration)
-> Value
-> Parser CloudWatchMonitoringConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CloudWatchMonitoringConfiguration"
      ( \Object
x ->
          Maybe Text -> Text -> CloudWatchMonitoringConfiguration
CloudWatchMonitoringConfiguration'
            (Maybe Text -> Text -> CloudWatchMonitoringConfiguration)
-> Parser (Maybe Text)
-> Parser (Text -> CloudWatchMonitoringConfiguration)
forall (f :: * -> *) a b. Functor 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
"logStreamNamePrefix")
            Parser (Text -> CloudWatchMonitoringConfiguration)
-> Parser Text -> Parser CloudWatchMonitoringConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"logGroupName")
      )

instance
  Prelude.Hashable
    CloudWatchMonitoringConfiguration

instance
  Prelude.NFData
    CloudWatchMonitoringConfiguration

instance
  Core.ToJSON
    CloudWatchMonitoringConfiguration
  where
  toJSON :: CloudWatchMonitoringConfiguration -> Value
toJSON CloudWatchMonitoringConfiguration' {Maybe Text
Text
logGroupName :: Text
logStreamNamePrefix :: Maybe Text
$sel:logGroupName:CloudWatchMonitoringConfiguration' :: CloudWatchMonitoringConfiguration -> Text
$sel:logStreamNamePrefix:CloudWatchMonitoringConfiguration' :: CloudWatchMonitoringConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"logStreamNamePrefix" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
logStreamNamePrefix,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"logGroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
logGroupName)
          ]
      )