[PR #3732] [MERGED] Replace API integer API choice values with slugs #12623

Closed
opened 2025-12-29 22:22:42 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/3732
Author: @jeremystretch
Created: 12/5/2019
Status: Merged
Merged: 12/5/2019
Merged by: @jeremystretch

Base: develop-2.7Head: 3569-api-choice-slugs


📝 Commits (10+)

📊 Changes

76 files changed (+2760 additions, -1401 deletions)

View changed files

📝 netbox/circuits/api/serializers.py (+2 -2)
netbox/circuits/choices.py (+48 -0)
netbox/circuits/constants.py (+0 -23)
📝 netbox/circuits/filters.py (+2 -2)
📝 netbox/circuits/forms.py (+4 -4)
netbox/circuits/migrations/0016_3569_circuit_fields.py (+39 -0)
📝 netbox/circuits/models.py (+17 -7)
📝 netbox/circuits/tests/test_api.py (+28 -13)
📝 netbox/circuits/views.py (+9 -5)
📝 netbox/dcim/api/serializers.py (+34 -34)
📝 netbox/dcim/choices.py (+493 -120)
📝 netbox/dcim/constants.py (+9 -469)
📝 netbox/dcim/filters.py (+9 -9)
📝 netbox/dcim/fixtures/dcim.json (+11 -11)
📝 netbox/dcim/forms.py (+82 -99)
netbox/dcim/migrations/0078_3569_site_fields.py (+35 -0)
netbox/dcim/migrations/0079_3569_rack_fields.py (+92 -0)
netbox/dcim/migrations/0080_3569_devicetype_fields.py (+39 -0)
netbox/dcim/migrations/0081_3569_device_fields.py (+65 -0)
netbox/dcim/migrations/0082_3569_interface_fields.py (+147 -0)

...and 56 more files

📄 Description

Fixes: #3569

Replaces all numeric choices with more human-friendly slugs. For example, the dcim.Site status field changes from

    "status": {
        "value": 1,
        "label": "Active"
    },

to

    "status": {
        "value": "active",
        "label": "Active"
    },

For backward-compatibility purposes, the legacy integer values will still be accepted on write through the v2.7 release cycle.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/3732 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 12/5/2019 **Status:** ✅ Merged **Merged:** 12/5/2019 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop-2.7` ← **Head:** `3569-api-choice-slugs` --- ### 📝 Commits (10+) - [`a2a6b75`](https://github.com/netbox-community/netbox/commit/a2a6b754befc9dbd61dc26db6d5deab2db180f52) Introduce ChoiceSet class for field choices - [`e09ad69`](https://github.com/netbox-community/netbox/commit/e09ad6915fd1702b3e06592f3cdf30b601b9f346) Circuit.status (#3569) - [`62b4549`](https://github.com/netbox-community/netbox/commit/62b45494b69987d99b1a02af5d2152dc9a88d7c6) Convert all DCIM choice classes to ChoiceSets - [`8d27b62`](https://github.com/netbox-community/netbox/commit/8d27b62114c582bf8e5ae268945b448c33509e9f) Rack.status to slug (#3569) - [`07aa036`](https://github.com/netbox-community/netbox/commit/07aa036fe8fb8e6b1eb925313963f3a139e1e80d) Convert RACK_WIDTH_CHOICES to ChoiceSet - [`e1e09bf`](https://github.com/netbox-community/netbox/commit/e1e09bff9b15c512e67c7cab82b8c7be7c112ef8) Correct Rack.type migration logic - [`c79c29e`](https://github.com/netbox-community/netbox/commit/c79c29e7692483f64f5375a0634cc44d5369a98a) Rack.status to slug (#3569) - [`a8db07e`](https://github.com/netbox-community/netbox/commit/a8db07e0a849b2572ab9004619ac4eacee255467) Device.face to slug (#3569) - [`88b8cf3`](https://github.com/netbox-community/netbox/commit/88b8cf33603a581948bd8e237a8f42355c36903f) Tweak migrations to handle NULL values - [`4f0d82a`](https://github.com/netbox-community/netbox/commit/4f0d82ac168913b4a6289b2740dbf7cc309161a2) Standardize migration names for #3569 ### 📊 Changes **76 files changed** (+2760 additions, -1401 deletions) <details> <summary>View changed files</summary> 📝 `netbox/circuits/api/serializers.py` (+2 -2) ➕ `netbox/circuits/choices.py` (+48 -0) ➖ `netbox/circuits/constants.py` (+0 -23) 📝 `netbox/circuits/filters.py` (+2 -2) 📝 `netbox/circuits/forms.py` (+4 -4) ➕ `netbox/circuits/migrations/0016_3569_circuit_fields.py` (+39 -0) 📝 `netbox/circuits/models.py` (+17 -7) 📝 `netbox/circuits/tests/test_api.py` (+28 -13) 📝 `netbox/circuits/views.py` (+9 -5) 📝 `netbox/dcim/api/serializers.py` (+34 -34) 📝 `netbox/dcim/choices.py` (+493 -120) 📝 `netbox/dcim/constants.py` (+9 -469) 📝 `netbox/dcim/filters.py` (+9 -9) 📝 `netbox/dcim/fixtures/dcim.json` (+11 -11) 📝 `netbox/dcim/forms.py` (+82 -99) ➕ `netbox/dcim/migrations/0078_3569_site_fields.py` (+35 -0) ➕ `netbox/dcim/migrations/0079_3569_rack_fields.py` (+92 -0) ➕ `netbox/dcim/migrations/0080_3569_devicetype_fields.py` (+39 -0) ➕ `netbox/dcim/migrations/0081_3569_device_fields.py` (+65 -0) ➕ `netbox/dcim/migrations/0082_3569_interface_fields.py` (+147 -0) _...and 56 more files_ </details> ### 📄 Description ### Fixes: #3569 Replaces all numeric choices with more human-friendly slugs. For example, the `dcim.Site` status field changes from ```json "status": { "value": 1, "label": "Active" }, ``` to ```json "status": { "value": "active", "label": "Active" }, ``` For backward-compatibility purposes, the legacy integer values will still be accepted on write through the v2.7 release cycle. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:22:42 +01:00
adam closed this issue 2025-12-29 22:22:42 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12623