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

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

-- | The structure containing configurations related to insights.
--
-- /See:/ 'newInsightsConfiguration' smart constructor.
data InsightsConfiguration = 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 -> Maybe Bool
notificationsEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Set the InsightsEnabled value to true to enable insights or false to
    -- disable insights.
    InsightsConfiguration -> Maybe Bool
insightsEnabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (InsightsConfiguration -> InsightsConfiguration -> Bool
(InsightsConfiguration -> InsightsConfiguration -> Bool)
-> (InsightsConfiguration -> InsightsConfiguration -> Bool)
-> Eq InsightsConfiguration
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]
(Int -> ReadS InsightsConfiguration)
-> ReadS [InsightsConfiguration]
-> ReadPrec InsightsConfiguration
-> ReadPrec [InsightsConfiguration]
-> Read 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
(Int -> InsightsConfiguration -> ShowS)
-> (InsightsConfiguration -> String)
-> ([InsightsConfiguration] -> ShowS)
-> Show InsightsConfiguration
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. InsightsConfiguration -> Rep InsightsConfiguration x)
-> (forall x. Rep InsightsConfiguration x -> InsightsConfiguration)
-> Generic InsightsConfiguration
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:
--
-- '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.
--
-- 'insightsEnabled', 'insightsConfiguration_insightsEnabled' - Set the InsightsEnabled value to true to enable insights or false to
-- disable insights.
newInsightsConfiguration ::
  InsightsConfiguration
newInsightsConfiguration :: InsightsConfiguration
newInsightsConfiguration =
  InsightsConfiguration' :: Maybe Bool -> Maybe Bool -> InsightsConfiguration
InsightsConfiguration'
    { $sel:notificationsEnabled:InsightsConfiguration' :: Maybe Bool
notificationsEnabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:insightsEnabled:InsightsConfiguration' :: Maybe Bool
insightsEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Bool -> f (Maybe Bool))
-> InsightsConfiguration -> f InsightsConfiguration
insightsConfiguration_notificationsEnabled = (InsightsConfiguration -> Maybe Bool)
-> (InsightsConfiguration -> Maybe Bool -> InsightsConfiguration)
-> Lens
     InsightsConfiguration
     InsightsConfiguration
     (Maybe Bool)
     (Maybe Bool)
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)

-- | 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 :: (Maybe Bool -> f (Maybe Bool))
-> InsightsConfiguration -> f InsightsConfiguration
insightsConfiguration_insightsEnabled = (InsightsConfiguration -> Maybe Bool)
-> (InsightsConfiguration -> Maybe Bool -> InsightsConfiguration)
-> Lens
     InsightsConfiguration
     InsightsConfiguration
     (Maybe Bool)
     (Maybe Bool)
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)

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

instance Prelude.Hashable InsightsConfiguration

instance Prelude.NFData InsightsConfiguration

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