konecty-sdk-python 2.1.0__tar.gz → 2.1.2__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.
- konecty_sdk_python-2.1.2/KonectySdkPython/lib/exceptions.py +42 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/auth.py +34 -5
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/PKG-INFO +22 -2
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/README.md +21 -1
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/pyproject.toml +1 -1
- konecty_sdk_python-2.1.0/KonectySdkPython/lib/exceptions.py +0 -26
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/.gitignore +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/__init__.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/cli/__init__.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/cli/apply.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/cli/backup.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/cli/pull.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/__init__.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/client.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/feature_types/__init__.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/feature_types/cross_module_query.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/feature_types/kpi.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/feature_types/query_json.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/file_manager.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/filters.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/http.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/model.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/serialization.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/__init__.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/aggregation.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/base.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/change_user.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/comments.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/export.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/files.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/notifications.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/query.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/stream.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/subscriptions.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/settings.py +0 -0
- {konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/types.py +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Exceptions for the Konecty SDK."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class KonectyError(Exception):
|
|
5
|
+
"""Base exception for Konecty errors."""
|
|
6
|
+
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class KonectyAPIError(KonectyError):
|
|
11
|
+
"""Raised when the API returns success=false or a non-2xx status."""
|
|
12
|
+
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class KonectyGoogleSessionError(KonectyAPIError):
|
|
17
|
+
"""
|
|
18
|
+
Raised by exchange_google_code. Carries the machine-readable ``code`` from
|
|
19
|
+
``errors[0].code`` so callers can branch or translate without parsing the
|
|
20
|
+
message; ``failed`` covers unreadable or unrecognised bodies.
|
|
21
|
+
|
|
22
|
+
Subclasses KonectyAPIError so existing ``except KonectyAPIError`` keeps working.
|
|
23
|
+
|
|
24
|
+
Mirrors KonectyGoogleSessionError in the TypeScript SDK — keep both in sync.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, code: str, message: str) -> None:
|
|
28
|
+
super().__init__(message)
|
|
29
|
+
self.code = code
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class KonectyValidationError(KonectyError):
|
|
33
|
+
"""Raised for validation errors."""
|
|
34
|
+
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class KonectySerializationError(KonectyError):
|
|
39
|
+
"""Raised when a value is not serializable."""
|
|
40
|
+
|
|
41
|
+
def __init__(self) -> None:
|
|
42
|
+
super().__init__("Tipo não serializável")
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from typing import Any, Dict, Optional, Union
|
|
4
4
|
from urllib.parse import quote, urlencode
|
|
5
5
|
|
|
6
|
-
from ..exceptions import KonectyAPIError
|
|
6
|
+
from ..exceptions import KonectyAPIError, KonectyGoogleSessionError
|
|
7
7
|
from .base import BaseService
|
|
8
8
|
|
|
9
9
|
GOOGLE_START_PATH = "/api/auth/google/start"
|
|
@@ -15,6 +15,29 @@ GOOGLE_SESSION_PATH = "/api/auth/google/session"
|
|
|
15
15
|
LOGIN_OPTIONS_PATH = "/api/auth/login-options"
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
_GOOGLE_SESSION_ERROR_CODES = (
|
|
19
|
+
"invalid_code",
|
|
20
|
+
"expired_code",
|
|
21
|
+
"user_not_found",
|
|
22
|
+
"user_inactive",
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _first_error_code(error: KonectyAPIError) -> str:
|
|
27
|
+
"""
|
|
28
|
+
Extract the first recognised ``errors[].code``; ``failed`` when there is none.
|
|
29
|
+
|
|
30
|
+
Same set and same fallback as the TypeScript SDK, so both raise the same code
|
|
31
|
+
for the same response.
|
|
32
|
+
"""
|
|
33
|
+
errors = error.args[0] if error.args else None
|
|
34
|
+
if isinstance(errors, list):
|
|
35
|
+
for item in errors:
|
|
36
|
+
if isinstance(item, dict) and item.get("code") in _GOOGLE_SESSION_ERROR_CODES:
|
|
37
|
+
return str(item["code"])
|
|
38
|
+
return "failed"
|
|
39
|
+
|
|
40
|
+
|
|
18
41
|
def _first_error_message(error: KonectyAPIError) -> str:
|
|
19
42
|
"""Extract errors[0].message from a KonectyAPIError raised by the HTTP layer."""
|
|
20
43
|
errors = error.args[0] if error.args else None
|
|
@@ -74,8 +97,10 @@ class AuthService(BaseService):
|
|
|
74
97
|
POST /api/auth/google/session. Exchanges the single-use code (TTL 60s) for a session.
|
|
75
98
|
|
|
76
99
|
On success the returned authId is adopted by the client, so following requests
|
|
77
|
-
are authenticated. On error raises
|
|
78
|
-
|
|
100
|
+
are authenticated. On error raises KonectyGoogleSessionError — errors[0].message
|
|
101
|
+
as the message plus the machine-readable ``code`` — and leaves the client
|
|
102
|
+
authentication state untouched. The error subclasses KonectyAPIError, so callers
|
|
103
|
+
catching that keep working.
|
|
79
104
|
"""
|
|
80
105
|
payload: Dict[str, Any] = {"code": code}
|
|
81
106
|
if geolocation is not None:
|
|
@@ -90,11 +115,15 @@ class AuthService(BaseService):
|
|
|
90
115
|
try:
|
|
91
116
|
response = await self._post(GOOGLE_SESSION_PATH, json=payload)
|
|
92
117
|
except KonectyAPIError as error:
|
|
93
|
-
raise
|
|
118
|
+
raise KonectyGoogleSessionError(
|
|
119
|
+
_first_error_code(error), _first_error_message(error)
|
|
120
|
+
) from error
|
|
94
121
|
|
|
95
122
|
auth_id = response.get("authId") if isinstance(response, dict) else None
|
|
96
123
|
if not isinstance(auth_id, str) or not auth_id:
|
|
97
|
-
raise
|
|
124
|
+
raise KonectyGoogleSessionError(
|
|
125
|
+
"failed", "Google session response has no authId"
|
|
126
|
+
)
|
|
98
127
|
|
|
99
128
|
self._client.set_auth_id(auth_id)
|
|
100
129
|
return response
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: konecty_sdk_python
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.2
|
|
4
4
|
Summary: Konecty SDK Python
|
|
5
5
|
Author-email: Leonardo Leal <leonardo.leal@konecty.com>, Derotino Silveira <derotino.silveira@konecty.com>
|
|
6
6
|
License: MIT
|
|
@@ -127,9 +127,29 @@ uv pip install -e ".[dev]"
|
|
|
127
127
|
|
|
128
128
|
#### Build & Publish
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
Publishing runs from the **Publish** workflow, triggered by hand from the Actions tab
|
|
131
|
+
(`Run workflow`) — no merge publishes on its own. Pick the increment (`patch`, `minor` or
|
|
132
|
+
`major`) and run it; **the version bump is part of publishing**, so there is nothing to edit
|
|
133
|
+
beforehand.
|
|
134
|
+
|
|
135
|
+
The workflow runs the tests, bumps `version` in [pyproject.toml](./pyproject.toml), builds into
|
|
136
|
+
`dist-build/` and uploads with `uv publish` (secret `PYPI_API_TOKEN`). Only after the upload
|
|
137
|
+
succeeds does it commit `chore(release): <version>` and tag it — a failed upload leaves no bump
|
|
138
|
+
behind claiming a release that does not exist on PyPI.
|
|
139
|
+
|
|
140
|
+
<details>
|
|
141
|
+
<summary>Publishing manually</summary>
|
|
142
|
+
|
|
143
|
+
Same PyPI endpoint (`upload.pypi.org/legacy/`) and the same kind of API token. Credentials
|
|
144
|
+
come from `.pypirc`, which is gitignored and therefore local-only — this is why CI
|
|
145
|
+
authenticates through a secret instead.
|
|
131
146
|
|
|
132
147
|
```sh
|
|
133
148
|
uv build
|
|
134
149
|
uvx twine upload --config-file .pypirc --skip-existing dist/*
|
|
135
150
|
```
|
|
151
|
+
|
|
152
|
+
Note `--skip-existing`: unlike the workflow, this silently skips versions already published,
|
|
153
|
+
and it is what keeps a stale local `dist/` from re-uploading old artifacts.
|
|
154
|
+
|
|
155
|
+
</details>
|
|
@@ -97,9 +97,29 @@ uv pip install -e ".[dev]"
|
|
|
97
97
|
|
|
98
98
|
#### Build & Publish
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
Publishing runs from the **Publish** workflow, triggered by hand from the Actions tab
|
|
101
|
+
(`Run workflow`) — no merge publishes on its own. Pick the increment (`patch`, `minor` or
|
|
102
|
+
`major`) and run it; **the version bump is part of publishing**, so there is nothing to edit
|
|
103
|
+
beforehand.
|
|
104
|
+
|
|
105
|
+
The workflow runs the tests, bumps `version` in [pyproject.toml](./pyproject.toml), builds into
|
|
106
|
+
`dist-build/` and uploads with `uv publish` (secret `PYPI_API_TOKEN`). Only after the upload
|
|
107
|
+
succeeds does it commit `chore(release): <version>` and tag it — a failed upload leaves no bump
|
|
108
|
+
behind claiming a release that does not exist on PyPI.
|
|
109
|
+
|
|
110
|
+
<details>
|
|
111
|
+
<summary>Publishing manually</summary>
|
|
112
|
+
|
|
113
|
+
Same PyPI endpoint (`upload.pypi.org/legacy/`) and the same kind of API token. Credentials
|
|
114
|
+
come from `.pypirc`, which is gitignored and therefore local-only — this is why CI
|
|
115
|
+
authenticates through a secret instead.
|
|
101
116
|
|
|
102
117
|
```sh
|
|
103
118
|
uv build
|
|
104
119
|
uvx twine upload --config-file .pypirc --skip-existing dist/*
|
|
105
120
|
```
|
|
121
|
+
|
|
122
|
+
Note `--skip-existing`: unlike the workflow, this silently skips versions already published,
|
|
123
|
+
and it is what keeps a stale local `dist/` from re-uploading old artifacts.
|
|
124
|
+
|
|
125
|
+
</details>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"""Exceptions for the Konecty SDK."""
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class KonectyError(Exception):
|
|
5
|
-
"""Base exception for Konecty errors."""
|
|
6
|
-
|
|
7
|
-
pass
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class KonectyAPIError(KonectyError):
|
|
11
|
-
"""Raised when the API returns success=false or a non-2xx status."""
|
|
12
|
-
|
|
13
|
-
pass
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class KonectyValidationError(KonectyError):
|
|
17
|
-
"""Raised for validation errors."""
|
|
18
|
-
|
|
19
|
-
pass
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class KonectySerializationError(KonectyError):
|
|
23
|
-
"""Raised when a value is not serializable."""
|
|
24
|
-
|
|
25
|
-
def __init__(self) -> None:
|
|
26
|
-
super().__init__("Tipo não serializável")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/feature_types/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/feature_types/kpi.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/__init__.py
RENAMED
|
File without changes
|
{konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/aggregation.py
RENAMED
|
File without changes
|
|
File without changes
|
{konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/change_user.py
RENAMED
|
File without changes
|
{konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/comments.py
RENAMED
|
File without changes
|
{konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/export.py
RENAMED
|
File without changes
|
{konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/files.py
RENAMED
|
File without changes
|
{konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/notifications.py
RENAMED
|
File without changes
|
{konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/query.py
RENAMED
|
File without changes
|
{konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/stream.py
RENAMED
|
File without changes
|
{konecty_sdk_python-2.1.0 → konecty_sdk_python-2.1.2}/KonectySdkPython/lib/services/subscriptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|