netsware-sdk 2.0.0__tar.gz → 2.2.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,18 +1,18 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: netsware-sdk
3
- Version: 2.0.0
4
- Summary: Official Netsware SDK — Business Hours + Scheduled Jobs APIs
5
- Author: Netsware Systems LLP
3
+ Version: 2.2.0
4
+ Summary: Official Netsware SDK for the Business Hours and Scheduled Jobs APIs
5
+ Author: Netsware Cloud Solutions LLP
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://netsware.com
8
- Project-URL: Documentation, https://netsware.com/dashboard/docs
8
+ Project-URL: Documentation, https://netsware.com/docs
9
9
  Keywords: netsware,business-hours,scheduled-jobs,webhooks,cron
10
10
  Requires-Python: >=3.8
11
11
  Description-Content-Type: text/markdown
12
12
 
13
13
  # netsware-sdk
14
14
 
15
- Official Python SDK for the [Netsware](https://netsware.com) API — Business Hours,
15
+ Official Python SDK for the [Netsware](https://netsware.com) API: Business Hours,
16
16
  Scheduled Jobs, and Webhooks. Pure standard library, no dependencies.
17
17
 
18
18
  ## Install
@@ -42,6 +42,13 @@ sched = client.hours.create_schedule(
42
42
  country="IN",
43
43
  )
44
44
 
45
+ # Combine schedules, switch one off, list countries and regions
46
+ client.hours.schedule_stats() # {"schedules": {total, active, ...}}
47
+ client.hours.resolve_schedules([sched["id"], other_id], match="all") # open only if all are open
48
+ client.hours.set_schedule_active(sched["id"], False) # off, hours unchanged
49
+ client.hours.countries()
50
+ client.hours.regions("US")
51
+
45
52
  # Schedule a one-time job
46
53
  job = client.jobs.schedule(
47
54
  name="Send reminder",
@@ -74,12 +81,36 @@ if not ok:
74
81
  ... # reject
75
82
  ```
76
83
 
84
+ ## Groups, variables, runs & metrics
85
+
86
+ ```python
87
+ # Organize jobs into groups
88
+ g = client.groups.create("Nightly")
89
+ client.groups.rename(g["id"], "Nightly batch")
90
+
91
+ # Reusable values + secrets (secret values are WRITE-ONLY: list() returns value=None)
92
+ client.variables.set("API_BASE_URL", "https://api.acme.io")
93
+ client.variables.set("API_TOKEN", "t0ken", is_secret=True)
94
+
95
+ # What's broken everywhere? (status is required; success has no account-wide feed)
96
+ failing = client.runs.list(status="failed", since="24h")
97
+
98
+ # Per-job history filtered by outcome (retention-clamped)
99
+ errs = client.jobs.logs(job["id"], status="failed")
100
+ if errs["logs"] and errs["logs"][0].get("run_id"):
101
+ run = client.jobs.run(job["id"], errs["logs"][0]["run_id"]) # one run, every attempt
102
+
103
+ # Daily monitoring rollups for your own NOC/monitor (default 30d, plan-clamped)
104
+ m = client.metrics.get(window="30d")
105
+ print(m["totals"]["runs"], m["current"]["active_jobs"])
106
+ ```
107
+
77
108
  ## Configuration
78
109
 
79
110
  ```python
80
111
  client = Netsware("nw_live_xxx", base_url="https://app.netsware.com", timeout=30.0)
81
112
  ```
82
113
 
83
- Full API reference: <https://netsware.com/dashboard/docs>.
114
+ Full API reference: <https://netsware.com/docs>.
84
115
 
85
- MIT © Netsware Systems LLP
116
+ MIT © Netsware Cloud Solutions LLP
@@ -1,6 +1,6 @@
1
1
  # netsware-sdk
2
2
 
3
- Official Python SDK for the [Netsware](https://netsware.com) API — Business Hours,
3
+ Official Python SDK for the [Netsware](https://netsware.com) API: Business Hours,
4
4
  Scheduled Jobs, and Webhooks. Pure standard library, no dependencies.
5
5
 
6
6
  ## Install
@@ -30,6 +30,13 @@ sched = client.hours.create_schedule(
30
30
  country="IN",
31
31
  )
32
32
 
33
+ # Combine schedules, switch one off, list countries and regions
34
+ client.hours.schedule_stats() # {"schedules": {total, active, ...}}
35
+ client.hours.resolve_schedules([sched["id"], other_id], match="all") # open only if all are open
36
+ client.hours.set_schedule_active(sched["id"], False) # off, hours unchanged
37
+ client.hours.countries()
38
+ client.hours.regions("US")
39
+
33
40
  # Schedule a one-time job
34
41
  job = client.jobs.schedule(
35
42
  name="Send reminder",
@@ -62,12 +69,36 @@ if not ok:
62
69
  ... # reject
63
70
  ```
64
71
 
72
+ ## Groups, variables, runs & metrics
73
+
74
+ ```python
75
+ # Organize jobs into groups
76
+ g = client.groups.create("Nightly")
77
+ client.groups.rename(g["id"], "Nightly batch")
78
+
79
+ # Reusable values + secrets (secret values are WRITE-ONLY: list() returns value=None)
80
+ client.variables.set("API_BASE_URL", "https://api.acme.io")
81
+ client.variables.set("API_TOKEN", "t0ken", is_secret=True)
82
+
83
+ # What's broken everywhere? (status is required; success has no account-wide feed)
84
+ failing = client.runs.list(status="failed", since="24h")
85
+
86
+ # Per-job history filtered by outcome (retention-clamped)
87
+ errs = client.jobs.logs(job["id"], status="failed")
88
+ if errs["logs"] and errs["logs"][0].get("run_id"):
89
+ run = client.jobs.run(job["id"], errs["logs"][0]["run_id"]) # one run, every attempt
90
+
91
+ # Daily monitoring rollups for your own NOC/monitor (default 30d, plan-clamped)
92
+ m = client.metrics.get(window="30d")
93
+ print(m["totals"]["runs"], m["current"]["active_jobs"])
94
+ ```
95
+
65
96
  ## Configuration
66
97
 
67
98
  ```python
68
99
  client = Netsware("nw_live_xxx", base_url="https://app.netsware.com", timeout=30.0)
69
100
  ```
70
101
 
71
- Full API reference: <https://netsware.com/dashboard/docs>.
102
+ Full API reference: <https://netsware.com/docs>.
72
103
 
73
- MIT © Netsware Systems LLP
104
+ MIT © Netsware Cloud Solutions LLP
@@ -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.2.0")
74
74
  try:
75
75
  with urllib.request.urlopen(req, timeout=self._timeout) as resp:
76
76
  raw = resp.read().decode()
@@ -151,6 +151,28 @@ class _Hours:
151
151
  return self._http.request("DELETE", f"/v1/hours/schedules/{schedule_id}",
152
152
  query={"permanent": "true" if permanent else None})
153
153
 
154
+ def schedule_stats(self) -> dict:
155
+ """Count the API key's schedules by state: {"schedules": {total, active, disabled, deleted}}."""
156
+ return self._http.request("GET", "/v1/hours/schedules/stats")
157
+
158
+ def resolve_schedules(self, schedule_ids: List[str], match: Optional[str] = None) -> dict:
159
+ """Combine several schedules: is ANY (default) or are ALL ("all") of them open now?"""
160
+ return self._http.request("GET", "/v1/hours/schedules/resolve",
161
+ query={"schedule_ids": ",".join(schedule_ids), "match": match})
162
+
163
+ def set_schedule_active(self, schedule_id: str, is_active: bool) -> dict:
164
+ """Turn a schedule on (True) or off (False) without changing its hours."""
165
+ return self._http.request("PUT", f"/v1/hours/schedules/{schedule_id}/active",
166
+ body={"is_active": is_active})
167
+
168
+ def countries(self) -> dict:
169
+ """Supported countries with their timezones and weekend days (0 = Sunday ... 6 = Saturday)."""
170
+ return self._http.request("GET", "/v1/hours/meta/countries")
171
+
172
+ def regions(self, country: str) -> dict:
173
+ """States/regions of a country, for region and regions[]."""
174
+ return self._http.request("GET", "/v1/hours/meta/regions", query={"country": country})
175
+
154
176
  def holidays(self, country: str, year: int, region: Optional[str] = None,
155
177
  type: Optional[str] = None) -> Any:
156
178
  """List public holidays. ``region`` for state-level calendars; ``type`` to filter."""
@@ -212,8 +234,24 @@ class _Jobs:
212
234
  def stats(self) -> dict:
213
235
  return self._http.request("GET", "/v1/jobs/stats")
214
236
 
215
- def logs(self, job_id: str) -> dict:
216
- return self._http.request("GET", f"/v1/jobs/{job_id}/logs")
237
+ def logs(self, job_id: str, page: Optional[int] = None, limit: Optional[int] = None,
238
+ status: Optional[str] = None) -> dict:
239
+ """Execution logs for a job (newest first), paginated.
240
+
241
+ Optional ``status`` filter (``success``/``failed``/``timeout``); the window is
242
+ clamped to your plan retention and each row carries retry detail
243
+ (``attempt_number``/``max_attempts``). Returns a flat
244
+ ``{"logs": [...], "pagination": {...}}`` — ``logs`` is always a list.
245
+ """
246
+ query = {"page": page, "limit": limit, "status": status}
247
+ return self._http.request("GET", f"/v1/jobs/{job_id}/logs", query=query)
248
+
249
+ def run(self, job_id: str, run_id: str) -> dict:
250
+ """One run in detail, with every attempt. ``run_id`` is the run UUID from the logs.
251
+
252
+ 404 if the run is older than your plan's history window.
253
+ """
254
+ return self._http.request("GET", f"/v1/jobs/{job_id}/runs/{run_id}")
217
255
 
218
256
  def cancel(self, job_id: str) -> dict:
219
257
  return self._http.request("DELETE", f"/v1/jobs/{job_id}")
@@ -290,6 +328,76 @@ class _Webhooks:
290
328
  return self._http.request("GET", f"/v1/webhooks/{webhook_id}/deliveries")
291
329
 
292
330
 
331
+ class _Groups:
332
+ def __init__(self, http: _Http):
333
+ self._http = http
334
+
335
+ def list(self, page: Optional[int] = None, limit: Optional[int] = None) -> dict:
336
+ """List groups (paginated)."""
337
+ return self._http.request("GET", "/v1/groups", query={"page": page, "limit": limit})
338
+
339
+ def get(self, group_id: str) -> dict:
340
+ return self._http.request("GET", f"/v1/groups/{group_id}")
341
+
342
+ def create(self, name: str) -> dict:
343
+ return self._http.request("POST", "/v1/groups", body={"name": name})
344
+
345
+ def rename(self, group_id: str, name: str) -> dict:
346
+ return self._http.request("PATCH", f"/v1/groups/{group_id}", body={"name": name})
347
+
348
+ def delete(self, group_id: str) -> dict:
349
+ """Delete a group (its jobs are ungrouped, not deleted)."""
350
+ return self._http.request("DELETE", f"/v1/groups/{group_id}")
351
+
352
+
353
+ class _Variables:
354
+ def __init__(self, http: _Http):
355
+ self._http = http
356
+
357
+ def list(self, group_id: Optional[str] = None) -> dict:
358
+ """List variables. Secret values come back as ``None`` (write-only)."""
359
+ return self._http.request("GET", "/v1/variables", query={"group_id": group_id})
360
+
361
+ def set(self, name: str, value: str, is_secret: bool = False,
362
+ group_id: Optional[str] = None) -> dict:
363
+ """Create or update a variable by name. A secret value is sealed at rest and
364
+ can never be read back."""
365
+ return self._http.request("PUT", "/v1/variables", body={
366
+ "name": name, "value": value, "is_secret": is_secret, "group_id": group_id,
367
+ })
368
+
369
+ def delete(self, name: str, group_id: Optional[str] = None) -> dict:
370
+ return self._http.request("DELETE", f"/v1/variables/{urllib.parse.quote(name)}",
371
+ query={"group_id": group_id})
372
+
373
+
374
+ class _Runs:
375
+ def __init__(self, http: _Http):
376
+ self._http = http
377
+
378
+ def list(self, status: str, since: Optional[str] = None, job: Optional[str] = None,
379
+ page: Optional[int] = None, limit: Optional[int] = None) -> dict:
380
+ """Account-wide failed/deferred feed ("what's broken everywhere?").
381
+
382
+ ``status`` is required (``failed`` or ``deferred``); there is no success feed —
383
+ use ``jobs.logs(id, status="success")`` for one job. ``since`` defaults to 24h,
384
+ hard-capped at 7d. No ``total`` is returned (cursor pagination).
385
+ """
386
+ return self._http.request("GET", "/v1/runs", query={
387
+ "status": status, "since": since, "job": job, "page": page, "limit": limit,
388
+ })
389
+
390
+
391
+ class _Metrics:
392
+ def __init__(self, http: _Http):
393
+ self._http = http
394
+
395
+ def get(self, window: Optional[str] = None) -> dict:
396
+ """Daily monitoring rollups (default 30d; clamped to plan retention). ``window``
397
+ one of 24h|48h|7d|30d|60d|90d. Series is a fixed small size (<=90 daily points)."""
398
+ return self._http.request("GET", "/v1/metrics", query={"window": window})
399
+
400
+
293
401
  class _Usage:
294
402
  def __init__(self, http: _Http):
295
403
  self._http = http
@@ -306,6 +414,10 @@ class Netsware:
306
414
  http = _Http(api_key, base_url, timeout)
307
415
  self.hours = _Hours(http)
308
416
  self.jobs = _Jobs(http)
417
+ self.groups = _Groups(http)
418
+ self.variables = _Variables(http)
419
+ self.runs = _Runs(http)
420
+ self.metrics = _Metrics(http)
309
421
  self.webhooks = _Webhooks(http)
310
422
  self.usage = _Usage(http)
311
423
 
@@ -1,18 +1,18 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: netsware-sdk
3
- Version: 2.0.0
4
- Summary: Official Netsware SDK — Business Hours + Scheduled Jobs APIs
5
- Author: Netsware Systems LLP
3
+ Version: 2.2.0
4
+ Summary: Official Netsware SDK for the Business Hours and Scheduled Jobs APIs
5
+ Author: Netsware Cloud Solutions LLP
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://netsware.com
8
- Project-URL: Documentation, https://netsware.com/dashboard/docs
8
+ Project-URL: Documentation, https://netsware.com/docs
9
9
  Keywords: netsware,business-hours,scheduled-jobs,webhooks,cron
10
10
  Requires-Python: >=3.8
11
11
  Description-Content-Type: text/markdown
12
12
 
13
13
  # netsware-sdk
14
14
 
15
- Official Python SDK for the [Netsware](https://netsware.com) API — Business Hours,
15
+ Official Python SDK for the [Netsware](https://netsware.com) API: Business Hours,
16
16
  Scheduled Jobs, and Webhooks. Pure standard library, no dependencies.
17
17
 
18
18
  ## Install
@@ -42,6 +42,13 @@ sched = client.hours.create_schedule(
42
42
  country="IN",
43
43
  )
44
44
 
45
+ # Combine schedules, switch one off, list countries and regions
46
+ client.hours.schedule_stats() # {"schedules": {total, active, ...}}
47
+ client.hours.resolve_schedules([sched["id"], other_id], match="all") # open only if all are open
48
+ client.hours.set_schedule_active(sched["id"], False) # off, hours unchanged
49
+ client.hours.countries()
50
+ client.hours.regions("US")
51
+
45
52
  # Schedule a one-time job
46
53
  job = client.jobs.schedule(
47
54
  name="Send reminder",
@@ -74,12 +81,36 @@ if not ok:
74
81
  ... # reject
75
82
  ```
76
83
 
84
+ ## Groups, variables, runs & metrics
85
+
86
+ ```python
87
+ # Organize jobs into groups
88
+ g = client.groups.create("Nightly")
89
+ client.groups.rename(g["id"], "Nightly batch")
90
+
91
+ # Reusable values + secrets (secret values are WRITE-ONLY: list() returns value=None)
92
+ client.variables.set("API_BASE_URL", "https://api.acme.io")
93
+ client.variables.set("API_TOKEN", "t0ken", is_secret=True)
94
+
95
+ # What's broken everywhere? (status is required; success has no account-wide feed)
96
+ failing = client.runs.list(status="failed", since="24h")
97
+
98
+ # Per-job history filtered by outcome (retention-clamped)
99
+ errs = client.jobs.logs(job["id"], status="failed")
100
+ if errs["logs"] and errs["logs"][0].get("run_id"):
101
+ run = client.jobs.run(job["id"], errs["logs"][0]["run_id"]) # one run, every attempt
102
+
103
+ # Daily monitoring rollups for your own NOC/monitor (default 30d, plan-clamped)
104
+ m = client.metrics.get(window="30d")
105
+ print(m["totals"]["runs"], m["current"]["active_jobs"])
106
+ ```
107
+
77
108
  ## Configuration
78
109
 
79
110
  ```python
80
111
  client = Netsware("nw_live_xxx", base_url="https://app.netsware.com", timeout=30.0)
81
112
  ```
82
113
 
83
- Full API reference: <https://netsware.com/dashboard/docs>.
114
+ Full API reference: <https://netsware.com/docs>.
84
115
 
85
- MIT © Netsware Systems LLP
116
+ MIT © Netsware Cloud Solutions LLP
@@ -4,18 +4,18 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "netsware-sdk"
7
- version = "2.0.0"
8
- description = "Official Netsware SDK — Business Hours + Scheduled Jobs APIs"
7
+ version = "2.2.0"
8
+ description = "Official Netsware SDK for the Business Hours and Scheduled Jobs APIs"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
11
11
  license = { text = "MIT" }
12
- authors = [{ name = "Netsware Systems LLP" }]
12
+ authors = [{ name = "Netsware Cloud Solutions LLP" }]
13
13
  keywords = ["netsware", "business-hours", "scheduled-jobs", "webhooks", "cron"]
14
14
  dependencies = []
15
15
 
16
16
  [project.urls]
17
17
  Homepage = "https://netsware.com"
18
- Documentation = "https://netsware.com/dashboard/docs"
18
+ Documentation = "https://netsware.com/docs"
19
19
 
20
20
  [tool.setuptools.packages.find]
21
21
  include = ["netsware*"]
File without changes