Journal Serializers
Serializers for the Smarter Journal api.
- class smarter.lib.journal.serializers.SAMJournalMiniSerializer(*args, **kwargs)[source]
Bases:
SmarterCamelCaseSerializerMinimal serializer for the
smarter.lib.journal.models.SAMJournalmodel, without the entry’s request and response documents.It is used to list journal entries, whose documents can be large, and hold user content.
Fields:
key(string): The entry’s primary key.createdAt(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.statusCode(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:
SmarterCamelCaseSerializerSerializer for the
smarter.lib.journal.models.SAMJournalmodel: a complete journal entry.The entry’s
requestandresponsedocuments are included. They hold user content, e.g. prompts and manifests, so this serializer is only used for one entry at a time, by superusers. The request document never holds the caller’s cookies or api key: seeHttpAnonymousRequestSerializer. SeeSAMJournalMiniSerializerfor lists.Fields:
key(string): The entry’s primary key, 64 hexadecimal characters.createdAt(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.statusCode(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