{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Data.Connect.Scopes
( ProductScope(..)
) where
import Control.Monad (mzero)
import Data.Aeson
import GHC.Generics
data ProductScope
= Read
| Write
| Delete
| ProjectAdmin
| SpaceAdmin
| Admin
| ActAsUser
deriving (Int -> ProductScope -> ShowS
[ProductScope] -> ShowS
ProductScope -> String
(Int -> ProductScope -> ShowS)
-> (ProductScope -> String)
-> ([ProductScope] -> ShowS)
-> Show ProductScope
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProductScope] -> ShowS
$cshowList :: [ProductScope] -> ShowS
show :: ProductScope -> String
$cshow :: ProductScope -> String
showsPrec :: Int -> ProductScope -> ShowS
$cshowsPrec :: Int -> ProductScope -> ShowS
Show, ProductScope -> ProductScope -> Bool
(ProductScope -> ProductScope -> Bool)
-> (ProductScope -> ProductScope -> Bool) -> Eq ProductScope
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProductScope -> ProductScope -> Bool
$c/= :: ProductScope -> ProductScope -> Bool
== :: ProductScope -> ProductScope -> Bool
$c== :: ProductScope -> ProductScope -> Bool
Eq, (forall x. ProductScope -> Rep ProductScope x)
-> (forall x. Rep ProductScope x -> ProductScope)
-> Generic ProductScope
forall x. Rep ProductScope x -> ProductScope
forall x. ProductScope -> Rep ProductScope x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProductScope x -> ProductScope
$cfrom :: forall x. ProductScope -> Rep ProductScope x
Generic)
instance ToJSON ProductScope where
toJSON :: ProductScope -> Value
toJSON ProductScope
Read = Value
"read"
toJSON ProductScope
Write = Value
"write"
toJSON ProductScope
Delete = Value
"delete"
toJSON ProductScope
ProjectAdmin = Value
"project_admin"
toJSON ProductScope
SpaceAdmin = Value
"space_admin"
toJSON ProductScope
Admin = Value
"admin"
toJSON ProductScope
ActAsUser = Value
"act_as_user"
instance FromJSON ProductScope where
parseJSON :: Value -> Parser ProductScope
parseJSON (String Text
"read") = ProductScope -> Parser ProductScope
forall (m :: * -> *) a. Monad m => a -> m a
return ProductScope
Read
parseJSON (String Text
"write") = ProductScope -> Parser ProductScope
forall (m :: * -> *) a. Monad m => a -> m a
return ProductScope
Write
parseJSON (String Text
"delete") = ProductScope -> Parser ProductScope
forall (m :: * -> *) a. Monad m => a -> m a
return ProductScope
Delete
parseJSON (String Text
"project_admin") = ProductScope -> Parser ProductScope
forall (m :: * -> *) a. Monad m => a -> m a
return ProductScope
ProjectAdmin
parseJSON (String Text
"space_admin") = ProductScope -> Parser ProductScope
forall (m :: * -> *) a. Monad m => a -> m a
return ProductScope
SpaceAdmin
parseJSON (String Text
"admin") = ProductScope -> Parser ProductScope
forall (m :: * -> *) a. Monad m => a -> m a
return ProductScope
Admin
parseJSON (String Text
"act_as_user") = ProductScope -> Parser ProductScope
forall (m :: * -> *) a. Monad m => a -> m a
return ProductScope
ActAsUser
parseJSON Value
_ = Parser ProductScope
forall (m :: * -> *) a. MonadPlus m => m a
mzero