{-# 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.CloudFormation.Types.LoggingConfig
-- 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.CloudFormation.Types.LoggingConfig 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

-- | Contains logging configuration information for an extension.
--
-- /See:/ 'newLoggingConfig' smart constructor.
data LoggingConfig = LoggingConfig'
  { -- | The Amazon Resource Name (ARN) of the role that CloudFormation should
    -- assume when sending log entries to CloudWatch Logs.
    LoggingConfig -> Text
logRoleArn :: Prelude.Text,
    -- | The Amazon CloudWatch Logs group to which CloudFormation sends error
    -- logging information when invoking the extension\'s handlers.
    LoggingConfig -> Text
logGroupName :: Prelude.Text
  }
  deriving (LoggingConfig -> LoggingConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoggingConfig -> LoggingConfig -> Bool
$c/= :: LoggingConfig -> LoggingConfig -> Bool
== :: LoggingConfig -> LoggingConfig -> Bool
$c== :: LoggingConfig -> LoggingConfig -> Bool
Prelude.Eq, ReadPrec [LoggingConfig]
ReadPrec LoggingConfig
Int -> ReadS LoggingConfig
ReadS [LoggingConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoggingConfig]
$creadListPrec :: ReadPrec [LoggingConfig]
readPrec :: ReadPrec LoggingConfig
$creadPrec :: ReadPrec LoggingConfig
readList :: ReadS [LoggingConfig]
$creadList :: ReadS [LoggingConfig]
readsPrec :: Int -> ReadS LoggingConfig
$creadsPrec :: Int -> ReadS LoggingConfig
Prelude.Read, Int -> LoggingConfig -> ShowS
[LoggingConfig] -> ShowS
LoggingConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoggingConfig] -> ShowS
$cshowList :: [LoggingConfig] -> ShowS
show :: LoggingConfig -> String
$cshow :: LoggingConfig -> String
showsPrec :: Int -> LoggingConfig -> ShowS
$cshowsPrec :: Int -> LoggingConfig -> ShowS
Prelude.Show, forall x. Rep LoggingConfig x -> LoggingConfig
forall x. LoggingConfig -> Rep LoggingConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoggingConfig x -> LoggingConfig
$cfrom :: forall x. LoggingConfig -> Rep LoggingConfig x
Prelude.Generic)

-- |
-- Create a value of 'LoggingConfig' 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:
--
-- 'logRoleArn', 'loggingConfig_logRoleArn' - The Amazon Resource Name (ARN) of the role that CloudFormation should
-- assume when sending log entries to CloudWatch Logs.
--
-- 'logGroupName', 'loggingConfig_logGroupName' - The Amazon CloudWatch Logs group to which CloudFormation sends error
-- logging information when invoking the extension\'s handlers.
newLoggingConfig ::
  -- | 'logRoleArn'
  Prelude.Text ->
  -- | 'logGroupName'
  Prelude.Text ->
  LoggingConfig
newLoggingConfig :: Text -> Text -> LoggingConfig
newLoggingConfig Text
pLogRoleArn_ Text
pLogGroupName_ =
  LoggingConfig'
    { $sel:logRoleArn:LoggingConfig' :: Text
logRoleArn = Text
pLogRoleArn_,
      $sel:logGroupName:LoggingConfig' :: Text
logGroupName = Text
pLogGroupName_
    }

-- | The Amazon Resource Name (ARN) of the role that CloudFormation should
-- assume when sending log entries to CloudWatch Logs.
loggingConfig_logRoleArn :: Lens.Lens' LoggingConfig Prelude.Text
loggingConfig_logRoleArn :: Lens' LoggingConfig Text
loggingConfig_logRoleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingConfig' {Text
logRoleArn :: Text
$sel:logRoleArn:LoggingConfig' :: LoggingConfig -> Text
logRoleArn} -> Text
logRoleArn) (\s :: LoggingConfig
s@LoggingConfig' {} Text
a -> LoggingConfig
s {$sel:logRoleArn:LoggingConfig' :: Text
logRoleArn = Text
a} :: LoggingConfig)

-- | The Amazon CloudWatch Logs group to which CloudFormation sends error
-- logging information when invoking the extension\'s handlers.
loggingConfig_logGroupName :: Lens.Lens' LoggingConfig Prelude.Text
loggingConfig_logGroupName :: Lens' LoggingConfig Text
loggingConfig_logGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingConfig' {Text
logGroupName :: Text
$sel:logGroupName:LoggingConfig' :: LoggingConfig -> Text
logGroupName} -> Text
logGroupName) (\s :: LoggingConfig
s@LoggingConfig' {} Text
a -> LoggingConfig
s {$sel:logGroupName:LoggingConfig' :: Text
logGroupName = Text
a} :: LoggingConfig)

instance Data.FromXML LoggingConfig where
  parseXML :: [Node] -> Either String LoggingConfig
parseXML [Node]
x =
    Text -> Text -> LoggingConfig
LoggingConfig'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"LogRoleArn")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"LogGroupName")

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

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

instance Data.ToQuery LoggingConfig where
  toQuery :: LoggingConfig -> QueryString
toQuery LoggingConfig' {Text
logGroupName :: Text
logRoleArn :: Text
$sel:logGroupName:LoggingConfig' :: LoggingConfig -> Text
$sel:logRoleArn:LoggingConfig' :: LoggingConfig -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"LogRoleArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
logRoleArn,
        ByteString
"LogGroupName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
logGroupName
      ]