netsware-sdk 2.1.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.1.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",
@@ -90,6 +97,8 @@ failing = client.runs.list(status="failed", since="24h")
90
97
 
91
98
  # Per-job history filtered by outcome (retention-clamped)
92
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
93
102
 
94
103
  # Daily monitoring rollups for your own NOC/monitor (default 30d, plan-clamped)
95
104
  m = client.metrics.get(window="30d")
@@ -102,6 +111,6 @@ print(m["totals"]["runs"], m["current"]["active_jobs"])
102
111
  client = Netsware("nw_live_xxx", base_url="https://app.netsware.com", timeout=30.0)
103
112
  ```
104
113
 
105
- Full API reference: <https://netsware.com/dashboard/docs>.
114
+ Full API reference: <https://netsware.com/docs>.
106
115
 
107
- MIT © Netsware Systems LLP
116
+ MIT © Netsware Cloud Solutions LLP
@@ -1,18 +1,6 @@
1
- Metadata-Version: 2.4
2
- Name: netsware-sdk
3
- Version: 2.1.0
4
- Summary: Official Netsware SDK — Business Hours + Scheduled Jobs APIs
5
- Author: Netsware Systems LLP
6
- License: MIT
7
- Project-URL: Homepage, https://netsware.com
8
- Project-URL: Documentation, https://netsware.com/dashboard/docs
9
- Keywords: netsware,business-hours,scheduled-jobs,webhooks,cron
10
- Requires-Python: >=3.8
11
- Description-Content-Type: text/markdown
12
-
13
1
  # netsware-sdk
14
2
 
15
- 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,
16
4
  Scheduled Jobs, and Webhooks. Pure standard library, no dependencies.
17
5
 
18
6
  ## Install
@@ -42,6 +30,13 @@ sched = client.hours.create_schedule(
42
30
  country="IN",
43
31
  )
44
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
+
45
40
  # Schedule a one-time job
46
41
  job = client.jobs.schedule(
47
42
  name="Send reminder",
@@ -90,6 +85,8 @@ failing = client.runs.list(status="failed", since="24h")
90
85
 
91
86
  # Per-job history filtered by outcome (retention-clamped)
92
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
93
90
 
94
91
  # Daily monitoring rollups for your own NOC/monitor (default 30d, plan-clamped)
95
92
  m = client.metrics.get(window="30d")
@@ -102,6 +99,6 @@ print(m["totals"]["runs"], m["current"]["active_jobs"])
102
99
  client = Netsware("nw_live_xxx", base_url="https://app.netsware.com", timeout=30.0)
103
100
  ```
104
101
 
105
- Full API reference: <https://netsware.com/dashboard/docs>.
102
+ Full API reference: <https://netsware.com/docs>.
106
103
 
107
- 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/2.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."""
@@ -224,6 +246,13 @@ class _Jobs:
224
246
  query = {"page": page, "limit": limit, "status": status}
225
247
  return self._http.request("GET", f"/v1/jobs/{job_id}/logs", query=query)
226
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}")
255
+
227
256
  def cancel(self, job_id: str) -> dict:
228
257
  return self._http.request("DELETE", f"/v1/jobs/{job_id}")
229
258
 
@@ -1,6 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: netsware-sdk
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
+ License: MIT
7
+ Project-URL: Homepage, https://netsware.com
8
+ Project-URL: Documentation, https://netsware.com/docs
9
+ Keywords: netsware,business-hours,scheduled-jobs,webhooks,cron
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+
1
13
  # netsware-sdk
2
14
 
3
- 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,
4
16
  Scheduled Jobs, and Webhooks. Pure standard library, no dependencies.
5
17
 
6
18
  ## Install
@@ -30,6 +42,13 @@ sched = client.hours.create_schedule(
30
42
  country="IN",
31
43
  )
32
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
+
33
52
  # Schedule a one-time job
34
53
  job = client.jobs.schedule(
35
54
  name="Send reminder",
@@ -78,6 +97,8 @@ failing = client.runs.list(status="failed", since="24h")
78
97
 
79
98
  # Per-job history filtered by outcome (retention-clamped)
80
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
81
102
 
82
103
  # Daily monitoring rollups for your own NOC/monitor (default 30d, plan-clamped)
83
104
  m = client.metrics.get(window="30d")
@@ -90,6 +111,6 @@ print(m["totals"]["runs"], m["current"]["active_jobs"])
90
111
  client = Netsware("nw_live_xxx", base_url="https://app.netsware.com", timeout=30.0)
91
112
  ```
92
113
 
93
- Full API reference: <https://netsware.com/dashboard/docs>.
114
+ Full API reference: <https://netsware.com/docs>.
94
115
 
95
- 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.1.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