Debian Codegraph @

src/auth0/management/organizations/groups/roles/client.py

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
2
3 import typing
4
5 from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6 from ....core.pagination import AsyncPager, SyncPager
7 from ....core.request_options import RequestOptions
8 from ....types.list_organization_group_roles_response_content import ListOrganizationGroupRolesResponseContent
9 from ....types.role import Role
10 from .raw_client import AsyncRawRolesClient, RawRolesClient
11
12 # this is used as the default value for optional parameters
13 OMIT = typing.cast(typing.Any, ...)
14
15
16 class RolesClient:
17 def __init__(self, *, client_wrapper: SyncClientWrapper):
18 self._raw_client = RawRolesClient(client_wrapper=client_wrapper)
19
20 @property
21 def with_raw_response(self) -> RawRolesClient:
22 """
23 Retrieves a raw implementation of this client that returns raw responses.
24
25 Returns
26 -------
27 RawRolesClient
28 """
29 return self._raw_client
30
31 def list(
32 self,
33 organization_id: str,
34 group_id: str,
35 *,
36 from_: typing.Optional[str] = None,
37 take: typing.Optional[int] = 50,
38 request_options: typing.Optional[RequestOptions] = None,
39 ) -> SyncPager[Role, ListOrganizationGroupRolesResponseContent]:
40 """
41 Lists the roles assigned to the specified group in the context of an organization.
42
43 Parameters
44 ----------
45 organization_id : str
46 ID of the organization
47
48 group_id : str
49 ID of the group
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[Role, ListOrganizationGroupRolesResponseContent]
63 Organization group roles 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.roles.list(
73 organization_id="organization_id",
74 group_id="group_id",
75 from_="from",
76 take=1,
77 )
78 for item in response:
79 yield item
80 # alternatively, you can paginate page-by-page
81 for page in response.iter_pages():
82 yield page
83 """
84 return self._raw_client.list(organization_id, group_id, from_=from_, take=take, request_options=request_options)
85
86 def create(
87 self,
88 organization_id: str,
89 group_id: str,
90 *,
91 roles: typing.Sequence[str],
92 request_options: typing.Optional[RequestOptions] = None,
93 ) -> None:
94 """
95 Assign one or more roles to a specified group in the context of an organization.
96
97 Parameters
98 ----------
99 organization_id : str
100 ID of the organization
101
102 group_id : str
103 ID of the group
104
105 roles : typing.Sequence[str]
106 Array of role IDs to assign to organization group.
107
108 request_options : typing.Optional[RequestOptions]
109 Request-specific configuration.
110
111 Returns
112 -------
113 None
114
115 Examples
116 --------
117 from auth0 import Auth0
118
119 client = Auth0(
120 token="YOUR_TOKEN",
121 )
122 client.organizations.groups.roles.create(
123 organization_id="organization_id",
124 group_id="group_id",
125 roles=["roles"],
126 )
127 """
128 _response = self._raw_client.create(organization_id, group_id, roles=roles, request_options=request_options)
129 return _response.data
130
131 def delete(
132 self,
133 organization_id: str,
134 group_id: str,
135 *,
136 roles: typing.Sequence[str],
137 request_options: typing.Optional[RequestOptions] = None,
138 ) -> None:
139 """
140 Unassign one or more roles from a specified group in the context of an organization.
141
142 Parameters
143 ----------
144 organization_id : str
145 ID of the organization
146
147 group_id : str
148 ID of the group
149
150 roles : typing.Sequence[str]
151 Array of role IDs to delete from organization group.
152
153 request_options : typing.Optional[RequestOptions]
154 Request-specific configuration.
155
156 Returns
157 -------
158 None
159
160 Examples
161 --------
162 from auth0 import Auth0
163
164 client = Auth0(
165 token="YOUR_TOKEN",
166 )
167 client.organizations.groups.roles.delete(
168 organization_id="organization_id",
169 group_id="group_id",
170 roles=["roles"],
171 )
172 """
173 _response = self._raw_client.delete(organization_id, group_id, roles=roles, request_options=request_options)
174 return _response.data
175
176
177 class AsyncRolesClient:
178 def __init__(self, *, client_wrapper: AsyncClientWrapper):
179 self._raw_client = AsyncRawRolesClient(client_wrapper=client_wrapper)
180
181 @property
182 def with_raw_response(self) -> AsyncRawRolesClient:
183 """
184 Retrieves a raw implementation of this client that returns raw responses.
185
186 Returns
187 -------
188 AsyncRawRolesClient
189 """
190 return self._raw_client
191
192 async def list(
193 self,
194 organization_id: str,
195 group_id: str,
196 *,
197 from_: typing.Optional[str] = None,
198 take: typing.Optional[int] = 50,
199 request_options: typing.Optional[RequestOptions] = None,
200 ) -> AsyncPager[Role, ListOrganizationGroupRolesResponseContent]:
201 """
202 Lists the roles assigned to the specified group in the context of an organization.
203
204 Parameters
205 ----------
206 organization_id : str
207 ID of the organization
208
209 group_id : str
210 ID of the group
211
212 from_ : typing.Optional[str]
213 Optional Id from which to start selection.
214
215 take : typing.Optional[int]
216 Number of results per page. Defaults to 50.
217
218 request_options : typing.Optional[RequestOptions]
219 Request-specific configuration.
220
221 Returns
222 -------
223 AsyncPager[Role, ListOrganizationGroupRolesResponseContent]
224 Organization group roles successfully retrieved.
225
226 Examples
227 --------
228 import asyncio
229
230 from auth0 import AsyncAuth0
231
232 client = AsyncAuth0(
233 token="YOUR_TOKEN",
234 )
235
236
237 async def main() -> None:
238 response = await client.organizations.groups.roles.list(
239 organization_id="organization_id",
240 group_id="group_id",
241 from_="from",
242 take=1,
243 )
244 async for item in response:
245 yield item
246
247 # alternatively, you can paginate page-by-page
248 async for page in response.iter_pages():
249 yield page
250
251
252 asyncio.run(main())
253 """
254 return await self._raw_client.list(
255 organization_id, group_id, from_=from_, take=take, request_options=request_options
256 )
257
258 async def create(
259 self,
260 organization_id: str,
261 group_id: str,
262 *,
263 roles: typing.Sequence[str],
264 request_options: typing.Optional[RequestOptions] = None,
265 ) -> None:
266 """
267 Assign one or more roles to a specified group in the context of an organization.
268
269 Parameters
270 ----------
271 organization_id : str
272 ID of the organization
273
274 group_id : str
275 ID of the group
276
277 roles : typing.Sequence[str]
278 Array of role IDs to assign to organization group.
279
280 request_options : typing.Optional[RequestOptions]
281 Request-specific configuration.
282
283 Returns
284 -------
285 None
286
287 Examples
288 --------
289 import asyncio
290
291 from auth0 import AsyncAuth0
292
293 client = AsyncAuth0(
294 token="YOUR_TOKEN",
295 )
296
297
298 async def main() -> None:
299 await client.organizations.groups.roles.create(
300 organization_id="organization_id",
301 group_id="group_id",
302 roles=["roles"],
303 )
304
305
306 asyncio.run(main())
307 """
308 _response = await self._raw_client.create(
309 organization_id, group_id, roles=roles, request_options=request_options
310 )
311 return _response.data
312
313 async def delete(
314 self,
315 organization_id: str,
316 group_id: str,
317 *,
318 roles: typing.Sequence[str],
319 request_options: typing.Optional[RequestOptions] = None,
320 ) -> None:
321 """
322 Unassign one or more roles from a specified group in the context of an organization.
323
324 Parameters
325 ----------
326 organization_id : str
327 ID of the organization
328
329 group_id : str
330 ID of the group
331
332 roles : typing.Sequence[str]
333 Array of role IDs to delete from organization group.
334
335 request_options : typing.Optional[RequestOptions]
336 Request-specific configuration.
337
338 Returns
339 -------
340 None
341
342 Examples
343 --------
344 import asyncio
345
346 from auth0 import AsyncAuth0
347
348 client = AsyncAuth0(
349 token="YOUR_TOKEN",
350 )
351
352
353 async def main() -> None:
354 await client.organizations.groups.roles.delete(
355 organization_id="organization_id",
356 group_id="group_id",
357 roles=["roles"],
358 )
359
360
361 asyncio.run(main())
362 """
363 _response = await self._raw_client.delete(
364 organization_id, group_id, roles=roles, request_options=request_options
365 )
366 return _response.data