netbox-plugin-dns 1.1.0__py3-none-any.whl → 1.1.0b1__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 (84) hide show
  1. netbox_dns/__init__.py +6 -9
  2. netbox_dns/api/nested_serializers.py +16 -17
  3. netbox_dns/api/serializers.py +1 -1
  4. netbox_dns/api/serializers_/{registration_contact.py → contact.py} +5 -5
  5. netbox_dns/api/serializers_/record.py +0 -1
  6. netbox_dns/api/serializers_/zone.py +5 -5
  7. netbox_dns/api/serializers_/zone_template.py +5 -5
  8. netbox_dns/api/urls.py +2 -2
  9. netbox_dns/api/views.py +35 -9
  10. netbox_dns/fields/ipam.py +3 -0
  11. netbox_dns/filtersets/__init__.py +1 -1
  12. netbox_dns/filtersets/{registration_contact.py → contact.py} +4 -4
  13. netbox_dns/filtersets/record.py +1 -1
  14. netbox_dns/filtersets/zone.py +15 -15
  15. netbox_dns/filtersets/zone_template.py +15 -15
  16. netbox_dns/forms/__init__.py +1 -1
  17. netbox_dns/forms/{registration_contact.py → contact.py} +16 -16
  18. netbox_dns/forms/view.py +7 -95
  19. netbox_dns/forms/zone.py +17 -22
  20. netbox_dns/forms/zone_template.py +13 -13
  21. netbox_dns/graphql/__init__.py +2 -2
  22. netbox_dns/graphql/filters.py +5 -5
  23. netbox_dns/graphql/schema.py +44 -24
  24. netbox_dns/graphql/types.py +12 -40
  25. netbox_dns/management/commands/{setup_dnssync.py → setup_autodns.py} +28 -48
  26. netbox_dns/migrations/{0008_view_prefixes.py → 0007_view_prefixes.py} +1 -1
  27. netbox_dns/models/__init__.py +1 -1
  28. netbox_dns/models/{registration_contact.py → contact.py} +9 -15
  29. netbox_dns/models/nameserver.py +3 -8
  30. netbox_dns/models/record.py +28 -93
  31. netbox_dns/models/record_template.py +1 -4
  32. netbox_dns/models/registrar.py +1 -7
  33. netbox_dns/models/view.py +2 -9
  34. netbox_dns/models/zone.py +22 -59
  35. netbox_dns/models/zone_template.py +9 -12
  36. netbox_dns/navigation.py +7 -7
  37. netbox_dns/signals/ipam_autodns.py +138 -0
  38. netbox_dns/tables/__init__.py +1 -1
  39. netbox_dns/tables/{registration_contact.py → contact.py} +6 -5
  40. netbox_dns/tables/nameserver.py +7 -1
  41. netbox_dns/tables/record.py +30 -43
  42. netbox_dns/tables/record_template.py +17 -0
  43. netbox_dns/tables/registrar.py +2 -0
  44. netbox_dns/tables/view.py +8 -1
  45. netbox_dns/tables/zone.py +15 -0
  46. netbox_dns/tables/zone_template.py +16 -2
  47. netbox_dns/template_content.py +2 -14
  48. netbox_dns/templates/netbox_dns/{registrationcontact.html → contact.html} +1 -1
  49. netbox_dns/templates/netbox_dns/view.html +7 -3
  50. netbox_dns/urls/__init__.py +2 -2
  51. netbox_dns/urls/contact.py +51 -0
  52. netbox_dns/urls/nameserver.py +38 -14
  53. netbox_dns/urls/record.py +19 -7
  54. netbox_dns/urls/record_template.py +27 -18
  55. netbox_dns/urls/registrar.py +35 -11
  56. netbox_dns/urls/view.py +20 -12
  57. netbox_dns/urls/zone.py +46 -8
  58. netbox_dns/urls/zone_template.py +26 -16
  59. netbox_dns/utilities/__init__.py +1 -1
  60. netbox_dns/utilities/{ipam_dnssync.py → ipam_autodns.py} +32 -122
  61. netbox_dns/validators/dns_name.py +0 -9
  62. netbox_dns/views/__init__.py +1 -1
  63. netbox_dns/views/contact.py +95 -0
  64. netbox_dns/views/nameserver.py +3 -7
  65. netbox_dns/views/record.py +7 -12
  66. netbox_dns/views/record_template.py +1 -1
  67. netbox_dns/views/registrar.py +1 -0
  68. netbox_dns/views/view.py +2 -32
  69. netbox_dns/views/zone.py +6 -7
  70. netbox_dns/views/zone_template.py +2 -2
  71. {netbox_plugin_dns-1.1.0.dist-info → netbox_plugin_dns-1.1.0b1.dist-info}/METADATA +2 -3
  72. netbox_plugin_dns-1.1.0b1.dist-info/RECORD +140 -0
  73. netbox_dns/management/commands/rebuild_dnssync.py +0 -18
  74. netbox_dns/migrations/0007_alter_ordering_options.py +0 -25
  75. netbox_dns/migrations/0009_rename_contact_registrationcontact.py +0 -27
  76. netbox_dns/signals/ipam_dnssync.py +0 -224
  77. netbox_dns/tables/ipam_dnssync.py +0 -11
  78. netbox_dns/templates/netbox_dns/view/button.html +0 -9
  79. netbox_dns/templates/netbox_dns/view/prefix.html +0 -41
  80. netbox_dns/urls/registration_contact.py +0 -60
  81. netbox_dns/views/registration_contact.py +0 -94
  82. netbox_plugin_dns-1.1.0.dist-info/RECORD +0 -146
  83. {netbox_plugin_dns-1.1.0.dist-info → netbox_plugin_dns-1.1.0b1.dist-info}/LICENSE +0 -0
  84. {netbox_plugin_dns-1.1.0.dist-info → netbox_plugin_dns-1.1.0b1.dist-info}/WHEEL +0 -0
