Debian Codegraph @

src/auth0/management/roles/groups/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.group import Group
9 from ...types.list_role_groups_response_content import ListRoleGroupsResponseContent
10 from .raw_client import AsyncRawGroupsClient, RawGroupsClient
11
12 # this is used as the default value for optional parameters
13 OMIT = typing.cast(typing.Any, ...)
14
15
16 class GroupsClient:
17 def __init__(self, *, client_wrapper: SyncClientWrapper):
18 self._raw_client = RawGroupsClient(client_wrapper=client_wrapper)
19
20 @property
21 def with_raw_response(self) -> RawGroupsClient:
22 """
23 Retrieves a raw implementation of this client that returns raw responses.
24
25 Returns
26 -------
27 RawGroupsClient
28 """
29 return self._raw_client
30
31 def get(
32 self,
33 id: str,
34 *,
35 from_: typing.Optional[str] = None,
36 take: typing.Optional[int] = 50,
37 request_options: typing.Optional[RequestOptions] = None,
38 ) -> SyncPager[Group, ListRoleGroupsResponseContent]:
39 """
40 Lists the groups to which the specified role is assigned.
41
42 Parameters
43 ----------
44 id : str
45 Unique identifier for the role (service-generated).
46
47 from_ : typing.Optional[str]
48 Optional Id from which to start selection.
49
50 take : typing.Optional[int]
51 Number of results per page. Defaults to 50.
52
53 request_options : typing.Optional[RequestOptions]
54 Request-specific configuration.
55
56 Returns
57 -------
58 SyncPager[Group, ListRoleGroupsResponseContent]
59 Role's groups successfully retrieved.
60
61 Examples
62 --------
63 from auth0 import Auth0
64
65 client = Auth0(
66 token="YOUR_TOKEN",
67 )
68 response = client.roles.groups.get(
69 id="id",
70 from_="from",
71 take=1,
72 )
73 for item in response:
74 yield item
75 # alternatively, you can paginate page-by-page
76 for page in response.iter_pages():
77 yield page
78 """
79 return self._raw_client.get(id, from_=from_, take=take, request_options=request_options)
80
81 def create(
82 self, id: str, *, groups: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
83 ) -> None:
84 """
85 Assign one or more groups to a specified role.
86
87 Parameters
88 ----------
89 id : str
90 Unique identifier for the role (service-generated).
91
92 groups : typing.Sequence[str]
93 Array of group IDs to assign to the role.
94
95 request_options : typing.Optional[RequestOptions]
96 Request-specific configuration.
97
98 Returns
99 -------
100 None
101
102 Examples
103 --------
104 from auth0 import Auth0
105
106 client = Auth0(
107 token="YOUR_TOKEN",
108 )
109 client.roles.groups.create(
110 id="id",
111 groups=["groups"],
112 )
113 """
114 _response = self._raw_client.create(id, groups=groups, request_options=request_options)
115 return _response.data
116
117 def delete(
118 self, id: str, *, groups: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
119 ) -> None:
120 """
121 Unassign one or more groups from a specified role.
122
123 Parameters
124 ----------
125 id : str
126 Unique identifier for the role (service-generated).
127
128 groups : typing.Sequence[str]
129 Array of group IDs to remove from the role.
130
131 request_options : typing.Optional[RequestOptions]
132 Request-specific configuration.
133
134 Returns
135 -------
136 None
137
138 Examples
139 --------
140 from auth0 import Auth0
141
142 client = Auth0(
143 token="YOUR_TOKEN",
144 )
145 client.roles.groups.delete(
146 id="id",
147 groups=["groups"],
148 )
149 """
150 _response = self._raw_client.delete(id, groups=groups, request_options=request_options)
151 return _response.data
152
153
154 class AsyncGroupsClient:
155 def __init__(self, *, client_wrapper: AsyncClientWrapper):
156 self._raw_client = AsyncRawGroupsClient(client_wrapper=client_wrapper)
157
158 @property
159 def with_raw_response(self) -> AsyncRawGroupsClient:
160 """
161 Retrieves a raw implementation of this client that returns raw responses.
162
163 Returns
164 -------
165 AsyncRawGroupsClient
166 """
167 return self._raw_client
168
169 async def get(
170 self,
171 id: str,
172 *,
173 from_: typing.Optional[str] = None,
174 take: typing.Optional[int] = 50,
175 request_options: typing.Optional[RequestOptions] = None,
176 ) -> AsyncPager[Group, ListRoleGroupsResponseContent]:
177 """
178 Lists the groups to which the specified role is assigned.
179
180 Parameters
181 ----------
182 id : str
183 Unique identifier for the role (service-generated).
184
185 from_ : typing.Optional[str]
186 Optional Id from which to start selection.
187
188 take : typing.Optional[int]
189 Number of results per page. Defaults to 50.
190
191 request_options : typing.Optional[RequestOptions]
192 Request-specific configuration.
193
194 Returns
195 -------
196 AsyncPager[Group, ListRoleGroupsResponseContent]
197 Role's groups successfully retrieved.
198
199 Examples
200 --------
201 import asyncio
202
203 from auth0 import AsyncAuth0
204
205 client = AsyncAuth0(
206 token="YOUR_TOKEN",
207 )
208
209
210 async def main() -> None:
211 response = await client.roles.groups.get(
212 id="id",
213 from_="from",
214 take=1,
215 )
216 async for item in response:
217 yield item
218
219 # alternatively, you can paginate page-by-page
220 async for page in response.iter_pages():
221 yield page
222
223
224 asyncio.run(main())
225 """
226 return await self._raw_client.get(id, from_=from_, take=take, request_options=request_options)
227
228 async def create(
229 self, id: str, *, groups: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
230 ) -> None:
231 """
232 Assign one or more groups to a specified role.
233
234 Parameters
235 ----------
236 id : str
237 Unique identifier for the role (service-generated).
238
239 groups : typing.Sequence[str]
240 Array of group IDs to assign to the role.
241
242 request_options : typing.Optional[RequestOptions]
243 Request-specific configuration.
244
245 Returns
246 -------
247 None
248
249 Examples
250 --------
251 import asyncio
252
253 from auth0 import AsyncAuth0
254
255 client = AsyncAuth0(
256 token="YOUR_TOKEN",
257 )
258
259
260 async def main() -> None:
261 await client.roles.groups.create(
262 id="id",
263 groups=["groups"],
264 )
265
266
267 asyncio.run(main())
268 """
269 _response = await self._raw_client.create(id, groups=groups, request_options=request_options)
270 return _response.data
271
272 async def delete(
273 self, id: str, *, groups: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
274 ) -> None:
275 """
276 Unassign one or more groups from a specified role.
277
278 Parameters
279 ----------
280 id : str
281 Unique identifier for the role (service-generated).
282
283 groups : typing.Sequence[str]
284 Array of group IDs to remove from the role.
285
286 request_options : typing.Optional[RequestOptions]
287 Request-specific configuration.
288
289 Returns
290 -------
291 None
292
293 Examples
294 --------
295 import asyncio
296
297 from auth0 import AsyncAuth0
298
299 client = AsyncAuth0(
300 token="YOUR_TOKEN",
301 )
302
303
304 async def main() -> None:
305 await client.roles.groups.delete(
306 id="id",
307 groups=["groups"],
308 )
309
310
311 asyncio.run(main())
312 """
313 _response = await self._raw_client.delete(id, groups=groups, request_options=request_options)
314 return _response.data