Skip to content

Commit 5ceab3a

Browse files
committed
[client] Add payloads helpers
1 parent 56a1ebd commit 5ceab3a

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

pyobas/apis/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
from .organization import * # noqa: F401,F403
1111
from .team import * # noqa: F401,F403
1212
from .user import * # noqa: F401,F403
13+
from .payload import * # noqa: F401,F403
1314

1415
__all__ = [name for name in dir() if not name.startswith("_")]

pyobas/apis/attack_pattern.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from pyobas.base import RESTManager, RESTObject
55

66

7-
class AttackPatternPhase(RESTObject):
7+
class AttackPattern(RESTObject):
88
_id_attr = "attack_pattern_id"
99

1010

1111
class AttackPatternManager(RESTManager):
1212
_path = "/attack_patterns"
13-
_obj_cls = AttackPatternPhase
13+
_obj_cls = AttackPattern
1414

1515
@exc.on_http_error(exc.OpenBASUpdateError)
1616
def upsert(

pyobas/apis/payload.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from typing import Any, Dict, List
2+
3+
from pyobas import exceptions as exc
4+
from pyobas.base import RESTManager, RESTObject
5+
6+
7+
class Payload(RESTObject):
8+
_id_attr = "payload_id"
9+
10+
11+
class PayloadManager(RESTManager):
12+
_path = "/payloads"
13+
_obj_cls = Payload
14+
15+
@exc.on_http_error(exc.OpenBASUpdateError)
16+
def upsert(self, payload: Dict[str, Any], **kwargs: Any) -> Dict[str, Any]:
17+
path = f"{self.path}/upsert"
18+
result = self.openbas.http_post(path, post_data=payload, **kwargs)
19+
return result

pyobas/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def __init__(
6767
self.endpoint = apis.EndpointManager(self)
6868
self.user = apis.UserManager(self)
6969
self.inject_expectation = apis.InjectExpectationManager(self)
70+
self.payload = apis.PayloadManager(self)
7071

7172
@staticmethod
7273
def _check_redirects(result: requests.Response) -> None:

0 commit comments

Comments
 (0)