querykey-cases 0.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.
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: querykey-cases
3
+ Version: 0.1.0
4
+ Summary: Python client for QueryKey Cases HTTP API
5
+ Author: QueryKey Cases Engineering
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://querykey.com/developers/
8
+ Project-URL: Documentation, https://querykey.com/developers/
9
+ Project-URL: Repository, https://github.com/RellWilson/querykey-cases
10
+ Project-URL: Issues, https://github.com/RellWilson/querykey-cases/issues
11
+ Keywords: querykey,cases,api,sdk,troubleshooting
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest; extra == "dev"
23
+ Provides-Extra: publish
24
+ Requires-Dist: build; extra == "publish"
25
+ Requires-Dist: twine; extra == "publish"
26
+
27
+ # querykey-cases (Python)
28
+
29
+ ```bash
30
+ pip install querykey-cases
31
+ ```
32
+
33
+ ```python
34
+ from querykey_cases import QueryKeyClient
35
+
36
+ client = QueryKeyClient(base_url="https://api.querykey.com")
37
+ print(client.search_cases(q="TypeError", limit=5))
38
+ ```
39
+
40
+ Environment: `QKEY_API_BASE`, `QKEY_API_KEY`.
41
+
42
+ Local development:
43
+
44
+ ```bash
45
+ pip install -e ./packages/querykey-cases-py
46
+ ```
47
+
48
+ Release workflow:
49
+
50
+ ```bash
51
+ python3 -m pip install --upgrade build twine
52
+ python3 -m build
53
+ python3 -m twine check dist/*
54
+ python3 -m twine upload dist/*
55
+ ```
56
+
57
+ Notes:
58
+
59
+ - Python 3.10+
60
+ - `timeout_seconds` defaults to `10`
61
+ - `QueryKeyError` includes HTTP status and parsed error payload when available
@@ -0,0 +1,35 @@
1
+ # querykey-cases (Python)
2
+
3
+ ```bash
4
+ pip install querykey-cases
5
+ ```
6
+
7
+ ```python
8
+ from querykey_cases import QueryKeyClient
9
+
10
+ client = QueryKeyClient(base_url="https://api.querykey.com")
11
+ print(client.search_cases(q="TypeError", limit=5))
12
+ ```
13
+
14
+ Environment: `QKEY_API_BASE`, `QKEY_API_KEY`.
15
+
16
+ Local development:
17
+
18
+ ```bash
19
+ pip install -e ./packages/querykey-cases-py
20
+ ```
21
+
22
+ Release workflow:
23
+
24
+ ```bash
25
+ python3 -m pip install --upgrade build twine
26
+ python3 -m build
27
+ python3 -m twine check dist/*
28
+ python3 -m twine upload dist/*
29
+ ```
30
+
31
+ Notes:
32
+
33
+ - Python 3.10+
34
+ - `timeout_seconds` defaults to `10`
35
+ - `QueryKeyError` includes HTTP status and parsed error payload when available
@@ -0,0 +1,38 @@
1
+ [project]
2
+ name = "querykey-cases"
3
+ version = "0.1.0"
4
+ description = "Python client for QueryKey Cases HTTP API"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = "Apache-2.0"
8
+ authors = [
9
+ { name = "QueryKey Cases Engineering" }
10
+ ]
11
+ keywords = ["querykey", "cases", "api", "sdk", "troubleshooting"]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Developers",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.10",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Topic :: Software Development :: Libraries :: Python Modules"
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://querykey.com/developers/"
24
+ Documentation = "https://querykey.com/developers/"
25
+ Repository = "https://github.com/RellWilson/querykey-cases"
26
+ Issues = "https://github.com/RellWilson/querykey-cases/issues"
27
+
28
+ [project.optional-dependencies]
29
+ dev = ["pytest"]
30
+ publish = ["build", "twine"]
31
+
32
+ [build-system]
33
+ requires = ["setuptools>=68"]
34
+ build-backend = "setuptools.build_meta"
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["."]
38
+ include = ["querykey_cases*"]
@@ -0,0 +1,3 @@
1
+ from querykey_cases.client import QueryKeyClient, QueryKeyError
2
+
3
+ __all__ = ["QueryKeyClient", "QueryKeyError"]
@@ -0,0 +1,86 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import os
5
+ import urllib.error
6
+ import urllib.parse
7
+ import urllib.request
8
+ from typing import Any, Mapping, MutableMapping, Optional
9
+
10
+ DEFAULT_BASE_URL = "https://api.querykey.com"
11
+ DEFAULT_TIMEOUT_SECONDS = 10
12
+
13
+
14
+ class QueryKeyError(RuntimeError):
15
+ def __init__(self, message: str, *, status: Optional[int] = None, data: Any = None) -> None:
16
+ super().__init__(message)
17
+ self.status = status
18
+ self.data = data
19
+
20
+
21
+ def _require_non_empty(value: str, field_name: str) -> str:
22
+ normalized = str(value or "").strip()
23
+ if not normalized:
24
+ raise ValueError(f"{field_name} must be a non-empty string.")
25
+ return normalized
26
+
27
+
28
+ def _require_positive_int(value: int, field_name: str) -> int:
29
+ normalized = int(value)
30
+ if normalized <= 0:
31
+ raise ValueError(f"{field_name} must be a positive integer.")
32
+ return normalized
33
+
34
+
35
+ class QueryKeyClient:
36
+ def __init__(
37
+ self,
38
+ base_url: Optional[str] = None,
39
+ api_key: Optional[str] = None,
40
+ timeout_seconds: int = DEFAULT_TIMEOUT_SECONDS,
41
+ ) -> None:
42
+ self.base_url = (base_url or os.environ.get("QKEY_API_BASE") or DEFAULT_BASE_URL).rstrip("/")
43
+ self.api_key = api_key or os.environ.get("QKEY_API_KEY") or ""
44
+ self.timeout_seconds = _require_positive_int(timeout_seconds, "timeout_seconds")
45
+
46
+ def _request(
47
+ self,
48
+ method: str,
49
+ path: str,
50
+ body: Optional[Mapping[str, Any]] = None,
51
+ ) -> Any:
52
+ url = f"{self.base_url}{path}"
53
+ headers: MutableMapping[str, str] = {"Accept": "application/json"}
54
+ if self.api_key:
55
+ headers["Authorization"] = f"Bearer {self.api_key}"
56
+ data: Optional[bytes] = None
57
+ if body is not None:
58
+ headers["Content-Type"] = "application/json"
59
+ data = json.dumps(body).encode("utf-8")
60
+ req = urllib.request.Request(url, data=data, headers=headers, method=method)
61
+ try:
62
+ with urllib.request.urlopen(req, timeout=self.timeout_seconds) as resp:
63
+ raw = resp.read().decode("utf-8")
64
+ return json.loads(raw) if raw else {}
65
+ except urllib.error.HTTPError as e:
66
+ payload = e.read().decode("utf-8")
67
+ try:
68
+ detail = json.loads(payload)
69
+ except json.JSONDecodeError:
70
+ detail = {"message": payload or str(e)}
71
+ raise QueryKeyError(detail.get("message", str(e)), status=e.code, data=detail) from e
72
+ except urllib.error.URLError as e:
73
+ raise QueryKeyError(str(e.reason) or str(e)) from e
74
+
75
+ def search_cases(self, q: str = "", limit: int = 5, page: int = 1) -> Any:
76
+ limit_value = _require_positive_int(limit, "limit")
77
+ page_value = _require_positive_int(page, "page")
78
+ qs = urllib.parse.urlencode({"q": q, "limit": limit_value, "page": page_value})
79
+ return self._request("GET", f"/api/v1/cases?{qs}")
80
+
81
+ def get_case(self, case_id: str) -> Any:
82
+ enc = urllib.parse.quote(_require_non_empty(case_id, "case_id"), safe="")
83
+ return self._request("GET", f"/api/v1/cases/{enc}")
84
+
85
+ def bootstrap_start(self) -> Any:
86
+ return self._request("POST", "/api/v1/bootstrap/start")
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: querykey-cases
3
+ Version: 0.1.0
4
+ Summary: Python client for QueryKey Cases HTTP API
5
+ Author: QueryKey Cases Engineering
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://querykey.com/developers/
8
+ Project-URL: Documentation, https://querykey.com/developers/
9
+ Project-URL: Repository, https://github.com/RellWilson/querykey-cases
10
+ Project-URL: Issues, https://github.com/RellWilson/querykey-cases/issues
11
+ Keywords: querykey,cases,api,sdk,troubleshooting
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest; extra == "dev"
23
+ Provides-Extra: publish
24
+ Requires-Dist: build; extra == "publish"
25
+ Requires-Dist: twine; extra == "publish"
26
+
27
+ # querykey-cases (Python)
28
+
29
+ ```bash
30
+ pip install querykey-cases
31
+ ```
32
+
33
+ ```python
34
+ from querykey_cases import QueryKeyClient
35
+
36
+ client = QueryKeyClient(base_url="https://api.querykey.com")
37
+ print(client.search_cases(q="TypeError", limit=5))
38
+ ```
39
+
40
+ Environment: `QKEY_API_BASE`, `QKEY_API_KEY`.
41
+
42
+ Local development:
43
+
44
+ ```bash
45
+ pip install -e ./packages/querykey-cases-py
46
+ ```
47
+
48
+ Release workflow:
49
+
50
+ ```bash
51
+ python3 -m pip install --upgrade build twine
52
+ python3 -m build
53
+ python3 -m twine check dist/*
54
+ python3 -m twine upload dist/*
55
+ ```
56
+
57
+ Notes:
58
+
59
+ - Python 3.10+
60
+ - `timeout_seconds` defaults to `10`
61
+ - `QueryKeyError` includes HTTP status and parsed error payload when available
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ querykey_cases/__init__.py
4
+ querykey_cases/client.py
5
+ querykey_cases.egg-info/PKG-INFO
6
+ querykey_cases.egg-info/SOURCES.txt
7
+ querykey_cases.egg-info/dependency_links.txt
8
+ querykey_cases.egg-info/requires.txt
9
+ querykey_cases.egg-info/top_level.txt
@@ -0,0 +1,7 @@
1
+
2
+ [dev]
3
+ pytest
4
+
5
+ [publish]
6
+ build
7
+ twine
@@ -0,0 +1 @@
1
+ querykey_cases
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+