Skip to content

Commit 1608a3c

Browse files
committed
chore(service): update top-level api docs
1 parent 271cc39 commit 1608a3c

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

renku/service/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@
2222

2323
import pkg_resources
2424

25+
# TODO: #2100 the git access error should have its own error code
2526
GIT_ACCESS_DENIED_ERROR_CODE = -32000
2627
GIT_UNKNOWN_ERROR_CODE = -32001
2728

2829
RENKU_EXCEPTION_ERROR_CODE = -32100
2930
REDIS_EXCEPTION_ERROR_CODE = -32200
3031

32+
# TODO: #2100 according to the JSON-RPC spec this code is reserved for "method not
33+
# found" - the invalid headers code should either be a custom code or lumped
34+
# under invalid params code
3135
INVALID_HEADERS_ERROR_CODE = -32601
3236
INVALID_PARAMS_ERROR_CODE = -32602
3337
INTERNAL_FAILURE_ERROR_CODE = -32603

renku/service/views/apispec.py

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@
3838
gitlab_token_scheme = {"type": "apiKey", "name": "Authorization", "in": "header"}
3939

4040
TOP_LEVEL_DESCRIPTION = """
41-
This is the API specification of the renku core service. The API follows
42-
JSON-RPC conventions that mirrors the functionality of the renku CLI.
41+
This is the API specification of the renku core service. The API follows the
42+
[JSON-RPC 2.0](https://www.jsonrpc.org/specification) specifications and mirrors
43+
the functionality of the renku CLI.
4344
4445
The basic API is low-level and requires that the client handles project
4546
(repository) state in the service cache by invoking the `cache.project_clone`
@@ -51,9 +52,37 @@
5152
## Higher-level interface
5253
5354
Some API methods allow the client to defer repository management to the service.
54-
In these cases, the API documentation will include `project_id` _and_ `git_url`
55-
+ `ref` in the spec. Note that for such methods, _either_ `project_id` _or_
56-
`git_url` (and optionally `ref`) should be passed in the request body.
55+
In these cases, the API documentation will include `project_id` _and_
56+
`git_url`+`ref` in the spec. Note that for such methods, _either_ `project_id`
57+
_or_ `git_url` (and optionally `ref`) should be passed in the request body.
58+
59+
## Responses
60+
61+
Following the JSON-RPC 2.0 Specification, the methods all return with HTTP code
62+
200 and include a [response
63+
object](https://www.jsonrpc.org/specification#response_object) may contain
64+
either a `result` or an `error` object. If the call succeeds, the returned
65+
`result` follows the schema documented in the individual methods. In the case of
66+
an error, the [`error`
67+
object](https://www.jsonrpc.org/specification#error_object), contains a code and
68+
a message describing the nature of the error. In addition to the [standard JSON-RPC
69+
response codes](https://www.jsonrpc.org/specification#error_object), we define application-specific
70+
codes:
71+
72+
```
73+
GIT_ACCESS_DENIED_ERROR_CODE = -32000
74+
GIT_UNKNOWN_ERROR_CODE = -32001
75+
76+
RENKU_EXCEPTION_ERROR_CODE = -32100
77+
REDIS_EXCEPTION_ERROR_CODE = -32200
78+
79+
INVALID_HEADERS_ERROR_CODE = -32601
80+
INVALID_PARAMS_ERROR_CODE = -32602
81+
INTERNAL_FAILURE_ERROR_CODE = -32603
82+
83+
HTTP_SERVER_ERROR = -32000
84+
```
85+
5786
"""
5887

5988
spec = APISpec(

0 commit comments

Comments
 (0)