diff --git a/pyobas/apis/inject_expectation/inject_expectation.py b/pyobas/apis/inject_expectation/inject_expectation.py index 54120e9..bbd1288 100644 --- a/pyobas/apis/inject_expectation/inject_expectation.py +++ b/pyobas/apis/inject_expectation/inject_expectation.py @@ -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 + ) diff --git a/pyobas/apis/inject_expectation_trace.py b/pyobas/apis/inject_expectation_trace.py index ea71166..125fd9c 100644 --- a/pyobas/apis/inject_expectation_trace.py +++ b/pyobas/apis/inject_expectation_trace.py @@ -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 @@ -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 diff --git a/pyobas/utils.py b/pyobas/utils.py index 2f51b82..242ae68 100644 --- a/pyobas/utils.py +++ b/pyobas/utils.py @@ -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()