{-# 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.DataPathValue
-- 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.DataPathValue 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

-- | The data path that needs to be sorted.
--
-- /See:/ 'newDataPathValue' smart constructor.
data DataPathValue = DataPathValue'
  { -- | The field ID of the field that needs to be sorted.
    DataPathValue -> Text
fieldId :: Prelude.Text,
    -- | The actual value of the field that needs to be sorted.
    DataPathValue -> Sensitive Text
fieldValue :: Data.Sensitive Prelude.Text
  }
  deriving (DataPathValue -> DataPathValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataPathValue -> DataPathValue -> Bool
$c/= :: DataPathValue -> DataPathValue -> Bool
== :: DataPathValue -> DataPathValue -> Bool
$c== :: DataPathValue -> DataPathValue -> Bool
Prelude.Eq, Int -> DataPathValue -> ShowS
[DataPathValue] -> ShowS
DataPathValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataPathValue] -> ShowS
$cshowList :: [DataPathValue] -> ShowS
show :: DataPathValue -> String
$cshow :: DataPathValue -> String
showsPrec :: Int -> DataPathValue -> ShowS
$cshowsPrec :: Int -> DataPathValue -> ShowS
Prelude.Show, forall x. Rep DataPathValue x -> DataPathValue
forall x. DataPathValue -> Rep DataPathValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataPathValue x -> DataPathValue
$cfrom :: forall x. DataPathValue -> Rep DataPathValue x
Prelude.Generic)

-- |
-- Create a value of 'DataPathValue' 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', 'dataPathValue_fieldId' - The field ID of the field that needs to be sorted.
--
-- 'fieldValue', 'dataPathValue_fieldValue' - The actual value of the field that needs to be sorted.
newDataPathValue ::
  -- | 'fieldId'
  Prelude.Text ->
  -- | 'fieldValue'
  Prelude.Text ->
  DataPathValue
newDataPathValue :: Text -> Text -> DataPathValue
newDataPathValue Text
pFieldId_ Text
pFieldValue_ =
  DataPathValue'
    { $sel:fieldId:DataPathValue' :: Text
fieldId = Text
pFieldId_,
      $sel:fieldValue:DataPathValue' :: Sensitive Text
fieldValue = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pFieldValue_
    }

-- | The field ID of the field that needs to be sorted.
dataPathValue_fieldId :: Lens.Lens' DataPathValue Prelude.Text
dataPathValue_fieldId :: Lens' DataPathValue Text
dataPathValue_fieldId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataPathValue' {Text
fieldId :: Text
$sel:fieldId:DataPathValue' :: DataPathValue -> Text
fieldId} -> Text
fieldId) (\s :: DataPathValue
s@DataPathValue' {} Text
a -> DataPathValue
s {$sel:fieldId:DataPathValue' :: Text
fieldId = Text
a} :: DataPathValue)

-- | The actual value of the field that needs to be sorted.
dataPathValue_fieldValue :: Lens.Lens' DataPathValue Prelude.Text
dataPathValue_fieldValue :: Lens' DataPathValue Text
dataPathValue_fieldValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataPathValue' {Sensitive Text
fieldValue :: Sensitive Text
$sel:fieldValue:DataPathValue' :: DataPathValue -> Sensitive Text
fieldValue} -> Sensitive Text
fieldValue) (\s :: DataPathValue
s@DataPathValue' {} Sensitive Text
a -> DataPathValue
s {$sel:fieldValue:DataPathValue' :: Sensitive Text
fieldValue = Sensitive Text
a} :: DataPathValue) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Data.FromJSON DataPathValue where
  parseJSON :: Value -> Parser DataPathValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataPathValue"
      ( \Object
x ->
          Text -> Sensitive Text -> DataPathValue
DataPathValue'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser 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 a
Data..: Key
"FieldValue")
      )

instance Prelude.Hashable DataPathValue where
  hashWithSalt :: Int -> DataPathValue -> Int
hashWithSalt Int
_salt DataPathValue' {Text
Sensitive Text
fieldValue :: Sensitive Text
fieldId :: Text
$sel:fieldValue:DataPathValue' :: DataPathValue -> Sensitive Text
$sel:fieldId:DataPathValue' :: DataPathValue -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fieldId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
fieldValue

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

instance Data.ToJSON DataPathValue where
  toJSON :: DataPathValue -> Value
toJSON DataPathValue' {Text
Sensitive Text
fieldValue :: Sensitive Text
fieldId :: Text
$sel:fieldValue:DataPathValue' :: DataPathValue -> Sensitive Text
$sel:fieldId:DataPathValue' :: DataPathValue -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"FieldId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
fieldId),
            forall a. a -> Maybe a
Prelude.Just (Key
"FieldValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
fieldValue)
          ]
      )