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

Event Rule Action Data passed to Script #14884

Open
renatoalmeidaoliveira opened this issue Jan 21, 2024 · 6 comments · May be fixed by #15063
Open

Event Rule Action Data passed to Script #14884

renatoalmeidaoliveira opened this issue Jan 21, 2024 · 6 comments · May be fixed by #15063
Assignees
Labels
complexity: medium Requires a substantial but not unusual amount of effort to implement status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application

Comments

@renatoalmeidaoliveira
Copy link
Contributor

NetBox version

v3.7.0

Feature type

Change to existing functionality

Proposed functionality

Currently EventRules passes a serialized version of the model as data to the linked Script, I think it would be better if the Action Data was processed like the Body Template of Webhoocks and passed to the Script.

Use case

It would allow users to build Script to react NetBox changes with the change context, currently the user cannot get directly the changelog. And by passing a parsed data with Event Data gives the plugin developer a lot of flexibility to build automations

Database changes

None

External dependencies

None

@renatoalmeidaoliveira renatoalmeidaoliveira added the type: feature Introduction of new functionality to the application label Jan 21, 2024
@jeremystretch
Copy link
Member

I don't think we have a mechanism in place within a script right now to accept this data. Could you please expand your proposal above to specify exactly how a script would receive this data, in addition to the form data it currently accepts?

@jeremystretch jeremystretch added the status: revisions needed This issue requires additional information to be actionable label Jan 22, 2024
@renatoalmeidaoliveira
Copy link
Contributor Author

renatoalmeidaoliveira commented Jan 22, 2024

In the current implementation the EventRule passes a serialized version of the instance as data to the script., so it isn't possible to pass any input to the Script using the EventRule.
For example:
The user wants that for every interface change a Script runs and perform Napalm checks on the interface, to implement that the user might need the Interface, the Device and the changes performed by the end user.
But in the current implementation is only receives the changed object and the way it is passed to the Script it can't even be used as Script Inputs.
The feature request aims to give the user an interface to setup what data should be passed to the Script when the changes happens

@renatoalmeidaoliveira
Copy link
Contributor Author

renatoalmeidaoliveira commented Jan 22, 2024

In run_script data is passed as a dict where the keys are the Script Input, but when the Job is schedules in process_event_rules it passed as built in enqueue_object, (the serialized model) and that way it ain't gonna pass the expected dict to the Script since its expecting a dict with keys as the Script Inputs.
I think that the Action Data (or any other field) could be used similar as the Templete body of webhooks using something like rende_body

@DanSheps
Copy link
Member

I think I get what this is saying.

Basically, you can define your data template for what is passed to a script.

This is originally what I thought "action data" wass for.

@renatoalmeidaoliveira
Copy link
Contributor Author

@DanSheps I thougt that it was the purpose of "action data" too.
And when I look to the rest of the implementation it makes sense for me change the context injected to the template body in the webhook to whatever the user wants to setup inside the action data

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: revisions needed This issue requires additional information to be actionable labels Feb 14, 2024
@jeremystretch
Copy link
Member

I've assigned this to @renatoalmeidaoliveira with the understanding that its scope is limited to passing the action_data associated with an event rule directly to the script being executed, as if it were user input.

@jeremystretch jeremystretch added the complexity: medium Requires a substantial but not unusual amount of effort to implement label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity: medium Requires a substantial but not unusual amount of effort to implement status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
3 participants