Skip to content

Commit

Permalink
docs: add saveObjects, deleteObjects and partialUpdateObjects to help…
Browse files Browse the repository at this point in the history
…ers (#3256)
  • Loading branch information
shortcuts authored Jun 26, 2024
1 parent 7a90e45 commit f160d6f
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions website/docs/contributing/add-new-api-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,22 @@ For more information, see [Common Test Suite](../contributing/testing/common-tes

The API clients have hand-written helpers for tasks that would otherwise require custom code.

| Helper name | Description | Wrapped API call | Stop condition | Example |
|-------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `waitForTask` | Given a `taskID`, calls the `getTask` method until the status gets `published` | `getTask()` | `response.status == "published"` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `waitForAppTask` | Given a `taskID`, calls the `getAppTask` method until the status gets `published` | `getAppTask()` | `response.status == "published"` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `waitForApiKey` | Given a `Key`, calls the `getApiKey` method until the stop condition for the given `operation` is validated | `getApiKey()` | Diff between the given `Key` and the `response` payload | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `browseObjects<T>` | Given an `indexName` and the same parameters as the `browse` method, aggregates all the `objects` returned by the API calls in a single `browse` response object | `browse()` | `response.cursor == null` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `browseRules` | Given an `indexName` and the same parameters as the `searchRules` method, aggregates all the `rules` returned by the API calls in a single `searchRules` response object | `searchRules()` | `response.nbHits < params.hitsPerPage` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `browseSynonyms` | Given an `indexName` and the same parameters as the `searchSynonyms` method, aggregates all the `synonyms` returned by the API calls in a single `searchSynonyms` response object | `searchSynonyms()` | `response.nbHits < params.hitsPerPage` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `searchForHits<T>` | Given the same parameters as the `search` method, returns the API response with the certainty that it will only contain `hits` by casting it to a generic `SearchResponse<T>` object | `search()` | `none` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `searchForFacets` | Given the same parameters as the `search` method, returns the API response with the certainty that it will only contain `facets` by casting it to a `SearchForFacetValuesResponse` object | `search()` | `none` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `replaceAllObjects` | Given an `indexName` and an array of `objects`, replace all objects in this index using a temporary one | `operationIndex(), chunkedBatch()` | `none` | [PHP](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-php/lib/Api/SearchClient.php) |
| `generateSecuredApiKey` | Given a `indexName` and an array of `restrictions`, generates a secured API Key using the SHA-256 algorithm | `none` | `none` | [PHP](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-php/lib/Api/SearchClient.php) |
| `chunkedBatch` | Creates chunks of `objects` in order to make them fit in multiple `batch` requests | `none` | `none` | [PHP](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-php/lib/Api/SearchClient.php) |
| Helper name | Description | Wrapped API call | Stop condition | Example |
|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `waitForTask` | Given a `taskID`, calls the `getTask` method until the status gets `published` | `getTask()` | `response.status == "published"` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `waitForAppTask` | Given a `taskID`, calls the `getAppTask` method until the status gets `published` | `getAppTask()` | `response.status == "published"` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `waitForApiKey` | Given a `Key`, calls the `getApiKey` method until the stop condition for the given `operation` is validated | `getApiKey()` | Diff between the given `Key` and the `response` payload | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `browseObjects<T>` | Given an `indexName` and the same parameters as the `browse` method, aggregates all the `objects` returned by the API calls in a single `browse` response object | `browse()` | `response.cursor == null` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `browseRules` | Given an `indexName` and the same parameters as the `searchRules` method, aggregates all the `rules` returned by the API calls in a single `searchRules` response object | `searchRules()` | `response.nbHits < params.hitsPerPage` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `browseSynonyms` | Given an `indexName` and the same parameters as the `searchSynonyms` method, aggregates all the `synonyms` returned by the API calls in a single `searchSynonyms` response object | `searchSynonyms()` | `response.nbHits < params.hitsPerPage` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `searchForHits<T>` | Given the same parameters as the `search` method, returns the API response with the certainty that it will only contain `hits` by casting it to a generic `SearchResponse<T>` object | `search()` | `none` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `searchForFacets` | Given the same parameters as the `search` method, returns the API response with the certainty that it will only contain `facets` by casting it to a `SearchForFacetValuesResponse` object | `search()` | `none` | [JavaScript](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts) |
| `replaceAllObjects` | Given an `indexName` and an array of `objects`, replace all objects in this index using a temporary one | `operationIndex(), batch()` | `none` | [PHP](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-php/lib/Api/SearchClient.php) |
| `generateSecuredApiKey` | Given an `indexName` and an array of `restrictions`, generates a secured API Key using the SHA-256 algorithm | `none` | `none` | [PHP](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-php/lib/Api/SearchClient.php) |
| `chunkedBatch` | Creates chunks of `objects` in order to make them fit in multiple `batch` requests | `batch()` | `none` | [PHP](https://github.com/algolia/api-clients-automation/blob/main/clients/algoliasearch-client-php/lib/Api/SearchClient.php) |
| `saveObjects` | Saves the given array of objects in the given index. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it. | `batch()` | `none` | [Go](https://github.com/algolia/api-clients-automation/blob/main/templates/go/search_helpers.mustache) |
| `deleteObjects` | Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it. | `batch()` | `none` | [Go](https://github.com/algolia/api-clients-automation/blob/main/templates/go/search_helpers.mustache) |
| `partialUpdateObjects` | Replaces object content of all the given objects according to their respective `objectID` field. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it. | `batch()` | `none` | [Go](https://github.com/algolia/api-clients-automation/blob/main/templates/go/search_helpers.mustache) |

### `replaceAllObjects`

Expand Down

1 comment on commit f160d6f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.