konecty-sdk-python 1.0.7__tar.gz → 1.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.
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/KonectySdkPython/lib/__init__.py +2 -0
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/KonectySdkPython/lib/client.py +22 -1
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/KonectySdkPython/lib/types.py +20 -0
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/PKG-INFO +1 -1
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/pyproject.toml +1 -1
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/.gitignore +0 -0
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/KonectySdkPython/__init__.py +0 -0
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/KonectySdkPython/cli/__init__.py +0 -0
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/KonectySdkPython/cli/apply.py +0 -0
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/KonectySdkPython/cli/backup.py +0 -0
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/KonectySdkPython/cli/pull.py +0 -0
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/KonectySdkPython/lib/file_manager.py +0 -0
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/KonectySdkPython/lib/filters.py +0 -0
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/KonectySdkPython/lib/model.py +0 -0
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/KonectySdkPython/lib/settings.py +0 -0
- {konecty_sdk_python-1.0.7 → konecty_sdk_python-1.1.0}/README.md +0 -0
|
@@ -9,7 +9,7 @@ import aiohttp
|
|
|
9
9
|
|
|
10
10
|
from .file_manager import FileManager
|
|
11
11
|
from .filters import KonectyFilter, KonectyFindParams
|
|
12
|
-
from .types import KonectyDateTime
|
|
12
|
+
from .types import KonectyDateTime, KonectyUpdateId
|
|
13
13
|
|
|
14
14
|
# Configura o logger do urllib3 para mostrar apenas erros
|
|
15
15
|
logging.getLogger("urllib3.connectionpool").setLevel(logging.ERROR)
|
|
@@ -217,6 +217,27 @@ class KonectyClient:
|
|
|
217
217
|
raise KonectyAPIError(errors)
|
|
218
218
|
return result.get("data", [None])[0]
|
|
219
219
|
|
|
220
|
+
async def update(
|
|
221
|
+
self, module: str, ids: list[KonectyUpdateId], data: KonectyDict
|
|
222
|
+
) -> list[KonectyDict]:
|
|
223
|
+
endpoint = f"/rest/data/{module}"
|
|
224
|
+
cleaned_data = {
|
|
225
|
+
k: v for k, v in data.items() if k not in KONECTY_UPDATE_IGNORE_FIELDS
|
|
226
|
+
}
|
|
227
|
+
payload = {
|
|
228
|
+
"ids": [id.to_dict() for id in ids],
|
|
229
|
+
"data": json.loads(json.dumps(cleaned_data, default=json_serial)),
|
|
230
|
+
}
|
|
231
|
+
async with (
|
|
232
|
+
aiohttp.ClientSession(base_url=self.base_url) as session,
|
|
233
|
+
session.put(endpoint, headers=self.headers, json=payload) as response,
|
|
234
|
+
):
|
|
235
|
+
result = await response.json()
|
|
236
|
+
if not result.get("success", False):
|
|
237
|
+
errors = result.get("errors", [])
|
|
238
|
+
raise KonectyAPIError(errors)
|
|
239
|
+
return result.get("data", [])
|
|
240
|
+
|
|
220
241
|
async def delete_one(
|
|
221
242
|
self, module: str, id: str, updatedAt: datetime
|
|
222
243
|
) -> Optional[KonectyDict]:
|
|
@@ -392,3 +392,23 @@ class KonectyPersonName(BaseModel):
|
|
|
392
392
|
|
|
393
393
|
def to_dict(self) -> dict[str, Any]:
|
|
394
394
|
return self.model_dump(by_alias=True)
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
class KonectyUpdateId(BaseModel):
|
|
398
|
+
_id: str = Field(alias="_id")
|
|
399
|
+
_updatedAt: KonectyDateTime = Field(alias="_updatedAt")
|
|
400
|
+
|
|
401
|
+
@classmethod
|
|
402
|
+
def from_dict(cls, data: dict[str, Any]) -> Self:
|
|
403
|
+
id = data.get("_id")
|
|
404
|
+
updatedAt = data.get("_updatedAt")
|
|
405
|
+
if id is None or updatedAt is None:
|
|
406
|
+
raise ValueError("Invalid value for KonectyUpdateIds")
|
|
407
|
+
return cls(id=id, updatedAt=KonectyDateTime.from_any(updatedAt))
|
|
408
|
+
|
|
409
|
+
@classmethod
|
|
410
|
+
def from_list(cls, data: list[dict[str, Any]]) -> list[Self]:
|
|
411
|
+
return [cls.from_dict(item) for item in data]
|
|
412
|
+
|
|
413
|
+
def to_dict(self) -> dict[str, Any]:
|
|
414
|
+
return {"_id": self._id, "_updatedAt": self._updatedAt.to_json()}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|