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

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

-- | Contains logging configuration information for an extension.
--
-- /See:/ 'newLoggingConfig' smart constructor.
data LoggingConfig = LoggingConfig'
  { -- | The ARN of the role that CloudFormation should assume when sending log
    -- entries to CloudWatch logs.
    LoggingConfig -> Text
logRoleArn :: Prelude.Text,
    -- | The Amazon CloudWatch log group to which CloudFormation sends error
    -- logging information when invoking the extension\'s handlers.
    LoggingConfig -> Text
logGroupName :: Prelude.Text
  }
  deriving (LoggingConfig -> LoggingConfig -> Bool
(LoggingConfig -> LoggingConfig -> Bool)
-> (LoggingConfig -> LoggingConfig -> Bool) -> Eq LoggingConfig
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]
(Int -> ReadS LoggingConfig)
-> ReadS [LoggingConfig]
-> ReadPrec LoggingConfig
-> ReadPrec [LoggingConfig]
-> Read 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
(Int -> LoggingConfig -> ShowS)
-> (LoggingConfig -> String)
-> ([LoggingConfig] -> ShowS)
-> Show LoggingConfig
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. LoggingConfig -> Rep LoggingConfig x)
-> (forall x. Rep LoggingConfig x -> LoggingConfig)
-> Generic LoggingConfig
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 ARN of the role that CloudFormation should assume when sending log
-- entries to CloudWatch logs.
--
-- 'logGroupName', 'loggingConfig_logGroupName' - The Amazon CloudWatch log 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' :: Text -> Text -> LoggingConfig
LoggingConfig'
    { $sel:logRoleArn:LoggingConfig' :: Text
logRoleArn = Text
pLogRoleArn_,
      $sel:logGroupName:LoggingConfig' :: Text
logGroupName = Text
pLogGroupName_
    }

-- | The ARN of the role that CloudFormation should assume when sending log
-- entries to CloudWatch logs.
loggingConfig_logRoleArn :: Lens.Lens' LoggingConfig Prelude.Text
loggingConfig_logRoleArn :: (Text -> f Text) -> LoggingConfig -> f LoggingConfig
loggingConfig_logRoleArn = (LoggingConfig -> Text)
-> (LoggingConfig -> Text -> LoggingConfig)
-> Lens LoggingConfig LoggingConfig Text Text
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 log group to which CloudFormation sends error
-- logging information when invoking the extension\'s handlers.
loggingConfig_logGroupName :: Lens.Lens' LoggingConfig Prelude.Text
loggingConfig_logGroupName :: (Text -> f Text) -> LoggingConfig -> f LoggingConfig
loggingConfig_logGroupName = (LoggingConfig -> Text)
-> (LoggingConfig -> Text -> LoggingConfig)
-> Lens LoggingConfig LoggingConfig Text Text
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 Core.FromXML LoggingConfig where
  parseXML :: [Node] -> Either String LoggingConfig
parseXML [Node]
x =
    Text -> Text -> LoggingConfig
LoggingConfig'
      (Text -> Text -> LoggingConfig)
-> Either String Text -> Either String (Text -> LoggingConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"LogRoleArn")
      Either String (Text -> LoggingConfig)
-> Either String Text -> Either String LoggingConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"LogGroupName")

instance Prelude.Hashable LoggingConfig

instance Prelude.NFData LoggingConfig

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