anaplan-sdk 0.2.8__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.
@@ -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,30 +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
- """
53
- Get audit events from Anaplan Audit API.
54
- :param days_into_past: The nuber of days into the past to get events for. The API provides
55
- data for up to 30 days.
56
- :param event_type: The type of events to get.
57
- :return: A list of audit events.
58
- """
59
- total = await self._get_total(days_into_past, event_type)
60
- if total == 0:
61
- return []
62
- if total <= 10_000:
63
- return await self._get_result_page(days_into_past, event_type)
64
-
65
- return list(
66
- chain.from_iterable(
67
- await gather(
68
- *(
69
- self._get_result_page(
70
- days_into_past, event_type, self._limit, n * self._limit
71
- )
72
- for n in range(ceil(total / self._limit))
73
- )
74
- )
75
- )
76
- )
@@ -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")
@@ -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,29 +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
- """
53
- Get audit events from Anaplan Audit API.
54
- :param days_into_past: The nuber of days into the past to get events for. The API provides
55
- data for up to 30 days.
56
- :param event_type: The type of events to get.
57
- :return: A list of audit events.
58
- """
59
- total = self._get_total(days_into_past, event_type)
60
- if total == 0:
61
- return []
62
- if total <= 10_000:
63
- return self._get_result_page(days_into_past, event_type)
64
-
65
- from concurrent.futures import ThreadPoolExecutor
66
-
67
- with ThreadPoolExecutor(max_workers=self._thread_count) as executor:
68
- futures = [
69
- executor.submit(
70
- self._get_result_page, days_into_past, event_type, self._limit, n * self._limit
71
- )
72
- for n in range(ceil(total / self._limit))
73
- ]
74
- results = [future.result() for future in futures]
75
- 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.8
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@ba.valantic.com>
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
@@ -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=-sFk91tRihc5GVPlW41-I5sQ0fxSRCSYTop5S4q2lHc,3673
8
- anaplan_sdk/_async_clients/_audit.py,sha256=seCaB3wm_RXeO1CPUhzJwR0OxkS_iAwgrAWnLXAAb9M,2521
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=Vcrn3TjHlH365O7F1TKc1WiZWURNqQf_gSc8UUVESM8,3564
13
- anaplan_sdk/_clients/_audit.py,sha256=08CIBaxL8g6s6s0kpuA9_pxJpwRxxJrAjI9lQE3YgqE,2596
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.8.dist-info/METADATA,sha256=ay8eF31erA7KFU96IPNLfhgw_BUNvU8Ua5wGQyqL0yU,3602
17
- anaplan_sdk-0.2.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
- anaplan_sdk-0.2.8.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
19
- anaplan_sdk-0.2.8.dist-info/RECORD,,
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,,