From 72e13133cfc7ef37abb2dd0add8cb53521fbee64 Mon Sep 17 00:00:00 2001 From: Erik Reid <erik.reid@geant.org> Date: Sun, 24 Jan 2021 21:32:33 +0100 Subject: [PATCH] added msr route doc --- README.md | 66 ++------------------------------ docs/source/protocol/data.rst | 2 +- docs/source/protocol/index.rst | 1 + docs/source/protocol/lg.rst | 2 +- docs/source/protocol/msr.rst | 12 ++++++ docs/source/protocol/poller.rst | 2 +- inventory_provider/routes/msr.py | 42 ++++++++++++++++++++ test/test_msr_routes.py | 31 +-------------- 8 files changed, 63 insertions(+), 95 deletions(-) create mode 100644 docs/source/protocol/msr.rst diff --git a/README.md b/README.md index 9157e3ed..7067dcb4 100644 --- a/README.md +++ b/README.md @@ -5,66 +5,8 @@ acts as a single point of truth for information about the GÉANT network, exposed by by an HTTP API. -Sphinx documentation is generated in `/docs`. +Documentation can be generated by running sphinx: - -* [Inventory Provider](#inventory-provider) - * [Protocol Specification](#protocol-specification) - - * [/jobs/update](#jobsupdate) - * [/jobs/log](#jobslog) - * [/jobs/reload-router-config](#jobsreload-router-config) - * [/jobs/check-task-status](#jobscheck-task-status) - * [/msr/access-services](#msraccess-services) - * [/testing/flushdb](#testingflushdb) - * [/testing/infinera-dna-addresses](#testinginfinera-dna-addresses) - * [/testing/coriant-tnms-addresses](#testingcoriant-tnms-addresses) - * [/testing/juniper-server-addresses](#testingjuniper-server-addresses) - - - -# Inventory Provider - - -## Protocol Specification - -The following resources can be requested from the webservice. - -### resources - -Any non-empty responses are JSON formatted messages. - -### Testing utilities - -The following routes are only available if the server -was started with the `ENABLE_TESTING_ROUTES` flag. These routes -are present only for testing, or for deprectated routes that -are intended to be deleted. - - -#### /testing/flushdb - - * /testing/flushdb - - This method erases all data in the backend redis - database. - -#### /testing/infinera-dna-addresses -#### /testing/coriant-tnms-addresses -#### /testing/juniper-server-addresses - - * /testing/infinera-dna-addresses - * /testing/coriant-tnms-addresses - * /testing/juniper-server-addresses - - All of these resources return lists of source addresses - of known senders of snmp traps. Responses will be - formatted as follows: - - ```json - { - "$schema": "http://json-schema.org/raft-07/schema#", - "type": "array", - "items": {"type": "string"} - } - ``` +```bash +sphinx-build -M html docs/source docs/build +``` \ No newline at end of file diff --git a/docs/source/protocol/data.rst b/docs/source/protocol/data.rst index 753f3fc5..72531fd8 100644 --- a/docs/source/protocol/data.rst +++ b/docs/source/protocol/data.rst @@ -14,7 +14,7 @@ These endpoints are temporary and will be removed. /data/interfaces --------------------------------- -.. autofunction:: inventory_provider.routes.data.interfaces +.. autofunction:: inventory_provider.routes.data.router_interfaces /data/pop --------------------------------- diff --git a/docs/source/protocol/index.rst b/docs/source/protocol/index.rst index 068ea0ec..e0ef1976 100644 --- a/docs/source/protocol/index.rst +++ b/docs/source/protocol/index.rst @@ -33,3 +33,4 @@ API modules lg data jobs + msr \ No newline at end of file diff --git a/docs/source/protocol/lg.rst b/docs/source/protocol/lg.rst index c6ce6541..363555fe 100644 --- a/docs/source/protocol/lg.rst +++ b/docs/source/protocol/lg.rst @@ -1,7 +1,7 @@ .. LG endpoint docs -LG Endpoints +LG Support Endpoints ========================= These endpoints are intended for use by LG. diff --git a/docs/source/protocol/msr.rst b/docs/source/protocol/msr.rst new file mode 100644 index 00000000..c73074bb --- /dev/null +++ b/docs/source/protocol/msr.rst @@ -0,0 +1,12 @@ +.. poller endpoint docs + + +MSR Support Endpoints +========================= + +These endpoints are intended for use by MSR. + +/msr/access-services +--------------------------------- + +.. autofunction:: inventory_provider.routes.msr.access_services diff --git a/docs/source/protocol/poller.rst b/docs/source/protocol/poller.rst index 617414f5..8bfa6ddc 100644 --- a/docs/source/protocol/poller.rst +++ b/docs/source/protocol/poller.rst @@ -1,7 +1,7 @@ .. poller endpoint docs -Poller Endpoints +BRIAN support Endpoints ========================= These endpoints are intended for use by BRIAN. diff --git a/inventory_provider/routes/msr.py b/inventory_provider/routes/msr.py index d109d656..ce17ae63 100644 --- a/inventory_provider/routes/msr.py +++ b/inventory_provider/routes/msr.py @@ -7,6 +7,37 @@ from inventory_provider.routes import common routes = Blueprint("msr-query-routes", __name__) +ACCESS_SERVICES_LIST_SCHEMA = { + "$schema": "http://json-schema.org/draft-07/schema#", + + "definitions": { + "service": { + "type": "object", + "properties": { + "id": {"type": "integer"}, + "name": {"type": "string"}, + "equipment": {"type": "string"}, + "pop_name": {"type": "string"}, + "other_end_equipment": {"type": "string"}, + "other_end_pop_name": {"type": "string"}, + "speed_value": {"type": "integer"}, + "speed_unit": {"type": "string"} + }, + "required": [ + "id", "name", + "pop_name", "equipment", + "other_end_pop_name", "other_end_equipment", + "speed_value", "speed_unit" + ], + "additionalProperties": False + } + }, + + "type": "array", + "items": {"$ref": "#/definitions/service"} +} + + @routes.after_request def after_request(resp): return common.after_request(resp) @@ -15,7 +46,18 @@ def after_request(resp): @routes.route("/access-services", methods=['GET', 'POST']) @common.require_accepts_json def access_services(): + """ + Handler for `/msr/access-services`. + + This method is in development, not yet used. + + The response will be formatted according to the following schema: + + .. asjson:: + inventory_provider.routes.msr.ACCESS_SERVICES_LIST_SCHEMA + :return: + """ redis = common.get_current_redis() def _services(): diff --git a/test/test_msr_routes.py b/test/test_msr_routes.py index 47a9d42e..b842938d 100644 --- a/test/test_msr_routes.py +++ b/test/test_msr_routes.py @@ -1,41 +1,12 @@ import json import jsonschema +from inventory_provider.routes.msr import ACCESS_SERVICES_LIST_SCHEMA DEFAULT_REQUEST_HEADERS = { "Content-type": "application/json", "Accept": ["application/json"] } -ACCESS_SERVICES_LIST_SCHEMA = { - "$schema": "http://json-schema.org/draft-07/schema#", - - "definitions": { - "service": { - "type": "object", - "properties": { - "id": {"type": "integer"}, - "name": {"type": "string"}, - "equipment": {"type": "string"}, - "pop_name": {"type": "string"}, - "other_end_equipment": {"type": "string"}, - "other_end_pop_name": {"type": "string"}, - "speed_value": {"type": "integer"}, - "speed_unit": {"type": "string"} - }, - "required": [ - "id", "name", - "pop_name", "equipment", - "other_end_pop_name", "other_end_equipment", - "speed_value", "speed_unit" - ], - "additionalProperties": False - } - }, - - "type": "array", - "items": {"$ref": "#/definitions/service"} -} - def test_access_services(client): rv = client.get( -- GitLab