Skip to content

Nautobot Floor Plan API Package

nautobot_floor_plan.api

REST API module for nautobot_floor_plan app.

serializers

API serializers for nautobot_floor_plan.

FloorPlanSerializer

Bases: NautobotModelSerializer, TaggedModelSerializerMixin

FloorPlan Serializer.

Source code in nautobot_floor_plan/api/serializers.py
class FloorPlanSerializer(NautobotModelSerializer, TaggedModelSerializerMixin):  # pylint: disable=too-many-ancestors
    """FloorPlan Serializer."""

    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, TaggedModelSerializerMixin

FloorPlanTile Serializer.

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

    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 app.

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):  # pylint: disable=too-many-ancestors
    """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")