netbox-rack-design 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. netbox_rack_design-0.1.0/CONTRIBUTING.md +121 -0
  2. netbox_rack_design-0.1.0/LICENSE +1 -0
  3. netbox_rack_design-0.1.0/MANIFEST.in +11 -0
  4. netbox_rack_design-0.1.0/PKG-INFO +160 -0
  5. netbox_rack_design-0.1.0/README.md +129 -0
  6. netbox_rack_design-0.1.0/netbox_rack_design/__init__.py +44 -0
  7. netbox_rack_design-0.1.0/netbox_rack_design/api/__init__.py +6 -0
  8. netbox_rack_design-0.1.0/netbox_rack_design/api/serializers.py +52 -0
  9. netbox_rack_design-0.1.0/netbox_rack_design/api/urls.py +14 -0
  10. netbox_rack_design-0.1.0/netbox_rack_design/api/views.py +27 -0
  11. netbox_rack_design-0.1.0/netbox_rack_design/choices.py +39 -0
  12. netbox_rack_design-0.1.0/netbox_rack_design/filtersets.py +81 -0
  13. netbox_rack_design-0.1.0/netbox_rack_design/forms.py +206 -0
  14. netbox_rack_design-0.1.0/netbox_rack_design/graphql/__init__.py +5 -0
  15. netbox_rack_design-0.1.0/netbox_rack_design/graphql/filters.py +23 -0
  16. netbox_rack_design-0.1.0/netbox_rack_design/graphql/schema.py +24 -0
  17. netbox_rack_design-0.1.0/netbox_rack_design/graphql/types.py +41 -0
  18. netbox_rack_design-0.1.0/netbox_rack_design/migrations/0001_initial.py +97 -0
  19. netbox_rack_design-0.1.0/netbox_rack_design/migrations/__init__.py +7 -0
  20. netbox_rack_design-0.1.0/netbox_rack_design/models.py +275 -0
  21. netbox_rack_design-0.1.0/netbox_rack_design/navigation.py +41 -0
  22. netbox_rack_design-0.1.0/netbox_rack_design/search.py +30 -0
  23. netbox_rack_design-0.1.0/netbox_rack_design/tables.py +61 -0
  24. netbox_rack_design-0.1.0/netbox_rack_design/templates/netbox_rack_design/design.html +125 -0
  25. netbox_rack_design-0.1.0/netbox_rack_design/templates/netbox_rack_design/designgroup.html +58 -0
  26. netbox_rack_design-0.1.0/netbox_rack_design/templates/netbox_rack_design/designplacement.html +59 -0
  27. netbox_rack_design-0.1.0/netbox_rack_design/templates/netbox_rack_design/rack-design.html +27 -0
  28. netbox_rack_design-0.1.0/netbox_rack_design/tests/__init__.py +6 -0
  29. netbox_rack_design-0.1.0/netbox_rack_design/tests/test_api.py +138 -0
  30. netbox_rack_design-0.1.0/netbox_rack_design/tests/test_filtersets.py +129 -0
  31. netbox_rack_design-0.1.0/netbox_rack_design/tests/test_graphql.py +74 -0
  32. netbox_rack_design-0.1.0/netbox_rack_design/tests/test_models.py +155 -0
  33. netbox_rack_design-0.1.0/netbox_rack_design/tests/test_views.py +154 -0
  34. netbox_rack_design-0.1.0/netbox_rack_design/tests/utils.py +39 -0
  35. netbox_rack_design-0.1.0/netbox_rack_design/urls.py +17 -0
  36. netbox_rack_design-0.1.0/netbox_rack_design/views.py +168 -0
  37. netbox_rack_design-0.1.0/netbox_rack_design.egg-info/PKG-INFO +160 -0
  38. netbox_rack_design-0.1.0/netbox_rack_design.egg-info/SOURCES.txt +42 -0
  39. netbox_rack_design-0.1.0/netbox_rack_design.egg-info/dependency_links.txt +1 -0
  40. netbox_rack_design-0.1.0/netbox_rack_design.egg-info/requires.txt +6 -0
  41. netbox_rack_design-0.1.0/netbox_rack_design.egg-info/top_level.txt +1 -0
  42. netbox_rack_design-0.1.0/pyproject.toml +80 -0
  43. netbox_rack_design-0.1.0/setup.cfg +4 -0
  44. netbox_rack_design-0.1.0/tests/__init__.py +1 -0
