{-# 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.SSM.Types.CloudWatchOutputConfig
-- 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.SSM.Types.CloudWatchOutputConfig where

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

-- | Configuration options for sending command output to Amazon CloudWatch
-- Logs.
--
-- /See:/ 'newCloudWatchOutputConfig' smart constructor.
data CloudWatchOutputConfig = CloudWatchOutputConfig'
  { -- | The name of the CloudWatch Logs log group where you want to send command
    -- output. If you don\'t specify a group name, Amazon Web Services Systems
    -- Manager automatically creates a log group for you. The log group uses
    -- the following naming format:
    --
    -- @aws\/ssm\/SystemsManagerDocumentName @
    CloudWatchOutputConfig -> Maybe Text
cloudWatchLogGroupName :: Prelude.Maybe Prelude.Text,
    -- | Enables Systems Manager to send command output to CloudWatch Logs.
    CloudWatchOutputConfig -> Maybe Bool
cloudWatchOutputEnabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (CloudWatchOutputConfig -> CloudWatchOutputConfig -> Bool
(CloudWatchOutputConfig -> CloudWatchOutputConfig -> Bool)
-> (CloudWatchOutputConfig -> CloudWatchOutputConfig -> Bool)
-> Eq CloudWatchOutputConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudWatchOutputConfig -> CloudWatchOutputConfig -> Bool
$c/= :: CloudWatchOutputConfig -> CloudWatchOutputConfig -> Bool
== :: CloudWatchOutputConfig -> CloudWatchOutputConfig -> Bool
$c== :: CloudWatchOutputConfig -> CloudWatchOutputConfig -> Bool
Prelude.Eq, ReadPrec [CloudWatchOutputConfig]
ReadPrec CloudWatchOutputConfig
Int -> ReadS CloudWatchOutputConfig
ReadS [CloudWatchOutputConfig]
(Int -> ReadS CloudWatchOutputConfig)
-> ReadS [CloudWatchOutputConfig]
-> ReadPrec CloudWatchOutputConfig
-> ReadPrec [CloudWatchOutputConfig]
-> Read CloudWatchOutputConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudWatchOutputConfig]
$creadListPrec :: ReadPrec [CloudWatchOutputConfig]
readPrec :: ReadPrec CloudWatchOutputConfig
$creadPrec :: ReadPrec CloudWatchOutputConfig
readList :: ReadS [CloudWatchOutputConfig]
$creadList :: ReadS [CloudWatchOutputConfig]
readsPrec :: Int -> ReadS CloudWatchOutputConfig
$creadsPrec :: Int -> ReadS CloudWatchOutputConfig
Prelude.Read, Int -> CloudWatchOutputConfig -> ShowS
[CloudWatchOutputConfig] -> ShowS
CloudWatchOutputConfig -> String
(Int -> CloudWatchOutputConfig -> ShowS)
-> (CloudWatchOutputConfig -> String)
-> ([CloudWatchOutputConfig] -> ShowS)
-> Show CloudWatchOutputConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudWatchOutputConfig] -> ShowS
$cshowList :: [CloudWatchOutputConfig] -> ShowS
show :: CloudWatchOutputConfig -> String
$cshow :: CloudWatchOutputConfig -> String
showsPrec :: Int -> CloudWatchOutputConfig -> ShowS
$cshowsPrec :: Int -> CloudWatchOutputConfig -> ShowS
Prelude.Show, (forall x. CloudWatchOutputConfig -> Rep CloudWatchOutputConfig x)
-> (forall x.
    Rep CloudWatchOutputConfig x -> CloudWatchOutputConfig)
-> Generic CloudWatchOutputConfig
forall x. Rep CloudWatchOutputConfig x -> CloudWatchOutputConfig
forall x. CloudWatchOutputConfig -> Rep CloudWatchOutputConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CloudWatchOutputConfig x -> CloudWatchOutputConfig
$cfrom :: forall x. CloudWatchOutputConfig -> Rep CloudWatchOutputConfig x
Prelude.Generic)

-- |
-- Create a value of 'CloudWatchOutputConfig' 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:
--
-- 'cloudWatchLogGroupName', 'cloudWatchOutputConfig_cloudWatchLogGroupName' - The name of the CloudWatch Logs log group where you want to send command
-- output. If you don\'t specify a group name, Amazon Web Services Systems
-- Manager automatically creates a log group for you. The log group uses
-- the following naming format:
--
-- @aws\/ssm\/SystemsManagerDocumentName @
--
-- 'cloudWatchOutputEnabled', 'cloudWatchOutputConfig_cloudWatchOutputEnabled' - Enables Systems Manager to send command output to CloudWatch Logs.
newCloudWatchOutputConfig ::
  CloudWatchOutputConfig
