anaplan-sdk 0.2.11__py3-none-any.whl → 0.3.1b1__py3-none-any.whl

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.
@@ -28,7 +28,9 @@ class _TransactionalClient(_BaseClient):
28
28
  Lists all the Modules in the Model.
29
29
  :return: The List of Modules.
30
30
  """
31
- return [Module.model_validate(e) for e in self._get(f"{self._url}/modules").get("modules")]
31
+ return [
32
+ Module.model_validate(e) for e in self._get_paginated(f"{self._url}/modules", "modules")
33
+ ]
32
34
 
33
35
  def get_model_status(self) -> ModelStatus:
34
36
  """
@@ -48,14 +50,14 @@ class _TransactionalClient(_BaseClient):
48
50
  if only_module_id
49
51
  else f"{self._url}/lineItems?includeAll=true"
50
52
  )
51
- return [LineItem.model_validate(e) for e in self._get(url).get("items")]
53
+ return [LineItem.model_validate(e) for e in self._get(url).get("items", [])]
52
54
 
53
55
  def list_lists(self) -> list[List]:
54
56
  """
55
57
  Lists all the Lists in the Model.
56
- :return: All Lists on this Model.
58
+ :return: All Lists on this model.
57
59
  """
58
- return [List.model_validate(e) for e in self._get(f"{self._url}/lists").get("lists")]
60
+ return [List.model_validate(e) for e in self._get_paginated(f"{self._url}/lists", "lists")]
59
61
 
60
62
  def get_list_metadata(self, list_id: int) -> ListMetadata:
61
63
  """
@@ -76,7 +78,7 @@ class _TransactionalClient(_BaseClient):
76
78
  return [
77
79
  ListItem.model_validate(e)
78
80
  for e in self._get(f"{self._url}/lists/{list_id}/items?includeAll=true").get(
79
- "listItems"
81
+ "listItems", []
80
82
  )
81
83
  ]
82
84
 
@@ -149,7 +151,9 @@ class _TransactionalClient(_BaseClient):
149
151
  """
150
152
  self._post_empty(f"{self._url}/lists/{list_id}/resetIndex")
151
153
 
152
- def write_to_module(self, module_id: int, data: list[dict[str, Any]]) -> int | dict[str, Any]:
154
+ def update_module_data(
155
+ self, module_id: int, data: list[dict[str, Any]]
156
+ ) -> int | dict[str, Any]:
153
157
  """
154
158
  Write the passed items to the specified module. If successful, the number of cells changed
155
159
  is returned, if only partially successful or unsuccessful, the response with the according
@@ -162,6 +166,15 @@ class _TransactionalClient(_BaseClient):
162
166
  res = self._post(f"{self._url}/modules/{module_id}/data", json=data)
163
167
  return res if "failures" in res else res["numberOfCellsChanged"]
164
168
 
169
+ def write_to_module(self, module_id: int, data: list[dict[str, Any]]) -> int | dict[str, Any]:
170
+ warnings.warn(
171
+ "`write_to_module()` is deprecated and will be removed in a future version. "
172
+ "Use `update_module_data()` instead.",
173
+ DeprecationWarning,
174
+ stacklevel=1,
175
+ )
176
+ return self.update_module_data(module_id, data)
177
+
165
178
  def add_items_to_list(
166
179
  self, list_id: int, items: list[dict[str, str | int | dict]]
167
180
  ) -> InsertionResult: