argus-api-client 0.5.0__tar.gz → 0.6.0__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.
- {argus_api_client-0.5.0/src/argus_api_client.egg-info → argus_api_client-0.6.0}/PKG-INFO +42 -3
- {argus_api_client-0.5.0 → argus_api_client-0.6.0}/README.md +30 -0
- {argus_api_client-0.5.0 → argus_api_client-0.6.0}/pyproject.toml +29 -3
- {argus_api_client-0.5.0 → argus_api_client-0.6.0/src/argus_api_client.egg-info}/PKG-INFO +42 -3
- argus_api_client-0.6.0/src/argus_api_client.egg-info/requires.txt +13 -0
- {argus_api_client-0.5.0 → argus_api_client-0.6.0}/src/pyargus/__init__.py +1 -1
- {argus_api_client-0.5.0 → argus_api_client-0.6.0}/src/pyargus/api.py +8 -0
- {argus_api_client-0.5.0 → argus_api_client-0.6.0}/src/pyargus/client.py +14 -0
- {argus_api_client-0.5.0 → argus_api_client-0.6.0}/src/pyargus/models.py +19 -0
- {argus_api_client-0.5.0 → argus_api_client-0.6.0}/tests/test_api.py +1 -1
- argus_api_client-0.5.0/src/argus_api_client.egg-info/requires.txt +0 -2
- {argus_api_client-0.5.0 → argus_api_client-0.6.0}/LICENSE +0 -0
- {argus_api_client-0.5.0 → argus_api_client-0.6.0}/setup.cfg +0 -0
- {argus_api_client-0.5.0 → argus_api_client-0.6.0}/src/argus_api_client.egg-info/SOURCES.txt +0 -0
- {argus_api_client-0.5.0 → argus_api_client-0.6.0}/src/argus_api_client.egg-info/dependency_links.txt +0 -0
- {argus_api_client-0.5.0 → argus_api_client-0.6.0}/src/argus_api_client.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: argus-api-client
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: A Python API client library for the Argus alert aggregator server
|
|
5
5
|
Author-email: Sikt - Kunnskapssektorens Tjenesteleverandør <kontakt@sikt.no>
|
|
6
6
|
License:
|
|
@@ -197,18 +197,29 @@ License:
|
|
|
197
197
|
|
|
198
198
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
199
199
|
Classifier: Programming Language :: Python :: 3
|
|
200
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
201
200
|
Classifier: Programming Language :: Python :: 3.8
|
|
202
201
|
Classifier: Programming Language :: Python :: 3.9
|
|
203
202
|
Classifier: Programming Language :: Python :: 3.10
|
|
204
203
|
Classifier: Programming Language :: Python :: 3.11
|
|
205
|
-
Requires-Python: >=3.
|
|
204
|
+
Requires-Python: >=3.8
|
|
206
205
|
Description-Content-Type: text/markdown
|
|
207
206
|
License-File: LICENSE
|
|
208
207
|
Requires-Dist: simple_rest_client
|
|
209
208
|
Requires-Dist: iso8601
|
|
209
|
+
Provides-Extra: dev
|
|
210
|
+
Requires-Dist: build; extra == "dev"
|
|
211
|
+
Requires-Dist: coverage; extra == "dev"
|
|
212
|
+
Requires-Dist: ipython; extra == "dev"
|
|
213
|
+
Requires-Dist: isort; extra == "dev"
|
|
214
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
215
|
+
Requires-Dist: pytest; extra == "dev"
|
|
216
|
+
Requires-Dist: ruff; extra == "dev"
|
|
217
|
+
Requires-Dist: tox; extra == "dev"
|
|
218
|
+
Requires-Dist: twine; extra == "dev"
|
|
210
219
|
|
|
211
220
|
# Argus API Client
|
|
221
|
+
[](https://github.com/Uninett/pyargus/actions)
|
|
222
|
+
[](https://github.com/astral-sh/ruff)
|
|
212
223
|
|
|
213
224
|
This is the official Python client library for the
|
|
214
225
|
[Argus](https://github.com/Uninett/Argus) API server.
|
|
@@ -343,6 +354,34 @@ stateless_incident = Incident(
|
|
|
343
354
|
)
|
|
344
355
|
```
|
|
345
356
|
|
|
357
|
+
|
|
358
|
+
### Get a new authentication token
|
|
359
|
+
|
|
360
|
+
If your argus server is running version 1.29.0 or newer you can request to get
|
|
361
|
+
a new token (with a new expiration date) via API version 2. The token you are
|
|
362
|
+
using to access the server with must still be valid.
|
|
363
|
+
|
|
364
|
+
```python
|
|
365
|
+
tokenobj = c.refresh_token()
|
|
366
|
+
c = Client(api_root_url="https://argus.example.org/api/v2", token=tokenobj.token)
|
|
367
|
+
# save the contents of tokenobj in an environment variable, config file or
|
|
368
|
+
# secrets file so that it is not lost on program exit
|
|
369
|
+
```
|
|
370
|
+
|
|
346
371
|
## BUGS
|
|
347
372
|
|
|
348
373
|
* Doesn't provide high-level error handling yet.
|
|
374
|
+
|
|
375
|
+
## Development
|
|
376
|
+
|
|
377
|
+
### Code style
|
|
378
|
+
|
|
379
|
+
Pyargus uses *ruff* as a source code formatter. Ruff is part of the optional dev dependencies listed in
|
|
380
|
+
[pyproject.toml](./pyproject.toml)
|
|
381
|
+
|
|
382
|
+
A pre-commit hook will format new code automatically before committing.
|
|
383
|
+
To enable this pre-commit hook, run
|
|
384
|
+
|
|
385
|
+
```console
|
|
386
|
+
$ pre-commit install
|
|
387
|
+
```
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
# Argus API Client
|
|
2
|
+
[](https://github.com/Uninett/pyargus/actions)
|
|
3
|
+
[](https://github.com/astral-sh/ruff)
|
|
2
4
|
|
|
3
5
|
This is the official Python client library for the
|
|
4
6
|
[Argus](https://github.com/Uninett/Argus) API server.
|
|
@@ -133,6 +135,34 @@ stateless_incident = Incident(
|
|
|
133
135
|
)
|
|
134
136
|
```
|
|
135
137
|
|
|
138
|
+
|
|
139
|
+
### Get a new authentication token
|
|
140
|
+
|
|
141
|
+
If your argus server is running version 1.29.0 or newer you can request to get
|
|
142
|
+
a new token (with a new expiration date) via API version 2. The token you are
|
|
143
|
+
using to access the server with must still be valid.
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
tokenobj = c.refresh_token()
|
|
147
|
+
c = Client(api_root_url="https://argus.example.org/api/v2", token=tokenobj.token)
|
|
148
|
+
# save the contents of tokenobj in an environment variable, config file or
|
|
149
|
+
# secrets file so that it is not lost on program exit
|
|
150
|
+
```
|
|
151
|
+
|
|
136
152
|
## BUGS
|
|
137
153
|
|
|
138
154
|
* Doesn't provide high-level error handling yet.
|
|
155
|
+
|
|
156
|
+
## Development
|
|
157
|
+
|
|
158
|
+
### Code style
|
|
159
|
+
|
|
160
|
+
Pyargus uses *ruff* as a source code formatter. Ruff is part of the optional dev dependencies listed in
|
|
161
|
+
[pyproject.toml](./pyproject.toml)
|
|
162
|
+
|
|
163
|
+
A pre-commit hook will format new code automatically before committing.
|
|
164
|
+
To enable this pre-commit hook, run
|
|
165
|
+
|
|
166
|
+
```console
|
|
167
|
+
$ pre-commit install
|
|
168
|
+
```
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "argus-api-client"
|
|
3
|
-
|
|
3
|
+
dynamic = ["version"]
|
|
4
4
|
description = "A Python API client library for the Argus alert aggregator server"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{name="Sikt - Kunnskapssektorens Tjenesteleverandør", email="kontakt@sikt.no"}]
|
|
7
|
-
requires-python = ">=3.
|
|
7
|
+
requires-python = ">=3.8"
|
|
8
8
|
license = {file = "LICENSE"}
|
|
9
9
|
classifiers = [
|
|
10
10
|
"License :: OSI Approved :: Apache Software License",
|
|
11
11
|
"Programming Language :: Python :: 3",
|
|
12
|
-
"Programming Language :: Python :: 3.7",
|
|
13
12
|
"Programming Language :: Python :: 3.8",
|
|
14
13
|
"Programming Language :: Python :: 3.9",
|
|
15
14
|
"Programming Language :: Python :: 3.10",
|
|
@@ -20,6 +19,33 @@ dependencies = [
|
|
|
20
19
|
"iso8601",
|
|
21
20
|
]
|
|
22
21
|
|
|
22
|
+
[project.optional-dependencies]
|
|
23
|
+
dev = [
|
|
24
|
+
"build",
|
|
25
|
+
"coverage",
|
|
26
|
+
"ipython",
|
|
27
|
+
"isort",
|
|
28
|
+
"pre-commit",
|
|
29
|
+
"pytest",
|
|
30
|
+
"ruff",
|
|
31
|
+
"tox",
|
|
32
|
+
"twine",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[tool.setuptools.dynamic]
|
|
36
|
+
version = {attr = "pyargus.VERSION"}
|
|
37
|
+
|
|
23
38
|
[tool.setuptools.packages.find]
|
|
24
39
|
where = ["src"]
|
|
25
40
|
exclude = ["tests*"]
|
|
41
|
+
|
|
42
|
+
[tool.ruff]
|
|
43
|
+
line-length = 88
|
|
44
|
+
extend-exclude = [
|
|
45
|
+
".egg-info",
|
|
46
|
+
]
|
|
47
|
+
output-format = "full"
|
|
48
|
+
|
|
49
|
+
[tool.ruff.lint]
|
|
50
|
+
select = ["E4", "E7", "E9", "F4", "F5", "F6", "F7", "F8", "F9"]
|
|
51
|
+
ignore = ["F403", "F405"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: argus-api-client
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: A Python API client library for the Argus alert aggregator server
|
|
5
5
|
Author-email: Sikt - Kunnskapssektorens Tjenesteleverandør <kontakt@sikt.no>
|
|
6
6
|
License:
|
|
@@ -197,18 +197,29 @@ License:
|
|
|
197
197
|
|
|
198
198
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
199
199
|
Classifier: Programming Language :: Python :: 3
|
|
200
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
201
200
|
Classifier: Programming Language :: Python :: 3.8
|
|
202
201
|
Classifier: Programming Language :: Python :: 3.9
|
|
203
202
|
Classifier: Programming Language :: Python :: 3.10
|
|
204
203
|
Classifier: Programming Language :: Python :: 3.11
|
|
205
|
-
Requires-Python: >=3.
|
|
204
|
+
Requires-Python: >=3.8
|
|
206
205
|
Description-Content-Type: text/markdown
|
|
207
206
|
License-File: LICENSE
|
|
208
207
|
Requires-Dist: simple_rest_client
|
|
209
208
|
Requires-Dist: iso8601
|
|
209
|
+
Provides-Extra: dev
|
|
210
|
+
Requires-Dist: build; extra == "dev"
|
|
211
|
+
Requires-Dist: coverage; extra == "dev"
|
|
212
|
+
Requires-Dist: ipython; extra == "dev"
|
|
213
|
+
Requires-Dist: isort; extra == "dev"
|
|
214
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
215
|
+
Requires-Dist: pytest; extra == "dev"
|
|
216
|
+
Requires-Dist: ruff; extra == "dev"
|
|
217
|
+
Requires-Dist: tox; extra == "dev"
|
|
218
|
+
Requires-Dist: twine; extra == "dev"
|
|
210
219
|
|
|
211
220
|
# Argus API Client
|
|
221
|
+
[](https://github.com/Uninett/pyargus/actions)
|
|
222
|
+
[](https://github.com/astral-sh/ruff)
|
|
212
223
|
|
|
213
224
|
This is the official Python client library for the
|
|
214
225
|
[Argus](https://github.com/Uninett/Argus) API server.
|
|
@@ -343,6 +354,34 @@ stateless_incident = Incident(
|
|
|
343
354
|
)
|
|
344
355
|
```
|
|
345
356
|
|
|
357
|
+
|
|
358
|
+
### Get a new authentication token
|
|
359
|
+
|
|
360
|
+
If your argus server is running version 1.29.0 or newer you can request to get
|
|
361
|
+
a new token (with a new expiration date) via API version 2. The token you are
|
|
362
|
+
using to access the server with must still be valid.
|
|
363
|
+
|
|
364
|
+
```python
|
|
365
|
+
tokenobj = c.refresh_token()
|
|
366
|
+
c = Client(api_root_url="https://argus.example.org/api/v2", token=tokenobj.token)
|
|
367
|
+
# save the contents of tokenobj in an environment variable, config file or
|
|
368
|
+
# secrets file so that it is not lost on program exit
|
|
369
|
+
```
|
|
370
|
+
|
|
346
371
|
## BUGS
|
|
347
372
|
|
|
348
373
|
* Doesn't provide high-level error handling yet.
|
|
374
|
+
|
|
375
|
+
## Development
|
|
376
|
+
|
|
377
|
+
### Code style
|
|
378
|
+
|
|
379
|
+
Pyargus uses *ruff* as a source code formatter. Ruff is part of the optional dev dependencies listed in
|
|
380
|
+
[pyproject.toml](./pyproject.toml)
|
|
381
|
+
|
|
382
|
+
A pre-commit hook will format new code automatically before committing.
|
|
383
|
+
To enable this pre-commit hook, run
|
|
384
|
+
|
|
385
|
+
```console
|
|
386
|
+
$ pre-commit install
|
|
387
|
+
```
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Defines a low-level API interface for Argus using simple_rest_client"""
|
|
2
|
+
|
|
2
3
|
from simple_rest_client.api import API
|
|
3
4
|
from simple_rest_client.resource import Resource
|
|
4
5
|
|
|
@@ -21,6 +22,7 @@ def connect(api_root_url: str, token: str, timeout: float = 2.0) -> API:
|
|
|
21
22
|
argusapi.add_resource(
|
|
22
23
|
resource_name="acknowledgements", resource_class=IncidentAcknowledgementResource
|
|
23
24
|
)
|
|
25
|
+
argusapi.add_resource(resource_name="tokens", resource_class=ExpiringTokenResource)
|
|
24
26
|
return argusapi
|
|
25
27
|
|
|
26
28
|
|
|
@@ -51,3 +53,9 @@ class IncidentAcknowledgementResource(Resource):
|
|
|
51
53
|
"create": {"method": "POST", "url": "incidents/{}/acks"},
|
|
52
54
|
"retrieve": {"method": "GET", "url": "incidents/{}/acks/{}"},
|
|
53
55
|
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class ExpiringTokenResource(Resource):
|
|
59
|
+
actions = {
|
|
60
|
+
"refresh": {"method": "POST", "url": "auth/token/login/"},
|
|
61
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Slightly higher level Argus API client abstraction"""
|
|
2
|
+
|
|
2
3
|
from __future__ import annotations
|
|
3
4
|
|
|
4
5
|
from datetime import datetime
|
|
@@ -131,6 +132,19 @@ class Client:
|
|
|
131
132
|
response = self.api.events.create(incident_pk, body=body)
|
|
132
133
|
return models.Event.from_json(response.body)
|
|
133
134
|
|
|
135
|
+
def refresh_token(self) -> models.ExpiringToken:
|
|
136
|
+
"""Post w/o body to get a new token and its expiration timestamp
|
|
137
|
+
|
|
138
|
+
It will be necessary to re-initialize the client as the old token has
|
|
139
|
+
been rendered invalid.
|
|
140
|
+
|
|
141
|
+
Store the new token (and the returned expiration datetime) where your
|
|
142
|
+
program can load it on next run: environment variable, config file or
|
|
143
|
+
secrets file.
|
|
144
|
+
"""
|
|
145
|
+
response = self.api.tokens.refresh()
|
|
146
|
+
return models.ExpiringToken.from_json(response.body)
|
|
147
|
+
|
|
134
148
|
|
|
135
149
|
def paginated_query(method: Callable, *args, **kwargs) -> Iterator[Tuple]:
|
|
136
150
|
"""Extracts paginated results from a simple_rest_client API call.
|
|
@@ -11,8 +11,11 @@ import inspect
|
|
|
11
11
|
# need an explicit value to flag stateless incidents.
|
|
12
12
|
class _STATELESS_TYPE:
|
|
13
13
|
pass
|
|
14
|
+
|
|
15
|
+
|
|
14
16
|
STATELESS = _STATELESS_TYPE()
|
|
15
17
|
|
|
18
|
+
|
|
16
19
|
@dataclass
|
|
17
20
|
class SourceSystem:
|
|
18
21
|
"""Class for describing an Argus Source system"""
|
|
@@ -164,3 +167,19 @@ class Acknowledgement:
|
|
|
164
167
|
else None,
|
|
165
168
|
}
|
|
166
169
|
return cls(**kwargs)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
@dataclass
|
|
173
|
+
class ExpiringToken:
|
|
174
|
+
"""Class for describing the authentication token"""
|
|
175
|
+
|
|
176
|
+
expiration: datetime
|
|
177
|
+
token: int
|
|
178
|
+
|
|
179
|
+
@classmethod
|
|
180
|
+
def from_json(cls, data: dict) -> ExpiringToken:
|
|
181
|
+
kwargs = {
|
|
182
|
+
"expiration": parse_date(data["expiration"]),
|
|
183
|
+
"token": parse_date(data["token"]),
|
|
184
|
+
}
|
|
185
|
+
return cls(**kwargs)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{argus_api_client-0.5.0 → argus_api_client-0.6.0}/src/argus_api_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{argus_api_client-0.5.0 → argus_api_client-0.6.0}/src/argus_api_client.egg-info/top_level.txt
RENAMED
|
File without changes
|