Debian Codegraph @

src/auth0/management/keys/encryption/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_encryption_key_public_wrapping_response_content import (
9 CreateEncryptionKeyPublicWrappingResponseContent,
10 )
11 from ...types.create_encryption_key_response_content import CreateEncryptionKeyResponseContent
12 from ...types.create_encryption_key_type import CreateEncryptionKeyType
13 from ...types.encryption_key import EncryptionKey
14 from ...types.get_encryption_key_response_content import GetEncryptionKeyResponseContent
15 from ...types.import_encryption_key_response_content import ImportEncryptionKeyResponseContent
16 from ...types.list_encryption_key_offset_paginated_response_content import (
17 ListEncryptionKeyOffsetPaginatedResponseContent,
18 )
19 from .raw_client import AsyncRawEncryptionClient, RawEncryptionClient
20
21 # this is used as the default value for optional parameters
22 OMIT = typing.cast(typing.Any, ...)
23
24
25 class EncryptionClient:
26 def __init__(self, *, client_wrapper: SyncClientWrapper):
27 self._raw_client = RawEncryptionClient(client_wrapper=client_wrapper)
28
29 @property
30 def with_raw_response(self) -> RawEncryptionClient:
31 """
32 Retrieves a raw implementation of this client that returns raw responses.
33
34 Returns
35 -------
36 RawEncryptionClient
37 """
38 return self._raw_client
39
40 def list(
41 self,
42 *,
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[EncryptionKey, ListEncryptionKeyOffsetPaginatedResponseContent]:
48 """
49 Retrieve details of all the encryption keys associated with your tenant.
50
51 Parameters
52 ----------
53 page : typing.Optional[int]
54 Page index of the results to return. First page is 0.
55
56 per_page : typing.Optional[int]
57 Number of results per page. Default value is 50, maximum value is 100.
58
59 include_totals : typing.Optional[bool]
60 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
61
62 request_options : typing.Optional[RequestOptions]
63 Request-specific configuration.
64
65 Returns
66 -------
67 SyncPager[EncryptionKey, ListEncryptionKeyOffsetPaginatedResponseContent]
68 The keys were successfully retrieved.
69
70 Examples
71 --------
72 from auth0 import Auth0
73
74 client = Auth0(
75 token="YOUR_TOKEN",
76 )
77 response = client.keys.encryption.list(
78 page=1,
79 per_page=1,
80 include_totals=True,
81 )
82 for item in response:
83 yield item
84 # alternatively, you can paginate page-by-page
85 for page in response.iter_pages():
86 yield page
87 """
88 return self._raw_client.list(
89 page=page, per_page=per_page, include_totals=include_totals, request_options=request_options
90 )
91
92 def create(
93 self, *, type: CreateEncryptionKeyType, request_options: typing.Optional[RequestOptions] = None
94 ) -> CreateEncryptionKeyResponseContent:
95 """
96 Create the new, pre-activated encryption key, without the key material.
97
98 Parameters
99 ----------
100 type : CreateEncryptionKeyType
101
102 request_options : typing.Optional[RequestOptions]
103 Request-specific configuration.
104
105 Returns
106 -------
107 CreateEncryptionKeyResponseContent
108 The key was successfully created.
109
110 Examples
111 --------
112 from auth0 import Auth0
113
114 client = Auth0(
115 token="YOUR_TOKEN",
116 )
117 client.keys.encryption.create(
118 type="customer-provided-root-key",
119 )
120 """
121 _response = self._raw_client.create(type=type, request_options=request_options)
122 return _response.data
123
124 def rekey(self, *, request_options: typing.Optional[RequestOptions] = None) -> None:
125 """
126 Perform rekeying operation on the key hierarchy.
127
128 Parameters
129 ----------
130 request_options : typing.Optional[RequestOptions]
131 Request-specific configuration.
132
133 Returns
134 -------
135 None
136
137 Examples
138 --------
139 from auth0 import Auth0
140
141 client = Auth0(
142 token="YOUR_TOKEN",
143 )
144 client.keys.encryption.rekey()
145 """
146 _response = self._raw_client.rekey(request_options=request_options)
147 return _response.data
148
149 def get(
150 self, kid: str, *, request_options: typing.Optional[RequestOptions] = None
151 ) -> GetEncryptionKeyResponseContent:
152 """
153 Retrieve details of the encryption key with the given ID.
154
155 Parameters
156 ----------
157 kid : str
158 Encryption key ID
159
160 request_options : typing.Optional[RequestOptions]
161 Request-specific configuration.
162
163 Returns
164 -------
165 GetEncryptionKeyResponseContent
166 The key was successfully retrieved.
167
168 Examples
169 --------
170 from auth0 import Auth0
171
172 client = Auth0(
173 token="YOUR_TOKEN",
174 )
175 client.keys.encryption.get(
176 kid="kid",
177 )
178 """
179 _response = self._raw_client.get(kid, request_options=request_options)
180 return _response.data
181
182 def import_(
183 self, kid: str, *, wrapped_key: str, request_options: typing.Optional[RequestOptions] = None
184 ) -> ImportEncryptionKeyResponseContent:
185 """
186 Import wrapped key material and activate encryption key.
187
188 Parameters
189 ----------
190 kid : str
191 Encryption key ID
192
193 wrapped_key : str
194 Base64 encoded ciphertext of key material wrapped by public wrapping key.
195
196 request_options : typing.Optional[RequestOptions]
197 Request-specific configuration.
198
199 Returns
200 -------
201 ImportEncryptionKeyResponseContent
202 The key was successfully imported.
203
204 Examples
205 --------
206 from auth0 import Auth0
207
208 client = Auth0(
209 token="YOUR_TOKEN",
210 )
211 client.keys.encryption.import_(
212 kid="kid",
213 wrapped_key="wrapped_key",
214 )
215 """
216 _response = self._raw_client.import_(kid, wrapped_key=wrapped_key, request_options=request_options)
217 return _response.data
218
219 def delete(self, kid: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
220 """
221 Delete the custom provided encryption key with the given ID and move back to using native encryption key.
222
223 Parameters
224 ----------
225 kid : str
226 Encryption key ID
227
228 request_options : typing.Optional[RequestOptions]
229 Request-specific configuration.
230
231 Returns
232 -------
233 None
234
235 Examples
236 --------
237 from auth0 import Auth0
238
239 client = Auth0(
240 token="YOUR_TOKEN",
241 )
242 client.keys.encryption.delete(
243 kid="kid",
244 )
245 """
246 _response = self._raw_client.delete(kid, request_options=request_options)
247 return _response.data
248
249 def create_public_wrapping_key(
250 self, kid: str, *, request_options: typing.Optional[RequestOptions] = None
251 ) -> CreateEncryptionKeyPublicWrappingResponseContent:
252 """
253 Create the public wrapping key to wrap your own encryption key material.
254
255 Parameters
256 ----------
257 kid : str
258 Encryption key ID
259
260 request_options : typing.Optional[RequestOptions]
261 Request-specific configuration.
262
263 Returns
264 -------
265 CreateEncryptionKeyPublicWrappingResponseContent
266 The public wrapping key was successfully created.
267
268 Examples
269 --------
270 from auth0 import Auth0
271
272 client = Auth0(
273 token="YOUR_TOKEN",
274 )
275 client.keys.encryption.create_public_wrapping_key(
276 kid="kid",
277 )
278 """
279 _response = self._raw_client.create_public_wrapping_key(kid, request_options=request_options)
280 return _response.data
281
282
283 class AsyncEncryptionClient:
284 def __init__(self, *, client_wrapper: AsyncClientWrapper):
285 self._raw_client = AsyncRawEncryptionClient(client_wrapper=client_wrapper)
286
287 @property
288 def with_raw_response(self) -> AsyncRawEncryptionClient:
289 """
290 Retrieves a raw implementation of this client that returns raw responses.
291
292 Returns
293 -------
294 AsyncRawEncryptionClient
295 """
296 return self._raw_client
297
298 async def list(
299 self,
300 *,
301 page: typing.Optional[int] = 0,
302 per_page: typing.Optional[int] = 50,
303 include_totals: typing.Optional[bool] = True,
304 request_options: typing.Optional[RequestOptions] = None,
305 ) -> AsyncPager[EncryptionKey, ListEncryptionKeyOffsetPaginatedResponseContent]:
306 """
307 Retrieve details of all the encryption keys associated with your tenant.
308
309 Parameters
310 ----------
311 page : typing.Optional[int]
312 Page index of the results to return. First page is 0.
313
314 per_page : typing.Optional[int]
315 Number of results per page. Default value is 50, maximum value is 100.
316
317 include_totals : typing.Optional[bool]
318 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
319
320 request_options : typing.Optional[RequestOptions]
321 Request-specific configuration.
322
323 Returns
324 -------
325 AsyncPager[EncryptionKey, ListEncryptionKeyOffsetPaginatedResponseContent]
326 The keys were successfully retrieved.
327
328 Examples
329 --------
330 import asyncio
331
332 from auth0 import AsyncAuth0
333
334 client = AsyncAuth0(
335 token="YOUR_TOKEN",
336 )
337
338
339 async def main() -> None:
340 response = await client.keys.encryption.list(
341 page=1,
342 per_page=1,
343 include_totals=True,
344 )
345 async for item in response:
346 yield item
347
348 # alternatively, you can paginate page-by-page
349 async for page in response.iter_pages():
350 yield page
351
352
353 asyncio.run(main())
354 """
355 return await self._raw_client.list(
356 page=page, per_page=per_page, include_totals=include_totals, request_options=request_options
357 )
358
359 async def create(
360 self, *, type: CreateEncryptionKeyType, request_options: typing.Optional[RequestOptions] = None
361 ) -> CreateEncryptionKeyResponseContent:
362 """
363 Create the new, pre-activated encryption key, without the key material.
364
365 Parameters
366 ----------
367 type : CreateEncryptionKeyType
368
369 request_options : typing.Optional[RequestOptions]
370 Request-specific configuration.
371
372 Returns
373 -------
374 CreateEncryptionKeyResponseContent
375 The key was successfully created.
376
377 Examples
378 --------
379 import asyncio
380
381 from auth0 import AsyncAuth0
382
383 client = AsyncAuth0(
384 token="YOUR_TOKEN",
385 )
386
387
388 async def main() -> None:
389 await client.keys.encryption.create(
390 type="customer-provided-root-key",
391 )
392
393
394 asyncio.run(main())
395 """
396 _response = await self._raw_client.create(type=type, request_options=request_options)
397 return _response.data
398
399 async def rekey(self, *, request_options: typing.Optional[RequestOptions] = None) -> None:
400 """
401 Perform rekeying operation on the key hierarchy.
402
403 Parameters
404 ----------
405 request_options : typing.Optional[RequestOptions]
406 Request-specific configuration.
407
408 Returns
409 -------
410 None
411
412 Examples
413 --------
414 import asyncio
415
416 from auth0 import AsyncAuth0
417
418 client = AsyncAuth0(
419 token="YOUR_TOKEN",
420 )
421
422
423 async def main() -> None:
424 await client.keys.encryption.rekey()
425
426
427 asyncio.run(main())
428 """
429 _response = await self._raw_client.rekey(request_options=request_options)
430 return _response.data
431
432 async def get(
433 self, kid: str, *, request_options: typing.Optional[RequestOptions] = None
434 ) -> GetEncryptionKeyResponseContent:
435 """
436 Retrieve details of the encryption key with the given ID.
437
438 Parameters
439 ----------
440 kid : str
441 Encryption key ID
442
443 request_options : typing.Optional[RequestOptions]
444 Request-specific configuration.
445
446 Returns
447 -------
448 GetEncryptionKeyResponseContent
449 The key was successfully retrieved.
450
451 Examples
452 --------
453 import asyncio
454
455 from auth0 import AsyncAuth0
456
457 client = AsyncAuth0(
458 token="YOUR_TOKEN",
459 )
460
461
462 async def main() -> None:
463 await client.keys.encryption.get(
464 kid="kid",
465 )
466
467
468 asyncio.run(main())
469 """
470 _response = await self._raw_client.get(kid, request_options=request_options)
471 return _response.data
472
473 async def import_(
474 self, kid: str, *, wrapped_key: str, request_options: typing.Optional[RequestOptions] = None
475 ) -> ImportEncryptionKeyResponseContent:
476 """
477 Import wrapped key material and activate encryption key.
478
479 Parameters
480 ----------
481 kid : str
482 Encryption key ID
483
484 wrapped_key : str
485 Base64 encoded ciphertext of key material wrapped by public wrapping key.
486
487 request_options : typing.Optional[RequestOptions]
488 Request-specific configuration.
489
490 Returns
491 -------
492 ImportEncryptionKeyResponseContent
493 The key was successfully imported.
494
495 Examples
496 --------
497 import asyncio
498
499 from auth0 import AsyncAuth0
500
501 client = AsyncAuth0(
502 token="YOUR_TOKEN",
503 )
504
505
506 async def main() -> None:
507 await client.keys.encryption.import_(
508 kid="kid",
509 wrapped_key="wrapped_key",
510 )
511
512
513 asyncio.run(main())
514 """
515 _response = await self._raw_client.import_(kid, wrapped_key=wrapped_key, request_options=request_options)
516 return _response.data
517
518 async def delete(self, kid: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
519 """
520 Delete the custom provided encryption key with the given ID and move back to using native encryption key.
521
522 Parameters
523 ----------
524 kid : str
525 Encryption key ID
526
527 request_options : typing.Optional[RequestOptions]
528 Request-specific configuration.
529
530 Returns
531 -------
532 None
533
534 Examples
535 --------
536 import asyncio
537
538 from auth0 import AsyncAuth0
539
540 client = AsyncAuth0(
541 token="YOUR_TOKEN",
542 )
543
544
545 async def main() -> None:
546 await client.keys.encryption.delete(
547 kid="kid",
548 )
549
550
551 asyncio.run(main())
552 """
553 _response = await self._raw_client.delete(kid, request_options=request_options)
554 return _response.data
555
556 async def create_public_wrapping_key(
557 self, kid: str, *, request_options: typing.Optional[RequestOptions] = None
558 ) -> CreateEncryptionKeyPublicWrappingResponseContent:
559 """
560 Create the public wrapping key to wrap your own encryption key material.
561
562 Parameters
563 ----------
564 kid : str
565 Encryption key ID
566
567 request_options : typing.Optional[RequestOptions]
568 Request-specific configuration.
569
570 Returns
571 -------
572 CreateEncryptionKeyPublicWrappingResponseContent
573 The public wrapping key was successfully created.
574
575 Examples
576 --------
577 import asyncio
578
579 from auth0 import AsyncAuth0
580
581 client = AsyncAuth0(
582 token="YOUR_TOKEN",
583 )
584
585
586 async def main() -> None:
587 await client.keys.encryption.create_public_wrapping_key(
588 kid="kid",
589 )
590
591
592 asyncio.run(main())
593 """
594 _response = await self._raw_client.create_public_wrapping_key(kid, request_options=request_options)
595 return _response.data