Skip to content

Commit

Permalink
feat: param to exclude addtl. fields w/ log_safe_model_dump
Browse files Browse the repository at this point in the history
  • Loading branch information
tazlin committed Jul 7, 2024
1 parent c71fc68 commit 855f2e6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions horde_sdk/generic_api/apimodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,14 @@ def get_extra_fields_to_exclude_from_log(self) -> set[str]:
"""Return an additional set of fields to exclude from the log_safe_model_dump method."""
return set()

def log_safe_model_dump(self) -> dict[Any, Any]:
def log_safe_model_dump(self, extra_exclude: set[str] | None = None) -> dict[Any, Any]:
"""Return a dict of the model's fields, with any sensitive fields redacted."""
return self.model_dump(exclude=self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log())
if extra_exclude is None:
extra_exclude = set()

return self.model_dump(
exclude=self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude,
)


class HordeResponse(HordeAPIMessage):
Expand Down

0 comments on commit 855f2e6

Please sign in to comment.