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

import qualified Amazonka.Core as Core
import Amazonka.Lambda.Types.TracingMode
import qualified Amazonka.Lens as Lens
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
(TracingConfig -> TracingConfig -> Bool)
-> (TracingConfig -> TracingConfig -> Bool) -> Eq TracingConfig
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]
(Int -> ReadS TracingConfig)
-> ReadS [TracingConfig]
-> ReadPrec TracingConfig
-> ReadPrec [TracingConfig]
-> Read 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
(Int -> TracingConfig -> ShowS)
-> (TracingConfig -> String)
-> ([TracingConfig] -> ShowS)
-> Show TracingConfig
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. TracingConfig -> Rep TracingConfig x)
-> (forall x. Rep TracingConfig x -> TracingConfig)
-> Generic TracingConfig
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' :: Maybe TracingMode -> TracingConfig
TracingConfig' {$sel:mode:TracingConfig' :: Maybe TracingMode
mode = Maybe TracingMode
forall a. Maybe a
Prelude.Nothing}

-- | The tracing mode.
tracingConfig_mode :: Lens.Lens' TracingConfig (Prelude.Maybe TracingMode)
tracingConfig_mode :: (Maybe TracingMode -> f (Maybe TracingMode))
-> TracingConfig -> f TracingConfig
tracingConfig_mode = (TracingConfig -> Maybe TracingMode)
-> (TracingConfig -> Maybe TracingMode -> TracingConfig)
-> Lens
     TracingConfig TracingConfig (Maybe TracingMode) (Maybe TracingMode)
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

instance Prelude.NFData TracingConfig

instance Core.ToJSON TracingConfig where
  toJSON :: TracingConfig -> Value
toJSON TracingConfig' {Maybe TracingMode
mode :: Maybe TracingMode
$sel:mode:TracingConfig' :: TracingConfig -> Maybe TracingMode
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Mode" Text -> TracingMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TracingMode -> Pair) -> Maybe TracingMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TracingMode
mode]
      )