netbox-plugin-dns 1.1.0b7__py3-none-any.whl → 1.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of netbox-plugin-dns might be problematic. Click here for more details.

Files changed (82) hide show
  1. netbox_dns/__init__.py +3 -2
  2. netbox_dns/api/nested_serializers.py +17 -16
  3. netbox_dns/api/serializers.py +1 -1
  4. netbox_dns/api/serializers_/record.py +1 -0
  5. netbox_dns/api/serializers_/{contact.py → registration_contact.py} +5 -5
  6. netbox_dns/api/serializers_/view.py +1 -0
  7. netbox_dns/api/serializers_/zone.py +5 -5
  8. netbox_dns/api/serializers_/zone_template.py +5 -5
  9. netbox_dns/api/urls.py +2 -2
  10. netbox_dns/api/views.py +7 -35
  11. netbox_dns/filtersets/__init__.py +1 -1
  12. netbox_dns/filtersets/nameserver.py +0 -0
  13. netbox_dns/filtersets/record.py +0 -0
  14. netbox_dns/filtersets/record_template.py +0 -0
  15. netbox_dns/filtersets/{contact.py → registration_contact.py} +4 -4
  16. netbox_dns/filtersets/zone.py +15 -15
  17. netbox_dns/filtersets/zone_template.py +15 -15
  18. netbox_dns/forms/__init__.py +1 -1
  19. netbox_dns/forms/nameserver.py +0 -0
  20. netbox_dns/forms/record.py +0 -0
  21. netbox_dns/forms/record_template.py +0 -0
  22. netbox_dns/forms/{contact.py → registration_contact.py} +16 -16
  23. netbox_dns/forms/view.py +29 -10
  24. netbox_dns/forms/zone.py +13 -13
  25. netbox_dns/forms/zone_template.py +13 -13
  26. netbox_dns/graphql/__init__.py +2 -2
  27. netbox_dns/graphql/filters.py +5 -5
  28. netbox_dns/graphql/schema.py +23 -53
  29. netbox_dns/graphql/types.py +39 -12
  30. netbox_dns/migrations/0007_alter_ordering_options.py +25 -0
  31. netbox_dns/migrations/{0007_view_prefixes.py → 0008_view_prefixes.py} +1 -1
  32. netbox_dns/migrations/0009_rename_contact_registrationcontact.py +36 -0
  33. netbox_dns/migrations/0010_view_ip_address_filter.py +18 -0
  34. netbox_dns/mixins/object_modification.py +30 -8
  35. netbox_dns/models/__init__.py +1 -1
  36. netbox_dns/models/nameserver.py +8 -3
  37. netbox_dns/models/record.py +47 -14
  38. netbox_dns/models/record_template.py +4 -1
  39. netbox_dns/models/registrar.py +7 -1
  40. netbox_dns/models/{contact.py → registration_contact.py} +15 -9
  41. netbox_dns/models/view.py +49 -2
  42. netbox_dns/models/zone.py +24 -18
  43. netbox_dns/models/zone_template.py +12 -9
  44. netbox_dns/navigation.py +7 -7
  45. netbox_dns/signals/ipam_dnssync.py +4 -4
  46. netbox_dns/tables/__init__.py +1 -1
  47. netbox_dns/tables/nameserver.py +1 -7
  48. netbox_dns/tables/record.py +10 -35
  49. netbox_dns/tables/record_template.py +0 -17
  50. netbox_dns/tables/registrar.py +0 -2
  51. netbox_dns/tables/{contact.py → registration_contact.py} +5 -6
  52. netbox_dns/tables/view.py +1 -8
  53. netbox_dns/tables/zone.py +0 -15
  54. netbox_dns/tables/zone_template.py +2 -16
  55. netbox_dns/templates/netbox_dns/{contact.html → registrationcontact.html} +1 -1
  56. netbox_dns/templates/netbox_dns/view.html +16 -0
  57. netbox_dns/urls/__init__.py +2 -2
  58. netbox_dns/urls/nameserver.py +14 -38
  59. netbox_dns/urls/record.py +7 -19
  60. netbox_dns/urls/record_template.py +18 -27
  61. netbox_dns/urls/registrar.py +11 -35
  62. netbox_dns/urls/registration_contact.py +60 -0
  63. netbox_dns/urls/view.py +8 -22
  64. netbox_dns/urls/zone.py +8 -46
  65. netbox_dns/urls/zone_template.py +16 -26
  66. netbox_dns/utilities/ipam_dnssync.py +58 -26
  67. netbox_dns/views/__init__.py +1 -1
  68. netbox_dns/views/nameserver.py +7 -3
  69. netbox_dns/views/record.py +12 -3
  70. netbox_dns/views/record_template.py +1 -1
  71. netbox_dns/views/registrar.py +0 -1
  72. netbox_dns/views/registration_contact.py +94 -0
  73. netbox_dns/views/view.py +6 -1
  74. netbox_dns/views/zone.py +7 -6
  75. netbox_dns/views/zone_template.py +2 -2
  76. {netbox_plugin_dns-1.1.0b7.dist-info → netbox_plugin_dns-1.1.2.dist-info}/METADATA +14 -14
  77. {netbox_plugin_dns-1.1.0b7.dist-info → netbox_plugin_dns-1.1.2.dist-info}/RECORD +80 -76
  78. {netbox_plugin_dns-1.1.0b7.dist-info → netbox_plugin_dns-1.1.2.dist-info}/WHEEL +2 -1
  79. netbox_plugin_dns-1.1.2.dist-info/top_level.txt +1 -0
  80. netbox_dns/urls/contact.py +0 -51
  81. netbox_dns/views/contact.py +0 -95
  82. {netbox_plugin_dns-1.1.0b7.dist-info → netbox_plugin_dns-1.1.2.dist-info}/LICENSE +0 -0
