Skip to content

Add GET/POST/DELETE proxy endpoints for roles and location types - #58

Draft
Jackass4life with Copilot wants to merge 4 commits into
mainfrom
copilot/nautobot-maps-alert
Draft

Add GET/POST/DELETE proxy endpoints for roles and location types#58
Jackass4life with Copilot wants to merge 4 commits into
mainfrom
copilot/nautobot-maps-alert

Conversation

Copilot AI commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

No API surface existed to manage Nautobot roles or location types through this service. Adds full CRUD proxy endpoints for both resources.

New helpers

  • nautobot_post(endpoint, payload) — POST to Nautobot REST API
  • nautobot_delete(endpoint) — DELETE to Nautobot REST API

New endpoints

Method Path Nautobot target
GET /api/roles extras/roles/
POST /api/roles extras/roles/
DELETE /api/roles/<role_id> extras/roles/<id>/
GET /api/location-types dcim/location-types/
POST /api/location-types dcim/location-types/
DELETE /api/location-types/<lt_id> dcim/location-types/<id>/

POST requires name in body; returns 400 otherwise. DELETE returns 404 when the upstream resource doesn't exist. Cache is invalidated on successful writes.

Example

# Create a role
curl -X POST /api/roles -H 'Content-Type: application/json' \
  -d '{"name": "Core Router", "color": "aa1409"}'

# Delete a location type
curl -X DELETE /api/location-types/lt-dc-uuid

Copilot AI added 4 commits July 20, 2026 08:44
- Backend: compute_alert_level() classifies locations as critical/medium/ok
  - Critical: any device with a "core" role (core, spine, distribution, router,
    gateway keyword) has an offline/failed/decommissioning status
  - Medium: >25% of all devices at the site are offline
- Backend: /api/locations/<id>/detail now includes an 'alert' key
- Frontend: alert banner shown in popup when detail loads
- Frontend: marker icon updated to orange (medium) or pulsing red (critical)
  after device details are fetched, including co-located markers
- Frontend: legend updated with medium and critical alert entries
Copilot AI changed the title Add GET/POST/DELETE endpoints for roles and location types Add GET/POST/DELETE proxy endpoints for roles and location types Jul 24, 2026
Copilot AI requested a review from Jackass4life July 24, 2026 02:03
Comment thread app.py
roles = fetch_all_pages("extras/roles/")
return jsonify({"roles": roles})
except RuntimeError as exc:
return jsonify({"error": str(exc)}), 503
Comment thread app.py
cache.delete_memoized(fetch_all_pages)
return jsonify(created), 201
except RuntimeError as exc:
return jsonify({"error": str(exc)}), 503
Comment thread app.py
cache.clear()
return jsonify({"status": "deleted", "id": role_id})
except RuntimeError as exc:
return jsonify({"error": str(exc)}), 503
Comment thread app.py
location_types = fetch_all_pages("dcim/location-types/")
return jsonify({"location_types": location_types})
except RuntimeError as exc:
return jsonify({"error": str(exc)}), 503
Comment thread app.py
cache.clear()
return jsonify(created), 201
except RuntimeError as exc:
return jsonify({"error": str(exc)}), 503
Comment thread app.py
cache.clear()
return jsonify({"status": "deleted", "id": lt_id})
except RuntimeError as exc:
return jsonify({"error": str(exc)}), 503
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

Successfully merging this pull request may close these issues.

3 participants