{-# 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.Chime.Types.LoggingConfiguration
-- 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.Chime.Types.LoggingConfiguration where

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

-- | The logging configuration associated with an Amazon Chime Voice
-- Connector. Specifies whether SIP message logs are enabled for sending to
-- Amazon CloudWatch Logs.
--
-- /See:/ 'newLoggingConfiguration' smart constructor.
data LoggingConfiguration = LoggingConfiguration'
  { -- | When true, enables SIP message logs for sending to Amazon CloudWatch
    -- Logs.
    LoggingConfiguration -> Maybe Bool
enableSIPLogs :: Prelude.Maybe Prelude.Bool
  }
  deriving (LoggingConfiguration -> LoggingConfiguration -> Bool
(LoggingConfiguration -> LoggingConfiguration -> Bool)
-> (LoggingConfiguration -> LoggingConfiguration -> Bool)
-> Eq LoggingConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoggingConfiguration -> LoggingConfiguration -> Bool
$c/= :: LoggingConfiguration -> LoggingConfiguration -> Bool
== :: LoggingConfiguration -> LoggingConfiguration -> Bool
$c== :: LoggingConfiguration -> LoggingConfiguration -> Bool
Prelude.Eq, ReadPrec [LoggingConfiguration]
ReadPrec LoggingConfiguration
Int -> ReadS LoggingConfiguration
ReadS [LoggingConfiguration]
(Int -> ReadS LoggingConfiguration)
-> ReadS [LoggingConfiguration]
-> ReadPrec LoggingConfiguration
-> ReadPrec [LoggingConfiguration]
-> Read LoggingConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoggingConfiguration]
$creadListPrec :: ReadPrec [LoggingConfiguration]
readPrec :: ReadPrec LoggingConfiguration
$creadPrec :: ReadPrec LoggingConfiguration
readList :: ReadS [LoggingConfiguration]
$creadList :: ReadS [LoggingConfiguration]
readsPrec :: Int -> ReadS LoggingConfiguration
$creadsPrec :: Int -> ReadS LoggingConfiguration
Prelude.Read, Int -> LoggingConfiguration -> ShowS
[LoggingConfiguration] -> ShowS
LoggingConfiguration -> String
(Int -> LoggingConfiguration -> ShowS)
-> (LoggingConfiguration -> String)
-> ([LoggingConfiguration] -> ShowS)
-> Show LoggingConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoggingConfiguration] -> ShowS
$cshowList :: [LoggingConfiguration] -> ShowS
show :: LoggingConfiguration -> String
$cshow :: LoggingConfiguration -> String
showsPrec :: Int -> LoggingConfiguration -> ShowS
$cshowsPrec :: Int -> LoggingConfiguration -> ShowS
Prelude.Show, (forall x. LoggingConfiguration -> Rep LoggingConfiguration x)
-> (forall x. Rep LoggingConfiguration x -> LoggingConfiguration)
-> Generic LoggingConfiguration
forall x. Rep LoggingConfiguration x -> LoggingConfiguration
forall x. LoggingConfiguration -> Rep LoggingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoggingConfiguration x -> LoggingConfiguration
$cfrom :: forall x. LoggingConfiguration -> Rep LoggingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'LoggingConfiguration' 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:
--
-- 'enableSIPLogs', 'loggingConfiguration_enableSIPLogs' - When true, enables SIP message logs for sending to Amazon CloudWatch
-- Logs.
newLoggingConfiguration ::
  LoggingConfiguration
newLoggingConfiguration :: LoggingConfiguration
newLoggingConfiguration =
  LoggingConfiguration' :: Maybe Bool -> LoggingConfiguration
LoggingConfiguration'
    { $sel:enableSIPLogs:LoggingConfiguration' :: Maybe Bool
enableSIPLogs =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | When true, enables SIP message logs for sending to Amazon CloudWatch
-- Logs.
loggingConfiguration_enableSIPLogs :: Lens.Lens' LoggingConfiguration (Prelude.Maybe Prelude.Bool)
loggingConfiguration_enableSIPLogs :: (Maybe Bool -> f (Maybe Bool))
-> LoggingConfiguration -> f LoggingConfiguration
loggingConfiguration_enableSIPLogs = (LoggingConfiguration -> Maybe Bool)
-> (LoggingConfiguration -> Maybe Bool -> LoggingConfiguration)
-> Lens
     LoggingConfiguration LoggingConfiguration (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingConfiguration' {Maybe Bool
enableSIPLogs :: Maybe Bool
$sel:enableSIPLogs:LoggingConfiguration' :: LoggingConfiguration -> Maybe Bool
enableSIPLogs} -> Maybe Bool
enableSIPLogs) (\s :: LoggingConfiguration
s@LoggingConfiguration' {} Maybe Bool
a -> LoggingConfiguration
s {$sel:enableSIPLogs:LoggingConfiguration' :: Maybe Bool
enableSIPLogs = Maybe Bool
a} :: LoggingConfiguration)

instance Core.FromJSON LoggingConfiguration where
  parseJSON :: Value -> Parser LoggingConfiguration
parseJSON =
    String
-> (Object -> Parser LoggingConfiguration)
-> Value
-> Parser LoggingConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LoggingConfiguration"
      ( \Object
x ->
          Maybe Bool -> LoggingConfiguration
LoggingConfiguration'
            (Maybe Bool -> LoggingConfiguration)
-> Parser (Maybe Bool) -> Parser LoggingConfiguration
forall (f :: * -> *) a b. Functor 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
"EnableSIPLogs")
      )

instance Prelude.Hashable LoggingConfiguration

instance Prelude.NFData LoggingConfiguration

instance Core.ToJSON LoggingConfiguration where
  toJSON :: LoggingConfiguration -> Value
toJSON LoggingConfiguration' {Maybe Bool
enableSIPLogs :: Maybe Bool
$sel:enableSIPLogs:LoggingConfiguration' :: LoggingConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EnableSIPLogs" 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
enableSIPLogs
          ]
      )