{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}

module Hercules.API.Effects.EffectInfo where

import Data.OpenApi qualified as O3
import Hercules.API.Build.DerivationInfo.DerivationInput (DerivationInput)
import Hercules.API.Effects.EffectEvent (EffectEvent)
import Hercules.API.Effects.EffectReference (EffectReference)
import Hercules.API.Prelude
import Hercules.API.Projects.Job (Job)
import Hercules.API.Projects.Project (Project)
import Hercules.API.Projects.SimpleJob (SimpleJob)

data EffectStatus
  = Waiting
  | Running
  | Failed
  | DependencyFailed
  | Successful
  | Cancelled
  deriving ((forall x. EffectStatus -> Rep EffectStatus x)
-> (forall x. Rep EffectStatus x -> EffectStatus)
-> Generic EffectStatus
forall x. Rep EffectStatus x -> EffectStatus
forall x. EffectStatus -> Rep EffectStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. EffectStatus -> Rep EffectStatus x
from :: forall x. EffectStatus -> Rep EffectStatus x
$cto :: forall x. Rep EffectStatus x -> EffectStatus
to :: forall x. Rep EffectStatus x -> EffectStatus
Generic, Int -> EffectStatus -> ShowS
[EffectStatus] -> ShowS
EffectStatus -> String
(Int -> EffectStatus -> ShowS)
-> (EffectStatus -> String)
-> ([EffectStatus] -> ShowS)
-> Show EffectStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EffectStatus -> ShowS
showsPrec :: Int -> EffectStatus -> ShowS
$cshow :: EffectStatus -> String
show :: EffectStatus -> String
$cshowList :: [EffectStatus] -> ShowS
showList :: [EffectStatus] -> ShowS
Show, EffectStatus -> EffectStatus -> Bool
(EffectStatus -> EffectStatus -> Bool)
-> (EffectStatus -> EffectStatus -> Bool) -> Eq EffectStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EffectStatus -> EffectStatus -> Bool
== :: EffectStatus -> EffectStatus -> Bool
$c/= :: EffectStatus -> EffectStatus -> Bool
/= :: EffectStatus -> EffectStatus -> Bool
Eq)
  deriving anyclass (EffectStatus -> ()
(EffectStatus -> ()) -> NFData EffectStatus
forall a. (a -> ()) -> NFData a
$crnf :: EffectStatus -> ()
rnf :: EffectStatus -> ()
NFData, [EffectStatus] -> Value
[EffectStatus] -> Encoding
EffectStatus -> Value
EffectStatus -> Encoding
(EffectStatus -> Value)
-> (EffectStatus -> Encoding)
-> ([EffectStatus] -> Value)
-> ([EffectStatus] -> Encoding)
-> ToJSON EffectStatus
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: EffectStatus -> Value
toJSON :: EffectStatus -> Value
$ctoEncoding :: EffectStatus -> Encoding
toEncoding :: EffectStatus -> Encoding
$ctoJSONList :: [EffectStatus] -> Value
toJSONList :: [EffectStatus] -> Value
$ctoEncodingList :: [EffectStatus] -> Encoding
toEncodingList :: [EffectStatus] -> Encoding
ToJSON, Value -> Parser [EffectStatus]
Value -> Parser EffectStatus
(Value -> Parser EffectStatus)
-> (Value -> Parser [EffectStatus]) -> FromJSON EffectStatus
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser EffectStatus
parseJSON :: Value -> Parser EffectStatus
$cparseJSONList :: Value -> Parser [EffectStatus]
parseJSONList :: Value -> Parser [EffectStatus]
FromJSON, Proxy EffectStatus -> Declare (Definitions Schema) NamedSchema
(Proxy EffectStatus -> Declare (Definitions Schema) NamedSchema)
-> ToSchema EffectStatus
forall a.
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy EffectStatus -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy EffectStatus -> Declare (Definitions Schema) NamedSchema
ToSchema, Typeable EffectStatus
Typeable EffectStatus
-> (Proxy EffectStatus -> Declare (Definitions Schema) NamedSchema)
-> ToSchema EffectStatus
Proxy EffectStatus -> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a
-> (Proxy a -> Declare (Definitions Schema) NamedSchema)
-> ToSchema a
$cdeclareNamedSchema :: Proxy EffectStatus -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy EffectStatus -> Declare (Definitions Schema) NamedSchema
O3.ToSchema)

