|
3 | 3 | from pyobas import exceptions as exc
|
4 | 4 | from pyobas.base import RESTManager, RESTObject
|
5 | 5 | from pyobas.mixins import ListMixin, UpdateMixin
|
| 6 | +from pyobas.utils import RequiredOptional |
6 | 7 |
|
7 | 8 |
|
8 | 9 | class InjectExpectation(RESTObject):
|
9 |
| - pass |
| 10 | + _id_attr = "inject_expectation_id" |
10 | 11 |
|
11 | 12 |
|
12 | 13 | class InjectExpectationManager(ListMixin, UpdateMixin, RESTManager):
|
13 | 14 | _path = "/injects/expectations"
|
14 | 15 | _obj_cls = InjectExpectation
|
| 16 | + _update_attrs = RequiredOptional(required=("collector_id", "result", "is_success")) |
15 | 17 |
|
16 | 18 | @exc.on_http_error(exc.OpenBASUpdateError)
|
17 | 19 | def expectations_for_source(self, source_id: str, **kwargs: Any) -> Dict[str, Any]:
|
18 | 20 | path = f"{self.path}/" + source_id
|
19 | 21 | result = self.openbas.http_get(path, **kwargs)
|
20 | 22 | return result
|
| 23 | + |
| 24 | + @exc.on_http_error(exc.OpenBASUpdateError) |
| 25 | + def update( |
| 26 | + self, |
| 27 | + inject_expectation_id: str, |
| 28 | + inject_expectation: Dict[str, Any], |
| 29 | + **kwargs: Any, |
| 30 | + ) -> Dict[str, Any]: |
| 31 | + path = f"{self.path}/{inject_expectation_id}" |
| 32 | + result = self.openbas.http_put(path, post_data=inject_expectation, **kwargs) |
| 33 | + return result |
0 commit comments