78 lines
2.9 KiB
Python
Raw Normal View History

# retoor <retoor@molodetz.nl>
from __future__ import annotations
from ..spec import Action
from ._shared import body, path, query
JOB_ACTIONS: tuple[Action, ...] = (
Action(
name="zip_project",
method="POST",
path="/projects/{project_slug}/zip",
summary="Build a downloadable zip archive of a whole project",
description=(
"Queues a background zip job and returns {uid, status_url}. Poll the status_url with "
"zip_status until status is 'done', then give the user the download_url."
),
params=(path("project_slug", "Project slug or uid."),),
requires_auth=False,
),
Action(
name="project_files_zip",
method="POST",
path="/projects/{project_slug}/files/zip",
summary="Build a downloadable zip archive of a project subdirectory",
description=(
"Queues a background zip job for a subpath inside the project and returns "
"{uid, status_url}. Poll the status_url with zip_status until status is 'done', "
"then give the user the download_url. When path is empty the whole project is zipped."
),
params=(
path("project_slug", "Project slug or uid."),
query("path", "Relative subpath inside the project to zip; empty for the whole project."),
),
requires_auth=False,
),
Action(
name="zip_status",
method="GET",
path="/zips/{uid}",
summary="Check a zip job and obtain its download link once finished",
description=(
"Returns the job status and stats. When status is 'done', download_url points at the "
"ready archive; while 'pending' or 'running', poll again shortly."
),
params=(path("uid", "Zip job uid returned by zip_project."),),
requires_auth=False,
),
Action(
name="fork_project",
method="POST",
path="/projects/{project_slug}/fork",
summary="Fork a project into a new project owned by the current user",
description=(
"Queues a background fork job and returns {uid, status_url}. Poll the status_url with "
"fork_status until status is 'done', then give the user the project_url of the new fork."
),
params=(
path("project_slug", "Slug or uid of the project to fork."),
body("title", "Title for the new forked project.", required=True),
),
requires_auth=True,
),
Action(
name="fork_status",
method="GET",
path="/forks/{uid}",
summary="Check a fork job and obtain the new project once finished",
description=(
"Returns the job status. When status is 'done', project_url points at the new forked "
"project; while 'pending' or 'running', poll again shortly."
),
params=(path("uid", "Fork job uid returned by fork_project."),),
requires_auth=False,
),
)