Skip to content

Client

thehive4py.client

TheHiveApi(url, apikey=None, username=None, password=None, organisation=None, verify=True, max_retries=DEFAULT_RETRY)

Create a client of TheHive API.

Parameters:

Name Type Description Default
url str

TheHive's url.

required
apikey Optional[str]

TheHive's apikey. It's required if username and password is not provided.

None
username Optional[str]

TheHive's username. It's required if apikey is not provided. Must be specified together with password.

None
password Optional[str]

TheHive's password. It's required if apikey is not provided. Must be specified together with username.

None
organisation Optional[str]

TheHive organisation to use in the session.

None
verify VerifyValue

Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use.

True
max_retries RetryValue

Either None, in which case we do not retry failed requests, or a Retry object.

DEFAULT_RETRY
Source code in thehive4py/client.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
def __init__(
    self,
    url: str,
    apikey: Optional[str] = None,
    username: Optional[str] = None,
    password: Optional[str] = None,
    organisation: Optional[str] = None,
    verify: VerifyValue = True,
    max_retries: RetryValue = DEFAULT_RETRY,
):
    """Create a client of TheHive API.

    Parameters:
        url: TheHive's url.
        apikey: TheHive's apikey. It's required if `username` and `password`
            is not provided.
        username: TheHive's username. It's required if `apikey` is not provided.
            Must be specified together with `password`.
        password: TheHive's password. It's required if `apikey` is not provided.
            Must be specified together with `username`.
        organisation: TheHive organisation to use in the session.
        verify: Either a boolean, in which case it controls whether we verify
            the server's TLS certificate, or a string, in which case it must be a
            path to a CA bundle to use.
        max_retries: Either `None`, in which case we do not retry failed requests,
            or a `Retry` object.

    """
    self.session = TheHiveSession(
        url=url,
        apikey=apikey,
        username=username,
        password=password,
        verify=verify,
        max_retries=max_retries,
    )
    self.session_organisation = organisation

    # case management endpoints
    self.alert = AlertEndpoint(self.session)
    self.case = CaseEndpoint(self.session)
    self.case_template = CaseTemplateEndpoint(self.session)
    self.comment = CommentEndpoint(self.session)
    self.observable = ObservableEndpoint(self.session)
    self.page_template = PageTemplateEndpoint(self.session)
    self.procedure = ProcedureEndpoint(self.session)
    self.task = TaskEndpoint(self.session)
    self.task_log = TaskLogEndpoint(self.session)
    self.timeline = TimelineEndpoint(self.session)

    # user management endpoints
    self.user = UserEndpoint(self.session)
    self.organisation = OrganisationEndpoint(self.session)
    self.profile = ProfileEndpoint(self.session)

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

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

    # standard endpoints
    self.query = QueryEndpoint(self.session)

session = TheHiveSession(url=url, apikey=apikey, username=username, password=password, verify=verify, max_retries=max_retries) instance-attribute

alert = AlertEndpoint(self.session) instance-attribute

case = CaseEndpoint(self.session) instance-attribute

case_template = CaseTemplateEndpoint(self.session) instance-attribute

comment = CommentEndpoint(self.session) instance-attribute

observable = ObservableEndpoint(self.session) instance-attribute

page_template = PageTemplateEndpoint(self.session) instance-attribute

procedure = ProcedureEndpoint(self.session) instance-attribute

task = TaskEndpoint(self.session) instance-attribute

task_log = TaskLogEndpoint(self.session) instance-attribute

timeline = TimelineEndpoint(self.session) instance-attribute

user = UserEndpoint(self.session) instance-attribute

organisation = OrganisationEndpoint(self.session) instance-attribute

profile = ProfileEndpoint(self.session) instance-attribute

custom_field = CustomFieldEndpoint(self.session) instance-attribute

observable_type = ObservableTypeEndpoint(self.session) instance-attribute

cortex = CortexEndpoint(self.session) instance-attribute

query = QueryEndpoint(self.session) instance-attribute

session_organisation property writable