Skip to content

Commit

Permalink
#252 - Add custom field endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamforka committed Aug 11, 2022
1 parent 0c2d711 commit 639d417
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions thehive4py/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
UserEndpoint,
)
from thehive4py.endpoints.cortex import CortexEndpoint
from thehive4py.endpoints.custom_field import CustomFieldEndpoint
from thehive4py.session import TheHiveSession


Expand Down Expand Up @@ -51,6 +52,9 @@ def __init__(
self.organisation = OrganisationEndpoint(self.session)
self.profile = ProfileEndpoint(self.session)

# entity endpoints
self.custom_field = CustomFieldEndpoint(self.session)

# connector endpoints
self.cortex = CortexEndpoint(self.session)

Expand Down
1 change: 1 addition & 0 deletions thehive4py/endpoints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .case import CaseEndpoint
from .comment import CommentEndpoint
from .cortex import CortexEndpoint
from .custom_field import CustomFieldEndpoint
from .observable import ObservableEndpoint
from .organisation import OrganisationEndpoint
from .procedure import ProcedureEndpoint
Expand Down
28 changes: 28 additions & 0 deletions thehive4py/endpoints/custom_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from typing import List

from thehive4py.endpoints._base import EndpointBase
from thehive4py.types.custom_field import (
InputCustomField,
InputUpdateCustomField,
OutputCustomField,
)


class CustomFieldEndpoint(EndpointBase):
def create(self, custom_field: InputCustomField) -> OutputCustomField:
return self._session.make_request(
"POST", path="/api/v1/customField", json=custom_field
)

def list(self) -> List[OutputCustomField]:
return self._session.make_request("GET", path="/api/v1/customField")

def delete(self, custom_field_id: str) -> None:
return self._session.make_request(
"DELETE", path=f"/api/v1/customField/{custom_field_id}"
)

def update(self, custom_field_id: str, fields: InputUpdateCustomField) -> None:
return self._session.make_request(
"PATCH", path=f"/api/v1/customField/{custom_field_id}", json=fields
)

0 comments on commit 639d417

Please sign in to comment.