{-# 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.QuickSight.Types.InsightConfiguration
-- 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.QuickSight.Types.InsightConfiguration 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
import Amazonka.QuickSight.Types.Computation
import Amazonka.QuickSight.Types.CustomNarrativeOptions

-- | The configuration of an insight visual.
--
-- /See:/ 'newInsightConfiguration' smart constructor.
data InsightConfiguration = InsightConfiguration'
  { -- | The computations configurations of the insight visual
    InsightConfiguration -> Maybe [Computation]
computations :: Prelude.Maybe [Computation],
    -- | The custom narrative of the insight visual.
    InsightConfiguration -> Maybe CustomNarrativeOptions
customNarrative :: Prelude.Maybe CustomNarrativeOptions
  }
  deriving (InsightConfiguration -> InsightConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InsightConfiguration -> InsightConfiguration -> Bool
$c/= :: InsightConfiguration -> InsightConfiguration -> Bool
== :: InsightConfiguration -> InsightConfiguration -> Bool
$c== :: InsightConfiguration -> InsightConfiguration -> Bool
Prelude.Eq, Int -> InsightConfiguration -> ShowS
[InsightConfiguration] -> ShowS
InsightConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InsightConfiguration] -> ShowS
$cshowList :: [InsightConfiguration] -> ShowS
show :: InsightConfiguration -> String
$cshow :: InsightConfiguration -> String
showsPrec :: Int -> InsightConfiguration -> ShowS
$cshowsPrec :: Int -> InsightConfiguration -> ShowS
Prelude.Show, forall x. Rep InsightConfiguration x -> InsightConfiguration
forall x. InsightConfiguration -> Rep InsightConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InsightConfiguration x -> InsightConfiguration
$cfrom :: forall x. InsightConfiguration -> Rep InsightConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'InsightConfiguration' 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:
--
-- 'computations', 'insightConfiguration_computations' - The computations configurations of the insight visual
--
-- 'customNarrative', 'insightConfiguration_customNarrative' - The custom narrative of the insight visual.
newInsightConfiguration ::
  InsightConfiguration
newInsightConfiguration :: InsightConfiguration
newInsightConfiguration =
  InsightConfiguration'
    { $sel:computations:InsightConfiguration' :: Maybe [Computation]
computations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:customNarrative:InsightConfiguration' :: Maybe CustomNarrativeOptions
customNarrative = forall a. Maybe a
Prelude.Nothing
    }

-- | The computations configurations of the insight visual
insightConfiguration_computations :: Lens.Lens' InsightConfiguration (Prelude.Maybe [Computation])
insightConfiguration_computations :: Lens' InsightConfiguration (Maybe [Computation])
insightConfiguration_computations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightConfiguration' {Maybe [Computation]
computations :: Maybe [Computation]
$sel:computations:InsightConfiguration' :: InsightConfiguration -> Maybe [Computation]
computations} -> Maybe [Computation]
computations) (\s :: InsightConfiguration
s@InsightConfiguration' {} Maybe [Computation]
a -> InsightConfiguration
s {$sel:computations:InsightConfiguration' :: Maybe [Computation]
computations = Maybe [Computation]
a} :: InsightConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The custom narrative of the insight visual.
insightConfiguration_customNarrative :: Lens.Lens' InsightConfiguration (Prelude.Maybe CustomNarrativeOptions)
insightConfiguration_customNarrative :: Lens' InsightConfiguration (Maybe CustomNarrativeOptions)
insightConfiguration_customNarrative = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightConfiguration' {Maybe CustomNarrativeOptions
customNarrative :: Maybe CustomNarrativeOptions
$sel:customNarrative:InsightConfiguration' :: InsightConfiguration -> Maybe CustomNarrativeOptions
customNarrative} -> Maybe CustomNarrativeOptions
customNarrative) (\s :: InsightConfiguration
s@InsightConfiguration' {} Maybe CustomNarrativeOptions
a -> InsightConfiguration
s {$sel:customNarrative:InsightConfiguration' :: Maybe CustomNarrativeOptions
customNarrative = Maybe CustomNarrativeOptions
a} :: InsightConfiguration)

instance Data.FromJSON InsightConfiguration where
  parseJSON :: Value -> Parser InsightConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InsightConfiguration"
      ( \Object
x ->
          Maybe [Computation]
-> Maybe CustomNarrativeOptions -> InsightConfiguration
InsightConfiguration'
            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
"Computations" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"CustomNarrative")
      )

instance Prelude.Hashable InsightConfiguration where
  hashWithSalt :: Int -> InsightConfiguration -> Int
hashWithSalt Int
_salt InsightConfiguration' {Maybe [Computation]
Maybe CustomNarrativeOptions
customNarrative :: Maybe CustomNarrativeOptions
computations :: Maybe [Computation]
$sel:customNarrative:InsightConfiguration' :: InsightConfiguration -> Maybe CustomNarrativeOptions
$sel:computations:InsightConfiguration' :: InsightConfiguration -> Maybe [Computation]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Computation]
computations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CustomNarrativeOptions
customNarrative

instance Prelude.NFData InsightConfiguration where
  rnf :: InsightConfiguration -> ()
rnf InsightConfiguration' {Maybe [Computation]
Maybe CustomNarrativeOptions
customNarrative :: Maybe CustomNarrativeOptions
computations :: Maybe [Computation]
$sel:customNarrative:InsightConfiguration' :: InsightConfiguration -> Maybe CustomNarrativeOptions
$sel:computations:InsightConfiguration' :: InsightConfiguration -> Maybe [Computation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Computation]
computations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CustomNarrativeOptions
customNarrative

instance Data.ToJSON InsightConfiguration where
  toJSON :: InsightConfiguration -> Value
toJSON InsightConfiguration' {Maybe [Computation]
Maybe CustomNarrativeOptions
customNarrative :: Maybe CustomNarrativeOptions
computations :: Maybe [Computation]
$sel:customNarrative:InsightConfiguration' :: InsightConfiguration -> Maybe CustomNarrativeOptions
$sel:computations:InsightConfiguration' :: InsightConfiguration -> Maybe [Computation]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Computations" 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 [Computation]
computations,
            (Key
"CustomNarrative" 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 CustomNarrativeOptions
customNarrative
          ]
      )