mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 00:15:17 -06:00
14132 api / graphql
This commit is contained in:
parent
e0b10c984b
commit
f650f88806
@ -39,6 +39,7 @@ __all__ = (
|
|||||||
'CustomFieldSerializer',
|
'CustomFieldSerializer',
|
||||||
'CustomLinkSerializer',
|
'CustomLinkSerializer',
|
||||||
'DashboardSerializer',
|
'DashboardSerializer',
|
||||||
|
'EventRuleSerializer',
|
||||||
'ExportTemplateSerializer',
|
'ExportTemplateSerializer',
|
||||||
'ImageAttachmentSerializer',
|
'ImageAttachmentSerializer',
|
||||||
'JournalEntrySerializer',
|
'JournalEntrySerializer',
|
||||||
@ -58,22 +59,38 @@ __all__ = (
|
|||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Webhooks
|
# Event Rules
|
||||||
#
|
#
|
||||||
|
|
||||||
class WebhookSerializer(NetBoxModelSerializer):
|
class EventRuleSerializer(NetBoxModelSerializer):
|
||||||
url = serializers.HyperlinkedIdentityField(view_name='extras-api:webhook-detail')
|
url = serializers.HyperlinkedIdentityField(view_name='extras-api:eventrule-detail')
|
||||||
content_types = ContentTypeField(
|
content_types = ContentTypeField(
|
||||||
queryset=ContentType.objects.filter(FeatureQuery('webhooks').get_query()),
|
queryset=ContentType.objects.filter(FeatureQuery('webhooks').get_query()),
|
||||||
many=True
|
many=True
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Webhook
|
model = EventRule
|
||||||
fields = [
|
fields = [
|
||||||
'id', 'url', 'display', 'content_types', 'name', 'type_create', 'type_update', 'type_delete',
|
'id', 'url', 'display', 'content_types', 'name', 'type_create', 'type_update', 'type_delete',
|
||||||
'type_job_start', 'type_job_end', 'payload_url', 'enabled', 'http_method', 'http_content_type',
|
'type_job_start', 'type_job_end', 'enabled', 'conditions', 'event_type',
|
||||||
'additional_headers', 'body_template', 'secret', 'conditions', 'ssl_verification', 'ca_file_path',
|
'custom_fields', 'tags', 'created', 'last_updated',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Webhooks
|
||||||
|
#
|
||||||
|
|
||||||
|
class WebhookSerializer(NetBoxModelSerializer):
|
||||||
|
url = serializers.HyperlinkedIdentityField(view_name='extras-api:webhook-detail')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Webhook
|
||||||
|
fields = [
|
||||||
|
'id', 'url', 'display',
|
||||||
|
'payload_url', 'http_method', 'http_content_type',
|
||||||
|
'additional_headers', 'body_template', 'secret', 'ssl_verification', 'ca_file_path',
|
||||||
'custom_fields', 'tags', 'created', 'last_updated',
|
'custom_fields', 'tags', 'created', 'last_updated',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ from . import views
|
|||||||
router = NetBoxRouter()
|
router = NetBoxRouter()
|
||||||
router.APIRootView = views.ExtrasRootView
|
router.APIRootView = views.ExtrasRootView
|
||||||
|
|
||||||
|
router.register('event-rules', views.EventRuleViewSet)
|
||||||
router.register('webhooks', views.WebhookViewSet)
|
router.register('webhooks', views.WebhookViewSet)
|
||||||
router.register('custom-fields', views.CustomFieldViewSet)
|
router.register('custom-fields', views.CustomFieldViewSet)
|
||||||
router.register('custom-field-choice-sets', views.CustomFieldChoiceSetViewSet)
|
router.register('custom-field-choice-sets', views.CustomFieldChoiceSetViewSet)
|
||||||
|
@ -37,6 +37,17 @@ class ExtrasRootView(APIRootView):
|
|||||||
return 'Extras'
|
return 'Extras'
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# EventRules
|
||||||
|
#
|
||||||
|
|
||||||
|
class EventRuleViewSet(NetBoxModelViewSet):
|
||||||
|
metadata_class = ContentTypeMetadata
|
||||||
|
queryset = EventRule.objects.all()
|
||||||
|
serializer_class = serializers.EventRuleSerializer
|
||||||
|
filterset_class = filtersets.EventRuleFilterSet
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Webhooks
|
# Webhooks
|
||||||
#
|
#
|
||||||
|
@ -8,6 +8,7 @@ __all__ = (
|
|||||||
'CustomFieldChoiceSetType',
|
'CustomFieldChoiceSetType',
|
||||||
'CustomFieldType',
|
'CustomFieldType',
|
||||||
'CustomLinkType',
|
'CustomLinkType',
|
||||||
|
'EventRuleType',
|
||||||
'ExportTemplateType',
|
'ExportTemplateType',
|
||||||
'ImageAttachmentType',
|
'ImageAttachmentType',
|
||||||
'JournalEntryType',
|
'JournalEntryType',
|
||||||
@ -110,5 +111,12 @@ class WebhookType(OrganizationalObjectType):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Webhook
|
model = models.Webhook
|
||||||
exclude = ('content_types', )
|
|
||||||
filterset_class = filtersets.WebhookFilterSet
|
filterset_class = filtersets.WebhookFilterSet
|
||||||
|
|
||||||
|
|
||||||
|
class EventRuleType(OrganizationalObjectType):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = models.EventRule
|
||||||
|
exclude = ('content_types', )
|
||||||
|
filterset_class = filtersets.EventRuleFilterSet
|
||||||
|
Loading…
Reference in New Issue
Block a user