Skip to content

Commit fa6aadb

Browse files
committed
feat(keys): Deprecate remaining API keys methods on Index in favor of Client ones
1 parent 729842b commit fa6aadb

File tree

1 file changed

+18
-41
lines changed

1 file changed

+18
-41
lines changed

algoliasearch/index.py

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -859,57 +859,62 @@ def set_settings(self, settings, forward_to_slaves=True,
859859

860860
@deprecated
861861
def listUserKeys(self):
862+
"""Use `list_api_keys` on the client instead."""
862863
return self.list_user_keys()
863864

864865
@deprecated
865866
def list_user_keys(self):
866-
"""Use `list_api_keys`"""
867+
"""Use `list_api_keys` on the client instead."""
867868
return self.list_api_keys()
868869

870+
@deprecated
869871
def list_api_keys(self, request_options=None):
870-
"""
871-
List all existing api keys of this index with their associated ACLs.
872-
"""
872+
"""Use `list_api_keys` on the client instead."""
873873
return self._req(True, '/keys', 'GET', request_options)
874874

875875
@deprecated
876876
def getUserKeyACL(self, key):
877+
"""Use `get_api_key` on the client instead."""
877878
return self.get_user_key_acl(key)
878879

879880
@deprecated
880881
def get_user_key_acl(self, key):
881-
"""Use `get_api_key_acl`"""
882+
"""Use `get_api_key` on the client instead."""
882883
return self.get_api_key_acl(key)
883884

885+
@deprecated
884886
def get_api_key_acl(self, key, request_options=None):
885-
"""Get ACL of a api key associated to this index."""
887+
"""Use `get_api_key` on the client instead."""
886888
path = '/keys/%s' % key
887889
return self._req(True, path, 'GET', request_options)
888890

889891
@deprecated
890892
def deleteUserKey(self, key):
893+
"""Use `delete_api_key` on the client instead."""
891894
return self.delete_user_key(key)
892895

893896
@deprecated
894897
def delete_user_key(self, key):
895-
"""Use `delete_api_key`"""
898+
"""Use `delete_api_key` on the client instead."""
896899
return self.delete_api_key(key)
897900

901+
@deprecated
898902
def delete_api_key(self, key, request_options=None):
899-
"""Delete an existing api key associated to this index."""
903+
"""Use `delete_api_key` on the client instead."""
900904
path = '/keys/%s' % key
901905
return self._req(False, path, 'DELETE', request_options)
902906

903907
@deprecated
904908
def addUserKey(self, obj, validity=0, max_queries_per_ip_per_hour=0,
905909
max_hits_per_query=0):
910+
"""Use `add_api_key` on the client instead."""
906911
return self.add_user_key(obj, validity, max_queries_per_ip_per_hour,
907912
max_hits_per_query)
908913

909914
@deprecated
910915
def add_user_key(self, obj, validity=0, max_queries_per_ip_per_hour=0,
911916
max_hits_per_query=0):
912-
"""Use `add_api_key` on the client instead"""
917+
"""Use `add_api_key` on the client instead."""
913918
return self.add_api_key(
914919
obj, validity, max_queries_per_ip_per_hour,
915920
max_hits_per_query
@@ -918,7 +923,7 @@ def add_user_key(self, obj, validity=0, max_queries_per_ip_per_hour=0,
918923
@deprecated
919924
def add_api_key(self, obj, validity=0, max_queries_per_ip_per_hour=0,
920925
max_hits_per_query=0, request_options=None):
921-
"""Use `add_api_key` on the client instead"""
926+
"""Use `add_api_key` on the client instead."""
922927
if not isinstance(obj, dict):
923928
obj = {'acl': obj}
924929

@@ -934,45 +939,17 @@ def add_api_key(self, obj, validity=0, max_queries_per_ip_per_hour=0,
934939
def update_user_key(self, key, obj, validity=None,
935940
max_queries_per_ip_per_hour=None,
936941
max_hits_per_query=None):
937-
"""Use `update_api_key`"""
942+
"""Use `update_api_key` on the client instead."""
938943
return self.update_api_key(
939944
key, obj, validity, max_queries_per_ip_per_hour,
940945
max_hits_per_query
941946
)
942947

948+
@deprecated
943949
def update_api_key(self, key, obj, validity=None,
944950
max_queries_per_ip_per_hour=None,
945951
max_hits_per_query=None, request_options=None):
946-
"""
947-
Update a api key associated to this index (can only access to this index).
948-
949-
@param obj can be two different parameters:
950-
The list of parameters for this key. Defined by a dictionary that
951-
can contains the following values:
952-
- acl: array of string
953-
- indices: array of string
954-
- validity: int
955-
- referers: array of string
956-
- description: string
957-
- maxHitsPerQuery: integer
958-
- queryParameters: string
959-
- maxQueriesPerIPPerHour: integer
960-
Or the list of ACL for this key. Defined by an array of string that
961-
can contains the following values:
962-
- search: allow to search (https and http)
963-
- addObject: allows to add/update an object in the index (https only)
964-
- deleteObject : allows to delete an existing object (https only)
965-
- deleteIndex : allows to delete index content (https only)
966-
- settings : allows to get index settings (https only)
967-
- editSettings : allows to change index settings (https only)
968-
@param validity the number of seconds after which the key will be
969-
automatically removed (0 means no time limit for this key)
970-
@param max_queries_per_ip_per_hour Specify the maximum number of API
971-
calls allowed from an IP address per hour. Defaults to 0 (no rate
972-
limit).
973-
@param max_hits_per_query Specify the maximum number of hits this API
974-
key can retrieve in one call. Defaults to 0 (unlimited)
975-
"""
952+
"""Use `update_api_key` on the client instead."""
976953
if not isinstance(obj, dict):
977954
obj = {'acl': obj}
978955

0 commit comments

Comments
 (0)