netbox_dns/forms/view.py CHANGED
@@ -21,13 +21,12 @@ from utilities.forms.rendering import FieldSet
21
21
  from tenancy.models import Tenant
22
22
  from tenancy.forms import TenancyForm, TenancyFilterForm
23
23
  from ipam.models import Prefix
24
- from netbox.context import current_request
25
24
 
26
25
  from netbox_dns.models import View
27
26
  from netbox_dns.fields import PrefixDynamicModelMultipleChoiceField
28
27
  from netbox_dns.utilities import (
29
- check_dns_records,
30
28
  get_ip_addresses_by_prefix,
29
+ update_dns_records,
31
30
  get_views_by_prefix,
32
31
  )
33
32
 
@@ -37,7 +36,6 @@ __all__ = (
37
36
  "ViewFilterForm",
38
37
  "ViewImportForm",
39
38
  "ViewBulkEditForm",
40
- "ViewPrefixEditForm",
41
39
  )
42
40
 
43
41
 
@@ -54,7 +52,7 @@ class ViewPrefixUpdateMixin:
54
52
  for prefix in prefixes.difference(old_prefixes):
55
53
  for ip_address in get_ip_addresses_by_prefix(prefix, check_view=False):
56
54
  try:
57
- check_dns_records(ip_address, view=self.instance)
55
+ update_dns_records(ip_address, commit=False, view=self.instance)
58
56
  except ValidationError as exc:
59
57
  self.add_error("prefixes", exc.messages)
60
58
 
@@ -76,7 +74,7 @@ class ViewPrefixUpdateMixin:
76
74
  # parent. If that's the case, the IP addresses need to be checked.
77
75
  # -
78
76
  if (parent := check_prefix.get_parents().last()) is None:
79
- continue
77
+ return
80
78
 