netbox_dns/forms/view.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from django import forms
2
2
  from django.conf import settings
3
- from django.core.exceptions import ValidationError
3
+ from django.core.exceptions import ValidationError, FieldError
4
4
  from django.db.models import Q, Count
5
5
 
6
6
  from netbox.forms import (
@@ -18,9 +18,10 @@ from utilities.forms.fields import (
18
18
  )
19
19
  from utilities.forms import BOOLEAN_WITH_BLANK_CHOICES
20
20
  from utilities.forms.rendering import FieldSet
21
+ from utilities.forms.fields import JSONField
21
22
  from tenancy.models import Tenant
22
23
  from tenancy.forms import TenancyForm, TenancyFilterForm
23
- from ipam.models import Prefix
24
+ from ipam.models import Prefix, IPAddress
24
25
  from netbox.context import current_request
25
26
 
26
27
  from netbox_dns.models import View
@@ -29,6 +30,7 @@ from netbox_dns.utilities import (
29
30
  check_dns_records,
30
31
  get_ip_addresses_by_prefix,
31
32
  get_views_by_prefix,
33
+ get_query_from_filter,
32
34
  )
33
35
 
34
36
 
@@ -45,7 +47,7 @@ class ViewPrefixUpdateMixin:
45
47
  def clean(self, *args, **kwargs):
46
48
  super().clean(*args, **kwargs)
47
49
 
48
- if self.instance.pk is None or "prefixes" not in self.changed_data:
50
+ if self.instance._state.adding or "prefixes" not in self.changed_data:
49
51
  return
50
52
 
51
53
  prefixes = self.cleaned_data.get("prefixes")
@@ -97,6 +99,7 @@ class ViewForm(ViewPrefixUpdateMixin, TenancyForm, NetBoxModelForm):
97
99
 
98
100
  if settings.PLUGINS_CONFIG["netbox_dns"].get("dnssync_disabled"):
99
101
  del self.fields["prefixes"]
102
+ del self.fields["ip_address_filter"]
100
103
 
101
104
  if request := current_request.get():
102
105
  if not request.user.has_perm("ipam.view_prefix"):
@@ -107,12 +110,6 @@ class ViewForm(ViewPrefixUpdateMixin, TenancyForm, NetBoxModelForm):
107
110
  "placeholder"
108
111
  ] = "You do not have permission to modify assigned prefixes"
109
112
 
110
- def clean_prefixes(self):
111
- if hasattr(self, "_saved_prefixes"):
112
- return self._saved_prefixes
113
-
114
- return self.cleaned_data["prefixes"]
115
-
116
113
  prefixes = PrefixDynamicModelMultipleChoiceField(
117
114
  queryset=Prefix.objects.all(),
118
115
  required=False,
@@ -121,10 +118,15 @@ class ViewForm(ViewPrefixUpdateMixin, TenancyForm, NetBoxModelForm):
121
118
  "depth": None,
122
119
  },
