[PR #2428] [CLOSED] Generic Relation for Secrets (Needs API feedback) #12369

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/2428
Author: @AndyGauge
Created: 9/14/2018
Status: Closed

Base: developHead: 1503_generic_secrets


📝 Commits (1)

  • bbc66b5 Generic Relation for Secrets

📊 Changes

14 files changed (+165 additions, -42 deletions)

View changed files

📝 netbox/dcim/api/serializers.py (+1 -0)
📝 netbox/dcim/models.py (+3 -0)
📝 netbox/secrets/api/serializers.py (+15 -4)
📝 netbox/secrets/api/views.py (+1 -1)
📝 netbox/secrets/filters.py (+1 -1)
netbox/secrets/migrations/0006_foregin_key_generic.py (+20 -0)
netbox/secrets/migrations/0007_populate_generic_foregin_key.py (+22 -0)
netbox/secrets/migrations/0008_create_related_object.py (+32 -0)
📝 netbox/secrets/models.py (+31 -13)
📝 netbox/secrets/tables.py (+2 -2)
📝 netbox/secrets/tests/test_api.py (+13 -8)
📝 netbox/secrets/views.py (+19 -8)
📝 netbox/templates/secrets/secret.html (+3 -3)
📝 netbox/templates/secrets/secret_edit.html (+2 -2)

📄 Description

Fixes: #1503

Fixes: #1503

This change replaces the Device Foreign Key with a GenericRelationship that allows extending the scope of Secrets. Currently there are test failures for the API updating devices. This work does not include extending the Secrets to any additional objects, yet. This is an example output from the api:

{
    "id": 1,
    "object": {
        "id": 1,
        "url": "http://localhost:8000/api/dcim/devices/1/",
        "name": "a",
        "display_name": "a",
        "class": "device"
    },
    "role": {
        "id": 1,
        "url": "http://localhost:8000/api/secrets/secret-roles/1/",
        "name": "Login Credentials",
        "slug": "login-credentials"
    },
    "name": "ab",
    "plaintext": "--",
    "hash": "------",
    "tags": [],
    "custom_fields": {},
    "created": "2018-08-10",
    "last_updated": "2018-08-10T18:00:23.899052Z"
}

The 'device' node is replaced with 'object' which includes the 'class' of 'device'


🔄 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/2428 **Author:** [@AndyGauge](https://github.com/AndyGauge) **Created:** 9/14/2018 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `1503_generic_secrets` --- ### 📝 Commits (1) - [`bbc66b5`](https://github.com/netbox-community/netbox/commit/bbc66b5a66b9c6173367acb8cc08e7f81cb08392) Generic Relation for Secrets ### 📊 Changes **14 files changed** (+165 additions, -42 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/api/serializers.py` (+1 -0) 📝 `netbox/dcim/models.py` (+3 -0) 📝 `netbox/secrets/api/serializers.py` (+15 -4) 📝 `netbox/secrets/api/views.py` (+1 -1) 📝 `netbox/secrets/filters.py` (+1 -1) ➕ `netbox/secrets/migrations/0006_foregin_key_generic.py` (+20 -0) ➕ `netbox/secrets/migrations/0007_populate_generic_foregin_key.py` (+22 -0) ➕ `netbox/secrets/migrations/0008_create_related_object.py` (+32 -0) 📝 `netbox/secrets/models.py` (+31 -13) 📝 `netbox/secrets/tables.py` (+2 -2) 📝 `netbox/secrets/tests/test_api.py` (+13 -8) 📝 `netbox/secrets/views.py` (+19 -8) 📝 `netbox/templates/secrets/secret.html` (+3 -3) 📝 `netbox/templates/secrets/secret_edit.html` (+2 -2) </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be opened for approval prior to filing a pull request. This helps avoid wasting time and effort on something that we might not be able to accept. Please indicate the relevant feature request or bug report below. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ACCEPTED BUG REPORT OR FEATURE REQUEST, IT WILL BE MARKED AS INVALID AND CLOSED. --> ### Fixes: #1503 <!-- Please include a summary of the proposed changes below. --> <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be opened for approval prior to filing a pull request. This helps avoid wasting time and effort on something that we might not be able to accept. Please indicate the relevant feature request or bug report below. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ACCEPTED BUG REPORT OR FEATURE REQUEST, IT WILL BE MARKED AS INVALID AND CLOSED. --> ### Fixes: #1503 <!-- Please include a summary of the proposed changes below. --> This change replaces the Device Foreign Key with a GenericRelationship that allows extending the scope of Secrets. Currently there are test failures for the API updating devices. This work does not include extending the Secrets to any additional objects, yet. This is an example output from the api: ``` { "id": 1, "object": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "a", "display_name": "a", "class": "device" }, "role": { "id": 1, "url": "http://localhost:8000/api/secrets/secret-roles/1/", "name": "Login Credentials", "slug": "login-credentials" }, "name": "ab", "plaintext": "--", "hash": "------", "tags": [], "custom_fields": {}, "created": "2018-08-10", "last_updated": "2018-08-10T18:00:23.899052Z" } ``` The 'device' node is replaced with 'object' which includes the 'class' of 'device' --- <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:21:07 +01:00
adam closed this issue 2025-12-29 22:21:07 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12369