81
79
  for view in get_views_by_prefix(parent):
82
80
  if view == self.instance:
@@ -86,7 +84,7 @@ class ViewPrefixUpdateMixin:
86
84
  check_prefix, check_view=False
87
85
  ):
88
86
  try:
89
- check_dns_records(ip_address, view=view)
87
+ update_dns_records(ip_address, commit=False, view=view)
90
88
  except ValidationError as exc:
91
89
  self.add_error("prefixes", exc.messages)
92
90
 
@@ -95,24 +93,9 @@ class ViewForm(ViewPrefixUpdateMixin, TenancyForm, NetBoxModelForm):
95
93
  def __init__(self, *args, **kwargs):
96
94
  super().__init__(*args, **kwargs)
97
95
 
98
- if settings.PLUGINS_CONFIG["netbox_dns"].get("dnssync_disabled"):
96
+ if settings.PLUGINS_CONFIG["netbox_dns"].get("autodns_disabled"):
99
97
  del self.fields["prefixes"]
100
98
 
101
- if request := current_request.get():
102
- if not request.user.has_perm("ipam.view_prefix"):
103
- self._saved_prefixes = self.initial["prefixes"]
104
- self.initial["prefixes"] = []
105
- self.fields["prefixes"].disabled = True
106
- self.fields["prefixes"].widget.attrs[
107
- "placeholder"
108
- ] = "You do not have permission to modify assigned prefixes"
109
-
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
99
  prefixes = PrefixDynamicModelMultipleChoiceField(
117
100
  queryset=Prefix.objects.all(),
118
101
  required=False,
@@ -144,7 +127,7 @@ class ViewFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
144
127
  def __init__(self, *args, **kwargs):
145
128
  super().__init__(*args, **kwargs)
146
129
 
147
- if settings.PLUGINS_CONFIG["netbox_dns"].get("dnssync_disabled"):
130
+ if settings.PLUGINS_CONFIG["netbox_dns"].get("autodns_disabled"):
148
131
  del self.fields["prefix_id"]
149
132
 
150
133
  model = View
@@ -180,7 +163,7 @@ class ViewImportForm(ViewPrefixUpdateMixin, NetBoxModelImportForm):
180
163
  def __init__(self, *args, **kwargs):
181
164
  super().__init__(*args, **kwargs)
182
165
 
183
- if settings.PLUGINS_CONFIG["netbox_dns"].get("dnssync_disabled"):
166
+ if settings.PLUGINS_CONFIG["netbox_dns"].get("autodns_disabled"):
184
167
  del self.fields["prefixes"]
185
168
 
186
169
  prefixes = CSVModelMultipleChoiceField(
@@ -217,74 +200,3 @@ class ViewBulkEditForm(NetBoxModelBulkEditForm):
217
200
  )
218
201
 
219
202
  nullable_fields = ("description", "tenant")
220
-
221
-
222
- class ViewPrefixEditForm(forms.ModelForm):
223
- views = DynamicModelMultipleChoiceField(
224
- queryset=View.objects.all(),
225
- required=False,
226
- label="Assigned DNS Views",
227
- help_text="Explicitly assigning DNS views overrides all inherited views for this prefix",
228
- )
229
-
230
- class Meta:
231
- model = Prefix
232
- fields = ("views",)
233
-
234
- def __init__(self, *args, **kwargs):
235
- super().__init__(*args, **kwargs)
236
-
237
- self.initial["views"] = self.instance.netbox_dns_views.all()
238
- self._permission_denied = False
239
-
240
- if request := current_request.get():
241
- if not request.user.has_perm("netbox_dns.change_view"):
242
- self._permission_denied = True
243
- self.initial["views"] = []
244
- self.fields["views"].disabled = True
245
- self.fields["views"].widget.attrs[
246
- "placeholder"
247
- ] = "You do not have permission to modify assigned views"
248
-
249
- def clean(self, *args, **kwargs):
250
- if self._permission_denied:
251
- return
252
-
253
- prefix = self.instance
254
-
255
- super().clean(*args, **kwargs)
256
-
257
- views = self.cleaned_data.get("views")
258
- old_views = prefix.netbox_dns_views.all()
259
-
260
- check_views = View.objects.none()
261
-
262
- if not views.exists():
263
- if (parent := prefix.get_parents().last()) is not None:
264
- check_views = parent.netbox_dns_views.all().difference(old_views)
265
-
266
- else:
267
- check_views = views.difference(old_views)
268
-
269
- for view in check_views:
270
- try:
271
- for ip_address in get_ip_addresses_by_prefix(prefix, check_view=False):
272
- check_dns_records(ip_address, view=view)
273
- except ValidationError as exc:
274
- self.add_error("views", exc.messages)
275
-
276
- def save(self, *args, **kwargs):
277
- prefix = self.instance
278
-
279
- if self._permission_denied:
280
- return prefix
281
-
282
- old_views = prefix.netbox_dns_views.all()
283
- views = self.cleaned_data.get("views")
284
-
285
- for view in views.difference(old_views):
286
- view.prefixes.add(prefix)
287
- for view in old_views.difference(views):
288
- view.prefixes.remove(prefix)
289
-
290
- return prefix
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
- RegistrationContact,
33
+ Contact,
34
34
  ZoneTemplate,
35
35
  )
