{-# 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.RowLevelPermissionTagConfiguration
-- 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.RowLevelPermissionTagConfiguration 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.RowLevelPermissionTagRule
import Amazonka.QuickSight.Types.Status

-- | The configuration of tags on a dataset to set row-level security.
--
-- /See:/ 'newRowLevelPermissionTagConfiguration' smart constructor.
data RowLevelPermissionTagConfiguration = RowLevelPermissionTagConfiguration'
  { -- | The status of row-level security tags. If enabled, the status is
    -- @ENABLED@. If disabled, the status is @DISABLED@.
    RowLevelPermissionTagConfiguration -> Maybe Status
status :: Prelude.Maybe Status,
    -- | A set of rules associated with row-level security, such as the tag names
    -- and columns that they are assigned to.
    RowLevelPermissionTagConfiguration
-> NonEmpty RowLevelPermissionTagRule
tagRules :: Prelude.NonEmpty RowLevelPermissionTagRule
  }
  deriving (RowLevelPermissionTagConfiguration
-> RowLevelPermissionTagConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RowLevelPermissionTagConfiguration
-> RowLevelPermissionTagConfiguration -> Bool
$c/= :: RowLevelPermissionTagConfiguration
-> RowLevelPermissionTagConfiguration -> Bool
== :: RowLevelPermissionTagConfiguration
-> RowLevelPermissionTagConfiguration -> Bool
$c== :: RowLevelPermissionTagConfiguration
-> RowLevelPermissionTagConfiguration -> Bool
Prelude.Eq, Int -> RowLevelPermissionTagConfiguration -> ShowS
[RowLevelPermissionTagConfiguration] -> ShowS
RowLevelPermissionTagConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RowLevelPermissionTagConfiguration] -> ShowS
$cshowList :: [RowLevelPermissionTagConfiguration] -> ShowS
show :: RowLevelPermissionTagConfiguration -> String
$cshow :: RowLevelPermissionTagConfiguration -> String
showsPrec :: Int -> RowLevelPermissionTagConfiguration -> ShowS
$cshowsPrec :: Int -> RowLevelPermissionTagConfiguration -> ShowS
Prelude.Show, forall x.
Rep RowLevelPermissionTagConfiguration x
-> RowLevelPermissionTagConfiguration
forall x.
RowLevelPermissionTagConfiguration
-> Rep RowLevelPermissionTagConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RowLevelPermissionTagConfiguration x
-> RowLevelPermissionTagConfiguration
$cfrom :: forall x.
RowLevelPermissionTagConfiguration
-> Rep RowLevelPermissionTagConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'RowLevelPermissionTagConfiguration' 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:
--
-- 'status', 'rowLevelPermissionTagConfiguration_status' - The status of row-level security tags. If enabled, the status is
-- @ENABLED@. If disabled, the status is @DISABLED@.
--
-- 'tagRules', 'rowLevelPermissionTagConfiguration_tagRules' - A set of rules associated with row-level security, such as the tag names
-- and columns that they are assigned to.
newRowLevelPermissionTagConfiguration ::
  -- | 'tagRules'
  Prelude.NonEmpty RowLevelPermissionTagRule ->
  RowLevelPermissionTagConfiguration
newRowLevelPermissionTagConfiguration :: NonEmpty RowLevelPermissionTagRule
-> RowLevelPermissionTagConfiguration
newRowLevelPermissionTagConfiguration NonEmpty RowLevelPermissionTagRule
pTagRules_ =
  RowLevelPermissionTagConfiguration'
    { $sel:status:RowLevelPermissionTagConfiguration' :: Maybe Status
status =
        forall a. Maybe a
Prelude.Nothing,
      $sel:tagRules:RowLevelPermissionTagConfiguration' :: NonEmpty RowLevelPermissionTagRule
tagRules =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty RowLevelPermissionTagRule
pTagRules_
    }

-- | The status of row-level security tags. If enabled, the status is
-- @ENABLED@. If disabled, the status is @DISABLED@.
rowLevelPermissionTagConfiguration_status :: Lens.Lens' RowLevelPermissionTagConfiguration (Prelude.Maybe Status)
rowLevelPermissionTagConfiguration_status :: Lens' RowLevelPermissionTagConfiguration (Maybe Status)
rowLevelPermissionTagConfiguration_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RowLevelPermissionTagConfiguration' {Maybe Status
status :: Maybe Status
$sel:status:RowLevelPermissionTagConfiguration' :: RowLevelPermissionTagConfiguration -> Maybe Status
status} -> Maybe Status
status) (\s :: RowLevelPermissionTagConfiguration
s@RowLevelPermissionTagConfiguration' {} Maybe Status
a -> RowLevelPermissionTagConfiguration
s {$sel:status:RowLevelPermissionTagConfiguration' :: Maybe Status
status = Maybe Status
a} :: RowLevelPermissionTagConfiguration)