123
120
  )
121
+ ip_address_filter = JSONField(
122
+ label="IP Address Filter",
123
+ required=False,
124
+ help_text="Specify criteria for address record creation in JSON form",
125
+ )
124
126
 
125
127
  fieldsets = (
126
128
  FieldSet("name", "default_view", "description", "tags", name="View"),
127
- FieldSet("prefixes"),
129
+ FieldSet("prefixes", "ip_address_filter"),
128
130
  FieldSet("tenant_group", "tenant", name="Tenancy"),
129
131
  )
130
132
 
@@ -137,8 +139,25 @@ class ViewForm(ViewPrefixUpdateMixin, TenancyForm, NetBoxModelForm):
137
139
  "tags",
138
140
  "tenant",
139
141
  "prefixes",
142
+ "ip_address_filter",
140
143
  )
141
144
 
145
+ def clean_prefixes(self):
146
+ if hasattr(self, "_saved_prefixes"):
147
+ return self._saved_prefixes
148
+
149
+ return self.cleaned_data["prefixes"]
150
+
151
+ def clean_ip_address_filter(self):
152
+ ip_address_filter = self.cleaned_data.get("ip_address_filter")
153
+
154
+ try:
155
+ IPAddress.objects.filter(get_query_from_filter(ip_address_filter)).exists()
156
+ except (FieldError, ValueError) as exc:
157
+ self.add_error("ip_address_filter", f"Invalid filter for IPAddress: {exc}")
158
+
159
+ return ip_address_filter
160
+
142
161
 
143
162
  class ViewFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
144
163
  def __init__(self, *args, **kwargs):
netbox_dns/forms/zone.py CHANGED
@@ -30,7 +30,7 @@ from netbox_dns.models import (
30
30
  Zone,
31
31
  NameServer,
32
32
  Registrar,
33
- Contact,
33
+ RegistrationContact,
34
34
  ZoneTemplate,
35
35
  )
36
36
  from netbox_dns.choices import ZoneStatusChoices
@@ -421,22 +421,22 @@ class ZoneFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
421
421
  label="Registry Domain ID",
422
422
  )
423
423
  registrant_id = DynamicModelMultipleChoiceField(
424
- queryset=Contact.objects.all(),
424
+ queryset=RegistrationContact.objects.all(),
425
425
  required=False,
426
426
  label="Registrant",
427
427
  )
428
428
  admin_c_id = DynamicModelMultipleChoiceField(
429
- queryset=Contact.objects.all(),
429
+ queryset=RegistrationContact.objects.all(),
430
430
  required=False,
431
431
  label="Admin-C",
432
432
  )
433
433
  tech_c_id = DynamicModelMultipleChoiceField(
434
- queryset=Contact.objects.all(),
434
+ queryset=RegistrationContact.objects.all(),
435
435
  required=False,
436
436
  label="Tech-C",
437
437
  )
438
438
  billing_c_id = DynamicModelMultipleChoiceField(
439
- queryset=Contact.objects.all(),
439
+ queryset=RegistrationContact.objects.all(),
440
440
  required=False,
441
441
  label="Billing-C",
442
442
  )
@@ -532,7 +532,7 @@ class ZoneImportForm(ZoneTemplateUpdateMixin, NetBoxModelImportForm):
532
532
  help_text="Domain ID assigned by the registry",
533
533
  )
534
534
  registrant = CSVModelChoiceField(
535
- queryset=Contact.objects.all(),
535
+ queryset=RegistrationContact.objects.all(),
536
536
  required=False,
537
537
  to_field_name="contact_id",
538
538
  help_text="Owner of the domain",
@@ -541,7 +541,7 @@ class ZoneImportForm(ZoneTemplateUpdateMixin, NetBoxModelImportForm):
541
541
  },
542
542
  )
543
543
  admin_c = CSVModelChoiceField(
544
- queryset=Contact.objects.all(),
544
+ queryset=RegistrationContact.objects.all(),
545
545
  required=False,
546
546
  to_field_name="contact_id",
547
547
  help_text="Administrative contact for the domain",
@@ -550,7 +550,7 @@ class ZoneImportForm(ZoneTemplateUpdateMixin, NetBoxModelImportForm):
550
550
  },
