netsware-sdk 1.0.0__tar.gz → 2.1.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.
- {netsware_sdk-1.0.0 → netsware_sdk-2.1.0}/PKG-INFO +23 -1
- {netsware_sdk-1.0.0 → netsware_sdk-2.1.0}/README.md +22 -0
- {netsware_sdk-1.0.0 → netsware_sdk-2.1.0}/netsware/__init__.py +124 -6
- {netsware_sdk-1.0.0 → netsware_sdk-2.1.0}/netsware_sdk.egg-info/PKG-INFO +23 -1
- {netsware_sdk-1.0.0 → netsware_sdk-2.1.0}/pyproject.toml +1 -1
- {netsware_sdk-1.0.0 → netsware_sdk-2.1.0}/netsware_sdk.egg-info/SOURCES.txt +0 -0
- {netsware_sdk-1.0.0 → netsware_sdk-2.1.0}/netsware_sdk.egg-info/dependency_links.txt +0 -0
- {netsware_sdk-1.0.0 → netsware_sdk-2.1.0}/netsware_sdk.egg-info/top_level.txt +0 -0
- {netsware_sdk-1.0.0 → netsware_sdk-2.1.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: netsware-sdk
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Official Netsware SDK — Business Hours + Scheduled Jobs APIs
|
|
5
5
|
Author: Netsware Systems LLP
|
|
6
6
|
License: MIT
|
|
@@ -74,6 +74,28 @@ if not ok:
|
|
|
74
74
|
... # reject
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
## Groups, variables, runs & metrics
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
# Organize jobs into groups
|
|
81
|
+
g = client.groups.create("Nightly")
|
|
82
|
+
client.groups.rename(g["id"], "Nightly batch")
|
|
83
|
+
|
|
84
|
+
# Reusable values + secrets (secret values are WRITE-ONLY: list() returns value=None)
|
|
85
|
+
client.variables.set("API_BASE_URL", "https://api.acme.io")
|
|
86
|
+
client.variables.set("API_TOKEN", "t0ken", is_secret=True)
|
|
87
|
+
|
|
88
|
+
# What's broken everywhere? (status is required; success has no account-wide feed)
|
|
89
|
+
failing = client.runs.list(status="failed", since="24h")
|
|
90
|
+
|
|
91
|
+
# Per-job history filtered by outcome (retention-clamped)
|
|
92
|
+
errs = client.jobs.logs(job["id"], status="failed")
|
|
93
|
+
|
|
94
|
+
# Daily monitoring rollups for your own NOC/monitor (default 30d, plan-clamped)
|
|
95
|
+
m = client.metrics.get(window="30d")
|
|
96
|
+
print(m["totals"]["runs"], m["current"]["active_jobs"])
|
|
97
|
+
```
|
|
98
|
+
|
|
77
99
|
## Configuration
|
|
78
100
|
|
|
79
101
|
```python
|
|
@@ -62,6 +62,28 @@ if not ok:
|
|
|
62
62
|
... # reject
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
## Groups, variables, runs & metrics
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
# Organize jobs into groups
|
|
69
|
+
g = client.groups.create("Nightly")
|
|
70
|
+
client.groups.rename(g["id"], "Nightly batch")
|
|
71
|
+
|
|
72
|
+
# Reusable values + secrets (secret values are WRITE-ONLY: list() returns value=None)
|
|
73
|
+
client.variables.set("API_BASE_URL", "https://api.acme.io")
|
|
74
|
+
client.variables.set("API_TOKEN", "t0ken", is_secret=True)
|
|
75
|
+
|
|
76
|
+
# What's broken everywhere? (status is required; success has no account-wide feed)
|
|
77
|
+
failing = client.runs.list(status="failed", since="24h")
|
|
78
|
+
|
|
79
|
+
# Per-job history filtered by outcome (retention-clamped)
|
|
80
|
+
errs = client.jobs.logs(job["id"], status="failed")
|
|
81
|
+
|
|
82
|
+
# Daily monitoring rollups for your own NOC/monitor (default 30d, plan-clamped)
|
|
83
|
+
m = client.metrics.get(window="30d")
|
|
84
|
+
print(m["totals"]["runs"], m["current"]["active_jobs"])
|
|
85
|
+
```
|
|
86
|
+
|
|
65
87
|
## Configuration
|
|
66
88
|
|
|
67
89
|
```python
|
|
@@ -70,7 +70,7 @@ class _Http:
|
|
|
70
70
|
req = urllib.request.Request(url, data=data, method=method)
|
|
71
71
|
req.add_header("X-API-Key", self._api_key)
|
|
72
72
|
req.add_header("Content-Type", "application/json")
|
|
73
|
-
req.add_header("User-Agent", "netsware-sdk-python/1.0")
|
|
73
|
+
req.add_header("User-Agent", "netsware-sdk-python/2.1.0")
|
|
74
74
|
try:
|
|
75
75
|
with urllib.request.urlopen(req, timeout=self._timeout) as resp:
|
|
76
76
|
raw = resp.read().decode()
|
|
@@ -212,8 +212,17 @@ class _Jobs:
|
|
|
212
212
|
def stats(self) -> dict:
|
|
213
213
|
return self._http.request("GET", "/v1/jobs/stats")
|
|
214
214
|
|
|
215
|
-
def logs(self, job_id: str
|
|
216
|
-
|
|
215
|
+
def logs(self, job_id: str, page: Optional[int] = None, limit: Optional[int] = None,
|
|
216
|
+
status: Optional[str] = None) -> dict:
|
|
217
|
+
"""Execution logs for a job (newest first), paginated.
|
|
218
|
+
|
|
219
|
+
Optional ``status`` filter (``success``/``failed``/``timeout``); the window is
|
|
220
|
+
clamped to your plan retention and each row carries retry detail
|
|
221
|
+
(``attempt_number``/``max_attempts``). Returns a flat
|
|
222
|
+
``{"logs": [...], "pagination": {...}}`` — ``logs`` is always a list.
|
|
223
|
+
"""
|
|
224
|
+
query = {"page": page, "limit": limit, "status": status}
|
|
225
|
+
return self._http.request("GET", f"/v1/jobs/{job_id}/logs", query=query)
|
|
217
226
|
|
|
218
227
|
def cancel(self, job_id: str) -> dict:
|
|
219
228
|
return self._http.request("DELETE", f"/v1/jobs/{job_id}")
|
|
@@ -235,10 +244,45 @@ class _Webhooks:
|
|
|
235
244
|
def __init__(self, http: _Http):
|
|
236
245
|
self._http = http
|
|
237
246
|
|
|
247
|
+
# ── Endpoints (recommended): one URL subscribes to many events ──────────
|
|
248
|
+
|
|
249
|
+
def register_endpoint(self, url: str, events: list) -> dict:
|
|
250
|
+
"""Register an endpoint (one URL) for many events. ``events`` is a list of
|
|
251
|
+
``{"product": ..., "event": ...}`` dicts. The response includes a signing
|
|
252
|
+
``secret``, shown once."""
|
|
253
|
+
return self._http.request("POST", "/v1/webhooks/endpoints",
|
|
254
|
+
body={"url": url, "events": events})
|
|
255
|
+
|
|
256
|
+
def list_endpoints(self) -> dict:
|
|
257
|
+
return self._http.request("GET", "/v1/webhooks/endpoints")
|
|
258
|
+
|
|
259
|
+
def update_endpoint(self, endpoint_id: str, *, url: str = None,
|
|
260
|
+
is_active: bool = None, events: list = None) -> dict:
|
|
261
|
+
"""Edit an endpoint in place. The URL and signing secret are preserved;
|
|
262
|
+
``events`` (when given) fully replaces the endpoint's event set."""
|
|
263
|
+
body = {}
|
|
264
|
+
if url is not None:
|
|
265
|
+
body["url"] = url
|
|
266
|
+
if is_active is not None:
|
|
267
|
+
body["is_active"] = is_active
|
|
268
|
+
if events is not None:
|
|
269
|
+
body["events"] = events
|
|
270
|
+
return self._http.request("PATCH", f"/v1/webhooks/endpoints/{endpoint_id}", body=body)
|
|
271
|
+
|
|
272
|
+
def delete_endpoint(self, endpoint_id: str) -> dict:
|
|
273
|
+
return self._http.request("DELETE", f"/v1/webhooks/endpoints/{endpoint_id}")
|
|
274
|
+
|
|
275
|
+
def test_endpoint(self, endpoint_id: str) -> dict:
|
|
276
|
+
return self._http.request("POST", f"/v1/webhooks/endpoints/{endpoint_id}/test")
|
|
277
|
+
|
|
278
|
+
def endpoint_deliveries(self, endpoint_id: str) -> dict:
|
|
279
|
+
return self._http.request("GET", f"/v1/webhooks/endpoints/{endpoint_id}/deliveries")
|
|
280
|
+
|
|
281
|
+
# ── Single-event (legacy): kept for back-compat; prefer endpoints ───────
|
|
282
|
+
|
|
238
283
|
def register(self, product: str, event: str, url: str) -> dict:
|
|
239
|
-
"""Register a webhook.
|
|
240
|
-
|
|
241
|
-
includes a signing ``secret``, shown once."""
|
|
284
|
+
"""Deprecated: prefer ``register_endpoint``. Register a single-event webhook.
|
|
285
|
+
The response includes a signing ``secret``, shown once."""
|
|
242
286
|
return self._http.request("POST", "/v1/webhooks",
|
|
243
287
|
body={"product": product, "event": event, "url": url})
|
|
244
288
|
|
|
@@ -255,6 +299,76 @@ class _Webhooks:
|
|
|
255
299
|
return self._http.request("GET", f"/v1/webhooks/{webhook_id}/deliveries")
|
|
256
300
|
|
|
257
301
|
|
|
302
|
+
class _Groups:
|
|
303
|
+
def __init__(self, http: _Http):
|
|
304
|
+
self._http = http
|
|
305
|
+
|
|
306
|
+
def list(self, page: Optional[int] = None, limit: Optional[int] = None) -> dict:
|
|
307
|
+
"""List groups (paginated)."""
|
|
308
|
+
return self._http.request("GET", "/v1/groups", query={"page": page, "limit": limit})
|
|
309
|
+
|
|
310
|
+
def get(self, group_id: str) -> dict:
|
|
311
|
+
return self._http.request("GET", f"/v1/groups/{group_id}")
|
|
312
|
+
|
|
313
|
+
def create(self, name: str) -> dict:
|
|
314
|
+
return self._http.request("POST", "/v1/groups", body={"name": name})
|
|
315
|
+
|
|
316
|
+
def rename(self, group_id: str, name: str) -> dict:
|
|
317
|
+
return self._http.request("PATCH", f"/v1/groups/{group_id}", body={"name": name})
|
|
318
|
+
|
|
319
|
+
def delete(self, group_id: str) -> dict:
|
|
320
|
+
"""Delete a group (its jobs are ungrouped, not deleted)."""
|
|
321
|
+
return self._http.request("DELETE", f"/v1/groups/{group_id}")
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
class _Variables:
|
|
325
|
+
def __init__(self, http: _Http):
|
|
326
|
+
self._http = http
|
|
327
|
+
|
|
328
|
+
def list(self, group_id: Optional[str] = None) -> dict:
|
|
329
|
+
"""List variables. Secret values come back as ``None`` (write-only)."""
|
|
330
|
+
return self._http.request("GET", "/v1/variables", query={"group_id": group_id})
|
|
331
|
+
|
|
332
|
+
def set(self, name: str, value: str, is_secret: bool = False,
|
|
333
|
+
group_id: Optional[str] = None) -> dict:
|
|
334
|
+
"""Create or update a variable by name. A secret value is sealed at rest and
|
|
335
|
+
can never be read back."""
|
|
336
|
+
return self._http.request("PUT", "/v1/variables", body={
|
|
337
|
+
"name": name, "value": value, "is_secret": is_secret, "group_id": group_id,
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
def delete(self, name: str, group_id: Optional[str] = None) -> dict:
|
|
341
|
+
return self._http.request("DELETE", f"/v1/variables/{urllib.parse.quote(name)}",
|
|
342
|
+
query={"group_id": group_id})
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
class _Runs:
|
|
346
|
+
def __init__(self, http: _Http):
|
|
347
|
+
self._http = http
|
|
348
|
+
|
|
349
|
+
def list(self, status: str, since: Optional[str] = None, job: Optional[str] = None,
|
|
350
|
+
page: Optional[int] = None, limit: Optional[int] = None) -> dict:
|
|
351
|
+
"""Account-wide failed/deferred feed ("what's broken everywhere?").
|
|
352
|
+
|
|
353
|
+
``status`` is required (``failed`` or ``deferred``); there is no success feed —
|
|
354
|
+
use ``jobs.logs(id, status="success")`` for one job. ``since`` defaults to 24h,
|
|
355
|
+
hard-capped at 7d. No ``total`` is returned (cursor pagination).
|
|
356
|
+
"""
|
|
357
|
+
return self._http.request("GET", "/v1/runs", query={
|
|
358
|
+
"status": status, "since": since, "job": job, "page": page, "limit": limit,
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
class _Metrics:
|
|
363
|
+
def __init__(self, http: _Http):
|
|
364
|
+
self._http = http
|
|
365
|
+
|
|
366
|
+
def get(self, window: Optional[str] = None) -> dict:
|
|
367
|
+
"""Daily monitoring rollups (default 30d; clamped to plan retention). ``window``
|
|
368
|
+
one of 24h|48h|7d|30d|60d|90d. Series is a fixed small size (<=90 daily points)."""
|
|
369
|
+
return self._http.request("GET", "/v1/metrics", query={"window": window})
|
|
370
|
+
|
|
371
|
+
|
|
258
372
|
class _Usage:
|
|
259
373
|
def __init__(self, http: _Http):
|
|
260
374
|
self._http = http
|
|
@@ -271,6 +385,10 @@ class Netsware:
|
|
|
271
385
|
http = _Http(api_key, base_url, timeout)
|
|
272
386
|
self.hours = _Hours(http)
|
|
273
387
|
self.jobs = _Jobs(http)
|
|
388
|
+
self.groups = _Groups(http)
|
|
389
|
+
self.variables = _Variables(http)
|
|
390
|
+
self.runs = _Runs(http)
|
|
391
|
+
self.metrics = _Metrics(http)
|
|
274
392
|
self.webhooks = _Webhooks(http)
|
|
275
393
|
self.usage = _Usage(http)
|
|
276
394
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: netsware-sdk
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Official Netsware SDK — Business Hours + Scheduled Jobs APIs
|
|
5
5
|
Author: Netsware Systems LLP
|
|
6
6
|
License: MIT
|
|
@@ -74,6 +74,28 @@ if not ok:
|
|
|
74
74
|
... # reject
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
## Groups, variables, runs & metrics
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
# Organize jobs into groups
|
|
81
|
+
g = client.groups.create("Nightly")
|
|
82
|
+
client.groups.rename(g["id"], "Nightly batch")
|
|
83
|
+
|
|
84
|
+
# Reusable values + secrets (secret values are WRITE-ONLY: list() returns value=None)
|
|
85
|
+
client.variables.set("API_BASE_URL", "https://api.acme.io")
|
|
86
|
+
client.variables.set("API_TOKEN", "t0ken", is_secret=True)
|
|
87
|
+
|
|
88
|
+
# What's broken everywhere? (status is required; success has no account-wide feed)
|
|
89
|
+
failing = client.runs.list(status="failed", since="24h")
|
|
90
|
+
|
|
91
|
+
# Per-job history filtered by outcome (retention-clamped)
|
|
92
|
+
errs = client.jobs.logs(job["id"], status="failed")
|
|
93
|
+
|
|
94
|
+
# Daily monitoring rollups for your own NOC/monitor (default 30d, plan-clamped)
|
|
95
|
+
m = client.metrics.get(window="30d")
|
|
96
|
+
print(m["totals"]["runs"], m["current"]["active_jobs"])
|
|
97
|
+
```
|
|
98
|
+
|
|
77
99
|
## Configuration
|
|
78
100
|
|
|
79
101
|
```python
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|