Debian Codegraph @

src/auth0/management/user_grants/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_user_grants_offset_paginated_response_content import ListUserGrantsOffsetPaginatedResponseContent
9 from ..types.user_grant import UserGrant
10 from .raw_client import AsyncRawUserGrantsClient, RawUserGrantsClient
11
12
13 class UserGrantsClient:
14 def __init__(self, *, client_wrapper: SyncClientWrapper):
15 self._raw_client = RawUserGrantsClient(client_wrapper=client_wrapper)
16
17 @property
18 def with_raw_response(self) -> RawUserGrantsClient:
19 """
20 Retrieves a raw implementation of this client that returns raw responses.
21
22 Returns
23 -------
24 RawUserGrantsClient
25 """
26 return self._raw_client
27
28 def list(
29 self,
30 *,
31 per_page: typing.Optional[int] = 50,
32 page: typing.Optional[int] = 0,
33 include_totals: typing.Optional[bool] = True,
34 user_id: typing.Optional[str] = None,
35 client_id: typing.Optional[str] = None,
36 audience: typing.Optional[str] = None,
37 request_options: typing.Optional[RequestOptions] = None,
38 ) -> SyncPager[UserGrant, ListUserGrantsOffsetPaginatedResponseContent]:
39 """
40 Retrieve the [grants](https://auth0.com/docs/api-auth/which-oauth-flow-to-use) associated with your account.
41
42 Parameters
43 ----------
44 per_page : typing.Optional[int]
45 Number of results per page.
46
47 page : typing.Optional[int]
48 Page index of the results to return. First page is 0.
49
50 include_totals : typing.Optional[bool]
51 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
52
53 user_id : typing.Optional[str]
54 user_id of the grants to retrieve.
55
56 client_id : typing.Optional[str]
57 client_id of the grants to retrieve.
58
59 audience : typing.Optional[str]
60 audience of the grants to retrieve.
61
62 request_options : typing.Optional[RequestOptions]
63 Request-specific configuration.
64
65 Returns
66 -------
67 SyncPager[UserGrant, ListUserGrantsOffsetPaginatedResponseContent]
68 Grants successfully retrieved.
69
70 Examples
71 --------
72 from auth0 import Auth0
73
74 client = Auth0(
75 token="YOUR_TOKEN",
76 )
77 response = client.user_grants.list(
78 per_page=1,
79 page=1,
80 include_totals=True,
81 user_id="user_id",
82 client_id="client_id",
83 audience="audience",
84 )
85 for item in response:
86 yield item
87 # alternatively, you can paginate page-by-page
88 for page in response.iter_pages():
89 yield page
90 """
91 return self._raw_client.list(
92 per_page=per_page,
93 page=page,
94 include_totals=include_totals,
95 user_id=user_id,
96 client_id=client_id,
97 audience=audience,
98 request_options=request_options,
99 )
100
101 def delete_by_user_id(self, *, user_id: str, request_options: typing.Optional[RequestOptions] = None) -> None:
102 """
103 Delete a grant associated with your account.
104
105 Parameters
106 ----------
107 user_id : str
108 user_id of the grant to delete.
109
110 request_options : typing.Optional[RequestOptions]
111 Request-specific configuration.
112
113 Returns
114 -------
115 None
116
117 Examples
118 --------
119 from auth0 import Auth0
120
121 client = Auth0(
122 token="YOUR_TOKEN",
123 )
124 client.user_grants.delete_by_user_id(
125 user_id="user_id",
126 )
127 """
128 _response = self._raw_client.delete_by_user_id(user_id=user_id, request_options=request_options)
129 return _response.data
130
131 def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
132 """
133 Delete a grant associated with your account.
134
135 Parameters
136 ----------
137 id : str
138 ID of the grant to delete.
139
140 request_options : typing.Optional[RequestOptions]
141 Request-specific configuration.
142
143 Returns
144 -------
145 None
146
147 Examples
148 --------
149 from auth0 import Auth0
150
151 client = Auth0(
152 token="YOUR_TOKEN",
153 )
154 client.user_grants.delete(
155 id="id",
156 )
157 """
158 _response = self._raw_client.delete(id, request_options=request_options)
159 return _response.data
160
161
162 class AsyncUserGrantsClient:
163 def __init__(self, *, client_wrapper: AsyncClientWrapper):
164 self._raw_client = AsyncRawUserGrantsClient(client_wrapper=client_wrapper)
165
166 @property
167 def with_raw_response(self) -> AsyncRawUserGrantsClient:
168 """
169 Retrieves a raw implementation of this client that returns raw responses.
170
171 Returns
172 -------
173 AsyncRawUserGrantsClient
174 """
175 return self._raw_client
176
177 async def list(
178 self,
179 *,
180 per_page: typing.Optional[int] = 50,
181 page: typing.Optional[int] = 0,
182 include_totals: typing.Optional[bool] = True,
183 user_id: typing.Optional[str] = None,
184 client_id: typing.Optional[str] = None,
185 audience: typing.Optional[str] = None,
186 request_options: typing.Optional[RequestOptions] = None,
187 ) -> AsyncPager[UserGrant, ListUserGrantsOffsetPaginatedResponseContent]:
188 """
189 Retrieve the [grants](https://auth0.com/docs/api-auth/which-oauth-flow-to-use) associated with your account.
190
191 Parameters
192 ----------
193 per_page : typing.Optional[int]
194 Number of results per page.
195
196 page : typing.Optional[int]
197 Page index of the results to return. First page is 0.
198
199 include_totals : typing.Optional[bool]
200 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
201
202 user_id : typing.Optional[str]
203 user_id of the grants to retrieve.
204
205 client_id : typing.Optional[str]
206 client_id of the grants to retrieve.
207
208 audience : typing.Optional[str]
209 audience of the grants to retrieve.
210
211 request_options : typing.Optional[RequestOptions]
212 Request-specific configuration.
213
214 Returns
215 -------
216 AsyncPager[UserGrant, ListUserGrantsOffsetPaginatedResponseContent]
217 Grants successfully retrieved.
218
219 Examples
220 --------
221 import asyncio
222
223 from auth0 import AsyncAuth0
224
225 client = AsyncAuth0(
226 token="YOUR_TOKEN",
227 )
228
229
230 async def main() -> None:
231 response = await client.user_grants.list(
232 per_page=1,
233 page=1,
234 include_totals=True,
235 user_id="user_id",
236 client_id="client_id",
237 audience="audience",
238 )
239 async for item in response:
240 yield item
241
242 # alternatively, you can paginate page-by-page
243 async for page in response.iter_pages():
244 yield page
245
246
247 asyncio.run(main())
248 """
249 return await self._raw_client.list(
250 per_page=per_page,
251 page=page,
252 include_totals=include_totals,
253 user_id=user_id,
254 client_id=client_id,
255 audience=audience,
256 request_options=request_options,
257 )
258
259 async def delete_by_user_id(self, *, user_id: str, request_options: typing.Optional[RequestOptions] = None) -> None:
260 """
261 Delete a grant associated with your account.
262
263 Parameters
264 ----------
265 user_id : str
266 user_id of the grant to delete.
267
268 request_options : typing.Optional[RequestOptions]
269 Request-specific configuration.
270
271 Returns
272 -------
273 None
274
275 Examples
276 --------
277 import asyncio
278
279 from auth0 import AsyncAuth0
280
281 client = AsyncAuth0(
282 token="YOUR_TOKEN",
283 )
284
285
286 async def main() -> None:
287 await client.user_grants.delete_by_user_id(
288 user_id="user_id",
289 )
290
291
292 asyncio.run(main())
293 """
294 _response = await self._raw_client.delete_by_user_id(user_id=user_id, request_options=request_options)
295 return _response.data
296
297 async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
298 """
299 Delete a grant associated with your account.
300
301 Parameters
302 ----------
303 id : str
304 ID of the grant to delete.
305
306 request_options : typing.Optional[RequestOptions]
307 Request-specific configuration.
308
309 Returns
310 -------
311 None
312
313 Examples
314 --------
315 import asyncio
316
317 from auth0 import AsyncAuth0
318
319 client = AsyncAuth0(
320 token="YOUR_TOKEN",
321 )
322
323
324 async def main() -> None:
325 await client.user_grants.delete(
326 id="id",
327 )
328
329
330 asyncio.run(main())
331 """
332 _response = await self._raw_client.delete(id, request_options=request_options)
333 return _response.data