551
551
  )
552
552
  tech_c = CSVModelChoiceField(
553
- queryset=Contact.objects.all(),
553
+ queryset=RegistrationContact.objects.all(),
554
554
  required=False,
555
555
  to_field_name="contact_id",
556
556
  help_text="Technical contact for the domain",
@@ -559,7 +559,7 @@ class ZoneImportForm(ZoneTemplateUpdateMixin, NetBoxModelImportForm):
559
559
  },
560
560
  )
561
561
  billing_c = CSVModelChoiceField(
562
- queryset=Contact.objects.all(),
562
+ queryset=RegistrationContact.objects.all(),
563
563
  required=False,
564
564
  to_field_name="contact_id",
565
565
  help_text="Billing contact for the domain",
@@ -719,21 +719,21 @@ class ZoneBulkEditForm(NetBoxModelBulkEditForm):
719
719
  label="Registry Domain ID",
720
720
  )
721
721
  registrant = DynamicModelChoiceField(
722
- queryset=Contact.objects.all(),
722
+ queryset=RegistrationContact.objects.all(),
723
723
  required=False,
724
724
  )
725
725
  admin_c = DynamicModelChoiceField(
726
- queryset=Contact.objects.all(),
726
+ queryset=RegistrationContact.objects.all(),
727
727
  required=False,
728
728
  label="Administrative Contact",
729
729
  )
730
730
  tech_c = DynamicModelChoiceField(
731
- queryset=Contact.objects.all(),
731
+ queryset=RegistrationContact.objects.all(),
732
732
  required=False,
733
733
  label="Technical Contact",
734
734
  )
735
735
  billing_c = DynamicModelChoiceField(
736
- queryset=Contact.objects.all(),
736
+ queryset=RegistrationContact.objects.all(),
737
737
  required=False,
738
738
  label="Billing Contact",
739
739
  )
@@ -22,7 +22,7 @@ from netbox_dns.models import (
22
22
  RecordTemplate,
23
23
  NameServer,
24
24
  Registrar,
25
- Contact,
25
+ RegistrationContact,
26
26
  )
27
27
 
28
28
 
@@ -117,22 +117,22 @@ class ZoneTemplateFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
117
117
  label="Registrar",
118
118
  )
119
119
  registrant_id = DynamicModelMultipleChoiceField(
120
- queryset=Contact.objects.all(),
120
+ queryset=RegistrationContact.objects.all(),
121
121
  required=False,
122
122
  label="Registrant",
123
123
  )
124
124
  admin_c_id = DynamicModelMultipleChoiceField(
125
- queryset=Contact.objects.all(),
125
+ queryset=RegistrationContact.objects.all(),
126
126
  required=False,
127
127
  label="Admin-C",
128
128
  )
129
129
  tech_c_id = DynamicModelMultipleChoiceField(
130
- queryset=Contact.objects.all(),
130
+ queryset=RegistrationContact.objects.all(),
131
131
  required=False,
132
132
  label="Tech-C",
133
133
  )
134
134
  billing_c_id = DynamicModelMultipleChoiceField(
135
- queryset=Contact.objects.all(),
135
+ queryset=RegistrationContact.objects.all(),
136
136
  required=False,
137
137
  label="Billing-C",
138
138
  )
@@ -162,7 +162,7 @@ class ZoneTemplateImportForm(NetBoxModelImportForm):
162
162
  },
163
163
  )
164
164
  registrant = CSVModelChoiceField(
165
- queryset=Contact.objects.all(),
165
+ queryset=RegistrationContact.objects.all(),
166
166
  required=False,
167
167
  to_field_name="contact_id",
168
168
  help_text="Owner of the domain",
@@ -171,7 +171,7 @@ class ZoneTemplateImportForm(NetBoxModelImportForm):
171
171
  },
172
172
  )
173
173
  admin_c = CSVModelChoiceField(
174
- queryset=Contact.objects.all(),
174
+ queryset=RegistrationContact.objects.all(),
175
175
  required=False,
176
176
  to_field_name="contact_id",
177
177
  help_text="Administrative contact for the domain",
@@ -180,7 +180,7 @@ class ZoneTemplateImportForm(NetBoxModelImportForm):
180
180
  },
181
181
  )
