{-# 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-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.RowLevelPermissionDataSet where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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 namespace associated with the dataset that contains permissions for
    -- RLS.
    RowLevelPermissionDataSet -> Maybe Text
namespace :: Prelude.Maybe Prelude.Text,
    -- | 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 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
(RowLevelPermissionDataSet -> RowLevelPermissionDataSet -> Bool)
-> (RowLevelPermissionDataSet -> RowLevelPermissionDataSet -> Bool)
-> Eq RowLevelPermissionDataSet
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]
(Int -> ReadS RowLevelPermissionDataSet)
-> ReadS [RowLevelPermissionDataSet]
-> ReadPrec RowLevelPermissionDataSet
-> ReadPrec [RowLevelPermissionDataSet]
-> Read 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
(Int -> RowLevelPermissionDataSet -> ShowS)
-> (RowLevelPermissionDataSet -> String)
-> ([RowLevelPermissionDataSet] -> ShowS)
-> Show RowLevelPermissionDataSet
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.
 RowLevelPermissionDataSet -> Rep RowLevelPermissionDataSet x)
-> (forall x.
    Rep RowLevelPermissionDataSet x -> RowLevelPermissionDataSet)
-> Generic RowLevelPermissionDataSet
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:
--
-- 'status', 'rowLevelPermissionDataSet_status' - The status of the row-level security permission dataset. If enabled, the
-- status is @ENABLED@. If disabled, the status is @DISABLED@.
--
-- 'namespace', 'rowLevelPermissionDataSet_namespace' - The namespace associated with the dataset that contains permissions for
-- RLS.
--
-- '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.
--
-- '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' :: Maybe Status
-> Maybe Text
-> Maybe RowLevelPermissionFormatVersion
-> Text
-> RowLevelPermissionPolicy
-> RowLevelPermissionDataSet
RowLevelPermissionDataSet'
    { $sel:status:RowLevelPermissionDataSet' :: Maybe Status
status =
        Maybe Status
forall a. Maybe a
Prelude.Nothing,
      $sel:namespace:RowLevelPermissionDataSet' :: Maybe Text
namespace = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:formatVersion:RowLevelPermissionDataSet' :: Maybe RowLevelPermissionFormatVersion
formatVersion = Maybe RowLevelPermissionFormatVersion
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:RowLevelPermissionDataSet' :: Text
arn = Text
pArn_,
      $sel:permissionPolicy:RowLevelPermissionDataSet' :: RowLevelPermissionPolicy
permissionPolicy = RowLevelPermissionPolicy
pPermissionPolicy_
    }

-- | 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 :: (Maybe Status -> f (Maybe Status))
-> RowLevelPermissionDataSet -> f RowLevelPermissionDataSet
rowLevelPermissionDataSet_status = (RowLevelPermissionDataSet -> Maybe Status)
-> (RowLevelPermissionDataSet
    -> Maybe Status -> RowLevelPermissionDataSet)
