{-# 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.RowLevelPermissionDataSet
-- 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.RowLevelPermissionDataSet 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.RowLevelPermissionFormatVersion
import Amazonka.QuickSight.Types.RowLevelPermissionPolicy
import Amazonka.QuickSight.Types.Status

-- | Information about a dataset that contains permissions for row-level
-- security (RLS). The permissions dataset maps fields to users or groups.
-- For more information, see
-- <https://docs.aws.amazon.com/quicksight/latest/user/restrict-access-to-a-data-set-using-row-level-security.html Using Row-Level Security (RLS) to Restrict Access to a Dataset>
-- in the /Amazon QuickSight User Guide/.
--
-- The option to deny permissions by setting @PermissionPolicy@ to
-- @DENY_ACCESS@ is not supported for new RLS datasets.
--
-- /See:/ 'newRowLevelPermissionDataSet' smart constructor.
data RowLevelPermissionDataSet = RowLevelPermissionDataSet'
  { -- | The user or group rules associated with the dataset that contains
    -- permissions for RLS.
    --
    -- By default, @FormatVersion@ is @VERSION_1@. When @FormatVersion@ is
    -- @VERSION_1@, @UserName@ and @GroupName@ are required. When
    -- @FormatVersion@ is @VERSION_2@, @UserARN@ and @GroupARN@ are required,
    -- and @Namespace@ must not exist.
    RowLevelPermissionDataSet -> Maybe RowLevelPermissionFormatVersion
formatVersion :: Prelude.Maybe RowLevelPermissionFormatVersion,
    -- | The namespace associated with the dataset that contains permissions for
    -- RLS.
    RowLevelPermissionDataSet -> Maybe Text
namespace :: Prelude.Maybe Prelude.Text,
    -- | The status of the row-level security permission dataset. If enabled, the
    -- status is @ENABLED@. If disabled, the status is @DISABLED@.
    RowLevelPermissionDataSet -> Maybe Status
status :: Prelude.Maybe Status,
    -- | The Amazon Resource Name (ARN) of the dataset that contains permissions
    -- for RLS.
    RowLevelPermissionDataSet -> Text
arn :: Prelude.Text,
    -- | The type of permissions to use when interpreting the permissions for
    -- RLS. @DENY_ACCESS@ is included for backward compatibility only.
    RowLevelPermissionDataSet -> RowLevelPermissionPolicy
permissionPolicy :: RowLevelPermissionPolicy
  }
  deriving (RowLevelPermissionDataSet -> RowLevelPermissionDataSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RowLevelPermissionDataSet -> RowLevelPermissionDataSet -> Bool
$c/= :: RowLevelPermissionDataSet -> RowLevelPermissionDataSet -> Bool
== :: RowLevelPermissionDataSet -> RowLevelPermissionDataSet -> Bool
$c== :: RowLevelPermissionDataSet -> RowLevelPermissionDataSet -> Bool
Prelude.Eq, ReadPrec [RowLevelPermissionDataSet]
ReadPrec RowLevelPermissionDataSet
Int -> ReadS RowLevelPermissionDataSet
ReadS [RowLevelPermissionDataSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RowLevelPermissionDataSet]
$creadListPrec :: ReadPrec [RowLevelPermissionDataSet]
readPrec :: ReadPrec RowLevelPermissionDataSet
$creadPrec :: ReadPrec RowLevelPermissionDataSet
readList :: ReadS [RowLevelPermissionDataSet]
$creadList :: ReadS [RowLevelPermissionDataSet]
readsPrec :: Int -> ReadS RowLevelPermissionDataSet
$creadsPrec :: Int -> ReadS RowLevelPermissionDataSet
Prelude.Read, Int -> RowLevelPermissionDataSet -> ShowS
[RowLevelPermissionDataSet] -> ShowS
RowLevelPermissionDataSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RowLevelPermissionDataSet] -> ShowS
$cshowList :: [RowLevelPermissionDataSet] -> ShowS
show :: RowLevelPermissionDataSet -> String
$cshow :: RowLevelPermissionDataSet -> String
showsPrec :: Int -> RowLevelPermissionDataSet -> ShowS
$cshowsPrec :: Int -> RowLevelPermissionDataSet -> ShowS
Prelude.Show, forall x.
Rep RowLevelPermissionDataSet x -> RowLevelPermissionDataSet
forall x.
RowLevelPermissionDataSet -> Rep RowLevelPermissionDataSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RowLevelPermissionDataSet x -> RowLevelPermissionDataSet
$cfrom :: forall x.
RowLevelPermissionDataSet -> Rep RowLevelPermissionDataSet x
Prelude.Generic)

