{-# 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 #-}
module Amazonka.QuickSight.Types.ResourcePermission where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data ResourcePermission = ResourcePermission'
{
ResourcePermission -> Text
principal :: Prelude.Text,
ResourcePermission -> NonEmpty Text
actions :: Prelude.NonEmpty Prelude.Text
}
deriving (ResourcePermission -> ResourcePermission -> Bool
(ResourcePermission -> ResourcePermission -> Bool)
-> (ResourcePermission -> ResourcePermission -> Bool)
-> Eq ResourcePermission
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourcePermission -> ResourcePermission -> Bool
$c/= :: ResourcePermission -> ResourcePermission -> Bool
== :: ResourcePermission -> ResourcePermission -> Bool
$c== :: ResourcePermission -> ResourcePermission -> Bool
Prelude.Eq, ReadPrec [ResourcePermission]
ReadPrec ResourcePermission
Int -> ReadS ResourcePermission
ReadS [ResourcePermission]
(Int -> ReadS ResourcePermission)
-> ReadS [ResourcePermission]
-> ReadPrec ResourcePermission
-> ReadPrec [ResourcePermission]
-> Read ResourcePermission
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourcePermission]
$creadListPrec :: ReadPrec [ResourcePermission]
readPrec :: ReadPrec ResourcePermission
$creadPrec :: ReadPrec ResourcePermission
readList :: ReadS [ResourcePermission]
$creadList :: ReadS [ResourcePermission]
readsPrec :: Int -> ReadS ResourcePermission
$creadsPrec :: Int -> ReadS ResourcePermission
Prelude.Read, Int -> ResourcePermission -> ShowS
[ResourcePermission] -> ShowS
ResourcePermission -> String
(Int -> ResourcePermission -> ShowS)
-> (ResourcePermission -> String)
-> ([ResourcePermission] -> ShowS)
-> Show ResourcePermission
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourcePermission] -> ShowS
$cshowList :: [ResourcePermission] -> ShowS
show :: ResourcePermission -> String
$cshow :: ResourcePermission -> String
showsPrec :: Int -> ResourcePermission -> ShowS
$cshowsPrec :: Int -> ResourcePermission -> ShowS
Prelude.Show, (forall x. ResourcePermission -> Rep ResourcePermission x)
-> (forall x. Rep ResourcePermission x -> ResourcePermission)
-> Generic ResourcePermission
forall x. Rep ResourcePermission x -> ResourcePermission
forall x. ResourcePermission -> Rep ResourcePermission x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourcePermission x -> ResourcePermission
$cfrom :: forall x. ResourcePermission -> Rep ResourcePermission x
Prelude.Generic)
newResourcePermission ::
Prelude.Text ->
Prelude.NonEmpty Prelude.Text ->
ResourcePermission
newResourcePermission :: Text -> NonEmpty Text -> ResourcePermission
newResourcePermission Text
pPrincipal_ NonEmpty Text
pActions_ =
ResourcePermission' :: Text -> NonEmpty Text -> ResourcePermission
ResourcePermission'
{ $sel:principal:ResourcePermission' :: Text
principal = Text
pPrincipal_,
$sel:actions:ResourcePermission' :: NonEmpty Text
actions = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pActions_
}
resourcePermission_principal :: Lens.Lens' ResourcePermission Prelude.Text
resourcePermission_principal :: (Text -> f Text) -> ResourcePermission -> f ResourcePermission
resourcePermission_principal = (ResourcePermission -> Text)
-> (ResourcePermission -> Text -> ResourcePermission)
-> Lens ResourcePermission ResourcePermission Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourcePermission' {Text
principal :: Text
$sel:principal:ResourcePermission' :: ResourcePermission -> Text
principal} -> Text
principal) (\s :: ResourcePermission
s@ResourcePermission' {} Text
a -> ResourcePermission
s {$sel:principal:ResourcePermission' :: Text
principal = Text
a} :: ResourcePermission)
resourcePermission_actions :: Lens.Lens' ResourcePermission (Prelude.NonEmpty Prelude.Text)
resourcePermission_actions :: (NonEmpty Text -> f (NonEmpty Text))
-> ResourcePermission -> f ResourcePermission
resourcePermission_actions = (ResourcePermission -> NonEmpty Text)
-> (ResourcePermission -> NonEmpty Text -> ResourcePermission)
-> Lens
ResourcePermission
ResourcePermission
(NonEmpty Text)
(NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourcePermission' {NonEmpty Text
actions :: NonEmpty Text
$sel:actions:ResourcePermission' :: ResourcePermission -> NonEmpty Text
actions} -> NonEmpty Text
actions) (\s :: ResourcePermission
s@ResourcePermission' {} NonEmpty Text
a -> ResourcePermission
s {$sel:actions:ResourcePermission' :: NonEmpty Text
actions = NonEmpty Text
a} :: ResourcePermission) ((NonEmpty Text -> f (NonEmpty Text))
-> ResourcePermission -> f ResourcePermission)
-> ((NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> ResourcePermission
-> f ResourcePermission
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON ResourcePermission where
parseJSON :: Value -> Parser ResourcePermission
parseJSON =
String
-> (Object -> Parser ResourcePermission)
-> Value
-> Parser ResourcePermission
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"ResourcePermission"
( \Object
x ->
Text -> NonEmpty Text -> ResourcePermission
ResourcePermission'
(Text -> NonEmpty Text -> ResourcePermission)
-> Parser Text -> Parser (NonEmpty Text -> ResourcePermission)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Principal")
Parser (NonEmpty Text -> ResourcePermission)
-> Parser (NonEmpty Text) -> Parser ResourcePermission
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Actions")
)
instance Prelude.Hashable ResourcePermission
instance Prelude.NFData ResourcePermission
instance Core.ToJSON ResourcePermission where
toJSON :: ResourcePermission -> Value
toJSON ResourcePermission' {NonEmpty Text
Text
actions :: NonEmpty Text
principal :: Text
$sel:actions:ResourcePermission' :: ResourcePermission -> NonEmpty Text
$sel:principal:ResourcePermission' :: ResourcePermission -> 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
"Principal" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
principal),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Actions" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
actions)
]
)