konecty-sdk-python 1.0.0__tar.gz → 1.0.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-1.0.0 → konecty_sdk_python-1.0.2}/PKG-INFO +1 -1
- {konecty_sdk_python-1.0.0 → konecty_sdk_python-1.0.2}/cli/apply.py +14 -11
- konecty_sdk_python-1.0.2/lib/__init__.py +41 -0
- {konecty_sdk_python-1.0.0 → konecty_sdk_python-1.0.2}/lib/model.py +15 -3
- {konecty_sdk_python-1.0.0 → konecty_sdk_python-1.0.2}/pyproject.toml +7 -1
- konecty_sdk_python-1.0.0/.python-version +0 -1
- konecty_sdk_python-1.0.0/__init__.py +0 -5
- konecty_sdk_python-1.0.0/uv.lock +0 -943
- {konecty_sdk_python-1.0.0 → konecty_sdk_python-1.0.2}/.gitignore +0 -0
- {konecty_sdk_python-1.0.0 → konecty_sdk_python-1.0.2}/README.md +0 -0
- {konecty_sdk_python-1.0.0 → konecty_sdk_python-1.0.2}/cli/__init__.py +0 -0
- {konecty_sdk_python-1.0.0 → konecty_sdk_python-1.0.2}/cli/backup.py +0 -0
- {konecty_sdk_python-1.0.0 → konecty_sdk_python-1.0.2}/cli/pull.py +0 -0
- {konecty_sdk_python-1.0.0 → konecty_sdk_python-1.0.2}/lib/client.py +0 -0
- {konecty_sdk_python-1.0.0 → konecty_sdk_python-1.0.2}/lib/file_manager.py +0 -0
- {konecty_sdk_python-1.0.0 → konecty_sdk_python-1.0.2}/lib/filters.py +0 -0
- {konecty_sdk_python-1.0.0 → konecty_sdk_python-1.0.2}/lib/settings.py +0 -0
- {konecty_sdk_python-1.0.0 → konecty_sdk_python-1.0.2}/lib/types.py +0 -0
|
@@ -120,7 +120,7 @@ async def apply_document(
|
|
|
120
120
|
doc_data = load_json_file(doc_files["document"][0])
|
|
121
121
|
if doc_data:
|
|
122
122
|
existing_doc = collection.find_one(
|
|
123
|
-
{"
|
|
123
|
+
{"_id": doc_data["_id"], "type": {"$in": ["composite", "document"]}}
|
|
124
124
|
)
|
|
125
125
|
|
|
126
126
|
if existing_doc and is_equal_documents(doc_data, existing_doc):
|
|
@@ -128,16 +128,18 @@ async def apply_document(
|
|
|
128
128
|
else:
|
|
129
129
|
if not dry_run:
|
|
130
130
|
try:
|
|
131
|
-
collection.
|
|
131
|
+
collection.update_one(
|
|
132
132
|
{
|
|
133
|
-
"
|
|
133
|
+
"_id": doc_data["_id"],
|
|
134
134
|
"type": {"$in": ["composite", "document"]},
|
|
135
135
|
},
|
|
136
|
-
doc_data,
|
|
136
|
+
{"$set": doc_data},
|
|
137
137
|
upsert=True,
|
|
138
138
|
)
|
|
139
139
|
applied.append(f"✓ {doc_name} (document)")
|
|
140
140
|
except Exception as error:
|
|
141
|
+
print(doc_data["_id"], f"{doc_name} (document)")
|
|
142
|
+
print(error)
|
|
141
143
|
errors.append(f"✗ {doc_name} (document): {str(error)}")
|
|
142
144
|
else:
|
|
143
145
|
applied.append(f"✓ {doc_name} (document) [dry-run]")
|
|
@@ -162,17 +164,23 @@ async def apply_document(
|
|
|
162
164
|
else:
|
|
163
165
|
if not dry_run:
|
|
164
166
|
try:
|
|
165
|
-
collection.
|
|
167
|
+
collection.update_one(
|
|
166
168
|
{
|
|
167
169
|
"name": data["name"],
|
|
168
170
|
"type": type_name,
|
|
169
171
|
"document": doc_name,
|
|
170
172
|
},
|
|
171
|
-
data,
|
|
173
|
+
{"$set": data},
|
|
172
174
|
upsert=True,
|
|
173
175
|
)
|
|
174
176
|
applied.append(f"✓ {doc_name}/{type_name}/{data['name']}")
|
|
175
177
|
except Exception as error:
|
|
178
|
+
print(
|
|
179
|
+
data["_id"],
|
|
180
|
+
data["name"],
|
|
181
|
+
f"{doc_name}/{type_name}/{data['name']}",
|
|
182
|
+
)
|
|
183
|
+
print(error)
|
|
176
184
|
errors.append(
|
|
177
185
|
f"✗ {doc_name}/{type_name}/{data['name']}: {str(error)}"
|
|
178
186
|
)
|
|
@@ -545,8 +553,3 @@ def main():
|
|
|
545
553
|
|
|
546
554
|
if __name__ == "__main__":
|
|
547
555
|
main()
|
|
548
|
-
main()
|
|
549
|
-
main()
|
|
550
|
-
main()
|
|
551
|
-
main()
|
|
552
|
-
main()
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Konecty SDK Python - A Python SDK for interacting with Konecty platform
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .client import KonectyClient, KonectyDict, KonectyFilter, KonectyFindParams
|
|
6
|
+
from .file_manager import FileManager
|
|
7
|
+
from .model import KonectyModelGenerator
|
|
8
|
+
from .settings import fill_settings, fill_settings_sync
|
|
9
|
+
from .types import Address as KonectyAddress
|
|
10
|
+
from .types import (
|
|
11
|
+
KonectyBaseModel,
|
|
12
|
+
KonectyDateTime,
|
|
13
|
+
KonectyEmail,
|
|
14
|
+
KonectyLabel,
|
|
15
|
+
KonectyLookup,
|
|
16
|
+
KonectyPersonName,
|
|
17
|
+
KonectyPhone,
|
|
18
|
+
KonectyUser,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"KonectyClient",
|
|
23
|
+
"KonectyModel",
|
|
24
|
+
"FileManager",
|
|
25
|
+
"KonectyModelGenerator",
|
|
26
|
+
"fill_settings",
|
|
27
|
+
"fill_settings_sync",
|
|
28
|
+
"KonectyAddress",
|
|
29
|
+
"KonectyBaseModel",
|
|
30
|
+
"KonectyDateTime",
|
|
31
|
+
"KonectyEmail",
|
|
32
|
+
"KonectyLabel",
|
|
33
|
+
"KonectyLookup",
|
|
34
|
+
"KonectyPersonName",
|
|
35
|
+
"KonectyPhone",
|
|
36
|
+
"KonectyUser",
|
|
37
|
+
"KonectyModel",
|
|
38
|
+
"KonectyFilter",
|
|
39
|
+
"KonectyFindParams",
|
|
40
|
+
"KonectyDict",
|
|
41
|
+
]
|
|
@@ -3,7 +3,14 @@ from typing import Any, Dict, List, Optional, Type, TypeVar, cast
|
|
|
3
3
|
from pydantic import BaseModel, Field, create_model
|
|
4
4
|
from pydantic.fields import FieldInfo
|
|
5
5
|
|
|
6
|
-
from
|
|
6
|
+
from .types import (
|
|
7
|
+
Address,
|
|
8
|
+
KonectyDateTime,
|
|
9
|
+
KonectyEmail,
|
|
10
|
+
KonectyLookup,
|
|
11
|
+
KonectyPersonName,
|
|
12
|
+
KonectyPhone,
|
|
13
|
+
)
|
|
7
14
|
|
|
8
15
|
T = TypeVar("T")
|
|
9
16
|
ModelType = TypeVar("ModelType", bound=BaseModel)
|
|
@@ -47,7 +54,9 @@ class KonectyModelGenerator:
|
|
|
47
54
|
if field.get("minSelected", 1) > 1 or field.get("maxSelected", 1) > 1:
|
|
48
55
|
current_type = List[base_type] # type: ignore
|
|
49
56
|
|
|
50
|
-
is_required =
|
|
57
|
+
is_required = (
|
|
58
|
+
field.get("isRequired", False) or field.get("minSelected", 0) > 0
|
|
59
|
+
)
|
|
51
60
|
|
|
52
61
|
if not is_required and "defaultValue" not in field:
|
|
53
62
|
current_type = Optional[base_type] # type: ignore
|
|
@@ -63,7 +72,10 @@ class KonectyModelGenerator:
|
|
|
63
72
|
if not is_required and "defaultValue" not in field:
|
|
64
73
|
field_params["default"] = None
|
|
65
74
|
|
|
66
|
-
fields[self._clean_name_for_pydantic(field_name)] = (
|
|
75
|
+
fields[self._clean_name_for_pydantic(field_name)] = (
|
|
76
|
+
current_type,
|
|
77
|
+
Field(**field_params),
|
|
78
|
+
)
|
|
67
79
|
|
|
68
80
|
model_name = self.schema["name"]
|
|
69
81
|
return create_model(model_name, **fields)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "konecty-sdk-python"
|
|
3
|
-
version = "1.0.
|
|
3
|
+
version = "1.0.2"
|
|
4
4
|
description = "Konecty SDK Python"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11"
|
|
@@ -41,3 +41,9 @@ build-backend = "hatchling.build"
|
|
|
41
41
|
|
|
42
42
|
[tool.hatch.build.targets.wheel]
|
|
43
43
|
packages = ["cli", "lib"]
|
|
44
|
+
|
|
45
|
+
[tool.hatch.build]
|
|
46
|
+
include = [
|
|
47
|
+
"lib/**/*.py",
|
|
48
|
+
"cli/**/*.py",
|
|
49
|
+
]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.11
|