{-# 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.CustomValuesConfiguration
-- 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.CustomValuesConfiguration 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.CustomParameterValues

-- | The configuration of custom values for the destination parameter in
-- @DestinationParameterValueConfiguration@.
--
-- /See:/ 'newCustomValuesConfiguration' smart constructor.
data CustomValuesConfiguration = CustomValuesConfiguration'
  { -- | Includes the null value in custom action parameter values.
    CustomValuesConfiguration -> Maybe Bool
includeNullValue :: Prelude.Maybe Prelude.Bool,
    CustomValuesConfiguration -> CustomParameterValues
customValues :: CustomParameterValues
  }
  deriving (CustomValuesConfiguration -> CustomValuesConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomValuesConfiguration -> CustomValuesConfiguration -> Bool
$c/= :: CustomValuesConfiguration -> CustomValuesConfiguration -> Bool
== :: CustomValuesConfiguration -> CustomValuesConfiguration -> Bool
$c== :: CustomValuesConfiguration -> CustomValuesConfiguration -> Bool
Prelude.Eq, Int -> CustomValuesConfiguration -> ShowS
[CustomValuesConfiguration] -> ShowS
CustomValuesConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomValuesConfiguration] -> ShowS
$cshowList :: [CustomValuesConfiguration] -> ShowS
show :: CustomValuesConfiguration -> String
$cshow :: CustomValuesConfiguration -> String
showsPrec :: Int -> CustomValuesConfiguration -> ShowS
$cshowsPrec :: Int -> CustomValuesConfiguration -> ShowS
Prelude.Show, forall x.
Rep CustomValuesConfiguration x -> CustomValuesConfiguration
forall x.
CustomValuesConfiguration -> Rep CustomValuesConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CustomValuesConfiguration x -> CustomValuesConfiguration
$cfrom :: forall x.
CustomValuesConfiguration -> Rep CustomValuesConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'CustomValuesConfiguration' 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:
--
-- 'includeNullValue', 'customValuesConfiguration_includeNullValue' - Includes the null value in custom action parameter values.
--
-- 'customValues', 'customValuesConfiguration_customValues' - Undocumented member.
newCustomValuesConfiguration ::
  -- | 'customValues'
  CustomParameterValues ->
  CustomValuesConfiguration
newCustomValuesConfiguration :: CustomParameterValues -> CustomValuesConfiguration
newCustomValuesConfiguration CustomParameterValues
pCustomValues_ =
  CustomValuesConfiguration'
    { $sel:includeNullValue:CustomValuesConfiguration' :: Maybe Bool
includeNullValue =
        forall a. Maybe a
Prelude.Nothing,
      $sel:customValues:CustomValuesConfiguration' :: CustomParameterValues
customValues = CustomParameterValues
pCustomValues_
    }

-- | Includes the null value in custom action parameter values.
customValuesConfiguration_includeNullValue :: Lens.Lens' CustomValuesConfiguration (Prelude.Maybe Prelude.Bool)
customValuesConfiguration_includeNullValue :: Lens' CustomValuesConfiguration (Maybe Bool)
customValuesConfiguration_includeNullValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomValuesConfiguration' {Maybe Bool
includeNullValue :: Maybe Bool
$sel:includeNullValue:CustomValuesConfiguration' :: CustomValuesConfiguration -> Maybe Bool
includeNullValue} -> Maybe Bool
includeNullValue) (\s :: CustomValuesConfiguration
s@CustomValuesConfiguration' {} Maybe Bool
a -> CustomValuesConfiguration
s {$sel:includeNullValue:CustomValuesConfiguration' :: Maybe Bool
includeNullValue = Maybe Bool
a} :: CustomValuesConfiguration)

-- | Undocumented member.
customValuesConfiguration_customValues :: Lens.Lens' CustomValuesConfiguration CustomParameterValues
customValuesConfiguration_customValues :: Lens' CustomValuesConfiguration CustomParameterValues
customValuesConfiguration_customValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomValuesConfiguration' {CustomParameterValues
customValues :: CustomParameterValues
$sel:customValues:CustomValuesConfiguration' :: CustomValuesConfiguration -> CustomParameterValues
customValues} -> CustomParameterValues
customValues) (\s :: CustomValuesConfiguration
s@CustomValuesConfiguration' {} CustomParameterValues
a -> CustomValuesConfiguration
s {$sel:customValues:CustomValuesConfiguration' :: CustomParameterValues
customValues = CustomParameterValues
a} :: CustomValuesConfiguration)

instance Data.FromJSON CustomValuesConfiguration where
  parseJSON :: Value -> Parser CustomValuesConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomValuesConfiguration"
      ( \Object
x ->
          Maybe Bool -> CustomParameterValues -> CustomValuesConfiguration
CustomValuesConfiguration'
            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
"IncludeNullValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"CustomValues")
      )

instance Prelude.Hashable CustomValuesConfiguration where
  hashWithSalt :: Int -> CustomValuesConfiguration -> Int
hashWithSalt Int
_salt CustomValuesConfiguration' {Maybe Bool
CustomParameterValues
customValues :: CustomParameterValues
includeNullValue :: Maybe Bool
$sel:customValues:CustomValuesConfiguration' :: CustomValuesConfiguration -> CustomParameterValues
$sel:includeNullValue:CustomValuesConfiguration' :: CustomValuesConfiguration -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
includeNullValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CustomParameterValues
customValues

instance Prelude.NFData CustomValuesConfiguration where
  rnf :: CustomValuesConfiguration -> ()
rnf CustomValuesConfiguration' {Maybe Bool
CustomParameterValues
customValues :: CustomParameterValues
includeNullValue :: Maybe Bool
$sel:customValues:CustomValuesConfiguration' :: CustomValuesConfiguration -> CustomParameterValues
$sel:includeNullValue:CustomValuesConfiguration' :: CustomValuesConfiguration -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
includeNullValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf CustomParameterValues
customValues

instance Data.ToJSON CustomValuesConfiguration where
  toJSON :: CustomValuesConfiguration -> Value
toJSON CustomValuesConfiguration' {Maybe Bool
CustomParameterValues
customValues :: CustomParameterValues
includeNullValue :: Maybe Bool
$sel:customValues:CustomValuesConfiguration' :: CustomValuesConfiguration -> CustomParameterValues
$sel:includeNullValue:CustomValuesConfiguration' :: CustomValuesConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"IncludeNullValue" 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
includeNullValue,
            forall a. a -> Maybe a
Prelude.Just (Key
"CustomValues" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= CustomParameterValues
customValues)
          ]
      )