{-# 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.SessionTag
-- 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.SessionTag 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 key-value pair used for the row-level security tags feature.
--
-- /See:/ 'newSessionTag' smart constructor.
data SessionTag = SessionTag'
  { -- | The key for the tag.
    SessionTag -> Text
key :: Prelude.Text,
    -- | The value that you want to assign the tag.
    SessionTag -> Sensitive Text
value :: Data.Sensitive Prelude.Text
  }
  deriving (SessionTag -> SessionTag -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SessionTag -> SessionTag -> Bool
$c/= :: SessionTag -> SessionTag -> Bool
== :: SessionTag -> SessionTag -> Bool
$c== :: SessionTag -> SessionTag -> Bool
Prelude.Eq, Int -> SessionTag -> ShowS
[SessionTag] -> ShowS
SessionTag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SessionTag] -> ShowS
$cshowList :: [SessionTag] -> ShowS
show :: SessionTag -> String
$cshow :: SessionTag -> String
showsPrec :: Int -> SessionTag -> ShowS
$cshowsPrec :: Int -> SessionTag -> ShowS
Prelude.Show, forall x. Rep SessionTag x -> SessionTag
forall x. SessionTag -> Rep SessionTag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SessionTag x -> SessionTag
$cfrom :: forall x. SessionTag -> Rep SessionTag x
Prelude.Generic)

-- |
-- Create a value of 'SessionTag' 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:
--
-- 'key', 'sessionTag_key' - The key for the tag.
--
-- 'value', 'sessionTag_value' - The value that you want to assign the tag.
newSessionTag ::
  -- | 'key'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  SessionTag
newSessionTag :: Text -> Text -> SessionTag
newSessionTag Text
pKey_ Text
pValue_ =
  SessionTag'
    { $sel:key:SessionTag' :: Text
key = Text
pKey_,
      $sel:value:SessionTag' :: Sensitive Text
value = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pValue_
    }

-- | The key for the tag.
sessionTag_key :: Lens.Lens' SessionTag Prelude.Text
sessionTag_key :: Lens' SessionTag Text
sessionTag_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionTag' {Text
key :: Text
$sel:key:SessionTag' :: SessionTag -> Text
key} -> Text
key) (\s :: SessionTag
s@SessionTag' {} Text
a -> SessionTag
s {$sel:key:SessionTag' :: Text
key = Text
a} :: SessionTag)

-- | The value that you want to assign the tag.
sessionTag_value :: Lens.Lens' SessionTag Prelude.Text
sessionTag_value :: Lens' SessionTag Text
sessionTag_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionTag' {Sensitive Text
value :: Sensitive Text
$sel:value:SessionTag' :: SessionTag -> Sensitive Text
value} -> Sensitive Text
value) (\s :: SessionTag
s@SessionTag' {} Sensitive Text
a -> SessionTag
s {$sel:value:SessionTag' :: Sensitive Text
value = Sensitive Text
a} :: SessionTag) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Prelude.Hashable SessionTag where
  hashWithSalt :: Int -> SessionTag -> Int
hashWithSalt Int
_salt SessionTag' {Text
Sensitive Text
value :: Sensitive Text
key :: Text
$sel:value:SessionTag' :: SessionTag -> Sensitive Text
$sel:key:SessionTag' :: SessionTag -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
value

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

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