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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: konecty-sdk-python
3
- Version: 1.0.0
3
+ Version: 1.0.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
@@ -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
- {"name": doc_name, "type": {"$in": ["composite", "document"]}}
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.replace_one(
131
+ collection.update_one(
132
132
  {
133
- "name": doc_name,
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.replace_one(
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 konecty.types import Address, KonectyDateTime, KonectyEmail, KonectyLookup, KonectyPersonName, KonectyPhone
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 = field.get("isRequired", False) or field.get("minSelected", 0) > 0
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)] = (current_type, Field(**field_params))
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.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
@@ -1,5 +0,0 @@
1
- """Konecty metadata management package."""
2
-
3
- from .cli import apply_command, backup_command, pull_command
4
-
5
- __all__ = ["apply_command", "backup_command", "pull_command"]