Add API endpoints for listing peers and retrieving peer details

This commit is contained in:
Eduardo Silva
2026-02-11 16:49:32 -03:00
parent 8c6a5262d3
commit f2dc9942d9
5 changed files with 128 additions and 2 deletions

View File

@@ -0,0 +1,89 @@
{% extends "base.html" %}
{% load i18n %}
{% block content %}
<div class="row">
<div class="col-md-12">
<h2 class="mb-4">{% trans 'API Documentation' %}</h2>
{% for doc in docs %}
<div class="card mb-4">
<div class="card-header">
<h5 class="mb-0">
{% for method in doc.methods %}
<span class="badge badge-primary mr-2">{{ method }}</span>
{% endfor %}
<code>/api/v2/{{ doc.url_pattern }}</code>
</h5>
</div>
<div class="card-body">
<p class="lead">{{ doc.summary }}</p>
<p><strong>{% trans 'Authentication' %}:</strong> {{ doc.auth }}</p>
{% if doc.params %}
<h6 class="mt-3">{% trans 'Parameters' %}</h6>
<table class="table table-sm table-bordered">
<thead>
<tr>
<th>{% trans 'Name' %}</th>
<th>{% trans 'In' %}</th>
<th>{% trans 'Type' %}</th>
<th>{% trans 'Required' %}</th>
<th>{% trans 'Description' %}</th>
</tr>
</thead>
<tbody>
{% for param in doc.params %}
<tr>
<td><code>{{ param.name }}</code></td>
<td>{{ param.in }}</td>
<td>{{ param.type }}</td>
<td>
{% if param.required %}
<span class="badge badge-danger">{% trans 'Yes' %}</span>
{% else %}
<span class="badge badge-secondary">{% trans 'No' %}</span>
{% endif %}
</td>
<td>
{{ param.description }}
{% if param.example %}
<br><small class="text-muted">{% trans 'Example' %}: {{ param.example }}</small>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% if doc.returns %}
<h6 class="mt-3">{% trans 'Returns' %}</h6>
<ul class="list-group">
{% for ret in doc.returns %}
<li class="list-group-item">
<strong>{{ ret.status }}</strong>
<pre class="bg-light p-2 mt-2"><code>{{ ret.body|pprint }}</code></pre>
</li>
{% endfor %}
</ul>
{% endif %}
{% if doc.examples %}
<h6 class="mt-3">{% trans 'Examples' %}</h6>
{% for key, example in doc.examples.items %}
<div class="card bg-light mb-2">
<div class="card-body p-2">
<strong>{{ key }}</strong>
<pre class="mb-0"><code>{{ example|pprint }}</code></pre>
</div>
</div>
{% endfor %}
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}