Debian Codegraph @

src/auth0/management/device_credentials/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.create_public_key_device_credential_response_content import CreatePublicKeyDeviceCredentialResponseContent
9 from ..types.device_credential import DeviceCredential
10 from ..types.device_credential_public_key_type_enum import DeviceCredentialPublicKeyTypeEnum
11 from ..types.device_credential_type_enum import DeviceCredentialTypeEnum
12 from ..types.list_device_credentials_offset_paginated_response_content import (
13 ListDeviceCredentialsOffsetPaginatedResponseContent,
14 )
15 from .raw_client import AsyncRawDeviceCredentialsClient, RawDeviceCredentialsClient
16
17 # this is used as the default value for optional parameters
18 OMIT = typing.cast(typing.Any, ...)
19
20
21 class DeviceCredentialsClient:
22 def __init__(self, *, client_wrapper: SyncClientWrapper):
23 self._raw_client = RawDeviceCredentialsClient(client_wrapper=client_wrapper)
24
25 @property
26 def with_raw_response(self) -> RawDeviceCredentialsClient:
27 """
28 Retrieves a raw implementation of this client that returns raw responses.
29
30 Returns
31 -------
32 RawDeviceCredentialsClient
33 """
34 return self._raw_client
35
36 def list(
37 self,
38 *,
39 page: typing.Optional[int] = 0,
40 per_page: typing.Optional[int] = 50,
41 include_totals: typing.Optional[bool] = True,
42 fields: typing.Optional[str] = None,
43 include_fields: typing.Optional[bool] = None,
44 user_id: typing.Optional[str] = None,
45 client_id: typing.Optional[str] = None,
46 type: typing.Optional[DeviceCredentialTypeEnum] = None,
47 request_options: typing.Optional[RequestOptions] = None,
48 ) -> SyncPager[DeviceCredential, ListDeviceCredentialsOffsetPaginatedResponseContent]:
49 """
50 Retrieve device credential information (`public_key`, `refresh_token`, or `rotating_refresh_token`) associated with a specific user.
51
52 Parameters
53 ----------
54 page : typing.Optional[int]
55 Page index of the results to return. First page is 0.
56
57 per_page : typing.Optional[int]
58 Number of results per page. There is a maximum of 1000 results allowed from this endpoint.
59
60 include_totals : typing.Optional[bool]
61 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
62
63 fields : typing.Optional[str]
64 Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields.
65
66 include_fields : typing.Optional[bool]
67 Whether specified fields are to be included (true) or excluded (false).
68
69 user_id : typing.Optional[str]
70 user_id of the devices to retrieve.
71
72 client_id : typing.Optional[str]
73 client_id of the devices to retrieve.
74
75 type : typing.Optional[DeviceCredentialTypeEnum]
76 Type of credentials to retrieve. Must be `public_key`, `refresh_token` or `rotating_refresh_token`. The property will default to `refresh_token` when paging is requested
77
78 request_options : typing.Optional[RequestOptions]
79 Request-specific configuration.
80
81 Returns
82 -------
83 SyncPager[DeviceCredential, ListDeviceCredentialsOffsetPaginatedResponseContent]
84 Device credentials successfully retrieved.
85
86 Examples
87 --------
88 from auth0 import Auth0
89
90 client = Auth0(
91 token="YOUR_TOKEN",
92 )
93 response = client.device_credentials.list(
94 page=1,
95 per_page=1,
96 include_totals=True,
97 fields="fields",
98 include_fields=True,
99 user_id="user_id",
100 client_id="client_id",
101 type="public_key",
102 )
103 for item in response:
104 yield item
105 # alternatively, you can paginate page-by-page
106 for page in response.iter_pages():
107 yield page
108 """
109 return self._raw_client.list(
110 page=page,
111 per_page=per_page,
112 include_totals=include_totals,
113 fields=fields,
114 include_fields=include_fields,
115 user_id=user_id,
116 client_id=client_id,
117 type=type,
118 request_options=request_options,
119 )
120
121 def create_public_key(
122 self,
123 *,
124 device_name: str,
125 type: DeviceCredentialPublicKeyTypeEnum,
126 value: str,
127 device_id: str,
128 client_id: typing.Optional[str] = OMIT,
129 request_options: typing.Optional[RequestOptions] = None,
130 ) -> CreatePublicKeyDeviceCredentialResponseContent:
131 """
132 Create a device credential public key to manage refresh token rotation for a given `user_id`. Device Credentials APIs are designed for ad-hoc administrative use only and paging is by default enabled for GET requests.
133
134 When refresh token rotation is enabled, the endpoint becomes consistent. For more information, read [Signing Keys](https://auth0.com/docs/get-started/tenant-settings/signing-keys).
135
136 Parameters
137 ----------
138 device_name : str
139 Name for this device easily recognized by owner.
140
141 type : DeviceCredentialPublicKeyTypeEnum
142
143 value : str
144 Base64 encoded string containing the credential.
145
146 device_id : str
147 Unique identifier for the device. Recommend using <a href="http://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID">Android_ID</a> on Android and <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/index.html#//apple_ref/occ/instp/UIDevice/identifierForVendor">identifierForVendor</a>.
148
149 client_id : typing.Optional[str]
150 client_id of the client (application) this credential is for.
151
152 request_options : typing.Optional[RequestOptions]
153 Request-specific configuration.
154
155 Returns
156 -------
157 CreatePublicKeyDeviceCredentialResponseContent
158 Device credentials successfully created.
159
160 Examples
161 --------
162 from auth0 import Auth0
163
164 client = Auth0(
165 token="YOUR_TOKEN",
166 )
167 client.device_credentials.create_public_key(
168 device_name="device_name",
169 type="public_key",
170 value="value",
171 device_id="device_id",
172 )
173 """
174 _response = self._raw_client.create_public_key(
175 device_name=device_name,
176 type=type,
177 value=value,
178 device_id=device_id,
179 client_id=client_id,
180 request_options=request_options,
181 )
182 return _response.data
183
184 def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
185 """
186 Permanently delete a device credential (such as a refresh token or public key) with the given ID.
187
188 Parameters
189 ----------
190 id : str
191 ID of the credential to delete.
192
193 request_options : typing.Optional[RequestOptions]
194 Request-specific configuration.
195
196 Returns
197 -------
198 None
199
200 Examples
201 --------
202 from auth0 import Auth0
203
204 client = Auth0(
205 token="YOUR_TOKEN",
206 )
207 client.device_credentials.delete(
208 id="id",
209 )
210 """
211 _response = self._raw_client.delete(id, request_options=request_options)
212 return _response.data
213
214
215 class AsyncDeviceCredentialsClient:
216 def __init__(self, *, client_wrapper: AsyncClientWrapper):
217 self._raw_client = AsyncRawDeviceCredentialsClient(client_wrapper=client_wrapper)
218
219 @property
220 def with_raw_response(self) -> AsyncRawDeviceCredentialsClient:
221 """
222 Retrieves a raw implementation of this client that returns raw responses.
223
224 Returns
225 -------
226 AsyncRawDeviceCredentialsClient
227 """
228 return self._raw_client
229
230 async def list(
231 self,
232 *,
233 page: typing.Optional[int] = 0,
234 per_page: typing.Optional[int] = 50,
235 include_totals: typing.Optional[bool] = True,
236 fields: typing.Optional[str] = None,
237 include_fields: typing.Optional[bool] = None,
238 user_id: typing.Optional[str] = None,
239 client_id: typing.Optional[str] = None,
240 type: typing.Optional[DeviceCredentialTypeEnum] = None,
241 request_options: typing.Optional[RequestOptions] = None,
242 ) -> AsyncPager[DeviceCredential, ListDeviceCredentialsOffsetPaginatedResponseContent]:
243 """
244 Retrieve device credential information (`public_key`, `refresh_token`, or `rotating_refresh_token`) associated with a specific user.
245
246 Parameters
247 ----------
248 page : typing.Optional[int]
249 Page index of the results to return. First page is 0.
250
251 per_page : typing.Optional[int]
252 Number of results per page. There is a maximum of 1000 results allowed from this endpoint.
253
254 include_totals : typing.Optional[bool]
255 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
256
257 fields : typing.Optional[str]
258 Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields.
259
260 include_fields : typing.Optional[bool]
261 Whether specified fields are to be included (true) or excluded (false).
262
263 user_id : typing.Optional[str]
264 user_id of the devices to retrieve.
265
266 client_id : typing.Optional[str]
267 client_id of the devices to retrieve.
268
269 type : typing.Optional[DeviceCredentialTypeEnum]
270 Type of credentials to retrieve. Must be `public_key`, `refresh_token` or `rotating_refresh_token`. The property will default to `refresh_token` when paging is requested
271
272 request_options : typing.Optional[RequestOptions]
273 Request-specific configuration.
274
275 Returns
276 -------
277 AsyncPager[DeviceCredential, ListDeviceCredentialsOffsetPaginatedResponseContent]
278 Device credentials successfully retrieved.
279
280 Examples
281 --------
282 import asyncio
283
284 from auth0 import AsyncAuth0
285
286 client = AsyncAuth0(
287 token="YOUR_TOKEN",
288 )
289
290
291 async def main() -> None:
292 response = await client.device_credentials.list(
293 page=1,
294 per_page=1,
295 include_totals=True,
296 fields="fields",
297 include_fields=True,
298 user_id="user_id",
299 client_id="client_id",
300 type="public_key",
301 )
302 async for item in response:
303 yield item
304
305 # alternatively, you can paginate page-by-page
306 async for page in response.iter_pages():
307 yield page
308
309
310 asyncio.run(main())
311 """
312 return await self._raw_client.list(
313 page=page,
314 per_page=per_page,
315 include_totals=include_totals,
316 fields=fields,
317 include_fields=include_fields,
318 user_id=user_id,
319 client_id=client_id,
320 type=type,
321 request_options=request_options,
322 )
323
324 async def create_public_key(
325 self,
326 *,
327 device_name: str,
328 type: DeviceCredentialPublicKeyTypeEnum,
329 value: str,
330 device_id: str,
331 client_id: typing.Optional[str] = OMIT,
332 request_options: typing.Optional[RequestOptions] = None,
333 ) -> CreatePublicKeyDeviceCredentialResponseContent:
334 """
335 Create a device credential public key to manage refresh token rotation for a given `user_id`. Device Credentials APIs are designed for ad-hoc administrative use only and paging is by default enabled for GET requests.
336
337 When refresh token rotation is enabled, the endpoint becomes consistent. For more information, read [Signing Keys](https://auth0.com/docs/get-started/tenant-settings/signing-keys).
338
339 Parameters
340 ----------
341 device_name : str
342 Name for this device easily recognized by owner.
343
344 type : DeviceCredentialPublicKeyTypeEnum
345
346 value : str
347 Base64 encoded string containing the credential.
348
349 device_id : str
350 Unique identifier for the device. Recommend using <a href="http://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID">Android_ID</a> on Android and <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/index.html#//apple_ref/occ/instp/UIDevice/identifierForVendor">identifierForVendor</a>.
351
352 client_id : typing.Optional[str]
353 client_id of the client (application) this credential is for.
354
355 request_options : typing.Optional[RequestOptions]
356 Request-specific configuration.
357
358 Returns
359 -------
360 CreatePublicKeyDeviceCredentialResponseContent
361 Device credentials successfully created.
362
363 Examples
364 --------
365 import asyncio
366
367 from auth0 import AsyncAuth0
368
369 client = AsyncAuth0(
370 token="YOUR_TOKEN",
371 )
372
373
374 async def main() -> None:
375 await client.device_credentials.create_public_key(
376 device_name="device_name",
377 type="public_key",
378 value="value",
379 device_id="device_id",
380 )
381
382
383 asyncio.run(main())
384 """
385 _response = await self._raw_client.create_public_key(
386 device_name=device_name,
387 type=type,
388 value=value,
389 device_id=device_id,
390 client_id=client_id,
391 request_options=request_options,
392 )
393 return _response.data
394
395 async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
396 """
397 Permanently delete a device credential (such as a refresh token or public key) with the given ID.
398
399 Parameters
400 ----------
401 id : str
402 ID of the credential to delete.
403
404 request_options : typing.Optional[RequestOptions]
405 Request-specific configuration.
406
407 Returns
408 -------
409 None
410
411 Examples
412 --------
413 import asyncio
414
415 from auth0 import AsyncAuth0
416
417 client = AsyncAuth0(
418 token="YOUR_TOKEN",
419 )
420
421
422 async def main() -> None:
423 await client.device_credentials.delete(
424 id="id",
425 )
426
427
428 asyncio.run(main())
429 """
430 _response = await self._raw_client.delete(id, request_options=request_options)
431 return _response.data