authpi-admin 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.
Files changed (40) hide show
  1. authpi_admin/__init__.py +55 -0
  2. authpi_admin/_version.py +5 -0
  3. authpi_admin/client.py +155 -0
  4. authpi_admin/errors.py +218 -0
  5. authpi_admin/generated/__init__.py +28 -0
  6. authpi_admin/generated/models.py +380 -0
  7. authpi_admin/generated/resources/__init__.py +0 -0
  8. authpi_admin/generated/resources/accounts.py +157 -0
  9. authpi_admin/generated/resources/agents.py +177 -0
  10. authpi_admin/generated/resources/api_keys.py +213 -0
  11. authpi_admin/generated/resources/approvals.py +109 -0
  12. authpi_admin/generated/resources/auth_methods.py +148 -0
  13. authpi_admin/generated/resources/clients.py +197 -0
  14. authpi_admin/generated/resources/deliveries.py +83 -0
  15. authpi_admin/generated/resources/domains.py +194 -0
  16. authpi_admin/generated/resources/events.py +111 -0
  17. authpi_admin/generated/resources/groups.py +160 -0
  18. authpi_admin/generated/resources/invitations.py +202 -0
  19. authpi_admin/generated/resources/issuers.py +157 -0
  20. authpi_admin/generated/resources/members.py +154 -0
  21. authpi_admin/generated/resources/notes.py +192 -0
  22. authpi_admin/generated/resources/organizations.py +244 -0
  23. authpi_admin/generated/resources/sessions.py +125 -0
  24. authpi_admin/generated/resources/tokens.py +94 -0
  25. authpi_admin/generated/resources/trusted_devices.py +102 -0
  26. authpi_admin/generated/resources/users.py +224 -0
  27. authpi_admin/generated/resources/verifiers.py +102 -0
  28. authpi_admin/generated/resources/webhooks.py +167 -0
  29. authpi_admin/generated/scopes/__init__.py +0 -0
  30. authpi_admin/generated/scopes/agent_scope.py +84 -0
  31. authpi_admin/generated/scopes/issuer_scope.py +160 -0
  32. authpi_admin/generated/scopes/user_scope.py +102 -0
  33. authpi_admin/generated/scopes/webhook_scope.py +84 -0
  34. authpi_admin/http_client.py +305 -0
  35. authpi_admin/pagination.py +41 -0
  36. authpi_admin/py.typed +0 -0
  37. authpi_admin/user_agent.py +21 -0
  38. authpi_admin-0.3.0.dist-info/METADATA +285 -0
  39. authpi_admin-0.3.0.dist-info/RECORD +40 -0
  40. authpi_admin-0.3.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,244 @@
