{-# LANGUAGE DataKinds #-}

module Hercules.API.Agent.State where

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

type ContentLength = Header "Content-Length" Integer

data StateAPI auth f = StateAPI
  { forall auth f.
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)),
    forall auth f.
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 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)