{-# 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.Grafana.Types.RoleValues where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data RoleValues = RoleValues'
{
RoleValues -> Maybe [Text]
admin :: Prelude.Maybe [Prelude.Text],
RoleValues -> Maybe [Text]
editor :: Prelude.Maybe [Prelude.Text]
}
deriving (RoleValues -> RoleValues -> Bool
(RoleValues -> RoleValues -> Bool)
-> (RoleValues -> RoleValues -> Bool) -> Eq RoleValues
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RoleValues -> RoleValues -> Bool
$c/= :: RoleValues -> RoleValues -> Bool
== :: RoleValues -> RoleValues -> Bool
$c== :: RoleValues -> RoleValues -> Bool
Prelude.Eq, ReadPrec [RoleValues]
ReadPrec RoleValues
Int -> ReadS RoleValues
ReadS [RoleValues]
(Int -> ReadS RoleValues)
-> ReadS [RoleValues]
-> ReadPrec RoleValues
-> ReadPrec [RoleValues]
-> Read RoleValues
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RoleValues]
$creadListPrec :: ReadPrec [RoleValues]
readPrec :: ReadPrec RoleValues
$creadPrec :: ReadPrec RoleValues
readList :: ReadS [RoleValues]
$creadList :: ReadS [RoleValues]
readsPrec :: Int -> ReadS RoleValues
$creadsPrec :: Int -> ReadS RoleValues
Prelude.Read, Int -> RoleValues -> ShowS
[RoleValues] -> ShowS
RoleValues -> String
(Int -> RoleValues -> ShowS)
-> (RoleValues -> String)
-> ([RoleValues] -> ShowS)
-> Show RoleValues
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RoleValues] -> ShowS
$cshowList :: [RoleValues] -> ShowS
show :: RoleValues -> String
$cshow :: RoleValues -> String
showsPrec :: Int -> RoleValues -> ShowS
$cshowsPrec :: Int -> RoleValues -> ShowS
Prelude.Show, (forall x. RoleValues -> Rep RoleValues x)
-> (forall x. Rep RoleValues x -> RoleValues) -> Generic RoleValues
forall x. Rep RoleValues x -> RoleValues
forall x. RoleValues -> Rep RoleValues x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RoleValues x -> RoleValues
$cfrom :: forall x. RoleValues -> Rep RoleValues x
Prelude.Generic)
newRoleValues ::
RoleValues
newRoleValues :: RoleValues
newRoleValues =
RoleValues' :: Maybe [Text] -> Maybe [Text] -> RoleValues
RoleValues'
{ $sel:admin:RoleValues' :: Maybe [Text]
admin = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:editor:RoleValues' :: Maybe [Text]
editor = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
}
roleValues_admin :: Lens.Lens' RoleValues (Prelude.Maybe [Prelude.Text])
roleValues_admin :: (Maybe [Text] -> f (Maybe [Text])) -> RoleValues -> f RoleValues
roleValues_admin = (RoleValues -> Maybe [Text])
-> (RoleValues -> Maybe [Text] -> RoleValues)
-> Lens RoleValues RoleValues (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoleValues' {Maybe [Text]
admin :: Maybe [Text]
$sel:admin:RoleValues' :: RoleValues -> Maybe [Text]
admin} -> Maybe [Text]
admin) (\s :: RoleValues
s@RoleValues' {} Maybe [Text]
a -> RoleValues
s {$sel:admin:RoleValues' :: Maybe [Text]
admin = Maybe [Text]
a} :: RoleValues) ((Maybe [Text] -> f (Maybe [Text])) -> RoleValues -> f RoleValues)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> RoleValues
-> f RoleValues
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
roleValues_editor :: Lens.Lens' RoleValues (Prelude.Maybe [Prelude.Text])
roleValues_editor :: (Maybe [Text] -> f (Maybe [Text])) -> RoleValues -> f RoleValues
roleValues_editor = (RoleValues -> Maybe [Text])
-> (RoleValues -> Maybe [Text] -> RoleValues)
-> Lens RoleValues RoleValues (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoleValues' {Maybe [Text]
editor :: Maybe [Text]
$sel:editor:RoleValues' :: RoleValues -> Maybe [Text]
editor} -> Maybe [Text]
editor) (\s :: RoleValues
s@RoleValues' {} Maybe [Text]
a -> RoleValues
s {$sel:editor:RoleValues' :: Maybe [Text]
editor = Maybe [Text]
a} :: RoleValues) ((Maybe [Text] -> f (Maybe [Text])) -> RoleValues -> f RoleValues)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> RoleValues
-> f RoleValues
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON RoleValues where
parseJSON :: Value -> Parser RoleValues
parseJSON =
String
-> (Object -> Parser RoleValues) -> Value -> Parser RoleValues
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"RoleValues"
( \Object
x ->
Maybe [Text] -> Maybe [Text] -> RoleValues
RoleValues'
(Maybe [Text] -> Maybe [Text] -> RoleValues)
-> Parser (Maybe [Text]) -> Parser (Maybe [Text] -> RoleValues)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"admin" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
Parser (Maybe [Text] -> RoleValues)
-> Parser (Maybe [Text]) -> Parser RoleValues
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"editor" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable RoleValues
instance Prelude.NFData RoleValues
instance Core.ToJSON RoleValues where
toJSON :: RoleValues -> Value
toJSON RoleValues' {Maybe [Text]
editor :: Maybe [Text]
admin :: Maybe [Text]
$sel:editor:RoleValues' :: RoleValues -> Maybe [Text]
$sel:admin:RoleValues' :: RoleValues -> Maybe [Text]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"admin" 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]
admin,
(Text
"editor" 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]
editor
]
)