|
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: |
@@ -124,6 +125,7 @@ def deprecated(message): # pyright: ignore[reportUnknownParameterType] |
124 | 125 | PATH_RECEIVERS_STREAM = "/services/receivers/stream" |
125 | 126 | PATH_RECEIVERS_SIMPLE = "/services/receivers/simple" |
126 | 127 | PATH_STORAGE_PASSWORDS = "storage/passwords" |
| 128 | +PATH_LOOKUP_TABLE_FILES = "data/lookup-table-files/" |
127 | 129 |
|
128 | 130 | XNAMEF_ATOM = "{http://www.w3.org/2005/Atom}%s" |
129 | 131 | XNAME_ENTRY = XNAMEF_ATOM % "entry" |
@@ -554,6 +556,14 @@ def loggers(self): |
554 | 556 | """ |
555 | 557 | return Loggers(self) |
556 | 558 |
|
| 559 | + @property |
| 560 | + def lookup_table_files(self): |
| 561 | + """Returns the collection of lookup table files. |
| 562 | +
|
| 563 | + :return: A :class:`LookupTableFiles` collection of :class:`LookupTableFile` entities. |
| 564 | + """ |
| 565 | + return LookupTableFiles(self) |
| 566 | + |
557 | 567 | @property |
558 | 568 | def messages(self): |
559 | 569 | """Returns the collection of service messages. |
@@ -3881,6 +3891,36 @@ def delete(self, name): |
3881 | 3891 | return Collection.delete(self, name.lower()) |
3882 | 3892 |
|
3883 | 3893 |
|
| 3894 | +class LookupTableFile(Entity): |
| 3895 | + """Represents a lookup table CSV file.""" |
| 3896 | + |
| 3897 | + def __init__(self, service: "Service", path: str, **kwargs: Any) -> None: |
| 3898 | + Entity.__init__(self, service, path, **kwargs) |
| 3899 | + |
| 3900 | + def download(self) -> Any: |
| 3901 | + """Downloads the lookup file contents via ``| inputlookup``. |
| 3902 | +
|
| 3903 | + Runs a oneshot search to retrieve the CSV data for this lookup. |
| 3904 | +
|
| 3905 | + :return: A streaming response handle with the CSV content. |
| 3906 | + :rtype: ``InputStream`` |
| 3907 | + """ |
| 3908 | + return self.service.jobs.oneshot( # pyright: ignore[reportUnknownVariableType] |
| 3909 | + f"| inputlookup {self.name}", |
| 3910 | + output_mode="csv", |
| 3911 | + ) |
| 3912 | + |
| 3913 | + |
| 3914 | +class LookupTableFiles(Collection): |
| 3915 | + """Provides access to the collection of lookup table files. |
| 3916 | +
|
| 3917 | + Retrieve this collection using :meth:`Service.lookup_table_files`. |
| 3918 | + """ |
| 3919 | + |
| 3920 | + def __init__(self, service: "Service") -> None: |
| 3921 | + Collection.__init__(self, service, PATH_LOOKUP_TABLE_FILES, item=LookupTableFile) |
| 3922 | + |
| 3923 | + |
3884 | 3924 | class Application(Entity): |
3885 | 3925 | """Represents a locally-installed Splunk app.""" |
3886 | 3926 |
|
|
0 commit comments