mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 08:38:16 -06:00
Add Event documentation
This commit is contained in:
parent
6302a10a61
commit
41eff5c4c3
@ -1,3 +1,16 @@
|
||||
# Events
|
||||
|
||||
TODO
|
||||
Plugins can register their own custom event types for use with NetBox [event rules](../../models/extras/eventrule.md). This is accomplished by calling the `register()` method on an instance of the `Event` class. This can be done anywhere within the plugin. An example is provided below.
|
||||
|
||||
```python
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from netbox.events import Event, EVENT_TYPE_SUCCESS
|
||||
|
||||
Event(
|
||||
name='ticket_opened',
|
||||
text=_('Ticket opened'),
|
||||
type=EVENT_TYPE_SUCCESS
|
||||
).register()
|
||||
```
|
||||
|
||||
::: netbox.events.Event
|
||||
|
@ -37,6 +37,15 @@ def get_event_type_choices():
|
||||
|
||||
@dataclass
|
||||
class Event:
|
||||
"""
|
||||
A type of event which can occur in NetBox. Event rules can be defined to automatically
|
||||
perform some action in response to an event.
|
||||
|
||||
Args:
|
||||
name: The unique name under which the event is registered.
|
||||
text: The human-friendly event name. This should support translation.
|
||||
type: The event's classification (info, success, warning, or danger). The default type is info.
|
||||
"""
|
||||
name: str
|
||||
text: str
|
||||
type: str = EVENT_TYPE_INFO
|
||||
|
Loading…
Reference in New Issue
Block a user