36
36
  from netbox_dns.choices import ZoneStatusChoices
@@ -81,14 +81,6 @@ class ZoneTemplateUpdateMixin:
81
81
  else:
82
82
  zone_data = self.cleaned_data.copy()
83
83
 
84
- custom_fields = {}
85
- for key, value in zone_data.copy().items():
86
- if key.startswith("cf_"):
87
- custom_fields[key[3:]] = value
88
- zone_data.pop(key)
89
- if custom_fields:
90
- zone_data["custom_field_data"] = custom_fields
91
-
92
84
  zone_data.pop("template", None)
93
85
  zone_data.pop("tenant_group", None)
94
86
  zone_data.pop("_init_time", None)
@@ -105,7 +97,10 @@ class ZoneTemplateUpdateMixin:
105
97
  raise RollbackTransaction
106
98
 
107
99
  except ValidationError as exc:
108
- self.add_error("template", exc.messages)
100
+ if isinstance(exc, dict):
101
+ template_error = item.value()
102
+ else:
103
+ template_error = [exc]
109
104
  except RollbackTransaction:
110
105
  pass
111
106
 
@@ -421,22 +416,22 @@ class ZoneFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
421
416
  label="Registry Domain ID",
422
417
  )
423
418
  registrant_id = DynamicModelMultipleChoiceField(
424
- queryset=RegistrationContact.objects.all(),
419
+ queryset=Contact.objects.all(),
425
420
  required=False,
426
421
  label="Registrant",
427
422
  )
428
423
  admin_c_id = DynamicModelMultipleChoiceField(
429
- queryset=RegistrationContact.objects.all(),
424
+ queryset=Contact.objects.all(),
430
425
  required=False,
431
426
  label="Admin-C",
432
427
  )
433
428
  tech_c_id = DynamicModelMultipleChoiceField(
434
- queryset=RegistrationContact.objects.all(),
429
+ queryset=Contact.objects.all(),
435
430
  required=False,
436
431
  label="Tech-C",
437
432
  )
438
433
  billing_c_id = DynamicModelMultipleChoiceField(
439
- queryset=RegistrationContact.objects.all(),
434
+ queryset=Contact.objects.all(),
440
435
  required=False,
441
436
  label="Billing-C",
442
437
  )
@@ -532,7 +527,7 @@ class ZoneImportForm(ZoneTemplateUpdateMixin, NetBoxModelImportForm):
532
527
  help_text="Domain ID assigned by the registry",