newCloudWatchOutputConfig :: CloudWatchOutputConfig
newCloudWatchOutputConfig =
  CloudWatchOutputConfig' :: Maybe Text -> Maybe Bool -> CloudWatchOutputConfig
CloudWatchOutputConfig'
    { $sel:cloudWatchLogGroupName:CloudWatchOutputConfig' :: Maybe Text
cloudWatchLogGroupName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:cloudWatchOutputEnabled:CloudWatchOutputConfig' :: Maybe Bool
cloudWatchOutputEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the CloudWatch Logs log group where you want to send command
-- output. If you don\'t specify a group name, Amazon Web Services Systems
-- Manager automatically creates a log group for you. The log group uses
-- the following naming format:
--
-- @aws\/ssm\/SystemsManagerDocumentName @
cloudWatchOutputConfig_cloudWatchLogGroupName :: Lens.Lens' CloudWatchOutputConfig (Prelude.Maybe Prelude.Text)
cloudWatchOutputConfig_cloudWatchLogGroupName :: (Maybe Text -> f (Maybe Text))
-> CloudWatchOutputConfig -> f CloudWatchOutputConfig
cloudWatchOutputConfig_cloudWatchLogGroupName = (CloudWatchOutputConfig -> Maybe Text)
-> (CloudWatchOutputConfig -> Maybe Text -> CloudWatchOutputConfig)
-> Lens
     CloudWatchOutputConfig
     CloudWatchOutputConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchOutputConfig' {Maybe Text
cloudWatchLogGroupName :: Maybe Text
$sel:cloudWatchLogGroupName:CloudWatchOutputConfig' :: CloudWatchOutputConfig -> Maybe Text
cloudWatchLogGroupName} -> Maybe Text
cloudWatchLogGroupName) (\s :: CloudWatchOutputConfig
s@CloudWatchOutputConfig' {} Maybe Text
a -> CloudWatchOutputConfig
s {$sel:cloudWatchLogGroupName:CloudWatchOutputConfig' :: Maybe Text
cloudWatchLogGroupName = Maybe Text
a} :: CloudWatchOutputConfig)

-- | Enables Systems Manager to send command output to CloudWatch Logs.
cloudWatchOutputConfig_cloudWatchOutputEnabled :: Lens.Lens' CloudWatchOutputConfig (Prelude.Maybe Prelude.Bool)
cloudWatchOutputConfig_cloudWatchOutputEnabled :: (Maybe Bool -> f (Maybe Bool))
-> CloudWatchOutputConfig -> f CloudWatchOutputConfig
cloudWatchOutputConfig_cloudWatchOutputEnabled = (CloudWatchOutputConfig -> Maybe Bool)
-> (CloudWatchOutputConfig -> Maybe Bool -> CloudWatchOutputConfig)
-> Lens
     CloudWatchOutputConfig
     CloudWatchOutputConfig
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchOutputConfig' {Maybe Bool
cloudWatchOutputEnabled :: Maybe Bool
$sel:cloudWatchOutputEnabled:CloudWatchOutputConfig' :: CloudWatchOutputConfig -> Maybe Bool
cloudWatchOutputEnabled} -> Maybe Bool
cloudWatchOutputEnabled) (\s :: CloudWatchOutputConfig
s@CloudWatchOutputConfig' {} Maybe Bool
a -> CloudWatchOutputConfig
s {$sel:cloudWatchOutputEnabled:CloudWatchOutputConfig' :: Maybe Bool
cloudWatchOutputEnabled = Maybe Bool
a} :: CloudWatchOutputConfig)

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

instance Prelude.Hashable CloudWatchOutputConfig

instance Prelude.NFData CloudWatchOutputConfig

instance Core.ToJSON CloudWatchOutputConfig where
  toJSON :: CloudWatchOutputConfig -> Value
toJSON CloudWatchOutputConfig' {Maybe Bool
Maybe Text
cloudWatchOutputEnabled :: Maybe Bool
cloudWatchLogGroupName :: Maybe Text
$sel:cloudWatchOutputEnabled:CloudWatchOutputConfig' :: CloudWatchOutputConfig -> Maybe Bool
$sel:cloudWatchLogGroupName:CloudWatchOutputConfig' :: CloudWatchOutputConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CloudWatchLogGroupName" 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
cloudWatchLogGroupName,
            (Text
"CloudWatchOutputEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
cloudWatchOutputEnabled
          ]
      )