lib/algolia/client.rb in algoliasearch-1.2.10 vs lib/algolia/client.rb in algoliasearch-1.2.11
- old
+ new
@@ -309,9 +309,38 @@
}
params[:indexes] = indexes if indexes
Algolia.client.post(Protocol.keys_uri, params.to_json)
end
+ #
+ # Update a user key
+ #
+ # @param acls the list of ACL for this key. Defined by an array of strings that
+ # can contains the following values:
+ # - search: allow to search (https and http)
+ # - addObject: allows to add a new object in the index (https only)
+ # - updateObject : allows to change content of an existing object (https only)
+ # - deleteObject : allows to delete an existing object (https only)
+ # - deleteIndex : allows to delete index content (https only)
+ # - settings : allows to get index settings (https only)
+ # - editSettings : allows to change index settings (https only)
+ # @param validity the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
+ # @param maxQueriesPerIPPerHour the maximum number of API calls allowed from an IP address per hour (0 means unlimited)
+ # @param maxHitsPerQuery the maximum number of hits this API key can retrieve in one call (0 means unlimited)
+ # @param indexes the optional list of targeted indexes
+ #
+ def Algolia.update_user_key(key, acls, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
+ params = {
+ :acl => acls,
+ :validity => validity.to_i,
+ :maxQueriesPerIPPerHour => maxQueriesPerIPPerHour.to_i,
+ :maxHitsPerQuery => maxHitsPerQuery.to_i
+ }
+ params[:indexes] = indexes if indexes
+ Algolia.client.put(Protocol.key_uri(key), params.to_json)
+ end
+
+
# Delete an existing user key
def Algolia.delete_user_key(key)
Algolia.client.delete(Protocol.key_uri(key))
end