1
+ """Generated resource class for organizations — DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, AsyncIterator
6
+
7
+ from authpi_admin.http_client import HttpClient, validate_path_segment as _validate_path_segment
8
+ from authpi_admin.pagination import Page, auto_paginate
9
+
10
+
11
+ class OrganizationsResource:
12
+ """Operations on organizations."""
13
+
14
+ def __init__(self, client: HttpClient, base_path: str) -> None:
15
+ self._client = client
16
+ self._base_path = base_path
17
+
18
+ async def list(
19
+ self,
20
+ limit: int | None = None,
21
+ cursor: str | None = None,
22
+ status: str | None = None,
23
+ sso_enabled: str | None = None,
24
+ sso_only: str | None = None,
25
+ mfa_required: str | None = None,
26
+ invitation_enabled: str | None = None,
27
+ *,
28
+ timeout: float | None = None,
29
+ headers: dict[str, str] | None = None,
30
+ ) -> Page[dict[str, Any]]:
31
+ """List Organizations"""
32
+ query: dict[str, Any] = {}
33
+ if limit is not None:
34
+ query["limit"] = limit
35
+ if cursor is not None:
36
+ query["cursor"] = cursor
37
+ if status is not None:
38
+ query["status"] = status
39
+ if sso_enabled is not None:
40
+ query["sso_enabled"] = sso_enabled
41
+ if sso_only is not None:
42
+ query["sso_only"] = sso_only
43
+ if mfa_required is not None:
44
+ query["mfa_required"] = mfa_required
45
+ if invitation_enabled is not None:
46
+ query["invitation_enabled"] = invitation_enabled
47
+ resp = await self._client.request(
48
+ "GET",
49
+ self._base_path,
50
+ query=query or None,
51
+ timeout=timeout,
52
+ headers=headers,
53
+ )
54
+ data = resp.data
55
+ items = data.get("data", []) if data else []
56
+ return Page(
57
+ data=items,
58
+ has_more=data.get("has_more", False) if data else False,
59
+ next_cursor=data.get("next_cursor") if data else None,
60
+ )
61
+
62
+ async def list_all(
63
+ self,
64
+ limit: int | None = None,
65
+ status: str | None = None,
66
+ sso_enabled: str | None = None,
67
+ sso_only: str | None = None,
68
+ mfa_required: str | None = None,
69
+ invitation_enabled: str | None = None,
70
+ *,
71
+ timeout: float | None = None,
72
+ headers: dict[str, str] | None = None,
73
+ ) -> AsyncIterator[dict[str, Any]]:
74
+ """Auto-paginating iterator over all organizations."""
75
+ async def _fetch(cursor: str | None = None) -> Page[dict[str, Any]]:
76
+ return await self.list(
77
+ limit=limit,
78
+ status=status,
79
+ sso_enabled=sso_enabled,
80
+ sso_only=sso_only,
81
+ mfa_required=mfa_required,
82
+ invitation_enabled=invitation_enabled,
83
+ cursor=cursor,
84
+ timeout=timeout,
85
+ headers=headers,
86
+ )
87
+ async for item in auto_paginate(_fetch):
88
+ yield item
89
+
90
+ async def create(
91
+ self,
92
+ body: dict[str, Any],
93
+ *,
94
+ idempotency_key: str | None = None,
95
+ timeout: float | None = None,
96
+ headers: dict[str, str] | None = None,
97
+ ) -> dict[str, Any]:
98
+ """Create Organization"""
99
+ req_headers: dict[str, str] = {}
100
+ if headers:
101
+ req_headers.update(headers)
102
+ if idempotency_key:
103
+ req_headers["idempotency-key"] = idempotency_key
104
+ resp = await self._client.request(
105
+ "POST",
106
+ self._base_path,
107
+ body=body,
108
+ timeout=timeout,
109
+ headers=req_headers or None,
110
+ )
111
+ data = resp.data
112
+ if resp.etag and isinstance(data, dict):
113
+ data["_etag"] = resp.etag
114
+ return data
115
+
116
+ async def get(
117
+ self,
118
+ org_id: str,
119
+ *,
120
+ timeout: float | None = None,
121
+ headers: dict[str, str] | None = None,
122
+ ) -> dict[str, Any]:
123
+ """Get Organization"""
124
+ path = f"{self._base_path}/{org_id}"
125
+ resp = await self._client.request("GET", path, timeout=timeout, headers=headers)
126
+ data = resp.data
127
+ if resp.etag and isinstance(data, dict):
128
+ data["_etag"] = resp.etag
129
+ return data
130
+
131
+ async def update(
132
+ self,
133
+ org_id: str,
134
+ body: dict[str, Any],
135
+ *,
136
+ if_match: str | None = None,
137
+ idempotency_key: str | None = None,
138
+ timeout: float | None = None,
139
+ headers: dict[str, str] | None = None,
140
+ ) -> dict[str, Any]:
141
+ """Update Organization"""
142
+ path = f"{self._base_path}/{org_id}"
143
+ req_headers: dict[str, str] = {}
144
+ if headers:
145
+ req_headers.update(headers)
146
+ if if_match:
147
+ req_headers["if-match"] = if_match
148
+ if idempotency_key:
149
+ req_headers["idempotency-key"] = idempotency_key
150
+ resp = await self._client.request(
151
+ "PATCH",
152
+ path,
153
+ body=body,
154
+ timeout=timeout,
155
+ headers=req_headers or None,
156
+ )
157
+ data = resp.data
158
+ if resp.etag and isinstance(data, dict):
159
+ data["_etag"] = resp.etag
160
+ return data
161
+
162
+ async def delete(
163
+ self,
164
+ org_id: str,
165
+ *,
166
+ if_match: str | None = None,
167
+ timeout: float | None = None,
168
+ headers: dict[str, str] | None = None,
169
+ ) -> None:
170
+ """Delete Organization"""
171
+ path = f"{self._base_path}/{org_id}"
172
+ req_headers: dict[str, str] = {}
173
+ if headers:
174
+ req_headers.update(headers)
175
+ if if_match:
176
+ req_headers["if-match"] = if_match
177
+ await self._client.request(
178
+ "DELETE",
179
+ path,
180
+ timeout=timeout,
181
+ headers=req_headers or None,
182
+ )
183
+
184
+ async def domains_sso(
185
+ self,
186
+ org_id: str,
187
+ body: dict[str, Any] | None = None,
188
+ *,
189
+ if_match: str | None = None,
190
+ idempotency_key: str | None = None,
191
+ timeout: float | None = None,
192
+ headers: dict[str, str] | None = None,
193
+ ) -> dict[str, Any]:
194
+ """Add SSO Domain"""
195
+ _validate_path_segment(org_id, "org_id")
196
+ path = f"{self._base_path}/{org_id}/sso/domains"
197
+ req_headers: dict[str, str] = {}
198
+ if headers:
199
+ req_headers.update(headers)
200
+ if if_match:
201
+ req_headers["if-match"] = if_match
202
+ if idempotency_key:
203
+ req_headers["idempotency-key"] = idempotency_key
204
+ resp = await self._client.request(
205
+ "POST",
206
+ path,
207
+ body=body,
208
+ timeout=timeout,
209
+ headers=req_headers or None,
210
+ )
211
+ data = resp.data
212
+ if resp.etag and isinstance(data, dict):
213
+ data["_etag"] = resp.etag
214
+ return data
215
+
216
+ async def rotate_secret_sso(
217
+ self,
218
+ org_id: str,
219
+ *,
220
+ if_match: str | None = None,
221
+ idempotency_key: str | None = None,
222
+ timeout: float | None = None,
223
+ headers: dict[str, str] | None = None,
224
+ ) -> dict[str, Any]:
225
+ """Rotate SSO Client Secret"""
226
+ _validate_path_segment(org_id, "org_id")
227
+ path = f"{self._base_path}/{org_id}/sso/rotate-secret"
228
+ req_headers: dict[str, str] = {}
229
+ if headers:
230
+ req_headers.update(headers)
231
+ if if_match:
232
+ req_headers["if-match"] = if_match
233
+ if idempotency_key:
234
+ req_headers["idempotency-key"] = idempotency_key
235
+ resp = await self._client.request(
236
+ "POST",
237
+ path,
238
+ timeout=timeout,
239
+ headers=req_headers or None,
240
+ )
241
+ data = resp.data
242
+ if resp.etag and isinstance(data, dict):
243
+ data["_etag"] = resp.etag
244
+ return data
@@ -0,0 +1,125 @@
1
+ """Generated resource class for sessions — DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, AsyncIterator
6
+
7
+ from authpi_admin.http_client import HttpClient, validate_path_segment as _validate_path_segment
8
+ from authpi_admin.pagination import Page, auto_paginate
9
+
10
+
11
+ class SessionsResource:
12
+ """Operations on sessions."""
13
+
14
+ def __init__(self, client: HttpClient, base_path: str) -> None:
15
+ self._client = client
16
+ self._base_path = base_path
17
+
18
+ async def get(
19
+ self,
20
+ session_id: str,
21
+ *,
22
+ timeout: float | None = None,
23
+ headers: dict[str, str] | None = None,
24
+ ) -> dict[str, Any]:
25
+ """Get Session"""
26
+ path = f"{self._base_path}/{session_id}"
27
+ resp = await self._client.request("GET", path, timeout=timeout, headers=headers)
28
+ data = resp.data
29
+ if resp.etag and isinstance(data, dict):
30
+ data["_etag"] = resp.etag
31
+ return data
32
+
33
+ async def reactivate(
34
+ self,
35
+ session_id: str,
36
+ *,
37
+ if_match: str | None = None,
38
+ idempotency_key: str | None = None,
39
+ timeout: float | None = None,
40
+ headers: dict[str, str] | None = None,
41
+ ) -> dict[str, Any]:
42
+ """Reactivate Session"""
43
+ _validate_path_segment(session_id, "session_id")
44
+ path = f"{self._base_path}/{session_id}/reactivate"
45
+ req_headers: dict[str, str] = {}
46
+ if headers:
47
+ req_headers.update(headers)
48
+ if if_match:
49
+ req_headers["if-match"] = if_match
50
+ if idempotency_key:
51
+ req_headers["idempotency-key"] = idempotency_key
52
+ resp = await self._client.request(
53
+ "POST",
54
+ path,
55
+ timeout=timeout,
56
+ headers=req_headers or None,
57
+ )
58
+ data = resp.data
59
+ if resp.etag and isinstance(data, dict):
60
+ data["_etag"] = resp.etag
61
+ return data
62
+
63
+ async def revoke(
64
+ self,
65
+ session_id: str,
66
+ body: dict[str, Any] | None = None,
67
+ *,
68
+ if_match: str | None = None,
69
+ idempotency_key: str | None = None,
70
+ timeout: float | None = None,
71
+ headers: dict[str, str] | None = None,
72
+ ) -> dict[str, Any]:
73
+ """Revoke Session"""
74
+ _validate_path_segment(session_id, "session_id")
75
+ path = f"{self._base_path}/{session_id}/revoke"
76
+ req_headers: dict[str, str] = {}
77
+ if headers:
78
+ req_headers.update(headers)
79
+ if if_match:
80
+ req_headers["if-match"] = if_match
81
+ if idempotency_key:
82
+ req_headers["idempotency-key"] = idempotency_key
83
+ resp = await self._client.request(
84
+ "POST",
85
+ path,
86
+ body=body,
87
+ timeout=timeout,
88
+ headers=req_headers or None,
89
+ )
90
+ data = resp.data
91
+ if resp.etag and isinstance(data, dict):
92
+ data["_etag"] = resp.etag
93
+ return data
94
+
95
+ async def suspend(
96
+ self,
97
+ session_id: str,
98
+ body: dict[str, Any] | None = None,
99
+ *,
100
+ if_match: str | None = None,
101
+ idempotency_key: str | None = None,
102
+ timeout: float | None = None,
103
+ headers: dict[str, str] | None = None,
104
+ ) -> dict[str, Any]:
105
+ """Suspend Session"""
106
+ _validate_path_segment(session_id, "session_id")
107
+ path = f"{self._base_path}/{session_id}/suspend"
108
+ req_headers: dict[str, str] = {}
109
+ if headers:
110
+ req_headers.update(headers)
111
+ if if_match:
112
+ req_headers["if-match"] = if_match
113
+ if idempotency_key:
114
+ req_headers["idempotency-key"] = idempotency_key
115
+ resp = await self._client.request(
116
+ "POST",
117
+ path,
118
+ body=body,
119
+ timeout=timeout,
120
+ headers=req_headers or None,
121
+ )
122
+ data = resp.data
123
+ if resp.etag and isinstance(data, dict):
124
+ data["_etag"] = resp.etag
125
+ return data
@@ -0,0 +1,94 @@
1
+ """Generated resource class for tokens — DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, AsyncIterator
6
+
7
+ from authpi_admin.http_client import HttpClient, validate_path_segment as _validate_path_segment
8
+ from authpi_admin.pagination import Page, auto_paginate
9
+
10
+
11
+ class TokensResource:
12
+ """Operations on tokens."""
13
+
14
+ def __init__(self, client: HttpClient, base_path: str) -> None:
15
+ self._client = client
16
+ self._base_path = base_path
17
+
18
+ async def list(
19
+ self,
20
+ limit: int | None = None,
21
+ cursor: str | None = None,
22
+ status: str | None = None,
23
+ *,
24
+ timeout: float | None = None,
25
+ headers: dict[str, str] | None = None,
26
+ ) -> Page[dict[str, Any]]:
27
+ """List Personal Tokens"""
28
+ query: dict[str, Any] = {}
29
+ if limit is not None:
30
+ query["limit"] = limit
31
+ if cursor is not None:
32
+ query["cursor"] = cursor
33
+ if status is not None:
34
+ query["status"] = status
35
+ resp = await self._client.request(
36
+ "GET",
37
+ self._base_path,
38
+ query=query or None,
39
+ timeout=timeout,
40
+ headers=headers,
41
+ )
42
+ data = resp.data
43
+ items = data.get("data", []) if data else []
44
+ return Page(
45
+ data=items,
46
+ has_more=data.get("has_more", False) if data else False,
47
+ next_cursor=data.get("next_cursor") if data else None,
48
+ )
49
+
50
+ async def list_all(
51
+ self,
52
+ limit: int | None = None,
53
+ status: str | None = None,
54
+ *,
55
+ timeout: float | None = None,
56
+ headers: dict[str, str] | None = None,
57
+ ) -> AsyncIterator[dict[str, Any]]:
58
+ """Auto-paginating iterator over all tokens."""
59
+ async def _fetch(cursor: str | None = None) -> Page[dict[str, Any]]:
60
+ return await self.list(
61
+ limit=limit,
62
+ status=status,
63
+ cursor=cursor,
64
+ timeout=timeout,
65
+ headers=headers,
66
+ )
67
+ async for item in auto_paginate(_fetch):
68
+ yield item
69
+
70
+ async def create(
71
+ self,
72
+ body: dict[str, Any],
73
+ *,
74
+ idempotency_key: str | None = None,
75
+ timeout: float | None = None,
76
+ headers: dict[str, str] | None = None,
77
+ ) -> dict[str, Any]:
78
+ """Create Personal Token"""
79
+ req_headers: dict[str, str] = {}
80
+ if headers:
81
+ req_headers.update(headers)
82
+ if idempotency_key:
83
+ req_headers["idempotency-key"] = idempotency_key
84
+ resp = await self._client.request(
85
+ "POST",
86
+ self._base_path,
87
+ body=body,
88
+ timeout=timeout,
89
+ headers=req_headers or None,
90
+ )
91
+ data = resp.data
92
+ if resp.etag and isinstance(data, dict):
93
+ data["_etag"] = resp.etag
94
+ return data
@@ -0,0 +1,102 @@
1
+ """Generated resource class for trusted_devices — DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, AsyncIterator
6
+
7
+ from authpi_admin.http_client import HttpClient, validate_path_segment as _validate_path_segment
8
+ from authpi_admin.pagination import Page, auto_paginate
9
+
10
+
11
+ class TrustedDevicesResource:
12
+ """Operations on trusted_devices."""
13
+
14
+ def __init__(self, client: HttpClient, base_path: str) -> None:
15
+ self._client = client
16
+ self._base_path = base_path
17
+
18
+ async def list(
19
+ self,
20
+ *,
21
+ timeout: float | None = None,
22
+ headers: dict[str, str] | None = None,
23
+ ) -> Page[dict[str, Any]]:
24
+ """List Trusted Devices"""
25
+ query: dict[str, Any] = {}
26
+ resp = await self._client.request(
27
+ "GET",
28
+ self._base_path,
29
+ query=query or None,
30
+ timeout=timeout,
31
+ headers=headers,
32
+ )
33
+ data = resp.data
34
+ items = data.get("data", []) if data else []
35
+ return Page(
36
+ data=items,
37
+ has_more=data.get("has_more", False) if data else False,
38
+ next_cursor=data.get("next_cursor") if data else None,
39
+ )
40
+
41
+ async def list_all(
42
+ self,
43
+ *,
44
+ timeout: float | None = None,
45
+ headers: dict[str, str] | None = None,
46
+ ) -> AsyncIterator[dict[str, Any]]:
47
+ """Auto-paginating iterator over all trusted_devices."""
48
+ async def _fetch(cursor: str | None = None) -> Page[dict[str, Any]]:
49
+ return await self.list(
50
+ timeout=timeout,
51
+ headers=headers,
52
+ )
53
+ async for item in auto_paginate(_fetch):
54
+ yield item
55
+
56
+ async def create(
57
+ self,
58
+ body: dict[str, Any],
59
+ *,
60
+ idempotency_key: str | None = None,
61
+ timeout: float | None = None,
62
+ headers: dict[str, str] | None = None,
63
+ ) -> dict[str, Any]:
64
+ """Trust a Device"""
65
+ req_headers: dict[str, str] = {}
66
+ if headers:
67
+ req_headers.update(headers)
68
+ if idempotency_key:
69
+ req_headers["idempotency-key"] = idempotency_key
70
+ resp = await self._client.request(
71
+ "POST",
72
+ self._base_path,
73
+ body=body,
74
+ timeout=timeout,
75
+ headers=req_headers or None,
76
+ )
77
+ data = resp.data
78
+ if resp.etag and isinstance(data, dict):
79
+ data["_etag"] = resp.etag
80
+ return data
81
+
82
+ async def delete(
83
+ self,
84
+ device_id: str,
85
+ *,
86
+ if_match: str | None = None,
87
+ timeout: float | None = None,
88
+ headers: dict[str, str] | None = None,
89
+ ) -> None:
90
+ """Revoke Trusted Device"""
91
+ path = f"{self._base_path}/{device_id}"
92
+ req_headers: dict[str, str] = {}
93
+ if headers:
94
+ req_headers.update(headers)
95
+ if if_match:
96
+ req_headers["if-match"] = if_match
97
+ await self._client.request(
98
+ "DELETE",
99
+ path,
100
+ timeout=timeout,
101
+ headers=req_headers or None,
102
+ )