AlgoliaSearch\Client::addUserKey PHP Метод

addUserKey() публичный метод

Create a new user key.
public addUserKey ( array $obj, integer $validity, integer $maxQueriesPerIPPerHour, integer $maxHitsPerQuery, array | null $indexes = null ) : mixed
$obj array can be two different parameters: The list of parameters for this key. Defined by an array that can contain the following values: - acl: array of string - indices: array of string - validity: int - referers: array of string - description: string - maxHitsPerQuery: integer - queryParameters: string - maxQueriesPerIPPerHour: integer Or the list of ACL for this key. Defined by an array of string that can contains the following values: - search: allow to search (https and http) - addObject: allows to add/update an object in the index (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)
$validity integer the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
$maxQueriesPerIPPerHour integer Specify the maximum number of API calls allowed from an IP address per hour. Defaults to 0 (no rate limit).
$maxHitsPerQuery integer Specify the maximum number of hits this API key can retrieve in one call. Defaults to 0 (unlimited)
$indexes array | null Specify the list of indices to target (null means all)
Результат mixed
    public function addUserKey($obj, $validity = 0, $maxQueriesPerIPPerHour = 0, $maxHitsPerQuery = 0, $indexes = null)
    {
        if ($obj !== array_values($obj)) {
            // is dict of value
            $params = $obj;
            $params['validity'] = $validity;
            $params['maxQueriesPerIPPerHour'] = $maxQueriesPerIPPerHour;
            $params['maxHitsPerQuery'] = $maxHitsPerQuery;
        } else {
            $params = array('acl' => $obj, 'validity' => $validity, 'maxQueriesPerIPPerHour' => $maxQueriesPerIPPerHour, 'maxHitsPerQuery' => $maxHitsPerQuery);
        }
        if ($indexes != null) {
            $params['indexes'] = $indexes;
        }
        return $this->request($this->context, 'POST', '/1/keys', array(), $params, $this->context->writeHostsArray, $this->context->connectTimeout, $this->context->readTimeout);
    }