|
# retoor <retoor@molodetz.nl>
|
|
|
|
VOTE_TARGETS = ["post", "comment", "gist", "project"]
|
|
REACTION_TARGETS = ["post", "comment", "gist", "project"]
|
|
BOOKMARK_TARGETS = ["post", "gist", "project", "news"]
|
|
COMMENT_TARGETS = ["post", "project", "news", "issue", "gist"]
|
|
PROJECT_TYPES = ["game", "game_asset", "software", "mobile_app", "website"]
|
|
GIST_LANGUAGES = [
|
|
"python",
|
|
"javascript",
|
|
"typescript",
|
|
"html",
|
|
"css",
|
|
"c",
|
|
"cpp",
|
|
"java",
|
|
"go",
|
|
"rust",
|
|
"sql",
|
|
"bash",
|
|
"json",
|
|
"markdown",
|
|
"plaintext",
|
|
]
|
|
SERVICE_ACTIONS = [
|
|
("start", "Start the service"),
|
|
("stop", "Stop the service"),
|
|
("run", "Trigger a single run now"),
|
|
("clear-logs", "Clear the in-memory log buffer"),
|
|
]
|
|
|
|
|
|
def field(
|
|
name,
|
|
location,
|
|
type="string",
|
|
required=False,
|
|
example="",
|
|
description="",
|
|
options=None,
|
|
):
|
|
spec = {
|
|
"name": name,
|
|
"location": location,
|
|
"type": type,
|
|
"required": required,
|
|
"example": example,
|
|
"description": description,
|
|
}
|
|
if options:
|
|
spec["options"] = list(options)
|
|
return spec
|
|
|
|
|
|
ROLE_LABELS = {"public": "Public", "user": "Member", "admin": "Admin"}
|
|
|
|
|
|
def endpoint(
|
|
id,
|
|
method,
|
|
path,
|
|
title,
|
|
summary,
|
|
auth="user",
|
|
ajax=False,
|
|
encoding="none",
|
|
interactive=True,
|
|
destructive=False,
|
|
params=None,
|
|
notes=None,
|
|
sample_response=None,
|
|
negotiation=None,
|
|
):
|
|
return {
|
|
"id": id,
|
|
"method": method,
|
|
"path": path,
|
|
"title": title,
|
|
"summary": summary,
|
|
"auth": auth,
|
|
"min_role": ROLE_LABELS.get(auth, auth.title()),
|
|
"ajax": ajax,
|
|
"encoding": encoding,
|
|
"interactive": interactive,
|
|
"destructive": destructive,
|
|
"params": params or [],
|
|
"notes": notes or [],
|
|
"sample_response": sample_response,
|
|
"negotiation": negotiation,
|
|
}
|
|
|
|
|
|
NON_BODY_ENDPOINTS = {
|
|
"avatar",
|
|
"gateway-passthrough",
|
|
"notifications-open",
|
|
"admin-bots-frame",
|
|
}
|