533
528
  )
534
529
  registrant = CSVModelChoiceField(
535
- queryset=RegistrationContact.objects.all(),
530
+ queryset=Contact.objects.all(),
536
531
  required=False,
537
532
  to_field_name="contact_id",
538
533
  help_text="Owner of the domain",
@@ -541,7 +536,7 @@ class ZoneImportForm(ZoneTemplateUpdateMixin, NetBoxModelImportForm):
541
536
  },
542
537
  )
543
538
  admin_c = CSVModelChoiceField(
544
- queryset=RegistrationContact.objects.all(),
539
+ queryset=Contact.objects.all(),
545
540
  required=False,
546
541
  to_field_name="contact_id",
547
542
  help_text="Administrative contact for the domain",
@@ -550,7 +545,7 @@ class ZoneImportForm(ZoneTemplateUpdateMixin, NetBoxModelImportForm):
550
545
  },
551
546
  )
552
547
  tech_c = CSVModelChoiceField(
553
- queryset=RegistrationContact.objects.all(),
548
+ queryset=Contact.objects.all(),
554
549
  required=False,
555
550
  to_field_name="contact_id",
556
551
  help_text="Technical contact for the domain",
@@ -559,7 +554,7 @@ class ZoneImportForm(ZoneTemplateUpdateMixin, NetBoxModelImportForm):
559
554
  },
560
555
  )
561
556
  billing_c = CSVModelChoiceField(
562
- queryset=RegistrationContact.objects.all(),
557
+ queryset=Contact.objects.all(),
563
558
  required=False,
564
559
  to_field_name="contact_id",
565
560
  help_text="Billing contact for the domain",
@@ -719,21 +714,21 @@ class ZoneBulkEditForm(NetBoxModelBulkEditForm):
719
714
  label="Registry Domain ID",
720
715
  )
721
716
  registrant = DynamicModelChoiceField(
722
- queryset=RegistrationContact.objects.all(),
717
+ queryset=Contact.objects.all(),
723
718
  required=False,
724
719
  )
725
720
  admin_c = DynamicModelChoiceField(
726
- queryset=RegistrationContact.objects.all(),
721
+ queryset=Contact.objects.all(),
727
722
  required=False,
728
723
  label="Administrative Contact",
729
724
  )
730
725
  tech_c = DynamicModelChoiceField(
731
- queryset=RegistrationContact.objects.all(),
726
+ queryset=Contact.objects.all(),
732
727
  required=False,
733
728
  label="Technical Contact",
734
729
  )
735
730
  billing_c = DynamicModelChoiceField(
736
- queryset=RegistrationContact.objects.all(),
731
+ queryset=Contact.objects.all(),
737
732
  required=False,
738
733
  label="Billing Contact",
739
734
  )
@@ -22,7 +22,7 @@ from netbox_dns.models import (
22
22
  RecordTemplate,
23
23
  NameServer,
24
24
  Registrar,
25
- RegistrationContact,
25
+ Contact,
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=RegistrationContact.objects.all(),
120
+ queryset=Contact.objects.all(),
121
121
  required=False,
122
122
  label="Registrant",
123
123
  )
124
124
  admin_c_id = DynamicModelMultipleChoiceField(
125
- queryset=RegistrationContact.objects.all(),
125
+ queryset=Contact.objects.all(),
126
126
  required=False,
127
127
  label="Admin-C",
128
128
  )
129
129
  tech_c_id = DynamicModelMultipleChoiceField(
130
- queryset=RegistrationContact.objects.all(),
130
+ queryset=Contact.objects.all(),
131
131
  required=False,
132
132
  label="Tech-C",
133
133
  )
