anaplan-sdk 0.2.11__py3-none-any.whl → 0.3.0__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.
@@ -3,8 +3,7 @@ Asynchronous Client.
3
3
  """
4
4
 
5
5
  import logging
6
- import time
7
- from asyncio import gather
6
+ from asyncio import gather, sleep
8
7
  from copy import copy
9
8
  from typing import AsyncIterator, Iterator
10
9
 
@@ -14,7 +13,17 @@ from typing_extensions import Self
14
13
  from anaplan_sdk._auth import AnaplanBasicAuth, AnaplanCertAuth, get_certificate, get_private_key
15
14
  from anaplan_sdk._base import _AsyncBaseClient, action_url
16
15
  from anaplan_sdk.exceptions import AnaplanActionError, InvalidIdentifierException
17
- from anaplan_sdk.models import Action, Export, File, Import, Model, Process, Workspace
16
+ from anaplan_sdk.models import (
17
+ Action,
18
+ Export,
19
+ File,
20
+ Import,
21
+ Model,
22
+ Process,
23
+ TaskStatus,
24
+ TaskSummary,
25
+ Workspace,
26
+ )
18
27
 
19
28
  from ._alm import _AsyncAlmClient
20
29
  from ._audit import _AsyncAuditClient
@@ -250,7 +259,7 @@ class AsyncClient(_AsyncBaseClient):
250
259
  for e in (await self._get(f"{self._url}/exports")).get("exports", [])
251
260
  ]
252
261
 
253
- async def run_action(self, action_id: int) -> None:
262
+ async def run_action(self, action_id: int) -> TaskStatus:
254
263
  """
255
264
  Runs the specified Anaplan Action and validates the spawned task. If the Action fails or
256
265
  completes with errors, will raise an :py:class:`AnaplanActionError`. Failed Tasks are
@@ -268,16 +277,15 @@ class AsyncClient(_AsyncBaseClient):
268
277
  task_id = await self.invoke_action(action_id)
269
278
  task_status = await self.get_task_status(action_id, task_id)
270
279
 
271
- while "COMPLETE" not in task_status.get("taskState"):
272
- time.sleep(self.status_poll_delay)
280
+ while task_status.task_state != "COMPLETE":
281
+ await sleep(self.status_poll_delay)
273
282
  task_status = await self.get_task_status(action_id, task_id)
274
283
 
275
- if task_status.get("taskState") == "COMPLETE" and not task_status.get("result").get(
276
- "successful"
277
- ):
284
+ if task_status.task_state == "COMPLETE" and not task_status.result.successful:
278
285
  raise AnaplanActionError(f"Task '{task_id}' completed with errors.")
279
286
 
280
287
  logger.info(f"Task '{task_id}' completed successfully.")
288
+ return task_status
281
289
 
282
290
  async def get_file(self, file_id: int) -> bytes:
283
291
  """
@@ -390,29 +398,31 @@ class AsyncClient(_AsyncBaseClient):
390
398
  await self.run_action(action_id)
391
399
  return await self.get_file(action_id)
392
400
 
393
- async def list_task_status(self, action_id: int) -> list:
401
+ async def list_task_status(self, action_id: int) -> list[TaskSummary]:
394
402
  """
395
403
  Retrieves the status of all tasks spawned by the specified action.
396
404
  :param action_id: The identifier of the action that was invoked.
397
405
  :return: The list of tasks spawned by the action.
398
406
  """
399
- return (await self._get(f"{self._url}/{action_url(action_id)}/{action_id}/tasks")).get(
400
- "tasks", []
401
- )
407
+ return [
408
+ TaskSummary.model_validate(e)
409
+ for e in (
410
+ await self._get(f"{self._url}/{action_url(action_id)}/{action_id}/tasks")
411
+ ).get("tasks", [])
412
+ ]
402
413
 
403
- async def get_task_status(
404
- self, action_id: int, task_id: str
405
- ) -> dict[str, float | int | str | list | dict | bool]:
414
+ async def get_task_status(self, action_id: int, task_id: str) -> TaskStatus:
406
415
  """
407
416
  Retrieves the status of the specified task.
408
417
  :param action_id: The identifier of the action that was invoked.
409
418
  :param task_id: The identifier of the spawned task.
410
- :return: The status of the task as returned by the API. For more information
411
- see: https://anaplan.docs.apiary.io.
419
+ :return: The status of the task.
412
420
  """
413
- return (
414
- await self._get(f"{self._url}/{action_url(action_id)}/{action_id}/tasks/{task_id}")
415
- ).get("task")
421
+ return TaskStatus.model_validate(
422
+ (
423
+ await self._get(f"{self._url}/{action_url(action_id)}/{action_id}/tasks/{task_id}")
424
+ ).get("task")
425
+ )
416
426
 
417
427
  async def invoke_action(self, action_id: int) -> str:
418
428
  """
@@ -32,7 +32,7 @@ class _AsyncTransactionalClient(_AsyncBaseClient):
32
32
  """
33
33
  return [
34
34
  Module.model_validate(e)
35
- for e in (await self._get(f"{self._url}/modules")).get("modules")
35
+ for e in (await self._get(f"{self._url}/modules")).get("modules", [])
36
36
  ]
37
37
 
38
38
  async def get_model_status(self) -> ModelStatus:
@@ -55,7 +55,7 @@ class _AsyncTransactionalClient(_AsyncBaseClient):
55
55
  if only_module_id
56
56
  else f"{self._url}/lineItems?includeAll=true"
57
57
  )
58
- return [LineItem.model_validate(e) for e in (await self._get(url)).get("items")]
58
+ return [LineItem.model_validate(e) for e in (await self._get(url)).get("items", [])]
59
59
 
60
60
  async def list_lists(self) -> list[List]:
61
61
  """
