Skip to content
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

Create documentation for REST endpoints #8840

Open
DGabri opened this issue Nov 27, 2024 · 0 comments
Open

Create documentation for REST endpoints #8840

DGabri opened this issue Nov 27, 2024 · 0 comments
Assignees

Comments

@DGabri
Copy link
Contributor

DGabri commented Nov 27, 2024

This is to request the creation of documentation on REST APIs that can be found in:
https://github.com/ntop/ntopng/tree/dev/scripts/lua/rest/v2/get

Documentation is required so that we know how to call a specific endpoint and get a response.
below is an example that can be found in some lua scripts.
We need documentation in this format:

  • endpoint path: for example: https://github.com/ntop/ntopng/blob/dev/scripts/lua/rest/v2/get/asn/get_as_data.lua in ntopng becomes: http://{NTOPNG_HOST_IP}:{NTOPNG_HOST_PORT}/lua/rest/v2/get/asn/get_as_data.lua -> in the documentation put as endpoint: /lua/rest/v2/get/asn/get_as_data.lua
  • enumerate all the parameters and how to use them, for example how to sort by timestamp or name etc and which value to pass to sort by decreasing timestamp for example. Also add (required) if the parameter is required
  • write a short description on what the endpoint returns
  • Put a sample of returned data

NOTE
Skip the alerts endpoint as this data is not relevant for our use case

EXAMPLE
REST: https://github.com/ntop/ntopng/blob/dev/scripts/lua/rest/v2/get/alert/alert_from_map.lua

  • Path: /lua/rest/v2/get/alert/alert_from_map.lua
  • Description: This endpoint enables to convert an alert bitmap and alert type to the corresponding alert description. Alert bitmap and alert type are required parameters.
  • Parameters:
    • alert_map: string (required) -> Alert bitmap which uniquely identifies the main and sub alerts
    • alert_type: int (required) -> Alert id of the alert provided
  • Returns: {"rsp":{"additional_alerts":["TCP Connection Refused ","TCP No Data Exchanged ","Periodic Flow ","TCP Flow Reset "],"alerts_by_score":[]},"rc_str":"OK","rc":0,"rc_str_hr":"Success"}

This example can be found in REST lua scripts, if missing, add it a the top of the script to document how to call the endpoint

-- Given alerts bitmap and alert_id return all the alerts relevant for the provided values
-- Example: curl -u admin:admin -H "Content-Type: application/json" -d '{"alert_map": "10050000000100000000100000", "alert_type": "90"}' http://localhost:3000/lua/rest/v2/get/alert/alert_from_map.lua
-- Returns: {"rsp":{"additional_alerts":["TCP Connection Refused ","TCP No Data Exchanged ","Periodic Flow ","TCP Flow Reset "],"alerts_by_score":[]},"rc_str":"OK","rc":0,"rc_str_hr":"Success"}

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

No branches or pull requests

4 participants