-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade model to PrimaryModel, add GraphQL support
- Loading branch information
Showing
12 changed files
with
147 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import strawberry_django | ||
from netbox_config_backup import filtersets, models | ||
|
||
from netbox.graphql.filter_mixins import autotype_decorator, BaseFilterMixin | ||
|
||
__all__ = ( | ||
'BackupFilter', | ||
) | ||
|
||
|
||
@strawberry_django.filter(models.Backup, lookups=True) | ||
@autotype_decorator(filtersets.BackupFilterSet) | ||
class BackupFilter(BaseFilterMixin): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import List | ||
|
||
import strawberry | ||
import strawberry_django | ||
|
||
from .types import * | ||
|
||
|
||
@strawberry.type(name="Query") | ||
class BackupQuery: | ||
backup: BackupType = strawberry_django.field() | ||
backup_list: List[BackupType] = strawberry_django.field() | ||
|
||
|
||
schema = [ | ||
BackupQuery, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import Annotated | ||
|
||
import strawberry | ||
import strawberry_django | ||
|
||
from netbox.graphql.types import NetBoxObjectType | ||
from .filters import * | ||
|
||
from netbox_config_backup import models | ||
|
||
__all__ = ( | ||
'BackupType', | ||
) | ||
|
||
|
||
@strawberry_django.type( | ||
models.Backup, | ||
fields='__all__', | ||
filters=BackupFilter | ||
) | ||
class BackupType(NetBoxObjectType): | ||
|
||
name: str | ||
device: Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')] | None | ||
ip: Annotated["IPAddressType", strawberry.lazy('ipam.graphql.types')] | None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
from django.urls import path | ||
|
||
from netbox.views.generic import ObjectChangeLogView | ||
from . import views | ||
from .models import Backup | ||
|
||
urlpatterns = [ | ||
path('unassigned/', views.UnassignedBackupListView.as_view(), name='unassignedbackup_list'), | ||
path('devices/', views.BackupListView.as_view(), name='backup_list'), | ||
path('devices/add/', views.BackupEditView.as_view(), name='backup_add'), | ||
path('devices/<int:pk>/', views.BackupView.as_view(), name='backup'), | ||
path('devices/<int:pk>/changelog', ObjectChangeLogView.as_view(), name="backup_changelog", kwargs={'model': Backup}), | ||
path('devices/<int:pk>/edit/', views.BackupEditView.as_view(), name='backup_edit'), | ||
path('devices/<int:pk>/delete/', views.BackupDeleteView.as_view(), name='backup_delete'), | ||
path('devices/<int:pk>/backups/', views.BackupBackupsView.as_view(), name='backup_backups'), | ||
path('devices/<int:backup>/config/', views.ConfigView.as_view(), name='backup_config'), | ||
path('devices/<int:backup>/config/<int:current>/', views.ConfigView.as_view(), name='backup_config'), | ||
path('devices/<int:backup>/diff/', views.DiffView.as_view(), name='backup_diff'), | ||
path('devices/<int:backup>/diff/<int:current>/', views.DiffView.as_view(), name='backup_diff'), | ||
path('devices/edit/', views.BackupBulkEditView.as_view(), name='backup_bulk_edit'), | ||
path('devices/delete/', views.BackupBulkDeleteView.as_view(), name='backup_bulk_delete'), | ||
path('devices/<int:backup>/diff/<int:current>/<int:previous>/', views.DiffView.as_view(), name='backup_diff'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters