anaplan-sdk 0.2.7__py3-none-any.whl → 0.2.9__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/_alm.py +10 -0
- anaplan_sdk/_async_clients/_audit.py +38 -20
- anaplan_sdk/_clients/_alm.py +10 -0
- anaplan_sdk/_clients/_audit.py +37 -19
- {anaplan_sdk-0.2.7.dist-info → anaplan_sdk-0.2.9.dist-info}/METADATA +11 -10
- {anaplan_sdk-0.2.7.dist-info → anaplan_sdk-0.2.9.dist-info}/RECORD +8 -8
- {anaplan_sdk-0.2.7.dist-info → anaplan_sdk-0.2.9.dist-info}/WHEEL +0 -0
- {anaplan_sdk-0.2.7.dist-info → anaplan_sdk-0.2.9.dist-info}/licenses/LICENSE +0 -0
@@ -1,8 +1,12 @@
|
|
1
|
+
import warnings
|
2
|
+
|
1
3
|
import httpx
|
2
4
|
|
3
5
|
from anaplan_sdk._base import _AsyncBaseClient
|
4
6
|
from anaplan_sdk.models import ModelRevision, Revision, SyncTask, User
|
5
7
|
|
8
|
+
warnings.filterwarnings("always", category=DeprecationWarning)
|
9
|
+
|
6
10
|
|
7
11
|
class _AsyncAlmClient(_AsyncBaseClient):
|
8
12
|
def __init__(self, client: httpx.AsyncClient, model_id: str, retry_count: int) -> None:
|
@@ -15,6 +19,12 @@ class _AsyncAlmClient(_AsyncBaseClient):
|
|
15
19
|
Lists all the Users in the authenticated users default tenant.
|
16
20
|
:return: The List of Users.
|
17
21
|
"""
|
22
|
+
warnings.warn(
|
23
|
+
"`list_users()` on the ALM client is deprecated and will be removed in a "
|
24
|
+
"future version. Use `list_users()` on the Audit client instead.",
|
25
|
+
DeprecationWarning,
|
26
|
+
stacklevel=1,
|
27
|
+
)
|
18
28
|
return [
|
19
29
|
User.model_validate(e)
|
20
30
|
for e in (await self._get("https://api.anaplan.com/2/0/users")).get("users")
|
@@ -6,6 +6,7 @@ from typing import Literal
|
|
6
6
|
import httpx
|
7
7
|
|
8
8
|
from anaplan_sdk._base import _AsyncBaseClient
|
9
|
+
from anaplan_sdk.models import User
|
9
10
|
|
10
11
|
Event = Literal["all", "byok", "user_activity"]
|
11
12
|
|
@@ -17,6 +18,43 @@ class _AsyncAuditClient(_AsyncBaseClient):
|
|
17
18
|
self._url = "https://audit.anaplan.com/audit/api/1/events"
|
18
19
|
super().__init__(retry_count, client)
|
19
20
|
|
21
|
+
async def list_users(self) -> list[User]:
|
22
|
+
"""
|
23
|
+
Lists all the Users in the authenticated users default tenant.
|
24
|
+
:return: The List of Users.
|
25
|
+
"""
|
26
|
+
return [
|
27
|
+
User.model_validate(e)
|
28
|
+
for e in (await self._get("https://api.anaplan.com/2/0/users")).get("users")
|
29
|
+
]
|
30
|
+
|
31
|
+
async def get_events(self, days_into_past: int = 30, event_type: Event = "all") -> list:
|
32
|
+
"""
|
33
|
+
Get audit events from Anaplan Audit API.
|
34
|
+
:param days_into_past: The nuber of days into the past to get events for. The API provides
|
35
|
+
data for up to 30 days.
|
36
|
+
:param event_type: The type of events to get.
|
37
|
+
:return: A list of audit events.
|
38
|
+
"""
|
39
|
+
total = await self._get_total(days_into_past, event_type)
|
40
|
+
if total == 0:
|
41
|
+
return []
|
42
|
+
if total <= 10_000:
|
43
|
+
return await self._get_result_page(days_into_past, event_type)
|
44
|
+
|
45
|
+
return list(
|
46
|
+
chain.from_iterable(
|
47
|
+
await gather(
|
48
|
+
*(
|
49
|
+
self._get_result_page(
|
50
|
+
days_into_past, event_type, self._limit, n * self._limit
|
51
|
+
)
|
52
|
+
for n in range(ceil(total / self._limit))
|
53
|
+
)
|
54
|
+
)
|
55
|
+
)
|
56
|
+
)
|
57
|
+
|
20
58
|
async def _get_total(self, days_into_past: int = 60, event_type: Event = "all") -> int:
|
21
59
|
return ( # noqa
|
22
60
|
await self._get(
|
@@ -47,23 +85,3 @@ class _AsyncAuditClient(_AsyncBaseClient):
|
|
47
85
|
},
|
48
86
|
)
|
49
87
|
).get("response", [])
|
50
|
-
|
51
|
-
async def get_events(self, days_into_past: int = 30, event_type: Event = "all") -> list:
|
52
|
-
total = await self._get_total(days_into_past, event_type)
|
53
|
-
if total == 0:
|
54
|
-
return []
|
55
|
-
if total <= 10_000:
|
56
|
-
return await self._get_result_page(total)
|
57
|
-
|
58
|
-
return list(
|
59
|
-
chain.from_iterable(
|
60
|
-
await gather(
|
61
|
-
*(
|
62
|
-
self._get_result_page(
|
63
|
-
days_into_past, event_type, self._limit, n * self._limit
|
64
|
-
)
|
65
|
-
for n in range(ceil(total / self._limit))
|
66
|
-
)
|
67
|
-
)
|
68
|
-
)
|
69
|
-
)
|
anaplan_sdk/_clients/_alm.py
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
import warnings
|
2
|
+
|
1
3
|
import httpx
|
2
4
|
|
3
5
|
from anaplan_sdk._base import _BaseClient
|
4
6
|
from anaplan_sdk.models import ModelRevision, Revision, SyncTask, User
|
5
7
|
|
8
|
+
warnings.filterwarnings("always", category=DeprecationWarning)
|
9
|
+
|
6
10
|
|
7
11
|
class _AlmClient(_BaseClient):
|
8
12
|
def __init__(self, client: httpx.Client, model_id: str, retry_count: int) -> None:
|
@@ -15,6 +19,12 @@ class _AlmClient(_BaseClient):
|
|
15
19
|
Lists all the Users in the authenticated users default tenant.
|
16
20
|
:return: The List of Users.
|
17
21
|
"""
|
22
|
+
warnings.warn(
|
23
|
+
"`list_users()` on the ALM client is deprecated and will be removed in a "
|
24
|
+
"future version. Use `list_users()` on the Audit client instead.",
|
25
|
+
DeprecationWarning,
|
26
|
+
stacklevel=1,
|
27
|
+
)
|
18
28
|
return [
|
19
29
|
User.model_validate(e)
|
20
30
|
for e in self._get("https://api.anaplan.com/2/0/users").get("users")
|
anaplan_sdk/_clients/_audit.py
CHANGED
@@ -5,6 +5,7 @@ from typing import Literal
|
|
5
5
|
import httpx
|
6
6
|
|
7
7
|
from anaplan_sdk._base import _BaseClient
|
8
|
+
from anaplan_sdk.models import User
|
8
9
|
|
9
10
|
Event = Literal["all", "byok", "user_activity"]
|
10
11
|
|
@@ -17,6 +18,42 @@ class _AuditClient(_BaseClient):
|
|
17
18
|
self._url = "https://audit.anaplan.com/audit/api/1/events"
|
18
19
|
super().__init__(retry_count, client)
|
19
20
|
|
21
|
+
def list_users(self) -> list[User]:
|
22
|
+
"""
|
23
|
+
Lists all the Users in the authenticated users default tenant.
|
24
|
+
:return: The List of Users.
|
25
|
+
"""
|
26
|
+
return [
|
27
|
+
User.model_validate(e)
|
28
|
+
for e in self._get("https://api.anaplan.com/2/0/users").get("users")
|
29
|
+
]
|
30
|
+
|
31
|
+
def get_events(self, days_into_past: int = 30, event_type: Event = "all") -> list:
|
32
|
+
"""
|
33
|
+
Get audit events from Anaplan Audit API.
|
34
|
+
:param days_into_past: The nuber of days into the past to get events for. The API provides
|
35
|
+
data for up to 30 days.
|
36
|
+
:param event_type: The type of events to get.
|
37
|
+
:return: A list of audit events.
|
38
|
+
"""
|
39
|
+
total = self._get_total(days_into_past, event_type)
|
40
|
+
if total == 0:
|
41
|
+
return []
|
42
|
+
if total <= 10_000:
|
43
|
+
return self._get_result_page(days_into_past, event_type)
|
44
|
+
|
45
|
+
from concurrent.futures import ThreadPoolExecutor
|
46
|
+
|
47
|
+
with ThreadPoolExecutor(max_workers=self._thread_count) as executor:
|
48
|
+
futures = [
|
49
|
+
executor.submit(
|
50
|
+
self._get_result_page, days_into_past, event_type, self._limit, n * self._limit
|
51
|
+
)
|
52
|
+
for n in range(ceil(total / self._limit))
|
53
|
+
]
|
54
|
+
results = [future.result() for future in futures]
|
55
|
+
return list(chain.from_iterable(results))
|
56
|
+
|
20
57
|
def _get_total(self, days_into_past: int = 60, event_type: Event = "all") -> int:
|
21
58
|
return ( # noqa
|
22
59
|
self._get(
|
@@ -47,22 +84,3 @@ class _AuditClient(_BaseClient):
|
|
47
84
|
},
|
48
85
|
)
|
49
86
|
).get("response", [])
|
50
|
-
|
51
|
-
def get_events(self, days_into_past: int = 30, event_type: Event = "all") -> list:
|
52
|
-
total = self._get_total(days_into_past, event_type)
|
53
|
-
if total == 0:
|
54
|
-
return []
|
55
|
-
if total <= 10_000:
|
56
|
-
return self._get_result_page(total)
|
57
|
-
|
58
|
-
from concurrent.futures import ThreadPoolExecutor
|
59
|
-
|
60
|
-
with ThreadPoolExecutor(max_workers=self._thread_count) as executor:
|
61
|
-
futures = [
|
62
|
-
executor.submit(
|
63
|
-
self._get_result_page, days_into_past, event_type, self._limit, n * self._limit
|
64
|
-
)
|
65
|
-
for n in range(ceil(total / self._limit))
|
66
|
-
]
|
67
|
-
results = [future.result() for future in futures]
|
68
|
-
return list(chain.from_iterable(results))
|
@@ -1,14 +1,14 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: anaplan-sdk
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.9
|
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
|
7
7
|
Project-URL: Documentation, https://vinzenzklass.github.io/anaplan-sdk/
|
8
|
-
Author-email: Vinzenz Klass <vinzenz.klass@
|
8
|
+
Author-email: Vinzenz Klass <vinzenz.klass@valantic.com>
|
9
9
|
License-Expression: Apache-2.0
|
10
10
|
License-File: LICENSE
|
11
|
-
Keywords: anaplan,anaplan alm api,anaplan api,anaplan bulk api,anaplan integration
|
11
|
+
Keywords: anaplan,anaplan alm api,anaplan api,anaplan audit api,anaplan bulk api,anaplan integration
|
12
12
|
Requires-Python: >=3.10.4
|
13
13
|
Requires-Dist: cryptography<45.0.0,>=42.0.7
|
14
14
|
Requires-Dist: httpx<1.0.0,>=0.27.0
|
@@ -22,6 +22,7 @@ Description-Content-Type: text/markdown
|
|
22
22
|
<h1 align="center" style="font-size: 3rem; font-weight: 400; margin: -15px 0">
|
23
23
|
Anaplan SDK
|
24
24
|
</h1>
|
25
|
+
|
25
26
|
<p align="center" style="margin-top: 15px">
|
26
27
|
<a href="https://pepy.tech/project/anaplan-sdk">
|
27
28
|
<img align="center" src="https://static.pepy.tech/badge/anaplan-sdk/month" alt="Downloads Badge"/>
|
@@ -30,15 +31,15 @@ Anaplan SDK
|
|
30
31
|
|
31
32
|
---
|
32
33
|
|
33
|
-
Anaplan SDK is an independent, unofficial project providing pythonic access to
|
34
|
-
the
|
35
|
-
|
36
|
-
Requests, Authentication, JSON Parsing, Compression, Chunking and so on.
|
34
|
+
Anaplan SDK is an independent, unofficial project providing pythonic access to Anaplan. Anaplan SDK provides high-level
|
35
|
+
abstractions over the various Anaplan APIs, so you can focus on you requirements rather than spend time on
|
36
|
+
implementation details like authentication, error handling, chunking, compression and data formatting.
|
37
37
|
|
38
38
|
This Projects supports
|
39
|
-
the [Bulk
|
40
|
-
the [Transactional
|
41
|
-
the [ALM
|
39
|
+
the [Bulk APIs](https://help.anaplan.com/use-the-bulk-apis-93218e5e-00e5-406e-8361-09ab861889a7),
|
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),
|
42
|
+
the [Audit APIs](https://auditservice.docs.apiary.io/#),
|
42
43
|
providing both synchronous and asynchronous Clients.
|
43
44
|
|
44
45
|
Visit [Anaplan SDK](https://vinzenzklass.github.io/anaplan-sdk/) for documentation.
|
@@ -4,16 +4,16 @@ anaplan_sdk/_base.py,sha256=2Te7rg_o8_1KD64NfKsDiPLladaoDxMuzk0PaAUNSr8,5299
|
|
4
4
|
anaplan_sdk/exceptions.py,sha256=ALkA9fBF0NQ7dufFxV6AivjmHyuJk9DOQ9jtJV2n7f0,1809
|
5
5
|
anaplan_sdk/models.py,sha256=ceMaVctpjwQHk7a71Io_-1YcCQshx5i1YYnqxS51nYw,12491
|
6
6
|
anaplan_sdk/_async_clients/__init__.py,sha256=wT6qfi4f_4vLFWTJQTsBw8r3DrHtoTIVqi88p5_j-Cg,259
|
7
|
-
anaplan_sdk/_async_clients/_alm.py,sha256
|
8
|
-
anaplan_sdk/_async_clients/_audit.py,sha256=
|
7
|
+
anaplan_sdk/_async_clients/_alm.py,sha256=HtpwKNCc5eb6DUgS8nqNocxzaoaHOAMQPo0SaTMaD-A,4021
|
8
|
+
anaplan_sdk/_async_clients/_audit.py,sha256=wgJx58aDksWJLu4MU-tOz76KjG41AVzBW0v3jAEv9GE,2897
|
9
9
|
anaplan_sdk/_async_clients/_bulk.py,sha256=JmjvZKuekHQceBmItexhkk9YT6njg5_gsYLdtGCyWzE,22202
|
10
10
|
anaplan_sdk/_async_clients/_transactional.py,sha256=wX_1U5YS4uwrr8D8MfNkfeA-ylFERMb-6xvewG799xY,4961
|
11
11
|
anaplan_sdk/_clients/__init__.py,sha256=FsbwvZC1FHrxuRXwbPxUzbhz_lO1DpXIxEOjx6-3QuA,219
|
12
|
-
anaplan_sdk/_clients/_alm.py,sha256=
|
13
|
-
anaplan_sdk/_clients/_audit.py,sha256=
|
12
|
+
anaplan_sdk/_clients/_alm.py,sha256=wzhibRuNzsK3PZM2EOI3OnSGHfv8CG2fuY5zLbnSqog,3912
|
13
|
+
anaplan_sdk/_clients/_audit.py,sha256=jqj_sTGNUaM2jAu91Us747pVULntPUkL_qkA4nKc8so,2981
|
14
14
|
anaplan_sdk/_clients/_bulk.py,sha256=_rhp7MgcIRq0FYwxEzvU7jBkDm5PQaw9YCU_zqIwauY,22222
|
15
15
|
anaplan_sdk/_clients/_transactional.py,sha256=4NYhq2HdxNh4K-HqMyYoyAEqKih2eTtFiXDZi8xOaf8,4695
|
16
|
-
anaplan_sdk-0.2.
|
17
|
-
anaplan_sdk-0.2.
|
18
|
-
anaplan_sdk-0.2.
|
19
|
-
anaplan_sdk-0.2.
|
16
|
+
anaplan_sdk-0.2.9.dist-info/METADATA,sha256=24kFpDCg0Zo3U0AR2zbgXn_A49Wz90X4QUjvwawbJGM,3617
|
17
|
+
anaplan_sdk-0.2.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
18
|
+
anaplan_sdk-0.2.9.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
19
|
+
anaplan_sdk-0.2.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|