{-# 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.StepFunctions.Types.TracingConfiguration
-- 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.StepFunctions.Types.TracingConfiguration where

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

-- | Selects whether or not the state machine\'s AWS X-Ray tracing is
-- enabled. Default is @false@
--
-- /See:/ 'newTracingConfiguration' smart constructor.
data TracingConfiguration = TracingConfiguration'
  { -- | When set to @true@, AWS X-Ray tracing is enabled.
    TracingConfiguration -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (TracingConfiguration -> TracingConfiguration -> Bool
(TracingConfiguration -> TracingConfiguration -> Bool)
-> (TracingConfiguration -> TracingConfiguration -> Bool)
-> Eq TracingConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TracingConfiguration -> TracingConfiguration -> Bool
$c/= :: TracingConfiguration -> TracingConfiguration -> Bool
== :: TracingConfiguration -> TracingConfiguration -> Bool
$c== :: TracingConfiguration -> TracingConfiguration -> Bool
Prelude.Eq, ReadPrec [TracingConfiguration]
ReadPrec TracingConfiguration
Int -> ReadS TracingConfiguration
ReadS [TracingConfiguration]
(Int -> ReadS TracingConfiguration)
-> ReadS [TracingConfiguration]
-> ReadPrec TracingConfiguration
-> ReadPrec [TracingConfiguration]
-> Read TracingConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TracingConfiguration]
$creadListPrec :: ReadPrec [TracingConfiguration]
readPrec :: ReadPrec TracingConfiguration
$creadPrec :: ReadPrec TracingConfiguration
readList :: ReadS [TracingConfiguration]
$creadList :: ReadS [TracingConfiguration]
readsPrec :: Int -> ReadS TracingConfiguration
$creadsPrec :: Int -> ReadS TracingConfiguration
Prelude.Read, Int -> TracingConfiguration -> ShowS
[TracingConfiguration] -> ShowS
TracingConfiguration -> String
(Int -> TracingConfiguration -> ShowS)
-> (TracingConfiguration -> String)
-> ([TracingConfiguration] -> ShowS)
-> Show TracingConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TracingConfiguration] -> ShowS
$cshowList :: [TracingConfiguration] -> ShowS
show :: TracingConfiguration -> String
$cshow :: TracingConfiguration -> String
showsPrec :: Int -> TracingConfiguration -> ShowS
$cshowsPrec :: Int -> TracingConfiguration -> ShowS
Prelude.Show, (forall x. TracingConfiguration -> Rep TracingConfiguration x)
-> (forall x. Rep TracingConfiguration x -> TracingConfiguration)
-> Generic TracingConfiguration
forall x. Rep TracingConfiguration x -> TracingConfiguration
forall x. TracingConfiguration -> Rep TracingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TracingConfiguration x -> TracingConfiguration
$cfrom :: forall x. TracingConfiguration -> Rep TracingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'TracingConfiguration' 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:
--
-- 'enabled', 'tracingConfiguration_enabled' - When set to @true@, AWS X-Ray tracing is enabled.
newTracingConfiguration ::
  TracingConfiguration
newTracingConfiguration :: TracingConfiguration
newTracingConfiguration =
  TracingConfiguration' :: Maybe Bool -> TracingConfiguration
TracingConfiguration' {$sel:enabled:TracingConfiguration' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing}

-- | When set to @true@, AWS X-Ray tracing is enabled.
tracingConfiguration_enabled :: Lens.Lens' TracingConfiguration (Prelude.Maybe Prelude.Bool)
tracingConfiguration_enabled :: (Maybe Bool -> f (Maybe Bool))
-> TracingConfiguration -> f TracingConfiguration
tracingConfiguration_enabled = (TracingConfiguration -> Maybe Bool)
-> (TracingConfiguration -> Maybe Bool -> TracingConfiguration)
-> Lens
     TracingConfiguration TracingConfiguration (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TracingConfiguration' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:TracingConfiguration' :: TracingConfiguration -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: TracingConfiguration
s@TracingConfiguration' {} Maybe Bool
a -> TracingConfiguration
s {$sel:enabled:TracingConfiguration' :: Maybe Bool
enabled = Maybe Bool
a} :: TracingConfiguration)

instance Core.FromJSON TracingConfiguration where
  parseJSON :: Value -> Parser TracingConfiguration
parseJSON =
    String
-> (Object -> Parser TracingConfiguration)
-> Value
-> Parser TracingConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TracingConfiguration"
      ( \Object
x ->
          Maybe Bool -> TracingConfiguration
TracingConfiguration'
            (Maybe Bool -> TracingConfiguration)
-> Parser (Maybe Bool) -> Parser TracingConfiguration
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
"enabled")
      )

instance Prelude.Hashable TracingConfiguration

instance Prelude.NFData TracingConfiguration

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