{-# 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.Lambda.Types.TracingConfig
-- 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.Lambda.Types.TracingConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lambda.Types.TracingMode
import qualified Amazonka.Prelude as Prelude

-- | The function\'s
-- <https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html X-Ray>
-- tracing configuration. To sample and record incoming requests, set
-- @Mode@ to @Active@.
--
-- /See:/ 'newTracingConfig' smart constructor.
data TracingConfig = TracingConfig'
  { -- | The tracing mode.
    TracingConfig -> Maybe TracingMode
mode :: Prelude.Maybe TracingMode
  }
  deriving (TracingConfig -> TracingConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TracingConfig -> TracingConfig -> Bool
$c/= :: TracingConfig -> TracingConfig -> Bool
== :: TracingConfig -> TracingConfig -> Bool
$c== :: TracingConfig -> TracingConfig -> Bool
Prelude.Eq, ReadPrec [TracingConfig]
ReadPrec TracingConfig
Int -> ReadS TracingConfig
ReadS [TracingConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TracingConfig]
$creadListPrec :: ReadPrec [TracingConfig]
readPrec :: ReadPrec TracingConfig
$creadPrec :: ReadPrec TracingConfig
readList :: ReadS [TracingConfig]
$creadList :: ReadS [TracingConfig]
readsPrec :: Int -> ReadS TracingConfig
$creadsPrec :: Int -> ReadS TracingConfig
Prelude.Read, Int -> TracingConfig -> ShowS
[TracingConfig] -> ShowS
TracingConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TracingConfig] -> ShowS
$cshowList :: [TracingConfig] -> ShowS
show :: TracingConfig -> String
$cshow :: TracingConfig -> String
showsPrec :: Int -> TracingConfig -> ShowS
$cshowsPrec :: Int -> TracingConfig -> ShowS
Prelude.Show, forall x. Rep TracingConfig x -> TracingConfig
forall x. TracingConfig -> Rep TracingConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TracingConfig x -> TracingConfig
$cfrom :: forall x. TracingConfig -> Rep TracingConfig x
Prelude.Generic)

-- |
-- Create a value of 'TracingConfig' 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:
--
-- 'mode', 'tracingConfig_mode' - The tracing mode.
newTracingConfig ::
  TracingConfig
newTracingConfig :: TracingConfig
newTracingConfig =
  TracingConfig' {$sel:mode:TracingConfig' :: Maybe TracingMode
mode = forall a. Maybe a
Prelude.Nothing}

-- | The tracing mode.
tracingConfig_mode :: Lens.Lens' TracingConfig (Prelude.Maybe TracingMode)
tracingConfig_mode :: Lens' TracingConfig (Maybe TracingMode)
tracingConfig_mode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TracingConfig' {Maybe TracingMode
mode :: Maybe TracingMode
$sel:mode:TracingConfig' :: TracingConfig -> Maybe TracingMode
mode} -> Maybe TracingMode
mode) (\s :: TracingConfig
s@TracingConfig' {} Maybe TracingMode
a -> TracingConfig
s {$sel:mode:TracingConfig' :: Maybe TracingMode
mode = Maybe TracingMode
a} :: TracingConfig)

instance Prelude.Hashable TracingConfig where
  hashWithSalt :: Int -> TracingConfig -> Int
hashWithSalt Int
_salt TracingConfig' {Maybe TracingMode
mode :: Maybe TracingMode
$sel:mode:TracingConfig' :: TracingConfig -> Maybe TracingMode
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TracingMode
mode

instance Prelude.NFData TracingConfig where
  rnf :: TracingConfig -> ()
rnf TracingConfig' {Maybe TracingMode
mode :: Maybe TracingMode
$sel:mode:TracingConfig' :: TracingConfig -> Maybe TracingMode
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe TracingMode
mode

instance Data.ToJSON TracingConfig where
  toJSON :: TracingConfig -> Value
toJSON TracingConfig' {Maybe TracingMode
mode :: Maybe TracingMode
$sel:mode:TracingConfig' :: TracingConfig -> Maybe TracingMode
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Mode" 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 TracingMode
mode]
      )