{-# 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.DataPathLabelType
-- 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.DataPathLabelType 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.Visibility

-- | The option that specifies individual data values for labels.
--
-- /See:/ 'newDataPathLabelType' smart constructor.
data DataPathLabelType = DataPathLabelType'
  { -- | The field ID of the field that the data label needs to be applied to.
    DataPathLabelType -> Maybe Text
fieldId :: Prelude.Maybe Prelude.Text,
    -- | The actual value of the field that is labeled.
    DataPathLabelType -> Maybe (Sensitive Text)
fieldValue :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The visibility of the data label.
    DataPathLabelType -> Maybe Visibility
visibility :: Prelude.Maybe Visibility
  }
  deriving (DataPathLabelType -> DataPathLabelType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataPathLabelType -> DataPathLabelType -> Bool
$c/= :: DataPathLabelType -> DataPathLabelType -> Bool
== :: DataPathLabelType -> DataPathLabelType -> Bool
$c== :: DataPathLabelType -> DataPathLabelType -> Bool
Prelude.Eq, Int -> DataPathLabelType -> ShowS
[DataPathLabelType] -> ShowS
DataPathLabelType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataPathLabelType] -> ShowS
$cshowList :: [DataPathLabelType] -> ShowS
show :: DataPathLabelType -> String
$cshow :: DataPathLabelType -> String
showsPrec :: Int -> DataPathLabelType -> ShowS
$cshowsPrec :: Int -> DataPathLabelType -> ShowS
Prelude.Show, forall x. Rep DataPathLabelType x -> DataPathLabelType
forall x. DataPathLabelType -> Rep DataPathLabelType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataPathLabelType x -> DataPathLabelType
$cfrom :: forall x. DataPathLabelType -> Rep DataPathLabelType x
Prelude.Generic)

-- |
-- Create a value of 'DataPathLabelType' 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:
--
-- 'fieldId', 'dataPathLabelType_fieldId' - The field ID of the field that the data label needs to be applied to.
--
-- 'fieldValue', 'dataPathLabelType_fieldValue' - The actual value of the field that is labeled.
--
-- 'visibility', 'dataPathLabelType_visibility' - The visibility of the data label.
newDataPathLabelType ::
  DataPathLabelType
newDataPathLabelType :: DataPathLabelType
newDataPathLabelType =
  DataPathLabelType'
    { $sel:fieldId:DataPathLabelType' :: Maybe Text
fieldId = forall a. Maybe a
Prelude.Nothing,
      $sel:fieldValue:DataPathLabelType' :: Maybe (Sensitive Text)
fieldValue = forall a. Maybe a
Prelude.Nothing,
      $sel:visibility:DataPathLabelType' :: Maybe Visibility
visibility = forall a. Maybe a
Prelude.Nothing
    }

-- | The field ID of the field that the data label needs to be applied to.
dataPathLabelType_fieldId :: Lens.Lens' DataPathLabelType (Prelude.Maybe Prelude.Text)
dataPathLabelType_fieldId :: Lens' DataPathLabelType (Maybe Text)
dataPathLabelType_fieldId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataPathLabelType' {Maybe Text
fieldId :: Maybe Text
$sel:fieldId:DataPathLabelType' :: DataPathLabelType -> Maybe Text
fieldId} -> Maybe Text
fieldId) (\s :: DataPathLabelType
s@DataPathLabelType' {} Maybe Text
a -> DataPathLabelType
s {$sel:fieldId:DataPathLabelType' :: Maybe Text
fieldId = Maybe Text
a} :: DataPathLabelType)