-> Lens
     RowLevelPermissionDataSet
     RowLevelPermissionDataSet
     (Maybe Status)
     (Maybe 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 namespace associated with the dataset that contains permissions for
-- RLS.
rowLevelPermissionDataSet_namespace :: Lens.Lens' RowLevelPermissionDataSet (Prelude.Maybe Prelude.Text)
rowLevelPermissionDataSet_namespace :: (Maybe Text -> f (Maybe Text))
-> RowLevelPermissionDataSet -> f RowLevelPermissionDataSet
rowLevelPermissionDataSet_namespace = (RowLevelPermissionDataSet -> Maybe Text)
-> (RowLevelPermissionDataSet
    -> Maybe Text -> RowLevelPermissionDataSet)
-> Lens
     RowLevelPermissionDataSet
     RowLevelPermissionDataSet
     (Maybe Text)
     (Maybe Text)
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 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 :: (Maybe RowLevelPermissionFormatVersion
 -> f (Maybe RowLevelPermissionFormatVersion))
-> RowLevelPermissionDataSet -> f RowLevelPermissionDataSet
rowLevelPermissionDataSet_formatVersion = (RowLevelPermissionDataSet
 -> Maybe RowLevelPermissionFormatVersion)
-> (RowLevelPermissionDataSet
    -> Maybe RowLevelPermissionFormatVersion
    -> RowLevelPermissionDataSet)
-> Lens
     RowLevelPermissionDataSet
     RowLevelPermissionDataSet
     (Maybe RowLevelPermissionFormatVersion)
     (Maybe RowLevelPermissionFormatVersion)
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 Amazon Resource Name (ARN) of the dataset that contains permissions
-- for RLS.
rowLevelPermissionDataSet_arn :: Lens.Lens' RowLevelPermissionDataSet Prelude.Text
rowLevelPermissionDataSet_arn :: (Text -> f Text)
-> RowLevelPermissionDataSet -> f RowLevelPermissionDataSet
rowLevelPermissionDataSet_arn = (RowLevelPermissionDataSet -> Text)
-> (RowLevelPermissionDataSet -> Text -> RowLevelPermissionDataSet)
-> Lens
     RowLevelPermissionDataSet RowLevelPermissionDataSet Text Text
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 :: (RowLevelPermissionPolicy -> f RowLevelPermissionPolicy)
-> RowLevelPermissionDataSet -> f RowLevelPermissionDataSet
rowLevelPermissionDataSet_permissionPolicy = (RowLevelPermissionDataSet -> RowLevelPermissionPolicy)
-> (RowLevelPermissionDataSet
    -> RowLevelPermissionPolicy -> RowLevelPermissionDataSet)
-> Lens
     RowLevelPermissionDataSet
     RowLevelPermissionDataSet
     RowLevelPermissionPolicy
     RowLevelPermissionPolicy
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 Core.FromJSON RowLevelPermissionDataSet where
  parseJSON :: Value -> Parser RowLevelPermissionDataSet
parseJSON =
    String
-> (Object -> Parser RowLevelPermissionDataSet)
-> Value
-> Parser RowLevelPermissionDataSet
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RowLevelPermissionDataSet"
      ( \Object
x ->
          Maybe Status
-> Maybe Text
-> Maybe RowLevelPermissionFormatVersion
-> Text
-> RowLevelPermissionPolicy
-> RowLevelPermissionDataSet
RowLevelPermissionDataSet'
            (Maybe Status
 -> Maybe Text
 -> Maybe RowLevelPermissionFormatVersion
 -> Text
 -> RowLevelPermissionPolicy
 -> RowLevelPermissionDataSet)
-> Parser (Maybe Status)
-> Parser
     (Maybe Text
      -> Maybe RowLevelPermissionFormatVersion
      -> Text
      -> RowLevelPermissionPolicy
      -> RowLevelPermissionDataSet)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Status)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe Text
   -> Maybe RowLevelPermissionFormatVersion
   -> Text
   -> RowLevelPermissionPolicy
   -> RowLevelPermissionDataSet)
-> Parser (Maybe Text)
-> Parser
     (Maybe RowLevelPermissionFormatVersion
      -> Text -> RowLevelPermissionPolicy -> RowLevelPermissionDataSet)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Namespace")
            Parser
  (Maybe RowLevelPermissionFormatVersion
   -> Text -> RowLevelPermissionPolicy -> RowLevelPermissionDataSet)
-> Parser (Maybe RowLevelPermissionFormatVersion)
-> Parser
     (Text -> RowLevelPermissionPolicy -> RowLevelPermissionDataSet)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RowLevelPermissionFormatVersion)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FormatVersion")
            Parser
  (Text -> RowLevelPermissionPolicy -> RowLevelPermissionDataSet)
-> Parser Text
-> Parser (RowLevelPermissionPolicy -> RowLevelPermissionDataSet)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Arn")
            Parser (RowLevelPermissionPolicy -> RowLevelPermissionDataSet)
-> Parser RowLevelPermissionPolicy
-> Parser RowLevelPermissionDataSet
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser RowLevelPermissionPolicy
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"PermissionPolicy")
      )

instance Prelude.Hashable RowLevelPermissionDataSet

instance Prelude.NFData RowLevelPermissionDataSet

instance Core.ToJSON RowLevelPermissionDataSet where
  toJSON :: RowLevelPermissionDataSet -> Value
toJSON RowLevelPermissionDataSet' {Maybe Text
Maybe RowLevelPermissionFormatVersion
Maybe Status
Text
RowLevelPermissionPolicy
permissionPolicy :: RowLevelPermissionPolicy
arn :: Text
formatVersion :: Maybe RowLevelPermissionFormatVersion
namespace :: Maybe Text
status :: Maybe Status
$sel:permissionPolicy:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> RowLevelPermissionPolicy
$sel:arn:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Text
$sel:formatVersion:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe RowLevelPermissionFormatVersion
$sel:namespace:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe Text
$sel:status:RowLevelPermissionDataSet' :: RowLevelPermissionDataSet -> Maybe Status
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Status" Text -> Status -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Status -> Pair) -> Maybe Status -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Status
status,
            (Text
"Namespace" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
namespace,
            (Text
"FormatVersion" Text -> RowLevelPermissionFormatVersion -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RowLevelPermissionFormatVersion -> Pair)
-> Maybe RowLevelPermissionFormatVersion -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RowLevelPermissionFormatVersion
formatVersion,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Arn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
arn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"PermissionPolicy" Text -> RowLevelPermissionPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RowLevelPermissionPolicy
permissionPolicy)
          ]
      )