konecty-sdk-python 1.1.0__tar.gz → 1.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.
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/KonectySdkPython/lib/client.py +52 -0
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/KonectySdkPython/lib/settings.py +25 -10
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/KonectySdkPython/lib/types.py +8 -6
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/PKG-INFO +1 -1
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/pyproject.toml +1 -1
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/.gitignore +0 -0
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/KonectySdkPython/__init__.py +0 -0
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/KonectySdkPython/cli/__init__.py +0 -0
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/KonectySdkPython/cli/apply.py +0 -0
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/KonectySdkPython/cli/backup.py +0 -0
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/KonectySdkPython/cli/pull.py +0 -0
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/KonectySdkPython/lib/__init__.py +0 -0
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/KonectySdkPython/lib/file_manager.py +0 -0
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/KonectySdkPython/lib/filters.py +0 -0
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/KonectySdkPython/lib/model.py +0 -0
- {konecty_sdk_python-1.1.0 → konecty_sdk_python-1.2.0}/README.md +0 -0
|
@@ -302,6 +302,58 @@ class KonectyClient:
|
|
|
302
302
|
return None
|
|
303
303
|
return cast(str, setting.get("value"))
|
|
304
304
|
|
|
305
|
+
async def get_settings(self, keys: List[str]) -> Dict[str, str]:
|
|
306
|
+
"""Obtém múltiplas configurações do Konecty.
|
|
307
|
+
|
|
308
|
+
Args:
|
|
309
|
+
keys: Lista de chaves das configurações a serem obtidas
|
|
310
|
+
|
|
311
|
+
Returns:
|
|
312
|
+
Dicionário com as chaves e seus respectivos valores. Chaves não encontradas terão valor None.
|
|
313
|
+
"""
|
|
314
|
+
if not keys:
|
|
315
|
+
return {}
|
|
316
|
+
|
|
317
|
+
filter_params = KonectyFilter.create().add_condition("key", "in", keys)
|
|
318
|
+
find_params = KonectyFindParams(filter=filter_params)
|
|
319
|
+
|
|
320
|
+
settings = await self.find("Setting", find_params)
|
|
321
|
+
|
|
322
|
+
result = {}
|
|
323
|
+
|
|
324
|
+
for setting in settings:
|
|
325
|
+
key = setting.get("key")
|
|
326
|
+
value = setting.get("value")
|
|
327
|
+
result[key] = cast(str, value)
|
|
328
|
+
|
|
329
|
+
return result
|
|
330
|
+
|
|
331
|
+
def get_settings_sync(self, keys: List[str]) -> Dict[str, str]:
|
|
332
|
+
"""Versão síncrona de get_settings.
|
|
333
|
+
|
|
334
|
+
Args:
|
|
335
|
+
keys: Lista de chaves das configurações a serem obtidas
|
|
336
|
+
|
|
337
|
+
Returns:
|
|
338
|
+
Dicionário com as chaves e seus respectivos valores. Chaves não encontradas terão valor None.
|
|
339
|
+
"""
|
|
340
|
+
if not keys:
|
|
341
|
+
return {}
|
|
342
|
+
|
|
343
|
+
filter_params = KonectyFilter.create().add_condition("key", "in", keys)
|
|
344
|
+
find_params = KonectyFindParams(filter=filter_params)
|
|
345
|
+
|
|
346
|
+
settings = self.find_sync("Setting", find_params)
|
|
347
|
+
|
|
348
|
+
result = {}
|
|
349
|
+
|
|
350
|
+
for setting in settings:
|
|
351
|
+
key = setting.get("key")
|
|
352
|
+
value = setting.get("value")
|
|
353
|
+
result[key] = cast(str, value)
|
|
354
|
+
|
|
355
|
+
return result
|
|
356
|
+
|
|
305
357
|
async def count_documents(self, module: str, filter_params: KonectyFilter) -> int:
|
|
306
358
|
params: Dict[str, str] = {}
|
|
307
359
|
options = KonectyFindParams(
|
|
@@ -56,19 +56,26 @@ async def fill_settings(settings_class: Type[T]) -> T:
|
|
|
56
56
|
)
|
|
57
57
|
|
|
58
58
|
settings_dict = {}
|
|
59
|
+
fields_to_fetch = []
|
|
59
60
|
|
|
61
|
+
# Primeiro verifica variáveis de ambiente e coleta campos que precisam ser buscados no Konecty
|
|
60
62
|
for field_name in settings_class.model_fields.keys():
|
|
61
|
-
# Primeiro verifica se existe na variável de ambiente
|
|
62
63
|
env_value = os.getenv(field_name.upper())
|
|
63
64
|
if env_value is not None and env_value.strip():
|
|
64
65
|
field_type = settings_class.model_fields[field_name].annotation
|
|
65
66
|
converted_value = _convert_value(env_value, field_type)
|
|
66
67
|
if converted_value is not None:
|
|
67
68
|
settings_dict[field_name] = converted_value
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
else:
|
|
70
|
+
fields_to_fetch.append(field_name)
|
|
71
|
+
|
|
72
|
+
# Busca todas as configurações do Konecty de uma vez
|
|
73
|
+
if fields_to_fetch:
|
|
74
|
+
konecty_settings = await client.get_settings(
|
|
75
|
+
[field.upper() for field in fields_to_fetch]
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
for field_name, value in konecty_settings.items():
|
|
72
79
|
if value is not None and value.strip():
|
|
73
80
|
field_type = settings_class.model_fields[field_name].annotation
|
|
74
81
|
converted_value = _convert_value(value, field_type)
|
|
@@ -93,19 +100,27 @@ def fill_settings_sync(settings_class: Type[T]) -> T:
|
|
|
93
100
|
)
|
|
94
101
|
|
|
95
102
|
settings_dict = {}
|
|
103
|
+
fields_to_fetch = []
|
|
96
104
|
|
|
105
|
+
# Primeiro verifica variáveis de ambiente e coleta campos que precisam ser buscados no Konecty
|
|
97
106
|
for field_name in settings_class.model_fields.keys():
|
|
98
|
-
# Primeiro verifica se existe na variável de ambiente
|
|
99
107
|
env_value = os.getenv(field_name.upper())
|
|
100
108
|
if env_value is not None and env_value.strip():
|
|
101
109
|
field_type = settings_class.model_fields[field_name].annotation
|
|
102
110
|
converted_value = _convert_value(env_value, field_type)
|
|
103
111
|
if converted_value is not None:
|
|
104
112
|
settings_dict[field_name] = converted_value
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
113
|
+
else:
|
|
114
|
+
# Se não encontrou na variável de ambiente, adiciona à lista para buscar no Konecty
|
|
115
|
+
fields_to_fetch.append(field_name)
|
|
116
|
+
|
|
117
|
+
# Busca todas as configurações do Konecty de uma vez
|
|
118
|
+
if fields_to_fetch:
|
|
119
|
+
konecty_settings = client.get_settings_sync(
|
|
120
|
+
[field.upper() for field in fields_to_fetch]
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
for field_name, value in konecty_settings.items():
|
|
109
124
|
if value is not None and value.strip():
|
|
110
125
|
field_type = settings_class.model_fields[field_name].annotation
|
|
111
126
|
converted_value = _convert_value(value, field_type)
|
|
@@ -4,7 +4,7 @@ from datetime import datetime
|
|
|
4
4
|
from decimal import Decimal
|
|
5
5
|
from typing import Any, Dict, List, Optional, Self
|
|
6
6
|
|
|
7
|
-
from pydantic import BaseModel, Field
|
|
7
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
8
8
|
from pydantic.json_schema import JsonSchemaValue
|
|
9
9
|
from pydantic_core import CoreSchema, core_schema
|
|
10
10
|
|
|
@@ -395,13 +395,15 @@ class KonectyPersonName(BaseModel):
|
|
|
395
395
|
|
|
396
396
|
|
|
397
397
|
class KonectyUpdateId(BaseModel):
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
id: str = Field(alias="_id")
|
|
399
|
+
updatedAt: KonectyDateTime = Field(alias="_updatedAt")
|
|
400
|
+
|
|
401
|
+
model_config = ConfigDict(populate_by_name=True, extra="ignore")
|
|
400
402
|
|
|
401
403
|
@classmethod
|
|
402
404
|
def from_dict(cls, data: dict[str, Any]) -> Self:
|
|
403
|
-
id = data.get("_id")
|
|
404
|
-
updatedAt = data.get("_updatedAt")
|
|
405
|
+
id = data.get("_id", data.get("id", None))
|
|
406
|
+
updatedAt = data.get("_updatedAt", data.get("updatedAt", None))
|
|
405
407
|
if id is None or updatedAt is None:
|
|
406
408
|
raise ValueError("Invalid value for KonectyUpdateIds")
|
|
407
409
|
return cls(id=id, updatedAt=KonectyDateTime.from_any(updatedAt))
|
|
@@ -411,4 +413,4 @@ class KonectyUpdateId(BaseModel):
|
|
|
411
413
|
return [cls.from_dict(item) for item in data]
|
|
412
414
|
|
|
413
415
|
def to_dict(self) -> dict[str, Any]:
|
|
414
|
-
return {"_id": self.
|
|
416
|
+
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
|