-- | A set of rules associated with row-level security, such as the tag names
-- and columns that they are assigned to.
rowLevelPermissionTagConfiguration_tagRules :: Lens.Lens' RowLevelPermissionTagConfiguration (Prelude.NonEmpty RowLevelPermissionTagRule)
rowLevelPermissionTagConfiguration_tagRules :: Lens'
  RowLevelPermissionTagConfiguration
  (NonEmpty RowLevelPermissionTagRule)
rowLevelPermissionTagConfiguration_tagRules = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RowLevelPermissionTagConfiguration' {NonEmpty RowLevelPermissionTagRule
tagRules :: NonEmpty RowLevelPermissionTagRule
$sel:tagRules:RowLevelPermissionTagConfiguration' :: RowLevelPermissionTagConfiguration
-> NonEmpty RowLevelPermissionTagRule
tagRules} -> NonEmpty RowLevelPermissionTagRule
tagRules) (\s :: RowLevelPermissionTagConfiguration
s@RowLevelPermissionTagConfiguration' {} NonEmpty RowLevelPermissionTagRule
a -> RowLevelPermissionTagConfiguration
s {$sel:tagRules:RowLevelPermissionTagConfiguration' :: NonEmpty RowLevelPermissionTagRule
tagRules = NonEmpty RowLevelPermissionTagRule
a} :: RowLevelPermissionTagConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Data.FromJSON
    RowLevelPermissionTagConfiguration
  where
  parseJSON :: Value -> Parser RowLevelPermissionTagConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RowLevelPermissionTagConfiguration"
      ( \Object
x ->
          Maybe Status
-> NonEmpty RowLevelPermissionTagRule
-> RowLevelPermissionTagConfiguration
RowLevelPermissionTagConfiguration'
            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
"Status")
            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
"TagRules")
      )

instance
  Prelude.Hashable
    RowLevelPermissionTagConfiguration
  where
  hashWithSalt :: Int -> RowLevelPermissionTagConfiguration -> Int
hashWithSalt
    Int
_salt
    RowLevelPermissionTagConfiguration' {Maybe Status
NonEmpty RowLevelPermissionTagRule
tagRules :: NonEmpty RowLevelPermissionTagRule
status :: Maybe Status
$sel:tagRules:RowLevelPermissionTagConfiguration' :: RowLevelPermissionTagConfiguration
-> NonEmpty RowLevelPermissionTagRule
$sel:status:RowLevelPermissionTagConfiguration' :: RowLevelPermissionTagConfiguration -> Maybe Status
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Status
status
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty RowLevelPermissionTagRule
tagRules

instance
  Prelude.NFData
    RowLevelPermissionTagConfiguration
  where
  rnf :: RowLevelPermissionTagConfiguration -> ()
rnf RowLevelPermissionTagConfiguration' {Maybe Status
NonEmpty RowLevelPermissionTagRule
tagRules :: NonEmpty RowLevelPermissionTagRule
status :: Maybe Status
$sel:tagRules:RowLevelPermissionTagConfiguration' :: RowLevelPermissionTagConfiguration
-> NonEmpty RowLevelPermissionTagRule
$sel:status:RowLevelPermissionTagConfiguration' :: RowLevelPermissionTagConfiguration -> Maybe Status
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Status
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty RowLevelPermissionTagRule
tagRules

instance
  Data.ToJSON
    RowLevelPermissionTagConfiguration
  where
  toJSON :: RowLevelPermissionTagConfiguration -> Value
toJSON RowLevelPermissionTagConfiguration' {Maybe Status
NonEmpty RowLevelPermissionTagRule
tagRules :: NonEmpty RowLevelPermissionTagRule
status :: Maybe Status
$sel:tagRules:RowLevelPermissionTagConfiguration' :: RowLevelPermissionTagConfiguration
-> NonEmpty RowLevelPermissionTagRule
$sel:status:RowLevelPermissionTagConfiguration' :: RowLevelPermissionTagConfiguration -> Maybe Status
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Status" 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 Status
status,
            forall a. a -> Maybe a
Prelude.Just (Key
"TagRules" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty RowLevelPermissionTagRule
tagRules)
          ]
      )