|
1
|
# JSON API: Misc. APIs |
|
2
|
([⬑JSON API Index](index.md)) |
|
3
|
|
|
4
|
Some operations simply don't fit into a specific category (well, none |
|
5
|
except "misc")... |
|
6
|
|
|
7
|
Jump to: |
|
8
|
|
|
9
|
* [Global State ("g")](#g) |
|
10
|
* [Rebuild Repository](#rebuild) |
|
11
|
* [Result Code Descriptions](#result-codes) |
|
12
|
|
|
13
|
--- |
|
14
|
|
|
15
|
<a id="g"></a> |
|
16
|
# Global State ("g") |
|
17
|
|
|
18
|
Fossil's internal state is maintained in a global object called "g". And |
|
19
|
thus this command is named "g"... |
|
20
|
|
|
21
|
**Status:** implemented 20111009 |
|
22
|
|
|
23
|
**Required permissions:** "a" or "s" |
|
24
|
|
|
25
|
**Request:** `/json/g` |
|
26
|
|
|
27
|
**Response payload example:** this is a debugging-only request, and has |
|
28
|
no stable response payload structure. The result object contains all |
|
29
|
kinds of details gleaned from the fossil environment. |
|
30
|
|
|
31
|
Easter egg: this output can be added to ANY response by passing the |
|
32
|
`debugFossilG` boolean in the POST envelope or GET parameters, or as the |
|
33
|
`--json-debug-g` flag in CLI mode. This requires admin or setup |
|
34
|
privileges, though, and it is silently ignored for other users. |
|
35
|
|
|
36
|
|
|
37
|
<a id="rebuild"></a> |
|
38
|
# Rebuild Repository |
|
39
|
|
|
40
|
This request does the same as the "fossil rebuild" command, rebuilding |
|
41
|
the repo-internal structure. This is often required after upgrading the |
|
42
|
fossil binary on a system. There "are very probably" cases where calling |
|
43
|
this over HTTP will not work (e.g. if the user table has changed enough |
|
44
|
that the access rights cannot be validated without a rebuild, i.e. a |
|
45
|
chicken/egg scenario). Another consideration is that this request can |
|
46
|
take a long time to run - rebuilding the fossil repo on my laptop takes |
|
47
|
about 21 seconds, which is likely longer than the timeout set on an XHR |
|
48
|
request, meaning that the rebuild transaction will fail. It can safely |
|
49
|
be run in CLI mode, where timeouts are not normally a concern. As a |
|
50
|
preliminary benchmark: rebuilding the fossil repo (as of late 2011) |
|
51
|
takes just over 21 seconds on my 32-bit 1.6GHz netbook. That said, most |
|
52
|
repos are much smaller and rebuild in under a few seconds. |
|
53
|
|
|
54
|
**Status:** implemented 20110929 |
|
55
|
|
|
56
|
**Required privileges:** "a" |
|
57
|
|
|
58
|
**Request:** `/json/rebuild` |
|
59
|
|
|
60
|
Requires admin access rights. |
|
61
|
|
|
62
|
**Response payload:** none (response envelope `resultCode` reports failure). |
|
63
|
Potential TODO: return the amount of time it took to rebuild. |
|
64
|
|
|
65
|
|
|
66
|
<a id="result-codes"></a> |
|
67
|
# Result Code Descriptions |
|
68
|
|
|
69
|
This request returns the full list of result codes documented for |
|
70
|
Fossil's JSON API. Each result code is returned as an object containing |
|
71
|
metadata about the result code. |
|
72
|
|
|
73
|
**Status:** implemented 20111006 |
|
74
|
|
|
75
|
**Required permissions:** none |
|
76
|
|
|
77
|
**Request:** `/json/resultCodes` |
|
78
|
|
|
79
|
**Response payload example:** |
|
80
|
|
|
81
|
```json |
|
82
|
[{ |
|
83
|
"resultCode":"FOSSIL-1000", |
|
84
|
"cSymbol":"FSL_JSON_E_GENERIC", |
|
85
|
"number":1000, |
|
86
|
"description":"Generic error" |
|
87
|
}, |
|
88
|
… many more objects with the same structure … |
|
89
|
] |
|
90
|
``` |
|
91
|
|
|
92
|
|
|
93
|
|