data EffectInfo = EffectInfo
  { EffectInfo -> EffectStatus
status :: EffectStatus,
    EffectInfo -> Id Job
jobId :: Id Job,
    EffectInfo -> Id Project
projectId :: Id Project,
    EffectInfo -> Text
platform :: Text,
    EffectInfo -> [Text]
requiredSystemFeatures :: [Text],
    EffectInfo -> [DerivationInput]
inputDerivations :: [DerivationInput],
    EffectInfo -> [[EffectEvent]]
events :: [[EffectEvent]],
    EffectInfo -> [EffectReference]
waitingForEffects :: [EffectReference],
    EffectInfo -> [SimpleJob]
waitingForJobs :: [SimpleJob],
    EffectInfo -> Bool
mayCancel :: Bool,
    EffectInfo -> Maybe EffectEvent
dummy :: Maybe EffectEvent -- TODO: remove and update/fix codegen
  }
  deriving ((forall x. EffectInfo -> Rep EffectInfo x)
-> (forall x. Rep EffectInfo x -> EffectInfo) -> Generic EffectInfo
forall x. Rep EffectInfo x -> EffectInfo
forall x. EffectInfo -> Rep EffectInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. EffectInfo -> Rep EffectInfo x
from :: forall x. EffectInfo -> Rep EffectInfo x
$cto :: forall x. Rep EffectInfo x -> EffectInfo
to :: forall x. Rep EffectInfo x -> EffectInfo
Generic, Int -> EffectInfo -> ShowS
[EffectInfo] -> ShowS
EffectInfo -> String
(Int -> EffectInfo -> ShowS)
-> (EffectInfo -> String)
-> ([EffectInfo] -> ShowS)
-> Show EffectInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EffectInfo -> ShowS
showsPrec :: Int -> EffectInfo -> ShowS
$cshow :: EffectInfo -> String
show :: EffectInfo -> String
$cshowList :: [EffectInfo] -> ShowS
showList :: [EffectInfo] -> ShowS
Show, EffectInfo -> EffectInfo -> Bool
(EffectInfo -> EffectInfo -> Bool)
-> (EffectInfo -> EffectInfo -> Bool) -> Eq EffectInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EffectInfo -> EffectInfo -> Bool
== :: EffectInfo -> EffectInfo -> Bool
$c/= :: EffectInfo -> EffectInfo -> Bool
/= :: EffectInfo -> EffectInfo -> Bool
Eq)
  deriving anyclass (EffectInfo -> ()
(EffectInfo -> ()) -> NFData EffectInfo
forall a. (a -> ()) -> NFData a
$crnf :: EffectInfo -> ()
rnf :: EffectInfo -> ()
NFData, [EffectInfo] -> Value
[EffectInfo] -> Encoding
EffectInfo -> Value
EffectInfo -> Encoding
(EffectInfo -> Value)
-> (EffectInfo -> Encoding)
-> ([EffectInfo] -> Value)
-> ([EffectInfo] -> Encoding)
-> ToJSON EffectInfo
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: EffectInfo -> Value
toJSON :: EffectInfo -> Value
$ctoEncoding :: EffectInfo -> Encoding
toEncoding :: EffectInfo -> Encoding
$ctoJSONList :: [EffectInfo] -> Value
toJSONList :: [EffectInfo] -> Value
$ctoEncodingList :: [EffectInfo] -> Encoding
toEncodingList :: [EffectInfo] -> Encoding
ToJSON, Value -> Parser [EffectInfo]
Value -> Parser EffectInfo
(Value -> Parser EffectInfo)
-> (Value -> Parser [EffectInfo]) -> FromJSON EffectInfo
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser EffectInfo
parseJSON :: Value -> Parser EffectInfo
$cparseJSONList :: Value -> Parser [EffectInfo]
parseJSONList :: Value -> Parser [EffectInfo]
FromJSON, Proxy EffectInfo -> Declare (Definitions Schema) NamedSchema
(Proxy EffectInfo -> Declare (Definitions Schema) NamedSchema)
-> ToSchema EffectInfo
forall a.
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy EffectInfo -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy EffectInfo -> Declare (Definitions Schema) NamedSchema
ToSchema, Typeable EffectInfo
Typeable EffectInfo
-> (Proxy EffectInfo -> Declare (Definitions Schema) NamedSchema)
-> ToSchema EffectInfo
Proxy EffectInfo -> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a
-> (Proxy a -> Declare (Definitions Schema) NamedSchema)
-> ToSchema a
$cdeclareNamedSchema :: Proxy EffectInfo -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy EffectInfo -> Declare (Definitions Schema) NamedSchema
O3.ToSchema)