graylog-api-client 0.1.1__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {graylog_api_client-0.1.1 → graylog_api_client-0.1.3}/PKG-INFO +20 -1
- {graylog_api_client-0.1.1 → graylog_api_client-0.1.3}/README.md +19 -0
- {graylog_api_client-0.1.1 → graylog_api_client-0.1.3}/pyproject.toml +6 -1
- graylog_api_client-0.1.3/src/graylog_api_client/__init__.py +3 -0
- {graylog_api_client-0.1.1 → graylog_api_client-0.1.3}/src/graylog_api_client/data_structures.py +12 -0
- {graylog_api_client-0.1.1 → graylog_api_client-0.1.3}/src/graylog_api_client/graylog_api_client.py +26 -1
- graylog_api_client-0.1.1/src/graylog_api_client/__init__.py +0 -0
- {graylog_api_client-0.1.1 → graylog_api_client-0.1.3}/LICENSE +0 -0
- {graylog_api_client-0.1.1 → graylog_api_client-0.1.3}/src/graylog_api_client/exceptions.py +0 -0
- {graylog_api_client-0.1.1 → graylog_api_client-0.1.3}/src/graylog_api_client/rest_adapter.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: graylog-api-client
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: A Python wrapper for the Graylog REST API
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -21,6 +21,25 @@ Also the API responses all follow very different schemas and an implementation o
|
|
|
21
21
|
Feel free to add endpoints or schemas in PRs if you need them :)
|
|
22
22
|
#### Last tested Graylog Version is: 6.3.4
|
|
23
23
|
|
|
24
|
+
### Example Usage
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from graylog_api_client import GraylogAPI
|
|
28
|
+
|
|
29
|
+
# Initialize the GraylogAPI client
|
|
30
|
+
api = GraylogAPI(
|
|
31
|
+
host="https://localhost:9000/api", # Replace with your Graylog server URL
|
|
32
|
+
api_key="your_api_key_here", # Replace with your API key
|
|
33
|
+
ssl_verify=True # /path/to/cert for custom certificate
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# Example: Fetch all streams
|
|
37
|
+
streams = api.get_streams()
|
|
38
|
+
|
|
39
|
+
# Print the result
|
|
40
|
+
print("Streams:", streams.data)
|
|
41
|
+
```
|
|
42
|
+
|
|
24
43
|
Planned:
|
|
25
44
|
1. Tests that run against a Graylog instance to check if the Wrapper works after Graylog Updates
|
|
26
45
|
|
|
@@ -4,6 +4,25 @@ Also the API responses all follow very different schemas and an implementation o
|
|
|
4
4
|
Feel free to add endpoints or schemas in PRs if you need them :)
|
|
5
5
|
#### Last tested Graylog Version is: 6.3.4
|
|
6
6
|
|
|
7
|
+
### Example Usage
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from graylog_api_client import GraylogAPI
|
|
11
|
+
|
|
12
|
+
# Initialize the GraylogAPI client
|
|
13
|
+
api = GraylogAPI(
|
|
14
|
+
host="https://localhost:9000/api", # Replace with your Graylog server URL
|
|
15
|
+
api_key="your_api_key_here", # Replace with your API key
|
|
16
|
+
ssl_verify=True # /path/to/cert for custom certificate
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
# Example: Fetch all streams
|
|
20
|
+
streams = api.get_streams()
|
|
21
|
+
|
|
22
|
+
# Print the result
|
|
23
|
+
print("Streams:", streams.data)
|
|
24
|
+
```
|
|
25
|
+
|
|
7
26
|
Planned:
|
|
8
27
|
1. Tests that run against a Graylog instance to check if the Wrapper works after Graylog Updates
|
|
9
28
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "graylog-api-client"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.3"
|
|
4
4
|
description = "A Python wrapper for the Graylog REST API"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Chrxxxxs",email = "134285960+Chrxxxxs@users.noreply.github.com"}
|
|
@@ -22,3 +22,8 @@ packages = [{include = "graylog_api_client", from = "src"}]
|
|
|
22
22
|
[build-system]
|
|
23
23
|
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
24
24
|
build-backend = "poetry.core.masonry.api"
|
|
25
|
+
|
|
26
|
+
[dependency-groups]
|
|
27
|
+
dev = [
|
|
28
|
+
"pytest>=9.1.1",
|
|
29
|
+
]
|
{graylog_api_client-0.1.1 → graylog_api_client-0.1.3}/src/graylog_api_client/data_structures.py
RENAMED
|
@@ -12,3 +12,15 @@ class GraylogApiResult:
|
|
|
12
12
|
self.status_code = int(status_code)
|
|
13
13
|
self.message = str(message)
|
|
14
14
|
self.data = data if data else []
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# TODO make this a proper class
|
|
18
|
+
class GraylogTimerange:
|
|
19
|
+
# Example relative:
|
|
20
|
+
# { "type": "relative", "range": 300 }
|
|
21
|
+
# Example absolute:
|
|
22
|
+
# { "type": "absolute", "from": "2023-01-01T00:00:00.000Z", "to": "2023-01-02T00:00:00.000Z" }
|
|
23
|
+
def relative(range: int):
|
|
24
|
+
...
|
|
25
|
+
def absolute(from_time: str, to_time: str):
|
|
26
|
+
...
|
{graylog_api_client-0.1.1 → graylog_api_client-0.1.3}/src/graylog_api_client/graylog_api_client.py
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
from typing import List, Union, Dict
|
|
2
|
+
from typing import List, Literal, Union, Dict
|
|
3
3
|
|
|
4
4
|
from .rest_adapter import RestAdapter
|
|
5
5
|
from .data_structures import GraylogApiResult
|
|
@@ -7,6 +7,13 @@ from .data_structures import GraylogApiResult
|
|
|
7
7
|
|
|
8
8
|
class GraylogAPI:
|
|
9
9
|
def __init__(self, host: str, api_key: str, ssl_verify: Union[str, bool] = True, logger: logging.Logger = None):
|
|
10
|
+
"""GraylogAPI client
|
|
11
|
+
|
|
12
|
+
:param host: The hostname of the Graylog API endpoint plus the protocol. Example: https://graylog.com/api
|
|
13
|
+
:param api_key: An API Key to authenticate with Graylog
|
|
14
|
+
:param ssl_verify: Enables or Disables TLS Certificate verification. For a custom certificate, this value must a path pointing to the certificate, defaults to True
|
|
15
|
+
:param logger: The logger being used by the Adapter, will use a new one if none is given, defaults to None
|
|
16
|
+
"""
|
|
10
17
|
self._rest_adapter = RestAdapter(host=host, api_key=api_key, ssl_verify=ssl_verify, logger=logger)
|
|
11
18
|
|
|
12
19
|
# The endpoints grouped like they are in the api-browser
|
|
@@ -77,6 +84,24 @@ class GraylogAPI:
|
|
|
77
84
|
# /roles
|
|
78
85
|
# /views/search Search
|
|
79
86
|
# /search Search Options (Decorators, Export, Functions etc.)
|
|
87
|
+
def post_search_query(self, query: str, start: int, timerange: dict, streams: list[str], stream_categories: list[str] = None,\
|
|
88
|
+
sort: str = None, sort_order: Literal["Ascending", "Descending"] = None,\
|
|
89
|
+
fields: list[str] = None, size: int = 50) -> GraylogApiResult:
|
|
90
|
+
"""start replaces the "from" parameter in the API"""
|
|
91
|
+
data = {
|
|
92
|
+
"query": query,
|
|
93
|
+
"from": str(start),
|
|
94
|
+
"timerange": timerange,
|
|
95
|
+
"streams": streams,
|
|
96
|
+
"stream_categories": stream_categories,
|
|
97
|
+
"sort": sort,
|
|
98
|
+
"sort_order": sort_order,
|
|
99
|
+
"fields": fields,
|
|
100
|
+
"size": str(size),
|
|
101
|
+
}
|
|
102
|
+
result = self._rest_adapter.post("search/messages", data=data)
|
|
103
|
+
return result
|
|
104
|
+
|
|
80
105
|
# /views/searchjobs Searchjobs
|
|
81
106
|
# /sidecars
|
|
82
107
|
# /sidecar
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{graylog_api_client-0.1.1 → graylog_api_client-0.1.3}/src/graylog_api_client/rest_adapter.py
RENAMED
|
File without changes
|