-- |
-- Create a value of 'RowLevelPermissionDataSet' 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:
--
-- 'formatVersion', 'rowLevelPermissionDataSet_formatVersion' - The user or group rules associated with the dataset that contains
-- permissions for RLS.
--
-- By default, @FormatVersion@ is @VERSION_1@. When @FormatVersion@ is
-- @VERSION_1@, @UserName@ and @GroupName@ are required. When
-- @FormatVersion@ is @VERSION_2@, @UserARN@ and @GroupARN@ are required,
-- and @Namespace@ must not exist.
--
-- 'namespace', 'rowLevelPermissionDataSet_namespace' - The namespace associated with the dataset that contains permissions for
-- RLS.
--
-- 'status', 'rowLevelPermissionDataSet_status' - The status of the row-level security permission dataset. If enabled, the
-- status is @ENABLED@. If disabled, the status is @DISABLED@.
--
-- 'arn', 'rowLevelPermissionDataSet_arn' - The Amazon Resource Name (ARN) of the dataset that contains permissions
-- for RLS.
--
-- 'permissionPolicy', 'rowLevelPermissionDataSet_permissionPolicy' - The type of permissions to use when interpreting the permissions for
-- RLS. @DENY_ACCESS@ is included for backward compatibility only.
newRowLevelPermissionDataSet ::
  -- | 'arn'
  Prelude.Text ->
  -- | 'permissionPolicy'
  RowLevelPermissionPolicy ->
  RowLevelPermissionDataSet
newRowLevelPermissionDataSet :: Text -> RowLevelPermissionPolicy -> RowLevelPermissionDataSet
newRowLevelPermissionDataSet Text
pArn_ RowLevelPermissionPolicy
pPermissionPolicy_ =
  RowLevelPermissionDataSet'
    { $sel:formatVersion:RowLevelPermissionDataSet' :: Maybe RowLevelPermissionFormatVersion
formatVersion =
        forall a. Maybe a
Prelude.Nothing,
      $sel:namespace:RowLevelPermissionDataSet' :: Maybe Text
namespace = forall a. Maybe a
Prelude.Nothing,
      $sel:status:RowLevelPermissionDataSet' :: Maybe Status
status = forall a. Maybe a
Prelude.Nothing,
      $sel:arn:RowLevelPermissionDataSet' :: Text
arn = Text
pArn_,
      $sel:permissionPolicy:RowLevelPermissionDataSet' :: RowLevelPermissionPolicy
permissionPolicy = RowLevelPermissionPolicy
pPermissionPolicy_
    }

-- | The user or group rules associated with the dataset that contains
-- permissions for RLS.
--
-- By default, @FormatVersion@ is @VERSION_1@. When @FormatVersion@ is
-- @VERSION_1@, @UserName@ and @GroupName@ are required. When
-- @FormatVersion@ is @VERSION_2@, @UserARN@ and @GroupARN@ are required,
-- and @Namespace@ must not exist.
rowLevelPermissionDataSet_formatVersion :: Lens.Lens' RowLevelPermissionDataSet (Prelude.Maybe RowLevelPermissionFormatVersion)
rowLevelPermissionDataSet_formatVersion :: Lens'
  RowLevelPermissionDataSet (Maybe RowLevelPermissionFormatVersion)
rowLevelPermissionDataSet_formatVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RowLevelPermissionDataSet' {Maybe RowLevelPermissionFormatVersion
formatVersion :: Maybe RowLevelPermissionFormatVersion
$sel:formatVersion:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe RowLevelPermissionFormatVersion
formatVersion} -> Maybe RowLevelPermissionFormatVersion
formatVersion) (\s :: RowLevelPermissionDataSet
s@RowLevelPermissionDataSet' {} Maybe RowLevelPermissionFormatVersion
a -> RowLevelPermissionDataSet
s {$sel:formatVersion:RowLevelPermissionDataSet' :: Maybe RowLevelPermissionFormatVersion
formatVersion = Maybe RowLevelPermissionFormatVersion
a} :: RowLevelPermissionDataSet)

-- | The namespace associated with the dataset that contains permissions for
-- RLS.
rowLevelPermissionDataSet_namespace :: Lens.Lens' RowLevelPermissionDataSet (Prelude.Maybe Prelude.Text)
rowLevelPermissionDataSet_namespace :: Lens' RowLevelPermissionDataSet (Maybe Text)
rowLevelPermissionDataSet_namespace = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RowLevelPermissionDataSet' {Maybe Text
namespace :: Maybe Text
$sel:namespace:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe Text
namespace} -> Maybe Text
namespace) (\s :: RowLevelPermissionDataSet
s@RowLevelPermissionDataSet' {} Maybe Text
a -> RowLevelPermissionDataSet
s {$sel:namespace:RowLevelPermissionDataSet' :: Maybe Text
namespace = Maybe Text
a} :: RowLevelPermissionDataSet)

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

