-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closes #19002: Module type profiles #19014
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
65ad972
Move Module & ModuleType models to a separate file
jeremystretch 678e6f1
Add ModuleTypeProfile & related fields
jeremystretch 69e67d0
Initial work on JSON schema validation
jeremystretch 3cda074
Add attributes property on ModuleType
jeremystretch 93bd2ee
Introduce MultipleOfValidator
jeremystretch a67ea13
Introduce JSONSchemaProperty
jeremystretch 5f70732
Enable dynamic form field rendering
jeremystretch ad9c5ca
Misc cleanup
jeremystretch c1ff89e
Fix migration conflict
jeremystretch 0d2a8b8
Ensure deterministic ordering of attriubte fields
jeremystretch dc46cb2
Support choices & default values
jeremystretch 56d163e
Include module type attributes on module view
jeremystretch 4fd3a91
Enable modifying individual attributes via REST API
jeremystretch 94b3aae
Enable filtering by attribute values
jeremystretch 7edc67e
Add documentation & tests
jeremystretch 1be9209
Schema should be optional
jeremystretch 9f16e43
Include attributes column for profiles
jeremystretch 9bc2ad4
Profile is nullable
jeremystretch 5de244f
Include some initial profiles to be installed via migration
jeremystretch 96462e9
Fix migrations conflict
jeremystretch 668cfaf
Fix filterset test
jeremystretch 5c85805
Misc cleanup
jeremystretch 9ee9cc7
Fixes #19023: get_field_value() should respect null values in bound f…
jeremystretch 26efdde
Skip filters which do not specify a JSON-serializable value
jeremystretch 4c98b0f
Fix handling of array item types
jeremystretch f1092d3
Fix initial data in schema field during bulk edit
jeremystretch ef43bdf
Implement sanity checking for JSON schema definitions
jeremystretch 550152d
Fall back to filtering by string value
jeremystretch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Module Type Profiles | ||
|
|
||
| !!! info "This model was introduced in NetBox v4.3." | ||
|
|
||
| Each [module type](./moduletype.md) may optionally be assigned a profile according to its classification. A profile can extend module types with user-configured attributes. For example, you might want to specify the input current and voltage of a power supply, or the clock speed and number of cores for a processor. | ||
|
|
||
| Module type attributes are managed via the configuration of a [JSON schema](https://json-schema.org/) on the profile. For example, the following schema introduces three module type attributes, two of which are designated as required attributes. | ||
|
|
||
| ```json | ||
| { | ||
| "properties": { | ||
| "type": { | ||
| "type": "string", | ||
| "title": "Disk type", | ||
| "enum": ["HD", "SSD", "NVME"], | ||
| "default": "HD" | ||
| }, | ||
| "capacity": { | ||
| "type": "integer", | ||
| "title": "Capacity (GB)", | ||
| "description": "Gross disk size" | ||
| }, | ||
| "speed": { | ||
| "type": "integer", | ||
| "title": "Speed (RPM)" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "type", "capacity" | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| The assignment of module types to a profile is optional. The designation of a schema for a profile is also optional: A profile can be used simply as a mechanism for classifying module types if the addition of custom attributes is not needed. | ||
|
|
||
| ## Fields | ||
|
|
||
| ### Schema | ||
|
|
||
| This field holds the [JSON schema](https://json-schema.org/) for the profile. The configured JSON schema must be valid (or the field must be null). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed thatschemavalues ofnulland""don't affect any change on the items selected. However, I noticed that{}does essentially clear the schemas of the selected items.This might be the intended behavior, but was not super intuitive.Resolved
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relatedly,trueandfalseliterals were accepted as valid input for this field, even though they don't necessarily make sense.Perhaps values should be locked down to some representation of no schema (nullor{}perhaps) and some schema that is at least of type object. Not sure, though, just thinking out loud.Resolved