-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from DanSheps/develop
Add GraphQL support
- Loading branch information
Showing
5 changed files
with
66 additions
and
2 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
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,16 @@ | ||
import strawberry_django | ||
|
||
from netbox_routing import filtersets, models | ||
|
||
from netbox.graphql.filter_mixins import autotype_decorator, BaseFilterMixin | ||
|
||
__all__ = ( | ||
'StaticRouteFilter', | ||
) | ||
|
||
|
||
@strawberry_django.filter(models.StaticRoute, lookups=True) | ||
@autotype_decorator(filtersets.StaticRouteFilterSet) | ||
class StaticRouteFilter(BaseFilterMixin): | ||
prefix: str | ||
next_hop: str |
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 StaticRouteQuery: | ||
static_route: StaticRouteType = strawberry_django.field() | ||
static_route_list: List[StaticRouteType] = strawberry_django.field() | ||
|
||
|
||
schema = [ | ||
StaticRouteQuery, | ||
] |
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,30 @@ | ||
from typing import Annotated, List | ||
|
||
import strawberry | ||
import strawberry_django | ||
|
||
from netbox.graphql.types import NetBoxObjectType | ||
from .filters import * | ||
|
||
from netbox_routing import models | ||
|
||
__all__ = ( | ||
'StaticRouteType', | ||
) | ||
|
||
|
||
@strawberry_django.type( | ||
models.StaticRoute, | ||
fields='__all__', | ||
filters=StaticRouteFilter | ||
) | ||
class StaticRouteType(NetBoxObjectType): | ||
|
||
name: str | ||
devices: List[Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')]] | None | ||
vrf: Annotated["VRFType", strawberry.lazy('ipam.graphql.types')] | None | ||
prefix: str | None | ||
next_hop: str | None | ||
metric: int | None | ||
permanent: bool | None | ||
|