Skip to content

Commit 5dafd4a

Browse files
committed
implement Mickael comments
1 parent f9de1e0 commit 5dafd4a

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

dataikuapi/dss/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@ def set_definition(self, definition):
10651065
class DSSPersonalApiKey(object):
10661066
"""
10671067
A personal API key on the DSS instance
1068+
Do not call that directly, use :meth:`dataikuapi.DSSClient.get_personal_api_key`
10681069
"""
10691070
def __init__(self, client, id_):
10701071
"""Do not call that directly, use :meth:`dataikuapi.DSSClient.get_personal_api_key`"""
@@ -1078,6 +1079,7 @@ def __init__(self, client, id_):
10781079
def get_definition(self):
10791080
"""
10801081
Get the API key's definition
1082+
10811083
:returns: the personal API key definition, as a JSON object
10821084
"""
10831085
return self.client._perform_json(

dataikuapi/dssclient.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ def get_global_api_key(self, key):
612612
Get a handle to interact with a specific Global API key
613613
614614
:param str key: the secret key of the desired API key
615+
615616
:returns: A :class:`dataikuapi.dss.admin.DSSGlobalApiKey` API key handle
616617
"""
617618
return DSSGlobalApiKey(self, key)
@@ -625,6 +626,7 @@ def create_global_api_key(self, label=None, description=None, admin=False):
625626
:param str label: the label of the new API key
626627
:param str description: the description of the new API key
627628
:param str admin: has the new API key admin rights (True or False)
629+
628630
:returns: A :class:`dataikuapi.dss.admin.DSSGlobalApiKey` API key handle
629631
"""
630632
resp = self._perform_json(
@@ -651,8 +653,11 @@ def create_global_api_key(self, label=None, description=None, admin=False):
651653
def list_personal_api_keys(self, as_type='dict'):
652654
"""
653655
List all your personal API keys
654-
:param str as_type: 'objects' or 'dict'
655-
:returns: All personal API keys associated with your user
656+
657+
:param str as_type: How to return the personal API keys. Possible values are "dict" and "object"
658+
659+
:return: if as_type=dict, each personal API keys is returned as a dict.
660+
if as_type=object, each key is returned as a :class:`dataikuapi.dss.admin.DSSPersonalApiKey`.
656661
"""
657662
resp = self._perform_json(
658663
"GET", "/personal-api-keys/")
@@ -661,23 +666,26 @@ def list_personal_api_keys(self, as_type='dict'):
661666
else:
662667
return resp
663668

664-
def get_personal_api_key(self, key):
669+
def get_personal_api_key(self, id):
665670
"""
666671
Get a handle to interact with a specific Personal API key
667672
668-
:param str key: the secret key of the desired API key
673+
:param str id: the secret id of the desired API key
674+
669675
:returns: A :class:`dataikuapi.dss.admin.DSSPersonalApiKey` API key handle
670676
"""
671-
return DSSPersonalApiKey(self, key)
672-
677+
return DSSPersonalApiKey(self, id)
673678

674679
def create_personal_api_key(self, label="", description="", as_type='dict'):
675680
"""
676681
Create a Personal API key associated with your user
682+
677683
:param str label: the label of the new API key
678684
:param str description: the description of the new API key
679-
:param str as_type: 'object' or 'dict'
680-
:returns: The new personal API key associated with your user
685+
:param str as_type: How to return the personal API keys. Possible values are "dict" and "object"
686+
687+
:return: if as_type=dict, the new personal API key is returned as a dict.
688+
if as_type=object, the new personal API key is returned as a :class:`dataikuapi.dss.admin.DSSPersonalApiKey`.
681689
"""
682690
resp = self._perform_json(
683691
"POST", "/personal-api-keys/", body={"label": label, "description": description})
@@ -697,8 +705,11 @@ def list_all_personal_api_keys(self, as_type='dict'):
697705
"""
698706
List all personal API keys
699707
Only admin can list all the keys
700-
:param str as_type: 'objects' or 'dict'
701-
:returns: All personal API keys in DSS
708+
709+
:param str as_type: How to return the personal API keys. Possible values are "dict" and "object"
710+
711+
:return: if as_type=dict, each personal API keys is returned as a dict.
712+
if as_type=object, each key is returned as a :class:`dataikuapi.dss.admin.DSSPersonalApiKey`.
702713
"""
703714
resp = self._perform_json(
704715
"GET", "/admin/personal-api-keys/")
@@ -707,16 +718,18 @@ def list_all_personal_api_keys(self, as_type='dict'):
707718
else:
708719
return resp
709720

710-
711-
def create_personal_api_key_for_user(self, label="", description="", as_type='dict', user=""):
721+
def create_personal_api_key_for_user(self, label="", description="", user="", as_type='dict'):
712722
"""
713723
Create a Personal API key associated on behalf of a user
714724
Only admin can create a key for another user
725+
715726
:param str label: the label of the new API key
716727
:param str description: the description of the new API key
717-
:param str as_type: 'object' or 'dict'
718728
:param str user: the id of the user to impersonate
719-
:returns: The new personal API key associated with 'user'
729+
:param str as_type: How to return the personal API keys. Possible values are "dict" and "object"
730+
731+
:return: if as_type=dict, the new personal API key is returned as a dict.
732+
if as_type=object, the new personal API key is returned as a :class:`dataikuapi.dss.admin.DSSPersonalApiKey`.
720733
"""
721734
resp = self._perform_json(
722735
"POST", "/admin/personal-api-keys/", body={"user": user, "label": label, "description": description})
@@ -732,7 +745,6 @@ def create_personal_api_key_for_user(self, label="", description="", as_type='di
732745
else:
733746
return resp
734747

735-
736748
########################################################
737749
# Meanings
738750
########################################################

0 commit comments

Comments
 (0)