Debian Codegraph @

src/auth0/management/groups/client.py

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
2
3 from __future__ import annotations
4
5 import typing
6
7 from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8 from ..core.pagination import AsyncPager, SyncPager
9 from ..core.request_options import RequestOptions
10 from ..types.get_group_response_content import GetGroupResponseContent
11 from ..types.group import Group
12 from ..types.list_groups_paginated_response_content import ListGroupsPaginatedResponseContent
13 from .raw_client import AsyncRawGroupsClient, RawGroupsClient
14
15 if typing.TYPE_CHECKING:
16 from .members.client import AsyncMembersClient, MembersClient
17 from .roles.client import AsyncRolesClient, RolesClient
18
19
20 class GroupsClient:
21 def __init__(self, *, client_wrapper: SyncClientWrapper):
22 self._raw_client = RawGroupsClient(client_wrapper=client_wrapper)
23 self._client_wrapper = client_wrapper
24 self._members: typing.Optional[MembersClient] = None
25 self._roles: typing.Optional[RolesClient] = None
26
27 @property
28 def with_raw_response(self) -> RawGroupsClient:
29 """
30 Retrieves a raw implementation of this client that returns raw responses.
31
32 Returns
33 -------
34 RawGroupsClient
35 """
36 return self._raw_client
37
38 def list(
39 self,
40 *,
41 connection_id: typing.Optional[str] = None,
42 name: typing.Optional[str] = None,
43 external_id: typing.Optional[str] = None,
44 search: typing.Optional[str] = None,
45 fields: typing.Optional[str] = None,
46 include_fields: typing.Optional[bool] = None,
47 from_: typing.Optional[str] = None,
48 take: typing.Optional[int] = 50,
49 request_options: typing.Optional[RequestOptions] = None,
50 ) -> SyncPager[Group, ListGroupsPaginatedResponseContent]:
51 """
52 List all groups in your tenant.
53
54 Parameters
55 ----------
56 connection_id : typing.Optional[str]
57 Filter groups by connection ID.
58
59 name : typing.Optional[str]
60 Filter groups by name.
61
62 external_id : typing.Optional[str]
63 Filter groups by external ID.
64
65 search : typing.Optional[str]
66 Search for groups by name or external ID.
67
68 fields : typing.Optional[str]
69 A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve all fields
70
71 include_fields : typing.Optional[bool]
72 Whether specified fields are to be included (true) or excluded (false).
73
74 from_ : typing.Optional[str]
75 Optional Id from which to start selection.
76
77 take : typing.Optional[int]
78 Number of results per page. Defaults to 50.
79
80 request_options : typing.Optional[RequestOptions]
81 Request-specific configuration.
82
83 Returns
84 -------
85 SyncPager[Group, ListGroupsPaginatedResponseContent]
86 Groups successfully retrieved.
87
88 Examples
89 --------
90 from auth0 import Auth0
91
92 client = Auth0(
93 token="YOUR_TOKEN",
94 )
95 response = client.groups.list(
96 connection_id="connection_id",
97 name="name",
98 external_id="external_id",
99 search="search",
100 fields="fields",
101 include_fields=True,
102 from_="from",
103 take=1,
104 )
105 for item in response:
106 yield item
107 # alternatively, you can paginate page-by-page
108 for page in response.iter_pages():
109 yield page
110 """
111 return self._raw_client.list(
112 connection_id=connection_id,
113 name=name,
114 external_id=external_id,
115 search=search,
116 fields=fields,
117 include_fields=include_fields,
118 from_=from_,
119 take=take,
120 request_options=request_options,
121 )
122
123 def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetGroupResponseContent:
124 """
125 Retrieve a group by its ID.
126
127 Parameters
128 ----------
129 id : str
130 Unique identifier for the group (service-generated).
131
132 request_options : typing.Optional[RequestOptions]
133 Request-specific configuration.
134
135 Returns
136 -------
137 GetGroupResponseContent
138 Group successfully retrieved.
139
140 Examples
141 --------
142 from auth0 import Auth0
143
144 client = Auth0(
145 token="YOUR_TOKEN",
146 )
147 client.groups.get(
148 id="id",
149 )
150 """
151 _response = self._raw_client.get(id, request_options=request_options)
152 return _response.data
153
154 def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
155 """
156 Delete a group by its ID.
157
158 Parameters
159 ----------
160 id : str
161 Unique identifier for the group (service-generated).
162
163 request_options : typing.Optional[RequestOptions]
164 Request-specific configuration.
165
166 Returns
167 -------
168 None
169
170 Examples
171 --------
172 from auth0 import Auth0
173
174 client = Auth0(
175 token="YOUR_TOKEN",
176 )
177 client.groups.delete(
178 id="id",
179 )
180 """
181 _response = self._raw_client.delete(id, request_options=request_options)
182 return _response.data
183
184 @property
185 def members(self):
186 if self._members is None:
187 from .members.client import MembersClient # noqa: E402
188
189 self._members = MembersClient(client_wrapper=self._client_wrapper)
190 return self._members
191
192 @property
193 def roles(self):
194 if self._roles is None:
195 from .roles.client import RolesClient # noqa: E402
196
197 self._roles = RolesClient(client_wrapper=self._client_wrapper)
198 return self._roles
199
200
201 class AsyncGroupsClient:
202 def __init__(self, *, client_wrapper: AsyncClientWrapper):
203 self._raw_client = AsyncRawGroupsClient(client_wrapper=client_wrapper)
204 self._client_wrapper = client_wrapper
205 self._members: typing.Optional[AsyncMembersClient] = None
206 self._roles: typing.Optional[AsyncRolesClient] = None
207
208 @property
209 def with_raw_response(self) -> AsyncRawGroupsClient:
210 """
211 Retrieves a raw implementation of this client that returns raw responses.
212
213 Returns
214 -------
215 AsyncRawGroupsClient
216 """
217 return self._raw_client
218
219 async def list(
220 self,
221 *,
222 connection_id: typing.Optional[str] = None,
223 name: typing.Optional[str] = None,
224 external_id: typing.Optional[str] = None,
225 search: typing.Optional[str] = None,
226 fields: typing.Optional[str] = None,
227 include_fields: typing.Optional[bool] = None,
228 from_: typing.Optional[str] = None,
229 take: typing.Optional[int] = 50,
230 request_options: typing.Optional[RequestOptions] = None,
231 ) -> AsyncPager[Group, ListGroupsPaginatedResponseContent]:
232 """
233 List all groups in your tenant.
234
235 Parameters
236 ----------
237 connection_id : typing.Optional[str]
238 Filter groups by connection ID.
239
240 name : typing.Optional[str]
241 Filter groups by name.
242
243 external_id : typing.Optional[str]
244 Filter groups by external ID.
245
246 search : typing.Optional[str]
247 Search for groups by name or external ID.
248
249 fields : typing.Optional[str]
250 A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve all fields
251
252 include_fields : typing.Optional[bool]
253 Whether specified fields are to be included (true) or excluded (false).
254
255 from_ : typing.Optional[str]
256 Optional Id from which to start selection.
257
258 take : typing.Optional[int]
259 Number of results per page. Defaults to 50.
260
261 request_options : typing.Optional[RequestOptions]
262 Request-specific configuration.
263
264 Returns
265 -------
266 AsyncPager[Group, ListGroupsPaginatedResponseContent]
267 Groups successfully retrieved.
268
269 Examples
270 --------
271 import asyncio
272
273 from auth0 import AsyncAuth0
274
275 client = AsyncAuth0(
276 token="YOUR_TOKEN",
277 )
278
279
280 async def main() -> None:
281 response = await client.groups.list(
282 connection_id="connection_id",
283 name="name",
284 external_id="external_id",
285 search="search",
286 fields="fields",
287 include_fields=True,
288 from_="from",
289 take=1,
290 )
291 async for item in response:
292 yield item
293
294 # alternatively, you can paginate page-by-page
295 async for page in response.iter_pages():
296 yield page
297
298
299 asyncio.run(main())
300 """
301 return await self._raw_client.list(
302 connection_id=connection_id,
303 name=name,
304 external_id=external_id,
305 search=search,
306 fields=fields,
307 include_fields=include_fields,
308 from_=from_,
309 take=take,
310 request_options=request_options,
311 )
312
313 async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetGroupResponseContent:
314 """
315 Retrieve a group by its ID.
316
317 Parameters
318 ----------
319 id : str
320 Unique identifier for the group (service-generated).
321
322 request_options : typing.Optional[RequestOptions]
323 Request-specific configuration.
324
325 Returns
326 -------
327 GetGroupResponseContent
328 Group successfully retrieved.
329
330 Examples
331 --------
332 import asyncio
333
334 from auth0 import AsyncAuth0
335
336 client = AsyncAuth0(
337 token="YOUR_TOKEN",
338 )
339
340
341 async def main() -> None:
342 await client.groups.get(
343 id="id",
344 )
345
346
347 asyncio.run(main())
348 """
349 _response = await self._raw_client.get(id, request_options=request_options)
350 return _response.data
351
352 async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
353 """
354 Delete a group by its ID.
355
356 Parameters
357 ----------
358 id : str
359 Unique identifier for the group (service-generated).
360
361 request_options : typing.Optional[RequestOptions]
362 Request-specific configuration.
363
364 Returns
365 -------
366 None
367
368 Examples
369 --------
370 import asyncio
371
372 from auth0 import AsyncAuth0
373
374 client = AsyncAuth0(
375 token="YOUR_TOKEN",
376 )
377
378
379 async def main() -> None:
380 await client.groups.delete(
381 id="id",
382 )
383
384
385 asyncio.run(main())
386 """
387 _response = await self._raw_client.delete(id, request_options=request_options)
388 return _response.data
389
390 @property
391 def members(self):
392 if self._members is None:
393 from .members.client import AsyncMembersClient # noqa: E402
394
395 self._members = AsyncMembersClient(client_wrapper=self._client_wrapper)
396 return self._members
397
398 @property
399 def roles(self):
400 if self._roles is None:
401 from .roles.client import AsyncRolesClient # noqa: E402
402
403 self._roles = AsyncRolesClient(client_wrapper=self._client_wrapper)
404 return self._roles