Skip to content

API endpoints for Annotate, History, file listing #3042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jbaek7023 opened this issue Feb 18, 2020 · 13 comments
Closed

API endpoints for Annotate, History, file listing #3042

jbaek7023 opened this issue Feb 18, 2020 · 13 comments

Comments

@jbaek7023
Copy link

jbaek7023 commented Feb 18, 2020

Looking at the API documentation for Opengrok here (https://opengrok.docs.apiary.io/),

  1. Is this official API documentation? Is this official API documentation?

I'm building a Frontend web application that can talk with OpenGrok API.
I see History, Annotate and the file detail page such as http://androidxref.com/9.0.0_r3/xref/frameworks/base/packages/Keyguard/proguard.flags promising.

  1. Does OpenGrok application expose every available feature as API endpoints?

Thanks a lot!

@tulinkry
Copy link
Contributor

Hello,

  1. Yes, this is official documentation. @vladak it's not versioned right? It contains what is currently in master.
  2. No, it does not. The original purpose of the API is to make the system accessible by administrator and the opengrok indexer. Public features include searching and suggesting.

@vladak
Copy link
Member

vladak commented Feb 18, 2020

1. Yes, this is official documentation. @vladak it's not versioned right? It contains what is currently in master.

Yes, it captures the current state. We don't really play the API versioning game.

It is versioned in Git :-) As for the synchronization, in theory it should work both ways - whatever is edited on Apiary gets propagated to the Github repo (https://github.com/oracle/opengrok/blob/master/apiary.apib) and vice versa.

@vladak
Copy link
Member

vladak commented Feb 18, 2020

1. Does OpenGrok application expose every available feature as API endpoints?

Well, exposing "every feature" would be probably too much :-) What are you after specifically ?

@jbaek7023
Copy link
Author

@vladak @tulinkry Thanks for the quick turnaround!!!
I am building a Front-End application (ReactJS) which can interact with OpenGrok API endpoints.

Here are the descriptions:
(1) "Search Detail" endpoint When I click the filename, it opens the file.
Screenshot from 2020-02-18 02-56-56

Screenshot from 2020-02-18 03-00-37
example endpoint

{
"body": [{"line": 1, "content": "/*"} , {"line":2, "contentL": "* Copyright (C) ....}
"filename": "/android-4.2.2_r1.2/external/webkit/Source/WebKit/chromium/test/CCThreadTaskTest.cpp"
...
]
}

(2) "Annotate" endpoint. When I click the annotation, it returns the annotation with the line
Screenshot from 2020-02-18 03-01-02

{
[{"line": 1, "anno": "e2247f4", "author": "Chris Craik", "CL number": "CL195849"...} 
...
]
}

(3) FileStructure endpoint: Returns the file structure (Input: filename)

Input: "filename": "/android-4.2.2_r1.2/external/webkit/Source/WebKit/chromium/test/CCThreadTaskTest.cpp"

{
"parent": "/freeze2prod",
"currentFile": "filename": "CCThreadTaskTest.cpp"
"siblings": ["CCProcessTaskTests.cpp", "ExampleFile.cpp", ...]
}

(4) History endpoint: Returns the history of the file. (Input: filename)

(5) History of CL/Annotation endpoint: Returns the history By CL(ChangeList number or Annotation).

@jbaek7023
Copy link
Author

@vladak If you can ship these 5 endpoints, it will be super awesome.

But if you guys have other priorities for the next version, I can probably raise a PR for this. Can you please provide an instruction/documentation like where to edit the file..? I see opengrok_tools directory has the .py files which seems to server the APIs.

Thanks a lot

@vladak
Copy link
Member

vladak commented Feb 18, 2020

The API implementation lives under https://github.com/oracle/opengrok/tree/master/opengrok-web/src/main/java/org/opengrok/web/api/v1, the Python source is merely a consumer.

@vladak
Copy link
Member

vladak commented Feb 18, 2020

Out of these, only the search endpoint is implemented, see https://opengrok.docs.apiary.io/#reference/0/search/return-search-results ; it has its quirks (#2834, #2612).

The rest should be reasonably easy to implement. Note that pages served by the webapp should be XHTML compliant and therefore parseable.

@vladak vladak added the API label Feb 18, 2020
@vladak vladak changed the title Do we have a full support on API? (Annotate, History, file detail pages features?) API endpoints for Annotate, History, file detail Feb 18, 2020
@vladak vladak changed the title API endpoints for Annotate, History, file detail API endpoints for Annotate, History, file listing Feb 18, 2020
@vladak
Copy link
Member

vladak commented Feb 18, 2020

I'd suggest to create separate issue for each of the requested endpoints and we can hash out details there.

@vladak
Copy link
Member

vladak commented Feb 19, 2020

..like #3044 for history API.

@vladak
Copy link
Member

vladak commented Feb 20, 2020

The /history API endpoint is now implemented in the master branch. It was pretty easy to do. I filed issues for the rest as you can see above. These issues need more details on how the endpoints should work.

Not sure what is meant by:

  1. History of CL/Annotation endpoint: Returns the history By CL(ChangeList number or Annotation).

so I did not file new issue for this.

@jbaek7023
Copy link
Author

@vladak GREAT to hear that!!! Thanks a lot for the quick turnaround.

I'll follow up w you later next week. I'm occupied for other works now :) Thanks a lot for the help

@vladak
Copy link
Member

vladak commented Mar 9, 2020

The 1.3.9 release has some of the suggested API endpoints.

@vladak
Copy link
Member

vladak commented Mar 21, 2020

The 1.3.10 release has the annotate API endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants