{-# 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.XRay.Types.InsightsConfiguration
-- 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.XRay.Types.InsightsConfiguration where

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

-- | The structure containing configurations related to insights.
--
-- /See:/ 'newInsightsConfiguration' smart constructor.
data InsightsConfiguration = InsightsConfiguration'
  { -- | Set the InsightsEnabled value to true to enable insights or false to
    -- disable insights.
    InsightsConfiguration -> Maybe Bool
insightsEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Set the NotificationsEnabled value to true to enable insights
    -- notifications. Notifications can only be enabled on a group with
    -- InsightsEnabled set to true.
    InsightsConfiguration -> Maybe Bool
notificationsEnabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (InsightsConfiguration -> InsightsConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InsightsConfiguration -> InsightsConfiguration -> Bool
$c/= :: InsightsConfiguration -> InsightsConfiguration -> Bool
== :: InsightsConfiguration -> InsightsConfiguration -> Bool
$c== :: InsightsConfiguration -> InsightsConfiguration -> Bool
Prelude.Eq, ReadPrec [InsightsConfiguration]
ReadPrec InsightsConfiguration
Int -> ReadS InsightsConfiguration
ReadS [InsightsConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InsightsConfiguration]
$creadListPrec :: ReadPrec [InsightsConfiguration]
readPrec :: ReadPrec InsightsConfiguration
$creadPrec :: ReadPrec InsightsConfiguration
readList :: ReadS [InsightsConfiguration]
$creadList :: ReadS [InsightsConfiguration]
readsPrec :: Int -> ReadS InsightsConfiguration
$creadsPrec :: Int -> ReadS InsightsConfiguration
Prelude.Read, Int -> InsightsConfiguration -> ShowS
[InsightsConfiguration] -> ShowS
InsightsConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InsightsConfiguration] -> ShowS
$cshowList :: [InsightsConfiguration] -> ShowS
show :: InsightsConfiguration -> String
$cshow :: InsightsConfiguration -> String
showsPrec :: Int -> InsightsConfiguration -> ShowS
$cshowsPrec :: Int -> InsightsConfiguration -> ShowS
Prelude.Show, forall x. Rep InsightsConfiguration x -> InsightsConfiguration
forall x. InsightsConfiguration -> Rep InsightsConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InsightsConfiguration x -> InsightsConfiguration
$cfrom :: forall x. InsightsConfiguration -> Rep InsightsConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'InsightsConfiguration' 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:
--
-- 'insightsEnabled', 'insightsConfiguration_insightsEnabled' - Set the InsightsEnabled value to true to enable insights or false to
-- disable insights.
--
-- 'notificationsEnabled', 'insightsConfiguration_notificationsEnabled' - Set the NotificationsEnabled value to true to enable insights
-- notifications. Notifications can only be enabled on a group with
-- InsightsEnabled set to true.
newInsightsConfiguration ::
  InsightsConfiguration
newInsightsConfiguration :: InsightsConfiguration
newInsightsConfiguration =
  InsightsConfiguration'
    { $sel:insightsEnabled:InsightsConfiguration' :: Maybe Bool
insightsEnabled =
        forall a. Maybe a
Prelude.Nothing,
      $sel:notificationsEnabled:InsightsConfiguration' :: Maybe Bool
notificationsEnabled = forall a. Maybe a
Prelude.Nothing
    }

-- | Set the InsightsEnabled value to true to enable insights or false to
-- disable insights.
insightsConfiguration_insightsEnabled :: Lens.Lens' InsightsConfiguration (Prelude.Maybe Prelude.Bool)
insightsConfiguration_insightsEnabled :: Lens' InsightsConfiguration (Maybe Bool)
insightsConfiguration_insightsEnabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightsConfiguration' {Maybe Bool
insightsEnabled :: Maybe Bool
$sel:insightsEnabled:InsightsConfiguration' :: InsightsConfiguration -> Maybe Bool
insightsEnabled} -> Maybe Bool
insightsEnabled) (\s :: InsightsConfiguration
s@InsightsConfiguration' {} Maybe Bool
a -> InsightsConfiguration
s {$sel:insightsEnabled:InsightsConfiguration' :: Maybe Bool
insightsEnabled = Maybe Bool
a} :: InsightsConfiguration)

-- | Set the NotificationsEnabled value to true to enable insights
-- notifications. Notifications can only be enabled on a group with
-- InsightsEnabled set to true.
insightsConfiguration_notificationsEnabled :: Lens.Lens' InsightsConfiguration (Prelude.Maybe Prelude.Bool)
insightsConfiguration_notificationsEnabled :: Lens' InsightsConfiguration (Maybe Bool)
insightsConfiguration_notificationsEnabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightsConfiguration' {Maybe Bool
notificationsEnabled :: Maybe Bool
$sel:notificationsEnabled:InsightsConfiguration' :: InsightsConfiguration -> Maybe Bool
notificationsEnabled} -> Maybe Bool
notificationsEnabled) (\s :: InsightsConfiguration
s@InsightsConfiguration' {} Maybe Bool
a -> InsightsConfiguration
s {$sel:notificationsEnabled:InsightsConfiguration' :: Maybe Bool
notificationsEnabled = Maybe Bool
a} :: InsightsConfiguration)

instance Data.FromJSON InsightsConfiguration where
  parseJSON :: Value -> Parser InsightsConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InsightsConfiguration"
      ( \Object
x ->
          Maybe Bool -> Maybe Bool -> InsightsConfiguration
InsightsConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"InsightsEnabled")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NotificationsEnabled")
      )

instance Prelude.Hashable InsightsConfiguration where
  hashWithSalt :: Int -> InsightsConfiguration -> Int
hashWithSalt Int
_salt InsightsConfiguration' {Maybe Bool
notificationsEnabled :: Maybe Bool
insightsEnabled :: Maybe Bool
$sel:notificationsEnabled:InsightsConfiguration' :: InsightsConfiguration -> Maybe Bool
$sel:insightsEnabled:InsightsConfiguration' :: InsightsConfiguration -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
insightsEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
notificationsEnabled

instance Prelude.NFData InsightsConfiguration where
  rnf :: InsightsConfiguration -> ()
rnf InsightsConfiguration' {Maybe Bool
notificationsEnabled :: Maybe Bool
insightsEnabled :: Maybe Bool
$sel:notificationsEnabled:InsightsConfiguration' :: InsightsConfiguration -> Maybe Bool
$sel:insightsEnabled:InsightsConfiguration' :: InsightsConfiguration -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
insightsEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
notificationsEnabled

instance Data.ToJSON InsightsConfiguration where
  toJSON :: InsightsConfiguration -> Value
toJSON InsightsConfiguration' {Maybe Bool
notificationsEnabled :: Maybe Bool
insightsEnabled :: Maybe Bool
$sel:notificationsEnabled:InsightsConfiguration' :: InsightsConfiguration -> Maybe Bool
$sel:insightsEnabled:InsightsConfiguration' :: InsightsConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"InsightsEnabled" 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 Bool
insightsEnabled,
            (Key
"NotificationsEnabled" 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 Bool
notificationsEnabled
          ]
      )