{-# LANGUAGE DeriveGeneric #-}
module Data.Connect.Lifecycle
( Lifecycle(..)
, emptyLifecycle
, defaultLifecycle
) where
import Data.Aeson
import Data.Connect.AesonHelpers
import Data.Connect.OrphanInstances ()
import GHC.Generics
import qualified Network.URI as NU
data Lifecycle = Lifecycle
{ Lifecycle -> Maybe URI
installed :: Maybe NU.URI
, Lifecycle -> Maybe URI
uninstalled :: Maybe NU.URI
, Lifecycle -> Maybe URI
enabled :: Maybe NU.URI
, Lifecycle -> Maybe URI
disabled :: Maybe NU.URI
} deriving (Int -> Lifecycle -> ShowS
[Lifecycle] -> ShowS
Lifecycle -> String
(Int -> Lifecycle -> ShowS)
-> (Lifecycle -> String)
-> ([Lifecycle] -> ShowS)
-> Show Lifecycle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Lifecycle] -> ShowS
$cshowList :: [Lifecycle] -> ShowS
show :: Lifecycle -> String
$cshow :: Lifecycle -> String
showsPrec :: Int -> Lifecycle -> ShowS
$cshowsPrec :: Int -> Lifecycle -> ShowS
Show, (forall x. Lifecycle -> Rep Lifecycle x)
-> (forall x. Rep Lifecycle x -> Lifecycle) -> Generic Lifecycle
forall x. Rep Lifecycle x -> Lifecycle
forall x. Lifecycle -> Rep Lifecycle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Lifecycle x -> Lifecycle
$cfrom :: forall x. Lifecycle -> Rep Lifecycle x
Generic)
instance ToJSON Lifecycle where
toJSON :: Lifecycle -> Value
toJSON = Options -> Lifecycle -> Value
forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Options -> a -> Value
genericToJSON Options
baseOptions
emptyLifecycle :: Lifecycle
emptyLifecycle :: Lifecycle
emptyLifecycle = Maybe URI -> Maybe URI -> Maybe URI -> Maybe URI -> Lifecycle
Lifecycle Maybe URI
forall a. Maybe a
Nothing Maybe URI
forall a. Maybe a
Nothing Maybe URI
forall a. Maybe a
Nothing Maybe URI
forall a. Maybe a
Nothing
defaultLifecycle :: Lifecycle
defaultLifecycle :: Lifecycle
defaultLifecycle = Lifecycle :: Maybe URI -> Maybe URI -> Maybe URI -> Maybe URI -> Lifecycle
Lifecycle
{ installed :: Maybe URI
installed = String -> Maybe URI
NU.parseRelativeReference String
"/installed"
, uninstalled :: Maybe URI
uninstalled = String -> Maybe URI
NU.parseRelativeReference String
"/uninstalled"
, enabled :: Maybe URI
enabled = String -> Maybe URI
NU.parseRelativeReference String
"/enabled"
, disabled :: Maybe URI
disabled = String -> Maybe URI
NU.parseRelativeReference String
"/disabled"
}