{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.QuickSight.Types.SessionTag where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 :: Core.Sensitive Prelude.Text
  }
  deriving (SessionTag -> SessionTag -> Bool
(SessionTag -> SessionTag -> Bool)
-> (SessionTag -> SessionTag -> Bool) -> Eq SessionTag
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
(Int -> SessionTag -> ShowS)
-> (SessionTag -> String)
-> ([SessionTag] -> ShowS)
-> Show SessionTag
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. SessionTag -> Rep SessionTag x)
-> (forall x. Rep SessionTag x -> SessionTag) -> Generic SessionTag
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' :: Text -> Sensitive Text -> SessionTag
SessionTag'
    { $sel:key:SessionTag' :: Text
key = Text
pKey_,
      $sel:value:SessionTag' :: Sensitive Text
value = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
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 :: (Text -> f Text) -> SessionTag -> f SessionTag
sessionTag_key = (SessionTag -> Text)
-> (SessionTag -> Text -> SessionTag)
-> Lens SessionTag SessionTag Text Text
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 :: (Text -> f Text) -> SessionTag -> f SessionTag
sessionTag_value = (SessionTag -> Sensitive Text)
-> (SessionTag -> Sensitive Text -> SessionTag)
-> Lens SessionTag SessionTag (Sensitive Text) (Sensitive Text)
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) ((Sensitive Text -> f (Sensitive Text))
 -> SessionTag -> f SessionTag)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> SessionTag
-> f SessionTag
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance Prelude.Hashable SessionTag

instance Prelude.NFData SessionTag

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Value" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
value)
          ]
      )