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

Insert Nested Documents objects in REST API for assigned models #50

Open
marcosmas28 opened this issue Dec 18, 2023 · 0 comments
Open

Comments

@marcosmas28
Copy link
Contributor

marcosmas28 commented Dec 18, 2023

Hi,

With the template_content.py script we can extend the GUI of the assigned objects (Sites, Locations, Devices, Circuits) to show the documents they have attached.

How could we do the same for the REST API interface?
For instance, when I request http://<NETBOX_URL>/api/dcim/devices/<device_id>/ I would like to get some info about the documents this device has attached.

Example (see last part "documents"):

HTTP 200 OK
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 65,
    "url": "http://<NETBOX_URL>/api/dcim/devices/65/",
    "display": "7750SR_01",
    "name": "7750SR_01",
    "device_type": {
        "id": 21,
        "url": "http://<NETBOX_URL>/api/dcim/device-types/21/",
        "display": "7750 SR-12",
        "manufacturer": {
            "id": 4,
            "url": "http://<NETBOX_URL>/api/dcim/manufacturers/4/",
            "display": "Nokia",
            "name": "Nokia",
            "slug": "nokia"
        },
        "model": "7750 SR-12",
        "slug": "7750-sr-12"
    },
    "role": {
        "id": 3,
        "url": "http://<NETBOX_URL>/api/dcim/device-roles/3/",
        "display": "ROUTERS",
        "name": "ROUTERS",
        "slug": "routers"
    },
    "documents":{
        "id": <my_device_document_id>,
        "url": <my_device_document_url>,
        "name": <my_device_document_name>,
        "document_type": <my_device_document_type>
    },
...

Thanks for the guidance!

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

1 participant