Skip to content
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

Add JSON type for custom fields #897

Closed
4 tasks
jedelman8 opened this issue Sep 8, 2021 · 8 comments · Fixed by #1075
Closed
4 tasks

Add JSON type for custom fields #897

jedelman8 opened this issue Sep 8, 2021 · 8 comments · Fixed by #1075
Assignees
Labels
good first issue Great issues for newcomers! type: feature Introduction of new or enhanced functionality to the application
Milestone

Comments

@jedelman8
Copy link
Contributor

jedelman8 commented Sep 8, 2021

Overview

Users often need to support more advanced data structures as a custom field. This would add support for a JSON type to this list of available options when creating a CF.

image

User Story

As Austin a Network Automation Engineer,
I want to be able to create custom fields that can store JSON data,
so that I am not required to use config contexts. This will allow me to ensure these fields are "required" when adding/editing objects.

Acceptance Criteria

  • Allows a CF to be of "JSON" data type
  • Validates submitted data is valid JSON
  • To view CF data of JSON type, a "View Value" link should be presented to see the full payload. This keeps the UI clean for large JSON values.
  • Basic searching (icontains) of JSON custom fields in UI and API

Out of Scope

  • Is it NOT expected to be able to search into the field value
@jedelman8 jedelman8 added workflow: under review type: feature Introduction of new or enhanced functionality to the application labels Sep 8, 2021
@sirtux
Copy link
Contributor

sirtux commented Sep 8, 2021

I think this is a very desirable feature, right now I misuse the comment field for that, as a custom text field cannot be long enough...

@glennmatthews
Copy link
Contributor

Would the idea here be to use JSON custom fields to store "large"/"complex" data that isn't more suitably represented as a collection of individual value custom fields (text/integer/boolean)?

It seems like if we go this direction we'd also want to link JSON custom fields with the JSON schema feature for format validation/enforcement - does this make sense as an additional requirement?

@glennmatthews glennmatthews mentioned this issue Sep 8, 2021
14 tasks
@jedelman8
Copy link
Contributor Author

Would the idea here be to use JSON custom fields to store "large"/"complex" data that isn't more suitably represented as a collection of individual value custom fields (text/integer/boolean)?

Yes, and data that inherently has some relationship and hierarchy to it.

It seems like if we go this direction we'd also want to link JSON custom fields with the JSON schema feature for format validation/enforcement - does this make sense as an additional requirement?

I didn't mention that as I thought we would have that as a separate issue and possibly not in the initial implementation. Thoughts? Is it possible to use the implementation of the Context Schemas?

@sirtux
Copy link
Contributor

sirtux commented Sep 8, 2021

Would the idea here be to use JSON custom fields to store "large"/"complex" data that isn't more suitably represented as a collection of individual value custom fields (text/integer/boolean)?

Yes, for example I have VMs which have multiple assigned SSH Keys, and I don't know how many beforehand. So I have a JSON dict, which has this information. As well the storage information for a VM.

The "right" way would be to extend all the models with the relevant stuff, but I'd like to stay with the default nautobot installation, as everything else will cause problems in the future (with updates) etc...

It seems like if we go this direction we'd also want to link JSON custom fields with the JSON schema feature for format validation/enforcement - does this make sense as an additional requirement?

That would be cool - but I think a little bit grander: Why not having the relevant information from the schema available as direct fields, instead as one large JSON blob? I could then define my further required options without "coding", and maybe directly access and search for items in this json?

This, however, is a much larger scope then just adding the fields..

@jedelman8
Copy link
Contributor Author

That would be cool - but I think a little bit grander: Why not having the relevant information from the schema available as direct fields, instead as one large JSON blob? I could then define my further required options without "coding", and maybe directly access and search for items in this json? This, however, is a much larger scope then just adding the fields..

Yes, 100%. From a practical perspective, we can build out the feature in 3 steps: 1) add JSON support (no schema) 2) add JSON schema support 3) look to auto-generate forms based on the schema. For this FR, it is just 1.

@jedelman8
Copy link
Contributor Author

Initially taking on the JSON support (no schema) per #1 above.

@sirtux
Copy link
Contributor

sirtux commented Sep 16, 2021

Does this also need support in pynautobot as well?

@jedelman8 jedelman8 added this to the v1.3.0 milestone Sep 24, 2021
@glennmatthews glennmatthews added the good first issue Great issues for newcomers! label Dec 13, 2021
briddo added a commit that referenced this issue Mar 17, 2022
* Updated release notes

* Added to release notes overview

* Update nautobot/docs/release-notes/version-1.3.md

Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>

* PR suggestions actioned

Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>
@bryanculver
Copy link
Member

Implemented with #1075.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Great issues for newcomers! type: feature Introduction of new or enhanced functionality to the application
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

6 participants