Skip to content

Nautobot Design Builder API Package

nautobot_design_builder.api

REST API module for nautobot_design_builder app.

serializers

Serializers for design builder.

ChangeRecordSerializer

Bases: NautobotModelSerializer

Serializer for the change record model.

Source code in nautobot_design_builder/api/serializers.py
class ChangeRecordSerializer(NautobotModelSerializer):
    """Serializer for the change record model."""

    _design_object_type = ContentTypeField(queryset=ContentType.objects.all(), label="design_object_type")
    design_object = SerializerMethodField(read_only=True)

    class Meta:
        """Serializer options for the change record  model."""

        model = ChangeRecord
        fields = "__all__"

    @extend_schema_field(DictField())
    def get_design_object(self, obj):
        """Get design object serialized."""
        if obj.design_object:
            serializer = get_serializer_for_model(obj.design_object)
            context = {"request": self.context["request"]}
            return serializer(obj.design_object, context=context).data
        return None
Meta

Serializer options for the change record model.

Source code in nautobot_design_builder/api/serializers.py
class Meta:
    """Serializer options for the change record  model."""

    model = ChangeRecord
    fields = "__all__"
get_design_object(obj)

Get design object serialized.

Source code in nautobot_design_builder/api/serializers.py
@extend_schema_field(DictField())
def get_design_object(self, obj):
    """Get design object serialized."""
    if obj.design_object:
        serializer = get_serializer_for_model(obj.design_object)
        context = {"request": self.context["request"]}
        return serializer(obj.design_object, context=context).data
    return None

ChangeSetSerializer

Bases: NautobotModelSerializer, TaggedModelSerializerMixin

Serializer for the change set model.

Source code in nautobot_design_builder/api/serializers.py
class ChangeSetSerializer(NautobotModelSerializer, TaggedModelSerializerMixin):
    """Serializer for the change set model."""

    class Meta:
        """Serializer options for the change set model."""

        model = ChangeSet
        fields = "__all__"
Meta

Serializer options for the change set model.

Source code in nautobot_design_builder/api/serializers.py
class Meta:
    """Serializer options for the change set model."""

    model = ChangeSet
    fields = "__all__"

DeploymentSerializer

Bases: NautobotModelSerializer, TaggedModelSerializerMixin

Serializer for the Deployment model.

Source code in nautobot_design_builder/api/serializers.py
class DeploymentSerializer(NautobotModelSerializer, TaggedModelSerializerMixin):
    """Serializer for the Deployment model."""

    created_by = SerializerMethodField()
    last_updated_by = SerializerMethodField()

    class Meta:
        """Serializer options for the design model."""

        model = Deployment
        fields = "__all__"

    def get_created_by(self, instance):
        """Get the username of the user who created the object."""
        return instance.created_by

    def get_last_updated_by(self, instance):
        """Get the username of the user who update the object last time."""
        return instance.last_updated_by
Meta

Serializer options for the design model.

Source code in nautobot_design_builder/api/serializers.py
class Meta:
    """Serializer options for the design model."""

    model = Deployment
    fields = "__all__"
get_created_by(instance)

Get the username of the user who created the object.

Source code in nautobot_design_builder/api/serializers.py
def get_created_by(self, instance):
    """Get the username of the user who created the object."""
    return instance.created_by
get_last_updated_by(instance)

Get the username of the user who update the object last time.

Source code in nautobot_design_builder/api/serializers.py
def get_last_updated_by(self, instance):
    """Get the username of the user who update the object last time."""
    return instance.last_updated_by

DesignSerializer

Bases: NautobotModelSerializer, TaggedModelSerializerMixin

Serializer for the design model.

Source code in nautobot_design_builder/api/serializers.py
class DesignSerializer(NautobotModelSerializer, TaggedModelSerializerMixin):
    """Serializer for the design model."""

    name = ReadOnlyField()

    class Meta:
        """Serializer options for the design model."""

        model = Design
        fields = "__all__"
Meta

Serializer options for the design model.

Source code in nautobot_design_builder/api/serializers.py
class Meta:
    """Serializer options for the design model."""

    model = Design
    fields = "__all__"

urls

API URLs for design builder.

views

UI Views for design builder.

ChangeRecordAPIViewSet

Bases: NautobotModelViewSet

API views for the change record model.

Source code in nautobot_design_builder/api/views.py
class ChangeRecordAPIViewSet(NautobotModelViewSet):
    """API views for the change record model."""

    queryset = ChangeRecord.objects.all()
    serializer_class = ChangeRecordSerializer
    filterset_class = ChangeRecordFilterSet

ChangeSetAPIViewSet

Bases: NautobotModelViewSet

API views for the change set model.

Source code in nautobot_design_builder/api/views.py
class ChangeSetAPIViewSet(NautobotModelViewSet):
    """API views for the change set model."""

    queryset = ChangeSet.objects.all()
    serializer_class = ChangeSetSerializer
    filterset_class = ChangeSetFilterSet

DeploymentAPIViewSet

Bases: NautobotModelViewSet

API views for the design instance model.

Source code in nautobot_design_builder/api/views.py
class DeploymentAPIViewSet(NautobotModelViewSet):
    """API views for the design instance model."""

    queryset = Deployment.objects.all()
    serializer_class = DeploymentSerializer
    filterset_class = DeploymentFilterSet

DesignAPIViewSet

Bases: NautobotModelViewSet

API views for the design model.

Source code in nautobot_design_builder/api/views.py
class DesignAPIViewSet(NautobotModelViewSet):
    """API views for the design model."""

    queryset = Design.objects.all()
    serializer_class = DesignSerializer
    filterset_class = DesignFilterSet