forked from oracle/opengrok
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiary.apib
724 lines (492 loc) · 20.2 KB
/
apiary.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
HIFORMAT: 1A
# OpenGrok
OpenGrok RESTful API documentation. The following endpoints are accessible under `/api/v1` with the exception of `/metrics`.
Besides `/suggester`, `/search` and `/metrics` endpoints, everything is accessible from `localhost` only
unless authentication bearer tokens are configured in the web application and used via the 'Authorization' HTTP header
(within HTTPS connection).
Some of the APIs are asynchronous. They return status code 202 (Accepted) and a Location header that contains the URL
for the status endpoint to check for the result of the API call. Once the status API returns result other than 202,
the client should issue DELETE request to this URL to clean up server resources.
For all entry points that modify web application configuration it is worth noting that
the configuration has to be retrieved and stored on disk (using the configuration specific
entry points) in order to be persistent (e.g. in case of application server restart or
web application redeploy).
## Annotation [/annotation{?path}]
### Get annotation for a file [GET]
+ Parameters
+ path (string) - path of file, relative to source root
+ Response 200 (application/json)
+ Body
[
{
"revision": "c55d5891",
"author": "Adam Hornáček",
"description": "changeset: c55d5891\nsummary: Rewrite README.txt to use markdown syntax\nuser: Adam Hornáček <adam.hornacek@oracle.com>\ndate: Wed Aug 30 17:42:12 CEST 2017",
"version": "1/15"
},
{
"revision": "5e0c6b22",
"author": "Vladimir Kotal",
"description": "changeset: 5e0c6b22\nsummary: bump year\nuser: Vladimir Kotal <vlada@devnull.cz>\ndate: Thu Jul 18 14:43:01 CEST 2019",
"version": "14/15"
}
]
## Authorization framework reload [/configuration/authorization/reload]
### reloads authorization framework [POST]
This is asynchronous API endpoint.
+ Request (application/text)
+ Response 204
## Configuration [/configuration]
### return XML representation of configuration [GET]
+ Response 200 (application/xml)
+ Body
```
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.8.0_172" class="java.beans.XMLDecoder">
<object class="org.opengrok.indexer.configuration.Configuration" id="Configuration0">
<void property="allowLeadingWildcard">
<boolean>true</boolean>
</void>
</object>
</java>
```
### sets configuration from XML representation [PUT]
This is asynchronous API endpoint.
+ Request (application/xml)
+ Body
```
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.8.0_172" class="java.beans.XMLDecoder">
<object class="org.opengrok.indexer.configuration.Configuration" id="Configuration0">
<void property="allowLeadingWildcard">
<boolean>true</boolean>
</void>
</object>
</java>
```
+ Response 201 (application/json)
## Configuration field [/configuration/{field}{?reindex}]
### returns specific configuration field [GET]
+ Response 200 (application/json)
### sets specific configuration field [PUT]
This is asynchronous API endpoint.
+ Parameters
+ reindex (boolean) - specifies if the underlying data were also reindexed (refreshes some searchers and additional data structures)
+ Request (application/text)
string value of the field to set
+ Response 204
## File content [/file/content{?path}]
### get file content [GET]
Honors the `Accept` header. If the value of the header is set to `text/plain`
and there is a document in the index that has the genre detected as plain text,
the contents of the document will be returned. If the document is not found,
HTTP error 404 will be returned. If the genre of the document is not plain text,
HTTP error 406 will be returned.
Alternatively, one can use the `application/octet-stream` value of the header
which bypasses the document and genre check.
The `Content-type` header of the reply will be set accordingly.
+ Parameters
+ path (string) - path of file, relative to source root
+ Response 200 (text/plain)
+ Body
foo
bar
+ Response 200
## File genre [/file/genre{?path}]
### get file genre [GET]
+ Parameters
+ path (string) - path of file, relative to source root
+ Response 200 (text/plain)
+ Body
genre as identified by analyzer, could be PLAIN, XREFABLE, IMAGE, DATA, HTML
## History [/history{?path,withFiles,start,max}]
### get history entries [GET]
+ Parameters
+ path (string) - path of file/directory to get history for, relative to source root
+ withFiles (optional, boolean) - whether to include list of files
+ start (optional, int) - start index
+ max (optional, int) - number of entries to get (default value 1000)
+ Response 200 (application/json)
+ Body
{
"entries": [
{
"revision": "86b0ab6b",
"date": 1565163646000,
"author": "Adam Hornacek <adam.hornacek@oracle.com>",
"tags": null,
"message": "Try to use mvnw in CI",
"files": [
"/opengrok/docker/README.md"
]
},
{
"revision": "a391bead",
"date": 1564745178000,
"author": "Adam Hornacek <adam.hornacek@oracle.com>",
"tags": null,
"message": "Fix docker readme typo",
"files": [
"/opengrok/docker/README.md"
]
},
{
"revision": "33551f14",
"date": 1563531391000,
"author": "Vladimir Kotal <vlada@devnull.cz>",
"tags": "1.3.0, 1.2.25, 1.2.24",
"message": "document docker-compose",
"files": [
"/opengrok/docker/README.md"
]
}
],
"start": 5,
"count": 3,
"total": 24
}
## Directory listing [/list{?path}]
### get directory entries [GET]
+ Parameters
+ path (string) - path of file/directory to get listing for, relative to source root, starting with /
+ Response 200 (application/json)
+ Body
[
{
"path": "/lucene/.github",
"numLines": 178,
"loc": 125,
"date": 1673456294670,
"description": null,
"pathDescription": "",
"isDirectory": true,
"size": null
},
{
"path": "/lucene/.asf.yaml",
"numLines": 25,
"loc": 21,
"date": 1673456294670,
"description": null,
"pathDescription": "",
"isDirectory": false,
"size": 574
}
]
## Include files reload [/system/includes/reload]
### reloads all include files for web application [PUT]
+ Response 204
## Get last index time [/system/indextime]
The time is in the ISO 8601 format in UTC time zone.
### Retrieve last index time [GET]
+ Response 200 (application/json)
+ Body
"2021-02-15T16:39:16.409+00:00"
## Messages [/messages{?tag}]
### adds message to a system [POST]
Usable values for `messageLevel` are: `success`, `info`, `warning`, `error`.
This will affect CSS class of the displayed message, leading to different coloring.
The values in the `tags` list can be: `main` (special value for top level message in the whole web application),
project name and project group name.
The format of `duration` is the same as Java's java.time.Duration class,
see https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence-
+ Request (application/json)
{
"tags": ["main"],
"messageLevel": "info",
"text":"test message",
"duration":"PT10M"
}
+ Response 201
### deletes messages with specified tag [DELETE]
+ Request (text/plain)
string value of the message text - only messages with the text (and specified tag) will be deleted
+ Parameters
+ tag (string) - tag
+ Response 204
### returns all messages with specified tag [GET]
+ Parameters
+ tag (string) - tag
+ Response 200 (application/json)
[
{
"expired": false,
"created": "2019-01-23 20:39:31 CET",
"tags": [
"main"
],
"expiration": "2019-01-23 20:49:31 CET",
"cssClass": "class",
"text": "test message"
}
]
## Monitoring [/metrics/prometheus]
### retrieves web application metrics in Prometheus format [GET]
+ Response 200 (text/plain)
## Path descriptions [/system/pathdesc]
### updates path descriptions for web application [POST]
This will refresh the path descriptions. The web application will store
the descriptions in a file under data root so it is not necessary to load the path
descriptions manually after each web application redeploy.
The paths are relative to source root, starting with /.
+ Request (application/json)
+ Body
[
{"path": "/foo", "description": "foo foo"},
{"path": "/bar", "description": "bar"}
]
+ Response 204
## Web app version [/system/version]
### get web app version as string [GET]
+ Request (text/plain)
+ Body
1.9.0 (a5ac05426bc5029158fedffee1cd44abf033bb61)
+ Response 200
## Ping the webapp [/system/ping]
This endpoint is used by the indexer when running with the -U option.
### Check if web app is deployed and alive [GET]
+ Response 200
## Groups [/groups]
### returns a list of all groups [GET]
+ Response 200 (application/json)
+ Body
["foo","bar"]
## Projects of a group [/groups/{group}/allprojects]
### returns list of all projects for given group [GET]
This includes also projects of any sub-groups.
+ Response 200 (application/json)
+ Body
["foo","bar"]
## Group pattern [/groups/{group}/pattern]
### returns pattern for given group [GET]
+ Response 200 (text/plain)
+ Body
^foo-.*
## Group match [/groups/{group}/match]
### check if (project) name matches group pattern [POST]
+ Request (text/plain)
+ Body
name of the project
+ Response 200
+ Response 204
## Projects [/projects]
### returns a list of all projects [GET]
+ Response 200 (application/json)
+ Body
["foo","bar"]
### add project [POST]
This will merely add the project and its repositories to the web application configuration.
The project will not be searchable (and thus appear in the UI) until it is indexed.
+ Request (text/plain)
+ Body
text/plain name of the project
+ Response 201
## Project management [/projects/{project}]
### delete project [DELETE]
This will remove the project and its repositories from the web application configuration.
It will also delete project specific data such as index, cross reference pages, history index
and suggester data.
+ Response 204
## Project data management [/projects/{project}/data]
### delete project index data [DELETE]
This will delete project index data but keep the project in web application configuration so that
can be indexed from scratch.
The project data (whatever is the project's directory under source root) will be left intact.
This will also mark the project as not indexed.
+ Response 204
## Project history cache management [/projects/{project}/historycache]
### delete history cache for a project [DELETE]
This will delete history cache for a project.
Return list of repository paths for which the cache was successfully deleted.
+ Response 200 (application/json)
+ Body
["/project/repository1","/project/repository2"]
## Project annotation cache management [/projects/{project}/annotationcache]
### delete annotation cache for a project [DELETE]
This will delete annotation cache for a project.
Return list of repository paths for which the cache was successfully deleted.
+ Response 200 (application/json)
+ Body
["/project/repository1","/project/repository2"]
## Project metadata management [/projects/{project}/indexed]
This entry point is used by the Indexer once it finishes indexing given project.
### marks project as indexed [PUT]
This is asynchronous API endpoint.
+ Request (text/plain)
+ Body
empty
+ Response 204
## Project index files [/projects/{project}/files]
### Get a list of files tracked by the index database for given project [GET]
+ Response 200 (application/json)
+ Body
["/project/foo.txt","/project/bar.txt"]
## Project metadata [/projects/{project}/property/{propertyname}]
The list of per project properties can be found on
https://github.com/oracle/opengrok/wiki/Per-project-configuration#properties
### sets property value for the project [PUT]
+ Request
+ Body
body – string representation of the value to set
+ Response 204
### returns the property value [GET]
+ Response 200 (application/json)
## Project repositories [/projects/{project}/repositories]
### returns a list of repositories for the specified project [GET]
Native path separators (of the system running the service)
will be used for repository paths.
+ Response 200 (application/json)
+ Body
["/opengrok-master/testdata/repositories/teamware",
"/opengrok-master/testdata/sources/rfe2575",
"/opengrok-master/testdata/repositories/rcs_test",
"/opengrok-master"]
## Repository type [/projects/{project}/repositories/type]
### returns types of project repositories [GET]
+ Response 200 (application/json)
+ Body
["RCS","git","SCCS"]
## Project indexed flag [/projects/indexed]
### returns a list of indexed projects [GET]
+ Response 200 (application/json)
+ Body
["sc-2","sc-1"]
## Repository field value [/repositories/property/{field}{?repository}]
### return the field value [GET]
The repository path is relative to source root. Examples of field names:
- `working` (boolean) - is the repository capable of running underlying SCM
commands
- `type` (string) - type of SCM
- `remote` (boolean) - is the SCM source remote
- `parent` (string) - origin/parent of the SCM
- `branch` (string) - branch identification
- `currentVersion` (string) - current revision ID
- `handleRenamedFiles` (boolean) - whether to handle renamed files for history
cache generation
- `historyEnabled` (boolean) - is history enabled
- `annotationCacheEnabled` (boolean) - is annotation cache enabled
The repository path is relative to source root.
+ Response 200 (application/json)
+ Parameters
+ repository - repository path with native path separators (of the machine
running the service) starting with path separator for which to return type
## Search [/search{?full,def,symbol,path,hist,type,projects,maxresults,start}]
## return search results [GET]
+ Parameters
+ full (optional, string) - full search field value to search for
+ def (optional, string) - definition field value to search for
+ symbol (optional, string) - symbol field value to search for
+ path (optional, string) - file path field value to search for
+ hist (optional, string) - history field value to search for
+ type (optional, string) - type of the files to search for
+ projects (optional, string) - projects to search in
+ maxresults (optional, string) - maximum number of documents whose hits will be returned (default 1000)
+ start (optional, string) - start index from which to return results
+ Response 200 (application/json)
+ Body
{
"time": 1229,
"resultCount": 8,
"startDocument": 0,
"endDocument": 7,
"results": {
"/onnv/usr/src/lib/libnisdb/db_pickle.cc": [
{
"line": "pickle_file::<b>transfer</b>(pptr p, bool_t (*f) (XDR*, pptr))",
"lineNumber": "106",
"tag": "function in pickle_file"
}
],
"/onnv/usr/src/cmd/pools/poold/com/sun/solaris/service/pools/Resource.java": [
{
"line": "\tpublic void <b>transfer</b>(Resource donor, long qty) throws PoolsException",
"lineNumber": "93",
"tag": "method in Resource"
},
{
"line": "\tpublic void <b>transfer</b>(Resource donor, List components)",
"lineNumber": "110",
"tag": "method in Resource"
}
],
}
}
## Suggester [/suggest{?projects,field,caret,full,defs,refs,path,hist,type}]
### returns suggestions [GET]
+ Parameters
+ projects (string) - list of projects for which to retrieve suggestions
+ field - field for which to suggest
+ caret - position of the caret in the input field
+ full - value of the Full Search input
+ defs - value of the Definitions input
+ refs - value of Symbol input
+ path - value of the File Path input
+ hist - value of the History input
+ type - value of the Type input
+ Response 200 (application/json)
+ Body
{
"time": 60,
"suggestions": [{
"phrase": "package",
"projects": ["kotlin"],
"score": 387
}],
"identifier": "pprttq",
"queryText": "pprttq",
"partialResult":false
}
## Suggester configuration [/suggest/config]
### returns suggester configuration [GET]
+ Response 200 (application/json)
+ Body
{"enabled":true,"maxResults":10,"minChars":4,"allowedProjects":null,
"maxProjects":2147483647,
"allowedFields":["defs","path","hist","refs","type","full"],
"allowComplexQueries":true,"allowMostPopular":true,"showScores":false,
"showProjects":true,"showTime":false,"rebuildCronConfig":"0 0 * * *",
"buildTerminationTime":1800,"timeThreshold":2000}
## Suggester popularity data initialization with queries [/suggest/init/queries]
### updates popularity data based on the queries [POST]
+ Request (application/json)
+ Body
["http://localhost:8080/source/search?project=kotlin&full=text"]
+ Response 204
## Suggester popularity data initialization [/suggest/init/raw]
### updates popularity data based on the provided data [POST]
+ Request (application/json)
+ Body
[{"project":"kotlin","field":"full","token":"args","increment":100}]
+ Response 204
## Suggester popularity data [/suggest/popularity/{project}{?field,page,pageSize,all}]
### retrieves popularity data for project [GET]
+ Parameters
+ field - field for which to retrieve data, default: full
+ page - page of data, default: 0
+ pageSize - size of the page, default: 100
+ all - if all data should be retrieved, if true then page and pageSize params are ignored
+ Response 200 (application/json)
+ Body
[{"iso":3},{"the":3},{"to":3},{"conform":3},{"-":2},
{"sc_window_set":1},{"_lso_outbound":1},{"missing":1}]
## Suggester data rebuild [/suggest/rebuild]
### rebuilds suggester data for all projects [PUT]
This kicks off suggester data rebuild in the background, i.e. the rebuild will very likely complete some time after the API call returned.
+ Response 204
## Suggester project data rebuild [/suggest/rebuild/{project}]
### rebuilds suggester data for given project [PUT]
This kicks off suggester data rebuild in the background, i.e. the rebuild will very likely complete some time after the API call returned.
+ Parameters
+ project - project name
+ Response 204
## Status [/status/{uuid}]
### Check the state of API request [GET]
+ Parameters
+ uuid
+ Response 202
### Delete state associated with API request tracking [DELETE]
This should be done only after the API request is completed, i.e. after the GET request for the API request state
returns appropriate status code (e.g. 201).
+ Parameters
+ uuid
+ Response 200