Journal Serializers

Serializers for the Smarter Journal api.

class smarter.lib.journal.serializers.SAMJournalMiniSerializer(*args, **kwargs)[source]

Bases: SmarterCamelCaseSerializer

Minimal serializer for the smarter.lib.journal.models.SAMJournal model, without the entry’s request and response documents.

It is used to list journal entries, which can be large, and whose documents hold credentials.

Parameters:
  • key – String. The entry’s primary key.

  • created_at – DateTime. When the entry was written.

  • user – String. The username of the user who made the request, or null for an anonymous request.

  • thing – String. The kind of resource, e.g. Guardrail.

  • command – String. The command, e.g. apply.

  • status_code – Integer. The response’s http status.

Example usage:

from smarter.lib.journal.serializers import SAMJournalMiniSerializer
data = SAMJournalMiniSerializer(journals, many=True).data
class smarter.lib.journal.serializers.SAMJournalSerializer(*args, **kwargs)[source]

Bases: SmarterCamelCaseSerializer

Serializer for the smarter.lib.journal.models.SAMJournal model: a complete journal entry.

The entry’s request and response documents are included. The request document holds the caller’s headers and cookies, including its api key, so this serializer is only used for one entry at a time, by superusers. See SAMJournalMiniSerializer for lists.

Parameters:
  • key – String. The entry’s primary key, 64 hexadecimal characters.

  • created_at – DateTime. When the entry was written.

  • user – String. The username of the user who made the request, or null for an anonymous request.

  • thing – String. The kind of resource, e.g. Guardrail.

  • command – String. The command, e.g. apply.

  • request – JSON. The serialized http request.

  • response – JSON. The response’s JSON body.

  • status_code – Integer. The response’s http status.

Note

All fields are read-only. Smarter never changes a journal entry.

Example usage:

from smarter.lib.journal.serializers import SAMJournalSerializer
data = SAMJournalSerializer(journal).data