182
182
  tech_c = CSVModelChoiceField(
183
- queryset=Contact.objects.all(),
183
+ queryset=RegistrationContact.objects.all(),
184
184
  required=False,
185
185
  to_field_name="contact_id",
186
186
  help_text="Technical contact for the domain",
@@ -189,7 +189,7 @@ class ZoneTemplateImportForm(NetBoxModelImportForm):
189
189
  },
190
190
  )
191
191
  billing_c = CSVModelChoiceField(
192
- queryset=Contact.objects.all(),
192
+ queryset=RegistrationContact.objects.all(),
193
193
  required=False,
194
194
  to_field_name="contact_id",
195
195
  help_text="Billing contact for the domain",
@@ -237,21 +237,21 @@ class ZoneTemplateBulkEditForm(NetBoxModelBulkEditForm):
237
237
  required=False,
238
238
  )
239
239
  registrant = DynamicModelChoiceField(
240
- queryset=Contact.objects.all(),
240
+ queryset=RegistrationContact.objects.all(),
241
241
  required=False,
242
242
  )
243
243
  admin_c = DynamicModelChoiceField(
244
- queryset=Contact.objects.all(),
244
+ queryset=RegistrationContact.objects.all(),
245
245
  required=False,
246
246
  label="Administrative Contact",
247
247
  )
248
248
  tech_c = DynamicModelChoiceField(
249
- queryset=Contact.objects.all(),
249
+ queryset=RegistrationContact.objects.all(),
250
250
  required=False,
251
251
  label="Technical Contact",
252
252
  )
253
253
  billing_c = DynamicModelChoiceField(
254
- queryset=Contact.objects.all(),
254
+ queryset=RegistrationContact.objects.all(),
255
255
  required=False,
256
256
  label="Billing Contact",
257
257
  )
