|
64 | 64 | import socket |
65 | 65 | from datetime import datetime, timedelta |
66 | 66 | from time import sleep |
| 67 | +from typing import Any |
67 | 68 | from urllib import parse |
68 | 69 |
|
69 | 70 | try: |
@@ -109,6 +110,7 @@ def deprecated(message): # pyright: ignore[reportUnknownParameterType] |
109 | 110 | PATH_DEPLOYMENT_SERVERCLASSES = "deployment/serverclass/" |
110 | 111 | PATH_EVENT_TYPES = "saved/eventtypes/" |
111 | 112 | PATH_FIRED_ALERTS = "alerts/fired_alerts/" |
| 113 | +PATH_HEC_TOKENS = "data/inputs/http/" |
112 | 114 | PATH_INDEXES = "data/indexes/" |
113 | 115 | PATH_INPUTS = "data/inputs/" |
114 | 116 | PATH_JOBS = "search/jobs/" |
@@ -498,6 +500,14 @@ def fired_alerts(self): |
498 | 500 | """ |
499 | 501 | return Collection(self, PATH_FIRED_ALERTS, item=AlertGroup) |
500 | 502 |
|
| 503 | + @property |
| 504 | + def hec_tokens(self): |
| 505 | + """Returns the collection of HTTP Event Collector tokens. |
| 506 | +
|
| 507 | + :return: A :class:`HECTokens` collection of :class:`HECToken` entities. |
| 508 | + """ |
| 509 | + return HECTokens(self) |
| 510 | + |
501 | 511 | @property |
502 | 512 | def indexes(self): |
503 | 513 | """Returns the collection of indexes for this Splunk instance. |
@@ -2126,6 +2136,39 @@ def count(self): |
2126 | 2136 | return int(self.content.get("triggered_alert_count", 0)) |
2127 | 2137 |
|
2128 | 2138 |
|
| 2139 | +class HECToken(Entity): |
| 2140 | + """This class represents an HTTP Event Collector token.""" |
| 2141 | + |
| 2142 | + def __init__(self, service: "Service", path: str, **kwargs: Any) -> None: |
| 2143 | + Entity.__init__(self, service, path, **kwargs) |
| 2144 | + |
| 2145 | + def disable(self) -> "HECToken": # pyright: ignore[reportImplicitOverride] |
| 2146 | + """Disables this HEC token. |
| 2147 | +
|
| 2148 | + :return: The :class:`HECToken`. |
| 2149 | + """ |
| 2150 | + self.post(disabled="1") |
| 2151 | + self.refresh() |
| 2152 | + return self |
| 2153 | + |
| 2154 | + def enable(self) -> "HECToken": # pyright: ignore[reportImplicitOverride] |
| 2155 | + """Enables this HEC token. |
| 2156 | +
|
| 2157 | + :return: The :class:`HECToken`. |
| 2158 | + """ |
| 2159 | + self.post(disabled="0") |
| 2160 | + self.refresh() |
| 2161 | + return self |
| 2162 | + |
| 2163 | + |
| 2164 | +class HECTokens(Collection): |
| 2165 | + """This class represents a collection of HTTP Event Collector tokens. |
| 2166 | + Retrieve this collection using :meth:`Service.hec_tokens`.""" |
| 2167 | + |
| 2168 | + def __init__(self, service: "Service") -> None: |
| 2169 | + Collection.__init__(self, service, PATH_HEC_TOKENS, item=HECToken) |
| 2170 | + |
| 2171 | + |
2129 | 2172 | class Indexes(Collection): |
2130 | 2173 | """This class contains the collection of indexes in this Splunk instance. |
2131 | 2174 | Retrieve this collection using :meth:`Service.indexes`. |
|
0 commit comments