@@ -63,7 +63,7 @@ class _AsyncTransactionalClient(_AsyncBaseClient):
63
63
  :return: All Lists on this model.
64
64
  """
65
65
  return [
66
- List.model_validate(e) for e in (await self._get(f"{self._url}/lists")).get("lists")
66
+ List.model_validate(e) for e in (await self._get(f"{self._url}/lists")).get("lists", [])
67
67
  ]
68
68
 
69
69
  async def get_list_metadata(self, list_id: int) -> ListMetadata:
@@ -156,7 +156,7 @@ class _AsyncTransactionalClient(_AsyncBaseClient):
156
156
  """
157
157
  await self._post_empty(f"{self._url}/lists/{list_id}/resetIndex")
158
158
 
159
- async def write_to_module(
159
+ async def update_module_data(
160
160
  self, module_id: int, data: list[dict[str, Any]]
161
161
  ) -> int | dict[str, Any]:
162
162
  """
@@ -171,6 +171,17 @@ class _AsyncTransactionalClient(_AsyncBaseClient):
171
171
  res = await self._post(f"{self._url}/modules/{module_id}/data", json=data)
172
172
  return res if "failures" in res else res["numberOfCellsChanged"]
173
173
 
174
+ async def write_to_module(
175
+ self, module_id: int, data: list[dict[str, Any]]
176
+ ) -> int | dict[str, Any]:
177
+ warnings.warn(
178
+ "`write_to_module()` is deprecated and will be removed in a future version. "
179
+ "Use `update_module_data()` instead.",
180
+ DeprecationWarning,
181
+ stacklevel=1,
182
+ )
183
+ return await self.update_module_data(module_id, data)
184
+
174
185
  async def add_items_to_list(
175
186
  self, list_id: int, items: list[dict[str, str | int | dict]]
176
187
  ) -> InsertionResult:
@@ -15,7 +15,17 @@ from typing_extensions import Self
15
15
  from anaplan_sdk._auth import AnaplanBasicAuth, AnaplanCertAuth, get_certificate, get_private_key
16
16
  from anaplan_sdk._base import _BaseClient, action_url
17
17
  from anaplan_sdk.exceptions import AnaplanActionError, InvalidIdentifierException
18
- from anaplan_sdk.models import Action, Export, File, Import, Model, Process, Workspace
18
+ from anaplan_sdk.models import (
19
+ Action,
20
+ Export,
21
+ File,
22
+ Import,
23
+ Model,
24
+ Process,
25
+ TaskStatus,
26
+ TaskSummary,
27
+ Workspace,
28
+ )
19
29
 
20
30
  from ._alm import _AlmClient
21
31
  from ._audit import _AuditClient
@@ -252,7 +262,7 @@ class Client(_BaseClient):
252
262
  Export.model_validate(e) for e in (self._get(f"{self._url}/exports")).get("exports", [])
253
263
  ]
254
264
 
255
- def run_action(self, action_id: int) -> None:
265
+ def run_action(self, action_id: int) -> TaskStatus:
256
266
  """
257
267
  Runs the specified Anaplan Action and validates the spawned task. If the Action fails or
258
268
  completes with errors, will raise an :py:class:`AnaplanActionError`. Failed Tasks are
@@ -270,16 +280,15 @@ class Client(_BaseClient):
270
280
  task_id = self.invoke_action(action_id)
271
281
  task_status = self.get_task_status(action_id, task_id)
272
282
 
273
- while "COMPLETE" not in task_status.get("taskState"):
283
+ while task_status.task_state != "COMPLETE":
274
284
  time.sleep(self.status_poll_delay)
275
285
  task_status = self.get_task_status(action_id, task_id)
276
286
 
277
- if task_status.get("taskState") == "COMPLETE" and not task_status.get("result").get(
278
- "successful"
279
- ):
287
+ if task_status.task_state == "COMPLETE" and not task_status.result.successful:
280
288
  raise AnaplanActionError(f"Task '{task_id}' completed with errors.")
281
289
 
282
290
  logger.info(f"Task '{task_id}' completed successfully.")
291
+ return task_status
283
292
 
284
293
  def get_file(self, file_id: int) -> bytes:
285
294
  """
@@ -383,26 +392,30 @@ class Client(_BaseClient):
383
392
  self.run_action(action_id)
384
393
  return self.get_file(action_id)
385
394
 
386
- def list_task_status(self, action_id: int) -> list:
395
+ def list_task_status(self, action_id: int) -> list[TaskSummary]:
387
396
  """
388
397
  Retrieves the status of all tasks spawned by the specified action.
389
398
  :param action_id: The identifier of the action that was invoked.
390
399
  :return: The list of tasks spawned by the action.
391
400
  """
392
- return self._get(f"{self._url}/{action_url(action_id)}/{action_id}/tasks").get("tasks", [])
401
+ return [
402
+ TaskSummary.model_validate(e)
403
+ for e in self._get(f"{self._url}/{action_url(action_id)}/{action_id}/tasks").get(
404
+ "tasks", []
405
+ )
406
+ ]
393
407
 
394
- def get_task_status(
395
- self, action_id: int, task_id: str
396
- ) -> dict[str, float | int | str | list | dict | bool]:
408
+ def get_task_status(self, action_id: int, task_id: str) -> TaskStatus:
397
409
  """
398
410
  Retrieves the status of the specified task.
399
411
  :param action_id: The identifier of the action that was invoked.
400
412
  :param task_id: The identifier of the spawned task.
401
- :return: The status of the task as returned by the API. For more information
402
- see: https://anaplan.docs.apiary.io.
413
+ :return: The status of the task.
403
414
  """
404
- return self._get(f"{self._url}/{action_url(action_id)}/{action_id}/tasks/{task_id}").get(
405
- "task"
415
+ return TaskStatus.model_validate(
416
+ self._get(f"{self._url}/{action_url(action_id)}/{action_id}/tasks/{task_id}").get(
417
+ "task"
418
+ )
406
419
  )
407
420
 
408
421
  def invoke_action(self, action_id: int) -> str:
@@ -48,14 +48,14 @@ class _TransactionalClient(_BaseClient):
48
48
  if only_module_id
49
49
  else f"{self._url}/lineItems?includeAll=true"
50
50
  )
51
- return [LineItem.model_validate(e) for e in self._get(url).get("items")]
51
+ return [LineItem.model_validate(e) for e in self._get(url).get("items", [])]
52
52
 
53
53
  def list_lists(self) -> list[List]:
54
54
  """
55
55
  Lists all the Lists in the Model.
56
56
  :return: All Lists on this Model.
57
57
  """
58
- return [List.model_validate(e) for e in self._get(f"{self._url}/lists").get("lists")]
58
+ return [List.model_validate(e) for e in self._get(f"{self._url}/lists").get("lists", [])]
59
59
 
60
60
  def get_list_metadata(self, list_id: int) -> ListMetadata:
61
61
  """
@@ -76,7 +76,7 @@ class _TransactionalClient(_BaseClient):
76
76
  return [
77
77
  ListItem.model_validate(e)
78
78
  for e in self._get(f"{self._url}/lists/{list_id}/items?includeAll=true").get(
79
- "listItems"
79
+ "listItems", []
80
80
  )
81
81
  ]
82
82
 
@@ -149,7 +149,9 @@ class _TransactionalClient(_BaseClient):
149
149
  """
150
150
  self._post_empty(f"{self._url}/lists/{list_id}/resetIndex")
151
151
 
152
- def write_to_module(self, module_id: int, data: list[dict[str, Any]]) -> int | dict[str, Any]:
152
+ def update_module_data(
153
+ self, module_id: int, data: list[dict[str, Any]]
154
+ ) -> int | dict[str, Any]:
153
155
  """
154
156
  Write the passed items to the specified module. If successful, the number of cells changed
155
157
  is returned, if only partially successful or unsuccessful, the response with the according
@@ -162,6 +164,15 @@ class _TransactionalClient(_BaseClient):
162
164
  res = self._post(f"{self._url}/modules/{module_id}/data", json=data)
163
165
  return res if "failures" in res else res["numberOfCellsChanged"]
164
166
 
167
+ def write_to_module(self, module_id: int, data: list[dict[str, Any]]) -> int | dict[str, Any]:
168
+ warnings.warn(
169
+ "`write_to_module()` is deprecated and will be removed in a future version. "
170
+ "Use `update_module_data()` instead.",
171
+ DeprecationWarning,
172
+ stacklevel=1,
173
+ )
174
+ return self.update_module_data(module_id, data)
175
+
165
176
  def add_items_to_list(
166
177
  self, list_id: int, items: list[dict[str, str | int | dict]]
167
178
  ) -> InsertionResult:
anaplan_sdk/models.py CHANGED
@@ -1,318 +1,329 @@
1
- from pydantic import BaseModel, Field, field_validator
1
+ from typing import Literal, TypeAlias
2
+
3
+ from pydantic import BaseModel, ConfigDict, Field, field_validator
4
+ from pydantic.alias_generators import to_camel
5
+
6
+ ExportTypes: TypeAlias = Literal[
7
+ "TABULAR_MULTI_COLUMN",
8
+ "TABULAR_SINGLE_COLUMN",
9
+ "GRID_CURRENT_PAGE",
10
+ "AUDIT_LOG",
11
+ "TABULAR_ALL_LINE_ITEMS",
12
+ "TABULAR_CURRENT_LINE_ITEM",
13
+ ]
14
+
15
+ ImportTypes: TypeAlias = Literal[
16
+ "MODULE_DATA", "HIERARCHY_DATA", "LINE_ITEM_DEFINITION", "USERS", "VERSIONS"
17
+ ]
2
18
 
3
19
 
4
20
  class Workspace(BaseModel):
5
- id: str
6
- """The unique identifier of this workspace."""
7
- name: str
8
- """The name of this workspace that is also displayed to the users. This can change any time."""
9
- active: bool
10
- """Whether this workspace is active or not."""
11
- size_allowance: int = Field(alias="sizeAllowance", ge=0)
12
- """The maximum allowed size of this workspace in bytes."""
13
- current_size: int = Field(alias="currentSize", ge=0)
14
- """The current size of this workspace in bytes."""
21
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
22
+ id: str = Field(description="The unique identifier of this workspace.")
23
+ name: str = Field(description="The name of this workspace that is also displayed to the users.")
24
+ active: bool = Field(description="Whether this workspace is active or not.")
25
+ size_allowance: int = Field(description="The maximum allowed size of this workspace in bytes.")
26
+ current_size: int = Field(description="The current size of this workspace in bytes.")
15
27
 
16
28
 
17
29
  class Model(BaseModel):
18
- id: str
19
- """The unique identifier of this model."""
30
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
31
+ id: str = Field(description="The unique identifier of this model.")
20
32
  name: str
21
- """The name of this model that is also displayed to the users. This can change any time."""
22
- active_state: str = Field(alias="activeState")
23
- """The current state of this model. One of "ARCHIVED", "UNLOCKED", "ACTIVE"."""
24
- last_saved_serial_number: int = Field(alias="lastSavedSerialNumber")
25
- """The serial number of the last save of this model."""
26
- last_modified_by_user_guid: str = Field(alias="lastModifiedByUserGuid")
27
- """The unique identifier of the user who last modified this model."""
28
- memory_usage: int | None = Field(None, alias="memoryUsage")
29
- """The memory usage of this model in bytes."""
30
- current_workspace_id: str = Field(alias="currentWorkspaceId")
31
- """The unique identifier of the workspace that this model is currently in."""
32
- current_workspace_name: str = Field(alias="currentWorkspaceName")
33
- """The name of the workspace that this model is currently in."""
34
- url: str = Field(alias="modelUrl")
35
- """The URL of this model."""
36
- category_values: list = Field(alias="categoryValues")
37
- """The category values of this model."""
38
- iso_creation_date: str = Field(alias="isoCreationDate")
39
- """The creation date of this model in ISO format."""
40
- last_modified: str = Field(alias="lastModified")
41
- """The last modified date of this model in ISO format."""
33
+ active_state: Literal["ARCHIVED", "UNLOCKED", "ACTIVE", "PRODUCTION"] = Field(
34
+ description="The current state of this model."
35
+ )
36
+ last_saved_serial_number: int = Field(
37
+ description="The serial number of the last save of this model."
38
+ )
39
+ last_modified_by_user_guid: str = Field(
40
+ description="The unique identifier of the user who last modified this model."
41
+ )
42
+ memory_usage: int = Field(0, description="The memory usage of this model in bytes.")
43
+ current_workspace_id: str = Field(
44
+ description="The unique identifier of the workspace that this model is currently in."
45
+ )
46
+ current_workspace_name: str = Field(
47
+ description="The name of the workspace that this model is currently in."
48
+ )
49
+ url: str = Field(validation_alias="modelUrl", description="The current URL of this model.")
50
+ category_values: list = Field(description="The category values of this model.")
51
+ iso_creation_date: str = Field(description="The creation date of this model in ISO format.")
52
+ last_modified: str = Field(description="The last modified date of this model.")
42
53
 
43
54
 
44
55
  class File(BaseModel):
45
- id: int
46
- """The unique identifier of this file."""
47
- name: str
48
- """The name of this file."""
49
- chunk_count: int = Field(alias="chunkCount")
50
- """The number of chunks this file is split into."""
51
- delimiter: str | None = Field(None)
52
- """The delimiter used in this file."""
53
- encoding: str | None = Field(None)
54
- """The encoding of this file."""
55
- first_data_row: int = Field(alias="firstDataRow")
56
- """The row number of the first data row in this file."""
57
- format: str | None = Field(None)
58
- """The format of this file."""
59
- header_row: int = Field(alias="headerRow")
60
- """The row number of the header row in this file."""
61
- separator: str | None = Field(None)
62
- """The separator used in this file."""
56
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
57
+ id: int = Field(description="The unique identifier of this file.")
58
+ name: str = Field(description="The name of this file.")
59
+ chunk_count: int = Field(description="The number of chunks this file is split into.")
60
+ delimiter: str | None = Field(None, description="The delimiter used in this file.")
61
+ encoding: str | None = Field(None, description="The encoding of this file.")
62
+ first_data_row: int = Field(description="The row number of the first data row in this file.")
63
+ format: str | None = Field(None, description="The format of this file.")
64
+ header_row: int = Field(description="The row number of the header row in this file.")
65
+ separator: str | None = Field(None, description="The separator used in this file.")
63
66
 
64
67
 
65
68
  class List(BaseModel):
66
- id: int
67
- """The unique identifier of this list."""
68
- name: str
69
- """The name of this list."""
69
+ id: int = Field(description="The unique identifier of this list.")
70
+ name: str = Field(description="The name of this list.")
70
71
 
71
72
 
72
73
  class ListMetadata(BaseModel):
73
- id: int
74
- """The unique identifier of this list."""
75
- name: str
76
- """The name of this list."""
77
- has_selective_access: bool = Field(alias="hasSelectiveAccess")
78
- """Whether this list has selective access or not."""
79
- properties: list = Field([])
80
- """The properties of this list."""
81
- production_data: bool = Field(alias="productionData")
82
- """Whether this list is production data or not."""
83
- managed_by: str = Field(alias="managedBy")
84
- """The user who manages this list."""
85
- numbered_list: bool = Field(alias="numberedList")
86
- """Whether this list is a numbered list or not."""
87
- use_top_level_as_page_default: bool = Field(alias="useTopLevelAsPageDefault")
88
- """Whether the top level is used as the page default or not."""
89
- item_count: int = Field(alias="itemCount")
90
- """The number of items in this list."""
91
- next_item_index: int | None = Field(None, alias="nextItemIndex")
92
- """The index of the next item in this list."""
93
- workflow_enabled: bool = Field(alias="workflowEnabled")
94
- """Whether the workflow is enabled for this list or not."""
95
- permitted_items: int = Field(alias="permittedItems")
96
- """The number of permitted items in this list."""
97
- used_in_applies_to: str | None = Field(None, alias="usedInAppliesTo")
98
- """The applies to value of this list."""
74
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
75
+ id: int = Field(description="The unique identifier of this list.")
76
+ name: str = Field(description="The name of this list.")
77
+ has_selective_access: bool = Field(description="Whether this list has selective access or not.")
78
+ properties: list = Field([], description="The properties of this list.")
79
+ production_data: bool = Field(description="Whether this list is production data or not.")
80
+ managed_by: str = Field(description="The user who manages this list.")
81
+ numbered_list: bool = Field(description="Whether this list is a numbered list or not.")
82
+ use_top_level_as_page_default: bool = Field(
83
+ description="Whether the top level is used as the page default or not."
84
+ )
85
+ item_count: int = Field(description="The number of items in this list.")
86
+ next_item_index: int | None = Field(
87
+ None, description="The index of the next item in this list."
88
+ )
89
+ workflow_enabled: bool = Field(
90
+ description="Whether the workflow is enabled for this list or not."
91
+ )
92
+ permitted_items: int = Field(description="The number of permitted items in this list.")
93
+ used_in_applies_to: str | None = Field(None, description="The applies to value of this list.")
99
94
 
100
95
 
101
- class ListItem(BaseModel):
102
- id: int
103
- """The unique identifier of this list item."""
104
- name: str
105
- """The name of this list item."""
106
- code: str | None = Field(None)
107
- """The code of this list item."""
108
- properties: dict = Field({})
109
- """The properties of this list item."""
110
- subsets: dict = Field({})
111
- """The subsets of this list item."""
112
- parent: str | None = Field(None)
113
- """The parent of this list item."""
114
- parent_id: str | None = Field(None, alias="parentId")
115
- """The unique identifier of the parent of this list item."""
96
+ class Action(BaseModel):
97
+ model_config = ConfigDict(populate_by_name=True)
98
+ id: int = Field(description="The unique identifier of this action.")
99
+ name: str = Field(
100
+ description="The name of this Action. This is the same as the one displayed in the Web UI."
101
+ )
102
+ type: str | None = Field(
103
+ None, validation_alias="actionType", description="The type of this action."
104
+ )
116
105
 
117
106
 
118
- class Action(BaseModel):
119
- id: int
120
- """The unique identifier of this action."""
121
- name: str
122
- """The name of this action."""
123
- type: str = Field(alias="actionType")
124
- """The type of this action."""
107
+ class ListItem(BaseModel):
108
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
109
+ id: int = Field(description="The unique identifier of this list item.")
110
+ name: str = Field(description="The name of this list item.")
111
+ code: str | None = Field(None, description="The code of this list item.")
112
+ properties: dict = Field({}, description="The properties of this list item.")
113
+ subsets: dict = Field({}, description="The subsets of this list item.")
114
+ parent: str | None = Field(None, description="The parent of this list item.")
115
+ parent_id: str | None = Field(
116
+ None, description="The unique identifier of the parent of this list item."
117
+ )
125
118
 
126
119
 
127
120
  class Process(BaseModel):
128
- id: int
129
- """The unique identifier of this process."""
130
- name: str
131
- """The name of this process."""
121
+ id: int = Field(description="The unique identifier of this process.")
122
+ name: str = Field(description="The name of this process.")
132
123
 
133
124
 
134
125
  class Import(BaseModel):
135
- id: int
136
- """The unique identifier of this import."""
137
- name: str
138
- """The name of this import."""
139
- type: str = Field(alias="importType")
140
- """The type of this import."""
141
- source_id: int | None = Field(None, alias="importDataSourceId")
142
- """The unique identifier of the data source of this import."""
126
+ id: int = Field(description="The unique identifier of this import.")
127
+ name: str = Field(description="The name of this import.")
128
+ type: ImportTypes = Field(validation_alias="importType", description="The type of this import.")
129
+ file_id: int | None = Field(
130
+ None,
131
+ validation_alias="importDataSourceId",
132
+ description=(
133
+ "The unique identifier of the data source of this import. If it is absent, it means "
134
+ "that the import is not a file import."
135
+ ),
136
+ )
143
137
 
144
138
  # noinspection PyNestedDecorators
145
- @field_validator("source_id", mode="before")
139
+ @field_validator("file_id", mode="before")
146
140
  @classmethod
147
141
  def _empty_source_is_none(cls, inp: str):
148
142
  return inp if inp else None
149
143
 
150
144
 
151
145
  class Export(BaseModel):
152
- id: int
153
- """The unique identifier of this export."""
154
- name: str
155
- """The name of this export."""
156
- type: str = Field(alias="exportType")
157
- """The type of this export."""
158
- format: str = Field(alias="exportFormat")
159
- """The format of this export."""
160
- encoding: str
161
- """The encoding of this export."""
162
- layout: str
163
- """The layout of this export. Will hold values such as `GRID_CURRENT_PAGE`
164
- and `TABULAR_ALL_LINE_ITEMS`, representing the Anaplan Export Structure.
165
- """
146
+ model_config = ConfigDict(populate_by_name=True)
147
+ id: int = Field(description="The unique identifier of this export.")
148
+ name: str = Field(description="The name of this export.")
149
+ type: ExportTypes = Field(validation_alias="exportType", description="The type of this export.")
150
+ format: str = Field(validation_alias="exportFormat", description="The format of this export.")
151
+ encoding: str | None = Field(None, description="The encoding of this export.")
152
+ layout: ExportTypes = Field(
153
+ description="The layout of this export, representing the Anaplan Export Structure."
154
+ )
166
155
 
167
156
 
168
157
  class Module(BaseModel):
169
- id: int
170
- """The unique identifier of this module."""
171
- name: str
172
- """The name of this module."""
158
+ id: int = Field(description="The unique identifier of this module.")
159
+ name: str = Field(description="The name of this module.")
173
160
 
174
161
 
175
162
  class ModelStatus(BaseModel):
176
- peak_memory_usage_estimate: int | None = Field(alias="peakMemoryUsageEstimate")
177
- """The peak memory usage estimate of this model."""
178
- peak_memory_usage_time: int | None = Field(alias="peakMemoryUsageTime")
179
- """The peak memory usage time of this model."""
180
- progress: float
181
- """The progress of this model."""
182
- current_step: str = Field(alias="currentStep")
183
- """The current step of this model."""
184
- tooltip: str | None
185
- """The tooltip of this model."""
186
- task_id: str | None = Field(alias="taskId")
187
- """The unique identifier of the task of this model."""
188
- creation_time: int = Field(alias="creationTime")
189
- """The creation time of this model."""
190
- export_task_type: str | None = Field(alias="exportTaskType")
191
- """The export task type of this model."""
163
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
164
+ peak_memory_usage_estimate: int | None = Field(
165
+ description="The peak memory usage estimate of this model."
166
+ )
167
+ peak_memory_usage_time: int | None = Field(
168
+ description="The peak memory usage time of this model."
169
+ )
170
+ progress: float = Field(description="The progress of this model.")
171
+ current_step: str = Field(description="The current step of this model.")
172
+ tooltip: str | None = Field(description="The tooltip of this model.")
173
+ task_id: str | None = Field(description="The unique identifier of the task of this model.")
174
+ creation_time: int = Field(description="The creation time of this model.")
175
+ export_task_type: str | None = Field(description="The export task type of this model.")
192
176
 
193
177
 
194
178
  class LineItem(BaseModel):
195
- id: int
196
- """The unique identifier of this line item."""
197
- name: str
198
- """The name of this line item."""
199
- module_id: int = Field(alias="moduleId")
200
- """The unique identifier of the module this line item belongs to."""
201
- module_name: str = Field(alias="moduleName")
202
- """The name of the module this line item belongs to."""
203
- format: str
204
- """The format of this line item."""
205
- format_metadata: dict = Field(alias="formatMetadata")
206
- """The format metadata of this line item."""
207
- summary: str
208
- """The summary of this line item."""
209
- applies_to: list[dict] = Field([], alias="appliesTo")
210
- """The applies to value of this line item."""
211
- time_scale: str = Field(alias="timeScale")
212
- """The time scale of this line item."""
213
- time_range: str = Field(alias="timeRange")
214
- """The time range of this line item."""
215
- version: dict
216
- """The version of this line item."""
217
- style: str
218
- """The style of this line item."""
219
- cell_count: int | None = Field(None, alias="cellCount")
220
- """The cell count of this line item."""
221
- notes: str
222
- """The notes of this line item."""
223
- is_summary: bool = Field(alias="isSummary")
224
- """Whether this line item is a summary or not."""
225
- formula: str | None = Field(None)
226
- """The formula of this line item."""
227
- formula_scope: str = Field(alias="formulaScope")
228
- """The formula scope of this line item."""
229
- use_switchover: bool = Field(alias="useSwitchover")
230
- """Whether the switchover is used or not."""
231
- breakback: bool
232
- """Whether the breakback is enabled or not."""
233
- brought_forward: bool = Field(alias="broughtForward")
234
- """Whether the brought forward is enabled or not."""
235
- start_of_section: bool = Field(alias="startOfSection")
236
- """Whether this line item is the start of a section or not."""
179
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
180
+ id: int = Field(description="The unique identifier of this line item.")
181
+ name: str = Field(description="The name of this line item.")
182
+ module_id: int = Field(
183
+ description="The unique identifier of the module this line item belongs to."
184
+ )
185
+ module_name: str = Field(description="The name of the module this line item belongs to.")
186
+ format: str = Field(description="The format of this line item.")
187
+ format_metadata: dict = Field(description="The format metadata of this line item.")
188
+ summary: str = Field(description="The summary of this line item.")
189
+ applies_to: list[dict] = Field([], description="The applies to value of this line item.")
190
+ time_scale: str = Field(description="The time scale of this line item.")
191
+ time_range: str = Field(description="The time range of this line item.")
192
+ version: dict = Field(description="The version of this line item.")
193
+ style: str = Field(description="The style of this line item.")
194
+ cell_count: int | None = Field(None, description="The cell count of this line item.")
195
+ notes: str = Field(description="The notes of this line item.")
196
+ is_summary: bool = Field(description="Whether this line item is a summary or not.")
197
+ formula: str | None = Field(None, description="The formula of this line item.")
198
+ formula_scope: str = Field(description="The formula scope of this line item.")
199
+ use_switchover: bool = Field(description="Whether the switchover is used or not.")
200
+ breakback: bool = Field(description="Whether the breakback is enabled or not.")
201
+ brought_forward: bool = Field(description="Whether the brought forward is enabled or not.")
202
+ start_of_section: bool = Field(
203
+ description="Whether this line item is the start of a section or not."
204
+ )
237
205
 
238
206
 
239
207
  class Failure(BaseModel):
240
- index: int = Field(alias="requestIndex")
241
- """The index of the item that failed."""
242
- reason: str = Field(alias="failureType")
243
- """The reason for the failure."""
244
- details: str = Field(alias="failureMessageDetails")
245
- """The details of the failure."""
208
+ model_config = ConfigDict(populate_by_name=True)
209
+ index: int = Field(
210
+ validation_alias="requestIndex", description="The index of the item that failed."
211
+ )
212
+ reason: str = Field(validation_alias="failureType", description="The reason for the failure.")
213
+ details: str = Field(
214
+ validation_alias="failureMessageDetails", description="The details of the failure."
215
+ )
246
216
 
247
217
 
248
218
  class InsertionResult(BaseModel):
249
- added: int
250
- """The number of items successfully added."""
251
- ignored: int
252
- """The number of items ignored, or items that failed."""
253
- total: int
254
- """The total number of items."""
255
- failures: list[Failure] = Field([])
256
- """The list of failures."""
219
+ added: int = Field(description="The number of items successfully added.")
220
+ ignored: int = Field(description="The number of items ignored, or items that failed.")
221
+ total: int = Field(description="The total number of items.")
222
+ failures: list[Failure] = Field([], description="The list of failures.")
257
223
 
258
224
 
259
225
  class Revision(BaseModel):
260
- id: str
261
- """The unique identifier of this revision."""
262
- name: str
263
- """The name of this revision."""
264
- description: str | None = Field(None)
265
- """The description of this revision. Not always present."""
266
- created_on: str = Field(alias="createdOn")
267
- """The creation date of this revision in ISO format."""
268
- created_by: str = Field(alias="createdBy")
269
- """The unique identifier of the user who created this revision."""
270
- creation_method: str = Field(alias="creationMethod")
271
- """The creation method of this revision."""
272
- applied_on: str = Field(alias="appliedOn")
273
- """The application date of this revision in ISO format."""
274
- applied_by: str = Field(alias="appliedBy")
275
- """The unique identifier of the user who applied this revision."""
226
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
227
+ id: str = Field(description="The unique identifier of this revision.")
228
+ name: str = Field(description="The name of this revision.")
229
+ description: str | None = Field(
230
+ None, description="The description of this revision. Not always present."
231
+ )
232
+ created_on: str = Field(description="The creation date of this revision in ISO format.")
233
+ created_by: str = Field(
234
+ description="The unique identifier of the user who created this revision."
235
+ )
236
+ creation_method: str = Field(description="The creation method of this revision.")
237
+ applied_on: str = Field(description="The application date of this revision in ISO format.")
238
+ applied_by: str = Field(
239
+ description="The unique identifier of the user who applied this revision."
240
+ )
276
241
 
277
242
 
278
243
  class ModelRevision(BaseModel):
279
- id: str = Field(alias="modelId")
280
- """The unique identifier of the model this revision belongs to."""
281
- name: str = Field(alias="modelName")
282
- """The name of the model this revision belongs to."""
283
- workspace_id: str = Field(alias="workspaceId")
284
- """The unique identifier of the workspace this revision belongs to."""
285
- applied_by: str = Field(alias="appliedBy")
286
- """The unique identifier of the user who applied this revision."""
287
- applied_on: str = Field(alias="appliedOn")
288
- """The application date of this revision in ISO format."""
289
- applied_method: str = Field(alias="appliedMethod")
290
- """The application method of this revision."""
291
- deleted: bool | None = Field(None, alias="modelDeleted")
292
- """Whether the model has been deleted or not."""
244
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
245
+ id: str = Field(
246
+ validation_alias="modelId",
247
+ description="The unique identifier of the model this revision belongs to.",
248
+ )
249
+ name: str = Field(
250
+ validation_alias="modelName", description="The name of the model this revision belongs to."
251
+ )
252
+ workspace_id: str = Field(
253
+ description="The unique identifier of the workspace this revision belongs to."
254
+ )
255
+ applied_by: str = Field(
256
+ description="The unique identifier of the user who applied this revision."
257
+ )
258
+ applied_on: str = Field(description="The application date of this revision in ISO format.")
259
+ applied_method: str = Field(description="The application method of this revision.")
260
+ deleted: bool | None = Field(
261
+ None,
262
+ validation_alias="modelDeleted",
263
+ description="Whether the model has been deleted or not.",
264
+ )
293
265
 
294
266
 
295
267
  class SyncTask(BaseModel):
296
- task_id: str = Field(alias="taskId")
297
- """The unique identifier of this task."""
298
- task_state: str = Field(alias="taskState")
299
- """The state of this task."""
300
- creation_time: int = Field(alias="creationTime")
301
- """The creation time of this task."""
268
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
269
+ id: str = Field(validation_alias="taskId", description="The unique identifier of this task.")
270
+ task_state: str = Field(description="The state of this task.")
271
+ creation_time: int = Field(description="The creation time of this task.")
302
272
 
303
273
 
304
274
  class User(BaseModel):
305
- id: str
306
- """The unique identifier of this user."""
307
- active: bool
308
- """Whether this user is active or not."""
309
- email: str
310
- """The email address of this user."""
311
- email_opt_in: bool = Field(alias="emailOptIn")
312
- """Whether this user has opted in to receive emails or not."""
313
- first_name: str = Field(alias="firstName")
314
- """The first name of this user."""
315
- last_name: str = Field(alias="lastName")
316
- """The last name of this user."""
317
- last_login_date: str | None = Field(None, alias="lastLoginDate")
318
- """The last login date of this user in ISO format."""
275
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
276
+ id: str = Field(description="The unique identifier of this user.")
277
+ active: bool = Field(description="Whether this user is active or not.")
278
+ email: str = Field(description="The email address of this user.")
279
+ email_opt_in: bool = Field(
280
+ description="Whether this user has opted in to receive emails or not."
281
+ )
282
+ first_name: str = Field(description="The first name of this user.")
283
+ last_name: str = Field(description="The last name of this user.")
284
+ last_login_date: str | None = Field(
285
+ None, description="The last login date of this user in ISO format."
286
+ )
287
+
288
+
289
+ class TaskSummary(BaseModel):
290
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
291
+ id: str = Field(validation_alias="taskId", description="The unique identifier of this task.")
292
+ task_state: Literal["NOT_STARTED", "IN_PROGRESS", "COMPLETE"] = Field(
293
+ description="The state of this task."
294
+ )
295
+ creation_time: int = Field(description="Unix timestamp of when this task was created.")
296
+
297
+
298
+ class TaskResultDetail(BaseModel):
299
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
300
+ local_message_text: str = Field(description="Error message text.")
301
+ occurrences: int = Field(0, description="The number of occurrences of this error.")
302
+ type: str = Field(description="The type of this error.")
303
+ values: list[str] = Field([], description="Further error information if available.")
304
+
305
+
306
+ class TaskResult(BaseModel):
307
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
308
+ details: list[TaskResultDetail] = Field(
309
+ [], description="The details of this task result if available."
310
+ )
311
+ successful: bool = Field(description="Whether this task completed successfully or not.")
312
+ failure_dump_available: bool = Field(
313
+ description="Whether this task completed successfully or not."
314
+ )
315
+ nested_results: list["TaskResult"] = Field(
316
+ [], description="The nested results of this task, if available."
317
+ )
318
+
319
+
320
+ class TaskStatus(BaseModel):
321
+ model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
322
+ id: str = Field(validation_alias="taskId", description="The unique identifier of this task.")
323
+ task_state: Literal["NOT_STARTED", "IN_PROGRESS", "COMPLETE"] = Field(
324
+ description="The state of this task."
325
+ )
326
+ creation_time: int = Field(description="Unix timestamp of when this task was created.")
327
+ progress: float = Field(description="The progress of this task as a float between 0 and 1.")
328
+ current_step: str | None = Field(None, description="The current step of this task.")
329
+ result: TaskResult | None = Field(None)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anaplan-sdk
3
- Version: 0.2.11
3
+ Version: 0.3.0
4
4
  Summary: Provides pythonic access to the Anaplan API
5
5
  Project-URL: Homepage, https://vinzenzklass.github.io/anaplan-sdk/
6
6
  Project-URL: Repository, https://github.com/VinzenzKlass/anaplan-sdk
@@ -38,7 +38,7 @@ implementation details like authentication, error handling, chunking, compressio
38
38
  This Projects supports
39
39
  the [Bulk APIs](https://help.anaplan.com/use-the-bulk-apis-93218e5e-00e5-406e-8361-09ab861889a7),
40
40
  the [Transactional APIs](https://help.anaplan.com/use-the-transactional-apis-cc1c1e91-39fc-4272-a4b5-16bc91e9c313) and
41
- the [ALM APsI](https://help.anaplan.com/application-lifecycle-management-api-2565cfa6-e0c2-4e24-884e-d0df957184d6),
41
+ the [ALM APIs](https://help.anaplan.com/application-lifecycle-management-api-2565cfa6-e0c2-4e24-884e-d0df957184d6),
42
42
  the [Audit APIs](https://auditservice.docs.apiary.io/#),
43
43
  providing both synchronous and asynchronous Clients.
44
44
 
@@ -2,18 +2,18 @@ anaplan_sdk/__init__.py,sha256=5fr-SZSsH6f3vkRUTDoK6xdAN31cCpe9Mwz2VNu47Uw,134
2
2
  anaplan_sdk/_auth.py,sha256=0d495G_iU8vfpk29BJow7Jw2staf18nXqpJlSfaL9h8,5123
3
3
  anaplan_sdk/_base.py,sha256=MEE6LpL788QTkrpAVsYI5hu3RfbzSMLGUj-QSW8-OU0,6160
4
4
  anaplan_sdk/exceptions.py,sha256=ALkA9fBF0NQ7dufFxV6AivjmHyuJk9DOQ9jtJV2n7f0,1809
5
- anaplan_sdk/models.py,sha256=ceMaVctpjwQHk7a71Io_-1YcCQshx5i1YYnqxS51nYw,12491
5
+ anaplan_sdk/models.py,sha256=CpfFVJcW4AVwbAoI6GuPClbywjs2bWXOyH7Vrlnlo4o,16255
6
6
  anaplan_sdk/_async_clients/__init__.py,sha256=wT6qfi4f_4vLFWTJQTsBw8r3DrHtoTIVqi88p5_j-Cg,259
7
7
  anaplan_sdk/_async_clients/_alm.py,sha256=HtpwKNCc5eb6DUgS8nqNocxzaoaHOAMQPo0SaTMaD-A,4021
8
8
  anaplan_sdk/_async_clients/_audit.py,sha256=wgJx58aDksWJLu4MU-tOz76KjG41AVzBW0v3jAEv9GE,2897
9
- anaplan_sdk/_async_clients/_bulk.py,sha256=kviZxMbTolz9ZmbtE_hhOxbnmZghToRo3mxIhVADzho,22299
10
- anaplan_sdk/_async_clients/_transactional.py,sha256=yhBt5Fzpt07IGIhvMZWcMoXEIGUlSJwAsxvzaq2vT9c,7056
9
+ anaplan_sdk/_async_clients/_bulk.py,sha256=X5W6-WgUYW9O2f8SIWy7IxjSv4vAz9fYL9jxpEzrpXQ,22354
10
+ anaplan_sdk/_async_clients/_transactional.py,sha256=LlrEVc6c9cUD62PBlOCNjS0ALxqoHy5GZvadacyPbG8,7496
11
11
  anaplan_sdk/_clients/__init__.py,sha256=FsbwvZC1FHrxuRXwbPxUzbhz_lO1DpXIxEOjx6-3QuA,219
12
12
  anaplan_sdk/_clients/_alm.py,sha256=wzhibRuNzsK3PZM2EOI3OnSGHfv8CG2fuY5zLbnSqog,3912
13
13
  anaplan_sdk/_clients/_audit.py,sha256=jqj_sTGNUaM2jAu91Us747pVULntPUkL_qkA4nKc8so,2981
14
- anaplan_sdk/_clients/_bulk.py,sha256=hTepWQZ-IxAs2WPqsuTfWF3ExuWWrNiMD9I4viQpUAQ,22314
15
- anaplan_sdk/_clients/_transactional.py,sha256=-DuNhhfp2h9fc-ENJQRh9qwXsZiBi3OV1LeH3S7Jzsc,6871
16
- anaplan_sdk-0.2.11.dist-info/METADATA,sha256=1GMwYl98joRinRzgF3edxbhnY0FeDFE236OnrYNK8CY,3618
17
- anaplan_sdk-0.2.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
- anaplan_sdk-0.2.11.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
19
- anaplan_sdk-0.2.11.dist-info/RECORD,,
14
+ anaplan_sdk/_clients/_bulk.py,sha256=3oOaUqjvHF-L-ThFK7joLMQ2iDSSFZ9y5mVUhW45fp8,22398
15
+ anaplan_sdk/_clients/_transactional.py,sha256=2ssYdMY9vynQUwwigOvgSgi2-wbfXDQaAShLqXbVFSQ,7299
16
+ anaplan_sdk-0.3.0.dist-info/METADATA,sha256=b4_PgGjPB-TPX2RV3R5PMLxozPjAnCqq6naA3BXLpNA,3617
17
+ anaplan_sdk-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ anaplan_sdk-0.3.0.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
19
+ anaplan_sdk-0.3.0.dist-info/RECORD,,