anaplan-sdk 0.5.0a4__py3-none-any.whl → 0.5.0a5__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.
- anaplan_sdk/_async_clients/_audit.py +3 -1
- anaplan_sdk/_async_clients/_bulk.py +20 -22
- anaplan_sdk/_clients/_audit.py +3 -1
- anaplan_sdk/_clients/_bulk.py +20 -22
- anaplan_sdk/_services.py +14 -0
- anaplan_sdk/models/_bulk.py +6 -4
- {anaplan_sdk-0.5.0a4.dist-info → anaplan_sdk-0.5.0a5.dist-info}/METADATA +1 -1
- {anaplan_sdk-0.5.0a4.dist-info → anaplan_sdk-0.5.0a5.dist-info}/RECORD +10 -10
- {anaplan_sdk-0.5.0a4.dist-info → anaplan_sdk-0.5.0a5.dist-info}/WHEEL +0 -0
- {anaplan_sdk-0.5.0a4.dist-info → anaplan_sdk-0.5.0a5.dist-info}/licenses/LICENSE +0 -0
@@ -21,7 +21,9 @@ class _AsyncAuditClient:
|
|
21
21
|
) -> list[User]:
|
22
22
|
"""
|
23
23
|
Lists all the Users in the authenticated users default tenant.
|
24
|
-
:param search_pattern:
|
24
|
+
:param search_pattern: **Caution: This is an undocumented Feature and may behave
|
25
|
+
unpredictably. It requires the Tenant Admin role. For non-admin users, it is
|
26
|
+
ignored.** Optionally filter for specific users. When provided,
|
25
27
|
case-insensitive matches users with emails or names containing this string.
|
26
28
|
You can use the wildcards `%` for 0-n characters, and `_` for exactly 1 character.
|
27
29
|
When None (default), returns all users.
|
@@ -7,7 +7,7 @@ import httpx
|
|
7
7
|
from typing_extensions import Self
|
8
8
|
|
9
9
|
from anaplan_sdk._auth import _create_auth
|
10
|
-
from anaplan_sdk._services import _AsyncHttpService, action_url, sort_params
|
10
|
+
from anaplan_sdk._services import _AsyncHttpService, action_url, models_url, sort_params
|
11
11
|
from anaplan_sdk.exceptions import AnaplanActionError, InvalidIdentifierException
|
12
12
|
from anaplan_sdk.models import (
|
13
13
|
Action,
|
@@ -142,34 +142,24 @@ class AsyncClient:
|
|
142
142
|
f"Initialized AsyncClient with workspace_id={workspace_id}, model_id={model_id}"
|
143
143
|
)
|
144
144
|
|
145
|
-
|
146
|
-
def from_existing(
|
147
|
-
cls, existing: Self, *, workspace_id: str | None = None, model_id: str | None = None
|
148
|
-
) -> Self:
|
145
|
+
def with_model(self, model_id: str | None = None, workspace_id: str | None = None) -> Self:
|
149
146
|
"""
|
150
|
-
Create a new instance of the Client
|
151
|
-
|
152
|
-
authentication and configuration. This creates a shallow copy of the existing client and
|
153
|
-
optionally updates the relevant attributes to the new workspace and model. You can provide
|
154
|
-
either a new workspace Id or a new model Id, or both. If you do not provide one of them,
|
155
|
-
the existing value will be used. If you omit both, the new instance will be an identical
|
156
|
-
copy of the existing instance.
|
157
|
-
|
158
|
-
:param existing: The existing instance to copy.
|
147
|
+
Create a new instance of the Client with the given model and workspace Ids. **This creates
|
148
|
+
a copy of the current client. The current instance remains unchanged.**
|
159
149
|
:param workspace_id: The workspace Id to use or None to use the existing workspace Id.
|
160
150
|
:param model_id: The model Id to use or None to use the existing model Id.
|
161
151
|
:return: A new instance of the Client.
|
162
152
|
"""
|
163
|
-
client = copy(
|
164
|
-
new_ws_id = workspace_id or
|
165
|
-
new_model_id = model_id or
|
153
|
+
client = copy(self)
|
154
|
+
new_ws_id = workspace_id or self._workspace_id
|
155
|
+
new_model_id = model_id or self._model_id
|
166
156
|
logger.debug(
|
167
157
|
f"Creating a new AsyncClient from existing instance "
|
168
158
|
f"with workspace_id={new_ws_id}, model_id={new_model_id}."
|
169
159
|
)
|
170
160
|
client._url = f"https://api.anaplan.com/2/0/workspaces/{new_ws_id}/models/{new_model_id}"
|
171
|
-
client._transactional_client = _AsyncTransactionalClient(
|
172
|
-
client._alm_client = _AsyncAlmClient(
|
161
|
+
client._transactional_client = _AsyncTransactionalClient(self._http, new_model_id)
|
162
|
+
client._alm_client = _AsyncAlmClient(self._http, new_model_id)
|
173
163
|
return client
|
174
164
|
|
175
165
|
@property
|
@@ -235,7 +225,9 @@ class AsyncClient:
|
|
235
225
|
) -> list[Workspace]:
|
236
226
|
"""
|
237
227
|
Lists all the Workspaces the authenticated user has access to.
|
238
|
-
:param search_pattern:
|
228
|
+
:param search_pattern: **Caution: This is an undocumented Feature and may behave
|
229
|
+
unpredictably. It requires the Tenant Admin role. For non-admin users, it is
|
230
|
+
ignored.** Optionally filter for specific workspaces. When provided,
|
239
231
|
case-insensitive matches workspaces with names containing this string.
|
240
232
|
You can use the wildcards `%` for 0-n characters, and `_` for exactly 1 character.
|
241
233
|
When None (default), returns all users.
|
@@ -253,13 +245,19 @@ class AsyncClient:
|
|
253
245
|
|
254
246
|
async def get_models(
|
255
247
|
self,
|
248
|
+
only_in_workspace: bool | str = False,
|
256
249
|
search_pattern: str | None = None,
|
257
250
|
sort_by: Literal["active_state", "name"] | None = None,
|
258
251
|
descending: bool = False,
|
259
252
|
) -> list[Model]:
|
260
253
|
"""
|
261
254
|
Lists all the Models the authenticated user has access to.
|
262
|
-
:param
|
255
|
+
:param only_in_workspace: If True, only lists models in the workspace provided when
|
256
|
+
instantiating the client. If a string is provided, only lists models in the workspace
|
257
|
+
with the given Id. If False (default), lists models in all workspaces the user
|
258
|
+
:param search_pattern: **Caution: This is an undocumented Feature and may behave
|
259
|
+
unpredictably. It requires the Tenant Admin role. For non-admin users, it is
|
260
|
+
ignored.** Optionally filter for specific models. When provided,
|
263
261
|
case-insensitive matches model names containing this string.
|
264
262
|
You can use the wildcards `%` for 0-n characters, and `_` for exactly 1 character.
|
265
263
|
When None (default), returns all models.
|
@@ -271,7 +269,7 @@ class AsyncClient:
|
|
271
269
|
if search_pattern:
|
272
270
|
params["s"] = search_pattern
|
273
271
|
res = await self._http.get_paginated(
|
274
|
-
|
272
|
+
models_url(only_in_workspace, self._workspace_id), "models", params=params
|
275
273
|
)
|
276
274
|
return [Model.model_validate(e) for e in res]
|
277
275
|
|
anaplan_sdk/_clients/_audit.py
CHANGED
@@ -21,7 +21,9 @@ class _AuditClient:
|
|
21
21
|
) -> list[User]:
|
22
22
|
"""
|
23
23
|
Lists all the Users in the authenticated users default tenant.
|
24
|
-
:param search_pattern:
|
24
|
+
:param search_pattern: **Caution: This is an undocumented Feature and may behave
|
25
|
+
unpredictably. It requires the Tenant Admin role. For non-admin users, it is
|
26
|
+
ignored.** Optionally filter for specific users. When provided,
|
25
27
|
case-insensitive matches users with emails or names containing this string.
|
26
28
|
You can use the wildcards `%` for 0-n characters, and `_` for exactly 1 character.
|
27
29
|
When None (default), returns all users.
|
anaplan_sdk/_clients/_bulk.py
CHANGED
@@ -8,7 +8,7 @@ import httpx
|
|
8
8
|
from typing_extensions import Self
|
9
9
|
|
10
10
|
from anaplan_sdk._auth import _create_auth
|
11
|
-
from anaplan_sdk._services import _HttpService, action_url, sort_params
|
11
|
+
from anaplan_sdk._services import _HttpService, action_url, models_url, sort_params
|
12
12
|
from anaplan_sdk.exceptions import AnaplanActionError, InvalidIdentifierException
|
13
13
|
from anaplan_sdk.models import (
|
14
14
|
Action,
|
@@ -147,34 +147,24 @@ class Client:
|
|
147
147
|
self.allow_file_creation = allow_file_creation
|
148
148
|
logger.debug(f"Initialized Client with workspace_id={workspace_id}, model_id={model_id}")
|
149
149
|
|
150
|
-
|
151
|
-
def from_existing(
|
152
|
-
cls, existing: Self, *, workspace_id: str | None = None, model_id: str | None = None
|
153
|
-
) -> Self:
|
150
|
+
def with_model(self, model_id: str | None = None, workspace_id: str | None = None) -> Self:
|
154
151
|
"""
|
155
|
-
Create a new instance of the Client
|
156
|
-
|
157
|
-
authentication and configuration. This creates a shallow copy of the existing client and
|
158
|
-
optionally updates the relevant attributes to the new workspace and model. You can provide
|
159
|
-
either a new workspace Id or a new model Id, or both. If you do not provide one of them,
|
160
|
-
the existing value will be used. If you omit both, the new instance will be an identical
|
161
|
-
copy of the existing instance.
|
162
|
-
|
163
|
-
:param existing: The existing instance to copy.
|
152
|
+
Create a new instance of the Client with the given model and workspace Ids. **This creates
|
153
|
+
a copy of the current client. The current instance remains unchanged.**
|
164
154
|
:param workspace_id: The workspace Id to use or None to use the existing workspace Id.
|
165
155
|
:param model_id: The model Id to use or None to use the existing model Id.
|
166
156
|
:return: A new instance of the Client.
|
167
157
|
"""
|
168
|
-
client = copy(
|
169
|
-
new_ws_id = workspace_id or
|
170
|
-
new_model_id = model_id or
|
158
|
+
client = copy(self)
|
159
|
+
new_ws_id = workspace_id or self._workspace_id
|
160
|
+
new_model_id = model_id or self._model_id
|
171
161
|
logger.debug(
|
172
162
|
f"Creating a new AsyncClient from existing instance "
|
173
163
|
f"with workspace_id={new_ws_id}, model_id={new_model_id}."
|
174
164
|
)
|
175
165
|
client._url = f"https://api.anaplan.com/2/0/workspaces/{new_ws_id}/models/{new_model_id}"
|
176
|
-
client._transactional_client = _TransactionalClient(
|
177
|
-
client._alm_client = _AlmClient(
|
166
|
+
client._transactional_client = _TransactionalClient(self._http, new_model_id)
|
167
|
+
client._alm_client = _AlmClient(self._http, new_model_id)
|
178
168
|
return client
|
179
169
|
|
180
170
|
@property
|
@@ -240,7 +230,9 @@ class Client:
|
|
240
230
|
) -> list[Workspace]:
|
241
231
|
"""
|
242
232
|
Lists all the Workspaces the authenticated user has access to.
|
243
|
-
:param search_pattern:
|
233
|
+
:param search_pattern: **Caution: This is an undocumented Feature and may behave
|
234
|
+
unpredictably. It requires the Tenant Admin role. For non-admin users, it is
|
235
|
+
ignored.** Optionally filter for specific workspaces. When provided,
|
244
236
|
case-insensitive matches workspaces with names containing this string.
|
245
237
|
You can use the wildcards `%` for 0-n characters, and `_` for exactly 1 character.
|
246
238
|
When None (default), returns all users.
|
@@ -258,13 +250,19 @@ class Client:
|
|
258
250
|
|
259
251
|
def get_models(
|
260
252
|
self,
|
253
|
+
only_in_workspace: bool | str = False,
|
261
254
|
search_pattern: str | None = None,
|
262
255
|
sort_by: Literal["active_state", "name"] | None = None,
|
263
256
|
descending: bool = False,
|
264
257
|
) -> list[Model]:
|
265
258
|
"""
|
266
259
|
Lists all the Models the authenticated user has access to.
|
267
|
-
:param
|
260
|
+
:param only_in_workspace: If True, only lists models in the workspace provided when
|
261
|
+
instantiating the client. If a string is provided, only lists models in the workspace
|
262
|
+
with the given Id. If False (default), lists models in all workspaces the user
|
263
|
+
:param search_pattern: **Caution: This is an undocumented Feature and may behave
|
264
|
+
unpredictably. It requires the Tenant Admin role. For non-admin users, it is
|
265
|
+
ignored.** Optionally filter for specific models. When provided,
|
268
266
|
case-insensitive matches model names containing this string.
|
269
267
|
You can use the wildcards `%` for 0-n characters, and `_` for exactly 1 character.
|
270
268
|
When None (default), returns all models.
|
@@ -276,7 +274,7 @@ class Client:
|
|
276
274
|
if search_pattern:
|
277
275
|
params["s"] = search_pattern
|
278
276
|
res = self._http.get_paginated(
|
279
|
-
|
277
|
+
models_url(only_in_workspace, self._workspace_id), "models", params=params
|
280
278
|
)
|
281
279
|
return [Model.model_validate(e) for e in res]
|
282
280
|
|
anaplan_sdk/_services.py
CHANGED
@@ -286,6 +286,20 @@ class _AsyncHttpService:
|
|
286
286
|
raise AnaplanException("Exhausted all retries without a successful response or Error.")
|
287
287
|
|
288
288
|
|
289
|
+
def models_url(only_in_workspace: bool | str, workspace_id: str | None) -> str:
|
290
|
+
if isinstance(only_in_workspace, bool) and only_in_workspace:
|
291
|
+
if not workspace_id:
|
292
|
+
raise ValueError(
|
293
|
+
"Cannot list models in the current workspace, since no workspace Id was "
|
294
|
+
"provided when instantiating the client. Either provide a workspace Id when "
|
295
|
+
"instantiating the client, or pass a specific workspace Id to this method."
|
296
|
+
)
|
297
|
+
return f"https://api.anaplan.com/2/0/workspaces/{workspace_id}/models"
|
298
|
+
if isinstance(only_in_workspace, str):
|
299
|
+
return f"https://api.anaplan.com/2/0/workspaces/{only_in_workspace}/models"
|
300
|
+
return "https://api.anaplan.com/2/0/models"
|
301
|
+
|
302
|
+
|
289
303
|
def sort_params(sort_by: str | None, descending: bool) -> dict[str, str | bool]:
|
290
304
|
"""
|
291
305
|
Construct search parameters for sorting. This also converts snake_case to camelCase.
|
anaplan_sdk/models/_bulk.py
CHANGED
@@ -39,11 +39,13 @@ class Model(AnaplanModel):
|
|
39
39
|
description="The unique identifier of the user who last modified this model."
|
40
40
|
)
|
41
41
|
memory_usage: int = Field(0, description="The memory usage of this model in bytes.")
|
42
|
-
|
43
|
-
|
42
|
+
workspace_id: str = Field(
|
43
|
+
validation_alias="currentWorkspaceId",
|
44
|
+
description="The unique identifier of the workspace that this model is currently in.",
|
44
45
|
)
|
45
|
-
|
46
|
-
|
46
|
+
workspace_name: str = Field(
|
47
|
+
validation_alias="currentWorkspaceName",
|
48
|
+
description="The name of the workspace that this model is currently in.",
|
47
49
|
)
|
48
50
|
url: str = Field(validation_alias="modelUrl", description="The current URL of this model.")
|
49
51
|
category_values: list = Field(description="The category values of this model.")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: anaplan-sdk
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.0a5
|
4
4
|
Summary: Streamlined Python Interface for 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
|
@@ -1,30 +1,30 @@
|
|
1
1
|
anaplan_sdk/__init__.py,sha256=WScEKtXlnRLjCb-j3qW9W4kEACTyPsTLFs-L54et2TQ,351
|
2
2
|
anaplan_sdk/_auth.py,sha256=l5z2WCcfQ05OkuQ1dcmikp6dB87Rw1qy2zu8bbaAQTs,16620
|
3
3
|
anaplan_sdk/_oauth.py,sha256=AynlJDrGIinQT0jwxI2RSvtU4D7Wasyw3H1uicdlLVI,12672
|
4
|
-
anaplan_sdk/_services.py,sha256=
|
4
|
+
anaplan_sdk/_services.py,sha256=D54hGrzj1MSj7_6-WDZUZsoLcThI_neW4aIoDOqALjE,20869
|
5
5
|
anaplan_sdk/exceptions.py,sha256=ALkA9fBF0NQ7dufFxV6AivjmHyuJk9DOQ9jtJV2n7f0,1809
|
6
6
|
anaplan_sdk/_async_clients/__init__.py,sha256=pZXgMMg4S9Aj_pxQCaSiPuNG-sePVGBtNJ0133VjqW4,364
|
7
7
|
anaplan_sdk/_async_clients/_alm.py,sha256=zvKEvXlxNkcQim_XvyZLCbDafFldljg8APHqhAAIfvw,13147
|
8
|
-
anaplan_sdk/_async_clients/_audit.py,sha256=
|
9
|
-
anaplan_sdk/_async_clients/_bulk.py,sha256=
|
8
|
+
anaplan_sdk/_async_clients/_audit.py,sha256=r3pJ4iHmXHyfDu19L80UTZzMReg6FKE7DlzyhXLhI8A,2896
|
9
|
+
anaplan_sdk/_async_clients/_bulk.py,sha256=JkXZ6mtK04bATyVZA6yA8akjVerurRjgINCViXAwoWM,30069
|
10
10
|
anaplan_sdk/_async_clients/_cloud_works.py,sha256=VB4l93426A0Xes5dZ6DsDu0go-BVNhs2RZn2zX5DSOc,17675
|
11
11
|
anaplan_sdk/_async_clients/_cw_flow.py,sha256=_allKIOP-qb33wrOj6GV5VAOvrCXOVJ1QXvck-jsocQ,3935
|
12
12
|
anaplan_sdk/_async_clients/_transactional.py,sha256=U6X5pW7By387JOgvHx-GmgVRi7MRJKALpx0lWI6xRMo,18024
|
13
13
|
anaplan_sdk/_clients/__init__.py,sha256=FsbwvZC1FHrxuRXwbPxUzbhz_lO1DpXIxEOjx6-3QuA,219
|
14
14
|
anaplan_sdk/_clients/_alm.py,sha256=3U7Cy5U5TsePF1YPogXvsOzNeQlQm_ezO5TlmD-Xbbs,12874
|
15
|
-
anaplan_sdk/_clients/_audit.py,sha256=
|
16
|
-
anaplan_sdk/_clients/_bulk.py,sha256
|
15
|
+
anaplan_sdk/_clients/_audit.py,sha256=oF1-7rGfYWG6LfM-i0vJzgpx4NAsLczo4welJR14N-U,2819
|
16
|
+
anaplan_sdk/_clients/_bulk.py,sha256=-I0e5yBHhQPIuS9pF_dRRi7OmY7H88P5mGPusGupKi4,30226
|
17
17
|
anaplan_sdk/_clients/_cloud_works.py,sha256=FsCp2wPxIoArAN1vcIfOI6ANNkK2ZebQ4MWJZB-nFJU,17466
|
18
18
|
anaplan_sdk/_clients/_cw_flow.py,sha256=O6t4utbDZdSVXGC0PXUcPpQ4oXrPohU9_8SUBCpxTXw,3824
|
19
19
|
anaplan_sdk/_clients/_transactional.py,sha256=SaHAnaGLZrhXmM8d6JnWWkwf-sVCEDW0nL2a4_wvjfk,17849
|
20
20
|
anaplan_sdk/models/__init__.py,sha256=zfwDQJQrXuLEXSpbJcm08a_YK1P7a7u-kMhwtJiJFmA,1783
|
21
21
|
anaplan_sdk/models/_alm.py,sha256=oeENd0YM7-LoIRBq2uATIQTxVgIP9rXx3UZE2UnQAp0,4670
|
22
22
|
anaplan_sdk/models/_base.py,sha256=6AZc9CfireUKgpZfMxYKu4MbwiyHQOsGLjKrxGXBLic,508
|
23
|
-
anaplan_sdk/models/_bulk.py,sha256=
|
23
|
+
anaplan_sdk/models/_bulk.py,sha256=C0s6XdvHxuJHrPXU-pnZ1JXK1PJOl9FScHArpaox_mQ,8489
|
24
24
|
anaplan_sdk/models/_transactional.py,sha256=2bH10zvtMb5Lfh6DC7iQk72aEwq6tyLQ-XnH_0wYSqI,14172
|
25
25
|
anaplan_sdk/models/cloud_works.py,sha256=APUGDt_e-JshtXkba5cQh5rZkXOZBz0Aix0qVNdEWgw,19501
|
26
26
|
anaplan_sdk/models/flows.py,sha256=SuLgNj5-2SeE3U1i8iY8cq2IkjuUgd_3M1n2ENructk,3625
|
27
|
-
anaplan_sdk-0.5.
|
28
|
-
anaplan_sdk-0.5.
|
29
|
-
anaplan_sdk-0.5.
|
30
|
-
anaplan_sdk-0.5.
|
27
|
+
anaplan_sdk-0.5.0a5.dist-info/METADATA,sha256=cPMNYurLnr08YAdhsgOUFlrcw-xehz2gd5MQF_TrFg8,3678
|
28
|
+
anaplan_sdk-0.5.0a5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
29
|
+
anaplan_sdk-0.5.0a5.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
30
|
+
anaplan_sdk-0.5.0a5.dist-info/RECORD,,
|
File without changes
|
File without changes
|