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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(RowLevelPermissionTagConfiguration
 -> RowLevelPermissionTagConfiguration -> Bool)
-> (RowLevelPermissionTagConfiguration
    -> RowLevelPermissionTagConfiguration -> Bool)
-> Eq RowLevelPermissionTagConfiguration
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
(Int -> RowLevelPermissionTagConfiguration -> ShowS)
-> (RowLevelPermissionTagConfiguration -> String)
-> ([RowLevelPermissionTagConfiguration] -> ShowS)
-> Show RowLevelPermissionTagConfiguration
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.
 RowLevelPermissionTagConfiguration
 -> Rep RowLevelPermissionTagConfiguration x)
-> (forall x.
    Rep RowLevelPermissionTagConfiguration x
    -> RowLevelPermissionTagConfiguration)
-> Generic RowLevelPermissionTagConfiguration
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' :: Maybe Status
-> NonEmpty RowLevelPermissionTagRule
-> RowLevelPermissionTagConfiguration
RowLevelPermissionTagConfiguration'
    { $sel:status:RowLevelPermissionTagConfiguration' :: Maybe Status
status =
        Maybe Status
forall a. Maybe a
Prelude.Nothing,
      $sel:tagRules:RowLevelPermissionTagConfiguration' :: NonEmpty RowLevelPermissionTagRule
tagRules =
        Tagged
  (NonEmpty RowLevelPermissionTagRule)
  (Identity (NonEmpty RowLevelPermissionTagRule))
-> Tagged
     (NonEmpty RowLevelPermissionTagRule)
     (Identity (NonEmpty RowLevelPermissionTagRule))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty RowLevelPermissionTagRule)
   (Identity (NonEmpty RowLevelPermissionTagRule))
 -> Tagged
      (NonEmpty RowLevelPermissionTagRule)
      (Identity (NonEmpty RowLevelPermissionTagRule)))
-> NonEmpty RowLevelPermissionTagRule
-> NonEmpty RowLevelPermissionTagRule
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 :: (Maybe Status -> f (Maybe Status))
-> RowLevelPermissionTagConfiguration
-> f RowLevelPermissionTagConfiguration
rowLevelPermissionTagConfiguration_status = (RowLevelPermissionTagConfiguration -> Maybe Status)
-> (RowLevelPermissionTagConfiguration
    -> Maybe Status -> RowLevelPermissionTagConfiguration)
-> Lens
     RowLevelPermissionTagConfiguration
     RowLevelPermissionTagConfiguration
     (Maybe Status)
     (Maybe 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 :: (NonEmpty RowLevelPermissionTagRule
 -> f (NonEmpty RowLevelPermissionTagRule))
-> RowLevelPermissionTagConfiguration
-> f RowLevelPermissionTagConfiguration
rowLevelPermissionTagConfiguration_tagRules = (RowLevelPermissionTagConfiguration
 -> NonEmpty RowLevelPermissionTagRule)
-> (RowLevelPermissionTagConfiguration
    -> NonEmpty RowLevelPermissionTagRule
    -> RowLevelPermissionTagConfiguration)
-> Lens
     RowLevelPermissionTagConfiguration
     RowLevelPermissionTagConfiguration
     (NonEmpty RowLevelPermissionTagRule)
     (NonEmpty RowLevelPermissionTagRule)
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) ((NonEmpty RowLevelPermissionTagRule
  -> f (NonEmpty RowLevelPermissionTagRule))
 -> RowLevelPermissionTagConfiguration
 -> f RowLevelPermissionTagConfiguration)
-> ((NonEmpty RowLevelPermissionTagRule
     -> f (NonEmpty RowLevelPermissionTagRule))
    -> NonEmpty RowLevelPermissionTagRule
    -> f (NonEmpty RowLevelPermissionTagRule))
-> (NonEmpty RowLevelPermissionTagRule
    -> f (NonEmpty RowLevelPermissionTagRule))
-> RowLevelPermissionTagConfiguration
-> f RowLevelPermissionTagConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty RowLevelPermissionTagRule
 -> f (NonEmpty RowLevelPermissionTagRule))
-> NonEmpty RowLevelPermissionTagRule
-> f (NonEmpty RowLevelPermissionTagRule)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.Hashable
    RowLevelPermissionTagConfiguration

instance
  Prelude.NFData
    RowLevelPermissionTagConfiguration

instance
  Core.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
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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TagRules" Text -> NonEmpty RowLevelPermissionTagRule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty RowLevelPermissionTagRule
tagRules)
          ]
      )