134
134
  billing_c_id = DynamicModelMultipleChoiceField(
135
- queryset=RegistrationContact.objects.all(),
135
+ queryset=Contact.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=RegistrationContact.objects.all(),
165
+ queryset=Contact.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=RegistrationContact.objects.all(),
174
+ queryset=Contact.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=RegistrationContact.objects.all(),
183
+ queryset=Contact.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=RegistrationContact.objects.all(),
192
+ queryset=Contact.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=RegistrationContact.objects.all(),
240
+ queryset=Contact.objects.all(),
241
241
  required=False,
242
242
  )
243
243
  admin_c = DynamicModelChoiceField(
244
- queryset=RegistrationContact.objects.all(),
244
+ queryset=Contact.objects.all(),
245
245
  required=False,
246
246
  label="Administrative Contact",
247
247
  )
248
248
  tech_c = DynamicModelChoiceField(
249
- queryset=RegistrationContact.objects.all(),
249
+ queryset=Contact.objects.all(),
250
250
  required=False,
251
251
  label="Technical Contact",
252
252
  )
253
253
  billing_c = DynamicModelChoiceField(
254
- queryset=RegistrationContact.objects.all(),
254
+ queryset=Contact.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
- NetBoxDNSRegistrationContactQuery,
4
+ NetBoxDNSContactQuery,
5
5
  NetBoxDNSRegistrarQuery,
6
6
  NetBoxDNSZoneQuery,
7
7
  NetBoxDNSRecordQuery,
@@ -14,7 +14,7 @@ schema = [
14
14
  NetBoxDNSViewQuery,
15
15
  NetBoxDNSZoneQuery,
16
16
  NetBoxDNSRecordQuery,
17
- NetBoxDNSRegistrationContactQuery,
17
+ NetBoxDNSContactQuery,
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
- RegistrationContact,
10
+ Contact,
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
- RegistrationContactFilterSet,
20
+ ContactFilterSet,
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(RegistrationContact, lookups=True)
64
- @autotype_decorator(RegistrationContactFilterSet)
65
- class NetBoxDNSRegistrationContactFilter(BaseFilterMixin):
63
+ @strawberry_django.filter(Contact, lookups=True)
64
+ @autotype_decorator(ContactFilterSet)
65
+ class NetBoxDNSContactFilter(BaseFilterMixin):
66
66
  pass
67
67
 
68
68
 
@@ -8,7 +8,7 @@ from netbox_dns.models import (
8
8
  View,
9
9
  Zone,
10
10
  Record,
11
- RegistrationContact,
11
+ Contact,
12
12
  Registrar,
13
13
  ZoneTemplate,
14
14
  RecordTemplate,
@@ -18,66 +18,86 @@ from .types import (
18
18
  NetBoxDNSViewType,
19
19
  NetBoxDNSZoneType,
20
20
  NetBoxDNSRecordType,
21
- NetBoxDNSRegistrationContactType,
21
+ NetBoxDNSContactType,
22
22
  NetBoxDNSRegistrarType,
23
23
  NetBoxDNSZoneTemplateType,
24
24
  NetBoxDNSRecordTemplateType,
25
25
  )
26
26
 
27
27
 
28
- @strawberry.type(name="Query")
28
+ @strawberry.type
29
29
  class NetBoxDNSNameServerQuery:
30
- netbox_dns_nameserver: NetBoxDNSNameServerType = strawberry_django.field()
30
+ @strawberry.field
31
+ def netbox_dns_nameserver(self, id: int) -> NetBoxDNSNameServerType:
32
+ return NameServer.objects.get(pk=id)
33
+
31
34
  netbox_dns_nameserver_list: List[NetBoxDNSNameServerType] = (
32
35
  strawberry_django.field()
33
36
  )
34
37
 
35
38
 
36
- @strawberry.type(name="Query")
39
+ @strawberry.type
37
40
  class NetBoxDNSViewQuery:
38
- netbox_dns_view: NetBoxDNSViewType = strawberry_django.field()
41
+ @strawberry.field
42
+ def netbox_dns_view(self, id: int) -> NetBoxDNSViewType:
43
+ return View.objects.get(pk=id)
44
+
39
45
  netbox_dns_view_list: List[NetBoxDNSViewType] = strawberry_django.field()
40
46
 
41
47
 
42
- @strawberry.type(name="Query")
48
+ @strawberry.type
43
49
  class NetBoxDNSZoneQuery:
44
- netbox_dns_zone: NetBoxDNSZoneType = strawberry_django.field()
50
+ @strawberry.field
51
+ def netbox_dns_zone(self, id: int) -> NetBoxDNSZoneType:
52
+ return Zone.objects.get(pk=id)
53
+
45
54
  netbox_dns_zone_list: List[NetBoxDNSZoneType] = strawberry_django.field()
46
55
 
47
56
 
48
- @strawberry.type(name="Query")
57
+ @strawberry.type
49
58
  class NetBoxDNSRecordQuery:
50
- netbox_dns_record: NetBoxDNSRecordType = strawberry_django.field()
59
+ @strawberry.field
60
+ def netbox_dns_record(self, id: int) -> NetBoxDNSRecordType:
61
+ return Record.objects.get(pk=id)
62
+
51
63
  netbox_dns_record_list: List[NetBoxDNSRecordType] = strawberry_django.field()
52
64
 
53
65
 
54
- @strawberry.type(name="Query")
55
- class NetBoxDNSRegistrationContactQuery:
56
- netbox_dns_registration_contact: NetBoxDNSRegistrationContactType = (
57
- strawberry_django.field()
58
- )
59
- netbox_dns_registration_contact_list: List[NetBoxDNSRegistrationContactType] = (
60
- strawberry_django.field()
61
- )
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()
62
73
 
63
74
 
64
- @strawberry.type(name="Query")
75
+ @strawberry.type
65
76
  class NetBoxDNSRegistrarQuery:
66
- netbox_dns_registrar: NetBoxDNSRegistrarType = strawberry_django.field()
77
+ @strawberry.field
78
+ def netbox_dns_registrar(self, id: int) -> NetBoxDNSRegistrarType:
79
+ return Registrar.objects.get(pk=id)
80
+
67
81
  netbox_dns_registrar_list: List[NetBoxDNSRegistrarType] = strawberry_django.field()
68
82
 
69
83
 
70
- @strawberry.type(name="Query")
84
+ @strawberry.type
71
85
  class NetBoxDNSZoneTemplateQuery:
72
- netbox_dns_zone_template: NetBoxDNSZoneTemplateType = strawberry_django.field()
86
+ @strawberry.field
87
+ def netbox_dns_zone_template(self, id: int) -> NetBoxDNSZoneTemplateType:
88
+ return ZoneTemplate.objects.get(pk=id)
89
+
73
90
  netbox_dns_zone_template_list: List[NetBoxDNSZoneTemplateType] = (
74
91
  strawberry_django.field()
75
92
  )
76
93
 
77
94
 
78
- @strawberry.type(name="Query")
95
+ @strawberry.type
79
96
  class NetBoxDNSRecordTemplateQuery:
80
- netbox_dns_record_template: NetBoxDNSRecordTemplateType = strawberry_django.field()
97
+ @strawberry.field
98
+ def netbox_dns_record_template(self, id: int) -> NetBoxDNSRecordTemplateType:
99
+ return RecordTemplate.objects.get(pk=id)
100
+
81
101
  netbox_dns_record_template_list: List[NetBoxDNSRecordTemplateType] = (
82
102
  strawberry_django.field()
83
103
  )
@@ -4,8 +4,6 @@ import strawberry
4
4
  import strawberry_django
5
5
 
6
6
  from netbox.graphql.types import NetBoxObjectType
7
- from tenancy.graphql.types import TenantType
8
- from ipam.graphql.types import IPAddressType, PrefixType
9
7
  from netbox.graphql.scalars import BigInt
10
8
 
11
9
  from netbox_dns.models import (
@@ -13,7 +11,7 @@ from netbox_dns.models import (
13
11
  View,
14
12
  Zone,
15
13
  Record,
16
- RegistrationContact,
14
+ Contact,
17
15
  Registrar,
18
16
  ZoneTemplate,
19
17
  RecordTemplate,
@@ -23,7 +21,7 @@ from .filters import (
23
21
  NetBoxDNSViewFilter,
24
22
  NetBoxDNSZoneFilter,
25
23
  NetBoxDNSRecordFilter,
26
- NetBoxDNSRegistrationContactFilter,
24
+ NetBoxDNSContactFilter,
27
25
  NetBoxDNSRegistrarFilter,
28
26
  NetBoxDNSZoneTemplateFilter,
29
27
  NetBoxDNSRecordTemplateFilter,
@@ -77,31 +75,19 @@ class NetBoxDNSZoneType(NetBoxObjectType):
77
75
  )
78
76
  registry_domain_id: str | None
79
77
  registrant: (
80
- Annotated[
81
- "NetBoxDNSRegistrationContactType",
82
- strawberry.lazy("netbox_dns.graphql.types"),
83
- ]
78
+ Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
84
79
  | None
85
80
  )
86
81
  admin_c: (
87
- Annotated[
88
- "NetBoxDNSRegistrationContactType",
89
- strawberry.lazy("netbox_dns.graphql.types"),
90
- ]
82
+ Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
91
83
  | None
92
84
  )
93
85
  tech_c: (
94
- Annotated[
95
- "NetBoxDNSRegistrationContactType",
96
- strawberry.lazy("netbox_dns.graphql.types"),
97
- ]
86
+ Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
98
87
  | None
99
88
  )
100
89
  billing_c: (
101
- Annotated[
102
- "NetBoxDNSRegistrationContactType",
103
- strawberry.lazy("netbox_dns.graphql.types"),
104
- ]
90
+ Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
105
91
  | None
106
92
  )
107
93
  rfc2317_prefix: str | None
@@ -138,10 +124,8 @@ class NetBoxDNSRecordType(NetBoxObjectType):
138
124
  )
139
125
 
140
126
 
141
- @strawberry_django.type(
142
- RegistrationContact, fields="__all__", filters=NetBoxDNSRegistrationContactFilter
143
- )
144
- class NetBoxDNSRegistrationContactType(NetBoxObjectType):
127
+ @strawberry_django.type(Contact, fields="__all__", filters=NetBoxDNSContactFilter)
128
+ class NetBoxDNSContactType(NetBoxObjectType):
145
129
  name: str
146
130
  contact_id: str
147
131
  description: str
@@ -192,31 +176,19 @@ class NetBoxDNSZoneTemplateType(NetBoxObjectType):
192
176
  | None
193
177
  )
194
178
  registrant: (
195
- Annotated[
196
- "NetBoxDNSRegistrationContactType",
197
- strawberry.lazy("netbox_dns.graphql.types"),
198
- ]
179
+ Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
199
180
  | None
200
181
  )
201
182
  admin_c: (
202
- Annotated[
203
- "NetBoxDNSRegistrationContactType",
204
- strawberry.lazy("netbox_dns.graphql.types"),
205
- ]
183
+ Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
206
184
  | None
207
185
  )
208
186
  tech_c: (
209
- Annotated[
210
- "NetBoxDNSRegistrationContactType",
211
- strawberry.lazy("netbox_dns.graphql.types"),
212
- ]
187
+ Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
213
188
  | None
214
189
  )
215
190
  billing_c: (
216
- Annotated[
217
- "NetBoxDNSRegistrationContactType",
218
- strawberry.lazy("netbox_dns.graphql.types"),
219
- ]
191
+ Annotated["NetBoxDNSContactType", strawberry.lazy("netbox_dns.graphql.types")]
220
192
  | None
221
193
  )
222
194