Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pyobas/apis/inject_expectation/inject_expectation.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,14 @@ def update(
path = f"{self.path}/{inject_expectation_id}"
result = self.openbas.http_put(path, post_data=inject_expectation, **kwargs)
return result

@exc.on_http_error(exc.OpenBASUpdateError)
def bulk_update(
self,
inject_expectation_input_by_id: Dict[str, Dict[str, Any]],
**kwargs: Any,
) -> None:
path = f"{self.path}/bulk"
self.openbas.http_put(
path, post_data={"inputs": inject_expectation_input_by_id}, **kwargs
)
15 changes: 15 additions & 0 deletions pyobas/apis/inject_expectation_trace.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from typing import Any, Dict, List

from pyobas import exceptions as exc
from pyobas.base import RESTManager, RESTObject
from pyobas.mixins import CreateMixin
from pyobas.utils import RequiredOptional
Expand All @@ -19,3 +22,15 @@ class InjectExpectationTraceManager(CreateMixin, RESTManager):
"inject_expectation_trace_date",
),
)

@exc.on_http_error(exc.OpenBASUpdateError)
def bulk_create(
self, payload: Dict[str, List[Dict[str, str]]], **kwargs: Any
) -> dict[str, Any]:
path = f"{self.path}/bulk"
result = self.openbas.http_post(
path,
post_data=payload,
**kwargs,
)
return result
2 changes: 1 addition & 1 deletion pyobas/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def add_fields(self, log_record, record, message_dict):
super(CustomJsonFormatter, self).add_fields(log_record, record, message_dict)
if not log_record.get("timestamp"):
# This doesn't use record.created, so it is slightly off
now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ")
now = datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
log_record["timestamp"] = now
if log_record.get("level"):
log_record["level"] = log_record["level"].upper()
Expand Down