{-# LANGUAGE DataKinds #-}

module Hercules.API.Effects where

import Hercules.API.Attribute
import Hercules.API.Build.Log (Log)
import Hercules.API.Effects.EffectInfo
import Hercules.API.Prelude
import Hercules.API.Projects.Job (Job)
import Servant.API (Capture, Get, JSON, NoContent, Optional, Post, QueryParam', Required, Summary, (:>))
import Servant.API.Generic (GenericMode ((:-)))

data EffectsAPI auth f = EffectsAPI
  { forall auth f.
EffectsAPI auth f
-> f
   :- (Summary "Read effect events"
       :> ("jobs"
           :> (Capture "jobId" (Id Job)
               :> ("effects"
                   :> (Capture "attribute" AttributePath
                       :> (auth :> Get '[JSON] EffectInfo))))))
getEffect ::
      f
        :- Summary "Read effect events"
          :> "jobs"
          :> Capture "jobId" (Id Job)
          :> "effects"
          :> Capture "attribute" AttributePath
          :> auth
          :> Get '[JSON] EffectInfo,
    forall auth f.
EffectsAPI auth f
-> f
   :- (Summary "Read all recorded log entries"
       :> ("jobs"
           :> (Capture "jobId" (Id Job)
               :> ("effects"
                   :> (Capture "attribute" AttributePath
                       :> ("log"
                           :> ("lines"
                               :> (QueryParam' '[Required] "logId" (Id "log")
                                   :> (QueryParam' '[Optional] "iMin" Int
                                       :> (auth :> Get '[JSON] Log))))))))))
getEffectLog ::
      f
        :- Summary "Read all recorded log entries"
          :> "jobs"
          :> Capture "jobId" (Id Job)
          :> "effects"
          :> Capture "attribute" AttributePath
          :> "log"
          :> "lines"
          :> QueryParam' '[Required] "logId" (Id "log")
          :> QueryParam' '[Optional] "iMin" Int
          :> auth
          :> Get '[JSON] Log,
    forall auth f.
EffectsAPI auth f
-> f
   :- (Summary
         "Cancel the effect. It will cause the Job to have a failed status."
       :> ("jobs"
           :> (Capture "jobId" (Id Job)
               :> ("effects"
                   :> (Capture "attribute" AttributePath
                       :> ("cancel" :> (auth :> Post '[JSON] NoContent)))))))
cancelEffect ::
      f
        :- Summary "Cancel the effect. It will cause the Job to have a failed status."
          :> "jobs"
          :> Capture "jobId" (Id Job)
          :> "effects"
          :> Capture "attribute" AttributePath
          :> "cancel"
          :> auth
          :> Post '[JSON] NoContent
  }
  deriving (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall auth f x. Rep (EffectsAPI auth f) x -> EffectsAPI auth f
forall auth f x. EffectsAPI auth f -> Rep (EffectsAPI auth f) x
$cto :: forall auth f x. Rep (EffectsAPI auth f) x -> EffectsAPI auth f
$cfrom :: forall auth f x. EffectsAPI auth f -> Rep (EffectsAPI auth f) x
Generic)