@@ -0,0 +1,121 @@
1
+ # Contributing
2
+
3
+ Contributions are welcome, and they are greatly appreciated! Every little bit
4
+ helps, and credit will always be given.
5
+
6
+ We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
7
+
8
+ - Reporting a bug
9
+ - Discussing the current state of the code
10
+ - Submitting a fix
11
+ - Proposing new features
12
+ - Becoming a maintainer
13
+
14
+ ## General Tips for Working on GitHub
15
+
16
+ * Register for a free [GitHub account](https://github.com/signup) if you haven't already.
17
+ * You can use [GitHub Markdown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) for formatting text and adding images.
18
+ * To help mitigate notification spam, please avoid "bumping" issues with no activity. (To vote an issue up or down, use a :thumbsup: or :thumbsdown: reaction.)
19
+ * Please avoid pinging members with `@` unless they've previously expressed interest or involvement with that particular issue.
20
+ * Familiarize yourself with [this list of discussion anti-patterns](https://github.com/bradfitz/issue-tracker-behaviors) and make every effort to avoid them.
21
+
22
+ ## Types of Contributions
23
+
24
+ ### Report Bugs
25
+
26
+ Report bugs at https://github.com/ravenrs/netbox-rack-design/issues.
27
+
28
+ If you are reporting a bug, please include:
29
+
30
+ * Your operating system name and version.
31
+ * Any details about your local setup that might be helpful in troubleshooting.
32
+ * Detailed steps to reproduce the bug.
33
+
34
+ ### Fix Bugs
35
+
36
+ Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
37
+ wanted" is open to whoever wants to implement it.
38
+
39
+ ### Implement Features
40
+
41
+ Look through the GitHub issues for features. Anything tagged with "enhancement"
42
+ and "help wanted" is open to whoever wants to implement it.
43
+
44
+ ### Write Documentation
45
+
46
+ NetBox Rack Design could always use more documentation, whether as part of the
47
+ official NetBox Rack Design docs, in docstrings, or even on the web in blog posts,
48
+ articles, and such.
49
+
50
+ ### Submit Feedback
51
+
52
+ The best way to send feedback is to file an issue at https://github.com/ravenrs/netbox-rack-design/issues.
53
+
54
+ If you are proposing a feature:
55
+
56
+ * Explain in detail how it would work.
57
+ * Keep the scope as narrow as possible, to make it easier to implement.
58
+ * Remember that this is a volunteer-driven project, and that contributions
59
+ are welcome :)
60
+
61
+ ## Get Started!
62
+
63
+ Ready to contribute? Here's how to set up `netbox-rack-design` for local development.
64
+
65
+ 1. Fork the `netbox-rack-design` repo on GitHub.
66
+ 2. Clone your fork locally
67
+
68
+ ```
69
+ $ git clone git@github.com:your_name_here/netbox-rack-design.git
70
+ ```
71
+
72
+ 3. Activate the NetBox virtual environment (see the NetBox documentation under [Setting up a Development Environment](https://docs.netbox.dev/en/stable/development/getting-started/)):
73
+
74
+ ```
75
+ $ source ~/.venv/netbox/bin/activate
76
+ ```
77
+
78
+ 4. Add the plugin to NetBox virtual environment in Develop mode (see [Plugins Development](https://docs.netbox.dev/en/stable/plugins/development/)):
79
+
80
+ To ease development, it is recommended to go ahead and install the plugin at this point using setuptools' develop mode. This will create symbolic links within your Python environment to the plugin development directory. Call setup.py from the plugin's root directory with the develop argument (instead of install):
81
+
82
+ ```
83
+ $ python setup.py develop
84
+ ```
85
+
86
+ 5. Create a branch for local development:
87
+
88
+ ```
89
+ $ git checkout -b name-of-your-bugfix-or-feature
90
+ ```
91
+
92
+ Now you can make your changes locally.
93
+
94
+ 6. Commit your changes and push your branch to GitHub:
95
+
96
+ ```
97
+ $ git add .
98
+ $ git commit -m "Your detailed description of your changes."
99
+ $ git push origin name-of-your-bugfix-or-feature
100
+ ```
101
+
102
+ 7. Submit a pull request through the GitHub website.
103
+
104
+ ## Pull Request Guidelines
105
+
106
+ Before you submit a pull request, check that it meets these guidelines:
107
+
108
+ 1. The pull request should include tests.
109
+ 2. If the pull request adds functionality, the docs should be updated. Put
110
+ your new functionality into a function with a docstring, and add the
111
+ feature to the list in README.md.
112
+ 3. The pull request should work for Python 3.12, 3.13, and 3.14. Check
113
+ https://github.com/ravenrs/netbox-rack-design/actions
114
+ and make sure that the tests pass for all supported Python versions.
115
+
116
+
117
+ ## Deploying
118
+
119
+ A reminder for the maintainers on how to deploy.
120
+ Make sure all your changes are committed (including an entry in CHANGELOG.md) and that all tests pass.
121
+ Then in the github project go to `Releases` and create a new release with a new tag. This will automatically upload the release to pypi:
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,11 @@
1
+ include CONTRIBUTING.md
2
+ include LICENSE
3
+ include README.md
4
+
5
+ recursive-include tests *
6
+ recursive-exclude * __pycache__
7
+ recursive-exclude * *.py[co]
8
+
9
+ recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
10
+
11
+ graft templates
@@ -0,0 +1,160 @@
1
+ Metadata-Version: 2.4
2
+ Name: netbox-rack-design
3
+ Version: 0.1.0
4
+ Summary: NetBox plugin for Rack Design.
5
+ Author-email: Petr Voronov <ravenrs@gmail.com>
6
+ Project-URL: Documentation, https://github.com/ravenrs/netbox-rack-design/blob/main/README.md
7
+ Project-URL: Source, https://github.com/ravenrs/netbox-rack-design
8
+ Project-URL: Tracker, https://github.com/ravenrs/netbox-rack-design/issues
9
+ Keywords: netbox,netbox-plugin
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Framework :: Django
12
+ Classifier: Framework :: Django :: 5.1
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: System Administrators
15
+ Classifier: Intended Audience :: Telecommunications Industry
16
+ Classifier: Natural Language :: English
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: System :: Networking
22
+ Requires-Python: >=3.12.0
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Provides-Extra: test
26
+ Requires-Dist: check-manifest==0.51; extra == "test"
27
+ Requires-Dist: ruff==0.14.14; extra == "test"
28
+ Requires-Dist: pre-commit==6.0.0; extra == "test"
29
+ Requires-Dist: pytest==9.0.2; extra == "test"
30
+ Dynamic: license-file
31
+
32
+ # NetBox Rack Design
33
+
34
+ NetBox plugin for Rack Design.
35
+
36
+
37
+ * Free software: Apache-2.0
38
+ * Documentation: https://ravenrs.github.io/netbox-rack-design/
39
+
40
+
41
+ ## Features
42
+
43
+ The features the plugin provides should be listed here. For example:
44
+
45
+ - Manage Rack Design resources through NetBox UI
46
+ - Track and organize Rack Design data with custom fields and tags
47
+ - REST API endpoints for programmatic access
48
+ - GraphQL support for flexible data queries
49
+ - Full change logging and journaling support
50
+ - Integration with NetBox's permission system
51
+ - Global search integration for finding Rack Design objects
52
+ - Comprehensive filtering and table views
53
+
54
+ ## Screenshots
55
+
56
+ <!-- Add screenshots or GIFs demonstrating your plugin's functionality here -->
57
+ _Screenshots will be added as features are developed._
58
+
59
+ ## Compatibility
60
+
61
+ This plugin targets **NetBox 4.4.x**.
62
+
63
+ | NetBox Version | Plugin Version |
64
+ |----------------|----------------|
65
+ | 4.4.x | 0.1.0 |
66
+
67
+ For more detailed compatibility information, see [COMPATIBILITY.md](COMPATIBILITY.md).
68
+
69
+ ## Dependencies
70
+
71
+ This plugin requires:
72
+ - NetBox 4.4.0 – 4.4.x
73
+ - Python 3.10 – 3.12
74
+
75
+ No additional Python packages are required beyond NetBox's core dependencies.
76
+
77
+ ## REST API
78
+
79
+ This plugin provides a REST API endpoint for managing Rack Design resources:
80
+
81
+ - `/api/plugins/netbox_rack_design/rack-designs/` - List and create Rackdesign objects
82
+
83
+
84
+ ## GraphQL
85
+
86
+ This plugin provides GraphQL support for querying Rack Design resources through NetBox's GraphQL API.
87
+
88
+
89
+ ## Installing
90
+
91
+ For adding to a NetBox Docker setup see
92
+ [the general instructions for using netbox-docker with plugins](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins).
93
+
94
+ While this is still in development and not yet on pypi you can install with pip:
95
+
96
+ ```bash
97
+ pip install git+https://github.com/ravenrs/netbox-rack-design
98
+ ```
99
+
100
+ or by adding to your `local_requirements.txt` or `plugin_requirements.txt` (netbox-docker):
101
+
102
+ ```bash
103
+ git+https://github.com/ravenrs/netbox-rack-design
104
+ ```
105
+
106
+ Enable the plugin in `/opt/netbox/netbox/netbox/configuration.py`,
107
+ or if you use netbox-docker, your `/configuration/plugins.py` file :
108
+
109
+ ```python
110
+ PLUGINS = [
111
+ 'netbox_rack_design'
112
+ ]
113
+
114
+ PLUGINS_CONFIG = {
115
+ "netbox_rack_design": {},
116
+ }
117
+ ```
118
+
119
+ ## Configuration
120
+
121
+ This plugin does not require any additional configuration by default. Optional configuration parameters can be added to `PLUGINS_CONFIG` in your NetBox configuration file as needed.
122
+
123
+ ## Usage
124
+
125
+ For detailed usage instructions, please refer to the [documentation](https://ravenrs.github.io/netbox-rack-design/).
126
+
127
+ ## Contributing
128
+
129
+ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
130
+
131
+ ### Reporting Bugs
132
+
133
+ Please report bugs by opening an issue on our [GitHub Issues](https://github.com/ravenrs/netbox-rack-design/issues) page. When reporting bugs, please include:
134
+
135
+ - NetBox version
136
+ - Plugin version
137
+ - Python version
138
+ - Steps to reproduce
139
+ - Expected behavior
140
+ - Actual behavior
141
+
142
+ ### Feature Requests
143
+
144
+ Feature requests can be submitted as [GitHub Issues](https://github.com/ravenrs/netbox-rack-design/issues) with the "enhancement" label.
145
+
146
+ ## Support
147
+
148
+ - **Documentation**: https://ravenrs.github.io/netbox-rack-design/
149
+ - **Issues**: https://github.com/ravenrs/netbox-rack-design/issues
150
+ - **Discussions**: https://github.com/ravenrs/netbox-rack-design/discussions
151
+ - **NetBox Community Slack**: [netdev-community.slack.com](https://netdev.chat/)
152
+
153
+ ## Credits
154
+
155
+ Based on the NetBox plugin tutorial:
156
+
157
+ - [demo repository](https://github.com/netbox-community/netbox-plugin-demo)
158
+ - [tutorial](https://github.com/netbox-community/netbox-plugin-tutorial)
159
+
160
+ This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [`netbox-community/cookiecutter-netbox-plugin`](https://github.com/netbox-community/cookiecutter-netbox-plugin) project template.
@@ -0,0 +1,129 @@
1
+ # NetBox Rack Design
2
+
3
+ NetBox plugin for Rack Design.
4
+
5
+
6
+ * Free software: Apache-2.0
7
+ * Documentation: https://ravenrs.github.io/netbox-rack-design/
8
+
9
+
10
+ ## Features
11
+
12
+ The features the plugin provides should be listed here. For example:
13
+
14
+ - Manage Rack Design resources through NetBox UI
15
+ - Track and organize Rack Design data with custom fields and tags
16
+ - REST API endpoints for programmatic access
17
+ - GraphQL support for flexible data queries
18
+ - Full change logging and journaling support
19
+ - Integration with NetBox's permission system
20
+ - Global search integration for finding Rack Design objects
21
+ - Comprehensive filtering and table views
22
+
23
+ ## Screenshots
24
+
25
+ <!-- Add screenshots or GIFs demonstrating your plugin's functionality here -->
26
+ _Screenshots will be added as features are developed._
27
+
28
+ ## Compatibility
29
+
30
+ This plugin targets **NetBox 4.4.x**.
31
+
32
+ | NetBox Version | Plugin Version |
33
+ |----------------|----------------|
34
+ | 4.4.x | 0.1.0 |
35
+
36
+ For more detailed compatibility information, see [COMPATIBILITY.md](COMPATIBILITY.md).
37
+
38
+ ## Dependencies
39
+
40
+ This plugin requires:
41
+ - NetBox 4.4.0 – 4.4.x
42
+ - Python 3.10 – 3.12
43
+
44
+ No additional Python packages are required beyond NetBox's core dependencies.
45
+
46
+ ## REST API
47
+
48
+ This plugin provides a REST API endpoint for managing Rack Design resources:
49
+
50
+ - `/api/plugins/netbox_rack_design/rack-designs/` - List and create Rackdesign objects
51
+
52
+
53
+ ## GraphQL
54
+
55
+ This plugin provides GraphQL support for querying Rack Design resources through NetBox's GraphQL API.
56
+
57
+
58
+ ## Installing
59
+
60
+ For adding to a NetBox Docker setup see
61
+ [the general instructions for using netbox-docker with plugins](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins).
62
+
63
+ While this is still in development and not yet on pypi you can install with pip:
64
+
65
+ ```bash
66
+ pip install git+https://github.com/ravenrs/netbox-rack-design
67
+ ```
68
+
69
+ or by adding to your `local_requirements.txt` or `plugin_requirements.txt` (netbox-docker):
70
+
71
+ ```bash
72
+ git+https://github.com/ravenrs/netbox-rack-design
73
+ ```
74
+
75
+ Enable the plugin in `/opt/netbox/netbox/netbox/configuration.py`,
76
+ or if you use netbox-docker, your `/configuration/plugins.py` file :
77
+
78
+ ```python
79
+ PLUGINS = [
80
+ 'netbox_rack_design'
81
+ ]
82
+
83
+ PLUGINS_CONFIG = {
84
+ "netbox_rack_design": {},
85
+ }
86
+ ```
87
+
88
+ ## Configuration
89
+
90
+ This plugin does not require any additional configuration by default. Optional configuration parameters can be added to `PLUGINS_CONFIG` in your NetBox configuration file as needed.
91
+
92
+ ## Usage
93
+
94
+ For detailed usage instructions, please refer to the [documentation](https://ravenrs.github.io/netbox-rack-design/).
95
+
96
+ ## Contributing
97
+
98
+ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
99
+
100
+ ### Reporting Bugs
101
+
102
+ Please report bugs by opening an issue on our [GitHub Issues](https://github.com/ravenrs/netbox-rack-design/issues) page. When reporting bugs, please include:
103
+
104
+ - NetBox version
105
+ - Plugin version
106
+ - Python version
107
+ - Steps to reproduce
108
+ - Expected behavior
109
+ - Actual behavior
110
+
111
+ ### Feature Requests
112
+
113
+ Feature requests can be submitted as [GitHub Issues](https://github.com/ravenrs/netbox-rack-design/issues) with the "enhancement" label.
114
+
115
+ ## Support
116
+
117
+ - **Documentation**: https://ravenrs.github.io/netbox-rack-design/
118
+ - **Issues**: https://github.com/ravenrs/netbox-rack-design/issues
119
+ - **Discussions**: https://github.com/ravenrs/netbox-rack-design/discussions
120
+ - **NetBox Community Slack**: [netdev-community.slack.com](https://netdev.chat/)
121
+
122
+ ## Credits
123
+
124
+ Based on the NetBox plugin tutorial:
125
+
126
+ - [demo repository](https://github.com/netbox-community/netbox-plugin-demo)
127
+ - [tutorial](https://github.com/netbox-community/netbox-plugin-tutorial)
128
+
129
+ This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [`netbox-community/cookiecutter-netbox-plugin`](https://github.com/netbox-community/cookiecutter-netbox-plugin) project template.
@@ -0,0 +1,44 @@
1
+ """
2
+ NetBox Rack Design
3
+
4
+ Plugin configuration for NetBox Rack Design.
5
+
6
+ For a complete list of PluginConfig attributes, see:
7
+ https://docs.netbox.dev/en/stable/plugins/development/#pluginconfig-attributes
8
+ """
9
+
10
+ __author__ = """Petr Voronov"""
11
+ __email__ = "ravenrs@gmail.com"
12
+ __version__ = "0.1.0"
13
+
14
+
15
+ from netbox.plugins import PluginConfig
16
+
17
+
18
+ class RackdesignConfig(PluginConfig):
19
+ name = "netbox_rack_design"
20
+ verbose_name = "NetBox Rack Design"
21
+ description = "NetBox plugin for Rack Design."
22
+ author= "Petr Voronov"
23
+ author_email = "ravenrs@gmail.com"
24
+ version = __version__
25
+ base_url = "rack-design"
26
+ min_version = "4.4.0"
27
+ max_version = "4.4.99"
28
+ graphql_schema = "graphql.schema"
29
+ default_settings = {
30
+ # Device statuses the plugin treats as "planned".
31
+ "planned_statuses": ["planned"],
32
+ # Device statuses that mark a planned removal. Default uses native
33
+ # 'decommissioning'. Environments where that status is destructive
34
+ # (auto-delete / inventory dismantle) should override with a custom
35
+ # status added via FIELD_CHOICES (e.g. 'to_decommission').
36
+ "removal_statuses": ["decommissioning"],
37
+ # Default lifecycle status for a new Design.
38
+ "default_status": "draft",
39
+ # Show the rack-page panel listing designs that touch a rack.
40
+ "enable_rack_panel": True,
41
+ }
42
+
43
+
44
+ config = RackdesignConfig
@@ -0,0 +1,6 @@
1
+ """
2
+ REST API for NetBox Rack Design.
3
+
4
+ For more information on developing NetBox REST APIs, see:
5
+ https://docs.netbox.dev/en/stable/plugins/development/rest-api/
6
+ """
@@ -0,0 +1,52 @@
1
+ """REST API serializers for NetBox Rack Design."""
2
+
3
+ from netbox.api.serializers import NetBoxModelSerializer
4
+ from rest_framework import serializers
5
+
6
+ from ..models import Design, DesignGroup, DesignPlacement
7
+
8
+ __all__ = ("DesignGroupSerializer", "DesignSerializer", "DesignPlacementSerializer")
9
+
10
+
11
+ class DesignGroupSerializer(NetBoxModelSerializer):
12
+ url = serializers.HyperlinkedIdentityField(
13
+ view_name="plugins-api:netbox_rack_design-api:designgroup-detail"
14
+ )
15
+
16
+ class Meta:
17
+ model = DesignGroup
18
+ fields = (
19
+ "id", "url", "display", "name", "parent", "description", "link",
20
+ "tags", "custom_fields", "created", "last_updated",
21
+ )
22
+ brief_fields = ("id", "url", "display", "name")
23
+
24
+
25
+ class DesignSerializer(NetBoxModelSerializer):
26
+ url = serializers.HyperlinkedIdentityField(
27
+ view_name="plugins-api:netbox_rack_design-api:design-detail"
28
+ )
29
+
30
+ class Meta:
31
+ model = Design
32
+ fields = (
33
+ "id", "url", "display", "title", "site", "status", "summary", "link",
34
+ "version", "root", "based_on", "sequence", "depends_on", "group",
35
+ "description", "comments", "tags", "custom_fields", "created", "last_updated",
36
+ )
37
+ brief_fields = ("id", "url", "display", "title", "version", "status")
38
+
39
+
40
+ class DesignPlacementSerializer(NetBoxModelSerializer):
41
+ url = serializers.HyperlinkedIdentityField(
42
+ view_name="plugins-api:netbox_rack_design-api:designplacement-detail"
43
+ )
44
+
45
+ class Meta:
46
+ model = DesignPlacement
47
+ fields = (
48
+ "id", "url", "display", "design", "kind", "device", "device_type",
49
+ "proposed_name", "target_rack", "target_position", "target_face",
50
+ "tags", "custom_fields", "created", "last_updated",
51
+ )
52
+ brief_fields = ("id", "url", "display", "kind")
@@ -0,0 +1,14 @@
1
+ """REST API URL routing for NetBox Rack Design."""
2
+
3
+ from netbox.api.routers import NetBoxRouter
4
+
5
+ from .views import DesignGroupViewSet, DesignPlacementViewSet, DesignViewSet
6
+
7
+ app_name = "netbox_rack_design"
8
+
9
+ router = NetBoxRouter()
10
+ router.register("design-groups", DesignGroupViewSet)
11
+ router.register("designs", DesignViewSet)
12
+ router.register("placements", DesignPlacementViewSet)
13
+
14
+ urlpatterns = router.urls
@@ -0,0 +1,27 @@
1
+ """REST API viewsets for NetBox Rack Design."""
2
+
3
+ from netbox.api.viewsets import NetBoxModelViewSet
4
+
5
+ from .. import filtersets
6
+ from ..models import Design, DesignGroup, DesignPlacement
7
+ from .serializers import DesignGroupSerializer, DesignPlacementSerializer, DesignSerializer
8
+
9
+ __all__ = ("DesignGroupViewSet", "DesignViewSet", "DesignPlacementViewSet")
10
+
11
+
12
+ class DesignGroupViewSet(NetBoxModelViewSet):
13
+ queryset = DesignGroup.objects.all()
14
+ serializer_class = DesignGroupSerializer
15
+ filterset_class = filtersets.DesignGroupFilterSet
16
+
17
+
18
+ class DesignViewSet(NetBoxModelViewSet):
19
+ queryset = Design.objects.prefetch_related("placements", "depends_on", "tags")
20
+ serializer_class = DesignSerializer
21
+ filterset_class = filtersets.DesignFilterSet
22
+
23
+
24
+ class DesignPlacementViewSet(NetBoxModelViewSet):
25
+ queryset = DesignPlacement.objects.all()
26
+ serializer_class = DesignPlacementSerializer
27
+ filterset_class = filtersets.DesignPlacementFilterSet
@@ -0,0 +1,39 @@
1
+ """
2
+ Choice sets for NetBox Rack Design.
3
+
4
+ Uses NetBox's built-in ``ChoiceSet`` (utilities.choices), per the plugin
5
+ development guide. Defining ``key`` lets administrators extend/replace these
6
+ choices via ``FIELD_CHOICES`` in configuration.py.
7
+ """
8
+
9
+ from utilities.choices import ChoiceSet
10
+
11
+
12
+ class DesignStatusChoices(ChoiceSet):
13
+ key = "Design.status"
14
+
15
+ STATUS_DRAFT = "draft"
16
+ STATUS_APPROVED = "approved"
17
+ STATUS_REJECTED = "rejected"
18
+ STATUS_IMPLEMENTED = "implemented"
19
+ STATUS_SUPERSEDED = "superseded"
20
+
21
+ CHOICES = [
22
+ (STATUS_DRAFT, "Draft", "cyan"),
23
+ (STATUS_APPROVED, "Approved", "green"),
24
+ (STATUS_REJECTED, "Rejected", "red"),
25
+ (STATUS_IMPLEMENTED, "Implemented", "blue"),
26
+ (STATUS_SUPERSEDED, "Superseded", "gray"),
27
+ ]
28
+
29
+
30
+ class DesignPlacementKindChoices(ChoiceSet):
31
+ KIND_ADD = "add"
32
+ KIND_MOVE = "move"
33
+ KIND_REMOVE = "remove"
34
+
35
+ CHOICES = [
36
+ (KIND_ADD, "Add", "green"),
37
+ (KIND_MOVE, "Move", "blue"),
38
+ (KIND_REMOVE, "Remove", "red"),
39
+ ]