{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}

-- | The zuul tenant data type
module Zuul.Tenant (Tenant (..)) where

import Data.Aeson (FromJSON (..), ToJSON (..))
import Data.Text (Text)
import GHC.Generics (Generic)
import Zuul.Aeson (zuulParseJSON, zuulToJSON)

data Tenant = Tenant
  { Tenant -> Text
tenantName :: Text,
    Tenant -> Int
tenantProjects :: Int,
    Tenant -> Int
tenantQueue :: Int
  }
  deriving (Int -> Tenant -> ShowS
[Tenant] -> ShowS
Tenant -> String
(Int -> Tenant -> ShowS)
-> (Tenant -> String) -> ([Tenant] -> ShowS) -> Show Tenant
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Tenant] -> ShowS
$cshowList :: [Tenant] -> ShowS
show :: Tenant -> String
$cshow :: Tenant -> String
showsPrec :: Int -> Tenant -> ShowS
$cshowsPrec :: Int -> Tenant -> ShowS
Show, Tenant -> Tenant -> Bool
(Tenant -> Tenant -> Bool)
-> (Tenant -> Tenant -> Bool) -> Eq Tenant
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Tenant -> Tenant -> Bool
$c/= :: Tenant -> Tenant -> Bool
== :: Tenant -> Tenant -> Bool
$c== :: Tenant -> Tenant -> Bool
Eq, Eq Tenant
Eq Tenant
-> (Tenant -> Tenant -> Ordering)
-> (Tenant -> Tenant -> Bool)
-> (Tenant -> Tenant -> Bool)
-> (Tenant -> Tenant -> Bool)
-> (Tenant -> Tenant -> Bool)
-> (Tenant -> Tenant -> Tenant)
-> (Tenant -> Tenant -> Tenant)
-> Ord Tenant
Tenant -> Tenant -> Bool
Tenant -> Tenant -> Ordering
Tenant -> Tenant -> Tenant
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Tenant -> Tenant -> Tenant
$cmin :: Tenant -> Tenant -> Tenant
max :: Tenant -> Tenant -> Tenant
$cmax :: Tenant -> Tenant -> Tenant
>= :: Tenant -> Tenant -> Bool
$c>= :: Tenant -> Tenant -> Bool
> :: Tenant -> Tenant -> Bool
$c> :: Tenant -> Tenant -> Bool
<= :: Tenant -> Tenant -> Bool
$c<= :: Tenant -> Tenant -> Bool
< :: Tenant -> Tenant -> Bool
$c< :: Tenant -> Tenant -> Bool
compare :: Tenant -> Tenant -> Ordering
$ccompare :: Tenant -> Tenant -> Ordering
$cp1Ord :: Eq Tenant
Ord, (forall x. Tenant -> Rep Tenant x)
-> (forall x. Rep Tenant x -> Tenant) -> Generic Tenant
forall x. Rep Tenant x -> Tenant
forall x. Tenant -> Rep Tenant x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Tenant x -> Tenant
$cfrom :: forall x. Tenant -> Rep Tenant x
Generic)

instance ToJSON Tenant where
  toJSON :: Tenant -> Value
toJSON = Text -> Tenant -> Value
forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Text -> a -> Value
zuulToJSON Text
"tenant"

instance FromJSON Tenant where
  parseJSON :: Value -> Parser Tenant
parseJSON = Text -> Value -> Parser Tenant
forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Text -> Value -> Parser a
zuulParseJSON Text
"tenant"