Skip to content

Commit

Permalink
feat(server): add new system information endpoint with proper formatting
Browse files Browse the repository at this point in the history
Closes #247
  • Loading branch information
ericswpark committed Nov 24, 2023
1 parent 1a790fc commit c0a7055
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docs/developer/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ If the user is installing the build for the first time (i.e. they are downloadin

This endpoint will throw a 404 if a build with the given file name or build ID does not exist, with specific error messages for each scenario.


### shippy

- `https://host/api/v2/system/info/`

Returns the shipper version installed on the server.


## v1 endpoints

### Statistics
Expand Down Expand Up @@ -58,6 +66,8 @@ The following endpoints are used by [shippy, a tool to help maintainers upload b

- `https://host/api/v1/system/info/`

#### This endpoint has been deprecated for v2. It will be removed at some point in the future!

Returns the shipper version installed on the server.

- `https://host/api/v1/maintainers/login/`
Expand Down
4 changes: 3 additions & 1 deletion server/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
v1_maintainers_upload_filename_regex_pattern,
v1_system_info,
V2DownloadBuildCounter,
v2_system_info,
)

urlpatterns = [
Expand Down Expand Up @@ -72,7 +73,7 @@
),
path("v1/download/count/all/", v1_download_count_all, name="v1_download_count_all"),
# shippy
path("latest/system/info/", v1_system_info, name="latest_system_info"),
path("latest/system/info/", v2_system_info, name="latest_system_info"),
path(
"latest/maintainers/login/",
v1_maintainers_login,
Expand Down Expand Up @@ -103,6 +104,7 @@
v1_maintainers_build_enabled_status_modify,
name="latest_maintainers_build_enabled_status_modify",
),
path("v2/system/info/", v2_system_info, name="v2_system_info"),
path("v1/system/info/", v1_system_info, name="v1_system_info"),
path("v1/maintainers/login/", v1_maintainers_login, name="v1_maintainers_login"),
path(
Expand Down
2 changes: 2 additions & 0 deletions server/api/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
v1_maintainers_token_check,
v1_maintainers_upload_filename_regex_pattern,
v1_system_info,
v2_system_info,
)
from .statistics import (
V2DownloadBuildCounter,
Expand All @@ -32,6 +33,7 @@
"v1_maintainers_token_check",
"v1_maintainers_upload_filename_regex_pattern",
"v1_system_info",
"v2_system_info",
"V2DownloadBuildCounter",
"v1_download_count_day",
"v1_download_count_week",
Expand Down
21 changes: 21 additions & 0 deletions server/api/views/shippy.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,27 @@ def v1_system_info(_):
)


@csrf_exempt
@api_view(["GET"])
@permission_classes((AllowAny,))
def v2_system_info(_):
"""
Returns shipper system information
:return: the current shipper system information
"""
variants = {v.codename: v.description for v in Variant.objects.all()}
return Response(
{
"version": settings.SHIPPER_VERSION,
"shippy_compat_version": settings.SHIPPER_SHIPPY_COMPAT_VERSION,
"shippy_upload_checksum_type": settings.DRF_CHUNKED_UPLOAD_CHECKSUM,
"shippy_allowed_versions": config.SHIPPER_ALLOWED_VERSIONS_TO_UPLOAD,
"shippy_upload_variants": variants,
}
)


@csrf_exempt
@api_view(["GET"])
def v1_maintainers_token_check(request):
Expand Down

0 comments on commit c0a7055

Please sign in to comment.