mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 04:02:52 -06:00
Closes #2671: Add documentation of API brief format
This commit is contained in:
parent
3480832bf5
commit
785cdcefd6
@ -122,6 +122,52 @@ When a base serializer includes one or more nested serializers, the hierarchical
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Brief Format
|
||||||
|
|
||||||
|
Most API endpoints support an optional "brief" format, which returns only a minimal representation of each object in the response. This is useful when you need only a list of the objects themselves without any related data, such as when populating a drop-down list in a form.
|
||||||
|
|
||||||
|
For example, the default (complete) format of an IP address looks like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
GET /api/ipam/prefixes/13980/
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": 13980,
|
||||||
|
"family": 4,
|
||||||
|
"prefix": "192.0.2.0/24",
|
||||||
|
"site": null,
|
||||||
|
"vrf": null,
|
||||||
|
"tenant": null,
|
||||||
|
"vlan": null,
|
||||||
|
"status": {
|
||||||
|
"value": 1,
|
||||||
|
"label": "Active"
|
||||||
|
},
|
||||||
|
"role": null,
|
||||||
|
"is_pool": false,
|
||||||
|
"description": "",
|
||||||
|
"tags": [],
|
||||||
|
"custom_fields": {},
|
||||||
|
"created": "2018-12-11",
|
||||||
|
"last_updated": "2018-12-11T16:27:55.073174-05:00"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The brief format is much more terse, but includes a link to the object's full representation:
|
||||||
|
|
||||||
|
```
|
||||||
|
GET /api/ipam/prefixes/13980/?brief=1
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": 13980,
|
||||||
|
"url": "https://netbox/api/ipam/prefixes/13980/",
|
||||||
|
"family": 4,
|
||||||
|
"prefix": "192.0.2.0/24"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The brief format is supported for both lists and individual objects.
|
||||||
|
|
||||||
## Static Choice Fields
|
## Static Choice Fields
|
||||||
|
|
||||||
Some model fields, such as the `status` field in the above example, utilize static integers corresponding to static choices. The available choices can be retrieved from the read-only `_choices` endpoint within each app. A specific `model:field` tuple may optionally be specified in the URL.
|
Some model fields, such as the `status` field in the above example, utilize static integers corresponding to static choices. The available choices can be retrieved from the read-only `_choices` endpoint within each app. A specific `model:field` tuple may optionally be specified in the URL.
|
||||||
|
Loading…
Reference in New Issue
Block a user