{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EMRContainers.Types.CloudWatchMonitoringConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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.
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'
    { $sel:logStreamNamePrefix:CloudWatchMonitoringConfiguration' :: Maybe Text
logStreamNamePrefix =
        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 :: Lens' CloudWatchMonitoringConfiguration (Maybe Text)
cloudWatchMonitoringConfiguration_logStreamNamePrefix = 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 :: Lens' CloudWatchMonitoringConfiguration Text
cloudWatchMonitoringConfiguration_logGroupName = 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
  Data.FromJSON
    CloudWatchMonitoringConfiguration
  where
  parseJSON :: Value -> Parser CloudWatchMonitoringConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CloudWatchMonitoringConfiguration"
      ( \Object
x ->
          Maybe Text -> Text -> CloudWatchMonitoringConfiguration
CloudWatchMonitoringConfiguration'
            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
"logStreamNamePrefix")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"logGroupName")
      )

instance
  Prelude.Hashable
    CloudWatchMonitoringConfiguration
  where
  hashWithSalt :: Int -> CloudWatchMonitoringConfiguration -> Int
hashWithSalt
    Int
_salt
    CloudWatchMonitoringConfiguration' {Maybe Text
Text
logGroupName :: Text
logStreamNamePrefix :: Maybe Text
$sel:logGroupName:CloudWatchMonitoringConfiguration' :: CloudWatchMonitoringConfiguration -> Text
$sel:logStreamNamePrefix:CloudWatchMonitoringConfiguration' :: CloudWatchMonitoringConfiguration -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
logStreamNamePrefix
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
logGroupName

instance
  Prelude.NFData
    CloudWatchMonitoringConfiguration
  where
  rnf :: CloudWatchMonitoringConfiguration -> ()
rnf CloudWatchMonitoringConfiguration' {Maybe Text
Text
logGroupName :: Text
logStreamNamePrefix :: Maybe Text
$sel:logGroupName:CloudWatchMonitoringConfiguration' :: CloudWatchMonitoringConfiguration -> Text
$sel:logStreamNamePrefix:CloudWatchMonitoringConfiguration' :: CloudWatchMonitoringConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
logStreamNamePrefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
logGroupName

instance
  Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"logStreamNamePrefix" 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 Text
logStreamNamePrefix,
            forall a. a -> Maybe a
Prelude.Just (Key
"logGroupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
logGroupName)
          ]
      )