-- | The actual value of the field that is labeled.
dataPathLabelType_fieldValue :: Lens.Lens' DataPathLabelType (Prelude.Maybe Prelude.Text)
dataPathLabelType_fieldValue :: Lens' DataPathLabelType (Maybe Text)
dataPathLabelType_fieldValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataPathLabelType' {Maybe (Sensitive Text)
fieldValue :: Maybe (Sensitive Text)
$sel:fieldValue:DataPathLabelType' :: DataPathLabelType -> Maybe (Sensitive Text)
fieldValue} -> Maybe (Sensitive Text)
fieldValue) (\s :: DataPathLabelType
s@DataPathLabelType' {} Maybe (Sensitive Text)
a -> DataPathLabelType
s {$sel:fieldValue:DataPathLabelType' :: Maybe (Sensitive Text)
fieldValue = Maybe (Sensitive Text)
a} :: DataPathLabelType) 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 a. Iso' (Sensitive a) a
Data._Sensitive

-- | The visibility of the data label.
dataPathLabelType_visibility :: Lens.Lens' DataPathLabelType (Prelude.Maybe Visibility)
dataPathLabelType_visibility :: Lens' DataPathLabelType (Maybe Visibility)
dataPathLabelType_visibility = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataPathLabelType' {Maybe Visibility
visibility :: Maybe Visibility
$sel:visibility:DataPathLabelType' :: DataPathLabelType -> Maybe Visibility
visibility} -> Maybe Visibility
visibility) (\s :: DataPathLabelType
s@DataPathLabelType' {} Maybe Visibility
a -> DataPathLabelType
s {$sel:visibility:DataPathLabelType' :: Maybe Visibility
visibility = Maybe Visibility
a} :: DataPathLabelType)

instance Data.FromJSON DataPathLabelType where
  parseJSON :: Value -> Parser DataPathLabelType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataPathLabelType"
      ( \Object
x ->
          Maybe Text
-> Maybe (Sensitive Text) -> Maybe Visibility -> DataPathLabelType
DataPathLabelType'
            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
"FieldId")
            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
"FieldValue")
            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
"Visibility")
      )

instance Prelude.Hashable DataPathLabelType where
  hashWithSalt :: Int -> DataPathLabelType -> Int
hashWithSalt Int
_salt DataPathLabelType' {Maybe Text
Maybe (Sensitive Text)
Maybe Visibility
visibility :: Maybe Visibility
fieldValue :: Maybe (Sensitive Text)
fieldId :: Maybe Text
$sel:visibility:DataPathLabelType' :: DataPathLabelType -> Maybe Visibility
$sel:fieldValue:DataPathLabelType' :: DataPathLabelType -> Maybe (Sensitive Text)
$sel:fieldId:DataPathLabelType' :: DataPathLabelType -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
fieldId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
fieldValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Visibility
visibility

instance Prelude.NFData DataPathLabelType where
  rnf :: DataPathLabelType -> ()
rnf DataPathLabelType' {Maybe Text
Maybe (Sensitive Text)
Maybe Visibility
visibility :: Maybe Visibility
fieldValue :: Maybe (Sensitive Text)
fieldId :: Maybe Text
$sel:visibility:DataPathLabelType' :: DataPathLabelType -> Maybe Visibility
$sel:fieldValue:DataPathLabelType' :: DataPathLabelType -> Maybe (Sensitive Text)
$sel:fieldId:DataPathLabelType' :: DataPathLabelType -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fieldId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
fieldValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Visibility
visibility

instance Data.ToJSON DataPathLabelType where
  toJSON :: DataPathLabelType -> Value
toJSON DataPathLabelType' {Maybe Text
Maybe (Sensitive Text)
Maybe Visibility
visibility :: Maybe Visibility
fieldValue :: Maybe (Sensitive Text)
fieldId :: Maybe Text
$sel:visibility:DataPathLabelType' :: DataPathLabelType -> Maybe Visibility
$sel:fieldValue:DataPathLabelType' :: DataPathLabelType -> Maybe (Sensitive Text)
$sel:fieldId:DataPathLabelType' :: DataPathLabelType -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"FieldId" 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 Text
fieldId,
            (Key
"FieldValue" 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 (Sensitive Text)
fieldValue,
            (Key
"Visibility" 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 Visibility
visibility
          ]
      )