Add make-public end-point
This commit is contained in:
parent
9260d74b08
commit
322609ec0f
@ -9,6 +9,12 @@ import PersistSHA1
|
||||
import Data.Text as T
|
||||
|
||||
import Handler.Runner
|
||||
import Handler.JWT
|
||||
|
||||
getMakePublicJsonR :: SubmissionId -> Handler Value
|
||||
getMakePublicJsonR submissionId = do
|
||||
Entity userId _ <- requireAuthPossiblyByToken
|
||||
runViewProgressAsynchronously $ doMakePublic userId submissionId
|
||||
|
||||
getMakePublicR :: SubmissionId -> Handler TypedContent
|
||||
getMakePublicR submissionId = do
|
||||
|
@ -18,7 +18,6 @@ import qualified Yesod.Table as Table
|
||||
import Control.Concurrent.Lifted (threadDelay)
|
||||
|
||||
import Data.Time.LocalTime
|
||||
import Data.Time.Clock
|
||||
|
||||
import qualified Data.List.Utils as DLU
|
||||
|
||||
@ -667,6 +666,36 @@ challengeSubmissionApi = spec & definitions .~ defs
|
||||
(defs, spec) = runDeclare declareChallengeSubmissionSwagger mempty
|
||||
|
||||
|
||||
declareMakePublicSwagger :: Declare (Definitions Schema) Swagger
|
||||
declareMakePublicSwagger = do
|
||||
-- param schemas
|
||||
let idSchema = toParamSchema (Proxy :: Proxy Int)
|
||||
|
||||
asyncJobResponse <- declareResponse (Proxy :: Proxy Int)
|
||||
wrongSubmissionResponse <- declareResponse (Proxy :: Proxy GonitoStatus)
|
||||
|
||||
return $ mempty
|
||||
& paths .~
|
||||
fromList [ ("/api/make-public/{submissionId}",
|
||||
mempty & DS.get ?~ (mempty
|
||||
& parameters .~ [ Inline $ mempty
|
||||
& name .~ "submissionId"
|
||||
& required ?~ True
|
||||
& schema .~ ParamOther (mempty
|
||||
& in_ .~ ParamPath
|
||||
& paramSchema .~ idSchema)]
|
||||
& produces ?~ MimeList ["application/json"]
|
||||
& description ?~ "Initiates opening a submission. Returns an asynchrous job ID."
|
||||
& at 200 ?~ Inline asyncJobResponse
|
||||
& at 422 ?~ Inline wrongSubmissionResponse))
|
||||
]
|
||||
|
||||
makePublicApi :: Swagger
|
||||
makePublicApi = spec & definitions .~ defs
|
||||
where
|
||||
(defs, spec) = runDeclare declareMakePublicSwagger mempty
|
||||
|
||||
|
||||
data ChallangeSubmissionStatus = SubmissionOK | SubmissionWrong Text
|
||||
deriving (Eq, Show)
|
||||
|
||||
|
@ -27,6 +27,7 @@ apiDescription = generalApi
|
||||
<> challengeReadmeInMarkdownApi
|
||||
<> queryApi
|
||||
<> challengeSubmissionApi
|
||||
<> makePublicApi
|
||||
<> versionInfoApi
|
||||
<> listTagsApi
|
||||
<> myTeamsApi
|
||||
|
@ -25,6 +25,8 @@
|
||||
/api/user-info UserInfoR GET
|
||||
/api/add-user AddUserR GET
|
||||
/api/challenge-submission/#Text ChallengeSubmissionJsonR POST
|
||||
/api/make-public/#SubmissionId MakePublicJsonR GET
|
||||
|
||||
/api/challenge-readme/#Text/markdown ChallengeReadmeInMarkdownR GET
|
||||
/api/challenge-img/#Text ChallengeImgR GET
|
||||
/api/query/#Text QueryJsonR GET
|
||||
|
Loading…
Reference in New Issue
Block a user