Beispiel #1
0
class PowerOutletType(gql_optimizer.OptimizedDjangoObjectType, CableTerminationMixin, PathEndpointMixin):
    """Graphql Type Object for PowerOutlet model."""

    class Meta:
        model = PowerOutlet
        filterset_class = PowerOutletFilterSet

    # Field Definitions
    cable_peer_power_port = graphene.Field("nautobot.dcim.graphql.types.PowerPortType")
    connected_power_port = graphene.Field("nautobot.dcim.graphql.types.PowerPortType")

    # Resolver Definitions
    resolve_cable_peer_power_port = construct_resolver("PowerPort", "cable_peer")
    resolve_connected_power_port = construct_resolver("PowerPort", "connected_endpoint")
Beispiel #2
0
class ConsoleServerPortType(gql_optimizer.OptimizedDjangoObjectType, CableTerminationMixin, PathEndpointMixin):
    """Graphql Type Object for ConsoleServerPort model."""

    class Meta:
        model = ConsoleServerPort
        filterset_class = ConsoleServerPortFilterSet

    # Field Definitions
    cable_peer_console_port = graphene.Field("nautobot.dcim.graphql.types.ConsolePortType")
    cable_peer_front_port = graphene.Field("nautobot.dcim.graphql.types.FrontPortType")
    cable_peer_rear_port = graphene.Field("nautobot.dcim.graphql.types.RearPortType")
    connected_console_port = graphene.Field("nautobot.dcim.graphql.types.ConsolePortType")

    # Resolver Definitions
    resolve_cable_peer_console_port = construct_resolver("ConsolePort", "cable_peer")
    resolve_cable_peer_front_port = construct_resolver("FrontPort", "cable_peer")
    resolve_cable_peer_rear_port = construct_resolver("RearPort", "cable_peer")
    resolve_connected_console_port = construct_resolver("ConsolePort", "connected_endpoint")
Beispiel #3
0
class InterfaceType(gql_optimizer.OptimizedDjangoObjectType, CableTerminationMixin, PathEndpointMixin):
    """Graphql Type Object for Interface model."""

    class Meta:
        model = Interface
        filterset_class = InterfaceFilterSet
        exclude = ["_name"]

    # Field Definitions
    cable_peer_circuit_termination = graphene.Field("nautobot.circuits.graphql.types.CircuitTerminationType")
    cable_peer_front_port = graphene.Field("nautobot.dcim.graphql.types.FrontPortType")
    cable_peer_interface = graphene.Field("nautobot.dcim.graphql.types.InterfaceType")
    cable_peer_rear_port = graphene.Field("nautobot.dcim.graphql.types.RearPortType")
    connected_circuit_termination = graphene.Field("nautobot.circuits.graphql.types.CircuitTerminationType")
    connected_interface = graphene.Field("nautobot.dcim.graphql.types.InterfaceType")
    ip_addresses = graphene.List("nautobot.ipam.graphql.types.IPAddressType")

    # Resolver Definitions
    resolve_cable_peer_circuit_termination = construct_resolver("CircuitTermination", "cable_peer")
    resolve_cable_peer_front_port = construct_resolver("FrontPort", "cable_peer")
    resolve_cable_peer_interface = construct_resolver("Interface", "cable_peer")
    resolve_cable_peer_rear_port = construct_resolver("RearPort", "cable_peer")
    resolve_connected_circuit_termination = construct_resolver("CircuitTermination", "connected_endpoint")
    resolve_connected_interface = construct_resolver("Interface", "connected_endpoint")

    # Interface.ip_addresses is the reverse side of a GenericRelation that cannot be auto-optimized.
    # See: https://github.com/tfoxy/graphene-django-optimizer#advanced-usage
    @gql_optimizer.resolver_hints(
        model_field="ip_addresses",
    )
    def resolve_ip_addresses(self, args):
        return self.ip_addresses.all()
Beispiel #4
0
class CircuitTerminationType(gql_optimizer.OptimizedDjangoObjectType,
                             CableTerminationMixin, PathEndpointMixin):
    """Graphql Type Object for CircuitTermination model."""
    class Meta:
        model = CircuitTermination
        filterset_class = CircuitTerminationFilterSet

    cable_peer_circuit_termination = Field(
        "nautobot.circuits.graphql.types.CircuitTerminationType")
    cable_peer_front_port = Field("nautobot.dcim.graphql.types.FrontPortType")
    cable_peer_interface = Field("nautobot.dcim.graphql.types.InterfaceType")
    cable_peer_rear_port = Field("nautobot.dcim.graphql.types.RearPortType")
    connected_circuit_termination = Field(
        "nautobot.circuits.graphql.types.CircuitTerminationType")
    connected_interface = Field("nautobot.dcim.graphql.types.InterfaceType")

    resolve_cable_peer_circuit_termination = construct_resolver(
        "CircuitTermination", "cable_peer")
    resolve_cable_peer_front_port = construct_resolver("FrontPort",
                                                       "cable_peer")
    resolve_cable_peer_interface = construct_resolver("Interface",
                                                      "cable_peer")
    resolve_cable_rear_port = construct_resolver("RearPort", "cable_peer")
    resolve_connected_circuit_termination = construct_resolver(
        "CircuitTermination", "connected_endpoint")
    resolve_connected_interface = construct_resolver("Interface",
                                                     "connected_endpoint")
Beispiel #5
0
class RearPortType(gql_optimizer.OptimizedDjangoObjectType, CableTerminationMixin):
    """Graphql Type Object for RearPort model."""

    class Meta:
        model = RearPort
        filterset_class = RearPortFilterSet

    # Field Definitions
    cable_peer_circuit_termination = graphene.Field("nautobot.circuits.graphql.types.CircuitTerminationType")
    cable_peer_console_port = graphene.Field("nautobot.dcim.graphql.types.ConsolePortType")
    cable_peer_console_server_port = graphene.Field("nautobot.dcim.graphql.types.ConsoleServerPortType")
    cable_peer_front_port = graphene.Field("nautobot.dcim.graphql.types.FrontPortType")
    cable_peer_rear_port = graphene.Field("nautobot.dcim.graphql.types.RearPortType")
    cable_peer_interface = graphene.Field("nautobot.dcim.graphql.types.InterfaceType")

    # Resolver Definitions
    resolve_cable_peer_circuit_termination = construct_resolver("CircuitTermination", "cable_peer")
    resolve_cable_peer_console_port = construct_resolver("ConsolePort", "cable_peer")
    resolve_cable_peer_console_server_port = construct_resolver("ConsoleServerPort", "cable_peer")
    resolve_cable_peer_front_port = construct_resolver("FrontPort", "cable_peer")
    resolve_cable_peer_interface = construct_resolver("Interface", "cable_peer")
    resolve_cable_peer_rear_port = construct_resolver("RearPort", "cable_peer")