SAMJournal
- class smarter.lib.journal.models.SAMJournal(*args, **kwargs)[source]
Bases:
ModelModel representing a journal entry for changes made to the SAM database.
This model is used to maintain a comprehensive log of all modifications performed on the SAM database, whether those changes are initiated via the API (
api/v1) or through CLI manifests. Each journal entry records the details of the operation, including the user responsible, the type of entity affected, the command executed, the request and response payloads, and the resulting status code.Examples
Creating a new journal entry:
entry = SAMJournal( user=request.user, thing=SmarterJournalThings.CHAT.value, command=SmarterJournalCliCommands.CREATE.value, request={"data": "example"}, response={"result": "success"}, status_code=201 ) entry.save()
See also
- smarter.common.utils.hash_factory
Utility function used to generate unique keys for journal entries.
- smarter.lib.journal.enum.SmarterJournalCliCommands
Enumeration of valid CLI commands for journal entries.
- smarter.lib.journal.enum.SmarterJournalThings
Enumeration of valid entity types for journal entries.
- param key:
Primary key: Key
- type key:
Unknown
- param created_at:
Created at
- type created_at:
Unknown
- param thing:
Thing
- type thing:
Unknown
- param command:
Command
- type command:
Unknown
- param request:
Request
- type request:
Unknown
- param response:
Response
- type response:
Unknown
- param status_code:
Status code
- type status_code:
Unknown
Relationship fields:
- param user:
User (related name:
samjournal)- type user:
ForeignKeytoUser
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- exception NotUpdated
Bases:
ObjectNotUpdated,DatabaseError
- command
-
Command
Choices:
applychatchat_configdeletedeploydescribegetjournallogsexample_manifestand 5 more
- Type:
Type
- created_at
-
Created at
- Type:
Type
- get_command_display(*, field=<django.db.models.CharField: command>)
Shows the label of the
command. Seeget_FOO_display()for more information.
- get_thing_display(*, field=<django.db.models.CharField: thing>)
Shows the label of the
thing. Seeget_FOO_display()for more information.
- objects = <django.db.models.Manager object>
- save(*args, **kwargs)[source]
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- status_code
-
Status code
- Type:
Type
- thing
-
Thing
Choices:
PluginApiPluginSqlPluginApiConnectionSqlConnectionAccountSmarterAuthTokenUserChatChatConfigand 7 more
- Type:
Type
- user
ForeignKeytoUserUser (related name:
samjournal)- Type:
Type