Skip to content
Snippets Groups Projects
Commit f729cd1f authored by Erik Reid's avatar Erik Reid
Browse files

Finished feature add-swagger-docs.

parents ae001c94 5a4480b4
No related branches found
No related tags found
No related merge requests found
import json
import os
from fastapi.testclient import TestClient
import resource_management
config_filename = os.path.join(
os.path.dirname(__file__),
'..', 'config-example.json')
output_filename = os.path.join(
os.path.dirname(__file__),
'source', '_static', 'openapi.json')
os.environ['SETTINGS_FILENAME'] = config_filename
app = resource_management.create_app()
client = TestClient(app)
rsp = client.get('/openapi.json')
openapi_doc = json.dumps(rsp.json(), indent=2)
with open(output_filename, 'w') as f:
f.write(openapi_doc)
print(f'wrote {output_filename}')
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="description"
content="SwaggerUI"
/>
<title>SwaggerUI</title>
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui.css" />
</head>
<body>
<div id="swagger-ui"></div>
<script src="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui-bundle.js" crossorigin></script>
<script>
window.onload = () => {
window.ui = SwaggerUIBundle({
url: '_static/openapi.json',
dom_id: '#swagger-ui',
});
};
</script>
</body>
</html>
\ No newline at end of file
.. list of basic cli tools
CLI Tools
=========================
.. automodule:: resource_management.cli
.. automodule:: resource_management.hardware.juniper
docs/source/images/db-er.png

48.1 KiB | W: | H:

docs/source/images/db-er.png

54 KiB | W: | H:

docs/source/images/db-er.png
docs/source/images/db-er.png
docs/source/images/db-er.png
docs/source/images/db-er.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -6,43 +6,15 @@
NAT Resource Management
==========================
Documentation for the NAT Resource Management tools
------------------
Configuration file format
---------------------------------
The following example indicates the schema for the configuration file required to call the Resource Management client::
{
"mysql":{
"username":"mydbuser",
"password":"mydbpass",
"hostname":"localhost",
"dbname":"mydb"
},
"ssh":{
"username":"user",
"password":"pass",
"private-key":"/path/to/private/key"
"ssh-config":"/path/to/ssh-config"
}
}
All "mysql" parameters are mandatory. For "ssh", username is mandatory, and either password or private-key must be provided. ssh-config is optional.
Excuting the client
---------------------
To create a new router from its fqdn::
python3 cli.py create --config /path/to/resource_management_config.json --fqdn test.example.com
Documentation for the NAT Resource Management service
.. toctree::
:maxdepth: 1
:caption: Contents:
basic-tools
quickstart
db
`Swagger API Docs <_static/openapi.html>`__
.. db model intro & info
Quick Start
==================
*This is a quick setup guide for running
standalone on your local machine*
Create a Local Database
--------------------------
* set the value of `sqlalchemy.url`
in `alembic.ini` to point to a writeable file, e.g.
.. code-block:: python
sqlalchemy.url = sqlite:////absolute/path/to/foo.db
* create the database by running the alembic
migration from the module (`resource_management`) directory
.. code-block:: bash
alembic upgrade head
Running the App
-------------------
* create a settings filename
(see `config-example.json` for an example) ... something like:
.. code-block:: json
{
"db": "sqlite:////tmp/test.db",
"ssh": {
"username": "ro-username",
"private-key": "/absolute/path/to/private/key"
}
}
* run the app like this
(`app.py` starts the server on port 44444):
.. code-block:: bash
SETTINGS_FILENAME=/absolute/path/to/config.json python -m resource_management.app
Examples
* get the version
.. code-block:: bash
curl http://localhost:44444/api/version
* load interfaces from a router
.. code-block:: bash
curl -X POST http://localhost:44444/api/initialize-router/router.host.name
* view the docs by loading `http://localhost:44444/docs`
in your browser (there are requests for reserving
lags and physical lag interfaces)
......@@ -18,4 +18,9 @@ commands =
coverage html
coverage report --fail-under 80
flake8
python docs/dump-openapi-spec.py
# to render the diagrams:
# pip install -r docs/requirements-er.txt
# ... and install dot on the system
# python docs/render_db_diagrams.py
sphinx-build -M html docs/source docs/build
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment