mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-24 02:11:50 +01:00
Clone all GraphQL objects to V1 versions
This commit is contained in:
52
netbox/extras/graphql/filter_mixins_v1.py
Normal file
52
netbox/extras/graphql/filter_mixins_v1.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Annotated, TYPE_CHECKING
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
from strawberry_django import FilterLookup
|
||||
|
||||
from core.graphql.filter_mixins_v1 import BaseFilterMixinV1
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from netbox.graphql.filter_lookups import JSONFilter
|
||||
from .filters_v1 import *
|
||||
|
||||
__all__ = (
|
||||
'CustomFieldsFilterMixinV1',
|
||||
'JournalEntriesFilterMixinV1',
|
||||
'TagsFilterMixinV1',
|
||||
'ConfigContextFilterMixinV1',
|
||||
'TagBaseFilterMixinV1',
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class CustomFieldsFilterMixinV1(BaseFilterMixinV1):
|
||||
custom_field_data: Annotated['JSONFilter', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class JournalEntriesFilterMixinV1(BaseFilterMixinV1):
|
||||
journal_entries: Annotated['JournalEntryFilterV1', strawberry.lazy('extras.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class TagsFilterMixinV1(BaseFilterMixinV1):
|
||||
tags: Annotated['TagFilter', strawberry.lazy('extras.graphql.filters')] | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@dataclass
|
||||
class ConfigContextFilterMixinV1(BaseFilterMixinV1):
|
||||
local_context_data: Annotated['JSONFilter', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class TagBaseFilterMixinV1(BaseFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
slug: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
357
netbox/extras/graphql/filters_v1.py
Normal file
357
netbox/extras/graphql/filters_v1.py
Normal file
@@ -0,0 +1,357 @@
|
||||
from typing import Annotated, TYPE_CHECKING
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
from strawberry.scalars import ID
|
||||
from strawberry_django import FilterLookup
|
||||
|
||||
from core.graphql.filter_mixins_v1 import BaseObjectTypeFilterMixinV1, ChangeLogFilterMixinV1
|
||||
from extras import models
|
||||
from extras.graphql.filter_mixins_v1 import TagBaseFilterMixinV1, CustomFieldsFilterMixinV1, TagsFilterMixinV1
|
||||
from netbox.graphql.filter_mixins_v1 import PrimaryModelFilterMixinV1, SyncedDataFilterMixinV1
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.graphql.filters_v1 import ContentTypeFilterV1
|
||||
from dcim.graphql.filters_v1 import (
|
||||
DeviceRoleFilterV1,
|
||||
DeviceTypeFilterV1,
|
||||
LocationFilterV1,
|
||||
PlatformFilterV1,
|
||||
RegionFilterV1,
|
||||
SiteFilterV1,
|
||||
SiteGroupFilterV1,
|
||||
)
|
||||
from tenancy.graphql.filters_v1 import TenantFilterV1, TenantGroupFilterV1
|
||||
from netbox.graphql.enums import ColorEnum
|
||||
from netbox.graphql.filter_lookups import FloatLookup, IntegerLookup, JSONFilter, StringArrayLookup, TreeNodeFilter
|
||||
from virtualization.graphql.filters_v1 import ClusterFilterV1, ClusterGroupFilterV1, ClusterTypeFilterV1
|
||||
from .enums import *
|
||||
|
||||
__all__ = (
|
||||
'ConfigContextFilterV1',
|
||||
'ConfigContextProfileFilterV1',
|
||||
'ConfigTemplateFilterV1',
|
||||
'CustomFieldFilterV1',
|
||||
'CustomFieldChoiceSetFilterV1',
|
||||
'CustomLinkFilterV1',
|
||||
'EventRuleFilterV1',
|
||||
'ExportTemplateFilterV1',
|
||||
'ImageAttachmentFilterV1',
|
||||
'JournalEntryFilterV1',
|
||||
'NotificationGroupFilterV1',
|
||||
'SavedFilterFilterV1',
|
||||
'TableConfigFilterV1',
|
||||
'TagFilterV1',
|
||||
'WebhookFilterV1',
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.ConfigContext, lookups=True)
|
||||
class ConfigContextFilterV1(BaseObjectTypeFilterMixinV1, SyncedDataFilterMixinV1, ChangeLogFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
weight: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
description: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
is_active: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
regions: Annotated['RegionFilterV1', strawberry.lazy('dcim.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
region_id: Annotated['TreeNodeFilter', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
site_groups: Annotated['SiteGroupFilterV1', strawberry.lazy('dcim.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
site_group_id: Annotated['TreeNodeFilter', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
sites: Annotated['SiteFilterV1', strawberry.lazy('dcim.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
locations: Annotated['LocationFilterV1', strawberry.lazy('dcim.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
device_types: Annotated['DeviceTypeFilterV1', strawberry.lazy('dcim.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
roles: Annotated['DeviceRoleFilterV1', strawberry.lazy('dcim.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
platforms: Annotated['PlatformFilterV1', strawberry.lazy('dcim.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
cluster_types: Annotated['ClusterTypeFilterV1', strawberry.lazy('virtualization.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
cluster_groups: Annotated['ClusterGroupFilterV1', strawberry.lazy('virtualization.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
clusters: Annotated['ClusterFilterV1', strawberry.lazy('virtualization.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
tenant_groups: Annotated['TenantGroupFilterV1', strawberry.lazy('tenancy.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
tenant_group_id: Annotated['TreeNodeFilter', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
tenants: Annotated['TenantFilterV1', strawberry.lazy('tenancy.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
tags: Annotated['TagFilterV1', strawberry.lazy('extras.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
data: Annotated['JSONFilter', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.ConfigContextProfile, lookups=True)
|
||||
class ConfigContextProfileFilterV1(SyncedDataFilterMixinV1, PrimaryModelFilterMixinV1):
|
||||
name: FilterLookup[str] = strawberry_django.filter_field()
|
||||
description: FilterLookup[str] = strawberry_django.filter_field()
|
||||
tags: Annotated['TagFilterV1', strawberry.lazy('extras.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.ConfigTemplate, lookups=True)
|
||||
class ConfigTemplateFilterV1(BaseObjectTypeFilterMixinV1, SyncedDataFilterMixinV1, ChangeLogFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
description: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
template_code: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
environment_params: Annotated['JSONFilter', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
mime_type: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
file_name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
file_extension: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
as_attachment: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.CustomField, lookups=True)
|
||||
class CustomFieldFilterV1(BaseObjectTypeFilterMixinV1, ChangeLogFilterMixinV1):
|
||||
type: Annotated['CustomFieldTypeEnum', strawberry.lazy('extras.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
object_types: Annotated['ContentTypeFilterV1', strawberry.lazy('core.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
related_object_type: Annotated['ContentTypeFilterV1', strawberry.lazy('core.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
label: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
group_name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
description: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
required: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
unique: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
search_weight: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
filter_logic: Annotated['CustomFieldFilterLogicEnum', strawberry.lazy('extras.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
default: Annotated['JSONFilter', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
related_object_filter: Annotated['JSONFilter', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
weight: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
validation_minimum: Annotated['FloatLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
validation_maximum: Annotated['FloatLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
validation_regex: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
choice_set: Annotated['CustomFieldChoiceSetFilterV1', strawberry.lazy('extras.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
choice_set_id: ID | None = strawberry_django.filter_field()
|
||||
ui_visible: Annotated['CustomFieldUIVisibleEnum', strawberry.lazy('extras.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
ui_editable: Annotated['CustomFieldUIEditableEnum', strawberry.lazy('extras.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
is_cloneable: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
comments: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.CustomFieldChoiceSet, lookups=True)
|
||||
class CustomFieldChoiceSetFilterV1(BaseObjectTypeFilterMixinV1, ChangeLogFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
description: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
base_choices: Annotated['CustomFieldChoiceSetBaseEnum', strawberry.lazy('extras.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
extra_choices: Annotated['StringArrayLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
order_alphabetically: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.CustomLink, lookups=True)
|
||||
class CustomLinkFilterV1(BaseObjectTypeFilterMixinV1, ChangeLogFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
enabled: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
link_text: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
link_url: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
weight: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
group_name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
button_class: Annotated['CustomLinkButtonClassEnum', strawberry.lazy('extras.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
new_window: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.ExportTemplate, lookups=True)
|
||||
class ExportTemplateFilterV1(BaseObjectTypeFilterMixinV1, SyncedDataFilterMixinV1, ChangeLogFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
description: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
template_code: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
environment_params: Annotated['JSONFilter', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
mime_type: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
file_name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
file_extension: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
as_attachment: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.ImageAttachment, lookups=True)
|
||||
class ImageAttachmentFilterV1(BaseObjectTypeFilterMixinV1, ChangeLogFilterMixinV1):
|
||||
object_type: Annotated['ContentTypeFilterV1', strawberry.lazy('core.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
object_id: ID | None = strawberry_django.filter_field()
|
||||
image_height: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
image_width: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.JournalEntry, lookups=True)
|
||||
class JournalEntryFilterV1(
|
||||
BaseObjectTypeFilterMixinV1, CustomFieldsFilterMixinV1, TagsFilterMixinV1, ChangeLogFilterMixinV1
|
||||
):
|
||||
assigned_object_type: Annotated['ContentTypeFilterV1', strawberry.lazy('core.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
assigned_object_type_id: ID | None = strawberry_django.filter_field()
|
||||
assigned_object_id: ID | None = strawberry_django.filter_field()
|
||||
created_by: Annotated['UserFilterV1', strawberry.lazy('users.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
kind: Annotated['JournalEntryKindEnum', strawberry.lazy('extras.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
comments: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.NotificationGroup, lookups=True)
|
||||
class NotificationGroupFilterV1(BaseObjectTypeFilterMixinV1, ChangeLogFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
description: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
groups: Annotated['GroupFilterV1', strawberry.lazy('users.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
users: Annotated['UserFilterV1', strawberry.lazy('users.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.SavedFilter, lookups=True)
|
||||
class SavedFilterFilterV1(BaseObjectTypeFilterMixinV1, ChangeLogFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
slug: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
description: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
user: Annotated['UserFilterV1', strawberry.lazy('users.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
user_id: ID | None = strawberry_django.filter_field()
|
||||
weight: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
enabled: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
shared: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
parameters: Annotated['JSONFilter', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.TableConfig, lookups=True)
|
||||
class TableConfigFilterV1(BaseObjectTypeFilterMixinV1, ChangeLogFilterMixinV1):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
description: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
user: Annotated['UserFilterV1', strawberry.lazy('users.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
user_id: ID | None = strawberry_django.filter_field()
|
||||
weight: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
enabled: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
shared: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.Tag, lookups=True)
|
||||
class TagFilterV1(BaseObjectTypeFilterMixinV1, ChangeLogFilterMixinV1, TagBaseFilterMixinV1):
|
||||
color: Annotated['ColorEnum', strawberry.lazy('netbox.graphql.enums')] | None = strawberry_django.filter_field()
|
||||
description: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.Webhook, lookups=True)
|
||||
class WebhookFilterV1(
|
||||
BaseObjectTypeFilterMixinV1, CustomFieldsFilterMixinV1, TagsFilterMixinV1, ChangeLogFilterMixinV1
|
||||
):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
description: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
payload_url: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
http_method: Annotated['WebhookHttpMethodEnum', strawberry.lazy('extras.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
http_content_type: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
additional_headers: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
body_template: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
secret: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
ssl_verification: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
ca_file_path: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
events: Annotated['EventRuleFilterV1', strawberry.lazy('extras.graphql.filters_v1')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.filter_type(models.EventRule, lookups=True)
|
||||
class EventRuleFilterV1(
|
||||
BaseObjectTypeFilterMixinV1, CustomFieldsFilterMixinV1, TagsFilterMixinV1, ChangeLogFilterMixinV1
|
||||
):
|
||||
name: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
description: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
event_types: Annotated['StringArrayLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
enabled: FilterLookup[bool] | None = strawberry_django.filter_field()
|
||||
conditions: Annotated['JSONFilter', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
action_type: Annotated['EventRuleActionEnum', strawberry.lazy('extras.graphql.enums')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
action_object_type: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
action_object_type_id: ID | None = strawberry_django.filter_field()
|
||||
action_object_id: ID | None = strawberry_django.filter_field()
|
||||
action_data: Annotated['JSONFilter', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
|
||||
strawberry_django.filter_field()
|
||||
)
|
||||
comments: FilterLookup[str] | None = strawberry_django.filter_field()
|
||||
62
netbox/extras/graphql/mixins_v1.py
Normal file
62
netbox/extras/graphql/mixins_v1.py
Normal file
@@ -0,0 +1,62 @@
|
||||
from typing import TYPE_CHECKING, Annotated, List
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
from strawberry.types import Info
|
||||
|
||||
__all__ = (
|
||||
'ConfigContextMixinV1',
|
||||
'ContactsMixinV1',
|
||||
'CustomFieldsMixinV1',
|
||||
'ImageAttachmentsMixinV1',
|
||||
'JournalEntriesMixinV1',
|
||||
'TagsMixinV1',
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .types_v1 import ImageAttachmentTypeV1, JournalEntryTypeV1, TagTypeV1
|
||||
from tenancy.graphql.types_v1 import ContactAssignmentTypeV1
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class ConfigContextMixinV1:
|
||||
|
||||
@strawberry_django.field
|
||||
def config_context(self) -> strawberry.scalars.JSON:
|
||||
return self.get_config_context()
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class CustomFieldsMixinV1:
|
||||
|
||||
@strawberry_django.field
|
||||
def custom_fields(self) -> strawberry.scalars.JSON:
|
||||
return self.custom_field_data
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class ImageAttachmentsMixinV1:
|
||||
|
||||
@strawberry_django.field
|
||||
def image_attachments(self, info: Info) -> List[Annotated['ImageAttachmentTypeV1', strawberry.lazy('.types_v1')]]:
|
||||
return self.images.restrict(info.context.request.user, 'view')
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class JournalEntriesMixinV1:
|
||||
|
||||
@strawberry_django.field
|
||||
def journal_entries(self, info: Info) -> List[Annotated['JournalEntryTypeV1', strawberry.lazy('.types_v1')]]:
|
||||
return self.journal_entries.all()
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class TagsMixinV1:
|
||||
|
||||
tags: List[Annotated['TagTypeV1', strawberry.lazy('.types_v1')]]
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class ContactsMixinV1:
|
||||
|
||||
contacts: List[Annotated['ContactAssignmentTypeV1', strawberry.lazy('tenancy.graphql.types_v1')]]
|
||||
60
netbox/extras/graphql/schema_v1.py
Normal file
60
netbox/extras/graphql/schema_v1.py
Normal file
@@ -0,0 +1,60 @@
|
||||
from typing import List
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
|
||||
from .types_v1 import *
|
||||
|
||||
|
||||
@strawberry.type(name="Query")
|
||||
class ExtrasQueryV1:
|
||||
config_context: ConfigContextTypeV1 = strawberry_django.field()
|
||||
config_context_list: List[ConfigContextTypeV1] = strawberry_django.field()
|
||||
|
||||
config_context_profile: ConfigContextProfileTypeV1 = strawberry_django.field()
|
||||
config_context_profile_list: List[ConfigContextProfileTypeV1] = strawberry_django.field()
|
||||
|
||||
config_template: ConfigTemplateTypeV1 = strawberry_django.field()
|
||||
config_template_list: List[ConfigTemplateTypeV1] = strawberry_django.field()
|
||||
|
||||
custom_field: CustomFieldTypeV1 = strawberry_django.field()
|
||||
custom_field_list: List[CustomFieldTypeV1] = strawberry_django.field()
|
||||
|
||||
custom_field_choice_set: CustomFieldChoiceSetTypeV1 = strawberry_django.field()
|
||||
custom_field_choice_set_list: List[CustomFieldChoiceSetTypeV1] = strawberry_django.field()
|
||||
|
||||
custom_link: CustomLinkTypeV1 = strawberry_django.field()
|
||||
custom_link_list: List[CustomLinkTypeV1] = strawberry_django.field()
|
||||
|
||||
export_template: ExportTemplateTypeV1 = strawberry_django.field()
|
||||
export_template_list: List[ExportTemplateTypeV1] = strawberry_django.field()
|
||||
|
||||
image_attachment: ImageAttachmentTypeV1 = strawberry_django.field()
|
||||
image_attachment_list: List[ImageAttachmentTypeV1] = strawberry_django.field()
|
||||
|
||||
saved_filter: SavedFilterTypeV1 = strawberry_django.field()
|
||||
saved_filter_list: List[SavedFilterTypeV1] = strawberry_django.field()
|
||||
|
||||
table_config: TableConfigTypeV1 = strawberry_django.field()
|
||||
table_config_list: List[TableConfigTypeV1] = strawberry_django.field()
|
||||
|
||||
journal_entry: JournalEntryTypeV1 = strawberry_django.field()
|
||||
journal_entry_list: List[JournalEntryTypeV1] = strawberry_django.field()
|
||||
|
||||
notification: NotificationTypeV1 = strawberry_django.field()
|
||||
notification_list: List[NotificationTypeV1] = strawberry_django.field()
|
||||
|
||||
notification_group: NotificationGroupTypeV1 = strawberry_django.field()
|
||||
notification_group_list: List[NotificationGroupTypeV1] = strawberry_django.field()
|
||||
|
||||
subscription: SubscriptionTypeV1 = strawberry_django.field()
|
||||
subscription_list: List[SubscriptionTypeV1] = strawberry_django.field()
|
||||
|
||||
tag: TagTypeV1 = strawberry_django.field()
|
||||
tag_list: List[TagTypeV1] = strawberry_django.field()
|
||||
|
||||
webhook: WebhookTypeV1 = strawberry_django.field()
|
||||
webhook_list: List[WebhookTypeV1] = strawberry_django.field()
|
||||
|
||||
event_rule: EventRuleTypeV1 = strawberry_django.field()
|
||||
event_rule_list: List[EventRuleTypeV1] = strawberry_django.field()
|
||||
239
netbox/extras/graphql/types_v1.py
Normal file
239
netbox/extras/graphql/types_v1.py
Normal file
@@ -0,0 +1,239 @@
|
||||
from typing import Annotated, List, TYPE_CHECKING
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
|
||||
from core.graphql.mixins_v1 import SyncedDataMixinV1
|
||||
from extras import models
|
||||
from extras.graphql.mixins_v1 import CustomFieldsMixinV1, TagsMixinV1
|
||||
from netbox.graphql.types_v1 import (
|
||||
BaseObjectTypeV1, ContentTypeTypeV1, NetBoxObjectTypeV1, ObjectTypeV1, OrganizationalObjectTypeV1
|
||||
)
|
||||
from .filters_v1 import *
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from dcim.graphql.types_v1 import (
|
||||
DeviceRoleTypeV1,
|
||||
DeviceTypeV1,
|
||||
DeviceTypeTypeV1,
|
||||
LocationTypeV1,
|
||||
PlatformTypeV1,
|
||||
RegionTypeV1,
|
||||
SiteGroupTypeV1,
|
||||
SiteTypeV1,
|
||||
)
|
||||
from tenancy.graphql.types_v1 import TenantGroupTypeV1, TenantTypeV1
|
||||
from users.graphql.types_v1 import GroupTypeV1, UserTypeV1
|
||||
from virtualization.graphql.types_v1 import (
|
||||
ClusterGroupTypeV1, ClusterTypeV1, ClusterTypeTypeV1, VirtualMachineTypeV1
|
||||
)
|
||||
|
||||
__all__ = (
|
||||
'ConfigContextProfileTypeV1',
|
||||
'ConfigContextTypeV1',
|
||||
'ConfigTemplateTypeV1',
|
||||
'CustomFieldChoiceSetTypeV1',
|
||||
'CustomFieldTypeV1',
|
||||
'CustomLinkTypeV1',
|
||||
'EventRuleTypeV1',
|
||||
'ExportTemplateTypeV1',
|
||||
'ImageAttachmentTypeV1',
|
||||
'JournalEntryTypeV1',
|
||||
'NotificationGroupTypeV1',
|
||||
'NotificationTypeV1',
|
||||
'SavedFilterTypeV1',
|
||||
'SubscriptionTypeV1',
|
||||
'TableConfigTypeV1',
|
||||
'TagTypeV1',
|
||||
'WebhookTypeV1',
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.ConfigContextProfile,
|
||||
fields='__all__',
|
||||
filters=ConfigContextProfileFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class ConfigContextProfileTypeV1(SyncedDataMixinV1, NetBoxObjectTypeV1):
|
||||
pass
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.ConfigContext,
|
||||
fields='__all__',
|
||||
filters=ConfigContextFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class ConfigContextTypeV1(SyncedDataMixinV1, ObjectTypeV1):
|
||||
profile: ConfigContextProfileTypeV1 | None
|
||||
roles: List[Annotated["DeviceRoleTypeV1", strawberry.lazy('dcim.graphql.types_v1')]]
|
||||
device_types: List[Annotated["DeviceTypeTypeV1", strawberry.lazy('dcim.graphql.types_v1')]]
|
||||
tags: List[Annotated["TagTypeV1", strawberry.lazy('extras.graphql.types_v1')]]
|
||||
platforms: List[Annotated["PlatformTypeV1", strawberry.lazy('dcim.graphql.types_v1')]]
|
||||
regions: List[Annotated["RegionTypeV1", strawberry.lazy('dcim.graphql.types_v1')]]
|
||||
cluster_groups: List[Annotated["ClusterGroupTypeV1", strawberry.lazy('virtualization.graphql.types_v1')]]
|
||||
tenant_groups: List[Annotated["TenantGroupTypeV1", strawberry.lazy('tenancy.graphql.types_v1')]]
|
||||
cluster_types: List[Annotated["ClusterTypeTypeV1", strawberry.lazy('virtualization.graphql.types_v1')]]
|
||||
clusters: List[Annotated["ClusterTypeV1", strawberry.lazy('virtualization.graphql.types_v1')]]
|
||||
locations: List[Annotated["LocationTypeV1", strawberry.lazy('dcim.graphql.types_v1')]]
|
||||
sites: List[Annotated["SiteTypeV1", strawberry.lazy('dcim.graphql.types_v1')]]
|
||||
tenants: List[Annotated["TenantTypeV1", strawberry.lazy('tenancy.graphql.types_v1')]]
|
||||
site_groups: List[Annotated["SiteGroupTypeV1", strawberry.lazy('dcim.graphql.types_v1')]]
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.ConfigTemplate,
|
||||
fields='__all__',
|
||||
filters=ConfigTemplateFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class ConfigTemplateTypeV1(SyncedDataMixinV1, TagsMixinV1, ObjectTypeV1):
|
||||
virtualmachines: List[Annotated["VirtualMachineTypeV1", strawberry.lazy('virtualization.graphql.types_v1')]]
|
||||
devices: List[Annotated["DeviceTypeV1", strawberry.lazy('dcim.graphql.types_v1')]]
|
||||
platforms: List[Annotated["PlatformTypeV1", strawberry.lazy('dcim.graphql.types_v1')]]
|
||||
device_roles: List[Annotated["DeviceRoleTypeV1", strawberry.lazy('dcim.graphql.types_v1')]]
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.CustomField,
|
||||
fields='__all__',
|
||||
filters=CustomFieldFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class CustomFieldTypeV1(ObjectTypeV1):
|
||||
related_object_type: Annotated["ContentTypeTypeV1", strawberry.lazy('netbox.graphql.types_v1')] | None
|
||||
choice_set: Annotated["CustomFieldChoiceSetTypeV1", strawberry.lazy('extras.graphql.types_v1')] | None
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.CustomFieldChoiceSet,
|
||||
exclude=['extra_choices'],
|
||||
filters=CustomFieldChoiceSetFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class CustomFieldChoiceSetTypeV1(ObjectTypeV1):
|
||||
|
||||
choices_for: List[Annotated["CustomFieldTypeV1", strawberry.lazy('extras.graphql.types_v1')]]
|
||||
extra_choices: List[List[str]] | None
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.CustomLink,
|
||||
fields='__all__',
|
||||
filters=CustomLinkFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class CustomLinkTypeV1(ObjectTypeV1):
|
||||
pass
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.ExportTemplate,
|
||||
fields='__all__',
|
||||
filters=ExportTemplateFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class ExportTemplateTypeV1(SyncedDataMixinV1, ObjectTypeV1):
|
||||
pass
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.ImageAttachment,
|
||||
fields='__all__',
|
||||
filters=ImageAttachmentFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class ImageAttachmentTypeV1(BaseObjectTypeV1):
|
||||
object_type: Annotated["ContentTypeTypeV1", strawberry.lazy('netbox.graphql.types_v1')] | None
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.JournalEntry,
|
||||
fields='__all__',
|
||||
filters=JournalEntryFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class JournalEntryTypeV1(CustomFieldsMixinV1, TagsMixinV1, ObjectTypeV1):
|
||||
assigned_object_type: Annotated["ContentTypeTypeV1", strawberry.lazy('netbox.graphql.types_v1')] | None
|
||||
created_by: Annotated["UserTypeV1", strawberry.lazy('users.graphql.types_v1')] | None
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.Notification,
|
||||
# filters=NotificationFilter
|
||||
pagination=True
|
||||
)
|
||||
class NotificationTypeV1(ObjectTypeV1):
|
||||
user: Annotated["UserTypeV1", strawberry.lazy('users.graphql.types_v1')] | None
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.NotificationGroup,
|
||||
filters=NotificationGroupFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class NotificationGroupTypeV1(ObjectTypeV1):
|
||||
users: List[Annotated["UserTypeV1", strawberry.lazy('users.graphql.types_v1')]]
|
||||
groups: List[Annotated["GroupTypeV1", strawberry.lazy('users.graphql.types_v1')]]
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.SavedFilter,
|
||||
exclude=['content_types',],
|
||||
filters=SavedFilterFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class SavedFilterTypeV1(ObjectTypeV1):
|
||||
user: Annotated["UserTypeV1", strawberry.lazy('users.graphql.types_v1')] | None
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.Subscription,
|
||||
# filters=NotificationFilter
|
||||
pagination=True
|
||||
)
|
||||
class SubscriptionTypeV1(ObjectTypeV1):
|
||||
user: Annotated["UserTypeV1", strawberry.lazy('users.graphql.types_v1')] | None
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.TableConfig,
|
||||
fields='__all__',
|
||||
filters=TableConfigFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class TableConfigTypeV1(ObjectTypeV1):
|
||||
user: Annotated["UserTypeV1", strawberry.lazy('users.graphql.types_v1')] | None
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.Tag,
|
||||
exclude=['extras_taggeditem_items', ],
|
||||
filters=TagFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class TagTypeV1(ObjectTypeV1):
|
||||
color: str
|
||||
|
||||
object_types: List[ContentTypeTypeV1]
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.Webhook,
|
||||
exclude=['content_types',],
|
||||
filters=WebhookFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class WebhookTypeV1(OrganizationalObjectTypeV1):
|
||||
pass
|
||||
|
||||
|
||||
@strawberry_django.type(
|
||||
models.EventRule,
|
||||
exclude=['content_types',],
|
||||
filters=EventRuleFilterV1,
|
||||
pagination=True
|
||||
)
|
||||
class EventRuleTypeV1(OrganizationalObjectTypeV1):
|
||||
action_object_type: Annotated["ContentTypeTypeV1", strawberry.lazy('netbox.graphql.types_v1')] | None
|
||||
Reference in New Issue
Block a user