How to use the ara.api.serializers function in ara

To help you get started, we’ve selected a few ara examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ansible-community / ara / ara / api / views.py View on Github external
def get_serializer_class(self):
        if self.action == "list":
            return serializers.ListTaskSerializer
        elif self.action == "retrieve":
            return serializers.DetailedTaskSerializer
        else:
            # create/update/destroy
            return serializers.TaskSerializer
github ansible-community / ara / ara / api / views.py View on Github external
def get_serializer_class(self):
        if self.action == "list":
            return serializers.ListLabelSerializer
        elif self.action == "retrieve":
            return serializers.DetailedLabelSerializer
        else:
            # create/update/destroy
            return serializers.LabelSerializer
github ansible-community / ara / ara / api / views.py View on Github external
def get_serializer_class(self):
        if self.action == "list":
            return serializers.ListHostSerializer
        elif self.action == "retrieve":
            return serializers.DetailedHostSerializer
        else:
            # create/update/destroy
            return serializers.HostSerializer
github ansible-community / ara / ara / api / views.py View on Github external
def get_serializer_class(self):
        if self.action == "list":
            return serializers.ListPlaySerializer
        elif self.action == "retrieve":
            return serializers.DetailedPlaySerializer
        else:
            # create/update/destroy
            return serializers.PlaySerializer
github ansible-community / ara / ara / ui / views.py View on Github external
def get(self, request, *args, **kwargs):
        # Results can contain a wide array of non-ascii or binary characters, escape them
        codecs.register_error("strict", codecs.lookup_error("surrogateescape"))
        result = self.get_object()
        serializer = serializers.DetailedResultSerializer(result)
        return Response({"result": serializer.data})
github ansible-community / ara / ara / api / views.py View on Github external
def get_serializer_class(self):
        if self.action == "list":
            return serializers.ListFileSerializer
        elif self.action == "retrieve":
            return serializers.DetailedFileSerializer
        else:
            # create/update/destroy
            return serializers.FileSerializer
github ansible-community / ara / ara / ui / management / commands / generate.py View on Github external
def handle(self, *args, **options):
        path = options.get("path")
        self.create_dirs(path)

        # TODO: Leverage ui views directly instead of duplicating logic here
        query = models.Playbook.objects.all()
        serializer = serializers.ListPlaybookSerializer(query.all(), many=True)

        print("[ara] Generating static files for %s playbooks at %s..." % (query.count(), path))

        # Index
        destination = os.path.join(path, "index.html")
        data = {"playbooks": serializer.data, "static_generation": True, "page": "index"}
        self.render("index.html", destination, **data)

        # Escape surrogates to prevent UnicodeEncodeError exceptions
        codecs.register_error("strict", codecs.lookup_error("surrogateescape"))

        # Playbooks
        for playbook in query.all():
            destination = os.path.join(path, "playbook/%s.html" % playbook.id)
            serializer = serializers.DetailedPlaybookSerializer(playbook)
            data = {"playbook": serializer.data, "static_generation": True}
github ansible-community / ara / ara / api / views.py View on Github external
def get_serializer_class(self):
        if self.action == "list":
            return serializers.ListResultSerializer
        elif self.action == "retrieve":
            return serializers.DetailedResultSerializer
        else:
            # create/update/destroy
            return serializers.ResultSerializer
github ansible-community / ara / ara / ui / views.py View on Github external
def get(self, request, *args, **kwargs):
        host = self.get_object()
        serializer = serializers.DetailedHostSerializer(host)
        return Response({"host": serializer.data})
github ansible-community / ara / ara / api / views.py View on Github external
def get_serializer_class(self):
        if self.action == "list":
            return serializers.ListPlaybookSerializer
        elif self.action == "retrieve":
            return serializers.DetailedPlaybookSerializer
        else:
            # create/update/destroy
            return serializers.PlaybookSerializer