Skip to content

Nautobot Floor Plan API Package

nautobot_floor_plan.api

REST API module for nautobot_floor_plan plugin.

nested_serializers

API nested serializers for nautobot_floor_plan.

NestedFloorPlanSerializer

Bases: WritableNestedSerializer

FloorPlan Nested Serializer.

Source code in nautobot_floor_plan/api/nested_serializers.py
class NestedFloorPlanSerializer(WritableNestedSerializer):
    """FloorPlan Nested Serializer."""

    url = serializers.HyperlinkedIdentityField(view_name="plugins-api:nautobot_floor_plan-api:floorplan-detail")

    class Meta:
        """Meta attributes."""

        model = models.FloorPlan
        fields = ["id", "url", "x_size", "y_size"]
Meta

Meta attributes.

Source code in nautobot_floor_plan/api/nested_serializers.py
class Meta:
    """Meta attributes."""

    model = models.FloorPlan
    fields = ["id", "url", "x_size", "y_size"]

NestedFloorPlanTileSerializer

Bases: WritableNestedSerializer

FloorPlanTile Nested Serializer.

Source code in nautobot_floor_plan/api/nested_serializers.py
class NestedFloorPlanTileSerializer(WritableNestedSerializer):
    """FloorPlanTile Nested Serializer."""

    url = serializers.HyperlinkedIdentityField(view_name="plugins-api:nautobot_floor_plan-api:floorplantile-detail")

    class Meta:
        """Meta attributes."""

        model = models.FloorPlanTile
        fields = ["id", "url", "x_origin", "y_origin", "x_size", "y_size"]
Meta

Meta attributes.

Source code in nautobot_floor_plan/api/nested_serializers.py
class Meta:
    """Meta attributes."""

    model = models.FloorPlanTile
    fields = ["id", "url", "x_origin", "y_origin", "x_size", "y_size"]

serializers

API serializers for nautobot_floor_plan.

FloorPlanSerializer

Bases: NautobotModelSerializer, TaggedObjectSerializer

FloorPlan Serializer.

Source code in nautobot_floor_plan/api/serializers.py
class FloorPlanSerializer(NautobotModelSerializer, TaggedObjectSerializer):
    """FloorPlan Serializer."""

    url = serializers.HyperlinkedIdentityField(view_name="plugins-api:nautobot_floor_plan-api:floorplan-detail")
    location = NestedLocationSerializer()

    class Meta:
        """Meta attributes."""

        model = models.FloorPlan
        fields = "__all__"
Meta

Meta attributes.

Source code in nautobot_floor_plan/api/serializers.py
class Meta:
    """Meta attributes."""

    model = models.FloorPlan
    fields = "__all__"

FloorPlanTileSerializer

Bases: NautobotModelSerializer, StatusModelSerializerMixin, TaggedObjectSerializer

FloorPlanTile Serializer.

Source code in nautobot_floor_plan/api/serializers.py
class FloorPlanTileSerializer(NautobotModelSerializer, StatusModelSerializerMixin, TaggedObjectSerializer):
    """FloorPlanTile Serializer."""

    url = serializers.HyperlinkedIdentityField(view_name="plugins-api:nautobot_floor_plan-api:floorplantile-detail")
    floor_plan = NestedFloorPlanSerializer()  # noqa: F405
    rack = NestedRackSerializer(required=False)

    class Meta:
        """Meta attributes."""

        model = models.FloorPlanTile
        fields = "__all__"
Meta

Meta attributes.

Source code in nautobot_floor_plan/api/serializers.py
class Meta:
    """Meta attributes."""

    model = models.FloorPlanTile
    fields = "__all__"

urls

Django API urlpatterns declaration for nautobot_floor_plan plugin.

views

API views for nautobot_floor_plan.

FloorPlanTileViewSet

Bases: NautobotModelViewSet

FloorPlanTile viewset.

Source code in nautobot_floor_plan/api/views.py
class FloorPlanTileViewSet(NautobotModelViewSet):
    """FloorPlanTile viewset."""

    queryset = models.FloorPlanTile.objects.all()
    serializer_class = serializers.FloorPlanTileSerializer
    filterset_class = filters.FloorPlanTileFilterSet

FloorPlanViewSet

Bases: NautobotModelViewSet

FloorPlan viewset.

Source code in nautobot_floor_plan/api/views.py
class FloorPlanViewSet(NautobotModelViewSet):
    """FloorPlan viewset."""

    queryset = models.FloorPlan.objects.all()
    serializer_class = serializers.FloorPlanSerializer
    filterset_class = filters.FloorPlanFilterSet

    @extend_schema(exclude=True)
    @action(detail=True)
    @xframe_options_sameorigin
    def svg(self, request, *, pk):
        """SVG representation of a FloorPlan."""
        floor_plan = get_object_or_404(self.queryset, pk=pk)
        drawing = floor_plan.get_svg(user=request.user, base_url=request.build_absolute_uri("/"))
        return HttpResponse(drawing.tostring(), content_type="image/svg+xml; charset=utf-8")
svg(request, *, pk)

SVG representation of a FloorPlan.

Source code in nautobot_floor_plan/api/views.py
@extend_schema(exclude=True)
@action(detail=True)
@xframe_options_sameorigin
def svg(self, request, *, pk):
    """SVG representation of a FloorPlan."""
    floor_plan = get_object_or_404(self.queryset, pk=pk)
    drawing = floor_plan.get_svg(user=request.user, base_url=request.build_absolute_uri("/"))
    return HttpResponse(drawing.tostring(), content_type="image/svg+xml; charset=utf-8")