Rename webhooks key for model_features registry key to event_rules

This commit is contained in:
Jeremy Stretch 2023-11-28 08:39:51 -05:00
parent 267b5a1b3a
commit 43eef0effe
9 changed files with 22 additions and 22 deletions

View File

@ -31,7 +31,7 @@ A dictionary of particular features (e.g. custom fields) mapped to the NetBox mo
'dcim': ['site', 'rack', 'devicetype', ...], 'dcim': ['site', 'rack', 'devicetype', ...],
... ...
}, },
'webhooks': { 'event_rules': {
'extras': ['configcontext', 'tag', ...], 'extras': ['configcontext', 'tag', ...],
'dcim': ['site', 'rack', 'devicetype', ...], 'dcim': ['site', 'rack', 'devicetype', ...],
}, },

View File

@ -10,19 +10,19 @@ The Django [content types](https://docs.djangoproject.com/en/stable/ref/contrib/
Depending on its classification, each NetBox model may support various features which enhance its operation. Each feature is enabled by inheriting from its designated mixin class, and some features also make use of the [application registry](./application-registry.md#model_features). Depending on its classification, each NetBox model may support various features which enhance its operation. Each feature is enabled by inheriting from its designated mixin class, and some features also make use of the [application registry](./application-registry.md#model_features).
| Feature | Feature Mixin | Registry Key | Description | | Feature | Feature Mixin | Registry Key | Description |
|------------------------------------------------------------|-------------------------|--------------------|--------------------------------------------------------------------------------| |------------------------------------------------------------|-------------------------|--------------------|-----------------------------------------------------------------------------------------|
| [Change logging](../features/change-logging.md) | `ChangeLoggingMixin` | - | Changes to these objects are automatically recorded in the change log | | [Change logging](../features/change-logging.md) | `ChangeLoggingMixin` | - | Changes to these objects are automatically recorded in the change log |
| Cloning | `CloningMixin` | - | Provides the `clone()` method to prepare a copy | | Cloning | `CloningMixin` | - | Provides the `clone()` method to prepare a copy |
| [Custom fields](../customization/custom-fields.md) | `CustomFieldsMixin` | `custom_fields` | These models support the addition of user-defined fields | | [Custom fields](../customization/custom-fields.md) | `CustomFieldsMixin` | `custom_fields` | These models support the addition of user-defined fields |
| [Custom links](../customization/custom-links.md) | `CustomLinksMixin` | `custom_links` | These models support the assignment of custom links | | [Custom links](../customization/custom-links.md) | `CustomLinksMixin` | `custom_links` | These models support the assignment of custom links |
| [Custom validation](../customization/custom-validation.md) | `CustomValidationMixin` | - | Supports the enforcement of custom validation rules | | [Custom validation](../customization/custom-validation.md) | `CustomValidationMixin` | - | Supports the enforcement of custom validation rules |
| [Export templates](../customization/export-templates.md) | `ExportTemplatesMixin` | `export_templates` | Users can create custom export templates for these models | | [Export templates](../customization/export-templates.md) | `ExportTemplatesMixin` | `export_templates` | Users can create custom export templates for these models |
| [Job results](../features/background-jobs.md) | `JobsMixin` | `jobs` | Users can create custom export templates for these models | | [Job results](../features/background-jobs.md) | `JobsMixin` | `jobs` | Users can create custom export templates for these models |
| [Journaling](../features/journaling.md) | `JournalingMixin` | `journaling` | These models support persistent historical commentary | | [Journaling](../features/journaling.md) | `JournalingMixin` | `journaling` | These models support persistent historical commentary |
| [Synchronized data](../integrations/synchronized-data.md) | `SyncedDataMixin` | `synced_data` | Certain model data can be automatically synchronized from a remote data source | | [Synchronized data](../integrations/synchronized-data.md) | `SyncedDataMixin` | `synced_data` | Certain model data can be automatically synchronized from a remote data source |
| [Tagging](../models/extras/tag.md) | `TagsMixin` | `tags` | The models can be tagged with user-defined tags | | [Tagging](../models/extras/tag.md) | `TagsMixin` | `tags` | The models can be tagged with user-defined tags |
| [Webhooks](../integrations/webhooks.md) | `EventRulesMixin` | `webhooks` | NetBox is capable of generating outgoing webhooks for these objects | | [Event rules](../features/event-rules.md) | `EventRulesMixin` | `event_rules` | Event rules can send webhooks or run custom scripts automatically in response to events |
## Models Index ## Models Index
@ -111,7 +111,7 @@ Component models represent individual physical or virtual components belonging t
### Component Template Models ### Component Template Models
These function as templates to effect the replication of device and virtual machine components. Component template models support a limited feature set, including change logging, custom validation, and webhooks. These function as templates to effect the replication of device and virtual machine components. Component template models support a limited feature set, including change logging, custom validation, and event rules.
* [dcim.ConsolePortTemplate](../models/dcim/consoleporttemplate.md) * [dcim.ConsolePortTemplate](../models/dcim/consoleporttemplate.md)
* [dcim.ConsoleServerPortTemplate](../models/dcim/consoleserverporttemplate.md) * [dcim.ConsoleServerPortTemplate](../models/dcim/consoleserverporttemplate.md)

View File

@ -26,7 +26,7 @@ class ContentTypeManager(ContentTypeManager_):
Return the ContentTypes only for models which are registered as supporting the specified feature. For example, Return the ContentTypes only for models which are registered as supporting the specified feature. For example,
we can find all ContentTypes for models which support webhooks with we can find all ContentTypes for models which support webhooks with
ContentType.objects.with_feature('webhooks') ContentType.objects.with_feature('event_rules')
""" """
if feature not in registry['model_features']: if feature not in registry['model_features']:
raise KeyError( raise KeyError(

View File

@ -64,7 +64,7 @@ __all__ = (
class EventRuleSerializer(NetBoxModelSerializer): class EventRuleSerializer(NetBoxModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='extras-api:eventrule-detail') url = serializers.HyperlinkedIdentityField(view_name='extras-api:eventrule-detail')
content_types = ContentTypeField( content_types = ContentTypeField(
queryset=ContentType.objects.with_feature('webhooks'), queryset=ContentType.objects.with_feature('event_rules'),
many=True many=True
) )
action_type = ChoiceField(choices=EventRuleActionChoices) action_type = ChoiceField(choices=EventRuleActionChoices)

View File

@ -55,7 +55,7 @@ def enqueue_object(queue, instance, user, request_id, action):
# Determine whether this type of object supports event rules # Determine whether this type of object supports event rules
app_label = instance._meta.app_label app_label = instance._meta.app_label
model_name = instance._meta.model_name model_name = instance._meta.model_name
if model_name not in registry['model_features']['webhooks'].get(app_label, []): if model_name not in registry['model_features']['event_rules'].get(app_label, []):
return return
queue.append({ queue.append({

View File

@ -156,7 +156,7 @@ class WebhookImportForm(NetBoxModelImportForm):
class EventRuleImportForm(NetBoxModelImportForm): class EventRuleImportForm(NetBoxModelImportForm):
content_types = CSVMultipleContentTypeField( content_types = CSVMultipleContentTypeField(
label=_('Content types'), label=_('Content types'),
queryset=ContentType.objects.with_feature('webhooks'), queryset=ContentType.objects.with_feature('event_rules'),
help_text=_("One or more assigned object types") help_text=_("One or more assigned object types")
) )

View File

@ -255,7 +255,7 @@ class EventRuleFilterForm(NetBoxModelFilterSetForm):
(_('Events'), ('type_create', 'type_update', 'type_delete', 'type_job_start', 'type_job_end')), (_('Events'), ('type_create', 'type_update', 'type_delete', 'type_job_start', 'type_job_end')),
) )
content_type_id = ContentTypeMultipleChoiceField( content_type_id = ContentTypeMultipleChoiceField(
queryset=ContentType.objects.with_feature('webhooks'), queryset=ContentType.objects.with_feature('event_rules'),
required=False, required=False,
label=_('Object type') label=_('Object type')
) )

View File

@ -237,7 +237,7 @@ class WebhookForm(NetBoxModelForm):
class EventRuleForm(NetBoxModelForm): class EventRuleForm(NetBoxModelForm):
content_types = ContentTypeMultipleChoiceField( content_types = ContentTypeMultipleChoiceField(
label=_('Content types'), label=_('Content types'),
queryset=ContentType.objects.with_feature('webhooks'), queryset=ContentType.objects.with_feature('event_rules'),
) )
action_choice = forms.ChoiceField( action_choice = forms.ChoiceField(
label=_('Action choice'), label=_('Action choice'),

View File

@ -555,7 +555,7 @@ FEATURES_MAP = {
'journaling': JournalingMixin, 'journaling': JournalingMixin,
'synced_data': SyncedDataMixin, 'synced_data': SyncedDataMixin,
'tags': TagsMixin, 'tags': TagsMixin,
'webhooks': EventRulesMixin, 'event_rules': EventRulesMixin,
} }
registry['model_features'].update({ registry['model_features'].update({