Debian Codegraph @

src/auth0/management/organizations/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.group import Group
11 from ...types.list_organization_groups_response_content import ListOrganizationGroupsResponseContent
12 from .raw_client import AsyncRawGroupsClient, RawGroupsClient
13
14 if typing.TYPE_CHECKING:
15 from .roles.client import AsyncRolesClient, RolesClient
16
17
18 class GroupsClient:
19 def __init__(self, *, client_wrapper: SyncClientWrapper):
20 self._raw_client = RawGroupsClient(client_wrapper=client_wrapper)
21 self._client_wrapper = client_wrapper
22 self._roles: typing.Optional[RolesClient] = None
23
24 @property
25 def with_raw_response(self) -> RawGroupsClient:
26 """
27 Retrieves a raw implementation of this client that returns raw responses.
28
29 Returns
30 -------
31 RawGroupsClient
32 """
33 return self._raw_client
34
35 def list(
36 self,
37 organization_id: str,
38 *,
39 from_: typing.Optional[str] = None,
40 take: typing.Optional[int] = 50,
41 request_options: typing.Optional[RequestOptions] = None,
42 ) -> SyncPager[Group, ListOrganizationGroupsResponseContent]:
43 """
44 Lists the groups that are assigned to the specified organization.
45
46 Parameters
47 ----------
48 organization_id : str
49 ID of the organization
50
51 from_ : typing.Optional[str]
52 Optional Id from which to start selection.
53
54 take : typing.Optional[int]
55 Number of results per page. Defaults to 50.
56
57 request_options : typing.Optional[RequestOptions]
58 Request-specific configuration.
59
60 Returns
61 -------
62 SyncPager[Group, ListOrganizationGroupsResponseContent]
63 Organization groups successfully retrieved.
64
65 Examples
66 --------
67 from auth0 import Auth0
68
69 client = Auth0(
70 token="YOUR_TOKEN",
71 )
72 response = client.organizations.groups.list(
73 organization_id="organization_id",
74 from_="from",
75 take=1,
76 )
77 for item in response:
78 yield item
79 # alternatively, you can paginate page-by-page
80 for page in response.iter_pages():
81 yield page
82 """
83 return self._raw_client.list(organization_id, from_=from_, take=take, request_options=request_options)
84
85 @property
86 def roles(self):
87 if self._roles is None:
88 from .roles.client import RolesClient # noqa: E402
89
90 self._roles = RolesClient(client_wrapper=self._client_wrapper)
91 return self._roles
92
93
94 class AsyncGroupsClient:
95 def __init__(self, *, client_wrapper: AsyncClientWrapper):
96 self._raw_client = AsyncRawGroupsClient(client_wrapper=client_wrapper)
97 self._client_wrapper = client_wrapper
98 self._roles: typing.Optional[AsyncRolesClient] = None
99
100 @property
101 def with_raw_response(self) -> AsyncRawGroupsClient:
102 """
103 Retrieves a raw implementation of this client that returns raw responses.
104
105 Returns
106 -------
107 AsyncRawGroupsClient
108 """
109 return self._raw_client
110
111 async def list(
112 self,
113 organization_id: str,
114 *,
115 from_: typing.Optional[str] = None,
116 take: typing.Optional[int] = 50,
117 request_options: typing.Optional[RequestOptions] = None,
118 ) -> AsyncPager[Group, ListOrganizationGroupsResponseContent]:
119 """
120 Lists the groups that are assigned to the specified organization.
121
122 Parameters
123 ----------
124 organization_id : str
125 ID of the organization
126
127 from_ : typing.Optional[str]
128 Optional Id from which to start selection.
129
130 take : typing.Optional[int]
131 Number of results per page. Defaults to 50.
132
133 request_options : typing.Optional[RequestOptions]
134 Request-specific configuration.
135
136 Returns
137 -------
138 AsyncPager[Group, ListOrganizationGroupsResponseContent]
139 Organization groups successfully retrieved.
140
141 Examples
142 --------
143 import asyncio
144
145 from auth0 import AsyncAuth0
146
147 client = AsyncAuth0(
148 token="YOUR_TOKEN",
149 )
150
151
152 async def main() -> None:
153 response = await client.organizations.groups.list(
154 organization_id="organization_id",
155 from_="from",
156 take=1,
157 )
158 async for item in response:
159 yield item
160
161 # alternatively, you can paginate page-by-page
162 async for page in response.iter_pages():
163 yield page
164
165
166 asyncio.run(main())
167 """
168 return await self._raw_client.list(organization_id, from_=from_, take=take, request_options=request_options)
169
170 @property
171 def roles(self):
172 if self._roles is None:
173 from .roles.client import AsyncRolesClient # noqa: E402
174
175 self._roles = AsyncRolesClient(client_wrapper=self._client_wrapper)
176 return self._roles