Debian Codegraph @

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