2022-10-06 13:50:53 -07:00
|
|
|
import graphene
|
2024-01-24 14:22:35 -08:00
|
|
|
from circuits.graphql.types import CircuitTerminationType, ProviderNetworkType
|
|
|
|
from circuits.models import CircuitTermination, ProviderNetwork
|
2022-10-06 13:50:53 -07:00
|
|
|
from dcim.graphql.types import (
|
2022-10-11 09:26:18 -07:00
|
|
|
ConsolePortTemplateType,
|
2022-10-06 13:50:53 -07:00
|
|
|
ConsolePortType,
|
2022-10-11 09:26:18 -07:00
|
|
|
ConsoleServerPortTemplateType,
|
2022-10-06 13:50:53 -07:00
|
|
|
ConsoleServerPortType,
|
2022-10-11 09:26:18 -07:00
|
|
|
FrontPortTemplateType,
|
2022-10-06 13:50:53 -07:00
|
|
|
FrontPortType,
|
2022-10-11 09:26:18 -07:00
|
|
|
InterfaceTemplateType,
|
2022-10-06 13:50:53 -07:00
|
|
|
InterfaceType,
|
|
|
|
PowerFeedType,
|
2022-10-11 09:26:18 -07:00
|
|
|
PowerOutletTemplateType,
|
2022-10-06 13:50:53 -07:00
|
|
|
PowerOutletType,
|
2022-10-11 09:26:18 -07:00
|
|
|
PowerPortTemplateType,
|
2022-10-06 13:50:53 -07:00
|
|
|
PowerPortType,
|
2022-10-11 09:26:18 -07:00
|
|
|
RearPortTemplateType,
|
2022-10-06 13:50:53 -07:00
|
|
|
RearPortType,
|
|
|
|
)
|
|
|
|
from dcim.models import (
|
|
|
|
ConsolePort,
|
2022-10-11 09:26:18 -07:00
|
|
|
ConsolePortTemplate,
|
2022-10-06 13:50:53 -07:00
|
|
|
ConsoleServerPort,
|
2022-10-11 09:26:18 -07:00
|
|
|
ConsoleServerPortTemplate,
|
2022-10-06 13:50:53 -07:00
|
|
|
FrontPort,
|
2022-10-11 09:26:18 -07:00
|
|
|
FrontPortTemplate,
|
2022-10-06 13:50:53 -07:00
|
|
|
Interface,
|
2022-10-11 09:26:18 -07:00
|
|
|
InterfaceTemplate,
|
2022-10-06 13:50:53 -07:00
|
|
|
PowerFeed,
|
|
|
|
PowerOutlet,
|
2022-10-11 09:26:18 -07:00
|
|
|
PowerOutletTemplate,
|
2022-10-06 13:50:53 -07:00
|
|
|
PowerPort,
|
2022-10-11 09:26:18 -07:00
|
|
|
PowerPortTemplate,
|
2022-10-06 13:50:53 -07:00
|
|
|
RearPort,
|
2022-10-11 09:26:18 -07:00
|
|
|
RearPortTemplate,
|
2022-10-06 13:50:53 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class LinkPeerType(graphene.Union):
|
|
|
|
class Meta:
|
|
|
|
types = (
|
|
|
|
CircuitTerminationType,
|
|
|
|
ConsolePortType,
|
|
|
|
ConsoleServerPortType,
|
|
|
|
FrontPortType,
|
|
|
|
InterfaceType,
|
|
|
|
PowerFeedType,
|
|
|
|
PowerOutletType,
|
|
|
|
PowerPortType,
|
|
|
|
RearPortType,
|
|
|
|
)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def resolve_type(cls, instance, info):
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is CircuitTermination:
|
2022-10-06 13:50:53 -07:00
|
|
|
return CircuitTerminationType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is ConsolePortType:
|
2022-10-06 13:50:53 -07:00
|
|
|
return ConsolePortType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is ConsoleServerPort:
|
2022-10-06 13:50:53 -07:00
|
|
|
return ConsoleServerPortType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is FrontPort:
|
2022-10-06 13:50:53 -07:00
|
|
|
return FrontPortType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is Interface:
|
2022-10-06 13:50:53 -07:00
|
|
|
return InterfaceType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is PowerFeed:
|
2022-10-06 13:50:53 -07:00
|
|
|
return PowerFeedType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is PowerOutlet:
|
2022-10-06 13:50:53 -07:00
|
|
|
return PowerOutletType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is PowerPort:
|
2022-10-06 13:50:53 -07:00
|
|
|
return PowerPortType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is RearPort:
|
2022-10-06 13:50:53 -07:00
|
|
|
return RearPortType
|
2022-10-11 09:26:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
class CableTerminationTerminationType(graphene.Union):
|
|
|
|
class Meta:
|
|
|
|
types = (
|
|
|
|
CircuitTerminationType,
|
|
|
|
ConsolePortType,
|
|
|
|
ConsoleServerPortType,
|
|
|
|
FrontPortType,
|
|
|
|
InterfaceType,
|
|
|
|
PowerFeedType,
|
|
|
|
PowerOutletType,
|
|
|
|
PowerPortType,
|
|
|
|
RearPortType,
|
|
|
|
)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def resolve_type(cls, instance, info):
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is CircuitTermination:
|
2022-10-11 09:26:18 -07:00
|
|
|
return CircuitTerminationType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is ConsolePortType:
|
2022-10-11 09:26:18 -07:00
|
|
|
return ConsolePortType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is ConsoleServerPort:
|
2022-10-11 09:26:18 -07:00
|
|
|
return ConsoleServerPortType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is FrontPort:
|
2022-10-11 09:26:18 -07:00
|
|
|
return FrontPortType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is Interface:
|
2022-10-11 09:26:18 -07:00
|
|
|
return InterfaceType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is PowerFeed:
|
2022-10-11 09:26:18 -07:00
|
|
|
return PowerFeedType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is PowerOutlet:
|
2022-10-11 09:26:18 -07:00
|
|
|
return PowerOutletType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is PowerPort:
|
2022-10-11 09:26:18 -07:00
|
|
|
return PowerPortType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is RearPort:
|
2022-10-11 09:26:18 -07:00
|
|
|
return RearPortType
|
|
|
|
|
|
|
|
|
|
|
|
class InventoryItemTemplateComponentType(graphene.Union):
|
|
|
|
class Meta:
|
|
|
|
types = (
|
|
|
|
ConsolePortTemplateType,
|
|
|
|
ConsoleServerPortTemplateType,
|
|
|
|
FrontPortTemplateType,
|
|
|
|
InterfaceTemplateType,
|
|
|
|
PowerOutletTemplateType,
|
|
|
|
PowerPortTemplateType,
|
|
|
|
RearPortTemplateType,
|
|
|
|
)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def resolve_type(cls, instance, info):
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is ConsolePortTemplate:
|
2022-10-11 09:26:18 -07:00
|
|
|
return ConsolePortTemplateType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is ConsoleServerPortTemplate:
|
2022-10-11 09:26:18 -07:00
|
|
|
return ConsoleServerPortTemplateType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is FrontPortTemplate:
|
2022-10-11 09:26:18 -07:00
|
|
|
return FrontPortTemplateType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is InterfaceTemplate:
|
2022-10-11 09:26:18 -07:00
|
|
|
return InterfaceTemplateType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is PowerOutletTemplate:
|
2022-10-11 09:26:18 -07:00
|
|
|
return PowerOutletTemplateType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is PowerPortTemplate:
|
2022-10-11 09:26:18 -07:00
|
|
|
return PowerPortTemplateType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is RearPortTemplate:
|
2022-10-11 09:26:18 -07:00
|
|
|
return RearPortTemplateType
|
|
|
|
|
|
|
|
|
|
|
|
class InventoryItemComponentType(graphene.Union):
|
|
|
|
class Meta:
|
|
|
|
types = (
|
|
|
|
ConsolePortType,
|
|
|
|
ConsoleServerPortType,
|
|
|
|
FrontPortType,
|
|
|
|
InterfaceType,
|
|
|
|
PowerOutletType,
|
|
|
|
PowerPortType,
|
|
|
|
RearPortType,
|
|
|
|
)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def resolve_type(cls, instance, info):
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is ConsolePort:
|
2022-10-11 09:26:18 -07:00
|
|
|
return ConsolePortType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is ConsoleServerPort:
|
2022-10-11 09:26:18 -07:00
|
|
|
return ConsoleServerPortType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is FrontPort:
|
2022-10-11 09:26:18 -07:00
|
|
|
return FrontPortType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is Interface:
|
2022-10-11 09:26:18 -07:00
|
|
|
return InterfaceType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is PowerOutlet:
|
2022-10-11 09:26:18 -07:00
|
|
|
return PowerOutletType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is PowerPort:
|
2022-10-11 09:26:18 -07:00
|
|
|
return PowerPortType
|
2023-07-30 13:34:08 -04:00
|
|
|
if type(instance) is RearPort:
|
2022-10-11 09:26:18 -07:00
|
|
|
return RearPortType
|
2024-01-24 14:22:35 -08:00
|
|
|
|
|
|
|
|
|
|
|
class ConnectedEndpointType(graphene.Union):
|
|
|
|
class Meta:
|
|
|
|
types = (
|
|
|
|
CircuitTerminationType,
|
|
|
|
ConsolePortType,
|
|
|
|
ConsoleServerPortType,
|
|
|
|
FrontPortType,
|
|
|
|
InterfaceType,
|
|
|
|
PowerFeedType,
|
|
|
|
PowerOutletType,
|
|
|
|
PowerPortType,
|
|
|
|
ProviderNetworkType,
|
|
|
|
RearPortType,
|
|
|
|
)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def resolve_type(cls, instance, info):
|
|
|
|
if type(instance) is CircuitTermination:
|
|
|
|
return CircuitTerminationType
|
|
|
|
if type(instance) is ConsolePortType:
|
|
|
|
return ConsolePortType
|
|
|
|
if type(instance) is ConsoleServerPort:
|
|
|
|
return ConsoleServerPortType
|
|
|
|
if type(instance) is FrontPort:
|
|
|
|
return FrontPortType
|
|
|
|
if type(instance) is Interface:
|
|
|
|
return InterfaceType
|
|
|
|
if type(instance) is PowerFeed:
|
|
|
|
return PowerFeedType
|
|
|
|
if type(instance) is PowerOutlet:
|
|
|
|
return PowerOutletType
|
|
|
|
if type(instance) is PowerPort:
|
|
|
|
return PowerPortType
|
|
|
|
if type(instance) is ProviderNetwork:
|
|
|
|
return ProviderNetworkType
|
|
|
|
if type(instance) is RearPort:
|
|
|
|
return RearPortType
|