@@ -1,7 +1,7 @@
1
1
  from .schema import (
2
2
  NetBoxDNSViewQuery,
3
3
  NetBoxDNSNameServerQuery,
4
- NetBoxDNSContactQuery,
4
+ NetBoxDNSRegistrationContactQuery,
5
5
  NetBoxDNSRegistrarQuery,
6
6
  NetBoxDNSZoneQuery,
7
7
  NetBoxDNSRecordQuery,
@@ -14,7 +14,7 @@ schema = [
14
14
  NetBoxDNSViewQuery,
15
15
  NetBoxDNSZoneQuery,
16
16
  NetBoxDNSRecordQuery,
17
- NetBoxDNSContactQuery,
17
+ NetBoxDNSRegistrationContactQuery,
18
18
  NetBoxDNSRegistrarQuery,
19
19
  NetBoxDNSZoneTemplateQuery,
20
20
  NetBoxDNSRecordTemplateQuery,
@@ -7,7 +7,7 @@ from netbox_dns.models import (
7
7
  View,
8
8
  Zone,
9
9
  Record,
10
- Contact,
10
+ RegistrationContact,
11
11
  Registrar,
12
12
  ZoneTemplate,
13
13
  RecordTemplate,
@@ -17,7 +17,7 @@ from netbox_dns.filtersets import (
17
17
  ViewFilterSet,
18
18
  ZoneFilterSet,
19
19
  RecordFilterSet,
20
- ContactFilterSet,
20
+ RegistrationContactFilterSet,
21
21
  RegistrarFilterSet,
22
22
  ZoneTemplateFilterSet,
23
23
  RecordTemplateFilterSet,
@@ -60,9 +60,9 @@ class NetBoxDNSRecordTemplateFilter(BaseFilterMixin):
60
60
  pass
61
61
 
62
62
 
63
- @strawberry_django.filter(Contact, lookups=True)
64
- @autotype_decorator(ContactFilterSet)
65
- class NetBoxDNSContactFilter(BaseFilterMixin):
63
+ @strawberry_django.filter(RegistrationContact, lookups=True)
64
+ @autotype_decorator(RegistrationContactFilterSet)
65
+ class NetBoxDNSRegistrationContactFilter(BaseFilterMixin):
66
66
  pass
67
67
 
68
68
 
@@ -3,101 +3,71 @@ from typing import List
3
3
  import strawberry
4
4
  import strawberry_django
5
5
 
6
- from netbox_dns.models import (
7
- NameServer,
8
- View,
9
- Zone,
10
- Record,
11
- Contact,
12
- Registrar,
13
- ZoneTemplate,
14
- RecordTemplate,
15
- )
16
6
  from .types import (
17
7
  NetBoxDNSNameServerType,
18
8
  NetBoxDNSViewType,
19
9
  NetBoxDNSZoneType,
20
10
  NetBoxDNSRecordType,
21
- NetBoxDNSContactType,
11
+ NetBoxDNSRegistrationContactType,
22
12
  NetBoxDNSRegistrarType,
23
13
  NetBoxDNSZoneTemplateType,
24
14
  NetBoxDNSRecordTemplateType,
25
15
  )
26
16
 
27
17
 
28
- @strawberry.type
18
+ @strawberry.type(name="Query")
29
19
  class NetBoxDNSNameServerQuery:
30
- @strawberry.field
31
- def netbox_dns_nameserver(self, id: int) -> NetBoxDNSNameServerType:
32
- return NameServer.objects.get(pk=id)
33
-
20
+ netbox_dns_nameserver: NetBoxDNSNameServerType = strawberry_django.field()
34
21
  netbox_dns_nameserver_list: List[NetBoxDNSNameServerType] = (
35
22
  strawberry_django.field()
36
23
  )
37
24
 
38
25
 
39
- @strawberry.type
26
+ @strawberry.type(name="Query")
40
27
  class NetBoxDNSViewQuery:
41
- @strawberry.field
42
- def netbox_dns_view(self, id: int) -> NetBoxDNSViewType:
43
- return View.objects.get(pk=id)
44
-
28
+ netbox_dns_view: NetBoxDNSViewType = strawberry_django.field()
45
29
  netbox_dns_view_list: List[NetBoxDNSViewType] = strawberry_django.field()
46
30
 
47
31
 
48
- @strawberry.type
32
+ @strawberry.type(name="Query")
49
33
  class NetBoxDNSZoneQuery:
50
- @strawberry.field
51
- def netbox_dns_zone(self, id: int) -> NetBoxDNSZoneType:
52
- return Zone.objects.get(pk=id)
53
-
34
+ netbox_dns_zone: NetBoxDNSZoneType = strawberry_django.field()
54
35
  netbox_dns_zone_list: List[NetBoxDNSZoneType] = strawberry_django.field()
55
36
 
56
37
 
57
- @strawberry.type
38
+ @strawberry.type(name="Query")
58
39
  class NetBoxDNSRecordQuery:
59
- @strawberry.field
60
- def netbox_dns_record(self, id: int) -> NetBoxDNSRecordType:
61
- return Record.objects.get(pk=id)
62
-
40
+ netbox_dns_record: NetBoxDNSRecordType = strawberry_django.field()
63
41
  netbox_dns_record_list: List[NetBoxDNSRecordType] = strawberry_django.field()
64
42
 
65
43
 
66
- @strawberry.type
67
- class NetBoxDNSContactQuery:
68
- @strawberry.field
69
- def netbox_dns_contact(self, id: int) -> NetBoxDNSContactType:
70
- return Contact.objects.get(pk=id)
71
-
72
- netbox_dns_contact_list: List[NetBoxDNSContactType] = strawberry_django.field()
44
+ @strawberry.type(name="Query")
45
+ class NetBoxDNSRegistrationContactQuery:
46
+ netbox_dns_registration_contact: NetBoxDNSRegistrationContactType = (
47
+ strawberry_django.field()
48
+ )
49
+ netbox_dns_registration_contact_list: List[NetBoxDNSRegistrationContactType] = (
50
+ strawberry_django.field()
51
+ )
73
52
 
74
53
 
75
- @strawberry.type
54
+ @strawberry.type(name="Query")
76
55
  class NetBoxDNSRegistrarQuery:
77
- @strawberry.field
78
- def netbox_dns_registrar(self, id: int) -> NetBoxDNSRegistrarType:
79
- return Registrar.objects.get(pk=id)
80
-
56
+ netbox_dns_registrar: NetBoxDNSRegistrarType = strawberry_django.field()
81
57
  netbox_dns_registrar_list: List[NetBoxDNSRegistrarType] = strawberry_django.field()
82
58
 
83
59
 
84
- @strawberry.type
60
+ @strawberry.type(name="Query")
85
61
  class NetBoxDNSZoneTemplateQuery:
86
- @strawberry.field
87
- def netbox_dns_zone_template(self, id: int) -> NetBoxDNSZoneTemplateType:
88
- return ZoneTemplate.objects.get(pk=id)
89
-
62
+ netbox_dns_zone_template: NetBoxDNSZoneTemplateType = strawberry_django.field()
90
63
  netbox_dns_zone_template_list: List[NetBoxDNSZoneTemplateType] = (
91
64
  strawberry_django.field()
92
65
  )
93
66
 
94
67
 
95
- @strawberry.type
68
+ @strawberry.type(name="Query")
96
69
  class NetBoxDNSRecordTemplateQuery:
97
- @strawberry.field
98
- def netbox_dns_record_template(self, id: int) -> NetBoxDNSRecordTemplateType:
99
- return RecordTemplate.objects.get(pk=id)
100
-
70
+ netbox_dns_record_template: NetBoxDNSRecordTemplateType = strawberry_django.field()
101
71
  netbox_dns_record_template_list: List[NetBoxDNSRecordTemplateType] = (
102
72
  strawberry_django.field()
103
73
  )
@@ -13,7 +13,7 @@ from netbox_dns.models import (
13
13
  View,
14
14
  Zone,
15
15
  Record,
16
- Contact,
16
+ RegistrationContact,
17
17
  Registrar,
18
18
  ZoneTemplate,
19
19
  RecordTemplate,
@@ -23,7 +23,7 @@ from .filters import (
23
23
  NetBoxDNSViewFilter,
24
24
  NetBoxDNSZoneFilter,
25
25
  NetBoxDNSRecordFilter,
26
- NetBoxDNSContactFilter,
26
+ NetBoxDNSRegistrationContactFilter,
27
27
  NetBoxDNSRegistrarFilter,
28
28
  NetBoxDNSZoneTemplateFilter,
29
29
  NetBoxDNSRecordTemplateFilter,
@@ -43,6 +43,7 @@ class NetBoxDNSViewType(NetBoxObjectType):
43
43
  description: str
44
44
  tenant: Annotated["TenantType", strawberry.lazy("tenancy.graphql.types")] | None
45
45
  prefixes: List[Annotated["PrefixType", strawberry.lazy("ipam.graphql.types")]]
46
+ ip_address_filter: str | None
46
47
 
47
48
 
48
49
  @strawberry_django.type(Zone, fields="__all__", filters=NetBoxDNSZoneFilter)
@@ -77,19 +78,31 @@ class NetBoxDNSZoneType(NetBoxObjectType):
77
78
  )
78
79
  registry_domain_id: str | None
79
80
  registrant: (
80
- Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
81
+ Annotated[
82
+ "NetBoxDNSRegistrationContactType",
83
+ strawberry.lazy("netbox_dns.graphql.types"),
84
+ ]
81
85
  | None
82
86
  )
83
87
  admin_c: (
84
- Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
88
+ Annotated[
89
+ "NetBoxDNSRegistrationContactType",
90
+ strawberry.lazy("netbox_dns.graphql.types"),
91
+ ]
85
92
  | None
86
93
  )
87
94
  tech_c: (
88
- Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
95
+ Annotated[
96
+ "NetBoxDNSRegistrationContactType",
97
+ strawberry.lazy("netbox_dns.graphql.types"),
98
+ ]
89
99
  | None
90
100
  )
91
101
  billing_c: (
92
- Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
102
+ Annotated[
103
+ "NetBoxDNSRegistrationContactType",
104
+ strawberry.lazy("netbox_dns.graphql.types"),
105
+ ]
93
106
  | None
94
107
  )
95
108
  rfc2317_prefix: str | None
@@ -126,8 +139,10 @@ class NetBoxDNSRecordType(NetBoxObjectType):
126
139
  )
127
140
 
128
141
 
129
- @strawberry_django.type(Contact, fields="__all__", filters=NetBoxDNSContactFilter)
130
- class NetBoxDNSContactType(NetBoxObjectType):
142
+ @strawberry_django.type(
143
+ RegistrationContact, fields="__all__", filters=NetBoxDNSRegistrationContactFilter
144
+ )
145
+ class NetBoxDNSRegistrationContactType(NetBoxObjectType):
131
146
  name: str
132
147
  contact_id: str
133
148
  description: str
@@ -178,19 +193,31 @@ class NetBoxDNSZoneTemplateType(NetBoxObjectType):
178
193
  | None
179
194
  )
180
195
  registrant: (
181
- Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
196
+ Annotated[
197
+ "NetBoxDNSRegistrationContactType",
198
+ strawberry.lazy("netbox_dns.graphql.types"),
199
+ ]
182
200
  | None
183
201
  )
184
202
  admin_c: (
185
- Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
203
+ Annotated[
204
+ "NetBoxDNSRegistrationContactType",
205
+ strawberry.lazy("netbox_dns.graphql.types"),
206
+ ]
186
207
  | None
187
208
  )
188
209
  tech_c: (
189
- Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
210
+ Annotated[
211
+ "NetBoxDNSRegistrationContactType",
212
+ strawberry.lazy("netbox_dns.graphql.types"),
213
+ ]
190
214
  | None
191
215
  )
192
216
  billing_c: (
193
- Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
217
+ Annotated[
218
+ "NetBoxDNSRegistrationContactType",
219
+ strawberry.lazy("netbox_dns.graphql.types"),
220
+ ]
194
221
  | None
195
222
  )
196
223
 
@@ -0,0 +1,25 @@
1
+ # Generated by Django 5.0.7 on 2024-08-27 09:29
2
+
3
+ from django.db import migrations
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("netbox_dns", "0006_templating"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AlterModelOptions(
14
+ name="record",
15
+ options={"ordering": ("fqdn", "zone", "name", "type", "value", "status")},
16
+ ),
17
+ migrations.AlterModelOptions(
18
+ name="recordtemplate",
19
+ options={"ordering": ("name",)},
20
+ ),
21
+ migrations.AlterModelOptions(
22
+ name="zonetemplate",
23
+ options={"ordering": ("name",)},
24
+ ),
25
+ ]
@@ -4,7 +4,7 @@ from django.db import migrations, models
4
4
  class Migration(migrations.Migration):
5
5
  dependencies = [
6
6
  ("ipam", "0067_ipaddress_index_host"),
7
- ("netbox_dns", "0006_templating"),
7
+ ("netbox_dns", "0007_alter_ordering_options"),
8
8
  ]
9
9
 
10
10
  operations = [
@@ -0,0 +1,36 @@
1
+ from django.db import migrations, connection
2
+
3
+
4
+ def remove_object_changes(apps, schema_editor):
5
+ if "objectchange" in apps.all_models.get("core"):
6
+ with connection.cursor() as cursor:
7
+ cursor.execute(
8
+ "DELETE FROM core_objectchange WHERE changed_object_type_id in (SELECT id FROM django_content_type WHERE app_label='netbox_dns' AND model='contact')"
9
+ )
10
+
11
+
12
+ class Migration(migrations.Migration):
13
+
14
+ dependencies = [
15
+ ("netbox_dns", "0008_view_prefixes"),
16
+ ]
17
+
18
+ operations = [
19
+ migrations.RenameModel(
20
+ old_name="Contact",
21
+ new_name="RegistrationContact",
22
+ ),
23
+ migrations.RunSQL(
24
+ "ALTER TABLE netbox_dns_contact_id_seq RENAME TO netbox_dns_registrationcontact_id_seq"
25
+ ),
26
+ migrations.RunSQL(
27
+ "ALTER INDEX netbox_dns_contact_pkey RENAME TO netbox_dns_registrationcontact_pkey"
28
+ ),
29
+ migrations.RunSQL(
30
+ "ALTER INDEX netbox_dns_contact_contact_id_50e9d89d_like RENAME TO netbox_dns_registrationcontact_contact_id_6ff98464_like"
31
+ ),
32
+ migrations.RunSQL(
33
+ "ALTER INDEX netbox_dns_contact_contact_id_key RENAME TO netbox_dns_contact_registrationcontact_id_key"
34
+ ),
35
+ migrations.RunPython(remove_object_changes),
36
+ ]
@@ -0,0 +1,18 @@
1
+ # Generated by Django 5.0.9 on 2024-09-18 13:12
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("netbox_dns", "0009_rename_contact_registrationcontact"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AddField(
14
+ model_name="view",
15
+ name="ip_address_filter",
16
+ field=models.JSONField(blank=True, null=True),
17
+ ),
18
+ ]