{-# LANGUAGE DataKinds #-}

module Hercules.API.Agent.State where

import Data.ByteString (ByteString)
import Hercules.API.Prelude
import Servant.API
import Servant.API.Generic

type ContentLength = Header "Content-Length" Integer

data StateAPI auth f = StateAPI
  { StateAPI auth f
-> f
   :- ("current-task"
       :> ("state"
           :> (Capture' '[Required] "name" Text
               :> ("data"
                   :> (auth
                       :> StreamGet
                            NoFraming
                            OctetStream
                            (Headers '[ContentLength] (SourceIO ByteString)))))))
getState ::
      f
        :- "current-task"
        :> "state"
        :> Capture' '[Required] "name" Text
        :> "data"
        :> auth
        :> StreamGet NoFraming OctetStream (Headers '[ContentLength] (SourceIO ByteString)),
    StateAPI auth f
-> f
   :- ("current-task"
       :> ("state"
           :> (Capture' '[Required] "name" Text
               :> ("data"
                   :> (StreamBody NoFraming OctetStream (SourceIO ByteString)
                       :> (ContentLength :> (auth :> Put '[JSON] NoContent)))))))
putState ::
      f
        :- "current-task"
        :> "state"
        :> Capture' '[Required] "name" Text
        :> "data"
        :> StreamBody NoFraming OctetStream (SourceIO ByteString)
        :> ContentLength
        :> auth
        :> Put '[JSON] NoContent
  }
  deriving ((forall x. StateAPI auth f -> Rep (StateAPI auth f) x)
-> (forall x. Rep (StateAPI auth f) x -> StateAPI auth f)
-> Generic (StateAPI auth f)
forall x. Rep (StateAPI auth f) x -> StateAPI auth f
forall x. StateAPI auth f -> Rep (StateAPI auth f) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall auth f x. Rep (StateAPI auth f) x -> StateAPI auth f
forall auth f x. StateAPI auth f -> Rep (StateAPI auth f) x
$cto :: forall auth f x. Rep (StateAPI auth f) x -> StateAPI auth f
$cfrom :: forall auth f x. StateAPI auth f -> Rep (StateAPI auth f) x
Generic)