-- | The Amazon Resource Name (ARN) of the dataset that contains permissions
-- for RLS.
rowLevelPermissionDataSet_arn :: Lens.Lens' RowLevelPermissionDataSet Prelude.Text
rowLevelPermissionDataSet_arn :: Lens' RowLevelPermissionDataSet Text
rowLevelPermissionDataSet_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RowLevelPermissionDataSet' {Text
arn :: Text
$sel:arn:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Text
arn} -> Text
arn) (\s :: RowLevelPermissionDataSet
s@RowLevelPermissionDataSet' {} Text
a -> RowLevelPermissionDataSet
s {$sel:arn:RowLevelPermissionDataSet' :: Text
arn = Text
a} :: RowLevelPermissionDataSet)

-- | The type of permissions to use when interpreting the permissions for
-- RLS. @DENY_ACCESS@ is included for backward compatibility only.
rowLevelPermissionDataSet_permissionPolicy :: Lens.Lens' RowLevelPermissionDataSet RowLevelPermissionPolicy
rowLevelPermissionDataSet_permissionPolicy :: Lens' RowLevelPermissionDataSet RowLevelPermissionPolicy
rowLevelPermissionDataSet_permissionPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RowLevelPermissionDataSet' {RowLevelPermissionPolicy
permissionPolicy :: RowLevelPermissionPolicy
$sel:permissionPolicy:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> RowLevelPermissionPolicy
permissionPolicy} -> RowLevelPermissionPolicy
permissionPolicy) (\s :: RowLevelPermissionDataSet
s@RowLevelPermissionDataSet' {} RowLevelPermissionPolicy
a -> RowLevelPermissionDataSet
s {$sel:permissionPolicy:RowLevelPermissionDataSet' :: RowLevelPermissionPolicy
permissionPolicy = RowLevelPermissionPolicy
a} :: RowLevelPermissionDataSet)

instance Data.FromJSON RowLevelPermissionDataSet where
  parseJSON :: Value -> Parser RowLevelPermissionDataSet
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RowLevelPermissionDataSet"
      ( \Object
x ->
          Maybe RowLevelPermissionFormatVersion
-> Maybe Text
-> Maybe Status
-> Text
-> RowLevelPermissionPolicy
-> RowLevelPermissionDataSet
RowLevelPermissionDataSet'
            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
"FormatVersion")
            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
"Namespace")
            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
"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
"Arn")
            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
"PermissionPolicy")
      )

instance Prelude.Hashable RowLevelPermissionDataSet where
  hashWithSalt :: Int -> RowLevelPermissionDataSet -> Int
hashWithSalt Int
_salt RowLevelPermissionDataSet' {Maybe Text
Maybe RowLevelPermissionFormatVersion
Maybe Status
Text
RowLevelPermissionPolicy
permissionPolicy :: RowLevelPermissionPolicy
arn :: Text
status :: Maybe Status
namespace :: Maybe Text
formatVersion :: Maybe RowLevelPermissionFormatVersion
$sel:permissionPolicy:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> RowLevelPermissionPolicy
$sel:arn:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Text
$sel:status:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe Status
$sel:namespace:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe Text
$sel:formatVersion:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe RowLevelPermissionFormatVersion
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RowLevelPermissionFormatVersion
formatVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
namespace
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Status
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RowLevelPermissionPolicy
permissionPolicy

instance Prelude.NFData RowLevelPermissionDataSet where
  rnf :: RowLevelPermissionDataSet -> ()
rnf RowLevelPermissionDataSet' {Maybe Text
Maybe RowLevelPermissionFormatVersion
Maybe Status
Text
RowLevelPermissionPolicy
permissionPolicy :: RowLevelPermissionPolicy
arn :: Text
status :: Maybe Status
namespace :: Maybe Text
formatVersion :: Maybe RowLevelPermissionFormatVersion
$sel:permissionPolicy:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> RowLevelPermissionPolicy
$sel:arn:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Text
$sel:status:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe Status
$sel:namespace:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe Text
$sel:formatVersion:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe RowLevelPermissionFormatVersion
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RowLevelPermissionFormatVersion
formatVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
namespace
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RowLevelPermissionPolicy
permissionPolicy

instance Data.ToJSON RowLevelPermissionDataSet where
  toJSON :: RowLevelPermissionDataSet -> Value
toJSON RowLevelPermissionDataSet' {Maybe Text
Maybe RowLevelPermissionFormatVersion
Maybe Status
Text
RowLevelPermissionPolicy
permissionPolicy :: RowLevelPermissionPolicy
arn :: Text
status :: Maybe Status
namespace :: Maybe Text
formatVersion :: Maybe RowLevelPermissionFormatVersion
$sel:permissionPolicy:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> RowLevelPermissionPolicy
$sel:arn:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Text
$sel:status:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe Status
$sel:namespace:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe Text
$sel:formatVersion:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe RowLevelPermissionFormatVersion
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"FormatVersion" 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 RowLevelPermissionFormatVersion
formatVersion,
            (Key
"Namespace" 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
namespace,
            (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
"Arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
arn),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"PermissionPolicy" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RowLevelPermissionPolicy
permissionPolicy)
          ]
      )