netsware-sdk 2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: netsware-sdk
3
- Version: 2.0.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) -> dict:
216
- return self._http.request("GET", f"/v1/jobs/{job_id}/logs")
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}")
@@ -290,6 +299,76 @@ class _Webhooks:
290
299
  return self._http.request("GET", f"/v1/webhooks/{webhook_id}/deliveries")
291
300
 
292
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
+
293
372
  class _Usage:
294
373
  def __init__(self, http: _Http):
295
374
  self._http = http
@@ -306,6 +385,10 @@ class Netsware:
306
385
  http = _Http(api_key, base_url, timeout)
307
386
  self.hours = _Hours(http)
308
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)
309
392
  self.webhooks = _Webhooks(http)
310
393
  self.usage = _Usage(http)
311
394
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: netsware-sdk
3
- Version: 2.0.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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "netsware-sdk"
7
- version = "2.0.0"
7
+ version = "2.1.0"
8
8
  description = "Official Netsware SDK — Business Hours + Scheduled Jobs APIs"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
File without changes