{-# 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.DataPathColor
-- 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.DataPathColor 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.DataPathValue
import Amazonka.QuickSight.Types.TimeGranularity

-- | The color map that determines the color options for a particular
-- element.
--
-- /See:/ 'newDataPathColor' smart constructor.
data DataPathColor = DataPathColor'
  { -- | The time granularity of the field that the color needs to be applied to.
    DataPathColor -> Maybe TimeGranularity
timeGranularity :: Prelude.Maybe TimeGranularity,
    -- | The element that the color needs to be applied to.
    DataPathColor -> DataPathValue
element :: DataPathValue,
    -- | The color that needs to be applied to the element.
    DataPathColor -> Text
color :: Prelude.Text
  }
  deriving (DataPathColor -> DataPathColor -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataPathColor -> DataPathColor -> Bool
$c/= :: DataPathColor -> DataPathColor -> Bool
== :: DataPathColor -> DataPathColor -> Bool
$c== :: DataPathColor -> DataPathColor -> Bool
Prelude.Eq, Int -> DataPathColor -> ShowS
[DataPathColor] -> ShowS
DataPathColor -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataPathColor] -> ShowS
$cshowList :: [DataPathColor] -> ShowS
show :: DataPathColor -> String
$cshow :: DataPathColor -> String
showsPrec :: Int -> DataPathColor -> ShowS
$cshowsPrec :: Int -> DataPathColor -> ShowS
Prelude.Show, forall x. Rep DataPathColor x -> DataPathColor
forall x. DataPathColor -> Rep DataPathColor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataPathColor x -> DataPathColor
$cfrom :: forall x. DataPathColor -> Rep DataPathColor x
Prelude.Generic)

-- |
-- Create a value of 'DataPathColor' 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:
--
-- 'timeGranularity', 'dataPathColor_timeGranularity' - The time granularity of the field that the color needs to be applied to.
--
-- 'element', 'dataPathColor_element' - The element that the color needs to be applied to.
--
-- 'color', 'dataPathColor_color' - The color that needs to be applied to the element.
newDataPathColor ::
  -- | 'element'
  DataPathValue ->
  -- | 'color'
  Prelude.Text ->
  DataPathColor
newDataPathColor :: DataPathValue -> Text -> DataPathColor
newDataPathColor DataPathValue
pElement_ Text
pColor_ =
  DataPathColor'
    { $sel:timeGranularity:DataPathColor' :: Maybe TimeGranularity
timeGranularity = forall a. Maybe a
Prelude.Nothing,
      $sel:element:DataPathColor' :: DataPathValue
element = DataPathValue
pElement_,
      $sel:color:DataPathColor' :: Text
color = Text
pColor_
    }

-- | The time granularity of the field that the color needs to be applied to.
dataPathColor_timeGranularity :: Lens.Lens' DataPathColor (Prelude.Maybe TimeGranularity)
dataPathColor_timeGranularity :: Lens' DataPathColor (Maybe TimeGranularity)
dataPathColor_timeGranularity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataPathColor' {Maybe TimeGranularity
timeGranularity :: Maybe TimeGranularity
$sel:timeGranularity:DataPathColor' :: DataPathColor -> Maybe TimeGranularity
timeGranularity} -> Maybe TimeGranularity
timeGranularity) (\s :: DataPathColor
s@DataPathColor' {} Maybe TimeGranularity
a -> DataPathColor
s {$sel:timeGranularity:DataPathColor' :: Maybe TimeGranularity
timeGranularity = Maybe TimeGranularity
a} :: DataPathColor)

-- | The element that the color needs to be applied to.
dataPathColor_element :: Lens.Lens' DataPathColor DataPathValue
dataPathColor_element :: Lens' DataPathColor DataPathValue
dataPathColor_element = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataPathColor' {DataPathValue
element :: DataPathValue
$sel:element:DataPathColor' :: DataPathColor -> DataPathValue
element} -> DataPathValue
element) (\s :: DataPathColor
s@DataPathColor' {} DataPathValue
a -> DataPathColor
s {$sel:element:DataPathColor' :: DataPathValue
element = DataPathValue
a} :: DataPathColor)

-- | The color that needs to be applied to the element.
dataPathColor_color :: Lens.Lens' DataPathColor Prelude.Text
dataPathColor_color :: Lens' DataPathColor Text
dataPathColor_color = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataPathColor' {Text
color :: Text
$sel:color:DataPathColor' :: DataPathColor -> Text
color} -> Text
color) (\s :: DataPathColor
s@DataPathColor' {} Text
a -> DataPathColor
s {$sel:color:DataPathColor' :: Text
color = Text
a} :: DataPathColor)

instance Data.FromJSON DataPathColor where
  parseJSON :: Value -> Parser DataPathColor
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataPathColor"
      ( \Object
x ->
          Maybe TimeGranularity -> DataPathValue -> Text -> DataPathColor
DataPathColor'
            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
"TimeGranularity")
            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
"Element")
            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
"Color")
      )

instance Prelude.Hashable DataPathColor where
  hashWithSalt :: Int -> DataPathColor -> Int
hashWithSalt Int
_salt DataPathColor' {Maybe TimeGranularity
Text
DataPathValue
color :: Text
element :: DataPathValue
timeGranularity :: Maybe TimeGranularity
$sel:color:DataPathColor' :: DataPathColor -> Text
$sel:element:DataPathColor' :: DataPathColor -> DataPathValue
$sel:timeGranularity:DataPathColor' :: DataPathColor -> Maybe TimeGranularity
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TimeGranularity
timeGranularity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DataPathValue
element
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
color

instance Prelude.NFData DataPathColor where
  rnf :: DataPathColor -> ()
rnf DataPathColor' {Maybe TimeGranularity
Text
DataPathValue
color :: Text
element :: DataPathValue
timeGranularity :: Maybe TimeGranularity
$sel:color:DataPathColor' :: DataPathColor -> Text
$sel:element:DataPathColor' :: DataPathColor -> DataPathValue
$sel:timeGranularity:DataPathColor' :: DataPathColor -> Maybe TimeGranularity
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe TimeGranularity
timeGranularity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DataPathValue
element
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
color

instance Data.ToJSON DataPathColor where
  toJSON :: DataPathColor -> Value
toJSON DataPathColor' {Maybe TimeGranularity
Text
DataPathValue
color :: Text
element :: DataPathValue
timeGranularity :: Maybe TimeGranularity
$sel:color:DataPathColor' :: DataPathColor -> Text
$sel:element:DataPathColor' :: DataPathColor -> DataPathValue
$sel:timeGranularity:DataPathColor' :: DataPathColor -> Maybe TimeGranularity
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"TimeGranularity" 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 TimeGranularity
timeGranularity,
            forall a. a -> Maybe a
Prelude.Just (Key
"Element" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DataPathValue
element),
            forall a. a -> Maybe a
Prelude.Just (Key
"Color" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
color)
          ]
      )