|
10 | 10 | from .dss.project import DSSProject |
11 | 11 | from .dss.app import DSSApp |
12 | 12 | from .dss.plugin import DSSPlugin |
13 | | -from .dss.admin import DSSUser, DSSUserActivity, DSSOwnUser, DSSGroup, DSSConnection, DSSGeneralSettings, DSSCodeEnv, DSSGlobalApiKey, DSSCluster, DSSGlobalUsageSummary, DSSInstanceVariables, DSSPersonalApiKey |
| 13 | +from .dss.admin import DSSPersonalApiKeyListItem, DSSUser, DSSUserActivity, DSSOwnUser, DSSGroup, DSSConnection, DSSGeneralSettings, DSSCodeEnv, DSSGlobalApiKey, DSSCluster, DSSGlobalUsageSummary, DSSInstanceVariables, DSSPersonalApiKey |
14 | 14 |
|
15 | 15 | from .dss.meaning import DSSMeaning |
16 | 16 | from .dss.sqlquery import DSSSQLQuery |
@@ -674,21 +674,24 @@ def create_global_api_key(self, label=None, description=None, admin=False): |
674 | 674 | # Personal API Keys |
675 | 675 | ######################################################## |
676 | 676 |
|
677 | | - def list_personal_api_keys(self, as_type='objects'): |
| 677 | + def list_personal_api_keys(self, as_type='listitems'): |
678 | 678 | """ |
679 | 679 | List all your personal API keys. |
680 | 680 |
|
681 | 681 | :param str as_type: How to return the personal API keys. Possible values are "dict" and "objects" |
682 | 682 | |
683 | | - :return: if as_type=dict, each personal API keys is returned as a dict. |
| 683 | + :return: if as_type=listitems, each one as a :class:`dataikuapi.dss.admin.DSSPersonalApiKeyListItem`. |
684 | 684 | if as_type=objects, each key is returned as a :class:`dataikuapi.dss.admin.DSSPersonalApiKey`. |
685 | 685 | """ |
686 | 686 | resp = self._perform_json( |
687 | 687 | "GET", "/personal-api-keys/") |
688 | | - if as_type == 'objects': |
| 688 | + |
| 689 | + if as_type == "listitems": |
| 690 | + return [DSSPersonalApiKeyListItem(self, item) for item in resp] |
| 691 | + elif as_type == 'objects': |
689 | 692 | return [DSSPersonalApiKey(self, item['id']) for item in resp] |
690 | 693 | else: |
691 | | - return resp |
| 694 | + raise ValueError("Unknown as_type") |
692 | 695 |
|
693 | 696 | def get_personal_api_key(self, id): |
694 | 697 | """ |
@@ -723,22 +726,24 @@ def create_personal_api_key(self, label="", description="", as_type='dict'): |
723 | 726 | else: |
724 | 727 | return resp |
725 | 728 |
|
726 | | - def list_all_personal_api_keys(self, as_type='objects'): |
| 729 | + def list_all_personal_api_keys(self, as_type='listitems'): |
727 | 730 | """ |
728 | 731 | List all personal API keys. |
729 | 732 | Only admin can list all the keys. |
730 | 733 | |
731 | 734 | :param str as_type: How to return the personal API keys. Possible values are "dict" and "objects" |
732 | 735 | |
733 | | - :return: if as_type=dict, each personal API keys is returned as a dict. |
| 736 | + :return: if as_type=listitems, each one as a :class:`dataikuapi.dss.admin.DSSPersonalApiKeyListItem`. |
734 | 737 | if as_type=objects, each key is returned as a :class:`dataikuapi.dss.admin.DSSPersonalApiKey`. |
735 | 738 | """ |
736 | 739 | resp = self._perform_json( |
737 | 740 | "GET", "/admin/personal-api-keys/") |
738 | | - if as_type == 'objects': |
| 741 | + if as_type == "listitems": |
| 742 | + return [DSSPersonalApiKeyListItem(self, item) for item in resp] |
| 743 | + elif as_type == 'objects': |
739 | 744 | return [DSSPersonalApiKey(self, item['id']) for item in resp] |
740 | 745 | else: |
741 | | - return resp |
| 746 | + raise ValueError("Unknown as_type") |
742 | 747 |
|
743 | 748 | def create_personal_api_key_for_user(self, user, label="", description="", as_type='object'): |
744 | 749 | """ |
|
0 commit comments