From 96e59ec8e90e65b90980c9c2355783b7fdf913d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Fri, 25 Feb 2022 13:59:17 +0100 Subject: [PATCH 1/5] feat(spec): add customRequest methods --- .../com/algolia/model/BatchOperation.java | 92 +++ .../com/algolia/model/BatchParams.java | 10 +- .../com/algolia/model/BatchWriteParams.java | 10 +- ...ation.java => MultipleBatchOperation.java} | 20 +- .../com/algolia/search/SearchApi.java | 622 +++++++++++++--- .../com/algolia/utils/echo/EchoResponse.java | 108 +++ .../client-abtesting/src/abtestingApi.ts | 216 +++++- .../client-analytics/src/analyticsApi.ts | 264 ++++++- .../client-insights/src/insightsApi.ts | 205 +++++- .../src/personalizationApi.ts | 212 +++++- .../packages/client-predict/src/predictApi.ts | 205 +++++- .../src/querySuggestionsApi.ts | 224 +++++- .../client-search/model/batchOperation.ts | 9 + .../client-search/model/batchParams.ts | 4 +- .../client-search/model/batchWriteParams.ts | 4 +- ...operation.ts => multipleBatchOperation.ts} | 2 +- .../packages/client-search/src/searchApi.ts | 424 ++++++++--- .../packages/client-sources/src/sourcesApi.ts | 205 +++++- .../packages/recommend/src/recommendApi.ts | 205 +++++- .../lib/Api/AbtestingApi.php | 144 ++++ .../lib/Api/AnalyticsApi.php | 144 ++++ .../lib/Api/InsightsApi.php | 145 ++++ .../lib/Api/PersonalizationApi.php | 144 ++++ .../lib/Api/QuerySuggestionsApi.php | 144 ++++ .../lib/Api/RecommendApi.php | 145 ++++ .../lib/Api/SearchApi.php | 144 ++++ scripts/buildSpecs.ts | 58 +- scripts/pre-gen/setHostsOptions.ts | 15 +- specs/abtesting/paths/abtest.yml | 4 - specs/abtesting/paths/abtests.yml | 4 - specs/abtesting/paths/stopABTest.yml | 2 - specs/abtesting/spec.yml | 9 + .../paths/click/getAverageClickPosition.yml | 2 - .../paths/click/getClickPositions.yml | 2 - .../paths/click/getClickThroughRate.yml | 2 - .../paths/click/getConversionRate.yml | 2 - .../analytics/paths/search/getNoClickRate.yml | 2 - .../paths/search/getNoResultsRate.yml | 2 - .../paths/search/getSearchesCount.yml | 2 - .../paths/search/getSearchesNoClicks.yml | 2 - .../paths/search/getSearchesNoResults.yml | 2 - .../paths/search/getTopCountries.yml | 2 - .../paths/search/getTopFilterAttributes.yml | 2 - .../paths/search/getTopFilterForAttribute.yml | 2 - .../paths/search/getTopFiltersNoResults.yml | 2 - specs/analytics/paths/search/getTopHits.yml | 2 - .../analytics/paths/search/getTopSearches.yml | 2 - .../analytics/paths/search/getUsersCount.yml | 2 - specs/analytics/paths/status/getStatus.yml | 2 - specs/analytics/spec.yml | 9 + specs/bundled/abtesting.yml | 234 +++++- specs/bundled/analytics.yml | 430 +++++++---- specs/bundled/insights.yml | 162 ++++- specs/bundled/personalization.yml | 200 +++++- specs/bundled/predict.yml | 204 +++++- specs/bundled/query-suggestions.yml | 224 +++++- specs/bundled/recommend.yml | 178 ++++- specs/bundled/search.yml | 678 +++++++++++------- specs/bundled/sources.yml | 196 ++++- specs/common/paths/customRequest.yml | 15 + specs/common/schemas/CustomRequest.yml | 31 + specs/insights/paths/pushEvents.yml | 2 - specs/insights/spec.yml | 9 + .../paths/deleteUserProfile.yml | 2 - .../paths/getUserTokenProfile.yml | 2 - .../paths/personalizationStrategy.yml | 2 - specs/personalization/spec.yml | 9 + specs/predict/paths/fetchUserProfile.yml | 2 - specs/predict/spec.yml | 9 + .../paths/getConfigurationStatus.yml | 2 - specs/query-suggestions/paths/getLogFile.yml | 2 - specs/query-suggestions/paths/qsConfig.yml | 2 - specs/query-suggestions/paths/qsConfigs.yml | 2 - specs/query-suggestions/spec.yml | 9 + specs/recommend/paths/getRecommendations.yml | 2 - specs/recommend/spec.yml | 9 + specs/search/paths/advanced/getLogs.yml | 2 - specs/search/paths/advanced/getTask.yml | 2 - .../dictionaries/batchDictionaryEntries.yml | 2 - .../paths/dictionaries/dictionarySettings.yml | 4 - .../dictionaries/getDictionaryLanguages.yml | 2 - .../dictionaries/searchDictionaryEntries.yml | 2 - specs/search/paths/keys/key.yml | 6 - specs/search/paths/keys/keys.yml | 4 - specs/search/paths/keys/restoreApiKey.yml | 2 - .../paths/manage_indices/listIndices.yml | 2 - .../paths/manage_indices/operationIndex.yml | 2 - .../multiclusters/batchAssignUserIds.yml | 2 - .../paths/multiclusters/getTopUserIds.yml | 2 - .../multiclusters/hasPendingMappings.yml | 2 - .../paths/multiclusters/listClusters.yml | 2 - .../paths/multiclusters/searchUserIds.yml | 2 - specs/search/paths/multiclusters/userId.yml | 4 - specs/search/paths/multiclusters/userIds.yml | 4 - specs/search/paths/objects/batch.yml | 4 +- specs/search/paths/objects/clearObjects.yml | 2 - specs/search/paths/objects/deleteBy.yml | 2 - specs/search/paths/objects/multipleBatch.yml | 4 +- .../paths/objects/multipleGetObjects.yml | 2 - specs/search/paths/objects/object.yml | 6 - specs/search/paths/objects/objects.yml | 6 +- specs/search/paths/objects/partialUpdate.yml | 2 - specs/search/paths/rules/batchRules.yml | 2 - specs/search/paths/rules/clearRules.yml | 2 - specs/search/paths/rules/rule.yml | 6 - specs/search/paths/rules/searchRules.yml | 2 - specs/search/paths/search/browse.yml | 2 - specs/search/paths/search/multipleQueries.yml | 2 - specs/search/paths/search/search.yml | 2 - .../paths/search/searchForFacetValues.yml | 2 - specs/search/paths/settings/settings.yml | 4 - specs/search/paths/synonyms/batchSynonyms.yml | 2 - .../paths/synonyms/clearAllSynonyms.yml | 2 - .../search/paths/synonyms/searchSynonyms.yml | 2 - specs/search/paths/synonyms/synonym.yml | 6 - specs/search/paths/vault/appendSource.yml | 2 - specs/search/paths/vault/deleteSource.yml | 2 - specs/search/paths/vault/vaultSources.yml | 2 - specs/search/spec.yml | 9 + specs/sources/paths/ingest/postUrl.yml | 2 - specs/sources/spec.yml | 9 + .../java/libraries/okhttp-gson/api.mustache | 4 +- templates/javascript/api-single.mustache | 4 +- tests/CTS/methods/requests/search/batch.json | 8 +- .../requests/search/multipleBatch.json | 2 +- .../requests/search/partialUpdateObject.json | 18 +- .../algolia/methods/requests/search.test.java | 34 +- .../src/methods/requests/search.test.ts | 22 +- 128 files changed, 5957 insertions(+), 1076 deletions(-) create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchOperation.java rename clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/{Operation.java => MultipleBatchOperation.java} (78%) create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/batchOperation.ts rename clients/algoliasearch-client-javascript/packages/client-search/model/{operation.ts => multipleBatchOperation.ts} (86%) create mode 100644 specs/common/paths/customRequest.yml create mode 100644 specs/common/schemas/CustomRequest.yml diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchOperation.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchOperation.java new file mode 100644 index 0000000000..85682a94ac --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchOperation.java @@ -0,0 +1,92 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import java.util.Objects; + +/** BatchOperation */ +public class BatchOperation { + + @SerializedName("action") + private Action action; + + @SerializedName("body") + private Object body; + + public BatchOperation action(Action action) { + this.action = action; + return this; + } + + /** + * Get action + * + * @return action + */ + @javax.annotation.Nullable + public Action getAction() { + return action; + } + + public void setAction(Action action) { + this.action = action; + } + + public BatchOperation body(Object body) { + this.body = body; + return this; + } + + /** + * arguments to the operation (depends on the type of the operation). + * + * @return body + */ + @javax.annotation.Nullable + public Object getBody() { + return body; + } + + public void setBody(Object body) { + this.body = body; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BatchOperation batchOperation = (BatchOperation) o; + return ( + Objects.equals(this.action, batchOperation.action) && + Objects.equals(this.body, batchOperation.body) + ); + } + + @Override + public int hashCode() { + return Objects.hash(action, body); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BatchOperation {\n"); + sb.append(" action: ").append(toIndentedString(action)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchParams.java index eaff3a9760..40486b162c 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchParams.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchParams.java @@ -9,14 +9,14 @@ public class BatchParams { @SerializedName("requests") - private List requests = null; + private List requests = null; - public BatchParams requests(List requests) { + public BatchParams requests(List requests) { this.requests = requests; return this; } - public BatchParams addRequestsItem(Operation requestsItem) { + public BatchParams addRequestsItem(MultipleBatchOperation requestsItem) { if (this.requests == null) { this.requests = new ArrayList<>(); } @@ -30,11 +30,11 @@ public BatchParams addRequestsItem(Operation requestsItem) { * @return requests */ @javax.annotation.Nullable - public List getRequests() { + public List getRequests() { return requests; } - public void setRequests(List requests) { + public void setRequests(List requests) { this.requests = requests; } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchWriteParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchWriteParams.java index 3eace6978b..020e1f9a45 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchWriteParams.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchWriteParams.java @@ -9,14 +9,14 @@ public class BatchWriteParams { @SerializedName("requests") - private List requests = null; + private List requests = null; - public BatchWriteParams requests(List requests) { + public BatchWriteParams requests(List requests) { this.requests = requests; return this; } - public BatchWriteParams addRequestsItem(Operation requestsItem) { + public BatchWriteParams addRequestsItem(BatchOperation requestsItem) { if (this.requests == null) { this.requests = new ArrayList<>(); } @@ -30,11 +30,11 @@ public BatchWriteParams addRequestsItem(Operation requestsItem) { * @return requests */ @javax.annotation.Nullable - public List getRequests() { + public List getRequests() { return requests; } - public void setRequests(List requests) { + public void setRequests(List requests) { this.requests = requests; } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/Operation.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/MultipleBatchOperation.java similarity index 78% rename from clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/Operation.java rename to clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/MultipleBatchOperation.java index 1b7ee98d67..a5c54777ef 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/Operation.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/MultipleBatchOperation.java @@ -3,8 +3,8 @@ import com.google.gson.annotations.SerializedName; import java.util.Objects; -/** Operation */ -public class Operation { +/** MultipleBatchOperation */ +public class MultipleBatchOperation { @SerializedName("action") private Action action; @@ -15,7 +15,7 @@ public class Operation { @SerializedName("indexName") private String indexName; - public Operation action(Action action) { + public MultipleBatchOperation action(Action action) { this.action = action; return this; } @@ -34,7 +34,7 @@ public void setAction(Action action) { this.action = action; } - public Operation body(Object body) { + public MultipleBatchOperation body(Object body) { this.body = body; return this; } @@ -53,7 +53,7 @@ public void setBody(Object body) { this.body = body; } - public Operation indexName(String indexName) { + public MultipleBatchOperation indexName(String indexName) { this.indexName = indexName; return this; } @@ -80,11 +80,11 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - Operation operation = (Operation) o; + MultipleBatchOperation multipleBatchOperation = (MultipleBatchOperation) o; return ( - Objects.equals(this.action, operation.action) && - Objects.equals(this.body, operation.body) && - Objects.equals(this.indexName, operation.indexName) + Objects.equals(this.action, multipleBatchOperation.action) && + Objects.equals(this.body, multipleBatchOperation.body) && + Objects.equals(this.indexName, multipleBatchOperation.indexName) ); } @@ -96,7 +96,7 @@ public int hashCode() { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class Operation {\n"); + sb.append("class MultipleBatchOperation {\n"); sb.append(" action: ").append(toIndentedString(action)).append("\n"); sb.append(" body: ").append(toIndentedString(body)).append("\n"); sb diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java index 4c9f5f528b..46bbf58e95 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java @@ -40,7 +40,7 @@ private Call addApiKeyCall( Object bodyObj = apiKey; // create path and map variables - String path = "/1/keys"; + String requestPath = "/1/keys"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -49,7 +49,7 @@ private Call addApiKeyCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -125,7 +125,7 @@ private Call addOrUpdateObjectCall( Object bodyObj = body; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/{objectID}".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -142,7 +142,7 @@ private Call addOrUpdateObjectCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "PUT", queryParams, bodyObj, @@ -257,7 +257,7 @@ private Call appendSourceCall( Object bodyObj = source; // create path and map variables - String path = "/1/security/sources/append"; + String requestPath = "/1/security/sources/append"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -266,7 +266,7 @@ private Call appendSourceCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -341,7 +341,7 @@ private Call assignUserIdCall( Object bodyObj = assignUserIdParams; // create path and map variables - String path = "/1/clusters/mapping"; + String requestPath = "/1/clusters/mapping"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -356,7 +356,7 @@ private Call assignUserIdCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -459,7 +459,7 @@ private Call batchCall( Object bodyObj = batchWriteParams; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/batch".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -472,7 +472,7 @@ private Call batchCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -561,7 +561,7 @@ private Call batchAssignUserIdsCall( Object bodyObj = batchAssignUserIdsParams; // create path and map variables - String path = "/1/clusters/mapping/batch"; + String requestPath = "/1/clusters/mapping/batch"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -576,7 +576,7 @@ private Call batchAssignUserIdsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -682,7 +682,7 @@ private Call batchDictionaryEntriesCall( Object bodyObj = batchDictionaryEntriesParams; // create path and map variables - String path = + String requestPath = "/1/dictionaries/{dictionaryName}/batch".replaceAll( "\\{" + "dictionaryName" + "\\}", this.escapeString(dictionaryName.toString()) @@ -695,7 +695,7 @@ private Call batchDictionaryEntriesCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -802,7 +802,7 @@ private Call batchRulesCall( Object bodyObj = rule; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/rules/batch".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -827,7 +827,7 @@ private Call batchRulesCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -953,7 +953,7 @@ private Call browseCall( Object bodyObj = browseRequest; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/browse".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -966,7 +966,7 @@ private Call browseCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -1061,7 +1061,7 @@ private Call clearAllSynonymsCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/synonyms/clear".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -1080,7 +1080,7 @@ private Call clearAllSynonymsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -1176,7 +1176,7 @@ private Call clearObjectsCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/clear".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -1189,7 +1189,7 @@ private Call clearObjectsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -1265,7 +1265,7 @@ private Call clearRulesCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/rules/clear".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -1284,7 +1284,7 @@ private Call clearRulesCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -1375,7 +1375,7 @@ private Call deleteApiKeyCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/keys/{key}".replaceAll( "\\{" + "key" + "\\}", this.escapeString(key.toString()) @@ -1388,7 +1388,7 @@ private Call deleteApiKeyCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "DELETE", queryParams, bodyObj, @@ -1463,7 +1463,7 @@ private Call deleteByCall( Object bodyObj = searchParams; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/deleteByQuery".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -1476,7 +1476,7 @@ private Call deleteByCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -1554,6 +1554,105 @@ public Call deleteByAsync( return call; } + /** + * Build call for deleteCustomRequest + * + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + private Call deleteCustomRequestCall( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + Object bodyObj = body; + + // create path and map variables + String requestPath = + "/1{path}".replaceAll( + "\\{" + "path" + "\\}", + this.escapeString(path.toString()) + ); + + List queryParams = new ArrayList(); + Map headers = new HashMap(); + + headers.put("Accept", "application/json"); + headers.put("Content-Type", "application/json"); + + return this.buildCall( + requestPath, + "DELETE", + queryParams, + bodyObj, + headers, + _callback + ); + } + + private Call deleteCustomRequestValidateBeforeCall( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'path' is set + if (path == null) { + throw new ApiException( + "Missing the required parameter 'path' when calling deleteCustomRequest(Async)" + ); + } + + return deleteCustomRequestCall(path, body, _callback); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @param path The path of the API endpoint to target, anything after the /1 needs to be + * specified. (required) + * @param body The parameters to send with the custom request. (optional) + * @return Object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + */ + public Object deleteCustomRequest(String path, Object body) + throws ApiException { + Call req = deleteCustomRequestValidateBeforeCall(path, body, null); + if (req instanceof CallEcho) { + return new EchoResponse.DeleteCustomRequest(((CallEcho) req).request()); + } + Call call = (Call) req; + Type returnType = new TypeToken() {}.getType(); + ApiResponse res = this.execute(call, returnType); + return res.getData(); + } + + public Object deleteCustomRequest(String path) throws ApiException { + return this.deleteCustomRequest(path, null); + } + + /** + * (asynchronously) The customRequest method allow you to send requests to the Algolia REST API. + * + * @param path The path of the API endpoint to target, anything after the /1 needs to be + * specified. (required) + * @param body The parameters to send with the custom request. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public Call deleteCustomRequestAsync( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + Call call = deleteCustomRequestValidateBeforeCall(path, body, _callback); + Type returnType = new TypeToken() {}.getType(); + this.executeAsync(call, returnType, _callback); + return call; + } + /** * Build call for deleteIndex * @@ -1568,7 +1667,7 @@ private Call deleteIndexCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -1581,7 +1680,7 @@ private Call deleteIndexCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "DELETE", queryParams, bodyObj, @@ -1656,7 +1755,7 @@ private Call deleteObjectCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/{objectID}".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -1673,7 +1772,7 @@ private Call deleteObjectCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "DELETE", queryParams, bodyObj, @@ -1761,7 +1860,7 @@ private Call deleteRuleCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/rules/{objectID}".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -1784,7 +1883,7 @@ private Call deleteRuleCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "DELETE", queryParams, bodyObj, @@ -1894,7 +1993,7 @@ private Call deleteSourceCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/security/sources/{source}".replaceAll( "\\{" + "source" + "\\}", this.escapeString(source.toString()) @@ -1907,7 +2006,7 @@ private Call deleteSourceCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "DELETE", queryParams, bodyObj, @@ -1983,7 +2082,7 @@ private Call deleteSynonymCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -2006,7 +2105,7 @@ private Call deleteSynonymCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "DELETE", queryParams, bodyObj, @@ -2114,7 +2213,7 @@ private Call getApiKeyCall(String key, final ApiCallback _callback) Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/keys/{key}".replaceAll( "\\{" + "key" + "\\}", this.escapeString(key.toString()) @@ -2127,7 +2226,7 @@ private Call getApiKeyCall(String key, final ApiCallback _callback) headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -2185,6 +2284,104 @@ public Call getApiKeyAsync(String key, final ApiCallback _callback) return call; } + /** + * Build call for getCustomRequest + * + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + private Call getCustomRequestCall( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + Object bodyObj = body; + + // create path and map variables + String requestPath = + "/1{path}".replaceAll( + "\\{" + "path" + "\\}", + this.escapeString(path.toString()) + ); + + List queryParams = new ArrayList(); + Map headers = new HashMap(); + + headers.put("Accept", "application/json"); + headers.put("Content-Type", "application/json"); + + return this.buildCall( + requestPath, + "GET", + queryParams, + bodyObj, + headers, + _callback + ); + } + + private Call getCustomRequestValidateBeforeCall( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'path' is set + if (path == null) { + throw new ApiException( + "Missing the required parameter 'path' when calling getCustomRequest(Async)" + ); + } + + return getCustomRequestCall(path, body, _callback); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @param path The path of the API endpoint to target, anything after the /1 needs to be + * specified. (required) + * @param body The parameters to send with the custom request. (optional) + * @return Object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + */ + public Object getCustomRequest(String path, Object body) throws ApiException { + Call req = getCustomRequestValidateBeforeCall(path, body, null); + if (req instanceof CallEcho) { + return new EchoResponse.GetCustomRequest(((CallEcho) req).request()); + } + Call call = (Call) req; + Type returnType = new TypeToken() {}.getType(); + ApiResponse res = this.execute(call, returnType); + return res.getData(); + } + + public Object getCustomRequest(String path) throws ApiException { + return this.getCustomRequest(path, null); + } + + /** + * (asynchronously) The customRequest method allow you to send requests to the Algolia REST API. + * + * @param path The path of the API endpoint to target, anything after the /1 needs to be + * specified. (required) + * @param body The parameters to send with the custom request. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public Call getCustomRequestAsync( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + Call call = getCustomRequestValidateBeforeCall(path, body, _callback); + Type returnType = new TypeToken() {}.getType(); + this.executeAsync(call, returnType, _callback); + return call; + } + /** * Build call for getDictionaryLanguages * @@ -2198,7 +2395,7 @@ private Call getDictionaryLanguagesCall( Object bodyObj = null; // create path and map variables - String path = "/1/dictionaries/*/languages"; + String requestPath = "/1/dictionaries/*/languages"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -2207,7 +2404,7 @@ private Call getDictionaryLanguagesCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -2271,7 +2468,7 @@ private Call getDictionarySettingsCall( Object bodyObj = null; // create path and map variables - String path = "/1/dictionaries/*/settings"; + String requestPath = "/1/dictionaries/*/settings"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -2280,7 +2477,7 @@ private Call getDictionarySettingsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -2350,7 +2547,7 @@ private Call getLogsCall( Object bodyObj = null; // create path and map variables - String path = "/1/logs"; + String requestPath = "/1/logs"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -2375,7 +2572,7 @@ private Call getLogsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -2479,7 +2676,7 @@ private Call getObjectCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/{objectID}".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -2502,7 +2699,7 @@ private Call getObjectCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -2612,7 +2809,7 @@ private Call getObjectsCall( Object bodyObj = getObjectsParams; // create path and map variables - String path = "/1/indexes/*/objects"; + String requestPath = "/1/indexes/*/objects"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -2621,7 +2818,7 @@ private Call getObjectsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -2698,7 +2895,7 @@ private Call getRuleCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/rules/{objectID}".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -2715,7 +2912,7 @@ private Call getRuleCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -2800,7 +2997,7 @@ private Call getSettingsCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/settings".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -2813,7 +3010,7 @@ private Call getSettingsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -2885,7 +3082,7 @@ private Call getSourcesCall(final ApiCallback> _callback) Object bodyObj = null; // create path and map variables - String path = "/1/security/sources"; + String requestPath = "/1/security/sources"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -2894,7 +3091,7 @@ private Call getSourcesCall(final ApiCallback> _callback) headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -2957,7 +3154,7 @@ private Call getSynonymCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -2974,7 +3171,7 @@ private Call getSynonymCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -3061,7 +3258,7 @@ private Call getTaskCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/task/{taskID}".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -3078,7 +3275,7 @@ private Call getTaskCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -3163,7 +3360,7 @@ private Call getTopUserIdsCall( Object bodyObj = null; // create path and map variables - String path = "/1/clusters/mapping/top"; + String requestPath = "/1/clusters/mapping/top"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -3172,7 +3369,7 @@ private Call getTopUserIdsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -3241,7 +3438,7 @@ private Call getUserIdCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/clusters/mapping/{userID}".replaceAll( "\\{" + "userID" + "\\}", this.escapeString(userID.toString()) @@ -3254,7 +3451,7 @@ private Call getUserIdCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -3334,7 +3531,7 @@ private Call hasPendingMappingsCall( Object bodyObj = null; // create path and map variables - String path = "/1/clusters/mapping/pending"; + String requestPath = "/1/clusters/mapping/pending"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -3347,7 +3544,7 @@ private Call hasPendingMappingsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -3426,7 +3623,7 @@ private Call listApiKeysCall( Object bodyObj = null; // create path and map variables - String path = "/1/keys"; + String requestPath = "/1/keys"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -3435,7 +3632,7 @@ private Call listApiKeysCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -3497,7 +3694,7 @@ private Call listClustersCall( Object bodyObj = null; // create path and map variables - String path = "/1/clusters"; + String requestPath = "/1/clusters"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -3506,7 +3703,7 @@ private Call listClustersCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -3571,7 +3768,7 @@ private Call listIndicesCall( Object bodyObj = null; // create path and map variables - String path = "/1/indexes"; + String requestPath = "/1/indexes"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -3584,7 +3781,7 @@ private Call listIndicesCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -3660,7 +3857,7 @@ private Call listUserIdsCall( Object bodyObj = null; // create path and map variables - String path = "/1/clusters/mapping"; + String requestPath = "/1/clusters/mapping"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -3677,7 +3874,7 @@ private Call listUserIdsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "GET", queryParams, bodyObj, @@ -3763,7 +3960,7 @@ private Call multipleBatchCall( Object bodyObj = batchParams; // create path and map variables - String path = "/1/indexes/*/batch"; + String requestPath = "/1/indexes/*/batch"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -3772,7 +3969,7 @@ private Call multipleBatchCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -3849,7 +4046,7 @@ private Call multipleQueriesCall( Object bodyObj = multipleQueriesParams; // create path and map variables - String path = "/1/indexes/*/queries"; + String requestPath = "/1/indexes/*/queries"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -3858,7 +4055,7 @@ private Call multipleQueriesCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -3939,7 +4136,7 @@ private Call operationIndexCall( Object bodyObj = operationIndexParams; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/operation".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -3952,7 +4149,7 @@ private Call operationIndexCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -4052,7 +4249,7 @@ private Call partialUpdateObjectCall( Object bodyObj = oneOfstringbuiltInOperation; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/{objectID}/partial".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -4075,7 +4272,7 @@ private Call partialUpdateObjectCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -4209,6 +4406,203 @@ public Call partialUpdateObjectAsync( return call; } + /** + * Build call for postCustomRequest + * + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + private Call postCustomRequestCall( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + Object bodyObj = body; + + // create path and map variables + String requestPath = + "/1{path}".replaceAll( + "\\{" + "path" + "\\}", + this.escapeString(path.toString()) + ); + + List queryParams = new ArrayList(); + Map headers = new HashMap(); + + headers.put("Accept", "application/json"); + headers.put("Content-Type", "application/json"); + + return this.buildCall( + requestPath, + "POST", + queryParams, + bodyObj, + headers, + _callback + ); + } + + private Call postCustomRequestValidateBeforeCall( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'path' is set + if (path == null) { + throw new ApiException( + "Missing the required parameter 'path' when calling postCustomRequest(Async)" + ); + } + + return postCustomRequestCall(path, body, _callback); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @param path The path of the API endpoint to target, anything after the /1 needs to be + * specified. (required) + * @param body The parameters to send with the custom request. (optional) + * @return Object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + */ + public Object postCustomRequest(String path, Object body) + throws ApiException { + Call req = postCustomRequestValidateBeforeCall(path, body, null); + if (req instanceof CallEcho) { + return new EchoResponse.PostCustomRequest(((CallEcho) req).request()); + } + Call call = (Call) req; + Type returnType = new TypeToken() {}.getType(); + ApiResponse res = this.execute(call, returnType); + return res.getData(); + } + + public Object postCustomRequest(String path) throws ApiException { + return this.postCustomRequest(path, null); + } + + /** + * (asynchronously) The customRequest method allow you to send requests to the Algolia REST API. + * + * @param path The path of the API endpoint to target, anything after the /1 needs to be + * specified. (required) + * @param body The parameters to send with the custom request. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public Call postCustomRequestAsync( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + Call call = postCustomRequestValidateBeforeCall(path, body, _callback); + Type returnType = new TypeToken() {}.getType(); + this.executeAsync(call, returnType, _callback); + return call; + } + + /** + * Build call for putCustomRequest + * + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + private Call putCustomRequestCall( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + Object bodyObj = body; + + // create path and map variables + String requestPath = + "/1{path}".replaceAll( + "\\{" + "path" + "\\}", + this.escapeString(path.toString()) + ); + + List queryParams = new ArrayList(); + Map headers = new HashMap(); + + headers.put("Accept", "application/json"); + headers.put("Content-Type", "application/json"); + + return this.buildCall( + requestPath, + "PUT", + queryParams, + bodyObj, + headers, + _callback + ); + } + + private Call putCustomRequestValidateBeforeCall( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'path' is set + if (path == null) { + throw new ApiException( + "Missing the required parameter 'path' when calling putCustomRequest(Async)" + ); + } + + return putCustomRequestCall(path, body, _callback); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @param path The path of the API endpoint to target, anything after the /1 needs to be + * specified. (required) + * @param body The parameters to send with the custom request. (optional) + * @return Object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + */ + public Object putCustomRequest(String path, Object body) throws ApiException { + Call req = putCustomRequestValidateBeforeCall(path, body, null); + if (req instanceof CallEcho) { + return new EchoResponse.PutCustomRequest(((CallEcho) req).request()); + } + Call call = (Call) req; + Type returnType = new TypeToken() {}.getType(); + ApiResponse res = this.execute(call, returnType); + return res.getData(); + } + + public Object putCustomRequest(String path) throws ApiException { + return this.putCustomRequest(path, null); + } + + /** + * (asynchronously) The customRequest method allow you to send requests to the Algolia REST API. + * + * @param path The path of the API endpoint to target, anything after the /1 needs to be + * specified. (required) + * @param body The parameters to send with the custom request. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public Call putCustomRequestAsync( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + Call call = putCustomRequestValidateBeforeCall(path, body, _callback); + Type returnType = new TypeToken() {}.getType(); + this.executeAsync(call, returnType, _callback); + return call; + } + /** * Build call for removeUserId * @@ -4223,7 +4617,7 @@ private Call removeUserIdCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/clusters/mapping/{userID}".replaceAll( "\\{" + "userID" + "\\}", this.escapeString(userID.toString()) @@ -4236,7 +4630,7 @@ private Call removeUserIdCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "DELETE", queryParams, bodyObj, @@ -4312,7 +4706,7 @@ private Call replaceSourcesCall( Object bodyObj = source; // create path and map variables - String path = "/1/security/sources"; + String requestPath = "/1/security/sources"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -4321,7 +4715,7 @@ private Call replaceSourcesCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "PUT", queryParams, bodyObj, @@ -4396,7 +4790,7 @@ private Call restoreApiKeyCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/keys/{key}/restore".replaceAll( "\\{" + "key" + "\\}", this.escapeString(key.toString()) @@ -4409,7 +4803,7 @@ private Call restoreApiKeyCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -4484,7 +4878,7 @@ private Call saveObjectCall( Object bodyObj = body; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -4497,7 +4891,7 @@ private Call saveObjectCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -4586,7 +4980,7 @@ private Call saveRuleCall( Object bodyObj = rule; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/rules/{objectID}".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -4609,7 +5003,7 @@ private Call saveRuleCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "PUT", queryParams, bodyObj, @@ -4745,7 +5139,7 @@ private Call saveSynonymCall( Object bodyObj = synonymHit; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -4768,7 +5162,7 @@ private Call saveSynonymCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "PUT", queryParams, bodyObj, @@ -4905,7 +5299,7 @@ private Call saveSynonymsCall( Object bodyObj = synonymHit; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/synonyms/batch".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -4930,7 +5324,7 @@ private Call saveSynonymsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -5060,7 +5454,7 @@ private Call searchCall( Object bodyObj = searchParams; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/query".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -5073,7 +5467,7 @@ private Call searchCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -5160,7 +5554,7 @@ private Call searchDictionaryEntriesCall( Object bodyObj = searchDictionaryEntriesParams; // create path and map variables - String path = + String requestPath = "/1/dictionaries/{dictionaryName}/search".replaceAll( "\\{" + "dictionaryName" + "\\}", this.escapeString(dictionaryName.toString()) @@ -5173,7 +5567,7 @@ private Call searchDictionaryEntriesCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -5279,7 +5673,7 @@ private Call searchForFacetValuesCall( Object bodyObj = searchForFacetValuesRequest; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/facets/{facetName}/query".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -5296,7 +5690,7 @@ private Call searchForFacetValuesCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -5417,7 +5811,7 @@ private Call searchRulesCall( Object bodyObj = searchRulesParams; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/rules/search".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -5430,7 +5824,7 @@ private Call searchRulesCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -5530,7 +5924,7 @@ private Call searchSynonymsCall( Object bodyObj = null; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/synonyms/search".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -5559,7 +5953,7 @@ private Call searchSynonymsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -5685,7 +6079,7 @@ private Call searchUserIdsCall( Object bodyObj = searchUserIdsParams; // create path and map variables - String path = "/1/clusters/mapping/search"; + String requestPath = "/1/clusters/mapping/search"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -5694,7 +6088,7 @@ private Call searchUserIdsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "POST", queryParams, bodyObj, @@ -5782,7 +6176,7 @@ private Call setDictionarySettingsCall( Object bodyObj = dictionarySettingsParams; // create path and map variables - String path = "/1/dictionaries/*/settings"; + String requestPath = "/1/dictionaries/*/settings"; List queryParams = new ArrayList(); Map headers = new HashMap(); @@ -5791,7 +6185,7 @@ private Call setDictionarySettingsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "PUT", queryParams, bodyObj, @@ -5876,7 +6270,7 @@ private Call setSettingsCall( Object bodyObj = indexSettings; // create path and map variables - String path = + String requestPath = "/1/indexes/{indexName}/settings".replaceAll( "\\{" + "indexName" + "\\}", this.escapeString(indexName.toString()) @@ -5895,7 +6289,7 @@ private Call setSettingsCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "PUT", queryParams, bodyObj, @@ -6016,7 +6410,7 @@ private Call updateApiKeyCall( Object bodyObj = apiKey; // create path and map variables - String path = + String requestPath = "/1/keys/{key}".replaceAll( "\\{" + "key" + "\\}", this.escapeString(key.toString()) @@ -6029,7 +6423,7 @@ private Call updateApiKeyCall( headers.put("Content-Type", "application/json"); return this.buildCall( - path, + requestPath, "PUT", queryParams, bodyObj, diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/echo/EchoResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/echo/EchoResponse.java index c9e9b4e64e..e861a74ee3 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/echo/EchoResponse.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/echo/EchoResponse.java @@ -412,6 +412,33 @@ public List getQueryParams() { } } + public static class DeleteCustomRequest + extends Object + implements EchoResponseInterface { + + private Request request; + + public DeleteCustomRequest(Request request) { + this.request = request; + } + + public String getPath() { + return request.url().encodedPath(); + } + + public String getMethod() { + return request.method(); + } + + public String getBody() { + return parseRequestBody(request); + } + + public List getQueryParams() { + return buildQueryParams(request); + } + } + public static class DeleteIndex extends DeletedAtResponse implements EchoResponseInterface { @@ -572,6 +599,33 @@ public List getQueryParams() { } } + public static class GetCustomRequest + extends Object + implements EchoResponseInterface { + + private Request request; + + public GetCustomRequest(Request request) { + this.request = request; + } + + public String getPath() { + return request.url().encodedPath(); + } + + public String getMethod() { + return request.method(); + } + + public String getBody() { + return parseRequestBody(request); + } + + public List getQueryParams() { + return buildQueryParams(request); + } + } + public static class GetDictionaryLanguages extends HashMap implements EchoResponseInterface { @@ -1137,6 +1191,60 @@ public List getQueryParams() { } } + public static class PostCustomRequest + extends Object + implements EchoResponseInterface { + + private Request request; + + public PostCustomRequest(Request request) { + this.request = request; + } + + public String getPath() { + return request.url().encodedPath(); + } + + public String getMethod() { + return request.method(); + } + + public String getBody() { + return parseRequestBody(request); + } + + public List getQueryParams() { + return buildQueryParams(request); + } + } + + public static class PutCustomRequest + extends Object + implements EchoResponseInterface { + + private Request request; + + public PutCustomRequest(Request request) { + this.request = request; + } + + public String getPath() { + return request.url().encodedPath(); + } + + public String getMethod() { + return request.method(); + } + + public String getBody() { + return parseRequestBody(request); + } + + public List getQueryParams() { + return buildQueryParams(request); + } + } + public static class RemoveUserId extends RemoveUserIdResponse implements EchoResponseInterface { diff --git a/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts b/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts index a1533a5e79..cac9fc878f 100644 --- a/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts @@ -67,7 +67,7 @@ export function createAbtestingApi( function addABTests( addABTestsRequest: AddABTestsRequest ): Promise { - const path = '/2/abtests'; + const requestPath = '/2/abtests'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -95,7 +95,7 @@ export function createAbtestingApi( const request: Request = { method: 'POST', - path, + path: requestPath, data: addABTestsRequest, }; @@ -113,7 +113,7 @@ export function createAbtestingApi( * @param deleteABTest.id - The A/B test ID. */ function deleteABTest({ id }: DeleteABTestProps): Promise { - const path = '/2/abtests/{id}'.replace( + const requestPath = '/2/abtests/{id}'.replace( '{id}', encodeURIComponent(String(id)) ); @@ -128,7 +128,44 @@ export function createAbtestingApi( const request: Request = { method: 'DELETE', - path, + path: requestPath, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param deleteCustomRequest - The deleteCustomRequest object. + * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param deleteCustomRequest.body - The parameters to send with the custom request. + */ + function deleteCustomRequest({ + path, + body, + }: DeleteCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `deleteCustomRequest`.' + ); + } + + const request: Request = { + method: 'DELETE', + path: requestPath, + data: body, }; return transporter.request(request, { @@ -145,7 +182,7 @@ export function createAbtestingApi( * @param getABTest.id - The A/B test ID. */ function getABTest({ id }: GetABTestProps): Promise { - const path = '/2/abtests/{id}'.replace( + const requestPath = '/2/abtests/{id}'.replace( '{id}', encodeURIComponent(String(id)) ); @@ -158,7 +195,44 @@ export function createAbtestingApi( const request: Request = { method: 'GET', - path, + path: requestPath, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param getCustomRequest - The getCustomRequest object. + * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param getCustomRequest.body - The parameters to send with the custom request. + */ + function getCustomRequest({ + path, + body, + }: GetCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `getCustomRequest`.' + ); + } + + const request: Request = { + method: 'GET', + path: requestPath, + data: body, }; return transporter.request(request, { @@ -179,7 +253,7 @@ export function createAbtestingApi( offset, limit, }: ListABTestsProps): Promise { - const path = '/2/abtests'; + const requestPath = '/2/abtests'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -193,7 +267,81 @@ export function createAbtestingApi( const request: Request = { method: 'GET', - path, + path: requestPath, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param postCustomRequest - The postCustomRequest object. + * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param postCustomRequest.body - The parameters to send with the custom request. + */ + function postCustomRequest({ + path, + body, + }: PostCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `postCustomRequest`.' + ); + } + + const request: Request = { + method: 'POST', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param putCustomRequest - The putCustomRequest object. + * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param putCustomRequest.body - The parameters to send with the custom request. + */ + function putCustomRequest({ + path, + body, + }: PutCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `putCustomRequest`.' + ); + } + + const request: Request = { + method: 'PUT', + path: requestPath, + data: body, }; return transporter.request(request, { @@ -210,7 +358,7 @@ export function createAbtestingApi( * @param stopABTest.id - The A/B test ID. */ function stopABTest({ id }: StopABTestProps): Promise { - const path = '/2/abtests/{id}/stop'.replace( + const requestPath = '/2/abtests/{id}/stop'.replace( '{id}', encodeURIComponent(String(id)) ); @@ -223,7 +371,7 @@ export function createAbtestingApi( const request: Request = { method: 'POST', - path, + path: requestPath, }; return transporter.request(request, { @@ -236,8 +384,12 @@ export function createAbtestingApi( addUserAgent, addABTests, deleteABTest, + deleteCustomRequest, getABTest, + getCustomRequest, listABTests, + postCustomRequest, + putCustomRequest, stopABTest, }; } @@ -251,6 +403,17 @@ export type DeleteABTestProps = { id: number; }; +export type DeleteCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type GetABTestProps = { /** * The A/B test ID. @@ -258,6 +421,17 @@ export type GetABTestProps = { id: number; }; +export type GetCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type ListABTestsProps = { /** * Position of the starting record. Used for paging. 0 is the first record. @@ -269,6 +443,28 @@ export type ListABTestsProps = { limit?: number; }; +export type PostCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type PutCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type StopABTestProps = { /** * The A/B test ID. diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts index 7486b001f1..d7280dbc1b 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts @@ -73,6 +73,43 @@ export function createAnalyticsApi( transporter.userAgent.add({ segment, version }); } + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param deleteCustomRequest - The deleteCustomRequest object. + * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param deleteCustomRequest.body - The parameters to send with the custom request. + */ + function deleteCustomRequest({ + path, + body, + }: DeleteCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `deleteCustomRequest`.' + ); + } + + const request: Request = { + method: 'DELETE', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + /** * Returns the average click position. The endpoint returns a value for the complete given time range, as well as a value per day. * @@ -89,7 +126,7 @@ export function createAnalyticsApi( endDate, tags, }: GetAverageClickPositionProps): Promise { - const path = '/2/clicks/averageClickPosition'; + const requestPath = '/2/clicks/averageClickPosition'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -117,7 +154,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -142,7 +179,7 @@ export function createAnalyticsApi( endDate, tags, }: GetClickPositionsProps): Promise { - const path = '/2/clicks/positions'; + const requestPath = '/2/clicks/positions'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -170,7 +207,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -195,7 +232,7 @@ export function createAnalyticsApi( endDate, tags, }: GetClickThroughRateProps): Promise { - const path = '/2/clicks/clickThroughRate'; + const requestPath = '/2/clicks/clickThroughRate'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -223,7 +260,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -248,7 +285,7 @@ export function createAnalyticsApi( endDate, tags, }: GetConversationRateProps): Promise { - const path = '/2/conversions/conversionRate'; + const requestPath = '/2/conversions/conversionRate'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -276,7 +313,44 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param getCustomRequest - The getCustomRequest object. + * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param getCustomRequest.body - The parameters to send with the custom request. + */ + function getCustomRequest({ + path, + body, + }: GetCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `getCustomRequest`.' + ); + } + + const request: Request = { + method: 'GET', + path: requestPath, + data: body, }; return transporter.request(request, { @@ -301,7 +375,7 @@ export function createAnalyticsApi( endDate, tags, }: GetNoClickRateProps): Promise { - const path = '/2/searches/noClickRate'; + const requestPath = '/2/searches/noClickRate'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -329,7 +403,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -354,7 +428,7 @@ export function createAnalyticsApi( endDate, tags, }: GetNoResultsRateProps): Promise { - const path = '/2/searches/noResultRate'; + const requestPath = '/2/searches/noResultRate'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -382,7 +456,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -407,7 +481,7 @@ export function createAnalyticsApi( endDate, tags, }: GetSearchesCountProps): Promise { - const path = '/2/searches/count'; + const requestPath = '/2/searches/count'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -435,7 +509,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -464,7 +538,7 @@ export function createAnalyticsApi( offset, tags, }: GetSearchesNoClicksProps): Promise { - const path = '/2/searches/noClicks'; + const requestPath = '/2/searches/noClicks'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -500,7 +574,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -529,7 +603,7 @@ export function createAnalyticsApi( offset, tags, }: GetSearchesNoResultsProps): Promise { - const path = '/2/searches/noResults'; + const requestPath = '/2/searches/noResults'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -565,7 +639,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -582,7 +656,7 @@ export function createAnalyticsApi( * @param getStatus.index - The index name to target. */ function getStatus({ index }: GetStatusProps): Promise { - const path = '/2/status'; + const requestPath = '/2/status'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -598,7 +672,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -627,7 +701,7 @@ export function createAnalyticsApi( offset, tags, }: GetTopCountriesProps): Promise { - const path = '/2/countries'; + const requestPath = '/2/countries'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -663,7 +737,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -694,7 +768,7 @@ export function createAnalyticsApi( offset, tags, }: GetTopFilterAttributesProps): Promise { - const path = '/2/filters'; + const requestPath = '/2/filters'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -734,7 +808,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -767,7 +841,7 @@ export function createAnalyticsApi( offset, tags, }: GetTopFilterForAttributeProps): Promise { - const path = '/2/filters/{attribute}'.replace( + const requestPath = '/2/filters/{attribute}'.replace( '{attribute}', encodeURIComponent(String(attribute)) ); @@ -816,7 +890,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -847,7 +921,7 @@ export function createAnalyticsApi( offset, tags, }: GetTopFiltersNoResultsProps): Promise { - const path = '/2/filters/noResults'; + const requestPath = '/2/filters/noResults'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -887,7 +961,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -922,7 +996,7 @@ export function createAnalyticsApi( }: GetTopHitsProps): Promise< GetTopHitsResponse | GetTopHitsResponseWithAnalytics > { - const path = '/2/hits'; + const requestPath = '/2/hits'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -966,7 +1040,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1003,7 +1077,7 @@ export function createAnalyticsApi( }: GetTopSearchesProps): Promise< GetTopSearchesResponse | GetTopSearchesResponseWithAnalytics > { - const path = '/2/searches'; + const requestPath = '/2/searches'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -1051,7 +1125,7 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1076,7 +1150,7 @@ export function createAnalyticsApi( endDate, tags, }: GetUsersCountProps): Promise { - const path = '/2/users/count'; + const requestPath = '/2/users/count'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -1104,7 +1178,81 @@ export function createAnalyticsApi( const request: Request = { method: 'GET', - path, + path: requestPath, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param postCustomRequest - The postCustomRequest object. + * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param postCustomRequest.body - The parameters to send with the custom request. + */ + function postCustomRequest({ + path, + body, + }: PostCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `postCustomRequest`.' + ); + } + + const request: Request = { + method: 'POST', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param putCustomRequest - The putCustomRequest object. + * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param putCustomRequest.body - The parameters to send with the custom request. + */ + function putCustomRequest({ + path, + body, + }: PutCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `putCustomRequest`.' + ); + } + + const request: Request = { + method: 'PUT', + path: requestPath, + data: body, }; return transporter.request(request, { @@ -1115,10 +1263,12 @@ export function createAnalyticsApi( return { addUserAgent, + deleteCustomRequest, getAverageClickPosition, getClickPositions, getClickThroughRate, getConversationRate, + getCustomRequest, getNoClickRate, getNoResultsRate, getSearchesCount, @@ -1132,11 +1282,24 @@ export function createAnalyticsApi( getTopHits, getTopSearches, getUsersCount, + postCustomRequest, + putCustomRequest, }; } export type AnalyticsApi = ReturnType; +export type DeleteCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type GetAverageClickPositionProps = { /** * The index name to target. @@ -1213,6 +1376,17 @@ export type GetConversationRateProps = { tags?: string; }; +export type GetCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type GetNoClickRateProps = { /** * The index name to target. @@ -1551,3 +1725,25 @@ export type GetUsersCountProps = { */ tags?: string; }; + +export type PostCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type PutCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts b/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts index 92a4f2ea0c..d3a894b275 100644 --- a/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts @@ -56,6 +56,117 @@ export function createInsightsApi( transporter.userAgent.add({ segment, version }); } + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param deleteCustomRequest - The deleteCustomRequest object. + * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param deleteCustomRequest.body - The parameters to send with the custom request. + */ + function deleteCustomRequest({ + path, + body, + }: DeleteCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `deleteCustomRequest`.' + ); + } + + const request: Request = { + method: 'DELETE', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param getCustomRequest - The getCustomRequest object. + * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param getCustomRequest.body - The parameters to send with the custom request. + */ + function getCustomRequest({ + path, + body, + }: GetCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `getCustomRequest`.' + ); + } + + const request: Request = { + method: 'GET', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param postCustomRequest - The postCustomRequest object. + * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param postCustomRequest.body - The parameters to send with the custom request. + */ + function postCustomRequest({ + path, + body, + }: PostCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `postCustomRequest`.' + ); + } + + const request: Request = { + method: 'POST', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + /** * This command pushes an array of events. * @@ -65,7 +176,7 @@ export function createInsightsApi( function pushEvents( insightEvents: InsightEvents ): Promise { - const path = '/1/events'; + const requestPath = '/1/events'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -83,7 +194,7 @@ export function createInsightsApi( const request: Request = { method: 'POST', - path, + path: requestPath, data: insightEvents, }; @@ -93,7 +204,95 @@ export function createInsightsApi( }); } - return { addUserAgent, pushEvents }; + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param putCustomRequest - The putCustomRequest object. + * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param putCustomRequest.body - The parameters to send with the custom request. + */ + function putCustomRequest({ + path, + body, + }: PutCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `putCustomRequest`.' + ); + } + + const request: Request = { + method: 'PUT', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + return { + addUserAgent, + deleteCustomRequest, + getCustomRequest, + postCustomRequest, + pushEvents, + putCustomRequest, + }; } export type InsightsApi = ReturnType; + +export type DeleteCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type GetCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type PostCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type PutCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts b/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts index ceeeff0aab..71d646acd0 100644 --- a/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts @@ -56,6 +56,43 @@ export function createPersonalizationApi( transporter.userAgent.add({ segment, version }); } + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param deleteCustomRequest - The deleteCustomRequest object. + * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param deleteCustomRequest.body - The parameters to send with the custom request. + */ + function deleteCustomRequest({ + path, + body, + }: DeleteCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `deleteCustomRequest`.' + ); + } + + const request: Request = { + method: 'DELETE', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + /** * Returns, as part of the response, a date until which the data can safely be considered as deleted for the given user. This means that if you send events for the given user before this date, they will be ignored. Any data received after the deletedUntil date will start building a new user profile. It might take a couple hours before for the deletion request to be fully processed. * @@ -66,7 +103,7 @@ export function createPersonalizationApi( function deleteUserProfile({ userToken, }: DeleteUserProfileProps): Promise { - const path = '/1/profiles/{userToken}'.replace( + const requestPath = '/1/profiles/{userToken}'.replace( '{userToken}', encodeURIComponent(String(userToken)) ); @@ -81,7 +118,44 @@ export function createPersonalizationApi( const request: Request = { method: 'DELETE', - path, + path: requestPath, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param getCustomRequest - The getCustomRequest object. + * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param getCustomRequest.body - The parameters to send with the custom request. + */ + function getCustomRequest({ + path, + body, + }: GetCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `getCustomRequest`.' + ); + } + + const request: Request = { + method: 'GET', + path: requestPath, + data: body, }; return transporter.request(request, { @@ -96,13 +170,13 @@ export function createPersonalizationApi( * @summary Get the current personalization strategy. */ function getPersonalizationStrategy(): Promise { - const path = '/1/strategies/personalization'; + const requestPath = '/1/strategies/personalization'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -121,7 +195,7 @@ export function createPersonalizationApi( function getUserTokenProfile({ userToken, }: GetUserTokenProfileProps): Promise { - const path = '/1/profiles/personalization/{userToken}'.replace( + const requestPath = '/1/profiles/personalization/{userToken}'.replace( '{userToken}', encodeURIComponent(String(userToken)) ); @@ -136,7 +210,81 @@ export function createPersonalizationApi( const request: Request = { method: 'GET', - path, + path: requestPath, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param postCustomRequest - The postCustomRequest object. + * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param postCustomRequest.body - The parameters to send with the custom request. + */ + function postCustomRequest({ + path, + body, + }: PostCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `postCustomRequest`.' + ); + } + + const request: Request = { + method: 'POST', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param putCustomRequest - The putCustomRequest object. + * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param putCustomRequest.body - The parameters to send with the custom request. + */ + function putCustomRequest({ + path, + body, + }: PutCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `putCustomRequest`.' + ); + } + + const request: Request = { + method: 'PUT', + path: requestPath, + data: body, }; return transporter.request(request, { @@ -154,7 +302,7 @@ export function createPersonalizationApi( function setPersonalizationStrategy( personalizationStrategyParams: PersonalizationStrategyParams ): Promise { - const path = '/1/strategies/personalization'; + const requestPath = '/1/strategies/personalization'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -182,7 +330,7 @@ export function createPersonalizationApi( const request: Request = { method: 'POST', - path, + path: requestPath, data: personalizationStrategyParams, }; @@ -194,15 +342,30 @@ export function createPersonalizationApi( return { addUserAgent, + deleteCustomRequest, deleteUserProfile, + getCustomRequest, getPersonalizationStrategy, getUserTokenProfile, + postCustomRequest, + putCustomRequest, setPersonalizationStrategy, }; } export type PersonalizationApi = ReturnType; +export type DeleteCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type DeleteUserProfileProps = { /** * UserToken representing the user for which to fetch the Personalization profile. @@ -210,9 +373,42 @@ export type DeleteUserProfileProps = { userToken: string; }; +export type GetCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type GetUserTokenProfileProps = { /** * UserToken representing the user for which to fetch the Personalization profile. */ userToken: string; }; + +export type PostCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type PutCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts b/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts index 4370f36e9b..81b25f76ec 100644 --- a/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts @@ -50,6 +50,43 @@ export function createPredictApi(options: CreateClientOptions) { transporter.userAgent.add({ segment, version }); } + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param deleteCustomRequest - The deleteCustomRequest object. + * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param deleteCustomRequest.body - The parameters to send with the custom request. + */ + function deleteCustomRequest({ + path, + body, + }: DeleteCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `deleteCustomRequest`.' + ); + } + + const request: Request = { + method: 'DELETE', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + /** * Get predictions, properties (raw, computed or custom) and segments (computed or custom) for a user profile. * @@ -62,7 +99,7 @@ export function createPredictApi(options: CreateClientOptions) { userID, params, }: FetchUserProfileProps): Promise { - const path = '/1/users/{userID}/fetch'.replace( + const requestPath = '/1/users/{userID}/fetch'.replace( '{userID}', encodeURIComponent(String(userID)) ); @@ -83,7 +120,7 @@ export function createPredictApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: params, }; @@ -93,11 +130,140 @@ export function createPredictApi(options: CreateClientOptions) { }); } - return { addUserAgent, fetchUserProfile }; + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param getCustomRequest - The getCustomRequest object. + * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param getCustomRequest.body - The parameters to send with the custom request. + */ + function getCustomRequest({ + path, + body, + }: GetCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `getCustomRequest`.' + ); + } + + const request: Request = { + method: 'GET', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param postCustomRequest - The postCustomRequest object. + * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param postCustomRequest.body - The parameters to send with the custom request. + */ + function postCustomRequest({ + path, + body, + }: PostCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `postCustomRequest`.' + ); + } + + const request: Request = { + method: 'POST', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param putCustomRequest - The putCustomRequest object. + * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param putCustomRequest.body - The parameters to send with the custom request. + */ + function putCustomRequest({ + path, + body, + }: PutCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `putCustomRequest`.' + ); + } + + const request: Request = { + method: 'PUT', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + return { + addUserAgent, + deleteCustomRequest, + fetchUserProfile, + getCustomRequest, + postCustomRequest, + putCustomRequest, + }; } export type PredictApi = ReturnType; +export type DeleteCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type FetchUserProfileProps = { /** * User ID for authenticated users or cookie ID for non-authenticated repeated users (visitors). @@ -105,3 +271,36 @@ export type FetchUserProfileProps = { userID: string; params: Params; }; + +export type GetCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type PostCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type PutCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts index 7b96119a8c..feed29f890 100644 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts @@ -67,7 +67,7 @@ export function createQuerySuggestionsApi( function createConfig( querySuggestionsIndexWithIndexParam: QuerySuggestionsIndexWithIndexParam ): Promise { - const path = '/1/configs'; + const requestPath = '/1/configs'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -79,7 +79,7 @@ export function createQuerySuggestionsApi( const request: Request = { method: 'POST', - path, + path: requestPath, data: querySuggestionsIndexWithIndexParam, }; @@ -99,7 +99,7 @@ export function createQuerySuggestionsApi( function deleteConfig({ indexName, }: DeleteConfigProps): Promise { - const path = '/1/configs/{indexName}'.replace( + const requestPath = '/1/configs/{indexName}'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -114,7 +114,44 @@ export function createQuerySuggestionsApi( const request: Request = { method: 'DELETE', - path, + path: requestPath, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param deleteCustomRequest - The deleteCustomRequest object. + * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param deleteCustomRequest.body - The parameters to send with the custom request. + */ + function deleteCustomRequest({ + path, + body, + }: DeleteCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `deleteCustomRequest`.' + ); + } + + const request: Request = { + method: 'DELETE', + path: requestPath, + data: body, }; return transporter.request(request, { @@ -129,13 +166,13 @@ export function createQuerySuggestionsApi( * @summary Get all the configurations of Query Suggestions. */ function getAllConfigs(): Promise { - const path = '/1/configs'; + const requestPath = '/1/configs'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -154,7 +191,7 @@ export function createQuerySuggestionsApi( function getConfig({ indexName, }: GetConfigProps): Promise { - const path = '/1/configs/{indexName}'.replace( + const requestPath = '/1/configs/{indexName}'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -169,7 +206,7 @@ export function createQuerySuggestionsApi( const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -188,7 +225,7 @@ export function createQuerySuggestionsApi( function getConfigStatus({ indexName, }: GetConfigStatusProps): Promise { - const path = '/1/configs/{indexName}/status'.replace( + const requestPath = '/1/configs/{indexName}/status'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -203,7 +240,44 @@ export function createQuerySuggestionsApi( const request: Request = { method: 'GET', - path, + path: requestPath, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param getCustomRequest - The getCustomRequest object. + * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param getCustomRequest.body - The parameters to send with the custom request. + */ + function getCustomRequest({ + path, + body, + }: GetCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `getCustomRequest`.' + ); + } + + const request: Request = { + method: 'GET', + path: requestPath, + data: body, }; return transporter.request(request, { @@ -220,7 +294,7 @@ export function createQuerySuggestionsApi( * @param getLogFile.indexName - The index in which to perform the request. */ function getLogFile({ indexName }: GetLogFileProps): Promise { - const path = '/1/logs/{indexName}'.replace( + const requestPath = '/1/logs/{indexName}'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -235,7 +309,81 @@ export function createQuerySuggestionsApi( const request: Request = { method: 'GET', - path, + path: requestPath, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param postCustomRequest - The postCustomRequest object. + * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param postCustomRequest.body - The parameters to send with the custom request. + */ + function postCustomRequest({ + path, + body, + }: PostCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `postCustomRequest`.' + ); + } + + const request: Request = { + method: 'POST', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param putCustomRequest - The putCustomRequest object. + * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param putCustomRequest.body - The parameters to send with the custom request. + */ + function putCustomRequest({ + path, + body, + }: PutCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `putCustomRequest`.' + ); + } + + const request: Request = { + method: 'PUT', + path: requestPath, + data: body, }; return transporter.request(request, { @@ -256,7 +404,7 @@ export function createQuerySuggestionsApi( indexName, querySuggestionsIndexParam, }: UpdateConfigProps): Promise { - const path = '/1/configs/{indexName}'.replace( + const requestPath = '/1/configs/{indexName}'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -283,7 +431,7 @@ export function createQuerySuggestionsApi( const request: Request = { method: 'PUT', - path, + path: requestPath, data: querySuggestionsIndexParam, }; @@ -297,10 +445,14 @@ export function createQuerySuggestionsApi( addUserAgent, createConfig, deleteConfig, + deleteCustomRequest, getAllConfigs, getConfig, getConfigStatus, + getCustomRequest, getLogFile, + postCustomRequest, + putCustomRequest, updateConfig, }; } @@ -314,6 +466,17 @@ export type DeleteConfigProps = { indexName: string; }; +export type DeleteCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type GetConfigProps = { /** * The index in which to perform the request. @@ -328,6 +491,17 @@ export type GetConfigStatusProps = { indexName: string; }; +export type GetCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type GetLogFileProps = { /** * The index in which to perform the request. @@ -335,6 +509,28 @@ export type GetLogFileProps = { indexName: string; }; +export type PostCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type PutCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type UpdateConfigProps = { /** * The index in which to perform the request. diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/batchOperation.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/batchOperation.ts new file mode 100644 index 0000000000..ae3679e0fe --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/batchOperation.ts @@ -0,0 +1,9 @@ +import type { Action } from './action'; + +export type BatchOperation = { + action?: Action; + /** + * Arguments to the operation (depends on the type of the operation). + */ + body?: Record; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/batchParams.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/batchParams.ts index c0c9a64003..e58a54c5d5 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/batchParams.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/batchParams.ts @@ -1,8 +1,8 @@ -import type { Operation } from './operation'; +import type { MultipleBatchOperation } from './multipleBatchOperation'; /** * The `multipleBatch` parameters. */ export type BatchParams = { - requests?: Operation[]; + requests?: MultipleBatchOperation[]; }; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/batchWriteParams.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/batchWriteParams.ts index 60cd949a70..33035eb2f2 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/batchWriteParams.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/batchWriteParams.ts @@ -1,8 +1,8 @@ -import type { Operation } from './operation'; +import type { BatchOperation } from './batchOperation'; /** * The `batch` parameters. */ export type BatchWriteParams = { - requests?: Operation[]; + requests?: BatchOperation[]; }; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/operation.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/multipleBatchOperation.ts similarity index 86% rename from clients/algoliasearch-client-javascript/packages/client-search/model/operation.ts rename to clients/algoliasearch-client-javascript/packages/client-search/model/multipleBatchOperation.ts index bc80b8fbbd..59437910af 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/operation.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/multipleBatchOperation.ts @@ -1,6 +1,6 @@ import type { Action } from './action'; -export type Operation = { +export type MultipleBatchOperation = { action?: Action; /** * Arguments to the operation (depends on the type of the operation). diff --git a/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts index b99e6a7f89..872944d8c4 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts @@ -137,7 +137,7 @@ export function createSearchApi(options: CreateClientOptions) { * @param apiKey - The apiKey object. */ function addApiKey(apiKey: ApiKey): Promise { - const path = '/1/keys'; + const requestPath = '/1/keys'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -155,7 +155,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: apiKey, }; @@ -179,7 +179,7 @@ export function createSearchApi(options: CreateClientOptions) { objectID, body, }: AddOrUpdateObjectProps): Promise { - const path = '/1/indexes/{indexName}/{objectID}' + const requestPath = '/1/indexes/{indexName}/{objectID}' .replace('{indexName}', encodeURIComponent(String(indexName))) .replace('{objectID}', encodeURIComponent(String(objectID))); const headers: Headers = { Accept: 'application/json' }; @@ -205,7 +205,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'PUT', - path, + path: requestPath, data: body, }; @@ -222,7 +222,7 @@ export function createSearchApi(options: CreateClientOptions) { * @param source - The source to add. */ function appendSource(source: Source): Promise { - const path = '/1/security/sources/append'; + const requestPath = '/1/security/sources/append'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -234,7 +234,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: source, }; @@ -256,7 +256,7 @@ export function createSearchApi(options: CreateClientOptions) { xAlgoliaUserID, assignUserIdParams, }: AssignUserIdProps): Promise { - const path = '/1/clusters/mapping'; + const requestPath = '/1/clusters/mapping'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -284,7 +284,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: assignUserIdParams, }; @@ -306,7 +306,7 @@ export function createSearchApi(options: CreateClientOptions) { indexName, batchWriteParams, }: BatchProps): Promise { - const path = '/1/indexes/{indexName}/batch'.replace( + const requestPath = '/1/indexes/{indexName}/batch'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -327,7 +327,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: batchWriteParams, }; @@ -349,7 +349,7 @@ export function createSearchApi(options: CreateClientOptions) { xAlgoliaUserID, batchAssignUserIdsParams, }: BatchAssignUserIdsProps): Promise { - const path = '/1/clusters/mapping/batch'; + const requestPath = '/1/clusters/mapping/batch'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -382,7 +382,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: batchAssignUserIdsParams, }; @@ -404,7 +404,7 @@ export function createSearchApi(options: CreateClientOptions) { dictionaryName, batchDictionaryEntriesParams, }: BatchDictionaryEntriesProps): Promise { - const path = '/1/dictionaries/{dictionaryName}/batch'.replace( + const requestPath = '/1/dictionaries/{dictionaryName}/batch'.replace( '{dictionaryName}', encodeURIComponent(String(dictionaryName)) ); @@ -431,7 +431,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: batchDictionaryEntriesParams, }; @@ -457,7 +457,7 @@ export function createSearchApi(options: CreateClientOptions) { forwardToReplicas, clearExistingRules, }: BatchRulesProps): Promise { - const path = '/1/indexes/{indexName}/rules/batch'.replace( + const requestPath = '/1/indexes/{indexName}/rules/batch'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -486,7 +486,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: rule, }; @@ -508,7 +508,7 @@ export function createSearchApi(options: CreateClientOptions) { indexName, browseRequest, }: BrowseProps): Promise { - const path = '/1/indexes/{indexName}/browse'.replace( + const requestPath = '/1/indexes/{indexName}/browse'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -523,7 +523,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: browseRequest, }; @@ -545,7 +545,7 @@ export function createSearchApi(options: CreateClientOptions) { indexName, forwardToReplicas, }: ClearAllSynonymsProps): Promise { - const path = '/1/indexes/{indexName}/synonyms/clear'.replace( + const requestPath = '/1/indexes/{indexName}/synonyms/clear'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -564,7 +564,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, }; return transporter.request(request, { @@ -583,7 +583,7 @@ export function createSearchApi(options: CreateClientOptions) { function clearObjects({ indexName, }: ClearObjectsProps): Promise { - const path = '/1/indexes/{indexName}/clear'.replace( + const requestPath = '/1/indexes/{indexName}/clear'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -598,7 +598,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, }; return transporter.request(request, { @@ -619,7 +619,7 @@ export function createSearchApi(options: CreateClientOptions) { indexName, forwardToReplicas, }: ClearRulesProps): Promise { - const path = '/1/indexes/{indexName}/rules/clear'.replace( + const requestPath = '/1/indexes/{indexName}/rules/clear'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -638,7 +638,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, }; return transporter.request(request, { @@ -657,7 +657,7 @@ export function createSearchApi(options: CreateClientOptions) { function deleteApiKey({ key, }: DeleteApiKeyProps): Promise { - const path = '/1/keys/{key}'.replace( + const requestPath = '/1/keys/{key}'.replace( '{key}', encodeURIComponent(String(key)) ); @@ -672,7 +672,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'DELETE', - path, + path: requestPath, }; return transporter.request(request, { @@ -693,7 +693,7 @@ export function createSearchApi(options: CreateClientOptions) { indexName, searchParams, }: DeleteByProps): Promise { - const path = '/1/indexes/{indexName}/deleteByQuery'.replace( + const requestPath = '/1/indexes/{indexName}/deleteByQuery'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -714,7 +714,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: searchParams, }; @@ -724,6 +724,43 @@ export function createSearchApi(options: CreateClientOptions) { }); } + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param deleteCustomRequest - The deleteCustomRequest object. + * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param deleteCustomRequest.body - The parameters to send with the custom request. + */ + function deleteCustomRequest({ + path, + body, + }: DeleteCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `deleteCustomRequest`.' + ); + } + + const request: Request = { + method: 'DELETE', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + /** * Delete an existing index. * @@ -734,7 +771,7 @@ export function createSearchApi(options: CreateClientOptions) { function deleteIndex({ indexName, }: DeleteIndexProps): Promise { - const path = '/1/indexes/{indexName}'.replace( + const requestPath = '/1/indexes/{indexName}'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -749,7 +786,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'DELETE', - path, + path: requestPath, }; return transporter.request(request, { @@ -770,7 +807,7 @@ export function createSearchApi(options: CreateClientOptions) { indexName, objectID, }: DeleteObjectProps): Promise { - const path = '/1/indexes/{indexName}/{objectID}' + const requestPath = '/1/indexes/{indexName}/{objectID}' .replace('{indexName}', encodeURIComponent(String(indexName))) .replace('{objectID}', encodeURIComponent(String(objectID))); const headers: Headers = { Accept: 'application/json' }; @@ -790,7 +827,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'DELETE', - path, + path: requestPath, }; return transporter.request(request, { @@ -813,7 +850,7 @@ export function createSearchApi(options: CreateClientOptions) { objectID, forwardToReplicas, }: DeleteRuleProps): Promise { - const path = '/1/indexes/{indexName}/rules/{objectID}' + const requestPath = '/1/indexes/{indexName}/rules/{objectID}' .replace('{indexName}', encodeURIComponent(String(indexName))) .replace('{objectID}', encodeURIComponent(String(objectID))); const headers: Headers = { Accept: 'application/json' }; @@ -837,7 +874,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'DELETE', - path, + path: requestPath, }; return transporter.request(request, { @@ -856,7 +893,7 @@ export function createSearchApi(options: CreateClientOptions) { function deleteSource({ source, }: DeleteSourceProps): Promise { - const path = '/1/security/sources/{source}'.replace( + const requestPath = '/1/security/sources/{source}'.replace( '{source}', encodeURIComponent(String(source)) ); @@ -871,7 +908,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'DELETE', - path, + path: requestPath, }; return transporter.request(request, { @@ -894,7 +931,7 @@ export function createSearchApi(options: CreateClientOptions) { objectID, forwardToReplicas, }: DeleteSynonymProps): Promise { - const path = '/1/indexes/{indexName}/synonyms/{objectID}' + const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}' .replace('{indexName}', encodeURIComponent(String(indexName))) .replace('{objectID}', encodeURIComponent(String(objectID))); const headers: Headers = { Accept: 'application/json' }; @@ -918,7 +955,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'DELETE', - path, + path: requestPath, }; return transporter.request(request, { @@ -935,7 +972,7 @@ export function createSearchApi(options: CreateClientOptions) { * @param getApiKey.key - API Key string. */ function getApiKey({ key }: GetApiKeyProps): Promise { - const path = '/1/keys/{key}'.replace( + const requestPath = '/1/keys/{key}'.replace( '{key}', encodeURIComponent(String(key)) ); @@ -948,7 +985,44 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'GET', - path, + path: requestPath, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param getCustomRequest - The getCustomRequest object. + * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param getCustomRequest.body - The parameters to send with the custom request. + */ + function getCustomRequest({ + path, + body, + }: GetCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `getCustomRequest`.' + ); + } + + const request: Request = { + method: 'GET', + path: requestPath, + data: body, }; return transporter.request(request, { @@ -963,13 +1037,13 @@ export function createSearchApi(options: CreateClientOptions) { * @summary List dictionaries supported per language. */ function getDictionaryLanguages(): Promise<{ [key: string]: Languages }> { - const path = '/1/dictionaries/*/languages'; + const requestPath = '/1/dictionaries/*/languages'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -984,13 +1058,13 @@ export function createSearchApi(options: CreateClientOptions) { * @summary Retrieve dictionaries settings. The API stores languages whose standard entries are disabled. Fetch settings does not return false values. */ function getDictionarySettings(): Promise { - const path = '/1/dictionaries/*/settings'; + const requestPath = '/1/dictionaries/*/settings'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1015,7 +1089,7 @@ export function createSearchApi(options: CreateClientOptions) { indexName, type, }: GetLogsProps): Promise { - const path = '/1/logs'; + const requestPath = '/1/logs'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -1037,7 +1111,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1060,7 +1134,7 @@ export function createSearchApi(options: CreateClientOptions) { objectID, attributesToRetrieve, }: GetObjectProps): Promise<{ [key: string]: string }> { - const path = '/1/indexes/{indexName}/{objectID}' + const requestPath = '/1/indexes/{indexName}/{objectID}' .replace('{indexName}', encodeURIComponent(String(indexName))) .replace('{objectID}', encodeURIComponent(String(objectID))); const headers: Headers = { Accept: 'application/json' }; @@ -1084,7 +1158,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1102,7 +1176,7 @@ export function createSearchApi(options: CreateClientOptions) { function getObjects( getObjectsParams: GetObjectsParams ): Promise { - const path = '/1/indexes/*/objects'; + const requestPath = '/1/indexes/*/objects'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -1114,7 +1188,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: getObjectsParams, }; @@ -1133,7 +1207,7 @@ export function createSearchApi(options: CreateClientOptions) { * @param getRule.objectID - Unique identifier of an object. */ function getRule({ indexName, objectID }: GetRuleProps): Promise { - const path = '/1/indexes/{indexName}/rules/{objectID}' + const requestPath = '/1/indexes/{indexName}/rules/{objectID}' .replace('{indexName}', encodeURIComponent(String(indexName))) .replace('{objectID}', encodeURIComponent(String(objectID))); const headers: Headers = { Accept: 'application/json' }; @@ -1153,7 +1227,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1172,7 +1246,7 @@ export function createSearchApi(options: CreateClientOptions) { function getSettings({ indexName, }: GetSettingsProps): Promise { - const path = '/1/indexes/{indexName}/settings'.replace( + const requestPath = '/1/indexes/{indexName}/settings'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -1187,7 +1261,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1202,13 +1276,13 @@ export function createSearchApi(options: CreateClientOptions) { * @summary List all allowed sources. */ function getSources(): Promise { - const path = '/1/security/sources'; + const requestPath = '/1/security/sources'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1229,7 +1303,7 @@ export function createSearchApi(options: CreateClientOptions) { indexName, objectID, }: GetSynonymProps): Promise { - const path = '/1/indexes/{indexName}/synonyms/{objectID}' + const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}' .replace('{indexName}', encodeURIComponent(String(indexName))) .replace('{objectID}', encodeURIComponent(String(objectID))); const headers: Headers = { Accept: 'application/json' }; @@ -1249,7 +1323,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1270,7 +1344,7 @@ export function createSearchApi(options: CreateClientOptions) { indexName, taskID, }: GetTaskProps): Promise { - const path = '/1/indexes/{indexName}/task/{taskID}' + const requestPath = '/1/indexes/{indexName}/task/{taskID}' .replace('{indexName}', encodeURIComponent(String(indexName))) .replace('{taskID}', encodeURIComponent(String(taskID))); const headers: Headers = { Accept: 'application/json' }; @@ -1288,7 +1362,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1303,13 +1377,13 @@ export function createSearchApi(options: CreateClientOptions) { * @summary Get top userID. */ function getTopUserIds(): Promise { - const path = '/1/clusters/mapping/top'; + const requestPath = '/1/clusters/mapping/top'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1326,7 +1400,7 @@ export function createSearchApi(options: CreateClientOptions) { * @param getUserId.userID - UserID to assign. */ function getUserId({ userID }: GetUserIdProps): Promise { - const path = '/1/clusters/mapping/{userID}'.replace( + const requestPath = '/1/clusters/mapping/{userID}'.replace( '{userID}', encodeURIComponent(String(userID)) ); @@ -1341,7 +1415,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1360,7 +1434,7 @@ export function createSearchApi(options: CreateClientOptions) { function hasPendingMappings({ getClusters, }: HasPendingMappingsProps): Promise { - const path = '/1/clusters/mapping/pending'; + const requestPath = '/1/clusters/mapping/pending'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -1370,7 +1444,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1385,13 +1459,13 @@ export function createSearchApi(options: CreateClientOptions) { * @summary Get the full list of API Keys. */ function listApiKeys(): Promise { - const path = '/1/keys'; + const requestPath = '/1/keys'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1406,13 +1480,13 @@ export function createSearchApi(options: CreateClientOptions) { * @summary List clusters. */ function listClusters(): Promise { - const path = '/1/clusters'; + const requestPath = '/1/clusters'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1431,7 +1505,7 @@ export function createSearchApi(options: CreateClientOptions) { function listIndices({ page, }: ListIndicesProps): Promise { - const path = '/1/indexes'; + const requestPath = '/1/indexes'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -1441,7 +1515,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1462,7 +1536,7 @@ export function createSearchApi(options: CreateClientOptions) { page, hitsPerPage, }: ListUserIdsProps): Promise { - const path = '/1/clusters/mapping'; + const requestPath = '/1/clusters/mapping'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -1476,7 +1550,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'GET', - path, + path: requestPath, }; return transporter.request(request, { @@ -1494,7 +1568,7 @@ export function createSearchApi(options: CreateClientOptions) { function multipleBatch( batchParams: BatchParams ): Promise { - const path = '/1/indexes/*/batch'; + const requestPath = '/1/indexes/*/batch'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -1506,7 +1580,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: batchParams, }; @@ -1525,7 +1599,7 @@ export function createSearchApi(options: CreateClientOptions) { function multipleQueries( multipleQueriesParams: MultipleQueriesParams ): Promise { - const path = '/1/indexes/*/queries'; + const requestPath = '/1/indexes/*/queries'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -1543,7 +1617,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: multipleQueriesParams, }; @@ -1565,7 +1639,7 @@ export function createSearchApi(options: CreateClientOptions) { indexName, operationIndexParams, }: OperationIndexProps): Promise { - const path = '/1/indexes/{indexName}/operation'.replace( + const requestPath = '/1/indexes/{indexName}/operation'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -1597,7 +1671,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: operationIndexParams, }; @@ -1623,7 +1697,7 @@ export function createSearchApi(options: CreateClientOptions) { stringBuiltInOperation, createIfNotExists, }: PartialUpdateObjectProps): Promise { - const path = '/1/indexes/{indexName}/{objectID}/partial' + const requestPath = '/1/indexes/{indexName}/{objectID}/partial' .replace('{indexName}', encodeURIComponent(String(indexName))) .replace('{objectID}', encodeURIComponent(String(objectID))); const headers: Headers = { Accept: 'application/json' }; @@ -1653,7 +1727,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: stringBuiltInOperation, }; @@ -1663,6 +1737,80 @@ export function createSearchApi(options: CreateClientOptions) { }); } + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param postCustomRequest - The postCustomRequest object. + * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param postCustomRequest.body - The parameters to send with the custom request. + */ + function postCustomRequest({ + path, + body, + }: PostCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `postCustomRequest`.' + ); + } + + const request: Request = { + method: 'POST', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param putCustomRequest - The putCustomRequest object. + * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param putCustomRequest.body - The parameters to send with the custom request. + */ + function putCustomRequest({ + path, + body, + }: PutCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `putCustomRequest`.' + ); + } + + const request: Request = { + method: 'PUT', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + /** * Remove a userID and its associated data from the multi-clusters. Upon success, the response is 200 OK and a task is created to remove the userID data and mapping. * @@ -1673,7 +1821,7 @@ export function createSearchApi(options: CreateClientOptions) { function removeUserId({ userID, }: RemoveUserIdProps): Promise { - const path = '/1/clusters/mapping/{userID}'.replace( + const requestPath = '/1/clusters/mapping/{userID}'.replace( '{userID}', encodeURIComponent(String(userID)) ); @@ -1688,7 +1836,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'DELETE', - path, + path: requestPath, }; return transporter.request(request, { @@ -1707,7 +1855,7 @@ export function createSearchApi(options: CreateClientOptions) { function replaceSources({ source, }: ReplaceSourcesProps): Promise { - const path = '/1/security/sources'; + const requestPath = '/1/security/sources'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -1719,7 +1867,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'PUT', - path, + path: requestPath, data: source, }; @@ -1739,7 +1887,7 @@ export function createSearchApi(options: CreateClientOptions) { function restoreApiKey({ key, }: RestoreApiKeyProps): Promise { - const path = '/1/keys/{key}/restore'.replace( + const requestPath = '/1/keys/{key}/restore'.replace( '{key}', encodeURIComponent(String(key)) ); @@ -1754,7 +1902,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, }; return transporter.request(request, { @@ -1775,7 +1923,7 @@ export function createSearchApi(options: CreateClientOptions) { indexName, body, }: SaveObjectProps): Promise { - const path = '/1/indexes/{indexName}'.replace( + const requestPath = '/1/indexes/{indexName}'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -1796,7 +1944,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: body, }; @@ -1822,7 +1970,7 @@ export function createSearchApi(options: CreateClientOptions) { rule, forwardToReplicas, }: SaveRuleProps): Promise { - const path = '/1/indexes/{indexName}/rules/{objectID}' + const requestPath = '/1/indexes/{indexName}/rules/{objectID}' .replace('{indexName}', encodeURIComponent(String(indexName))) .replace('{objectID}', encodeURIComponent(String(objectID))); const headers: Headers = { Accept: 'application/json' }; @@ -1861,7 +2009,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'PUT', - path, + path: requestPath, data: rule, }; @@ -1887,7 +2035,7 @@ export function createSearchApi(options: CreateClientOptions) { synonymHit, forwardToReplicas, }: SaveSynonymProps): Promise { - const path = '/1/indexes/{indexName}/synonyms/{objectID}' + const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}' .replace('{indexName}', encodeURIComponent(String(indexName))) .replace('{objectID}', encodeURIComponent(String(objectID))); const headers: Headers = { Accept: 'application/json' }; @@ -1923,7 +2071,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'PUT', - path, + path: requestPath, data: synonymHit, }; @@ -1949,7 +2097,7 @@ export function createSearchApi(options: CreateClientOptions) { forwardToReplicas, replaceExistingSynonyms, }: SaveSynonymsProps): Promise { - const path = '/1/indexes/{indexName}/synonyms/batch'.replace( + const requestPath = '/1/indexes/{indexName}/synonyms/batch'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -1979,7 +2127,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: synonymHit, }; @@ -2001,7 +2149,7 @@ export function createSearchApi(options: CreateClientOptions) { indexName, searchParams, }: SearchProps): Promise { - const path = '/1/indexes/{indexName}/query'.replace( + const requestPath = '/1/indexes/{indexName}/query'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -2022,7 +2170,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: searchParams, }; @@ -2044,7 +2192,7 @@ export function createSearchApi(options: CreateClientOptions) { dictionaryName, searchDictionaryEntriesParams, }: SearchDictionaryEntriesProps): Promise { - const path = '/1/dictionaries/{dictionaryName}/search'.replace( + const requestPath = '/1/dictionaries/{dictionaryName}/search'.replace( '{dictionaryName}', encodeURIComponent(String(dictionaryName)) ); @@ -2071,7 +2219,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: searchDictionaryEntriesParams, }; @@ -2095,7 +2243,7 @@ export function createSearchApi(options: CreateClientOptions) { facetName, searchForFacetValuesRequest, }: SearchForFacetValuesProps): Promise { - const path = '/1/indexes/{indexName}/facets/{facetName}/query' + const requestPath = '/1/indexes/{indexName}/facets/{facetName}/query' .replace('{indexName}', encodeURIComponent(String(indexName))) .replace('{facetName}', encodeURIComponent(String(facetName))); const headers: Headers = { Accept: 'application/json' }; @@ -2115,7 +2263,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: searchForFacetValuesRequest, }; @@ -2137,7 +2285,7 @@ export function createSearchApi(options: CreateClientOptions) { indexName, searchRulesParams, }: SearchRulesProps): Promise { - const path = '/1/indexes/{indexName}/rules/search'.replace( + const requestPath = '/1/indexes/{indexName}/rules/search'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -2158,7 +2306,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: searchRulesParams, }; @@ -2186,7 +2334,7 @@ export function createSearchApi(options: CreateClientOptions) { page, hitsPerPage, }: SearchSynonymsProps): Promise { - const path = '/1/indexes/{indexName}/synonyms/search'.replace( + const requestPath = '/1/indexes/{indexName}/synonyms/search'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -2217,7 +2365,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, }; return transporter.request(request, { @@ -2235,7 +2383,7 @@ export function createSearchApi(options: CreateClientOptions) { function searchUserIds( searchUserIdsParams: SearchUserIdsParams ): Promise { - const path = '/1/clusters/mapping/search'; + const requestPath = '/1/clusters/mapping/search'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -2253,7 +2401,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: searchUserIdsParams, }; @@ -2272,7 +2420,7 @@ export function createSearchApi(options: CreateClientOptions) { function setDictionarySettings( dictionarySettingsParams: DictionarySettingsParams ): Promise { - const path = '/1/dictionaries/*/settings'; + const requestPath = '/1/dictionaries/*/settings'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -2290,7 +2438,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'PUT', - path, + path: requestPath, data: dictionarySettingsParams, }; @@ -2314,7 +2462,7 @@ export function createSearchApi(options: CreateClientOptions) { indexSettings, forwardToReplicas, }: SetSettingsProps): Promise { - const path = '/1/indexes/{indexName}/settings'.replace( + const requestPath = '/1/indexes/{indexName}/settings'.replace( '{indexName}', encodeURIComponent(String(indexName)) ); @@ -2339,7 +2487,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'PUT', - path, + path: requestPath, data: indexSettings, }; @@ -2361,7 +2509,7 @@ export function createSearchApi(options: CreateClientOptions) { key, apiKey, }: UpdateApiKeyProps): Promise { - const path = '/1/keys/{key}'.replace( + const requestPath = '/1/keys/{key}'.replace( '{key}', encodeURIComponent(String(key)) ); @@ -2388,7 +2536,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'PUT', - path, + path: requestPath, data: apiKey, }; @@ -2414,12 +2562,14 @@ export function createSearchApi(options: CreateClientOptions) { clearRules, deleteApiKey, deleteBy, + deleteCustomRequest, deleteIndex, deleteObject, deleteRule, deleteSource, deleteSynonym, getApiKey, + getCustomRequest, getDictionaryLanguages, getDictionarySettings, getLogs, @@ -2441,6 +2591,8 @@ export function createSearchApi(options: CreateClientOptions) { multipleQueries, operationIndex, partialUpdateObject, + postCustomRequest, + putCustomRequest, removeUserId, replaceSources, restoreApiKey, @@ -2577,6 +2729,17 @@ export type DeleteByProps = { searchParams: SearchParams; }; +export type DeleteCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type DeleteIndexProps = { /** * The index in which to perform the request. @@ -2639,6 +2802,17 @@ export type GetApiKeyProps = { key: string; }; +export type GetCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type GetLogsProps = { /** * First entry to retrieve (zero-based). Log entries are sorted by decreasing date, therefore 0 designates the most recent log entry. @@ -2772,6 +2946,28 @@ export type PartialUpdateObjectProps = { createIfNotExists?: boolean; }; +export type PostCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type PutCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type RemoveUserIdProps = { /** * UserID to assign. diff --git a/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts b/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts index 2f2b15887f..ad645934b4 100644 --- a/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts @@ -54,6 +54,117 @@ export function createSourcesApi( transporter.userAgent.add({ segment, version }); } + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param deleteCustomRequest - The deleteCustomRequest object. + * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param deleteCustomRequest.body - The parameters to send with the custom request. + */ + function deleteCustomRequest({ + path, + body, + }: DeleteCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `deleteCustomRequest`.' + ); + } + + const request: Request = { + method: 'DELETE', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param getCustomRequest - The getCustomRequest object. + * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param getCustomRequest.body - The parameters to send with the custom request. + */ + function getCustomRequest({ + path, + body, + }: GetCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `getCustomRequest`.' + ); + } + + const request: Request = { + method: 'GET', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param postCustomRequest - The postCustomRequest object. + * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param postCustomRequest.body - The parameters to send with the custom request. + */ + function postCustomRequest({ + path, + body, + }: PostCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `postCustomRequest`.' + ); + } + + const request: Request = { + method: 'POST', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + /** * Add an ingestion job that will fetch data from an URL. * @@ -63,7 +174,7 @@ export function createSourcesApi( function postIngestUrl( postURLJob: PostURLJob ): Promise { - const path = '/1/ingest/url'; + const requestPath = '/1/ingest/url'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -91,7 +202,7 @@ export function createSourcesApi( const request: Request = { method: 'POST', - path, + path: requestPath, data: postURLJob, }; @@ -101,7 +212,95 @@ export function createSourcesApi( }); } - return { addUserAgent, postIngestUrl }; + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param putCustomRequest - The putCustomRequest object. + * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param putCustomRequest.body - The parameters to send with the custom request. + */ + function putCustomRequest({ + path, + body, + }: PutCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `putCustomRequest`.' + ); + } + + const request: Request = { + method: 'PUT', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + return { + addUserAgent, + deleteCustomRequest, + getCustomRequest, + postCustomRequest, + postIngestUrl, + putCustomRequest, + }; } export type SourcesApi = ReturnType; + +export type DeleteCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type GetCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type PostCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type PutCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; diff --git a/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts b/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts index 8d1b336333..52dc42a677 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts +++ b/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts @@ -76,6 +76,80 @@ export function createRecommendApi(options: CreateClientOptions) { transporter.userAgent.add({ segment, version }); } + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param deleteCustomRequest - The deleteCustomRequest object. + * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param deleteCustomRequest.body - The parameters to send with the custom request. + */ + function deleteCustomRequest({ + path, + body, + }: DeleteCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `deleteCustomRequest`.' + ); + } + + const request: Request = { + method: 'DELETE', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param getCustomRequest - The getCustomRequest object. + * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param getCustomRequest.body - The parameters to send with the custom request. + */ + function getCustomRequest({ + path, + body, + }: GetCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `getCustomRequest`.' + ); + } + + const request: Request = { + method: 'GET', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + /** * Returns recommendations for a specific model and objectID. * @@ -85,7 +159,7 @@ export function createRecommendApi(options: CreateClientOptions) { function getRecommendations( getRecommendationsParams: GetRecommendationsParams ): Promise { - const path = '/1/indexes/*/recommendations'; + const requestPath = '/1/indexes/*/recommendations'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -103,7 +177,7 @@ export function createRecommendApi(options: CreateClientOptions) { const request: Request = { method: 'POST', - path, + path: requestPath, data: getRecommendationsParams, }; @@ -113,7 +187,132 @@ export function createRecommendApi(options: CreateClientOptions) { }); } - return { addUserAgent, getRecommendations }; + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param postCustomRequest - The postCustomRequest object. + * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param postCustomRequest.body - The parameters to send with the custom request. + */ + function postCustomRequest({ + path, + body, + }: PostCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `postCustomRequest`.' + ); + } + + const request: Request = { + method: 'POST', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + /** + * The customRequest method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param putCustomRequest - The putCustomRequest object. + * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param putCustomRequest.body - The parameters to send with the custom request. + */ + function putCustomRequest({ + path, + body, + }: PutCustomRequestProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error( + 'Parameter `path` is required when calling `putCustomRequest`.' + ); + } + + const request: Request = { + method: 'PUT', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + + return { + addUserAgent, + deleteCustomRequest, + getCustomRequest, + getRecommendations, + postCustomRequest, + putCustomRequest, + }; } export type RecommendApi = ReturnType; + +export type DeleteCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type GetCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type PostCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + +export type PutCustomRequestProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; diff --git a/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php b/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php index 14e03c81f9..cc528c088a 100644 --- a/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php +++ b/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php @@ -144,6 +144,42 @@ public function deleteABTest($id) return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function deleteCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling deleteCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); + } + /** * Returns metadata and metrics for A/B test id. * @@ -175,6 +211,42 @@ public function getABTest($id) return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function getCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling getCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); + } + /** * Fetch all existing A/B tests for App that are available for the current API Key. * @@ -212,6 +284,78 @@ public function listABTests($offset = 0, $limit = 10) return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function postCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling postCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); + } + + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function putCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling putCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('PUT', $resourcePath, $queryParams, $httpBody); + } + /** * Marks the A/B test as stopped. * diff --git a/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php b/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php index 34f47931aa..eebbe419f1 100644 --- a/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php @@ -86,6 +86,42 @@ public function getClientConfig() return $this->config; } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function deleteCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling deleteCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); + } + /** * Returns the average click position. * @@ -378,6 +414,42 @@ public function getConversationRate($index, $startDate = null, $endDate = null, return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function getCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling getCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); + } + /** * Returns the rate at which searches didn't lead to any clicks. * @@ -1566,6 +1638,78 @@ public function getUsersCount($index, $startDate = null, $endDate = null, $tags return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function postCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling postCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); + } + + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function putCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling putCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('PUT', $resourcePath, $queryParams, $httpBody); + } + private function sendRequest($method, $resourcePath, $queryParams, $httpBody) { $query = \GuzzleHttp\Psr7\Query::build($queryParams); diff --git a/clients/algoliasearch-client-php/lib/Api/InsightsApi.php b/clients/algoliasearch-client-php/lib/Api/InsightsApi.php index b58c61bd54..547df21040 100644 --- a/clients/algoliasearch-client-php/lib/Api/InsightsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/InsightsApi.php @@ -4,6 +4,7 @@ use Algolia\AlgoliaSearch\Algolia; use Algolia\AlgoliaSearch\Configuration\InsightsConfig; +use Algolia\AlgoliaSearch\ObjectSerializer; use Algolia\AlgoliaSearch\RetryStrategy\ApiWrapper; use Algolia\AlgoliaSearch\RetryStrategy\ApiWrapperInterface; use Algolia\AlgoliaSearch\RetryStrategy\ClusterHosts; @@ -85,6 +86,114 @@ public function getClientConfig() return $this->config; } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function deleteCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling deleteCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); + } + + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function getCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling getCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); + } + + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function postCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling postCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); + } + /** * Pushes an array of events. * @@ -112,6 +221,42 @@ public function pushEvents($insightEvents) return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function putCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling putCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('PUT', $resourcePath, $queryParams, $httpBody); + } + private function sendRequest($method, $resourcePath, $queryParams, $httpBody) { $query = \GuzzleHttp\Psr7\Query::build($queryParams); diff --git a/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php b/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php index 55712ad1bb..87781b54d4 100644 --- a/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php +++ b/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php @@ -86,6 +86,42 @@ public function getClientConfig() return $this->config; } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function deleteCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling deleteCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); + } + /** * Delete the user profile and all its associated data. * @@ -117,6 +153,42 @@ public function deleteUserProfile($userToken) return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function getCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling getCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); + } + /** * Get the current personalization strategy. * @@ -163,6 +235,78 @@ public function getUserTokenProfile($userToken) return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function postCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling postCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); + } + + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function putCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling putCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('PUT', $resourcePath, $queryParams, $httpBody); + } + /** * Set a new personalization strategy. * diff --git a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php index 79e81c1d70..6781a549cd 100644 --- a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php @@ -144,6 +144,42 @@ public function deleteConfig($indexName) return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function deleteCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling deleteCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); + } + /** * Get all the configurations of Query Suggestions. * @@ -221,6 +257,42 @@ public function getConfigStatus($indexName) return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function getCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling getCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); + } + /** * Get the log file of the last build of a single Query Suggestion index. * @@ -252,6 +324,78 @@ public function getLogFile($indexName) return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function postCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling postCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); + } + + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function putCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling putCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('PUT', $resourcePath, $queryParams, $httpBody); + } + /** * Update the configuration of a Query Suggestions index. * diff --git a/clients/algoliasearch-client-php/lib/Api/RecommendApi.php b/clients/algoliasearch-client-php/lib/Api/RecommendApi.php index 0297bbbaf8..5d7b227d55 100644 --- a/clients/algoliasearch-client-php/lib/Api/RecommendApi.php +++ b/clients/algoliasearch-client-php/lib/Api/RecommendApi.php @@ -4,6 +4,7 @@ use Algolia\AlgoliaSearch\Algolia; use Algolia\AlgoliaSearch\Configuration\RecommendConfig; +use Algolia\AlgoliaSearch\ObjectSerializer; use Algolia\AlgoliaSearch\RetryStrategy\ApiWrapper; use Algolia\AlgoliaSearch\RetryStrategy\ApiWrapperInterface; use Algolia\AlgoliaSearch\RetryStrategy\ClusterHosts; @@ -86,6 +87,78 @@ public function getClientConfig() return $this->config; } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function deleteCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling deleteCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); + } + + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function getCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling getCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); + } + /** * Returns recommendations for a specific model and objectID. * @@ -113,6 +186,78 @@ public function getRecommendations($getRecommendationsParams) return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function postCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling postCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); + } + + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function putCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling putCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('PUT', $resourcePath, $queryParams, $httpBody); + } + private function sendRequest($method, $resourcePath, $queryParams, $httpBody) { $query = \GuzzleHttp\Psr7\Query::build($queryParams); diff --git a/clients/algoliasearch-client-php/lib/Api/SearchApi.php b/clients/algoliasearch-client-php/lib/Api/SearchApi.php index 4049e0dbef..e5139a8230 100644 --- a/clients/algoliasearch-client-php/lib/Api/SearchApi.php +++ b/clients/algoliasearch-client-php/lib/Api/SearchApi.php @@ -666,6 +666,42 @@ public function deleteBy($indexName, $searchParams) return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function deleteCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling deleteCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); + } + /** * Delete index. * @@ -919,6 +955,42 @@ public function getApiKey($key) return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function getCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling getCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); + } + /** * List dictionaries supported per language. * @@ -1612,6 +1684,78 @@ public function partialUpdateObject($indexName, $objectID, $oneOfStringBuiltInOp return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function postCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling postCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); + } + + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function putCustomRequest($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling putCustomRequest' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('PUT', $resourcePath, $queryParams, $httpBody); + } + /** * Remove userID * diff --git a/scripts/buildSpecs.ts b/scripts/buildSpecs.ts index 44bf1e6208..147f9b9fe4 100644 --- a/scripts/buildSpecs.ts +++ b/scripts/buildSpecs.ts @@ -1,9 +1,44 @@ -import fsp from 'fs/promises'; +import fsp, { readFile, writeFile } from 'fs/promises'; import { hashElement } from 'folder-hash'; +import yaml from 'js-yaml'; import { exists, run, toAbsolutePath } from './common'; import { createSpinner } from './oraLog'; +import type { Spec } from './pre-gen/setHostsOptions'; + +async function propagateTagsToOperations( + bundledPath: string +): Promise { + if (!(await exists(bundledPath))) { + throw new Error(`Bundled file not found ${bundledPath}.`); + } + + const bundledSpec = yaml.load(await readFile(bundledPath, 'utf8')) as Spec; + + if (bundledSpec.tags.length === 0) { + throw new Error( + `No tags defined for ${bundledPath}, tags are required to properly generate a client.` + ); + } + + const tagsName = bundledSpec.tags.map((tag) => tag.name); + + for (const pathMethods of Object.values(bundledSpec.paths)) { + for (const specMethod of Object.values(pathMethods)) { + specMethod.tags = tagsName; + } + } + + await writeFile( + bundledPath, + yaml.dump(bundledSpec, { + noRefs: true, + }) + ); + + return true; +} async function buildSpec( client: string, @@ -36,16 +71,25 @@ async function buildSpec( spinner.info(`cache not found for ${client}' spec`); } - const spinner = createSpinner(`linting '${client}' spec`, verbose).start(); - await run(`yarn specs:lint ${client}`, { verbose }); - - spinner.text = `building '${client}' spec`; + const spinner = createSpinner(`building ${client} spec`, verbose).start(); + const bundledPath = `specs/bundled/${client}.${outputFormat}`; await run( - `yarn openapi bundle specs/${client}/spec.yml -o specs/bundled/${client}.${outputFormat} --ext ${outputFormat}`, + `yarn openapi bundle specs/${client}/spec.yml -o ${bundledPath} --ext ${outputFormat}`, { verbose } ); - spinner.text = `validating '${client}' spec`; + if ( + (await propagateTagsToOperations(toAbsolutePath(bundledPath))) === false + ) { + throw new Error( + `Unable to propage tags to operations for \`${client}\` spec.` + ); + } + + spinner.text = `linting ${client} spec`; + await run(`yarn specs:lint ${client}`, { verbose }); + + spinner.text = `validating ${client} spec`; await run(`yarn openapi lint specs/bundled/${client}.${outputFormat}`, { verbose, }); diff --git a/scripts/pre-gen/setHostsOptions.ts b/scripts/pre-gen/setHostsOptions.ts index e60fea2063..eeae43775d 100644 --- a/scripts/pre-gen/setHostsOptions.ts +++ b/scripts/pre-gen/setHostsOptions.ts @@ -3,7 +3,7 @@ import { URL } from 'url'; import yaml from 'js-yaml'; -import { toAbsolutePath } from '../common'; +import { exists, toAbsolutePath } from '../common'; import type { Generator } from '../types'; type Server = { @@ -16,8 +16,17 @@ type Server = { }; }; -type Spec = { +type Tag = { + name: string; + description: string; +}; + +type Path = Record>; + +export type Spec = { servers: Server[]; + tags: Tag[]; + paths: Path[]; }; type AdditionalProperties = Partial<{ @@ -53,7 +62,7 @@ export async function setHostsOptions({ const specPath = toAbsolutePath(`specs/bundled/${client}.yml`); - if (!(await stat(specPath))) { + if (!(await exists(specPath))) { throw new Error( `File not found ${specPath}.\nMake sure your run scripts from the root directory using yarn workspace.` ); diff --git a/specs/abtesting/paths/abtest.yml b/specs/abtesting/paths/abtest.yml index 597a491c91..a44ba3c757 100644 --- a/specs/abtesting/paths/abtest.yml +++ b/specs/abtesting/paths/abtest.yml @@ -1,6 +1,4 @@ get: - tags: - - abtesting operationId: getABTest description: > Returns metadata and metrics for A/B test id. @@ -26,8 +24,6 @@ get: $ref: ../../common/responses/IndexNotFound.yml delete: - tags: - - abtesting operationId: deleteABTest description: Deletes the A/B Test and removes all associated metadata & metrics. summary: Deletes the A/B Test. diff --git a/specs/abtesting/paths/abtests.yml b/specs/abtesting/paths/abtests.yml index ff47184489..e1debbe822 100644 --- a/specs/abtesting/paths/abtests.yml +++ b/specs/abtesting/paths/abtests.yml @@ -1,6 +1,4 @@ post: - tags: - - abtesting operationId: addABTests description: > Creates a new A/B test with provided configuration. @@ -48,8 +46,6 @@ post: $ref: ../../common/responses/IndexNotFound.yml get: - tags: - - abtesting operationId: listABTests description: > Fetch all existing A/B tests for App that are available for the current API Key. Returns an array of metadata and metrics. When no data has been processed, the metrics will be returned as null. diff --git a/specs/abtesting/paths/stopABTest.yml b/specs/abtesting/paths/stopABTest.yml index 8dc1801144..4f37b5f9bd 100644 --- a/specs/abtesting/paths/stopABTest.yml +++ b/specs/abtesting/paths/stopABTest.yml @@ -1,6 +1,4 @@ post: - tags: - - abtesting operationId: stopABTest description: > Marks the A/B test as stopped. diff --git a/specs/abtesting/spec.yml b/specs/abtesting/spec.yml index 65e4cc902f..d9098cd5ac 100644 --- a/specs/abtesting/spec.yml +++ b/specs/abtesting/spec.yml @@ -21,7 +21,16 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: abtesting + description: abtesting API reference paths: + # ###################### + # ### Custom request ### + # ###################### + /1{path}: + $ref: ../common/paths/customRequest.yml + /2/abtests: $ref: paths/abtests.yml /2/abtests/{id}: diff --git a/specs/analytics/paths/click/getAverageClickPosition.yml b/specs/analytics/paths/click/getAverageClickPosition.yml index aa87050fcc..dbe7247408 100644 --- a/specs/analytics/paths/click/getAverageClickPosition.yml +++ b/specs/analytics/paths/click/getAverageClickPosition.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getAverageClickPosition description: Returns the average click position. The endpoint returns a value for the complete given time range, as well as a value per day. summary: Returns the average click position. diff --git a/specs/analytics/paths/click/getClickPositions.yml b/specs/analytics/paths/click/getClickPositions.yml index a4a530015d..98760de04b 100644 --- a/specs/analytics/paths/click/getClickPositions.yml +++ b/specs/analytics/paths/click/getClickPositions.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getClickPositions description: Returns the distribution of clicks per range of positions. summary: Returns the distribution of clicks per range of positions. diff --git a/specs/analytics/paths/click/getClickThroughRate.yml b/specs/analytics/paths/click/getClickThroughRate.yml index b10e6da827..b141d5250e 100644 --- a/specs/analytics/paths/click/getClickThroughRate.yml +++ b/specs/analytics/paths/click/getClickThroughRate.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getClickThroughRate description: Returns a click-through rate (CTR). The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of clicks and searches used to compute the rates. summary: Returns a click-through rate (CTR). diff --git a/specs/analytics/paths/click/getConversionRate.yml b/specs/analytics/paths/click/getConversionRate.yml index 84c012c759..5f50250955 100644 --- a/specs/analytics/paths/click/getConversionRate.yml +++ b/specs/analytics/paths/click/getConversionRate.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getConversationRate description: Returns a conversion rate (CR). The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of conversion and searches used to compute the rates. summary: Returns a conversion rate (CR). diff --git a/specs/analytics/paths/search/getNoClickRate.yml b/specs/analytics/paths/search/getNoClickRate.yml index 2e878fe808..bc6dca7686 100644 --- a/specs/analytics/paths/search/getNoClickRate.yml +++ b/specs/analytics/paths/search/getNoClickRate.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getNoClickRate description: Returns the rate at which searches didn't lead to any clicks. The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of searches and searches without clicks. summary: Returns the rate at which searches didn't lead to any clicks. diff --git a/specs/analytics/paths/search/getNoResultsRate.yml b/specs/analytics/paths/search/getNoResultsRate.yml index 3e74c2e119..4fc6413b5d 100644 --- a/specs/analytics/paths/search/getNoResultsRate.yml +++ b/specs/analytics/paths/search/getNoResultsRate.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getNoResultsRate description: Returns the rate at which searches didn't return any results. The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of searches and searches without results used to compute the rates. summary: Returns the rate at which searches didn't return any results. diff --git a/specs/analytics/paths/search/getSearchesCount.yml b/specs/analytics/paths/search/getSearchesCount.yml index 4c670c585e..f11e4e909a 100644 --- a/specs/analytics/paths/search/getSearchesCount.yml +++ b/specs/analytics/paths/search/getSearchesCount.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getSearchesCount description: Returns the number of searches across the given time range. The endpoint returns a value for the complete given time range, as well as a value per day. summary: Returns the number of searches across the given time range. diff --git a/specs/analytics/paths/search/getSearchesNoClicks.yml b/specs/analytics/paths/search/getSearchesNoClicks.yml index 2cc34456f3..279cf168ff 100644 --- a/specs/analytics/paths/search/getSearchesNoClicks.yml +++ b/specs/analytics/paths/search/getSearchesNoClicks.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getSearchesNoClicks description: Returns top searches that didn't lead to any clicks. Limited to the 1000 most frequent ones. For each search, also returns the average number of found hits. summary: Returns top searches that didn't lead to any clicks. diff --git a/specs/analytics/paths/search/getSearchesNoResults.yml b/specs/analytics/paths/search/getSearchesNoResults.yml index ade6adcc47..dd97e46961 100644 --- a/specs/analytics/paths/search/getSearchesNoResults.yml +++ b/specs/analytics/paths/search/getSearchesNoResults.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getSearchesNoResults description: Returns top searches that didn't return any results. Limited to the 1000 most frequent ones. summary: Returns top searches that didn't return any results. diff --git a/specs/analytics/paths/search/getTopCountries.yml b/specs/analytics/paths/search/getTopCountries.yml index 933a8fccc3..733f5b6b74 100644 --- a/specs/analytics/paths/search/getTopCountries.yml +++ b/specs/analytics/paths/search/getTopCountries.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getTopCountries description: Returns top countries. Limited to the 1000 most frequent ones. summary: Returns top countries. diff --git a/specs/analytics/paths/search/getTopFilterAttributes.yml b/specs/analytics/paths/search/getTopFilterAttributes.yml index 2cb343b5ad..b2176fa2da 100644 --- a/specs/analytics/paths/search/getTopFilterAttributes.yml +++ b/specs/analytics/paths/search/getTopFilterAttributes.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getTopFilterAttributes description: Returns top filter attributes. Limited to the 1000 most used filters. summary: Returns top filter attributes. diff --git a/specs/analytics/paths/search/getTopFilterForAttribute.yml b/specs/analytics/paths/search/getTopFilterForAttribute.yml index d3b86a4dce..49ae665be7 100644 --- a/specs/analytics/paths/search/getTopFilterForAttribute.yml +++ b/specs/analytics/paths/search/getTopFilterForAttribute.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getTopFilterForAttribute description: Returns top filters for the given attribute. Limited to the 1000 most used filters. summary: Returns top filters for the given attribute. diff --git a/specs/analytics/paths/search/getTopFiltersNoResults.yml b/specs/analytics/paths/search/getTopFiltersNoResults.yml index f19ae14ddf..039b94aa3b 100644 --- a/specs/analytics/paths/search/getTopFiltersNoResults.yml +++ b/specs/analytics/paths/search/getTopFiltersNoResults.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getTopFiltersNoResults description: Returns top filters with no results. Limited to the 1000 most used filters. summary: Returns top filters with no results. diff --git a/specs/analytics/paths/search/getTopHits.yml b/specs/analytics/paths/search/getTopHits.yml index 2373d2ea47..53060831b0 100644 --- a/specs/analytics/paths/search/getTopHits.yml +++ b/specs/analytics/paths/search/getTopHits.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getTopHits description: Returns top hits. Limited to the 1000 most frequent ones. summary: Returns top hits. diff --git a/specs/analytics/paths/search/getTopSearches.yml b/specs/analytics/paths/search/getTopSearches.yml index 64afb094f4..78cf649f52 100644 --- a/specs/analytics/paths/search/getTopSearches.yml +++ b/specs/analytics/paths/search/getTopSearches.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getTopSearches description: Returns top searches. Limited to the 1000 most frequent ones. For each search, also returns the average number of hits returned. summary: Returns top searches. diff --git a/specs/analytics/paths/search/getUsersCount.yml b/specs/analytics/paths/search/getUsersCount.yml index a161864be1..f17cf4a1ea 100644 --- a/specs/analytics/paths/search/getUsersCount.yml +++ b/specs/analytics/paths/search/getUsersCount.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getUsersCount description: Returns the distinct count of users across the given time range. The endpoint returns a value for the complete given time range, as well as a value per day. summary: Returns the distinct count of users across the given time range. diff --git a/specs/analytics/paths/status/getStatus.yml b/specs/analytics/paths/status/getStatus.yml index 704d6fde0b..a9df74b216 100644 --- a/specs/analytics/paths/status/getStatus.yml +++ b/specs/analytics/paths/status/getStatus.yml @@ -1,6 +1,4 @@ get: - tags: - - analytics operationId: getStatus description: Returns the latest update time of the analytics API for a given index. If the index has been recently created and/or no search has been performed yet the updated time will be null. summary: Get latest update time of the analytics API. diff --git a/specs/analytics/spec.yml b/specs/analytics/spec.yml index 892b649b35..001569e309 100644 --- a/specs/analytics/spec.yml +++ b/specs/analytics/spec.yml @@ -21,7 +21,16 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: analytics + description: Analytics API reference paths: + # ###################### + # ### Custom request ### + # ###################### + /1{path}: + $ref: ../common/paths/customRequest.yml + # ################################## # ### Search Analytics Endpoints ### # ################################## diff --git a/specs/bundled/abtesting.yml b/specs/bundled/abtesting.yml index 29195e0205..5cb714cc4e 100644 --- a/specs/bundled/abtesting.yml +++ b/specs/bundled/abtesting.yml @@ -13,29 +13,15 @@ components: type: apiKey in: header name: X-Algolia-API-Key - parameters: - Offset: - in: query - name: offset - description: Position of the starting record. Used for paging. 0 is the first record. - schema: - type: integer - default: 0 - Limit: - in: query - name: limit - description: Number of records to return. Limit is the size of the page. - schema: - type: integer - default: 10 - ID: - in: path - name: id - description: The A/B test ID. - required: true - schema: - type: integer schemas: + ErrorBase: + description: Error. + type: object + additionalProperties: true + properties: + message: + type: string + example: Invalid Application-Id or API-Key abTestID: type: integer description: The A/B test ID. @@ -161,14 +147,6 @@ components: description: List of A/B tests. items: $ref: '#/components/schemas/ABTest' - ErrorBase: - description: Error. - type: object - additionalProperties: true - properties: - message: - type: string - example: Invalid Application-Id or API-Key abTestsVariant: type: object additionalProperties: false @@ -240,6 +218,28 @@ components: application/json: schema: $ref: '#/components/schemas/ErrorBase' + parameters: + Offset: + in: query + name: offset + description: Position of the starting record. Used for paging. 0 is the first record. + schema: + type: integer + default: 0 + Limit: + in: query + name: limit + description: Number of records to return. Limit is the size of the page. + schema: + type: integer + default: 10 + ID: + in: path + name: id + description: The A/B test ID. + required: true + schema: + type: integer servers: - url: https://analytics.{region}.algolia.com variables: @@ -252,11 +252,169 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: abtesting + description: abtesting API reference paths: - /2/abtests: + /1{path}: + get: + operationId: getCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - abtesting post: + operationId: postCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - abtesting + put: + operationId: putCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - abtesting + delete: + operationId: deleteCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' tags: - abtesting + /2/abtests: + post: operationId: addABTests description: > Creates a new A/B test with provided configuration. @@ -304,9 +462,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - get: tags: - abtesting + get: operationId: listABTests description: > Fetch all existing A/B tests for App that are available for the current @@ -348,10 +506,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/abtests/{id}: - get: tags: - abtesting + /2/abtests/{id}: + get: operationId: getABTest description: > Returns metadata and metrics for A/B test id. @@ -376,9 +534,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - delete: tags: - abtesting + delete: operationId: deleteABTest description: Deletes the A/B Test and removes all associated metadata & metrics. summary: Deletes the A/B Test. @@ -399,10 +557,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/abtests/{id}/stop: - post: tags: - abtesting + /2/abtests/{id}/stop: + post: operationId: stopABTest description: > Marks the A/B test as stopped. @@ -429,3 +587,5 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' + tags: + - abtesting diff --git a/specs/bundled/analytics.yml b/specs/bundled/analytics.yml index ffdfbe25fc..a83acee55d 100644 --- a/specs/bundled/analytics.yml +++ b/specs/bundled/analytics.yml @@ -13,101 +13,15 @@ components: type: apiKey in: header name: X-Algolia-API-Key - parameters: - Index: - in: query - name: index - description: The index name to target. - required: true - schema: - type: string - ClickAnalytics: - in: query - name: clickAnalytics - description: Whether to include the click-through and conversion rates for a search. - schema: - type: boolean - default: false - StartDate: - in: query - name: startDate - description: >- - The lower bound timestamp (a date, a string like "2006-01-02") of the - period to analyze. - schema: - type: string - example: 1999-09-19 - pattern: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$ - EndDate: - in: query - name: endDate - description: >- - The upper bound timestamp (a date, a string like "2006-01-02") of the - period to analyze. - schema: - type: string - example: 2000-01-21 - pattern: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$ - OrderBy: - in: query - name: orderBy - description: Reorder the results. - schema: - type: string - enum: - - searchCount - - clickThroughRate - - conversionRate - - averageClickPosition - default: searchCount - Direction: - in: query - name: direction - description: The sorting of the result. - schema: - type: string - enum: - - asc - - desc - default: asc - Limit: - in: query - name: limit - description: Number of records to return. Limit is the size of the page. - schema: - type: integer - default: 10 - Offset: - in: query - name: offset - description: Position of the starting record. Used for paging. 0 is the first record. - schema: - type: integer - default: 0 - Tags: - name: tags - in: query - description: >- - Filter metrics on the provided tags. Each tag must correspond to an - analyticsTags set at search time. Multiple tags can be combined with the - operators OR and AND. If a tag contains characters like spaces or - parentheses, it should be URL encoded. - schema: - type: string - Search: - in: query - name: search - description: The query term to search for. Must match the exact user input. - schema: - type: string - Attribute: - in: path - name: attribute - description: The exact name of the attribute. - required: true - schema: - type: string schemas: + ErrorBase: + description: Error. + type: object + additionalProperties: true + properties: + message: + type: string + example: Invalid Application-Id or API-Key search: description: The search query. type: string @@ -202,14 +116,6 @@ components: $ref: '#/components/schemas/conversionCount' nbHits: $ref: '#/components/schemas/nbHits' - ErrorBase: - description: Error. - type: object - additionalProperties: true - properties: - message: - type: string - example: Invalid Application-Id or API-Key date: type: string description: Date of the event. @@ -401,6 +307,100 @@ components: application/json: schema: $ref: '#/components/schemas/ErrorBase' + parameters: + Index: + in: query + name: index + description: The index name to target. + required: true + schema: + type: string + ClickAnalytics: + in: query + name: clickAnalytics + description: Whether to include the click-through and conversion rates for a search. + schema: + type: boolean + default: false + StartDate: + in: query + name: startDate + description: >- + The lower bound timestamp (a date, a string like "2006-01-02") of the + period to analyze. + schema: + type: string + example: 1999-09-19T00:00:00.000Z + pattern: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$ + EndDate: + in: query + name: endDate + description: >- + The upper bound timestamp (a date, a string like "2006-01-02") of the + period to analyze. + schema: + type: string + example: 2000-01-21T00:00:00.000Z + pattern: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$ + OrderBy: + in: query + name: orderBy + description: Reorder the results. + schema: + type: string + enum: + - searchCount + - clickThroughRate + - conversionRate + - averageClickPosition + default: searchCount + Direction: + in: query + name: direction + description: The sorting of the result. + schema: + type: string + enum: + - asc + - desc + default: asc + Limit: + in: query + name: limit + description: Number of records to return. Limit is the size of the page. + schema: + type: integer + default: 10 + Offset: + in: query + name: offset + description: Position of the starting record. Used for paging. 0 is the first record. + schema: + type: integer + default: 0 + Tags: + name: tags + in: query + description: >- + Filter metrics on the provided tags. Each tag must correspond to an + analyticsTags set at search time. Multiple tags can be combined with the + operators OR and AND. If a tag contains characters like spaces or + parentheses, it should be URL encoded. + schema: + type: string + Search: + in: query + name: search + description: The query term to search for. Must match the exact user input. + schema: + type: string + Attribute: + in: path + name: attribute + description: The exact name of the attribute. + required: true + schema: + type: string servers: - url: https://analytics.{region}.algolia.com variables: @@ -413,11 +413,169 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: analytics + description: Analytics API reference paths: - /2/searches: + /1{path}: get: + operationId: getCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - analytics + post: + operationId: postCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' tags: - analytics + put: + operationId: putCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - analytics + delete: + operationId: deleteCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - analytics + /2/searches: + get: operationId: getTopSearches description: >- Returns top searches. Limited to the 1000 most frequent ones. For each @@ -450,10 +608,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/searches/count: - get: tags: - analytics + /2/searches/count: + get: operationId: getSearchesCount description: >- Returns the number of searches across the given time range. The endpoint @@ -502,10 +660,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/searches/noResults: - get: tags: - analytics + /2/searches/noResults: + get: operationId: getSearchesNoResults description: >- Returns top searches that didn't return any results. Limited to the 1000 @@ -555,10 +713,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/searches/noClicks: - get: tags: - analytics + /2/searches/noClicks: + get: operationId: getSearchesNoClicks description: >- Returns top searches that didn't lead to any clicks. Limited to the 1000 @@ -609,10 +767,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/searches/noResultRate: - get: tags: - analytics + /2/searches/noResultRate: + get: operationId: getNoResultsRate description: >- Returns the rate at which searches didn't return any results. The @@ -676,10 +834,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/searches/noClickRate: - get: tags: - analytics + /2/searches/noClickRate: + get: operationId: getNoClickRate description: >- Returns the rate at which searches didn't lead to any clicks. The @@ -743,10 +901,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/hits: - get: tags: - analytics + /2/hits: + get: operationId: getTopHits description: Returns top hits. Limited to the 1000 most frequent ones. summary: Returns top hits. @@ -776,10 +934,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/users/count: - get: tags: - analytics + /2/users/count: + get: operationId: getUsersCount description: >- Returns the distinct count of users across the given time range. The @@ -828,10 +986,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/filters: - get: tags: - analytics + /2/filters: + get: operationId: getTopFilterAttributes description: Returns top filter attributes. Limited to the 1000 most used filters. summary: Returns top filter attributes. @@ -858,10 +1016,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/filters/{attribute}: - get: tags: - analytics + /2/filters/{attribute}: + get: operationId: getTopFilterForAttribute description: >- Returns top filters for the given attribute. Limited to the 1000 most @@ -891,10 +1049,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/filters/noResults: - get: tags: - analytics + /2/filters/noResults: + get: operationId: getTopFiltersNoResults description: >- Returns top filters with no results. Limited to the 1000 most used @@ -923,10 +1081,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/countries: - get: tags: - analytics + /2/countries: + get: operationId: getTopCountries description: Returns top countries. Limited to the 1000 most frequent ones. summary: Returns top countries. @@ -972,10 +1130,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/clicks/averageClickPosition: - get: tags: - analytics + /2/clicks/averageClickPosition: + get: operationId: getAverageClickPosition description: >- Returns the average click position. The endpoint returns a value for the @@ -1029,10 +1187,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/clicks/positions: - get: tags: - analytics + /2/clicks/positions: + get: operationId: getClickPositions description: Returns the distribution of clicks per range of positions. summary: Returns the distribution of clicks per range of positions. @@ -1086,10 +1244,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/clicks/clickThroughRate: - get: tags: - analytics + /2/clicks/clickThroughRate: + get: operationId: getClickThroughRate description: >- Returns a click-through rate (CTR). The endpoint returns a value for the @@ -1150,10 +1308,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/conversions/conversionRate: - get: tags: - analytics + /2/conversions/conversionRate: + get: operationId: getConversationRate description: >- Returns a conversion rate (CR). The endpoint returns a value for the @@ -1214,10 +1372,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /2/status: - get: tags: - analytics + /2/status: + get: operationId: getStatus description: >- Returns the latest update time of the analytics API for a given index. @@ -1248,3 +1406,5 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' + tags: + - analytics diff --git a/specs/bundled/insights.yml b/specs/bundled/insights.yml index 44af652d88..214abd6336 100644 --- a/specs/bundled/insights.yml +++ b/specs/bundled/insights.yml @@ -59,11 +59,169 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: insights + description: Insights API reference paths: - /1/events: + /1{path}: + get: + operationId: getCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - insights post: + operationId: postCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' tags: - insights + put: + operationId: putCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - insights + delete: + operationId: deleteCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - insights + /1/events: + post: operationId: pushEvents description: This command pushes an array of events. summary: Pushes an array of events. @@ -170,3 +328,5 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' + tags: + - insights diff --git a/specs/bundled/personalization.yml b/specs/bundled/personalization.yml index 5107f8c6ba..1283476eea 100644 --- a/specs/bundled/personalization.yml +++ b/specs/bundled/personalization.yml @@ -13,22 +13,7 @@ components: type: apiKey in: header name: X-Algolia-API-Key - parameters: - UserToken: - name: userToken - in: path - required: true - description: >- - userToken representing the user for which to fetch the Personalization - profile. - schema: - type: string schemas: - userToken: - type: string - description: >- - userToken representing the user for which to fetch the Personalization - profile. ErrorBase: description: Error. type: object @@ -37,6 +22,11 @@ components: message: type: string example: Invalid Application-Id or API-Key + userToken: + type: string + description: >- + userToken representing the user for which to fetch the Personalization + profile. score: type: integer description: The score for the event. @@ -117,6 +107,16 @@ components: application/json: schema: $ref: '#/components/schemas/ErrorBase' + parameters: + UserToken: + name: userToken + in: path + required: true + description: >- + userToken representing the user for which to fetch the Personalization + profile. + schema: + type: string servers: - url: https://personalization.{region}.algolia.com variables: @@ -128,11 +128,169 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: personalization + description: Personalization API reference paths: - /1/profiles/personalization/{userToken}: + /1{path}: get: + operationId: getCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' tags: - personalization + post: + operationId: postCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - personalization + put: + operationId: putCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - personalization + delete: + operationId: deleteCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - personalization + /1/profiles/personalization/{userToken}: + get: operationId: getUserTokenProfile description: >- The profile is structured by facet name used in the strategy. Each facet @@ -174,10 +332,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/profiles/{userToken}: - delete: tags: - personalization + /1/profiles/{userToken}: + delete: operationId: deleteUserProfile description: >- Returns, as part of the response, a date until which the data can safely @@ -218,10 +376,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/strategies/personalization: - post: tags: - personalization + /1/strategies/personalization: + post: operationId: setPersonalizationStrategy description: >- A strategy defines the events and facets that impact user profiles and @@ -256,6 +414,8 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' + tags: + - personalization get: tags: - personalization diff --git a/specs/bundled/predict.yml b/specs/bundled/predict.yml index d6626922ab..8522a01eb8 100644 --- a/specs/bundled/predict.yml +++ b/specs/bundled/predict.yml @@ -13,16 +13,6 @@ components: type: apiKey in: header name: X-Algolia-API-Key - parameters: - userID: - name: userID - in: path - required: true - schema: - type: string - description: >- - User ID for authenticated users or cookie ID for non-authenticated - repeated users (visitors). schemas: ErrorBase: description: Error. @@ -33,8 +23,14 @@ components: type: string example: Invalid Application-Id or API-Key responses: - UserNotFound: - description: User not found. + BadRequest: + description: Bad request or request arguments. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBase' + FeatureNotEnabled: + description: This feature is not enabled on your Algolia account. content: application/json: schema: @@ -45,16 +41,196 @@ components: application/json: schema: $ref: '#/components/schemas/ErrorBase' + IndexNotFound: + description: Index not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBase' + UserNotFound: + description: User not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBase' + parameters: + userID: + name: userID + in: path + required: true + schema: + type: string + description: >- + User ID for authenticated users or cookie ID for non-authenticated + repeated users (visitors). servers: - url: https://predict-api-oslcbws3zq-ew.a.run.app security: - appId: [] apiKey: [] +tags: + - name: predict + description: Predict API reference paths: - /1/users/{userID}/fetch: + /1{path}: + get: + operationId: getCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - predict post: + operationId: postCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' tags: - predict + put: + operationId: putCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - predict + delete: + operationId: deleteCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - predict + /1/users/{userID}/fetch: + post: operationId: fetchUserProfile description: >- Get predictions, properties (raw, computed or custom) and segments @@ -193,3 +369,5 @@ paths: $ref: '#/components/responses/UserNotFound' '405': $ref: '#/components/responses/MethodNotAllowed' + tags: + - predict diff --git a/specs/bundled/query-suggestions.yml b/specs/bundled/query-suggestions.yml index ae9ace878f..71ce078413 100644 --- a/specs/bundled/query-suggestions.yml +++ b/specs/bundled/query-suggestions.yml @@ -14,6 +14,14 @@ components: in: header name: X-Algolia-API-Key schemas: + ErrorBase: + description: Error. + type: object + additionalProperties: true + properties: + message: + type: string + example: Invalid Application-Id or API-Key indexName: type: string description: Source index name. @@ -134,14 +142,6 @@ components: description: >- List of words and patterns to exclude from the Query Suggestions index. - ErrorBase: - description: Error. - type: object - additionalProperties: true - properties: - message: - type: string - example: Invalid Application-Id or API-Key SourceIndex: type: object additionalProperties: false @@ -205,8 +205,14 @@ components: type: string description: Index name to target. responses: - Unauthorized: - description: Unauthorized + BadRequest: + description: Bad request or request arguments. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBase' + FeatureNotEnabled: + description: This feature is not enabled on your Algolia account. content: application/json: schema: @@ -217,6 +223,18 @@ components: application/json: schema: $ref: '#/components/schemas/ErrorBase' + IndexNotFound: + description: Index not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBase' + Unauthorized: + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBase' StatusUnprocessableEntity: description: Status unprocessable entity content: @@ -249,18 +267,6 @@ components: type: string example: Success description: Message of the response. - BadRequest: - description: Bad request or request arguments. - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBase' - IndexNotFound: - description: Index not found. - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorBase' parameters: IndexName: name: indexName @@ -281,11 +287,169 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: query-suggestions + description: Query Suggestions API reference paths: - /1/configs: + /1{path}: + get: + operationId: getCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - query-suggestions post: + operationId: postCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' tags: - query-suggestions + put: + operationId: putCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - query-suggestions + delete: + operationId: deleteCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - query-suggestions + /1/configs: + post: operationId: createConfig description: >- Create a configuration of a Query Suggestions index. There's a limit of @@ -310,6 +474,8 @@ paths: $ref: '#/components/responses/StatusUnprocessableEntity' '500': $ref: '#/components/responses/InternalError' + tags: + - query-suggestions get: tags: - query-suggestions @@ -339,8 +505,6 @@ paths: $ref: '#/components/responses/InternalError' /1/configs/{indexName}: put: - tags: - - query-suggestions operationId: updateConfig description: Update the configuration of a Query Suggestions index. summary: Update the configuration of a Query Suggestions index. @@ -359,6 +523,8 @@ paths: $ref: '#/components/responses/Unauthorized' '500': $ref: '#/components/responses/InternalError' + tags: + - query-suggestions delete: tags: - query-suggestions @@ -410,8 +576,6 @@ paths: $ref: '#/components/responses/InternalError' /1/configs/{indexName}/status: get: - tags: - - query-suggestions operationId: getConfigStatus description: > Get the status of a Query Suggestion's index. @@ -451,10 +615,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '500': $ref: '#/components/responses/InternalError' - /1/logs/{indexName}: - get: tags: - query-suggestions + /1/logs/{indexName}: + get: operationId: getLogFile description: Get the log file of the last build of a single Query Suggestion index. summary: Get the log file of the last build of a single Query Suggestion index. @@ -506,3 +670,5 @@ paths: $ref: '#/components/responses/IndexNotFound' '500': $ref: '#/components/responses/InternalError' + tags: + - query-suggestions diff --git a/specs/bundled/recommend.yml b/specs/bundled/recommend.yml index 8119898e07..8b96f1ec06 100644 --- a/specs/bundled/recommend.yml +++ b/specs/bundled/recommend.yml @@ -14,6 +14,14 @@ components: in: header name: X-Algolia-API-Key schemas: + ErrorBase: + description: Error. + type: object + additionalProperties: true + properties: + message: + type: string + example: Invalid Application-Id or API-Key indexName: type: string example: products @@ -810,14 +818,6 @@ components: allOf: - $ref: '#/components/schemas/baseSearchResponse' - $ref: '#/components/schemas/recommendHits' - ErrorBase: - description: Error. - type: object - additionalProperties: true - properties: - message: - type: string - example: Invalid Application-Id or API-Key responses: BadRequest: description: Bad request or request arguments. @@ -867,11 +867,169 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: recommend + description: Recommend API reference paths: - /1/indexes/*/recommendations: + /1{path}: + get: + operationId: getCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - recommend post: + operationId: postCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - recommend + put: + operationId: putCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' tags: - recommend + delete: + operationId: deleteCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - recommend + /1/indexes/*/recommendations: + post: operationId: getRecommendations description: Returns recommendations for a specific model and objectID. summary: Returns recommendations for a specific model and objectID. @@ -950,3 +1108,5 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' + tags: + - recommend diff --git a/specs/bundled/search.yml b/specs/bundled/search.yml index 6a0734a7fb..b62e49affd 100644 --- a/specs/bundled/search.yml +++ b/specs/bundled/search.yml @@ -13,124 +13,15 @@ components: type: apiKey in: header name: X-Algolia-API-Key - parameters: - IndexName: - name: indexName - in: path - description: The index in which to perform the request. - required: true - schema: - type: string - example: myIndexName - ObjectID: - name: objectID - in: path - description: Unique identifier of an object. - required: true - schema: - type: string - example: '123' - ForwardToReplicas: - in: query - name: forwardToReplicas - description: >- - When true, changes are also propagated to replicas of the given - indexName. - schema: - type: boolean - ReplaceExistingSynonyms: - in: query - name: replaceExistingSynonyms - schema: - type: boolean - description: Replace all synonyms of the index with the ones sent with this request. - Query: - in: query - name: query - description: Search for specific synonyms matching this string. - schema: - type: string - default: '' - Type: - in: query - name: type - description: Only search for specific types of synonyms. - schema: - $ref: '#/components/schemas/SynonymType' - PageDefault0: - in: query - name: page - description: >- - Requested page (zero-based). When specified, will retrieve a specific - page; the page size is implicitly set to 100. When null, will retrieve - all indices (no pagination). - schema: - type: integer - nullable: true - default: 0 - HitsPerPage: - in: query - name: hitsPerPage - description: Maximum number of objects to retrieve. - schema: - type: integer - default: 100 - KeyString: - in: path - name: key - required: true - schema: - type: string - example: myAPIKey - description: API Key string. - ClearExistingRules: - in: query - name: clearExistingRules - required: false - schema: - type: boolean - description: >- - When true, existing Rules are cleared before adding this batch. When - false, existing Rules are kept. - DictionaryName: - in: path - name: dictionaryName - description: The dictionary to search in. - required: true - schema: - enum: - - plurals - - stopwords - - compounds - type: string - Page: - in: query - name: page - description: >- - Requested page (zero-based). When specified, will retrieve a specific - page; the page size is implicitly set to 100. When null, will retrieve - all indices (no pagination). - schema: - type: integer - nullable: true - default: null - UserIDInQuery: - name: X-Algolia-User-ID - description: userID to assign. - in: query - required: true - schema: - type: string - pattern: ^[a-zA-Z0-9 \-*.]+$ - UserIDInPath: - name: userID - description: userID to assign. - in: path - required: true - schema: - type: string - pattern: ^[a-zA-Z0-9 \-*.]+$ schemas: + ErrorBase: + description: Error. + type: object + additionalProperties: true + properties: + message: + type: string + example: Invalid Application-Id or API-Key paramsAsString: description: Search parameters as URL-encoded query string. type: string @@ -930,14 +821,6 @@ components: allOf: - $ref: '#/components/schemas/baseSearchResponse' - $ref: '#/components/schemas/searchHits' - ErrorBase: - description: Error. - type: object - additionalProperties: true - properties: - message: - type: string - example: Invalid Application-Id or API-Key indexName: type: string example: products @@ -1815,44 +1698,319 @@ components: content: application/json: schema: - title: createdAtResponse - description: The response with a createdAt timestamp. - additionalProperties: false - type: object - required: - - createdAt - properties: - createdAt: - $ref: '#/components/schemas/createdAt' -servers: - - url: https://{appId}.algolianet.com - variables: - appId: - default: myAppId - - url: https://{appId}-1.algolianet.com - variables: - appId: - default: myAppId - - url: https://{appId}-2.algolianet.com - variables: - appId: - default: myAppId - - url: https://{appId}-3.algolianet.com - variables: - appId: - default: myAppId - - url: https://{appId}-dsn.algolianet.com - variables: - appId: - default: myAppId -security: - - appId: [] - apiKey: [] -paths: - /1/indexes/{indexName}/query: - post: + title: createdAtResponse + description: The response with a createdAt timestamp. + additionalProperties: false + type: object + required: + - createdAt + properties: + createdAt: + $ref: '#/components/schemas/createdAt' + parameters: + IndexName: + name: indexName + in: path + description: The index in which to perform the request. + required: true + schema: + type: string + example: myIndexName + ObjectID: + name: objectID + in: path + description: Unique identifier of an object. + required: true + schema: + type: string + example: '123' + ForwardToReplicas: + in: query + name: forwardToReplicas + description: >- + When true, changes are also propagated to replicas of the given + indexName. + schema: + type: boolean + ReplaceExistingSynonyms: + in: query + name: replaceExistingSynonyms + schema: + type: boolean + description: Replace all synonyms of the index with the ones sent with this request. + Query: + in: query + name: query + description: Search for specific synonyms matching this string. + schema: + type: string + default: '' + Type: + in: query + name: type + description: Only search for specific types of synonyms. + schema: + $ref: '#/components/schemas/SynonymType' + PageDefault0: + in: query + name: page + description: >- + Requested page (zero-based). When specified, will retrieve a specific + page; the page size is implicitly set to 100. When null, will retrieve + all indices (no pagination). + schema: + type: integer + nullable: true + default: 0 + HitsPerPage: + in: query + name: hitsPerPage + description: Maximum number of objects to retrieve. + schema: + type: integer + default: 100 + KeyString: + in: path + name: key + required: true + schema: + type: string + example: myAPIKey + description: API Key string. + ClearExistingRules: + in: query + name: clearExistingRules + required: false + schema: + type: boolean + description: >- + When true, existing Rules are cleared before adding this batch. When + false, existing Rules are kept. + DictionaryName: + in: path + name: dictionaryName + description: The dictionary to search in. + required: true + schema: + enum: + - plurals + - stopwords + - compounds + type: string + Page: + in: query + name: page + description: >- + Requested page (zero-based). When specified, will retrieve a specific + page; the page size is implicitly set to 100. When null, will retrieve + all indices (no pagination). + schema: + type: integer + nullable: true + default: null + UserIDInQuery: + name: X-Algolia-User-ID + description: userID to assign. + in: query + required: true + schema: + type: string + pattern: ^[a-zA-Z0-9 \-*.]+$ + UserIDInPath: + name: userID + description: userID to assign. + in: path + required: true + schema: + type: string + pattern: ^[a-zA-Z0-9 \-*.]+$ +servers: + - url: https://{appId}.algolianet.com + variables: + appId: + default: myAppId + - url: https://{appId}-1.algolianet.com + variables: + appId: + default: myAppId + - url: https://{appId}-2.algolianet.com + variables: + appId: + default: myAppId + - url: https://{appId}-3.algolianet.com + variables: + appId: + default: myAppId + - url: https://{appId}-dsn.algolianet.com + variables: + appId: + default: myAppId +security: + - appId: [] + apiKey: [] +tags: + - name: search + description: Search API reference +paths: + /1{path}: + get: + operationId: getCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - search + post: + operationId: postCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - search + put: + operationId: putCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - search + delete: + operationId: deleteCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' tags: - search + /1/indexes/{indexName}/query: + post: operationId: search description: Get search results. summary: Get search results. @@ -1879,10 +2037,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/*/queries: - post: tags: - search + /1/indexes/*/queries: + post: operationId: multipleQueries description: Get search results for the given requests. summary: Get search results for the given requests. @@ -1943,10 +2101,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/facets/{facetName}/query: - post: tags: - search + /1/indexes/{indexName}/facets/{facetName}/query: + post: operationId: searchForFacetValues summary: Search for values of a given facet description: >- @@ -2018,10 +2176,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/browse: - post: tags: - search + /1/indexes/{indexName}/browse: + post: operationId: browse summary: Retrieve all index content. description: > @@ -2064,10 +2222,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}: - post: tags: - search + /1/indexes/{indexName}: + post: operationId: saveObject description: Add an object to the index, automatically assigning it an object ID. summary: Add an object to the index. @@ -2104,9 +2262,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - delete: tags: - search + delete: operationId: deleteIndex summary: Delete index. description: Delete an existing index. @@ -2123,10 +2281,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/{objectID}: - put: tags: - search + /1/indexes/{indexName}/{objectID}: + put: operationId: addOrUpdateObject summary: Add or replace an object with a given object ID. description: >- @@ -2153,9 +2311,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - get: tags: - search + get: operationId: getObject summary: Retrieve one object from the index. description: Retrieve one object from the index. @@ -2190,9 +2348,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - delete: tags: - search + delete: operationId: deleteObject summary: Delete object. description: Delete an existing object. @@ -2210,10 +2368,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/deleteByQuery: - post: tags: - search + /1/indexes/{indexName}/deleteByQuery: + post: operationId: deleteBy summary: Delete all records matching the query. description: > @@ -2242,10 +2400,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/clear: - post: tags: - search + /1/indexes/{indexName}/clear: + post: operationId: clearObjects summary: clear all objects from an index. description: >- @@ -2264,10 +2422,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/{objectID}/partial: - post: tags: - search + /1/indexes/{indexName}/{objectID}/partial: + post: operationId: partialUpdateObject summary: Partially update an object. description: > @@ -2316,10 +2474,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/batch: - post: tags: - search + /1/indexes/{indexName}/batch: + post: operationId: batch description: Performs multiple write operations in a single API call. summary: Performs multiple write operations in a single API call. @@ -2338,7 +2496,7 @@ paths: requests: type: array items: - title: operation + title: batchOperation type: object additionalProperties: false properties: @@ -2371,10 +2529,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/*/batch: - post: tags: - search + /1/indexes/*/batch: + post: operationId: multipleBatch description: >- Perform multiple write operations, potentially targeting multiple @@ -2393,7 +2551,7 @@ paths: requests: type: array items: - title: Operation. + title: multipleBatchOperation type: object additionalProperties: false properties: @@ -2430,10 +2588,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/*/objects: - post: tags: - search + /1/indexes/*/objects: + post: operationId: getObjects summary: Retrieve one or more objects. description: >- @@ -2498,10 +2656,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/settings: - get: tags: - search + /1/indexes/{indexName}/settings: + get: operationId: getSettings description: Retrieve settings of a given indexName. summary: Retrieve settings of a given indexName. @@ -2522,9 +2680,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - put: tags: - search + put: operationId: setSettings description: >- Update settings of a given indexName. Only specified settings are @@ -2551,10 +2709,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/synonyms/{objectID}: - put: tags: - search + /1/indexes/{indexName}/synonyms/{objectID}: + put: operationId: saveSynonym summary: Save synonym. description: >- @@ -2598,9 +2756,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - get: tags: - search + get: operationId: getSynonym summary: Get synonym. description: Fetch a synonym object identified by its objectID. @@ -2622,9 +2780,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - delete: tags: - search + delete: operationId: deleteSynonym summary: Delete synonym. description: Delete a single synonyms set, identified by the given objectID. @@ -2643,10 +2801,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/synonyms/batch: - post: tags: - search + /1/indexes/{indexName}/synonyms/batch: + post: operationId: saveSynonyms summary: Save a batch of synonyms. description: >- @@ -2673,10 +2831,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/synonyms/clear: - post: tags: - search + /1/indexes/{indexName}/synonyms/clear: + post: operationId: clearAllSynonyms summary: Clear all synonyms. description: Remove all synonyms from an index. @@ -2694,10 +2852,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/synonyms/search: - post: tags: - search + /1/indexes/{indexName}/synonyms/search: + post: operationId: searchSynonyms summary: Get all synonyms that match a query. description: Search or browse all synonyms, optionally filtering them by type. @@ -2722,10 +2880,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/keys: - post: tags: - search + /1/keys: + post: operationId: addApiKey summary: Create a new API key. description: Add a new API Key with specific permissions/restrictions. @@ -2750,9 +2908,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - get: tags: - search + get: operationId: listApiKeys summary: Get the full list of API Keys. description: List API keys, along with their associated rights. @@ -2781,10 +2939,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/keys/{key}: - put: tags: - search + /1/keys/{key}: + put: operationId: updateApiKey summary: Update an API key. description: Replace every permission of an existing API key. @@ -2821,9 +2979,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - get: tags: - search + get: operationId: getApiKey summary: Get an API key. description: Get the permissions of an API key. @@ -2844,9 +3002,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - delete: tags: - search + delete: operationId: deleteApiKey summary: Delete an API key. description: Delete an existing API Key. @@ -2874,10 +3032,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/keys/{key}/restore: - post: tags: - search + /1/keys/{key}/restore: + post: operationId: restoreApiKey summary: Restore an API key. description: Restore a deleted API key, along with its associated rights. @@ -2898,10 +3056,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/rules/{objectID}: - put: tags: - search + /1/indexes/{indexName}/rules/{objectID}: + put: operationId: saveRule summary: Save/Update a rule. description: Create or update the Rule with the specified objectID. @@ -2930,9 +3088,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - get: tags: - search + get: operationId: getRule summary: Get a rule. description: Retrieve the Rule with the specified objectID. @@ -2954,9 +3112,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - delete: tags: - search + delete: operationId: deleteRule summary: Delete a rule. description: Delete the Rule with the specified objectID. @@ -2975,10 +3133,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/rules/batch: - post: tags: - search + /1/indexes/{indexName}/rules/batch: + post: operationId: batchRules summary: Batch Rules. description: Create or update a batch of Rules. @@ -3006,10 +3164,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/rules/clear: - post: tags: - search + /1/indexes/{indexName}/rules/clear: + post: operationId: clearRules summary: Clear Rules. description: Delete all Rules in the index. @@ -3027,10 +3185,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/rules/search: - post: tags: - search + /1/indexes/{indexName}/rules/search: + post: operationId: searchRules summary: Search for rules. description: Search for rules matching various criteria. @@ -3109,10 +3267,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/dictionaries/{dictionaryName}/batch: - post: tags: - search + /1/dictionaries/{dictionaryName}/batch: + post: operationId: batchDictionaryEntries description: Send a batch of dictionary entries. summary: Send a batch of dictionary entries. @@ -3164,10 +3322,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/dictionaries/{dictionaryName}/search: - post: tags: - search + /1/dictionaries/{dictionaryName}/search: + post: operationId: searchDictionaryEntries description: Search the dictionary entries. summary: Search the dictionary entries. @@ -3204,10 +3362,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/dictionaries/*/settings: - put: tags: - search + /1/dictionaries/*/settings: + put: operationId: setDictionarySettings description: Set dictionary settings. summary: Set dictionary settings. @@ -3238,9 +3396,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - get: tags: - search + get: operationId: getDictionarySettings description: Retrieve dictionaries settings. summary: >- @@ -3268,10 +3426,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/dictionaries/*/languages: - get: tags: - search + /1/dictionaries/*/languages: + get: operationId: getDictionaryLanguages description: List dictionaries supported per language. summary: List dictionaries supported per language. @@ -3293,10 +3451,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/clusters/mapping: - post: tags: - search + /1/clusters/mapping: + post: operationId: assignUserId summary: Assign or Move userID description: > @@ -3336,9 +3494,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - get: tags: - search + get: operationId: listUserIds summary: List userIDs description: > @@ -3378,10 +3536,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/clusters/mapping/batch: - post: tags: - search + /1/clusters/mapping/batch: + post: operationId: batchAssignUserIds summary: Batch assign userIDs description: > @@ -3426,10 +3584,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/clusters/mapping/top: - get: tags: - search + /1/clusters/mapping/top: + get: operationId: getTopUserIds summary: Get top userID description: > @@ -3470,10 +3628,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/clusters/mapping/{userID}: - get: tags: - search + /1/clusters/mapping/{userID}: + get: operationId: getUserId summary: Get userID description: > @@ -3502,9 +3660,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - delete: tags: - search + delete: operationId: removeUserId summary: Remove userID description: > @@ -3536,10 +3694,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/clusters: - get: tags: - search + /1/clusters: + get: operationId: listClusters summary: List clusters description: > @@ -3573,10 +3731,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/clusters/mapping/search: - post: tags: - search + /1/clusters/mapping/search: + post: operationId: searchUserIds summary: Search userID description: > @@ -3684,10 +3842,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/clusters/mapping/pending: - get: tags: - search + /1/clusters/mapping/pending: + get: operationId: hasPendingMappings summary: Has pending mappings description: > @@ -3718,10 +3876,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/security/sources: - get: tags: - search + /1/security/sources: + get: operationId: getSources description: List all allowed sources. summary: List all allowed sources. @@ -3740,6 +3898,8 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' + tags: + - search put: tags: - search @@ -3777,8 +3937,6 @@ paths: $ref: '#/components/responses/IndexNotFound' /1/security/sources/append: post: - tags: - - search operationId: appendSource description: Add a single source to the list of allowed sources. summary: Add a single source. @@ -3800,10 +3958,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/security/sources/{source}: - delete: tags: - search + /1/security/sources/{source}: + delete: operationId: deleteSource description: Remove a single source from the list of allowed sources. summary: Remove a single source. @@ -3837,10 +3995,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/logs: - get: tags: - search + /1/logs: + get: operationId: getLogs description: Return the lastest log entries. summary: Return the lastest log entries. @@ -3982,10 +4140,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/task/{taskID}: - get: tags: - search + /1/indexes/{indexName}/task/{taskID}: + get: operationId: getTask description: Check the current status of a given task. summary: Check the current status of a given task. @@ -4023,10 +4181,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/operation: - post: tags: - search + /1/indexes/{indexName}/operation: + post: operationId: operationIndex summary: Copy/move index. description: Peforms a copy or a move operation on a index. @@ -4067,10 +4225,10 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' - /1/indexes: - get: tags: - search + /1/indexes: + get: operationId: listIndices summary: List existing indexes. description: List existing indexes from an application. @@ -4091,3 +4249,5 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' + tags: + - search diff --git a/specs/bundled/sources.yml b/specs/bundled/sources.yml index dbf7a7e24a..c535cb10db 100644 --- a/specs/bundled/sources.yml +++ b/specs/bundled/sources.yml @@ -14,6 +14,14 @@ components: in: header name: X-Algolia-API-Key schemas: + ErrorBase: + description: Error. + type: object + additionalProperties: true + properties: + message: + type: string + example: Invalid Application-Id or API-Key task: type: object description: A task object. @@ -31,14 +39,6 @@ components: required: - id - type - ErrorBase: - description: Error. - type: object - additionalProperties: true - properties: - message: - type: string - example: Invalid Application-Id or API-Key responses: BadRequest: description: Bad request or request arguments. @@ -46,6 +46,24 @@ components: application/json: schema: $ref: '#/components/schemas/ErrorBase' + FeatureNotEnabled: + description: This feature is not enabled on your Algolia account. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBase' + MethodNotAllowed: + description: Method not allowed with this API key. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBase' + IndexNotFound: + description: Index not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBase' servers: - url: https://data.{region}.algolia.com variables: @@ -57,11 +75,169 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: sources + description: Sources API reference paths: - /1/ingest/url: + /1{path}: + get: + operationId: getCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - sources post: + operationId: postCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' tags: - sources + put: + operationId: putCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - sources + delete: + operationId: deleteCustomRequest + summary: Send requests to the Algolia REST API. + description: >- + The customRequest method allow you to send requests to the Algolia REST + API. + parameters: + - name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs + to be specified. + required: true + schema: + type: string + example: /keys + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '402': + $ref: '#/components/responses/FeatureNotEnabled' + '403': + $ref: '#/components/responses/MethodNotAllowed' + '404': + $ref: '#/components/responses/IndexNotFound' + tags: + - sources + /1/ingest/url: + post: operationId: postIngestUrl summary: Create a new ingestion job via URL. description: Add an ingestion job that will fetch data from an URL. @@ -171,3 +347,5 @@ paths: $ref: '#/components/schemas/task' '400': $ref: '#/components/responses/BadRequest' + tags: + - sources diff --git a/specs/common/paths/customRequest.yml b/specs/common/paths/customRequest.yml new file mode 100644 index 0000000000..f41cadc460 --- /dev/null +++ b/specs/common/paths/customRequest.yml @@ -0,0 +1,15 @@ +get: + operationId: getCustomRequest + $ref: ../schemas/CustomRequest.yml + +post: + operationId: postCustomRequest + $ref: ../schemas/CustomRequest.yml + +put: + operationId: putCustomRequest + $ref: ../schemas/CustomRequest.yml + +delete: + operationId: deleteCustomRequest + $ref: ../schemas/CustomRequest.yml diff --git a/specs/common/schemas/CustomRequest.yml b/specs/common/schemas/CustomRequest.yml new file mode 100644 index 0000000000..97571aadae --- /dev/null +++ b/specs/common/schemas/CustomRequest.yml @@ -0,0 +1,31 @@ +summary: Send requests to the Algolia REST API. +description: The customRequest method allow you to send requests to the Algolia REST API. +parameters: + - name: path + in: path + description: The path of the API endpoint to target, anything after the /1 needs to be specified. + required: true + schema: + type: string + example: /keys +requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object +responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: ../responses/BadRequest.yml + '402': + $ref: ../responses/FeatureNotEnabled.yml + '403': + $ref: ../responses/MethodNotAllowed.yml + '404': + $ref: ../responses/IndexNotFound.yml diff --git a/specs/insights/paths/pushEvents.yml b/specs/insights/paths/pushEvents.yml index 945370372d..90b8c96f31 100644 --- a/specs/insights/paths/pushEvents.yml +++ b/specs/insights/paths/pushEvents.yml @@ -1,6 +1,4 @@ post: - tags: - - insights operationId: pushEvents description: This command pushes an array of events. summary: Pushes an array of events. diff --git a/specs/insights/spec.yml b/specs/insights/spec.yml index da2e859914..61ea23d549 100644 --- a/specs/insights/spec.yml +++ b/specs/insights/spec.yml @@ -21,6 +21,15 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: insights + description: Insights API reference paths: + # ###################### + # ### Custom request ### + # ###################### + /1{path}: + $ref: ../common/paths/customRequest.yml + /1/events: $ref: paths/pushEvents.yml diff --git a/specs/personalization/paths/deleteUserProfile.yml b/specs/personalization/paths/deleteUserProfile.yml index c3cf8fb7f1..a53134d0ea 100644 --- a/specs/personalization/paths/deleteUserProfile.yml +++ b/specs/personalization/paths/deleteUserProfile.yml @@ -1,6 +1,4 @@ delete: - tags: - - personalization operationId: deleteUserProfile description: Returns, as part of the response, a date until which the data can safely be considered as deleted for the given user. This means that if you send events for the given user before this date, they will be ignored. Any data received after the deletedUntil date will start building a new user profile. It might take a couple hours before for the deletion request to be fully processed. summary: Delete the user profile and all its associated data. diff --git a/specs/personalization/paths/getUserTokenProfile.yml b/specs/personalization/paths/getUserTokenProfile.yml index 684d571320..dc74a135b2 100644 --- a/specs/personalization/paths/getUserTokenProfile.yml +++ b/specs/personalization/paths/getUserTokenProfile.yml @@ -1,6 +1,4 @@ get: - tags: - - personalization operationId: getUserTokenProfile description: The profile is structured by facet name used in the strategy. Each facet value is mapped to its score. Each score represents the user affinity for a specific facet value given the userToken past events and the Personalization strategy defined. Scores are bounded to 20. The last processed event timestamp is provided using the ISO 8601 format for debugging purposes. summary: Get the user profile built from Personalization strategy. diff --git a/specs/personalization/paths/personalizationStrategy.yml b/specs/personalization/paths/personalizationStrategy.yml index c1eee12383..63ec486198 100644 --- a/specs/personalization/paths/personalizationStrategy.yml +++ b/specs/personalization/paths/personalizationStrategy.yml @@ -1,6 +1,4 @@ post: - tags: - - personalization operationId: setPersonalizationStrategy description: A strategy defines the events and facets that impact user profiles and personalized search results. summary: Set a new personalization strategy. diff --git a/specs/personalization/spec.yml b/specs/personalization/spec.yml index e6a71d9220..c2371e6693 100644 --- a/specs/personalization/spec.yml +++ b/specs/personalization/spec.yml @@ -20,7 +20,16 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: personalization + description: Personalization API reference paths: + # ###################### + # ### Custom request ### + # ###################### + /1{path}: + $ref: ../common/paths/customRequest.yml + /1/profiles/personalization/{userToken}: $ref: paths/getUserTokenProfile.yml /1/profiles/{userToken}: diff --git a/specs/predict/paths/fetchUserProfile.yml b/specs/predict/paths/fetchUserProfile.yml index a5248fa175..6b71a3eba6 100644 --- a/specs/predict/paths/fetchUserProfile.yml +++ b/specs/predict/paths/fetchUserProfile.yml @@ -1,6 +1,4 @@ post: - tags: - - predict operationId: fetchUserProfile description: Get predictions, properties (raw, computed or custom) and segments (computed or custom) for a user profile. summary: Get user profile. diff --git a/specs/predict/spec.yml b/specs/predict/spec.yml index 23f1665f25..f00e0e3c15 100644 --- a/specs/predict/spec.yml +++ b/specs/predict/spec.yml @@ -14,6 +14,15 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: predict + description: Predict API reference paths: + # ###################### + # ### Custom request ### + # ###################### + /1{path}: + $ref: ../common/paths/customRequest.yml + /1/users/{userID}/fetch: $ref: paths/fetchUserProfile.yml diff --git a/specs/query-suggestions/paths/getConfigurationStatus.yml b/specs/query-suggestions/paths/getConfigurationStatus.yml index d3ee5ee3e9..02bcab9b17 100644 --- a/specs/query-suggestions/paths/getConfigurationStatus.yml +++ b/specs/query-suggestions/paths/getConfigurationStatus.yml @@ -1,6 +1,4 @@ get: - tags: - - query-suggestions operationId: getConfigStatus description: > Get the status of a Query Suggestion's index. diff --git a/specs/query-suggestions/paths/getLogFile.yml b/specs/query-suggestions/paths/getLogFile.yml index 3001ba77e4..6ff282faf6 100644 --- a/specs/query-suggestions/paths/getLogFile.yml +++ b/specs/query-suggestions/paths/getLogFile.yml @@ -1,6 +1,4 @@ get: - tags: - - query-suggestions operationId: getLogFile description: Get the log file of the last build of a single Query Suggestion index. summary: Get the log file of the last build of a single Query Suggestion index. diff --git a/specs/query-suggestions/paths/qsConfig.yml b/specs/query-suggestions/paths/qsConfig.yml index 071f81e0e0..f4f2fae774 100644 --- a/specs/query-suggestions/paths/qsConfig.yml +++ b/specs/query-suggestions/paths/qsConfig.yml @@ -1,6 +1,4 @@ put: - tags: - - query-suggestions operationId: updateConfig description: Update the configuration of a Query Suggestions index. summary: Update the configuration of a Query Suggestions index. diff --git a/specs/query-suggestions/paths/qsConfigs.yml b/specs/query-suggestions/paths/qsConfigs.yml index 15a81f645c..fd71ca3d09 100644 --- a/specs/query-suggestions/paths/qsConfigs.yml +++ b/specs/query-suggestions/paths/qsConfigs.yml @@ -1,6 +1,4 @@ post: - tags: - - query-suggestions operationId: createConfig description: Create a configuration of a Query Suggestions index. There's a limit of 100 configurations per application. summary: Create a configuration of a Query Suggestions index. diff --git a/specs/query-suggestions/spec.yml b/specs/query-suggestions/spec.yml index 7b3aebd1e5..947381045f 100644 --- a/specs/query-suggestions/spec.yml +++ b/specs/query-suggestions/spec.yml @@ -20,7 +20,16 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: query-suggestions + description: Query Suggestions API reference paths: + # ###################### + # ### Custom request ### + # ###################### + /1{path}: + $ref: ../common/paths/customRequest.yml + /1/configs: $ref: paths/qsConfigs.yml /1/configs/{indexName}: diff --git a/specs/recommend/paths/getRecommendations.yml b/specs/recommend/paths/getRecommendations.yml index 6f810feaac..831cc61435 100644 --- a/specs/recommend/paths/getRecommendations.yml +++ b/specs/recommend/paths/getRecommendations.yml @@ -1,6 +1,4 @@ post: - tags: - - recommend operationId: getRecommendations description: Returns recommendations for a specific model and objectID. summary: Returns recommendations for a specific model and objectID. diff --git a/specs/recommend/spec.yml b/specs/recommend/spec.yml index d5cb089bb4..4a657d6775 100644 --- a/specs/recommend/spec.yml +++ b/specs/recommend/spec.yml @@ -33,6 +33,15 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: recommend + description: Recommend API reference paths: + # ###################### + # ### Custom request ### + # ###################### + /1{path}: + $ref: ../common/paths/customRequest.yml + /1/indexes/*/recommendations: $ref: paths/getRecommendations.yml diff --git a/specs/search/paths/advanced/getLogs.yml b/specs/search/paths/advanced/getLogs.yml index 0d6f7e4a9b..d9b5c43921 100644 --- a/specs/search/paths/advanced/getLogs.yml +++ b/specs/search/paths/advanced/getLogs.yml @@ -1,6 +1,4 @@ get: - tags: - - search operationId: getLogs description: Return the lastest log entries. summary: Return the lastest log entries. diff --git a/specs/search/paths/advanced/getTask.yml b/specs/search/paths/advanced/getTask.yml index ff91755b6e..9f339e133a 100644 --- a/specs/search/paths/advanced/getTask.yml +++ b/specs/search/paths/advanced/getTask.yml @@ -1,6 +1,4 @@ get: - tags: - - search operationId: getTask description: Check the current status of a given task. summary: Check the current status of a given task. diff --git a/specs/search/paths/dictionaries/batchDictionaryEntries.yml b/specs/search/paths/dictionaries/batchDictionaryEntries.yml index 3ee9c20c37..933a78c815 100644 --- a/specs/search/paths/dictionaries/batchDictionaryEntries.yml +++ b/specs/search/paths/dictionaries/batchDictionaryEntries.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: batchDictionaryEntries description: Send a batch of dictionary entries. summary: Send a batch of dictionary entries. diff --git a/specs/search/paths/dictionaries/dictionarySettings.yml b/specs/search/paths/dictionaries/dictionarySettings.yml index de0c124785..84d548cf05 100644 --- a/specs/search/paths/dictionaries/dictionarySettings.yml +++ b/specs/search/paths/dictionaries/dictionarySettings.yml @@ -1,6 +1,4 @@ put: - tags: - - search operationId: setDictionarySettings description: Set dictionary settings. summary: Set dictionary settings. @@ -31,8 +29,6 @@ put: $ref: ../../../common/responses/IndexNotFound.yml get: - tags: - - search operationId: getDictionarySettings description: Retrieve dictionaries settings. summary: Retrieve dictionaries settings. The API stores languages whose standard entries are disabled. Fetch settings does not return false values. diff --git a/specs/search/paths/dictionaries/getDictionaryLanguages.yml b/specs/search/paths/dictionaries/getDictionaryLanguages.yml index f480dbcc90..3999d222c5 100644 --- a/specs/search/paths/dictionaries/getDictionaryLanguages.yml +++ b/specs/search/paths/dictionaries/getDictionaryLanguages.yml @@ -1,6 +1,4 @@ get: - tags: - - search operationId: getDictionaryLanguages description: List dictionaries supported per language. summary: List dictionaries supported per language. diff --git a/specs/search/paths/dictionaries/searchDictionaryEntries.yml b/specs/search/paths/dictionaries/searchDictionaryEntries.yml index 3f18189041..a7dabbef6e 100644 --- a/specs/search/paths/dictionaries/searchDictionaryEntries.yml +++ b/specs/search/paths/dictionaries/searchDictionaryEntries.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: searchDictionaryEntries description: Search the dictionary entries. summary: Search the dictionary entries. diff --git a/specs/search/paths/keys/key.yml b/specs/search/paths/keys/key.yml index 12840f84f4..12c374a302 100644 --- a/specs/search/paths/keys/key.yml +++ b/specs/search/paths/keys/key.yml @@ -1,6 +1,4 @@ put: - tags: - - search operationId: updateApiKey summary: Update an API key. description: Replace every permission of an existing API key. @@ -39,8 +37,6 @@ put: $ref: ../../../common/responses/IndexNotFound.yml get: - tags: - - search operationId: getApiKey summary: Get an API key. description: Get the permissions of an API key. @@ -63,8 +59,6 @@ get: $ref: ../../../common/responses/IndexNotFound.yml delete: - tags: - - search operationId: deleteApiKey summary: Delete an API key. description: Delete an existing API Key. diff --git a/specs/search/paths/keys/keys.yml b/specs/search/paths/keys/keys.yml index 60d29a7a1a..78dceb8003 100644 --- a/specs/search/paths/keys/keys.yml +++ b/specs/search/paths/keys/keys.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: addApiKey summary: Create a new API key. description: Add a new API Key with specific permissions/restrictions. @@ -27,8 +25,6 @@ post: $ref: ../../../common/responses/IndexNotFound.yml get: - tags: - - search operationId: listApiKeys summary: Get the full list of API Keys. description: List API keys, along with their associated rights. diff --git a/specs/search/paths/keys/restoreApiKey.yml b/specs/search/paths/keys/restoreApiKey.yml index 3c0b7e5644..ef49f8dfd3 100644 --- a/specs/search/paths/keys/restoreApiKey.yml +++ b/specs/search/paths/keys/restoreApiKey.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: restoreApiKey summary: Restore an API key. description: Restore a deleted API key, along with its associated rights. diff --git a/specs/search/paths/manage_indices/listIndices.yml b/specs/search/paths/manage_indices/listIndices.yml index f1b1029667..62530ac1fd 100644 --- a/specs/search/paths/manage_indices/listIndices.yml +++ b/specs/search/paths/manage_indices/listIndices.yml @@ -1,6 +1,4 @@ get: - tags: - - search operationId: listIndices summary: List existing indexes. description: List existing indexes from an application. diff --git a/specs/search/paths/manage_indices/operationIndex.yml b/specs/search/paths/manage_indices/operationIndex.yml index 44d92ba584..dc9651b3a0 100644 --- a/specs/search/paths/manage_indices/operationIndex.yml +++ b/specs/search/paths/manage_indices/operationIndex.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: operationIndex summary: Copy/move index. description: Peforms a copy or a move operation on a index. diff --git a/specs/search/paths/multiclusters/batchAssignUserIds.yml b/specs/search/paths/multiclusters/batchAssignUserIds.yml index 568e65bc35..2e92c4b35f 100644 --- a/specs/search/paths/multiclusters/batchAssignUserIds.yml +++ b/specs/search/paths/multiclusters/batchAssignUserIds.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: batchAssignUserIds summary: Batch assign userIDs description: > diff --git a/specs/search/paths/multiclusters/getTopUserIds.yml b/specs/search/paths/multiclusters/getTopUserIds.yml index ec082f1d7f..c6278436fc 100644 --- a/specs/search/paths/multiclusters/getTopUserIds.yml +++ b/specs/search/paths/multiclusters/getTopUserIds.yml @@ -1,6 +1,4 @@ get: - tags: - - search operationId: getTopUserIds summary: Get top userID description: > diff --git a/specs/search/paths/multiclusters/hasPendingMappings.yml b/specs/search/paths/multiclusters/hasPendingMappings.yml index 12d8bc4ac0..39b90abcde 100644 --- a/specs/search/paths/multiclusters/hasPendingMappings.yml +++ b/specs/search/paths/multiclusters/hasPendingMappings.yml @@ -1,6 +1,4 @@ get: - tags: - - search operationId: hasPendingMappings summary: Has pending mappings description: > diff --git a/specs/search/paths/multiclusters/listClusters.yml b/specs/search/paths/multiclusters/listClusters.yml index 1c935bbddc..395d91fefa 100644 --- a/specs/search/paths/multiclusters/listClusters.yml +++ b/specs/search/paths/multiclusters/listClusters.yml @@ -1,6 +1,4 @@ get: - tags: - - search operationId: listClusters summary: List clusters description: > diff --git a/specs/search/paths/multiclusters/searchUserIds.yml b/specs/search/paths/multiclusters/searchUserIds.yml index 53e06e6961..728c4f3c79 100644 --- a/specs/search/paths/multiclusters/searchUserIds.yml +++ b/specs/search/paths/multiclusters/searchUserIds.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: searchUserIds summary: Search userID description: > diff --git a/specs/search/paths/multiclusters/userId.yml b/specs/search/paths/multiclusters/userId.yml index 2829a3799e..b363e0db18 100644 --- a/specs/search/paths/multiclusters/userId.yml +++ b/specs/search/paths/multiclusters/userId.yml @@ -1,6 +1,4 @@ get: - tags: - - search operationId: getUserId summary: Get userID description: > @@ -28,8 +26,6 @@ get: $ref: ../../../common/responses/IndexNotFound.yml delete: - tags: - - search operationId: removeUserId summary: Remove userID description: > diff --git a/specs/search/paths/multiclusters/userIds.yml b/specs/search/paths/multiclusters/userIds.yml index 3909f26232..a06bae2279 100644 --- a/specs/search/paths/multiclusters/userIds.yml +++ b/specs/search/paths/multiclusters/userIds.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: assignUserId summary: Assign or Move userID description: > @@ -40,8 +38,6 @@ post: $ref: ../../../common/responses/IndexNotFound.yml get: - tags: - - search operationId: listUserIds summary: List userIDs description: > diff --git a/specs/search/paths/objects/batch.yml b/specs/search/paths/objects/batch.yml index d892d04bb4..556392b848 100644 --- a/specs/search/paths/objects/batch.yml +++ b/specs/search/paths/objects/batch.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: batch description: Performs multiple write operations in a single API call. summary: Performs multiple write operations in a single API call. @@ -19,7 +17,7 @@ post: requests: type: array items: - title: operation + title: batchOperation type: object additionalProperties: false properties: diff --git a/specs/search/paths/objects/clearObjects.yml b/specs/search/paths/objects/clearObjects.yml index 292deb6384..6ead8059aa 100644 --- a/specs/search/paths/objects/clearObjects.yml +++ b/specs/search/paths/objects/clearObjects.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: clearObjects summary: clear all objects from an index. description: Delete an index's content, but leave settings and index-specific API keys untouched. diff --git a/specs/search/paths/objects/deleteBy.yml b/specs/search/paths/objects/deleteBy.yml index 1ae5d57cce..697234d89a 100644 --- a/specs/search/paths/objects/deleteBy.yml +++ b/specs/search/paths/objects/deleteBy.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: deleteBy summary: Delete all records matching the query. description: > diff --git a/specs/search/paths/objects/multipleBatch.yml b/specs/search/paths/objects/multipleBatch.yml index 98f458a75e..49a83d76e0 100644 --- a/specs/search/paths/objects/multipleBatch.yml +++ b/specs/search/paths/objects/multipleBatch.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: multipleBatch description: Perform multiple write operations, potentially targeting multiple indices, in a single API call. summary: Perform multiple write operations. @@ -17,7 +15,7 @@ post: requests: type: array items: - title: Operation. + title: multipleBatchOperation type: object additionalProperties: false properties: diff --git a/specs/search/paths/objects/multipleGetObjects.yml b/specs/search/paths/objects/multipleGetObjects.yml index 70cecc66c3..254572c752 100644 --- a/specs/search/paths/objects/multipleGetObjects.yml +++ b/specs/search/paths/objects/multipleGetObjects.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: getObjects summary: Retrieve one or more objects. description: Retrieve one or more objects, potentially from different indices, in a single API call. diff --git a/specs/search/paths/objects/object.yml b/specs/search/paths/objects/object.yml index a5eda8394f..3432c2c470 100644 --- a/specs/search/paths/objects/object.yml +++ b/specs/search/paths/objects/object.yml @@ -1,6 +1,4 @@ put: - tags: - - search operationId: addOrUpdateObject summary: Add or replace an object with a given object ID. description: Add or replace an object with a given object ID. If the object does not exist, it will be created. If it already exists, it will be replaced. @@ -27,8 +25,6 @@ put: $ref: ../../../common/responses/IndexNotFound.yml get: - tags: - - search operationId: getObject summary: Retrieve one object from the index. description: Retrieve one object from the index. @@ -63,8 +59,6 @@ get: $ref: ../../../common/responses/IndexNotFound.yml delete: - tags: - - search operationId: deleteObject summary: Delete object. description: Delete an existing object. diff --git a/specs/search/paths/objects/objects.yml b/specs/search/paths/objects/objects.yml index 28db949949..5a4e39a208 100644 --- a/specs/search/paths/objects/objects.yml +++ b/specs/search/paths/objects/objects.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: saveObject description: Add an object to the index, automatically assigning it an object ID. summary: Add an object to the index. @@ -37,10 +35,8 @@ post: $ref: ../../../common/responses/MethodNotAllowed.yml '404': $ref: ../../../common/responses/IndexNotFound.yml -# delete index + delete: - tags: - - search operationId: deleteIndex summary: Delete index. description: Delete an existing index. diff --git a/specs/search/paths/objects/partialUpdate.yml b/specs/search/paths/objects/partialUpdate.yml index 70ced042d7..d894a70fdb 100644 --- a/specs/search/paths/objects/partialUpdate.yml +++ b/specs/search/paths/objects/partialUpdate.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: partialUpdateObject summary: Partially update an object. description: > diff --git a/specs/search/paths/rules/batchRules.yml b/specs/search/paths/rules/batchRules.yml index 1802d5b880..1d15508ffd 100644 --- a/specs/search/paths/rules/batchRules.yml +++ b/specs/search/paths/rules/batchRules.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: batchRules summary: Batch Rules. description: Create or update a batch of Rules. diff --git a/specs/search/paths/rules/clearRules.yml b/specs/search/paths/rules/clearRules.yml index 519c7a8e9f..645db04bd8 100644 --- a/specs/search/paths/rules/clearRules.yml +++ b/specs/search/paths/rules/clearRules.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: clearRules summary: Clear Rules. description: Delete all Rules in the index. diff --git a/specs/search/paths/rules/rule.yml b/specs/search/paths/rules/rule.yml index dfd0388e3f..6b8eba5bfb 100644 --- a/specs/search/paths/rules/rule.yml +++ b/specs/search/paths/rules/rule.yml @@ -1,6 +1,4 @@ put: - tags: - - search operationId: saveRule summary: Save/Update a rule. description: Create or update the Rule with the specified objectID. @@ -31,8 +29,6 @@ put: $ref: ../../../common/responses/IndexNotFound.yml get: - tags: - - search operationId: getRule summary: Get a rule. description: Retrieve the Rule with the specified objectID. @@ -56,8 +52,6 @@ get: $ref: ../../../common/responses/IndexNotFound.yml delete: - tags: - - search operationId: deleteRule summary: Delete a rule. description: Delete the Rule with the specified objectID. diff --git a/specs/search/paths/rules/searchRules.yml b/specs/search/paths/rules/searchRules.yml index 155bc4ae51..687e32e911 100644 --- a/specs/search/paths/rules/searchRules.yml +++ b/specs/search/paths/rules/searchRules.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: searchRules summary: Search for rules. description: Search for rules matching various criteria. diff --git a/specs/search/paths/search/browse.yml b/specs/search/paths/search/browse.yml index 30864893ff..6ee3de243c 100644 --- a/specs/search/paths/search/browse.yml +++ b/specs/search/paths/search/browse.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: browse summary: Retrieve all index content. description: > diff --git a/specs/search/paths/search/multipleQueries.yml b/specs/search/paths/search/multipleQueries.yml index 1d2d140d74..887a3bc3e3 100644 --- a/specs/search/paths/search/multipleQueries.yml +++ b/specs/search/paths/search/multipleQueries.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: multipleQueries description: Get search results for the given requests. summary: Get search results for the given requests. diff --git a/specs/search/paths/search/search.yml b/specs/search/paths/search/search.yml index e81ee39397..23923f35e9 100644 --- a/specs/search/paths/search/search.yml +++ b/specs/search/paths/search/search.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: search description: Get search results. summary: Get search results. diff --git a/specs/search/paths/search/searchForFacetValues.yml b/specs/search/paths/search/searchForFacetValues.yml index cf05495fca..bfb403b1cf 100644 --- a/specs/search/paths/search/searchForFacetValues.yml +++ b/specs/search/paths/search/searchForFacetValues.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: searchForFacetValues summary: Search for values of a given facet description: Search for values of a given facet, optionally restricting the returned values to those contained in objects matching other search criteria. diff --git a/specs/search/paths/settings/settings.yml b/specs/search/paths/settings/settings.yml index c2c25b26e8..db6b51342b 100644 --- a/specs/search/paths/settings/settings.yml +++ b/specs/search/paths/settings/settings.yml @@ -1,6 +1,4 @@ get: - tags: - - search operationId: getSettings description: Retrieve settings of a given indexName. summary: Retrieve settings of a given indexName. @@ -23,8 +21,6 @@ get: $ref: ../../../common/responses/IndexNotFound.yml put: - tags: - - search operationId: setSettings description: Update settings of a given indexName. Only specified settings are overridden; unspecified settings are left unchanged. Specifying null for a setting resets it to its default value. summary: Update settings of a given indexName. diff --git a/specs/search/paths/synonyms/batchSynonyms.yml b/specs/search/paths/synonyms/batchSynonyms.yml index 86ea49be60..53769d52fd 100644 --- a/specs/search/paths/synonyms/batchSynonyms.yml +++ b/specs/search/paths/synonyms/batchSynonyms.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: saveSynonyms summary: Save a batch of synonyms. description: Create/update multiple synonym objects at once, potentially replacing the entire list of synonyms if replaceExistingSynonyms is true. diff --git a/specs/search/paths/synonyms/clearAllSynonyms.yml b/specs/search/paths/synonyms/clearAllSynonyms.yml index 46aeead520..4f78030b20 100644 --- a/specs/search/paths/synonyms/clearAllSynonyms.yml +++ b/specs/search/paths/synonyms/clearAllSynonyms.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: clearAllSynonyms summary: Clear all synonyms. description: Remove all synonyms from an index. diff --git a/specs/search/paths/synonyms/searchSynonyms.yml b/specs/search/paths/synonyms/searchSynonyms.yml index 65d18ba563..2cc5f7f756 100644 --- a/specs/search/paths/synonyms/searchSynonyms.yml +++ b/specs/search/paths/synonyms/searchSynonyms.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: searchSynonyms summary: Get all synonyms that match a query. description: Search or browse all synonyms, optionally filtering them by type. diff --git a/specs/search/paths/synonyms/synonym.yml b/specs/search/paths/synonyms/synonym.yml index 9d2b6a2a78..14000ed9e6 100644 --- a/specs/search/paths/synonyms/synonym.yml +++ b/specs/search/paths/synonyms/synonym.yml @@ -1,6 +1,4 @@ put: - tags: - - search operationId: saveSynonym summary: Save synonym. description: Create a new synonym object or update the existing synonym object with the given object ID. @@ -44,8 +42,6 @@ put: $ref: ../../../common/responses/IndexNotFound.yml get: - tags: - - search operationId: getSynonym summary: Get synonym. description: Fetch a synonym object identified by its objectID. @@ -69,8 +65,6 @@ get: $ref: ../../../common/responses/IndexNotFound.yml delete: - tags: - - search operationId: deleteSynonym summary: Delete synonym. description: Delete a single synonyms set, identified by the given objectID. diff --git a/specs/search/paths/vault/appendSource.yml b/specs/search/paths/vault/appendSource.yml index 78dcc909a2..4113335eb5 100644 --- a/specs/search/paths/vault/appendSource.yml +++ b/specs/search/paths/vault/appendSource.yml @@ -1,6 +1,4 @@ post: - tags: - - search operationId: appendSource description: Add a single source to the list of allowed sources. summary: Add a single source. diff --git a/specs/search/paths/vault/deleteSource.yml b/specs/search/paths/vault/deleteSource.yml index 9a2c7a601e..6c455c8f65 100644 --- a/specs/search/paths/vault/deleteSource.yml +++ b/specs/search/paths/vault/deleteSource.yml @@ -1,6 +1,4 @@ delete: - tags: - - search operationId: deleteSource description: Remove a single source from the list of allowed sources. summary: Remove a single source. diff --git a/specs/search/paths/vault/vaultSources.yml b/specs/search/paths/vault/vaultSources.yml index b86745f241..2dba28ad34 100644 --- a/specs/search/paths/vault/vaultSources.yml +++ b/specs/search/paths/vault/vaultSources.yml @@ -1,6 +1,4 @@ get: - tags: - - search operationId: getSources description: List all allowed sources. summary: List all allowed sources. diff --git a/specs/search/spec.yml b/specs/search/spec.yml index 4a079f0bd1..c55af8e904 100644 --- a/specs/search/spec.yml +++ b/specs/search/spec.yml @@ -33,7 +33,16 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: search + description: Search API reference paths: + # ###################### + # ### Custom request ### + # ###################### + /1{path}: + $ref: ../common/paths/customRequest.yml + # ######################## # ### Search Endpoints ### # ######################## diff --git a/specs/sources/paths/ingest/postUrl.yml b/specs/sources/paths/ingest/postUrl.yml index 3b2ca70adf..cb57386c57 100644 --- a/specs/sources/paths/ingest/postUrl.yml +++ b/specs/sources/paths/ingest/postUrl.yml @@ -1,6 +1,4 @@ post: - tags: - - sources operationId: postIngestUrl summary: Create a new ingestion job via URL. description: Add an ingestion job that will fetch data from an URL. diff --git a/specs/sources/spec.yml b/specs/sources/spec.yml index f681320d8e..cba1ae6bd5 100644 --- a/specs/sources/spec.yml +++ b/specs/sources/spec.yml @@ -20,6 +20,15 @@ servers: security: - appId: [] apiKey: [] +tags: + - name: sources + description: Sources API reference paths: + # ###################### + # ### Custom request ### + # ###################### + /1{path}: + $ref: ../common/paths/customRequest.yml + /1/ingest/url: $ref: paths/ingest/postUrl.yml diff --git a/templates/java/libraries/okhttp-gson/api.mustache b/templates/java/libraries/okhttp-gson/api.mustache index f942ba9ce5..fc2753641e 100644 --- a/templates/java/libraries/okhttp-gson/api.mustache +++ b/templates/java/libraries/okhttp-gson/api.mustache @@ -54,7 +54,7 @@ public class {{classname}} extends ApiClient { Object bodyObj = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; // create path and map variables - String path = "{{{path}}}"{{#pathParams}} + String requestPath = "{{{path}}}"{{#pathParams}} .replaceAll("\\{" + "{{baseName}}" + "\\}", this.escapeString({{{paramName}}}.toString())){{/pathParams}}; {{javaUtilPrefix}}List queryParams = new {{javaUtilPrefix}}ArrayList(); @@ -75,7 +75,7 @@ public class {{classname}} extends ApiClient { headers.put("Accept", "application/json"); headers.put("Content-Type", "application/json"); - return this.buildCall(path, "{{httpMethod}}", queryParams, bodyObj, headers, _callback); + return this.buildCall(requestPath, "{{httpMethod}}", queryParams, bodyObj, headers, _callback); } {{#isDeprecated}} diff --git a/templates/javascript/api-single.mustache b/templates/javascript/api-single.mustache index 5c948ac60b..c474a20157 100644 --- a/templates/javascript/api-single.mustache +++ b/templates/javascript/api-single.mustache @@ -195,7 +195,7 @@ export function create{{capitalizedApiName}}Api(options: CreateClientOptions{{#h {{/bodyParams.0}} {{/allParams.0}} ) : Promise<{{{returnType}}}> { - const path = '{{{path}}}'{{#pathParams}}.replace( + const requestPath = '{{{path}}}'{{#pathParams}}.replace( {{=<% %>=}} '{<%baseName%>}', <%={{ }}=%> @@ -232,7 +232,7 @@ export function create{{capitalizedApiName}}Api(options: CreateClientOptions{{#h const request: Request = { method: '{{httpMethod}}', - path, + path: requestPath, {{#bodyParam}} data: {{paramName}}, {{/bodyParam}} diff --git a/tests/CTS/methods/requests/search/batch.json b/tests/CTS/methods/requests/search/batch.json index 28a06dc5f1..2907779501 100644 --- a/tests/CTS/methods/requests/search/batch.json +++ b/tests/CTS/methods/requests/search/batch.json @@ -7,7 +7,7 @@ "$objectName": "BatchWriteParams", "requests": [ { - "$objectName": "Operation", + "$objectName": "BatchOperation", "action": { "$enumType": "Action", "value": "delete" @@ -15,8 +15,7 @@ "body": { "$objectName": "Object", "key": "value" - }, - "indexName": "otherIndexName" + } } ] } @@ -30,8 +29,7 @@ "action": "delete", "body": { "key": "value" - }, - "indexName": "otherIndexName" + } } ] } diff --git a/tests/CTS/methods/requests/search/multipleBatch.json b/tests/CTS/methods/requests/search/multipleBatch.json index fe3c3e8672..91f0fec9a7 100644 --- a/tests/CTS/methods/requests/search/multipleBatch.json +++ b/tests/CTS/methods/requests/search/multipleBatch.json @@ -5,7 +5,7 @@ "$objectName": "BatchParams", "requests": [ { - "$objectName": "Operation", + "$objectName": "MultipleBatchOperation", "action": { "$enumType": "Action", "value": "addObject" diff --git a/tests/CTS/methods/requests/search/partialUpdateObject.json b/tests/CTS/methods/requests/search/partialUpdateObject.json index f71e13cb93..413fa1e3a3 100644 --- a/tests/CTS/methods/requests/search/partialUpdateObject.json +++ b/tests/CTS/methods/requests/search/partialUpdateObject.json @@ -7,9 +7,16 @@ "stringBuiltInOperation": [ { "$objectName": "Object", - "id1": "test", + "id1": { + "$objectName": "Object", + "_operation": "AddUnique", + "value": "test1" + } + }, + { + "$objectName": "Object", "id2": { - "$objectName": "OneOfstringbuiltInOperation", + "$objectName": "Object", "_operation": "AddUnique", "value": "test2" } @@ -22,7 +29,12 @@ "method": "POST", "data": [ { - "id1": "test", + "id1": { + "_operation": "AddUnique", + "value": "test1" + } + }, + { "id2": { "_operation": "AddUnique", "value": "test2" diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java index 84ad278057..af59b9db5d 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java @@ -188,7 +188,7 @@ void batchTest0() { { List requests2 = new ArrayList(); { - Operation requestsParam03 = new Operation(); + BatchOperation requestsParam03 = new BatchOperation(); { Action action4 = Action.fromValue("delete"); @@ -201,9 +201,6 @@ void batchTest0() { body4.put("key", key5); } requestsParam03.setBody(body4); - String indexName4 = "otherIndexName"; - - requestsParam03.setIndexName(indexName4); } requests2.add(requestsParam03); } @@ -221,7 +218,7 @@ void batchTest0() { assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"},\"indexName\":\"otherIndexName\"}]}", + "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -1173,7 +1170,7 @@ void multipleBatchTest0() { { List requests1 = new ArrayList(); { - Operation requestsParam02 = new Operation(); + MultipleBatchOperation requestsParam02 = new MultipleBatchOperation(); { Action action3 = Action.fromValue("addObject"); @@ -1323,22 +1320,33 @@ void partialUpdateObjectTest0() { { HashMap stringBuiltInOperationParam02 = new HashMap(); { - String id13 = "test"; + HashMap id13 = new HashMap(); + { + String _operation4 = "AddUnique"; + id13.put("_operation", _operation4); + String value4 = "test1"; + + id13.put("value", value4); + } stringBuiltInOperationParam02.put("id1", id13); + } + stringBuiltInOperation1.add(stringBuiltInOperationParam02); - OneOfstringbuiltInOperation id23 = new OneOfstringbuiltInOperation(); + HashMap stringBuiltInOperationParam12 = new HashMap(); + { + HashMap id23 = new HashMap(); { String _operation4 = "AddUnique"; - id23.set_operation(_operation4); + id23.put("_operation", _operation4); String value4 = "test2"; - id23.setValue(value4); + id23.put("value", value4); } - stringBuiltInOperationParam02.put("id2", id23); + stringBuiltInOperationParam12.put("id2", id23); } - stringBuiltInOperation1.add(stringBuiltInOperationParam02); + stringBuiltInOperation1.add(stringBuiltInOperationParam12); } boolean createIfNotExists1 = true; @@ -1358,7 +1366,7 @@ void partialUpdateObjectTest0() { assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "[{\"id1\":\"test\",\"id2\":{\"_operation\":\"AddUnique\",\"value\":\"test2\"}}]", + "[{\"id1\":{\"_operation\":\"AddUnique\",\"value\":\"test1\"}},{\"id2\":{\"_operation\":\"AddUnique\",\"value\":\"test2\"}}]", req.getBody(), JSONCompareMode.STRICT_ORDER ); diff --git a/tests/output/javascript/src/methods/requests/search.test.ts b/tests/output/javascript/src/methods/requests/search.test.ts index d0f3780f81..089e67dcb2 100644 --- a/tests/output/javascript/src/methods/requests/search.test.ts +++ b/tests/output/javascript/src/methods/requests/search.test.ts @@ -81,26 +81,14 @@ describe('batch', () => { const req = (await client.batch({ indexName: 'theIndexName', batchWriteParams: { - requests: [ - { - action: 'delete', - body: { key: 'value' }, - indexName: 'otherIndexName', - }, - ], + requests: [{ action: 'delete', body: { key: 'value' } }], }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/indexes/theIndexName/batch'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ - requests: [ - { - action: 'delete', - body: { key: 'value' }, - indexName: 'otherIndexName', - }, - ], + requests: [{ action: 'delete', body: { key: 'value' } }], }); expect(req.searchParams).toEqual(undefined); }); @@ -760,7 +748,8 @@ describe('partialUpdateObject', () => { indexName: 'theIndexName', objectID: 'uniqueID', stringBuiltInOperation: [ - { id1: 'test', id2: { _operation: 'AddUnique', value: 'test2' } }, + { id1: { _operation: 'AddUnique', value: 'test1' } }, + { id2: { _operation: 'AddUnique', value: 'test2' } }, ], createIfNotExists: true, })) as unknown as EchoResponse; @@ -768,7 +757,8 @@ describe('partialUpdateObject', () => { expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID/partial'); expect(req.method).toEqual('POST'); expect(req.data).toEqual([ - { id1: 'test', id2: { _operation: 'AddUnique', value: 'test2' } }, + { id1: { _operation: 'AddUnique', value: 'test1' } }, + { id2: { _operation: 'AddUnique', value: 'test2' } }, ]); expect(req.searchParams).toEqual({ createIfNotExists: 'true' }); }); From f0b992cac344359d75b0e190b5e0a63547831ac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Tue, 1 Mar 2022 09:29:50 +0100 Subject: [PATCH 2/5] apply changes from suggestion --- scripts/buildSpecs.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/buildSpecs.ts b/scripts/buildSpecs.ts index 147f9b9fe4..f52af8c9a2 100644 --- a/scripts/buildSpecs.ts +++ b/scripts/buildSpecs.ts @@ -1,4 +1,4 @@ -import fsp, { readFile, writeFile } from 'fs/promises'; +import fsp from 'fs/promises'; import { hashElement } from 'folder-hash'; import yaml from 'js-yaml'; @@ -14,7 +14,9 @@ async function propagateTagsToOperations( throw new Error(`Bundled file not found ${bundledPath}.`); } - const bundledSpec = yaml.load(await readFile(bundledPath, 'utf8')) as Spec; + const bundledSpec = yaml.load( + await fsp.readFile(bundledPath, 'utf8') + ) as Spec; if (bundledSpec.tags.length === 0) { throw new Error( @@ -30,7 +32,7 @@ async function propagateTagsToOperations( } } - await writeFile( + await fsp.writeFile( bundledPath, yaml.dump(bundledSpec, { noRefs: true, @@ -81,6 +83,7 @@ async function buildSpec( if ( (await propagateTagsToOperations(toAbsolutePath(bundledPath))) === false ) { + spinner.fail(); throw new Error( `Unable to propage tags to operations for \`${client}\` spec.` ); From 88f096392250c19007053a526a445d543ca5cf37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Tue, 1 Mar 2022 10:02:42 +0100 Subject: [PATCH 3/5] use query parameters for `getCustomRequest` --- .../com/algolia/search/SearchApi.java | 32 +- .../client-abtesting/src/abtestingApi.ts | 17 +- .../client-analytics/src/analyticsApi.ts | 17 +- .../client-insights/src/insightsApi.ts | 17 +- .../src/personalizationApi.ts | 17 +- .../packages/client-predict/src/predictApi.ts | 17 +- .../src/querySuggestionsApi.ts | 17 +- .../packages/client-search/src/searchApi.ts | 17 +- .../packages/client-sources/src/sourcesApi.ts | 17 +- .../packages/recommend/src/recommendApi.ts | 17 +- .../lib/Api/AbtestingApi.php | 20 +- .../lib/Api/AnalyticsApi.php | 20 +- .../lib/Api/InsightsApi.php | 20 +- .../lib/Api/PersonalizationApi.php | 20 +- .../lib/Api/QuerySuggestionsApi.php | 20 +- .../lib/Api/RecommendApi.php | 20 +- .../lib/Api/SearchApi.php | 20 +- specs/bundled/abtesting.yml | 108 +++---- specs/bundled/analytics.yml | 252 +++++++-------- specs/bundled/insights.yml | 65 ++-- specs/bundled/personalization.yml | 84 ++--- specs/bundled/predict.yml | 84 ++--- specs/bundled/query-suggestions.yml | 82 ++--- specs/bundled/recommend.yml | 65 ++-- specs/bundled/search.yml | 298 ++++++++---------- specs/bundled/sources.yml | 65 ++-- specs/common/paths/customRequest.yml | 9 +- specs/common/schemas/CustomRequest.yml | 54 +++- 28 files changed, 706 insertions(+), 785 deletions(-) diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java index 46bbf58e95..ca3f8bb957 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java @@ -2293,10 +2293,10 @@ public Call getApiKeyAsync(String key, final ApiCallback _callback) */ private Call getCustomRequestCall( String path, - Object body, + String parameters, final ApiCallback _callback ) throws ApiException { - Object bodyObj = body; + Object bodyObj = null; // create path and map variables String requestPath = @@ -2308,6 +2308,10 @@ private Call getCustomRequestCall( List queryParams = new ArrayList(); Map headers = new HashMap(); + if (parameters != null) { + queryParams.addAll(this.parameterToPair("parameters", parameters)); + } + headers.put("Accept", "application/json"); headers.put("Content-Type", "application/json"); @@ -2323,7 +2327,7 @@ private Call getCustomRequestCall( private Call getCustomRequestValidateBeforeCall( String path, - Object body, + String parameters, final ApiCallback _callback ) throws ApiException { // verify the required parameter 'path' is set @@ -2333,21 +2337,23 @@ private Call getCustomRequestValidateBeforeCall( ); } - return getCustomRequestCall(path, body, _callback); + return getCustomRequestCall(path, parameters, _callback); } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * The getCustomRequest method allow you to send requests to the Algolia REST API. * * @param path The path of the API endpoint to target, anything after the /1 needs to be * specified. (required) - * @param body The parameters to send with the custom request. (optional) + * @param parameters URL-encoded query string. Force some query parameters to be applied for each + * query made with this API key. (optional) * @return Object * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body */ - public Object getCustomRequest(String path, Object body) throws ApiException { - Call req = getCustomRequestValidateBeforeCall(path, body, null); + public Object getCustomRequest(String path, String parameters) + throws ApiException { + Call req = getCustomRequestValidateBeforeCall(path, parameters, null); if (req instanceof CallEcho) { return new EchoResponse.GetCustomRequest(((CallEcho) req).request()); } @@ -2362,21 +2368,23 @@ public Object getCustomRequest(String path) throws ApiException { } /** - * (asynchronously) The customRequest method allow you to send requests to the Algolia REST API. + * (asynchronously) The getCustomRequest method allow you to send requests to the Algolia REST + * API. * * @param path The path of the API endpoint to target, anything after the /1 needs to be * specified. (required) - * @param body The parameters to send with the custom request. (optional) + * @param parameters URL-encoded query string. Force some query parameters to be applied for each + * query made with this API key. (optional) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call getCustomRequestAsync( String path, - Object body, + String parameters, final ApiCallback _callback ) throws ApiException { - Call call = getCustomRequestValidateBeforeCall(path, body, _callback); + Call call = getCustomRequestValidateBeforeCall(path, parameters, _callback); Type returnType = new TypeToken() {}.getType(); this.executeAsync(call, returnType, _callback); return call; diff --git a/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts b/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts index cac9fc878f..0466945363 100644 --- a/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts @@ -205,16 +205,16 @@ export function createAbtestingApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * The getCustomRequest method allow you to send requests to the Algolia REST API. * - * @summary Send requests to the Algolia REST API. + * @summary Send GET requests to the Algolia REST API. * @param getCustomRequest - The getCustomRequest object. * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.body - The parameters to send with the custom request. + * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ function getCustomRequest({ path, - body, + parameters, }: GetCustomRequestProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', @@ -229,10 +229,13 @@ export function createAbtestingApi( ); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'GET', path: requestPath, - data: body, }; return transporter.request(request, { @@ -427,9 +430,9 @@ export type GetCustomRequestProps = { */ path: string; /** - * The parameters to send with the custom request. + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - body?: Record; + parameters?: string; }; export type ListABTestsProps = { diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts index d7280dbc1b..5071680e2a 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts @@ -323,16 +323,16 @@ export function createAnalyticsApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * The getCustomRequest method allow you to send requests to the Algolia REST API. * - * @summary Send requests to the Algolia REST API. + * @summary Send GET requests to the Algolia REST API. * @param getCustomRequest - The getCustomRequest object. * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.body - The parameters to send with the custom request. + * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ function getCustomRequest({ path, - body, + parameters, }: GetCustomRequestProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', @@ -347,10 +347,13 @@ export function createAnalyticsApi( ); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'GET', path: requestPath, - data: body, }; return transporter.request(request, { @@ -1382,9 +1385,9 @@ export type GetCustomRequestProps = { */ path: string; /** - * The parameters to send with the custom request. + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - body?: Record; + parameters?: string; }; export type GetNoClickRateProps = { diff --git a/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts b/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts index d3a894b275..2ba51eedf7 100644 --- a/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts @@ -94,16 +94,16 @@ export function createInsightsApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * The getCustomRequest method allow you to send requests to the Algolia REST API. * - * @summary Send requests to the Algolia REST API. + * @summary Send GET requests to the Algolia REST API. * @param getCustomRequest - The getCustomRequest object. * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.body - The parameters to send with the custom request. + * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ function getCustomRequest({ path, - body, + parameters, }: GetCustomRequestProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', @@ -118,10 +118,13 @@ export function createInsightsApi( ); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'GET', path: requestPath, - data: body, }; return transporter.request(request, { @@ -270,9 +273,9 @@ export type GetCustomRequestProps = { */ path: string; /** - * The parameters to send with the custom request. + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - body?: Record; + parameters?: string; }; export type PostCustomRequestProps = { diff --git a/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts b/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts index 71d646acd0..7f6c5ca7cb 100644 --- a/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts @@ -128,16 +128,16 @@ export function createPersonalizationApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * The getCustomRequest method allow you to send requests to the Algolia REST API. * - * @summary Send requests to the Algolia REST API. + * @summary Send GET requests to the Algolia REST API. * @param getCustomRequest - The getCustomRequest object. * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.body - The parameters to send with the custom request. + * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ function getCustomRequest({ path, - body, + parameters, }: GetCustomRequestProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', @@ -152,10 +152,13 @@ export function createPersonalizationApi( ); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'GET', path: requestPath, - data: body, }; return transporter.request(request, { @@ -379,9 +382,9 @@ export type GetCustomRequestProps = { */ path: string; /** - * The parameters to send with the custom request. + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - body?: Record; + parameters?: string; }; export type GetUserTokenProfileProps = { diff --git a/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts b/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts index 81b25f76ec..1aabbb26ad 100644 --- a/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts @@ -131,16 +131,16 @@ export function createPredictApi(options: CreateClientOptions) { } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * The getCustomRequest method allow you to send requests to the Algolia REST API. * - * @summary Send requests to the Algolia REST API. + * @summary Send GET requests to the Algolia REST API. * @param getCustomRequest - The getCustomRequest object. * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.body - The parameters to send with the custom request. + * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ function getCustomRequest({ path, - body, + parameters, }: GetCustomRequestProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', @@ -155,10 +155,13 @@ export function createPredictApi(options: CreateClientOptions) { ); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'GET', path: requestPath, - data: body, }; return transporter.request(request, { @@ -278,9 +281,9 @@ export type GetCustomRequestProps = { */ path: string; /** - * The parameters to send with the custom request. + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - body?: Record; + parameters?: string; }; export type PostCustomRequestProps = { diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts index feed29f890..a29d537f3e 100644 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts @@ -250,16 +250,16 @@ export function createQuerySuggestionsApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * The getCustomRequest method allow you to send requests to the Algolia REST API. * - * @summary Send requests to the Algolia REST API. + * @summary Send GET requests to the Algolia REST API. * @param getCustomRequest - The getCustomRequest object. * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.body - The parameters to send with the custom request. + * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ function getCustomRequest({ path, - body, + parameters, }: GetCustomRequestProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', @@ -274,10 +274,13 @@ export function createQuerySuggestionsApi( ); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'GET', path: requestPath, - data: body, }; return transporter.request(request, { @@ -497,9 +500,9 @@ export type GetCustomRequestProps = { */ path: string; /** - * The parameters to send with the custom request. + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - body?: Record; + parameters?: string; }; export type GetLogFileProps = { diff --git a/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts index 872944d8c4..c4bd9f69ac 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts @@ -995,16 +995,16 @@ export function createSearchApi(options: CreateClientOptions) { } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * The getCustomRequest method allow you to send requests to the Algolia REST API. * - * @summary Send requests to the Algolia REST API. + * @summary Send GET requests to the Algolia REST API. * @param getCustomRequest - The getCustomRequest object. * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.body - The parameters to send with the custom request. + * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ function getCustomRequest({ path, - body, + parameters, }: GetCustomRequestProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', @@ -1019,10 +1019,13 @@ export function createSearchApi(options: CreateClientOptions) { ); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'GET', path: requestPath, - data: body, }; return transporter.request(request, { @@ -2808,9 +2811,9 @@ export type GetCustomRequestProps = { */ path: string; /** - * The parameters to send with the custom request. + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - body?: Record; + parameters?: string; }; export type GetLogsProps = { diff --git a/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts b/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts index ad645934b4..90b176120b 100644 --- a/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts @@ -92,16 +92,16 @@ export function createSourcesApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * The getCustomRequest method allow you to send requests to the Algolia REST API. * - * @summary Send requests to the Algolia REST API. + * @summary Send GET requests to the Algolia REST API. * @param getCustomRequest - The getCustomRequest object. * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.body - The parameters to send with the custom request. + * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ function getCustomRequest({ path, - body, + parameters, }: GetCustomRequestProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', @@ -116,10 +116,13 @@ export function createSourcesApi( ); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'GET', path: requestPath, - data: body, }; return transporter.request(request, { @@ -278,9 +281,9 @@ export type GetCustomRequestProps = { */ path: string; /** - * The parameters to send with the custom request. + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - body?: Record; + parameters?: string; }; export type PostCustomRequestProps = { diff --git a/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts b/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts index 52dc42a677..c68afaa38f 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts +++ b/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts @@ -114,16 +114,16 @@ export function createRecommendApi(options: CreateClientOptions) { } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * The getCustomRequest method allow you to send requests to the Algolia REST API. * - * @summary Send requests to the Algolia REST API. + * @summary Send GET requests to the Algolia REST API. * @param getCustomRequest - The getCustomRequest object. * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.body - The parameters to send with the custom request. + * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ function getCustomRequest({ path, - body, + parameters, }: GetCustomRequestProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', @@ -138,10 +138,13 @@ export function createRecommendApi(options: CreateClientOptions) { ); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'GET', path: requestPath, - data: body, }; return transporter.request(request, { @@ -290,9 +293,9 @@ export type GetCustomRequestProps = { */ path: string; /** - * The parameters to send with the custom request. + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - body?: Record; + parameters?: string; }; export type PostCustomRequestProps = { diff --git a/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php b/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php index cc528c088a..f66f59a820 100644 --- a/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php +++ b/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php @@ -212,14 +212,14 @@ public function getABTest($id) } /** - * Send requests to the Algolia REST API. + * Send GET requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param array $body The parameters to send with the custom request. (optional) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * * @return array */ - public function getCustomRequest($path, $body = null) + public function getCustomRequest($path, $parameters = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -231,6 +231,16 @@ public function getCustomRequest($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -240,10 +250,6 @@ public function getCustomRequest($path, $body = null) ); } - if (isset($body)) { - $httpBody = $body; - } - return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } diff --git a/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php b/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php index eebbe419f1..0ccff743af 100644 --- a/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php @@ -415,14 +415,14 @@ public function getConversationRate($index, $startDate = null, $endDate = null, } /** - * Send requests to the Algolia REST API. + * Send GET requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param array $body The parameters to send with the custom request. (optional) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * * @return array */ - public function getCustomRequest($path, $body = null) + public function getCustomRequest($path, $parameters = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -434,6 +434,16 @@ public function getCustomRequest($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -443,10 +453,6 @@ public function getCustomRequest($path, $body = null) ); } - if (isset($body)) { - $httpBody = $body; - } - return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } diff --git a/clients/algoliasearch-client-php/lib/Api/InsightsApi.php b/clients/algoliasearch-client-php/lib/Api/InsightsApi.php index 547df21040..6aa332fab6 100644 --- a/clients/algoliasearch-client-php/lib/Api/InsightsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/InsightsApi.php @@ -123,14 +123,14 @@ public function deleteCustomRequest($path, $body = null) } /** - * Send requests to the Algolia REST API. + * Send GET requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param array $body The parameters to send with the custom request. (optional) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * * @return array */ - public function getCustomRequest($path, $body = null) + public function getCustomRequest($path, $parameters = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -142,6 +142,16 @@ public function getCustomRequest($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -151,10 +161,6 @@ public function getCustomRequest($path, $body = null) ); } - if (isset($body)) { - $httpBody = $body; - } - return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } diff --git a/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php b/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php index 87781b54d4..556146e277 100644 --- a/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php +++ b/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php @@ -154,14 +154,14 @@ public function deleteUserProfile($userToken) } /** - * Send requests to the Algolia REST API. + * Send GET requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param array $body The parameters to send with the custom request. (optional) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * * @return array */ - public function getCustomRequest($path, $body = null) + public function getCustomRequest($path, $parameters = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -173,6 +173,16 @@ public function getCustomRequest($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -182,10 +192,6 @@ public function getCustomRequest($path, $body = null) ); } - if (isset($body)) { - $httpBody = $body; - } - return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } diff --git a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php index 6781a549cd..31694c971c 100644 --- a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php @@ -258,14 +258,14 @@ public function getConfigStatus($indexName) } /** - * Send requests to the Algolia REST API. + * Send GET requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param array $body The parameters to send with the custom request. (optional) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * * @return array */ - public function getCustomRequest($path, $body = null) + public function getCustomRequest($path, $parameters = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -277,6 +277,16 @@ public function getCustomRequest($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -286,10 +296,6 @@ public function getCustomRequest($path, $body = null) ); } - if (isset($body)) { - $httpBody = $body; - } - return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } diff --git a/clients/algoliasearch-client-php/lib/Api/RecommendApi.php b/clients/algoliasearch-client-php/lib/Api/RecommendApi.php index 5d7b227d55..71a79d8c76 100644 --- a/clients/algoliasearch-client-php/lib/Api/RecommendApi.php +++ b/clients/algoliasearch-client-php/lib/Api/RecommendApi.php @@ -124,14 +124,14 @@ public function deleteCustomRequest($path, $body = null) } /** - * Send requests to the Algolia REST API. + * Send GET requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param array $body The parameters to send with the custom request. (optional) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * * @return array */ - public function getCustomRequest($path, $body = null) + public function getCustomRequest($path, $parameters = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -143,6 +143,16 @@ public function getCustomRequest($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -152,10 +162,6 @@ public function getCustomRequest($path, $body = null) ); } - if (isset($body)) { - $httpBody = $body; - } - return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } diff --git a/clients/algoliasearch-client-php/lib/Api/SearchApi.php b/clients/algoliasearch-client-php/lib/Api/SearchApi.php index e5139a8230..c69505cafe 100644 --- a/clients/algoliasearch-client-php/lib/Api/SearchApi.php +++ b/clients/algoliasearch-client-php/lib/Api/SearchApi.php @@ -956,14 +956,14 @@ public function getApiKey($key) } /** - * Send requests to the Algolia REST API. + * Send GET requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param array $body The parameters to send with the custom request. (optional) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * * @return array */ - public function getCustomRequest($path, $body = null) + public function getCustomRequest($path, $parameters = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -975,6 +975,16 @@ public function getCustomRequest($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -984,10 +994,6 @@ public function getCustomRequest($path, $body = null) ); } - if (isset($body)) { - $httpBody = $body; - } - return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } diff --git a/specs/bundled/abtesting.yml b/specs/bundled/abtesting.yml index 5cb714cc4e..8965b72b20 100644 --- a/specs/bundled/abtesting.yml +++ b/specs/bundled/abtesting.yml @@ -13,6 +13,38 @@ components: type: apiKey in: header name: X-Algolia-API-Key + parameters: + PathInPath: + name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs to + be specified. + required: true + schema: + type: string + example: /keys + Offset: + in: query + name: offset + description: Position of the starting record. Used for paging. 0 is the first record. + schema: + type: integer + default: 0 + Limit: + in: query + name: limit + description: Number of records to return. Limit is the size of the page. + schema: + type: integer + default: 10 + ID: + in: path + name: id + description: The A/B test ID. + required: true + schema: + type: integer schemas: ErrorBase: description: Error. @@ -218,28 +250,6 @@ components: application/json: schema: $ref: '#/components/schemas/ErrorBase' - parameters: - Offset: - in: query - name: offset - description: Position of the starting record. Used for paging. 0 is the first record. - schema: - type: integer - default: 0 - Limit: - in: query - name: limit - description: Number of records to return. Limit is the size of the page. - schema: - type: integer - default: 10 - ID: - in: path - name: id - description: The A/B test ID. - required: true - schema: - type: integer servers: - url: https://analytics.{region}.algolia.com variables: @@ -259,26 +269,20 @@ paths: /1{path}: get: operationId: getCustomRequest - summary: Send requests to the Algolia REST API. + summary: Send GET requests to the Algolia REST API. description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + The getCustomRequest method allow you to send requests to the Algolia + REST API. parameters: - - name: path - in: path + - $ref: '#/components/parameters/PathInPath' + - name: parameters + in: query description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true + URL-encoded query string. Force some query parameters to be applied + for each query made with this API key. schema: type: string - example: /keys - requestBody: - description: The parameters to send with the custom request. - content: - application/json: - schema: - type: object + example: '?query=mySearchQuery&hitsPerPage=10' responses: '200': description: OK @@ -303,15 +307,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -342,15 +338,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -381,15 +369,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: diff --git a/specs/bundled/analytics.yml b/specs/bundled/analytics.yml index a83acee55d..e2d079342e 100644 --- a/specs/bundled/analytics.yml +++ b/specs/bundled/analytics.yml @@ -13,6 +13,110 @@ components: type: apiKey in: header name: X-Algolia-API-Key + parameters: + PathInPath: + name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs to + be specified. + required: true + schema: + type: string + example: /keys + Index: + in: query + name: index + description: The index name to target. + required: true + schema: + type: string + ClickAnalytics: + in: query + name: clickAnalytics + description: Whether to include the click-through and conversion rates for a search. + schema: + type: boolean + default: false + StartDate: + in: query + name: startDate + description: >- + The lower bound timestamp (a date, a string like "2006-01-02") of the + period to analyze. + schema: + type: string + example: 1999-09-19T00:00:00.000Z + pattern: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$ + EndDate: + in: query + name: endDate + description: >- + The upper bound timestamp (a date, a string like "2006-01-02") of the + period to analyze. + schema: + type: string + example: 2000-01-21T00:00:00.000Z + pattern: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$ + OrderBy: + in: query + name: orderBy + description: Reorder the results. + schema: + type: string + enum: + - searchCount + - clickThroughRate + - conversionRate + - averageClickPosition + default: searchCount + Direction: + in: query + name: direction + description: The sorting of the result. + schema: + type: string + enum: + - asc + - desc + default: asc + Limit: + in: query + name: limit + description: Number of records to return. Limit is the size of the page. + schema: + type: integer + default: 10 + Offset: + in: query + name: offset + description: Position of the starting record. Used for paging. 0 is the first record. + schema: + type: integer + default: 0 + Tags: + name: tags + in: query + description: >- + Filter metrics on the provided tags. Each tag must correspond to an + analyticsTags set at search time. Multiple tags can be combined with the + operators OR and AND. If a tag contains characters like spaces or + parentheses, it should be URL encoded. + schema: + type: string + Search: + in: query + name: search + description: The query term to search for. Must match the exact user input. + schema: + type: string + Attribute: + in: path + name: attribute + description: The exact name of the attribute. + required: true + schema: + type: string schemas: ErrorBase: description: Error. @@ -307,100 +411,6 @@ components: application/json: schema: $ref: '#/components/schemas/ErrorBase' - parameters: - Index: - in: query - name: index - description: The index name to target. - required: true - schema: - type: string - ClickAnalytics: - in: query - name: clickAnalytics - description: Whether to include the click-through and conversion rates for a search. - schema: - type: boolean - default: false - StartDate: - in: query - name: startDate - description: >- - The lower bound timestamp (a date, a string like "2006-01-02") of the - period to analyze. - schema: - type: string - example: 1999-09-19T00:00:00.000Z - pattern: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$ - EndDate: - in: query - name: endDate - description: >- - The upper bound timestamp (a date, a string like "2006-01-02") of the - period to analyze. - schema: - type: string - example: 2000-01-21T00:00:00.000Z - pattern: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$ - OrderBy: - in: query - name: orderBy - description: Reorder the results. - schema: - type: string - enum: - - searchCount - - clickThroughRate - - conversionRate - - averageClickPosition - default: searchCount - Direction: - in: query - name: direction - description: The sorting of the result. - schema: - type: string - enum: - - asc - - desc - default: asc - Limit: - in: query - name: limit - description: Number of records to return. Limit is the size of the page. - schema: - type: integer - default: 10 - Offset: - in: query - name: offset - description: Position of the starting record. Used for paging. 0 is the first record. - schema: - type: integer - default: 0 - Tags: - name: tags - in: query - description: >- - Filter metrics on the provided tags. Each tag must correspond to an - analyticsTags set at search time. Multiple tags can be combined with the - operators OR and AND. If a tag contains characters like spaces or - parentheses, it should be URL encoded. - schema: - type: string - Search: - in: query - name: search - description: The query term to search for. Must match the exact user input. - schema: - type: string - Attribute: - in: path - name: attribute - description: The exact name of the attribute. - required: true - schema: - type: string servers: - url: https://analytics.{region}.algolia.com variables: @@ -420,26 +430,20 @@ paths: /1{path}: get: operationId: getCustomRequest - summary: Send requests to the Algolia REST API. + summary: Send GET requests to the Algolia REST API. description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + The getCustomRequest method allow you to send requests to the Algolia + REST API. parameters: - - name: path - in: path + - $ref: '#/components/parameters/PathInPath' + - name: parameters + in: query description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true + URL-encoded query string. Force some query parameters to be applied + for each query made with this API key. schema: type: string - example: /keys - requestBody: - description: The parameters to send with the custom request. - content: - application/json: - schema: - type: object + example: '?query=mySearchQuery&hitsPerPage=10' responses: '200': description: OK @@ -464,15 +468,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -503,15 +499,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -542,15 +530,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: diff --git a/specs/bundled/insights.yml b/specs/bundled/insights.yml index 214abd6336..6532cf7623 100644 --- a/specs/bundled/insights.yml +++ b/specs/bundled/insights.yml @@ -13,6 +13,17 @@ components: type: apiKey in: header name: X-Algolia-API-Key + parameters: + PathInPath: + name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs to + be specified. + required: true + schema: + type: string + example: /keys schemas: ErrorBase: description: Error. @@ -66,26 +77,20 @@ paths: /1{path}: get: operationId: getCustomRequest - summary: Send requests to the Algolia REST API. + summary: Send GET requests to the Algolia REST API. description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + The getCustomRequest method allow you to send requests to the Algolia + REST API. parameters: - - name: path - in: path + - $ref: '#/components/parameters/PathInPath' + - name: parameters + in: query description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true + URL-encoded query string. Force some query parameters to be applied + for each query made with this API key. schema: type: string - example: /keys - requestBody: - description: The parameters to send with the custom request. - content: - application/json: - schema: - type: object + example: '?query=mySearchQuery&hitsPerPage=10' responses: '200': description: OK @@ -110,15 +115,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -149,15 +146,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -188,15 +177,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: diff --git a/specs/bundled/personalization.yml b/specs/bundled/personalization.yml index 1283476eea..abdad0f9b3 100644 --- a/specs/bundled/personalization.yml +++ b/specs/bundled/personalization.yml @@ -13,6 +13,26 @@ components: type: apiKey in: header name: X-Algolia-API-Key + parameters: + PathInPath: + name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs to + be specified. + required: true + schema: + type: string + example: /keys + UserToken: + name: userToken + in: path + required: true + description: >- + userToken representing the user for which to fetch the Personalization + profile. + schema: + type: string schemas: ErrorBase: description: Error. @@ -107,16 +127,6 @@ components: application/json: schema: $ref: '#/components/schemas/ErrorBase' - parameters: - UserToken: - name: userToken - in: path - required: true - description: >- - userToken representing the user for which to fetch the Personalization - profile. - schema: - type: string servers: - url: https://personalization.{region}.algolia.com variables: @@ -135,26 +145,20 @@ paths: /1{path}: get: operationId: getCustomRequest - summary: Send requests to the Algolia REST API. + summary: Send GET requests to the Algolia REST API. description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + The getCustomRequest method allow you to send requests to the Algolia + REST API. parameters: - - name: path - in: path + - $ref: '#/components/parameters/PathInPath' + - name: parameters + in: query description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true + URL-encoded query string. Force some query parameters to be applied + for each query made with this API key. schema: type: string - example: /keys - requestBody: - description: The parameters to send with the custom request. - content: - application/json: - schema: - type: object + example: '?query=mySearchQuery&hitsPerPage=10' responses: '200': description: OK @@ -179,15 +183,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -218,15 +214,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -257,15 +245,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: diff --git a/specs/bundled/predict.yml b/specs/bundled/predict.yml index 8522a01eb8..587358cc41 100644 --- a/specs/bundled/predict.yml +++ b/specs/bundled/predict.yml @@ -13,6 +13,26 @@ components: type: apiKey in: header name: X-Algolia-API-Key + parameters: + PathInPath: + name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs to + be specified. + required: true + schema: + type: string + example: /keys + userID: + name: userID + in: path + required: true + schema: + type: string + description: >- + User ID for authenticated users or cookie ID for non-authenticated + repeated users (visitors). schemas: ErrorBase: description: Error. @@ -53,16 +73,6 @@ components: application/json: schema: $ref: '#/components/schemas/ErrorBase' - parameters: - userID: - name: userID - in: path - required: true - schema: - type: string - description: >- - User ID for authenticated users or cookie ID for non-authenticated - repeated users (visitors). servers: - url: https://predict-api-oslcbws3zq-ew.a.run.app security: @@ -75,26 +85,20 @@ paths: /1{path}: get: operationId: getCustomRequest - summary: Send requests to the Algolia REST API. + summary: Send GET requests to the Algolia REST API. description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + The getCustomRequest method allow you to send requests to the Algolia + REST API. parameters: - - name: path - in: path + - $ref: '#/components/parameters/PathInPath' + - name: parameters + in: query description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true + URL-encoded query string. Force some query parameters to be applied + for each query made with this API key. schema: type: string - example: /keys - requestBody: - description: The parameters to send with the custom request. - content: - application/json: - schema: - type: object + example: '?query=mySearchQuery&hitsPerPage=10' responses: '200': description: OK @@ -119,15 +123,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -158,15 +154,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -197,15 +185,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: diff --git a/specs/bundled/query-suggestions.yml b/specs/bundled/query-suggestions.yml index 71ce078413..dae25c666f 100644 --- a/specs/bundled/query-suggestions.yml +++ b/specs/bundled/query-suggestions.yml @@ -13,6 +13,25 @@ components: type: apiKey in: header name: X-Algolia-API-Key + parameters: + PathInPath: + name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs to + be specified. + required: true + schema: + type: string + example: /keys + IndexName: + name: indexName + in: path + description: The index in which to perform the request. + required: true + schema: + type: string + example: myIndexName schemas: ErrorBase: description: Error. @@ -267,15 +286,6 @@ components: type: string example: Success description: Message of the response. - parameters: - IndexName: - name: indexName - in: path - description: The index in which to perform the request. - required: true - schema: - type: string - example: myIndexName servers: - url: https://query-suggestions.{region}.algolia.com variables: @@ -294,26 +304,20 @@ paths: /1{path}: get: operationId: getCustomRequest - summary: Send requests to the Algolia REST API. + summary: Send GET requests to the Algolia REST API. description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + The getCustomRequest method allow you to send requests to the Algolia + REST API. parameters: - - name: path - in: path + - $ref: '#/components/parameters/PathInPath' + - name: parameters + in: query description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true + URL-encoded query string. Force some query parameters to be applied + for each query made with this API key. schema: type: string - example: /keys - requestBody: - description: The parameters to send with the custom request. - content: - application/json: - schema: - type: object + example: '?query=mySearchQuery&hitsPerPage=10' responses: '200': description: OK @@ -338,15 +342,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -377,15 +373,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -416,15 +404,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: diff --git a/specs/bundled/recommend.yml b/specs/bundled/recommend.yml index 8b96f1ec06..714ccd27ba 100644 --- a/specs/bundled/recommend.yml +++ b/specs/bundled/recommend.yml @@ -13,6 +13,17 @@ components: type: apiKey in: header name: X-Algolia-API-Key + parameters: + PathInPath: + name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs to + be specified. + required: true + schema: + type: string + example: /keys schemas: ErrorBase: description: Error. @@ -874,26 +885,20 @@ paths: /1{path}: get: operationId: getCustomRequest - summary: Send requests to the Algolia REST API. + summary: Send GET requests to the Algolia REST API. description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + The getCustomRequest method allow you to send requests to the Algolia + REST API. parameters: - - name: path - in: path + - $ref: '#/components/parameters/PathInPath' + - name: parameters + in: query description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true + URL-encoded query string. Force some query parameters to be applied + for each query made with this API key. schema: type: string - example: /keys - requestBody: - description: The parameters to send with the custom request. - content: - application/json: - schema: - type: object + example: '?query=mySearchQuery&hitsPerPage=10' responses: '200': description: OK @@ -918,15 +923,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -957,15 +954,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -996,15 +985,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: diff --git a/specs/bundled/search.yml b/specs/bundled/search.yml index b62e49affd..58b8660836 100644 --- a/specs/bundled/search.yml +++ b/specs/bundled/search.yml @@ -13,6 +13,133 @@ components: type: apiKey in: header name: X-Algolia-API-Key + parameters: + PathInPath: + name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs to + be specified. + required: true + schema: + type: string + example: /keys + IndexName: + name: indexName + in: path + description: The index in which to perform the request. + required: true + schema: + type: string + example: myIndexName + ObjectID: + name: objectID + in: path + description: Unique identifier of an object. + required: true + schema: + type: string + example: '123' + ForwardToReplicas: + in: query + name: forwardToReplicas + description: >- + When true, changes are also propagated to replicas of the given + indexName. + schema: + type: boolean + ReplaceExistingSynonyms: + in: query + name: replaceExistingSynonyms + schema: + type: boolean + description: Replace all synonyms of the index with the ones sent with this request. + Query: + in: query + name: query + description: Search for specific synonyms matching this string. + schema: + type: string + default: '' + Type: + in: query + name: type + description: Only search for specific types of synonyms. + schema: + $ref: '#/components/schemas/SynonymType' + PageDefault0: + in: query + name: page + description: >- + Requested page (zero-based). When specified, will retrieve a specific + page; the page size is implicitly set to 100. When null, will retrieve + all indices (no pagination). + schema: + type: integer + nullable: true + default: 0 + HitsPerPage: + in: query + name: hitsPerPage + description: Maximum number of objects to retrieve. + schema: + type: integer + default: 100 + KeyString: + in: path + name: key + required: true + schema: + type: string + example: myAPIKey + description: API Key string. + ClearExistingRules: + in: query + name: clearExistingRules + required: false + schema: + type: boolean + description: >- + When true, existing Rules are cleared before adding this batch. When + false, existing Rules are kept. + DictionaryName: + in: path + name: dictionaryName + description: The dictionary to search in. + required: true + schema: + enum: + - plurals + - stopwords + - compounds + type: string + Page: + in: query + name: page + description: >- + Requested page (zero-based). When specified, will retrieve a specific + page; the page size is implicitly set to 100. When null, will retrieve + all indices (no pagination). + schema: + type: integer + nullable: true + default: null + UserIDInQuery: + name: X-Algolia-User-ID + description: userID to assign. + in: query + required: true + schema: + type: string + pattern: ^[a-zA-Z0-9 \-*.]+$ + UserIDInPath: + name: userID + description: userID to assign. + in: path + required: true + schema: + type: string + pattern: ^[a-zA-Z0-9 \-*.]+$ schemas: ErrorBase: description: Error. @@ -1707,123 +1834,6 @@ components: properties: createdAt: $ref: '#/components/schemas/createdAt' - parameters: - IndexName: - name: indexName - in: path - description: The index in which to perform the request. - required: true - schema: - type: string - example: myIndexName - ObjectID: - name: objectID - in: path - description: Unique identifier of an object. - required: true - schema: - type: string - example: '123' - ForwardToReplicas: - in: query - name: forwardToReplicas - description: >- - When true, changes are also propagated to replicas of the given - indexName. - schema: - type: boolean - ReplaceExistingSynonyms: - in: query - name: replaceExistingSynonyms - schema: - type: boolean - description: Replace all synonyms of the index with the ones sent with this request. - Query: - in: query - name: query - description: Search for specific synonyms matching this string. - schema: - type: string - default: '' - Type: - in: query - name: type - description: Only search for specific types of synonyms. - schema: - $ref: '#/components/schemas/SynonymType' - PageDefault0: - in: query - name: page - description: >- - Requested page (zero-based). When specified, will retrieve a specific - page; the page size is implicitly set to 100. When null, will retrieve - all indices (no pagination). - schema: - type: integer - nullable: true - default: 0 - HitsPerPage: - in: query - name: hitsPerPage - description: Maximum number of objects to retrieve. - schema: - type: integer - default: 100 - KeyString: - in: path - name: key - required: true - schema: - type: string - example: myAPIKey - description: API Key string. - ClearExistingRules: - in: query - name: clearExistingRules - required: false - schema: - type: boolean - description: >- - When true, existing Rules are cleared before adding this batch. When - false, existing Rules are kept. - DictionaryName: - in: path - name: dictionaryName - description: The dictionary to search in. - required: true - schema: - enum: - - plurals - - stopwords - - compounds - type: string - Page: - in: query - name: page - description: >- - Requested page (zero-based). When specified, will retrieve a specific - page; the page size is implicitly set to 100. When null, will retrieve - all indices (no pagination). - schema: - type: integer - nullable: true - default: null - UserIDInQuery: - name: X-Algolia-User-ID - description: userID to assign. - in: query - required: true - schema: - type: string - pattern: ^[a-zA-Z0-9 \-*.]+$ - UserIDInPath: - name: userID - description: userID to assign. - in: path - required: true - schema: - type: string - pattern: ^[a-zA-Z0-9 \-*.]+$ servers: - url: https://{appId}.algolianet.com variables: @@ -1855,26 +1865,20 @@ paths: /1{path}: get: operationId: getCustomRequest - summary: Send requests to the Algolia REST API. + summary: Send GET requests to the Algolia REST API. description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + The getCustomRequest method allow you to send requests to the Algolia + REST API. parameters: - - name: path - in: path + - $ref: '#/components/parameters/PathInPath' + - name: parameters + in: query description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true + URL-encoded query string. Force some query parameters to be applied + for each query made with this API key. schema: type: string - example: /keys - requestBody: - description: The parameters to send with the custom request. - content: - application/json: - schema: - type: object + example: '?query=mySearchQuery&hitsPerPage=10' responses: '200': description: OK @@ -1899,15 +1903,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -1938,15 +1934,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -1977,15 +1965,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: diff --git a/specs/bundled/sources.yml b/specs/bundled/sources.yml index c535cb10db..06483b4850 100644 --- a/specs/bundled/sources.yml +++ b/specs/bundled/sources.yml @@ -13,6 +13,17 @@ components: type: apiKey in: header name: X-Algolia-API-Key + parameters: + PathInPath: + name: path + in: path + description: >- + The path of the API endpoint to target, anything after the /1 needs to + be specified. + required: true + schema: + type: string + example: /keys schemas: ErrorBase: description: Error. @@ -82,26 +93,20 @@ paths: /1{path}: get: operationId: getCustomRequest - summary: Send requests to the Algolia REST API. + summary: Send GET requests to the Algolia REST API. description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + The getCustomRequest method allow you to send requests to the Algolia + REST API. parameters: - - name: path - in: path + - $ref: '#/components/parameters/PathInPath' + - name: parameters + in: query description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true + URL-encoded query string. Force some query parameters to be applied + for each query made with this API key. schema: type: string - example: /keys - requestBody: - description: The parameters to send with the custom request. - content: - application/json: - schema: - type: object + example: '?query=mySearchQuery&hitsPerPage=10' responses: '200': description: OK @@ -126,15 +131,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -165,15 +162,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: @@ -204,15 +193,7 @@ paths: The customRequest method allow you to send requests to the Algolia REST API. parameters: - - name: path - in: path - description: >- - The path of the API endpoint to target, anything after the /1 needs - to be specified. - required: true - schema: - type: string - example: /keys + - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: diff --git a/specs/common/paths/customRequest.yml b/specs/common/paths/customRequest.yml index f41cadc460..fa392cc630 100644 --- a/specs/common/paths/customRequest.yml +++ b/specs/common/paths/customRequest.yml @@ -1,15 +1,14 @@ get: - operationId: getCustomRequest - $ref: ../schemas/CustomRequest.yml + $ref: ../schemas/CustomRequest.yml#/getCustomRequest post: operationId: postCustomRequest - $ref: ../schemas/CustomRequest.yml + $ref: ../schemas/CustomRequest.yml#/customRequest put: operationId: putCustomRequest - $ref: ../schemas/CustomRequest.yml + $ref: ../schemas/CustomRequest.yml#/customRequest delete: operationId: deleteCustomRequest - $ref: ../schemas/CustomRequest.yml + $ref: ../schemas/CustomRequest.yml#/customRequest diff --git a/specs/common/schemas/CustomRequest.yml b/specs/common/schemas/CustomRequest.yml index 97571aadae..bf33eed3dd 100644 --- a/specs/common/schemas/CustomRequest.yml +++ b/specs/common/schemas/CustomRequest.yml @@ -1,20 +1,33 @@ -summary: Send requests to the Algolia REST API. -description: The customRequest method allow you to send requests to the Algolia REST API. -parameters: - - name: path - in: path - description: The path of the API endpoint to target, anything after the /1 needs to be specified. - required: true - schema: - type: string - example: /keys -requestBody: - description: The parameters to send with the custom request. - content: - application/json: +customRequest: + summary: Send requests to the Algolia REST API. + description: The customRequest method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/PathInPath' + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object + responses: + $ref: '#/Responses' + +getCustomRequest: + operationId: getCustomRequest + summary: Send GET requests to the Algolia REST API. + description: The getCustomRequest method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/PathInPath' + - name: parameters + in: query + description: URL-encoded query string. Force some query parameters to be applied for each query made with this API key. schema: - type: object -responses: + type: string + example: '?query=mySearchQuery&hitsPerPage=10' + responses: + $ref: '#/Responses' + +Responses: '200': description: OK content: @@ -29,3 +42,12 @@ responses: $ref: ../responses/MethodNotAllowed.yml '404': $ref: ../responses/IndexNotFound.yml + +PathInPath: + name: path + in: path + description: The path of the API endpoint to target, anything after the /1 needs to be specified. + required: true + schema: + type: string + example: /keys From 0c9c68dd2b73c9559b05e2f6332e8064bca55994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Tue, 1 Mar 2022 12:12:31 +0100 Subject: [PATCH 4/5] shorten method names --- .../com/algolia/search/SearchApi.java | 406 +++++++++--------- .../com/algolia/utils/echo/EchoResponse.java | 40 +- .../bundlesize.config.json | 10 +- .../client-abtesting/src/abtestingApi.ts | 164 ++++--- .../client-analytics/src/analyticsApi.ts | 168 ++++---- .../client-insights/src/insightsApi.ts | 85 ++-- .../src/personalizationApi.ts | 84 ++-- .../packages/client-predict/src/predictApi.ts | 85 ++-- .../src/querySuggestionsApi.ts | 172 ++++---- .../packages/client-search/src/searchApi.ts | 210 ++++----- .../packages/client-sources/src/sourcesApi.ts | 85 ++-- .../packages/recommend/src/recommendApi.ts | 85 ++-- .../lib/Api/AbtestingApi.php | 86 ++-- .../lib/Api/AnalyticsApi.php | 96 ++--- .../lib/Api/InsightsApi.php | 16 +- .../lib/Api/PersonalizationApi.php | 16 +- .../lib/Api/QuerySuggestionsApi.php | 110 ++--- .../lib/Api/RecommendApi.php | 16 +- .../lib/Api/SearchApi.php | 142 +++--- specs/bundled/abtesting.yml | 24 +- specs/bundled/analytics.yml | 24 +- specs/bundled/insights.yml | 24 +- specs/bundled/personalization.yml | 24 +- specs/bundled/predict.yml | 24 +- specs/bundled/query-suggestions.yml | 24 +- specs/bundled/recommend.yml | 24 +- specs/bundled/search.yml | 24 +- specs/bundled/sources.yml | 24 +- specs/common/paths/customRequest.yml | 6 +- specs/common/schemas/CustomRequest.yml | 6 +- 30 files changed, 1006 insertions(+), 1298 deletions(-) diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java index ca3f8bb957..c0d134b619 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java @@ -1361,6 +1361,104 @@ public Call clearRulesAsync( return call; } + /** + * Build call for del + * + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + private Call delCall( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + Object bodyObj = body; + + // create path and map variables + String requestPath = + "/1{path}".replaceAll( + "\\{" + "path" + "\\}", + this.escapeString(path.toString()) + ); + + List queryParams = new ArrayList(); + Map headers = new HashMap(); + + headers.put("Accept", "application/json"); + headers.put("Content-Type", "application/json"); + + return this.buildCall( + requestPath, + "DELETE", + queryParams, + bodyObj, + headers, + _callback + ); + } + + private Call delValidateBeforeCall( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'path' is set + if (path == null) { + throw new ApiException( + "Missing the required parameter 'path' when calling del(Async)" + ); + } + + return delCall(path, body, _callback); + } + + /** + * This method allow you to send requests to the Algolia REST API. + * + * @param path The path of the API endpoint to target, anything after the /1 needs to be + * specified. (required) + * @param body The parameters to send with the custom request. (optional) + * @return Object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + */ + public Object del(String path, Object body) throws ApiException { + Call req = delValidateBeforeCall(path, body, null); + if (req instanceof CallEcho) { + return new EchoResponse.Del(((CallEcho) req).request()); + } + Call call = (Call) req; + Type returnType = new TypeToken() {}.getType(); + ApiResponse res = this.execute(call, returnType); + return res.getData(); + } + + public Object del(String path) throws ApiException { + return this.del(path, null); + } + + /** + * (asynchronously) This method allow you to send requests to the Algolia REST API. + * + * @param path The path of the API endpoint to target, anything after the /1 needs to be + * specified. (required) + * @param body The parameters to send with the custom request. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public Call delAsync( + String path, + Object body, + final ApiCallback _callback + ) throws ApiException { + Call call = delValidateBeforeCall(path, body, _callback); + Type returnType = new TypeToken() {}.getType(); + this.executeAsync(call, returnType, _callback); + return call; + } + /** * Build call for deleteApiKey * @@ -1554,105 +1652,6 @@ public Call deleteByAsync( return call; } - /** - * Build call for deleteCustomRequest - * - * @param _callback Callback for upload/download progress - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - private Call deleteCustomRequestCall( - String path, - Object body, - final ApiCallback _callback - ) throws ApiException { - Object bodyObj = body; - - // create path and map variables - String requestPath = - "/1{path}".replaceAll( - "\\{" + "path" + "\\}", - this.escapeString(path.toString()) - ); - - List queryParams = new ArrayList(); - Map headers = new HashMap(); - - headers.put("Accept", "application/json"); - headers.put("Content-Type", "application/json"); - - return this.buildCall( - requestPath, - "DELETE", - queryParams, - bodyObj, - headers, - _callback - ); - } - - private Call deleteCustomRequestValidateBeforeCall( - String path, - Object body, - final ApiCallback _callback - ) throws ApiException { - // verify the required parameter 'path' is set - if (path == null) { - throw new ApiException( - "Missing the required parameter 'path' when calling deleteCustomRequest(Async)" - ); - } - - return deleteCustomRequestCall(path, body, _callback); - } - - /** - * The customRequest method allow you to send requests to the Algolia REST API. - * - * @param path The path of the API endpoint to target, anything after the /1 needs to be - * specified. (required) - * @param body The parameters to send with the custom request. (optional) - * @return Object - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the - * response body - */ - public Object deleteCustomRequest(String path, Object body) - throws ApiException { - Call req = deleteCustomRequestValidateBeforeCall(path, body, null); - if (req instanceof CallEcho) { - return new EchoResponse.DeleteCustomRequest(((CallEcho) req).request()); - } - Call call = (Call) req; - Type returnType = new TypeToken() {}.getType(); - ApiResponse res = this.execute(call, returnType); - return res.getData(); - } - - public Object deleteCustomRequest(String path) throws ApiException { - return this.deleteCustomRequest(path, null); - } - - /** - * (asynchronously) The customRequest method allow you to send requests to the Algolia REST API. - * - * @param path The path of the API endpoint to target, anything after the /1 needs to be - * specified. (required) - * @param body The parameters to send with the custom request. (optional) - * @param _callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public Call deleteCustomRequestAsync( - String path, - Object body, - final ApiCallback _callback - ) throws ApiException { - Call call = deleteCustomRequestValidateBeforeCall(path, body, _callback); - Type returnType = new TypeToken() {}.getType(); - this.executeAsync(call, returnType, _callback); - return call; - } - /** * Build call for deleteIndex * @@ -2202,26 +2201,33 @@ public Call deleteSynonymAsync( } /** - * Build call for getApiKey + * Build call for get * * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - private Call getApiKeyCall(String key, final ApiCallback _callback) - throws ApiException { + private Call getCall( + String path, + String parameters, + final ApiCallback _callback + ) throws ApiException { Object bodyObj = null; // create path and map variables String requestPath = - "/1/keys/{key}".replaceAll( - "\\{" + "key" + "\\}", - this.escapeString(key.toString()) + "/1{path}".replaceAll( + "\\{" + "path" + "\\}", + this.escapeString(path.toString()) ); List queryParams = new ArrayList(); Map headers = new HashMap(); + if (parameters != null) { + queryParams.addAll(this.parameterToPair("parameters", parameters)); + } + headers.put("Accept", "application/json"); headers.put("Content-Type", "application/json"); @@ -2235,83 +2241,90 @@ private Call getApiKeyCall(String key, final ApiCallback _callback) ); } - private Call getApiKeyValidateBeforeCall( - String key, - final ApiCallback _callback + private Call getValidateBeforeCall( + String path, + String parameters, + final ApiCallback _callback ) throws ApiException { - // verify the required parameter 'key' is set - if (key == null) { + // verify the required parameter 'path' is set + if (path == null) { throw new ApiException( - "Missing the required parameter 'key' when calling getApiKey(Async)" + "Missing the required parameter 'path' when calling get(Async)" ); } - return getApiKeyCall(key, _callback); + return getCall(path, parameters, _callback); } /** - * Get the permissions of an API key. + * This method allow you to send requests to the Algolia REST API. * - * @param key API Key string. (required) - * @return Key + * @param path The path of the API endpoint to target, anything after the /1 needs to be + * specified. (required) + * @param parameters URL-encoded query string. Force some query parameters to be applied for each + * query made with this API key. (optional) + * @return Object * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body */ - public Key getApiKey(String key) throws ApiException { - Call req = getApiKeyValidateBeforeCall(key, null); + public Object get(String path, String parameters) throws ApiException { + Call req = getValidateBeforeCall(path, parameters, null); if (req instanceof CallEcho) { - return new EchoResponse.GetApiKey(((CallEcho) req).request()); + return new EchoResponse.Get(((CallEcho) req).request()); } Call call = (Call) req; - Type returnType = new TypeToken() {}.getType(); - ApiResponse res = this.execute(call, returnType); + Type returnType = new TypeToken() {}.getType(); + ApiResponse res = this.execute(call, returnType); return res.getData(); } + public Object get(String path) throws ApiException { + return this.get(path, null); + } + /** - * (asynchronously) Get the permissions of an API key. + * (asynchronously) This method allow you to send requests to the Algolia REST API. * - * @param key API Key string. (required) + * @param path The path of the API endpoint to target, anything after the /1 needs to be + * specified. (required) + * @param parameters URL-encoded query string. Force some query parameters to be applied for each + * query made with this API key. (optional) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ - public Call getApiKeyAsync(String key, final ApiCallback _callback) - throws ApiException { - Call call = getApiKeyValidateBeforeCall(key, _callback); - Type returnType = new TypeToken() {}.getType(); + public Call getAsync( + String path, + String parameters, + final ApiCallback _callback + ) throws ApiException { + Call call = getValidateBeforeCall(path, parameters, _callback); + Type returnType = new TypeToken() {}.getType(); this.executeAsync(call, returnType, _callback); return call; } /** - * Build call for getCustomRequest + * Build call for getApiKey * * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - private Call getCustomRequestCall( - String path, - String parameters, - final ApiCallback _callback - ) throws ApiException { + private Call getApiKeyCall(String key, final ApiCallback _callback) + throws ApiException { Object bodyObj = null; // create path and map variables String requestPath = - "/1{path}".replaceAll( - "\\{" + "path" + "\\}", - this.escapeString(path.toString()) + "/1/keys/{key}".replaceAll( + "\\{" + "key" + "\\}", + this.escapeString(key.toString()) ); List queryParams = new ArrayList(); Map headers = new HashMap(); - if (parameters != null) { - queryParams.addAll(this.parameterToPair("parameters", parameters)); - } - headers.put("Accept", "application/json"); headers.put("Content-Type", "application/json"); @@ -2325,67 +2338,51 @@ private Call getCustomRequestCall( ); } - private Call getCustomRequestValidateBeforeCall( - String path, - String parameters, - final ApiCallback _callback + private Call getApiKeyValidateBeforeCall( + String key, + final ApiCallback _callback ) throws ApiException { - // verify the required parameter 'path' is set - if (path == null) { + // verify the required parameter 'key' is set + if (key == null) { throw new ApiException( - "Missing the required parameter 'path' when calling getCustomRequest(Async)" + "Missing the required parameter 'key' when calling getApiKey(Async)" ); } - return getCustomRequestCall(path, parameters, _callback); + return getApiKeyCall(key, _callback); } /** - * The getCustomRequest method allow you to send requests to the Algolia REST API. + * Get the permissions of an API key. * - * @param path The path of the API endpoint to target, anything after the /1 needs to be - * specified. (required) - * @param parameters URL-encoded query string. Force some query parameters to be applied for each - * query made with this API key. (optional) - * @return Object + * @param key API Key string. (required) + * @return Key * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body */ - public Object getCustomRequest(String path, String parameters) - throws ApiException { - Call req = getCustomRequestValidateBeforeCall(path, parameters, null); + public Key getApiKey(String key) throws ApiException { + Call req = getApiKeyValidateBeforeCall(key, null); if (req instanceof CallEcho) { - return new EchoResponse.GetCustomRequest(((CallEcho) req).request()); + return new EchoResponse.GetApiKey(((CallEcho) req).request()); } Call call = (Call) req; - Type returnType = new TypeToken() {}.getType(); - ApiResponse res = this.execute(call, returnType); + Type returnType = new TypeToken() {}.getType(); + ApiResponse res = this.execute(call, returnType); return res.getData(); } - public Object getCustomRequest(String path) throws ApiException { - return this.getCustomRequest(path, null); - } - /** - * (asynchronously) The getCustomRequest method allow you to send requests to the Algolia REST - * API. + * (asynchronously) Get the permissions of an API key. * - * @param path The path of the API endpoint to target, anything after the /1 needs to be - * specified. (required) - * @param parameters URL-encoded query string. Force some query parameters to be applied for each - * query made with this API key. (optional) + * @param key API Key string. (required) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ - public Call getCustomRequestAsync( - String path, - String parameters, - final ApiCallback _callback - ) throws ApiException { - Call call = getCustomRequestValidateBeforeCall(path, parameters, _callback); - Type returnType = new TypeToken() {}.getType(); + public Call getApiKeyAsync(String key, final ApiCallback _callback) + throws ApiException { + Call call = getApiKeyValidateBeforeCall(key, _callback); + Type returnType = new TypeToken() {}.getType(); this.executeAsync(call, returnType, _callback); return call; } @@ -4415,13 +4412,13 @@ public Call partialUpdateObjectAsync( } /** - * Build call for postCustomRequest + * Build call for post * * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - private Call postCustomRequestCall( + private Call postCall( String path, Object body, final ApiCallback _callback @@ -4451,7 +4448,7 @@ private Call postCustomRequestCall( ); } - private Call postCustomRequestValidateBeforeCall( + private Call postValidateBeforeCall( String path, Object body, final ApiCallback _callback @@ -4459,15 +4456,15 @@ private Call postCustomRequestValidateBeforeCall( // verify the required parameter 'path' is set if (path == null) { throw new ApiException( - "Missing the required parameter 'path' when calling postCustomRequest(Async)" + "Missing the required parameter 'path' when calling post(Async)" ); } - return postCustomRequestCall(path, body, _callback); + return postCall(path, body, _callback); } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @param path The path of the API endpoint to target, anything after the /1 needs to be * specified. (required) @@ -4476,11 +4473,10 @@ private Call postCustomRequestValidateBeforeCall( * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body */ - public Object postCustomRequest(String path, Object body) - throws ApiException { - Call req = postCustomRequestValidateBeforeCall(path, body, null); + public Object post(String path, Object body) throws ApiException { + Call req = postValidateBeforeCall(path, body, null); if (req instanceof CallEcho) { - return new EchoResponse.PostCustomRequest(((CallEcho) req).request()); + return new EchoResponse.Post(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -4488,12 +4484,12 @@ public Object postCustomRequest(String path, Object body) return res.getData(); } - public Object postCustomRequest(String path) throws ApiException { - return this.postCustomRequest(path, null); + public Object post(String path) throws ApiException { + return this.post(path, null); } /** - * (asynchronously) The customRequest method allow you to send requests to the Algolia REST API. + * (asynchronously) This method allow you to send requests to the Algolia REST API. * * @param path The path of the API endpoint to target, anything after the /1 needs to be * specified. (required) @@ -4502,25 +4498,25 @@ public Object postCustomRequest(String path) throws ApiException { * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ - public Call postCustomRequestAsync( + public Call postAsync( String path, Object body, final ApiCallback _callback ) throws ApiException { - Call call = postCustomRequestValidateBeforeCall(path, body, _callback); + Call call = postValidateBeforeCall(path, body, _callback); Type returnType = new TypeToken() {}.getType(); this.executeAsync(call, returnType, _callback); return call; } /** - * Build call for putCustomRequest + * Build call for put * * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - private Call putCustomRequestCall( + private Call putCall( String path, Object body, final ApiCallback _callback @@ -4550,7 +4546,7 @@ private Call putCustomRequestCall( ); } - private Call putCustomRequestValidateBeforeCall( + private Call putValidateBeforeCall( String path, Object body, final ApiCallback _callback @@ -4558,15 +4554,15 @@ private Call putCustomRequestValidateBeforeCall( // verify the required parameter 'path' is set if (path == null) { throw new ApiException( - "Missing the required parameter 'path' when calling putCustomRequest(Async)" + "Missing the required parameter 'path' when calling put(Async)" ); } - return putCustomRequestCall(path, body, _callback); + return putCall(path, body, _callback); } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @param path The path of the API endpoint to target, anything after the /1 needs to be * specified. (required) @@ -4575,10 +4571,10 @@ private Call putCustomRequestValidateBeforeCall( * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body */ - public Object putCustomRequest(String path, Object body) throws ApiException { - Call req = putCustomRequestValidateBeforeCall(path, body, null); + public Object put(String path, Object body) throws ApiException { + Call req = putValidateBeforeCall(path, body, null); if (req instanceof CallEcho) { - return new EchoResponse.PutCustomRequest(((CallEcho) req).request()); + return new EchoResponse.Put(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -4586,12 +4582,12 @@ public Object putCustomRequest(String path, Object body) throws ApiException { return res.getData(); } - public Object putCustomRequest(String path) throws ApiException { - return this.putCustomRequest(path, null); + public Object put(String path) throws ApiException { + return this.put(path, null); } /** - * (asynchronously) The customRequest method allow you to send requests to the Algolia REST API. + * (asynchronously) This method allow you to send requests to the Algolia REST API. * * @param path The path of the API endpoint to target, anything after the /1 needs to be * specified. (required) @@ -4600,12 +4596,12 @@ public Object putCustomRequest(String path) throws ApiException { * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ - public Call putCustomRequestAsync( + public Call putAsync( String path, Object body, final ApiCallback _callback ) throws ApiException { - Call call = putCustomRequestValidateBeforeCall(path, body, _callback); + Call call = putValidateBeforeCall(path, body, _callback); Type returnType = new TypeToken() {}.getType(); this.executeAsync(call, returnType, _callback); return call; diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/echo/EchoResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/echo/EchoResponse.java index e861a74ee3..efade3ee5a 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/echo/EchoResponse.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/echo/EchoResponse.java @@ -358,13 +358,11 @@ public List getQueryParams() { } } - public static class DeleteApiKey - extends DeleteApiKeyResponse - implements EchoResponseInterface { + public static class Del extends Object implements EchoResponseInterface { private Request request; - public DeleteApiKey(Request request) { + public Del(Request request) { this.request = request; } @@ -385,13 +383,13 @@ public List getQueryParams() { } } - public static class DeleteBy - extends DeletedAtResponse + public static class DeleteApiKey + extends DeleteApiKeyResponse implements EchoResponseInterface { private Request request; - public DeleteBy(Request request) { + public DeleteApiKey(Request request) { this.request = request; } @@ -412,13 +410,13 @@ public List getQueryParams() { } } - public static class DeleteCustomRequest - extends Object + public static class DeleteBy + extends DeletedAtResponse implements EchoResponseInterface { private Request request; - public DeleteCustomRequest(Request request) { + public DeleteBy(Request request) { this.request = request; } @@ -574,11 +572,11 @@ public List getQueryParams() { } } - public static class GetApiKey extends Key implements EchoResponseInterface { + public static class Get extends Object implements EchoResponseInterface { private Request request; - public GetApiKey(Request request) { + public Get(Request request) { this.request = request; } @@ -599,13 +597,11 @@ public List getQueryParams() { } } - public static class GetCustomRequest - extends Object - implements EchoResponseInterface { + public static class GetApiKey extends Key implements EchoResponseInterface { private Request request; - public GetCustomRequest(Request request) { + public GetApiKey(Request request) { this.request = request; } @@ -1191,13 +1187,11 @@ public List getQueryParams() { } } - public static class PostCustomRequest - extends Object - implements EchoResponseInterface { + public static class Post extends Object implements EchoResponseInterface { private Request request; - public PostCustomRequest(Request request) { + public Post(Request request) { this.request = request; } @@ -1218,13 +1212,11 @@ public List getQueryParams() { } } - public static class PutCustomRequest - extends Object - implements EchoResponseInterface { + public static class Put extends Object implements EchoResponseInterface { private Request request; - public PutCustomRequest(Request request) { + public Put(Request request) { this.request = request; } diff --git a/clients/algoliasearch-client-javascript/bundlesize.config.json b/clients/algoliasearch-client-javascript/bundlesize.config.json index 27e80d2f40..0a137425e4 100644 --- a/clients/algoliasearch-client-javascript/bundlesize.config.json +++ b/clients/algoliasearch-client-javascript/bundlesize.config.json @@ -2,7 +2,7 @@ "files": [ { "path": "packages/algoliasearch/dist/algoliasearch.umd.browser.js", - "maxSize": "6.25KB" + "maxSize": "6.50KB" }, { "path": "packages/client-abtesting/dist/client-abtesting.umd.browser.js", @@ -10,11 +10,11 @@ }, { "path": "packages/client-analytics/dist/client-analytics.umd.browser.js", - "maxSize": "3.75KB" + "maxSize": "4.00KB" }, { "path": "packages/client-insights/dist/client-insights.umd.browser.js", - "maxSize": "3.00KB" + "maxSize": "3.25KB" }, { "path": "packages/client-personalization/dist/client-personalization.umd.browser.js", @@ -30,11 +30,11 @@ }, { "path": "packages/client-sources/dist/client-sources.umd.browser.js", - "maxSize": "3.00KB" + "maxSize": "3.25KB" }, { "path": "packages/recommend/dist/recommend.umd.browser.js", - "maxSize": "3.00KB" + "maxSize": "3.25KB" }, { "path": "packages/client-common/dist/client-common.esm.node.js", diff --git a/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts b/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts index 0466945363..f933e350fd 100644 --- a/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts @@ -105,6 +105,38 @@ export function createAbtestingApi( }); } + /** + * This method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param del - The del object. + * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.body - The parameters to send with the custom request. + */ + function del({ path, body }: DelProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error('Parameter `path` is required when calling `del`.'); + } + + const request: Request = { + method: 'DELETE', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + /** * Deletes the A/B Test and removes all associated metadata & metrics. * @@ -138,17 +170,14 @@ export function createAbtestingApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * - * @summary Send requests to the Algolia REST API. - * @param deleteCustomRequest - The deleteCustomRequest object. - * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param deleteCustomRequest.body - The parameters to send with the custom request. + * @summary Send GET requests to the Algolia REST API. + * @param get - The get object. + * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - function deleteCustomRequest({ - path, - body, - }: DeleteCustomRequestProps): Promise> { + function get({ path, parameters }: GetProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -157,15 +186,16 @@ export function createAbtestingApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `deleteCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `get`.'); + } + + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); } const request: Request = { - method: 'DELETE', + method: 'GET', path: requestPath, - data: body, }; return transporter.request(request, { @@ -204,46 +234,6 @@ export function createAbtestingApi( }); } - /** - * The getCustomRequest method allow you to send requests to the Algolia REST API. - * - * @summary Send GET requests to the Algolia REST API. - * @param getCustomRequest - The getCustomRequest object. - * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. - */ - function getCustomRequest({ - path, - parameters, - }: GetCustomRequestProps): Promise> { - const requestPath = '/1{path}'.replace( - '{path}', - encodeURIComponent(String(path)) - ); - const headers: Headers = { Accept: 'application/json' }; - const queryParameters: Record = {}; - - if (!path) { - throw new Error( - 'Parameter `path` is required when calling `getCustomRequest`.' - ); - } - - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } - - const request: Request = { - method: 'GET', - path: requestPath, - }; - - return transporter.request(request, { - queryParameters, - headers, - }); - } - /** * Fetch all existing A/B tests for App that are available for the current API Key. Returns an array of metadata and metrics. When no data has been processed, the metrics will be returned as null. * @@ -280,17 +270,14 @@ export function createAbtestingApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param postCustomRequest - The postCustomRequest object. - * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param postCustomRequest.body - The parameters to send with the custom request. + * @param post - The post object. + * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.body - The parameters to send with the custom request. */ - function postCustomRequest({ - path, - body, - }: PostCustomRequestProps): Promise> { + function post({ path, body }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -299,9 +286,7 @@ export function createAbtestingApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `postCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `post`.'); } const request: Request = { @@ -317,17 +302,14 @@ export function createAbtestingApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param putCustomRequest - The putCustomRequest object. - * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param putCustomRequest.body - The parameters to send with the custom request. + * @param put - The put object. + * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.body - The parameters to send with the custom request. */ - function putCustomRequest({ - path, - body, - }: PutCustomRequestProps): Promise> { + function put({ path, body }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -336,9 +318,7 @@ export function createAbtestingApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `putCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `put`.'); } const request: Request = { @@ -386,27 +366,20 @@ export function createAbtestingApi( return { addUserAgent, addABTests, + del, deleteABTest, - deleteCustomRequest, + get, getABTest, - getCustomRequest, listABTests, - postCustomRequest, - putCustomRequest, + post, + put, stopABTest, }; } export type AbtestingApi = ReturnType; -export type DeleteABTestProps = { - /** - * The A/B test ID. - */ - id: number; -}; - -export type DeleteCustomRequestProps = { +export type DelProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -417,14 +390,14 @@ export type DeleteCustomRequestProps = { body?: Record; }; -export type GetABTestProps = { +export type DeleteABTestProps = { /** * The A/B test ID. */ id: number; }; -export type GetCustomRequestProps = { +export type GetProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -435,6 +408,13 @@ export type GetCustomRequestProps = { parameters?: string; }; +export type GetABTestProps = { + /** + * The A/B test ID. + */ + id: number; +}; + export type ListABTestsProps = { /** * Position of the starting record. Used for paging. 0 is the first record. @@ -446,7 +426,7 @@ export type ListABTestsProps = { limit?: number; }; -export type PostCustomRequestProps = { +export type PostProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -457,7 +437,7 @@ export type PostCustomRequestProps = { body?: Record; }; -export type PutCustomRequestProps = { +export type PutProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts index 5071680e2a..5ef5e59515 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts @@ -74,17 +74,14 @@ export function createAnalyticsApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param deleteCustomRequest - The deleteCustomRequest object. - * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param deleteCustomRequest.body - The parameters to send with the custom request. - */ - function deleteCustomRequest({ - path, - body, - }: DeleteCustomRequestProps): Promise> { + * @param del - The del object. + * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.body - The parameters to send with the custom request. + */ + function del({ path, body }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -93,9 +90,7 @@ export function createAnalyticsApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `deleteCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `del`.'); } const request: Request = { @@ -110,6 +105,41 @@ export function createAnalyticsApi( }); } + /** + * This method allow you to send requests to the Algolia REST API. + * + * @summary Send GET requests to the Algolia REST API. + * @param get - The get object. + * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + function get({ path, parameters }: GetProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error('Parameter `path` is required when calling `get`.'); + } + + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + + const request: Request = { + method: 'GET', + path: requestPath, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + /** * Returns the average click position. The endpoint returns a value for the complete given time range, as well as a value per day. * @@ -322,46 +352,6 @@ export function createAnalyticsApi( }); } - /** - * The getCustomRequest method allow you to send requests to the Algolia REST API. - * - * @summary Send GET requests to the Algolia REST API. - * @param getCustomRequest - The getCustomRequest object. - * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. - */ - function getCustomRequest({ - path, - parameters, - }: GetCustomRequestProps): Promise> { - const requestPath = '/1{path}'.replace( - '{path}', - encodeURIComponent(String(path)) - ); - const headers: Headers = { Accept: 'application/json' }; - const queryParameters: Record = {}; - - if (!path) { - throw new Error( - 'Parameter `path` is required when calling `getCustomRequest`.' - ); - } - - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } - - const request: Request = { - method: 'GET', - path: requestPath, - }; - - return transporter.request(request, { - queryParameters, - headers, - }); - } - /** * Returns the rate at which searches didn\'t lead to any clicks. The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of searches and searches without clicks. * @@ -1191,17 +1181,14 @@ export function createAnalyticsApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param postCustomRequest - The postCustomRequest object. - * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param postCustomRequest.body - The parameters to send with the custom request. - */ - function postCustomRequest({ - path, - body, - }: PostCustomRequestProps): Promise> { + * @param post - The post object. + * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.body - The parameters to send with the custom request. + */ + function post({ path, body }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -1210,9 +1197,7 @@ export function createAnalyticsApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `postCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `post`.'); } const request: Request = { @@ -1228,17 +1213,14 @@ export function createAnalyticsApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param putCustomRequest - The putCustomRequest object. - * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param putCustomRequest.body - The parameters to send with the custom request. - */ - function putCustomRequest({ - path, - body, - }: PutCustomRequestProps): Promise> { + * @param put - The put object. + * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.body - The parameters to send with the custom request. + */ + function put({ path, body }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -1247,9 +1229,7 @@ export function createAnalyticsApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `putCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `put`.'); } const request: Request = { @@ -1266,12 +1246,12 @@ export function createAnalyticsApi( return { addUserAgent, - deleteCustomRequest, + del, + get, getAverageClickPosition, getClickPositions, getClickThroughRate, getConversationRate, - getCustomRequest, getNoClickRate, getNoResultsRate, getSearchesCount, @@ -1285,14 +1265,14 @@ export function createAnalyticsApi( getTopHits, getTopSearches, getUsersCount, - postCustomRequest, - putCustomRequest, + post, + put, }; } export type AnalyticsApi = ReturnType; -export type DeleteCustomRequestProps = { +export type DelProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -1303,6 +1283,17 @@ export type DeleteCustomRequestProps = { body?: Record; }; +export type GetProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; +}; + export type GetAverageClickPositionProps = { /** * The index name to target. @@ -1379,17 +1370,6 @@ export type GetConversationRateProps = { tags?: string; }; -export type GetCustomRequestProps = { - /** - * The path of the API endpoint to target, anything after the /1 needs to be specified. - */ - path: string; - /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. - */ - parameters?: string; -}; - export type GetNoClickRateProps = { /** * The index name to target. @@ -1729,7 +1709,7 @@ export type GetUsersCountProps = { tags?: string; }; -export type PostCustomRequestProps = { +export type PostProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -1740,7 +1720,7 @@ export type PostCustomRequestProps = { body?: Record; }; -export type PutCustomRequestProps = { +export type PutProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts b/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts index 2ba51eedf7..60313eff7b 100644 --- a/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts @@ -57,17 +57,14 @@ export function createInsightsApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param deleteCustomRequest - The deleteCustomRequest object. - * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param deleteCustomRequest.body - The parameters to send with the custom request. + * @param del - The del object. + * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.body - The parameters to send with the custom request. */ - function deleteCustomRequest({ - path, - body, - }: DeleteCustomRequestProps): Promise> { + function del({ path, body }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -76,9 +73,7 @@ export function createInsightsApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `deleteCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `del`.'); } const request: Request = { @@ -94,17 +89,14 @@ export function createInsightsApi( } /** - * The getCustomRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send GET requests to the Algolia REST API. - * @param getCustomRequest - The getCustomRequest object. - * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get - The get object. + * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - function getCustomRequest({ - path, - parameters, - }: GetCustomRequestProps): Promise> { + function get({ path, parameters }: GetProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -113,9 +105,7 @@ export function createInsightsApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `getCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `get`.'); } if (parameters !== undefined) { @@ -134,17 +124,14 @@ export function createInsightsApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param postCustomRequest - The postCustomRequest object. - * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param postCustomRequest.body - The parameters to send with the custom request. + * @param post - The post object. + * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.body - The parameters to send with the custom request. */ - function postCustomRequest({ - path, - body, - }: PostCustomRequestProps): Promise> { + function post({ path, body }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -153,9 +140,7 @@ export function createInsightsApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `postCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `post`.'); } const request: Request = { @@ -208,17 +193,14 @@ export function createInsightsApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param putCustomRequest - The putCustomRequest object. - * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param putCustomRequest.body - The parameters to send with the custom request. + * @param put - The put object. + * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.body - The parameters to send with the custom request. */ - function putCustomRequest({ - path, - body, - }: PutCustomRequestProps): Promise> { + function put({ path, body }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -227,9 +209,7 @@ export function createInsightsApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `putCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `put`.'); } const request: Request = { @@ -244,19 +224,12 @@ export function createInsightsApi( }); } - return { - addUserAgent, - deleteCustomRequest, - getCustomRequest, - postCustomRequest, - pushEvents, - putCustomRequest, - }; + return { addUserAgent, del, get, post, pushEvents, put }; } export type InsightsApi = ReturnType; -export type DeleteCustomRequestProps = { +export type DelProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -267,7 +240,7 @@ export type DeleteCustomRequestProps = { body?: Record; }; -export type GetCustomRequestProps = { +export type GetProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -278,7 +251,7 @@ export type GetCustomRequestProps = { parameters?: string; }; -export type PostCustomRequestProps = { +export type PostProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -289,7 +262,7 @@ export type PostCustomRequestProps = { body?: Record; }; -export type PutCustomRequestProps = { +export type PutProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts b/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts index 7f6c5ca7cb..4822a02a3f 100644 --- a/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts @@ -57,17 +57,14 @@ export function createPersonalizationApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param deleteCustomRequest - The deleteCustomRequest object. - * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param deleteCustomRequest.body - The parameters to send with the custom request. + * @param del - The del object. + * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.body - The parameters to send with the custom request. */ - function deleteCustomRequest({ - path, - body, - }: DeleteCustomRequestProps): Promise> { + function del({ path, body }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -76,9 +73,7 @@ export function createPersonalizationApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `deleteCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `del`.'); } const request: Request = { @@ -128,17 +123,14 @@ export function createPersonalizationApi( } /** - * The getCustomRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send GET requests to the Algolia REST API. - * @param getCustomRequest - The getCustomRequest object. - * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get - The get object. + * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - function getCustomRequest({ - path, - parameters, - }: GetCustomRequestProps): Promise> { + function get({ path, parameters }: GetProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -147,9 +139,7 @@ export function createPersonalizationApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `getCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `get`.'); } if (parameters !== undefined) { @@ -223,17 +213,14 @@ export function createPersonalizationApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param postCustomRequest - The postCustomRequest object. - * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param postCustomRequest.body - The parameters to send with the custom request. + * @param post - The post object. + * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.body - The parameters to send with the custom request. */ - function postCustomRequest({ - path, - body, - }: PostCustomRequestProps): Promise> { + function post({ path, body }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -242,9 +229,7 @@ export function createPersonalizationApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `postCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `post`.'); } const request: Request = { @@ -260,17 +245,14 @@ export function createPersonalizationApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param putCustomRequest - The putCustomRequest object. - * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param putCustomRequest.body - The parameters to send with the custom request. + * @param put - The put object. + * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.body - The parameters to send with the custom request. */ - function putCustomRequest({ - path, - body, - }: PutCustomRequestProps): Promise> { + function put({ path, body }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -279,9 +261,7 @@ export function createPersonalizationApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `putCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `put`.'); } const request: Request = { @@ -345,20 +325,20 @@ export function createPersonalizationApi( return { addUserAgent, - deleteCustomRequest, + del, deleteUserProfile, - getCustomRequest, + get, getPersonalizationStrategy, getUserTokenProfile, - postCustomRequest, - putCustomRequest, + post, + put, setPersonalizationStrategy, }; } export type PersonalizationApi = ReturnType; -export type DeleteCustomRequestProps = { +export type DelProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -376,7 +356,7 @@ export type DeleteUserProfileProps = { userToken: string; }; -export type GetCustomRequestProps = { +export type GetProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -394,7 +374,7 @@ export type GetUserTokenProfileProps = { userToken: string; }; -export type PostCustomRequestProps = { +export type PostProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -405,7 +385,7 @@ export type PostCustomRequestProps = { body?: Record; }; -export type PutCustomRequestProps = { +export type PutProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts b/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts index 1aabbb26ad..809e15d504 100644 --- a/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts @@ -51,17 +51,14 @@ export function createPredictApi(options: CreateClientOptions) { } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param deleteCustomRequest - The deleteCustomRequest object. - * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param deleteCustomRequest.body - The parameters to send with the custom request. + * @param del - The del object. + * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.body - The parameters to send with the custom request. */ - function deleteCustomRequest({ - path, - body, - }: DeleteCustomRequestProps): Promise> { + function del({ path, body }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -70,9 +67,7 @@ export function createPredictApi(options: CreateClientOptions) { const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `deleteCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `del`.'); } const request: Request = { @@ -131,17 +126,14 @@ export function createPredictApi(options: CreateClientOptions) { } /** - * The getCustomRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send GET requests to the Algolia REST API. - * @param getCustomRequest - The getCustomRequest object. - * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get - The get object. + * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - function getCustomRequest({ - path, - parameters, - }: GetCustomRequestProps): Promise> { + function get({ path, parameters }: GetProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -150,9 +142,7 @@ export function createPredictApi(options: CreateClientOptions) { const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `getCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `get`.'); } if (parameters !== undefined) { @@ -171,17 +161,14 @@ export function createPredictApi(options: CreateClientOptions) { } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param postCustomRequest - The postCustomRequest object. - * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param postCustomRequest.body - The parameters to send with the custom request. + * @param post - The post object. + * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.body - The parameters to send with the custom request. */ - function postCustomRequest({ - path, - body, - }: PostCustomRequestProps): Promise> { + function post({ path, body }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -190,9 +177,7 @@ export function createPredictApi(options: CreateClientOptions) { const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `postCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `post`.'); } const request: Request = { @@ -208,17 +193,14 @@ export function createPredictApi(options: CreateClientOptions) { } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param putCustomRequest - The putCustomRequest object. - * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param putCustomRequest.body - The parameters to send with the custom request. + * @param put - The put object. + * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.body - The parameters to send with the custom request. */ - function putCustomRequest({ - path, - body, - }: PutCustomRequestProps): Promise> { + function put({ path, body }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -227,9 +209,7 @@ export function createPredictApi(options: CreateClientOptions) { const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `putCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `put`.'); } const request: Request = { @@ -244,19 +224,12 @@ export function createPredictApi(options: CreateClientOptions) { }); } - return { - addUserAgent, - deleteCustomRequest, - fetchUserProfile, - getCustomRequest, - postCustomRequest, - putCustomRequest, - }; + return { addUserAgent, del, fetchUserProfile, get, post, put }; } export type PredictApi = ReturnType; -export type DeleteCustomRequestProps = { +export type DelProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -275,7 +248,7 @@ export type FetchUserProfileProps = { params: Params; }; -export type GetCustomRequestProps = { +export type GetProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -286,7 +259,7 @@ export type GetCustomRequestProps = { parameters?: string; }; -export type PostCustomRequestProps = { +export type PostProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -297,7 +270,7 @@ export type PostCustomRequestProps = { body?: Record; }; -export type PutCustomRequestProps = { +export type PutProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts index a29d537f3e..5f8234eacf 100644 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts @@ -89,6 +89,38 @@ export function createQuerySuggestionsApi( }); } + /** + * This method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param del - The del object. + * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.body - The parameters to send with the custom request. + */ + function del({ path, body }: DelProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error('Parameter `path` is required when calling `del`.'); + } + + const request: Request = { + method: 'DELETE', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + /** * Delete a configuration of a Query Suggestion\'s index. By deleting a configuraton, you stop all updates to the underlying query suggestion index. Note that when doing this, the underlying index does not change - existing suggestions remain untouched. * @@ -124,17 +156,14 @@ export function createQuerySuggestionsApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * - * @summary Send requests to the Algolia REST API. - * @param deleteCustomRequest - The deleteCustomRequest object. - * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param deleteCustomRequest.body - The parameters to send with the custom request. + * @summary Send GET requests to the Algolia REST API. + * @param get - The get object. + * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - function deleteCustomRequest({ - path, - body, - }: DeleteCustomRequestProps): Promise> { + function get({ path, parameters }: GetProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -143,15 +172,16 @@ export function createQuerySuggestionsApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `deleteCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `get`.'); + } + + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); } const request: Request = { - method: 'DELETE', + method: 'GET', path: requestPath, - data: body, }; return transporter.request(request, { @@ -249,46 +279,6 @@ export function createQuerySuggestionsApi( }); } - /** - * The getCustomRequest method allow you to send requests to the Algolia REST API. - * - * @summary Send GET requests to the Algolia REST API. - * @param getCustomRequest - The getCustomRequest object. - * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. - */ - function getCustomRequest({ - path, - parameters, - }: GetCustomRequestProps): Promise> { - const requestPath = '/1{path}'.replace( - '{path}', - encodeURIComponent(String(path)) - ); - const headers: Headers = { Accept: 'application/json' }; - const queryParameters: Record = {}; - - if (!path) { - throw new Error( - 'Parameter `path` is required when calling `getCustomRequest`.' - ); - } - - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } - - const request: Request = { - method: 'GET', - path: requestPath, - }; - - return transporter.request(request, { - queryParameters, - headers, - }); - } - /** * Get the log file of the last build of a single Query Suggestion index. * @@ -322,17 +312,14 @@ export function createQuerySuggestionsApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param postCustomRequest - The postCustomRequest object. - * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param postCustomRequest.body - The parameters to send with the custom request. + * @param post - The post object. + * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.body - The parameters to send with the custom request. */ - function postCustomRequest({ - path, - body, - }: PostCustomRequestProps): Promise> { + function post({ path, body }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -341,9 +328,7 @@ export function createQuerySuggestionsApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `postCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `post`.'); } const request: Request = { @@ -359,17 +344,14 @@ export function createQuerySuggestionsApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param putCustomRequest - The putCustomRequest object. - * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param putCustomRequest.body - The parameters to send with the custom request. + * @param put - The put object. + * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.body - The parameters to send with the custom request. */ - function putCustomRequest({ - path, - body, - }: PutCustomRequestProps): Promise> { + function put({ path, body }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -378,9 +360,7 @@ export function createQuerySuggestionsApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `putCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `put`.'); } const request: Request = { @@ -447,21 +427,32 @@ export function createQuerySuggestionsApi( return { addUserAgent, createConfig, + del, deleteConfig, - deleteCustomRequest, + get, getAllConfigs, getConfig, getConfigStatus, - getCustomRequest, getLogFile, - postCustomRequest, - putCustomRequest, + post, + put, updateConfig, }; } export type QuerySuggestionsApi = ReturnType; +export type DelProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type DeleteConfigProps = { /** * The index in which to perform the request. @@ -469,15 +460,15 @@ export type DeleteConfigProps = { indexName: string; }; -export type DeleteCustomRequestProps = { +export type GetProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; /** - * The parameters to send with the custom request. + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - body?: Record; + parameters?: string; }; export type GetConfigProps = { @@ -494,17 +485,6 @@ export type GetConfigStatusProps = { indexName: string; }; -export type GetCustomRequestProps = { - /** - * The path of the API endpoint to target, anything after the /1 needs to be specified. - */ - path: string; - /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. - */ - parameters?: string; -}; - export type GetLogFileProps = { /** * The index in which to perform the request. @@ -512,7 +492,7 @@ export type GetLogFileProps = { indexName: string; }; -export type PostCustomRequestProps = { +export type PostProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -523,7 +503,7 @@ export type PostCustomRequestProps = { body?: Record; }; -export type PutCustomRequestProps = { +export type PutProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts index c4bd9f69ac..ebd8f4b032 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts @@ -647,6 +647,38 @@ export function createSearchApi(options: CreateClientOptions) { }); } + /** + * This method allow you to send requests to the Algolia REST API. + * + * @summary Send requests to the Algolia REST API. + * @param del - The del object. + * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.body - The parameters to send with the custom request. + */ + function del({ path, body }: DelProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (!path) { + throw new Error('Parameter `path` is required when calling `del`.'); + } + + const request: Request = { + method: 'DELETE', + path: requestPath, + data: body, + }; + + return transporter.request(request, { + queryParameters, + headers, + }); + } + /** * Delete an existing API Key. * @@ -724,43 +756,6 @@ export function createSearchApi(options: CreateClientOptions) { }); } - /** - * The customRequest method allow you to send requests to the Algolia REST API. - * - * @summary Send requests to the Algolia REST API. - * @param deleteCustomRequest - The deleteCustomRequest object. - * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param deleteCustomRequest.body - The parameters to send with the custom request. - */ - function deleteCustomRequest({ - path, - body, - }: DeleteCustomRequestProps): Promise> { - const requestPath = '/1{path}'.replace( - '{path}', - encodeURIComponent(String(path)) - ); - const headers: Headers = { Accept: 'application/json' }; - const queryParameters: Record = {}; - - if (!path) { - throw new Error( - 'Parameter `path` is required when calling `deleteCustomRequest`.' - ); - } - - const request: Request = { - method: 'DELETE', - path: requestPath, - data: body, - }; - - return transporter.request(request, { - queryParameters, - headers, - }); - } - /** * Delete an existing index. * @@ -965,22 +960,27 @@ export function createSearchApi(options: CreateClientOptions) { } /** - * Get the permissions of an API key. + * This method allow you to send requests to the Algolia REST API. * - * @summary Get an API key. - * @param getApiKey - The getApiKey object. - * @param getApiKey.key - API Key string. + * @summary Send GET requests to the Algolia REST API. + * @param get - The get object. + * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - function getApiKey({ key }: GetApiKeyProps): Promise { - const requestPath = '/1/keys/{key}'.replace( - '{key}', - encodeURIComponent(String(key)) + function get({ path, parameters }: GetProps): Promise> { + const requestPath = '/1{path}'.replace( + '{path}', + encodeURIComponent(String(path)) ); const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; - if (!key) { - throw new Error('Parameter `key` is required when calling `getApiKey`.'); + if (!path) { + throw new Error('Parameter `path` is required when calling `get`.'); + } + + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); } const request: Request = { @@ -995,32 +995,22 @@ export function createSearchApi(options: CreateClientOptions) { } /** - * The getCustomRequest method allow you to send requests to the Algolia REST API. + * Get the permissions of an API key. * - * @summary Send GET requests to the Algolia REST API. - * @param getCustomRequest - The getCustomRequest object. - * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. - */ - function getCustomRequest({ - path, - parameters, - }: GetCustomRequestProps): Promise> { - const requestPath = '/1{path}'.replace( - '{path}', - encodeURIComponent(String(path)) + * @summary Get an API key. + * @param getApiKey - The getApiKey object. + * @param getApiKey.key - API Key string. + */ + function getApiKey({ key }: GetApiKeyProps): Promise { + const requestPath = '/1/keys/{key}'.replace( + '{key}', + encodeURIComponent(String(key)) ); const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; - if (!path) { - throw new Error( - 'Parameter `path` is required when calling `getCustomRequest`.' - ); - } - - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); + if (!key) { + throw new Error('Parameter `key` is required when calling `getApiKey`.'); } const request: Request = { @@ -1741,17 +1731,14 @@ export function createSearchApi(options: CreateClientOptions) { } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param postCustomRequest - The postCustomRequest object. - * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param postCustomRequest.body - The parameters to send with the custom request. + * @param post - The post object. + * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.body - The parameters to send with the custom request. */ - function postCustomRequest({ - path, - body, - }: PostCustomRequestProps): Promise> { + function post({ path, body }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -1760,9 +1747,7 @@ export function createSearchApi(options: CreateClientOptions) { const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `postCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `post`.'); } const request: Request = { @@ -1778,17 +1763,14 @@ export function createSearchApi(options: CreateClientOptions) { } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param putCustomRequest - The putCustomRequest object. - * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param putCustomRequest.body - The parameters to send with the custom request. + * @param put - The put object. + * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.body - The parameters to send with the custom request. */ - function putCustomRequest({ - path, - body, - }: PutCustomRequestProps): Promise> { + function put({ path, body }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -1797,9 +1779,7 @@ export function createSearchApi(options: CreateClientOptions) { const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `putCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `put`.'); } const request: Request = { @@ -2563,16 +2543,16 @@ export function createSearchApi(options: CreateClientOptions) { clearAllSynonyms, clearObjects, clearRules, + del, deleteApiKey, deleteBy, - deleteCustomRequest, deleteIndex, deleteObject, deleteRule, deleteSource, deleteSynonym, + get, getApiKey, - getCustomRequest, getDictionaryLanguages, getDictionarySettings, getLogs, @@ -2594,8 +2574,8 @@ export function createSearchApi(options: CreateClientOptions) { multipleQueries, operationIndex, partialUpdateObject, - postCustomRequest, - putCustomRequest, + post, + put, removeUserId, replaceSources, restoreApiKey, @@ -2717,6 +2697,17 @@ export type ClearRulesProps = { forwardToReplicas?: boolean; }; +export type DelProps = { + /** + * The path of the API endpoint to target, anything after the /1 needs to be specified. + */ + path: string; + /** + * The parameters to send with the custom request. + */ + body?: Record; +}; + export type DeleteApiKeyProps = { /** * API Key string. @@ -2732,17 +2723,6 @@ export type DeleteByProps = { searchParams: SearchParams; }; -export type DeleteCustomRequestProps = { - /** - * The path of the API endpoint to target, anything after the /1 needs to be specified. - */ - path: string; - /** - * The parameters to send with the custom request. - */ - body?: Record; -}; - export type DeleteIndexProps = { /** * The index in which to perform the request. @@ -2798,14 +2778,7 @@ export type DeleteSynonymProps = { forwardToReplicas?: boolean; }; -export type GetApiKeyProps = { - /** - * API Key string. - */ - key: string; -}; - -export type GetCustomRequestProps = { +export type GetProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -2816,6 +2789,13 @@ export type GetCustomRequestProps = { parameters?: string; }; +export type GetApiKeyProps = { + /** + * API Key string. + */ + key: string; +}; + export type GetLogsProps = { /** * First entry to retrieve (zero-based). Log entries are sorted by decreasing date, therefore 0 designates the most recent log entry. @@ -2949,7 +2929,7 @@ export type PartialUpdateObjectProps = { createIfNotExists?: boolean; }; -export type PostCustomRequestProps = { +export type PostProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -2960,7 +2940,7 @@ export type PostCustomRequestProps = { body?: Record; }; -export type PutCustomRequestProps = { +export type PutProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts b/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts index 90b176120b..b58d5c227f 100644 --- a/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts @@ -55,17 +55,14 @@ export function createSourcesApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param deleteCustomRequest - The deleteCustomRequest object. - * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param deleteCustomRequest.body - The parameters to send with the custom request. + * @param del - The del object. + * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.body - The parameters to send with the custom request. */ - function deleteCustomRequest({ - path, - body, - }: DeleteCustomRequestProps): Promise> { + function del({ path, body }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -74,9 +71,7 @@ export function createSourcesApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `deleteCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `del`.'); } const request: Request = { @@ -92,17 +87,14 @@ export function createSourcesApi( } /** - * The getCustomRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send GET requests to the Algolia REST API. - * @param getCustomRequest - The getCustomRequest object. - * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get - The get object. + * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - function getCustomRequest({ - path, - parameters, - }: GetCustomRequestProps): Promise> { + function get({ path, parameters }: GetProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -111,9 +103,7 @@ export function createSourcesApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `getCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `get`.'); } if (parameters !== undefined) { @@ -132,17 +122,14 @@ export function createSourcesApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param postCustomRequest - The postCustomRequest object. - * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param postCustomRequest.body - The parameters to send with the custom request. + * @param post - The post object. + * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.body - The parameters to send with the custom request. */ - function postCustomRequest({ - path, - body, - }: PostCustomRequestProps): Promise> { + function post({ path, body }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -151,9 +138,7 @@ export function createSourcesApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `postCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `post`.'); } const request: Request = { @@ -216,17 +201,14 @@ export function createSourcesApi( } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param putCustomRequest - The putCustomRequest object. - * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param putCustomRequest.body - The parameters to send with the custom request. + * @param put - The put object. + * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.body - The parameters to send with the custom request. */ - function putCustomRequest({ - path, - body, - }: PutCustomRequestProps): Promise> { + function put({ path, body }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -235,9 +217,7 @@ export function createSourcesApi( const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `putCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `put`.'); } const request: Request = { @@ -252,19 +232,12 @@ export function createSourcesApi( }); } - return { - addUserAgent, - deleteCustomRequest, - getCustomRequest, - postCustomRequest, - postIngestUrl, - putCustomRequest, - }; + return { addUserAgent, del, get, post, postIngestUrl, put }; } export type SourcesApi = ReturnType; -export type DeleteCustomRequestProps = { +export type DelProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -275,7 +248,7 @@ export type DeleteCustomRequestProps = { body?: Record; }; -export type GetCustomRequestProps = { +export type GetProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -286,7 +259,7 @@ export type GetCustomRequestProps = { parameters?: string; }; -export type PostCustomRequestProps = { +export type PostProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -297,7 +270,7 @@ export type PostCustomRequestProps = { body?: Record; }; -export type PutCustomRequestProps = { +export type PutProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ diff --git a/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts b/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts index c68afaa38f..9ee3728e43 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts +++ b/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts @@ -77,17 +77,14 @@ export function createRecommendApi(options: CreateClientOptions) { } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param deleteCustomRequest - The deleteCustomRequest object. - * @param deleteCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param deleteCustomRequest.body - The parameters to send with the custom request. + * @param del - The del object. + * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.body - The parameters to send with the custom request. */ - function deleteCustomRequest({ - path, - body, - }: DeleteCustomRequestProps): Promise> { + function del({ path, body }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -96,9 +93,7 @@ export function createRecommendApi(options: CreateClientOptions) { const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `deleteCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `del`.'); } const request: Request = { @@ -114,17 +109,14 @@ export function createRecommendApi(options: CreateClientOptions) { } /** - * The getCustomRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send GET requests to the Algolia REST API. - * @param getCustomRequest - The getCustomRequest object. - * @param getCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param getCustomRequest.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get - The get object. + * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. */ - function getCustomRequest({ - path, - parameters, - }: GetCustomRequestProps): Promise> { + function get({ path, parameters }: GetProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -133,9 +125,7 @@ export function createRecommendApi(options: CreateClientOptions) { const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `getCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `get`.'); } if (parameters !== undefined) { @@ -191,17 +181,14 @@ export function createRecommendApi(options: CreateClientOptions) { } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param postCustomRequest - The postCustomRequest object. - * @param postCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param postCustomRequest.body - The parameters to send with the custom request. + * @param post - The post object. + * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.body - The parameters to send with the custom request. */ - function postCustomRequest({ - path, - body, - }: PostCustomRequestProps): Promise> { + function post({ path, body }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -210,9 +197,7 @@ export function createRecommendApi(options: CreateClientOptions) { const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `postCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `post`.'); } const request: Request = { @@ -228,17 +213,14 @@ export function createRecommendApi(options: CreateClientOptions) { } /** - * The customRequest method allow you to send requests to the Algolia REST API. + * This method allow you to send requests to the Algolia REST API. * * @summary Send requests to the Algolia REST API. - * @param putCustomRequest - The putCustomRequest object. - * @param putCustomRequest.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param putCustomRequest.body - The parameters to send with the custom request. + * @param put - The put object. + * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.body - The parameters to send with the custom request. */ - function putCustomRequest({ - path, - body, - }: PutCustomRequestProps): Promise> { + function put({ path, body }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -247,9 +229,7 @@ export function createRecommendApi(options: CreateClientOptions) { const queryParameters: Record = {}; if (!path) { - throw new Error( - 'Parameter `path` is required when calling `putCustomRequest`.' - ); + throw new Error('Parameter `path` is required when calling `put`.'); } const request: Request = { @@ -264,19 +244,12 @@ export function createRecommendApi(options: CreateClientOptions) { }); } - return { - addUserAgent, - deleteCustomRequest, - getCustomRequest, - getRecommendations, - postCustomRequest, - putCustomRequest, - }; + return { addUserAgent, del, get, getRecommendations, post, put }; } export type RecommendApi = ReturnType; -export type DeleteCustomRequestProps = { +export type DelProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -287,7 +260,7 @@ export type DeleteCustomRequestProps = { body?: Record; }; -export type GetCustomRequestProps = { +export type GetProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -298,7 +271,7 @@ export type GetCustomRequestProps = { parameters?: string; }; -export type PostCustomRequestProps = { +export type PostProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ @@ -309,7 +282,7 @@ export type PostCustomRequestProps = { body?: Record; }; -export type PutCustomRequestProps = { +export type PutProps = { /** * The path of the API endpoint to target, anything after the /1 needs to be specified. */ diff --git a/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php b/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php index f66f59a820..35abce834e 100644 --- a/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php +++ b/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php @@ -113,37 +113,6 @@ public function addABTests($addABTestsRequest) return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); } - /** - * Deletes the A/B Test. - * - * @param int $id The A/B test ID. (required) - * - * @return array - */ - public function deleteABTest($id) - { - // verify the required parameter 'id' is set - if ($id === null || (is_array($id) && count($id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $id when calling deleteABTest' - ); - } - - $resourcePath = '/2/abtests/{id}'; - $queryParams = []; - $httpBody = []; - // path params - if ($id !== null) { - $resourcePath = str_replace( - '{' . 'id' . '}', - ObjectSerializer::toPathValue($id), - $resourcePath - ); - } - - return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); - } - /** * Send requests to the Algolia REST API. * @@ -152,12 +121,12 @@ public function deleteABTest($id) * * @return array */ - public function deleteCustomRequest($path, $body = null) + public function del($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling deleteCustomRequest' + 'Missing the required parameter $path when calling del' ); } @@ -181,18 +150,18 @@ public function deleteCustomRequest($path, $body = null) } /** - * Returns metadata and metrics for A/B test id. + * Deletes the A/B Test. * * @param int $id The A/B test ID. (required) * * @return array */ - public function getABTest($id) + public function deleteABTest($id) { // verify the required parameter 'id' is set if ($id === null || (is_array($id) && count($id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $id when calling getABTest' + 'Missing the required parameter $id when calling deleteABTest' ); } @@ -208,7 +177,7 @@ public function getABTest($id) ); } - return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); + return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); } /** @@ -219,12 +188,12 @@ public function getABTest($id) * * @return array */ - public function getCustomRequest($path, $parameters = null) + public function get($path, $parameters = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling getCustomRequest' + 'Missing the required parameter $path when calling get' ); } @@ -253,6 +222,37 @@ public function getCustomRequest($path, $parameters = null) return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } + /** + * Returns metadata and metrics for A/B test id. + * + * @param int $id The A/B test ID. (required) + * + * @return array + */ + public function getABTest($id) + { + // verify the required parameter 'id' is set + if ($id === null || (is_array($id) && count($id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $id when calling getABTest' + ); + } + + $resourcePath = '/2/abtests/{id}'; + $queryParams = []; + $httpBody = []; + // path params + if ($id !== null) { + $resourcePath = str_replace( + '{' . 'id' . '}', + ObjectSerializer::toPathValue($id), + $resourcePath + ); + } + + return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); + } + /** * Fetch all existing A/B tests for App that are available for the current API Key. * @@ -298,12 +298,12 @@ public function listABTests($offset = 0, $limit = 10) * * @return array */ - public function postCustomRequest($path, $body = null) + public function post($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling postCustomRequest' + 'Missing the required parameter $path when calling post' ); } @@ -334,12 +334,12 @@ public function postCustomRequest($path, $body = null) * * @return array */ - public function putCustomRequest($path, $body = null) + public function put($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling putCustomRequest' + 'Missing the required parameter $path when calling put' ); } diff --git a/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php b/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php index 0ccff743af..981262d35c 100644 --- a/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php @@ -94,12 +94,12 @@ public function getClientConfig() * * @return array */ - public function deleteCustomRequest($path, $body = null) + public function del($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling deleteCustomRequest' + 'Missing the required parameter $path when calling del' ); } @@ -122,6 +122,48 @@ public function deleteCustomRequest($path, $body = null) return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); } + /** + * Send GET requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * + * @return array + */ + public function get($path, $parameters = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling get' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); + } + /** * Returns the average click position. * @@ -414,48 +456,6 @@ public function getConversationRate($index, $startDate = null, $endDate = null, return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } - /** - * Send GET requests to the Algolia REST API. - * - * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) - * - * @return array - */ - public function getCustomRequest($path, $parameters = null) - { - // verify the required parameter 'path' is set - if ($path === null || (is_array($path) && count($path) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling getCustomRequest' - ); - } - - $resourcePath = '/1{path}'; - $queryParams = []; - $httpBody = []; - - if ($parameters !== null) { - if ('form' === 'form' && is_array($parameters)) { - foreach ($parameters as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['parameters'] = $parameters; - } - } - // path params - if ($path !== null) { - $resourcePath = str_replace( - '{' . 'path' . '}', - ObjectSerializer::toPathValue($path), - $resourcePath - ); - } - - return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); - } - /** * Returns the rate at which searches didn't lead to any clicks. * @@ -1652,12 +1652,12 @@ public function getUsersCount($index, $startDate = null, $endDate = null, $tags * * @return array */ - public function postCustomRequest($path, $body = null) + public function post($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling postCustomRequest' + 'Missing the required parameter $path when calling post' ); } @@ -1688,12 +1688,12 @@ public function postCustomRequest($path, $body = null) * * @return array */ - public function putCustomRequest($path, $body = null) + public function put($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling putCustomRequest' + 'Missing the required parameter $path when calling put' ); } diff --git a/clients/algoliasearch-client-php/lib/Api/InsightsApi.php b/clients/algoliasearch-client-php/lib/Api/InsightsApi.php index 6aa332fab6..a32620e89d 100644 --- a/clients/algoliasearch-client-php/lib/Api/InsightsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/InsightsApi.php @@ -94,12 +94,12 @@ public function getClientConfig() * * @return array */ - public function deleteCustomRequest($path, $body = null) + public function del($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling deleteCustomRequest' + 'Missing the required parameter $path when calling del' ); } @@ -130,12 +130,12 @@ public function deleteCustomRequest($path, $body = null) * * @return array */ - public function getCustomRequest($path, $parameters = null) + public function get($path, $parameters = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling getCustomRequest' + 'Missing the required parameter $path when calling get' ); } @@ -172,12 +172,12 @@ public function getCustomRequest($path, $parameters = null) * * @return array */ - public function postCustomRequest($path, $body = null) + public function post($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling postCustomRequest' + 'Missing the required parameter $path when calling post' ); } @@ -235,12 +235,12 @@ public function pushEvents($insightEvents) * * @return array */ - public function putCustomRequest($path, $body = null) + public function put($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling putCustomRequest' + 'Missing the required parameter $path when calling put' ); } diff --git a/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php b/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php index 556146e277..18b3b5b830 100644 --- a/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php +++ b/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php @@ -94,12 +94,12 @@ public function getClientConfig() * * @return array */ - public function deleteCustomRequest($path, $body = null) + public function del($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling deleteCustomRequest' + 'Missing the required parameter $path when calling del' ); } @@ -161,12 +161,12 @@ public function deleteUserProfile($userToken) * * @return array */ - public function getCustomRequest($path, $parameters = null) + public function get($path, $parameters = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling getCustomRequest' + 'Missing the required parameter $path when calling get' ); } @@ -249,12 +249,12 @@ public function getUserTokenProfile($userToken) * * @return array */ - public function postCustomRequest($path, $body = null) + public function post($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling postCustomRequest' + 'Missing the required parameter $path when calling post' ); } @@ -285,12 +285,12 @@ public function postCustomRequest($path, $body = null) * * @return array */ - public function putCustomRequest($path, $body = null) + public function put($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling putCustomRequest' + 'Missing the required parameter $path when calling put' ); } diff --git a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php index 31694c971c..afba6f4e63 100644 --- a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php @@ -113,6 +113,42 @@ public function createConfig($querySuggestionsIndexWithIndexParam) return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function del($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling del' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); + } + /** * Delete a configuration of a Query Suggestion's index. * @@ -145,25 +181,35 @@ public function deleteConfig($indexName) } /** - * Send requests to the Algolia REST API. + * Send GET requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param array $body The parameters to send with the custom request. (optional) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * * @return array */ - public function deleteCustomRequest($path, $body = null) + public function get($path, $parameters = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling deleteCustomRequest' + 'Missing the required parameter $path when calling get' ); } $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -173,11 +219,7 @@ public function deleteCustomRequest($path, $body = null) ); } - if (isset($body)) { - $httpBody = $body; - } - - return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); + return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } /** @@ -257,48 +299,6 @@ public function getConfigStatus($indexName) return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); } - /** - * Send GET requests to the Algolia REST API. - * - * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) - * - * @return array - */ - public function getCustomRequest($path, $parameters = null) - { - // verify the required parameter 'path' is set - if ($path === null || (is_array($path) && count($path) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling getCustomRequest' - ); - } - - $resourcePath = '/1{path}'; - $queryParams = []; - $httpBody = []; - - if ($parameters !== null) { - if ('form' === 'form' && is_array($parameters)) { - foreach ($parameters as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['parameters'] = $parameters; - } - } - // path params - if ($path !== null) { - $resourcePath = str_replace( - '{' . 'path' . '}', - ObjectSerializer::toPathValue($path), - $resourcePath - ); - } - - return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody); - } - /** * Get the log file of the last build of a single Query Suggestion index. * @@ -338,12 +338,12 @@ public function getLogFile($indexName) * * @return array */ - public function postCustomRequest($path, $body = null) + public function post($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling postCustomRequest' + 'Missing the required parameter $path when calling post' ); } @@ -374,12 +374,12 @@ public function postCustomRequest($path, $body = null) * * @return array */ - public function putCustomRequest($path, $body = null) + public function put($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling putCustomRequest' + 'Missing the required parameter $path when calling put' ); } diff --git a/clients/algoliasearch-client-php/lib/Api/RecommendApi.php b/clients/algoliasearch-client-php/lib/Api/RecommendApi.php index 71a79d8c76..3380cb28f6 100644 --- a/clients/algoliasearch-client-php/lib/Api/RecommendApi.php +++ b/clients/algoliasearch-client-php/lib/Api/RecommendApi.php @@ -95,12 +95,12 @@ public function getClientConfig() * * @return array */ - public function deleteCustomRequest($path, $body = null) + public function del($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling deleteCustomRequest' + 'Missing the required parameter $path when calling del' ); } @@ -131,12 +131,12 @@ public function deleteCustomRequest($path, $body = null) * * @return array */ - public function getCustomRequest($path, $parameters = null) + public function get($path, $parameters = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling getCustomRequest' + 'Missing the required parameter $path when calling get' ); } @@ -200,12 +200,12 @@ public function getRecommendations($getRecommendationsParams) * * @return array */ - public function postCustomRequest($path, $body = null) + public function post($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling postCustomRequest' + 'Missing the required parameter $path when calling post' ); } @@ -236,12 +236,12 @@ public function postCustomRequest($path, $body = null) * * @return array */ - public function putCustomRequest($path, $body = null) + public function put($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling putCustomRequest' + 'Missing the required parameter $path when calling put' ); } diff --git a/clients/algoliasearch-client-php/lib/Api/SearchApi.php b/clients/algoliasearch-client-php/lib/Api/SearchApi.php index c69505cafe..598d27bfc9 100644 --- a/clients/algoliasearch-client-php/lib/Api/SearchApi.php +++ b/clients/algoliasearch-client-php/lib/Api/SearchApi.php @@ -593,6 +593,42 @@ public function clearRules($indexName, $forwardToReplicas = null) return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); } + /** + * Send requests to the Algolia REST API. + * + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param array $body The parameters to send with the custom request. (optional) + * + * @return array + */ + public function del($path, $body = null) + { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $path when calling del' + ); + } + + $resourcePath = '/1{path}'; + $queryParams = []; + $httpBody = []; + // path params + if ($path !== null) { + $resourcePath = str_replace( + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), + $resourcePath + ); + } + + if (isset($body)) { + $httpBody = $body; + } + + return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); + } + /** * Delete an API key. * @@ -666,42 +702,6 @@ public function deleteBy($indexName, $searchParams) return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); } - /** - * Send requests to the Algolia REST API. - * - * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param array $body The parameters to send with the custom request. (optional) - * - * @return array - */ - public function deleteCustomRequest($path, $body = null) - { - // verify the required parameter 'path' is set - if ($path === null || (is_array($path) && count($path) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling deleteCustomRequest' - ); - } - - $resourcePath = '/1{path}'; - $queryParams = []; - $httpBody = []; - // path params - if ($path !== null) { - $resourcePath = str_replace( - '{' . 'path' . '}', - ObjectSerializer::toPathValue($path), - $resourcePath - ); - } - - if (isset($body)) { - $httpBody = $body; - } - - return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody); - } - /** * Delete index. * @@ -925,29 +925,40 @@ public function deleteSynonym($indexName, $objectID, $forwardToReplicas = null) } /** - * Get an API key. + * Send GET requests to the Algolia REST API. * - * @param string $key API Key string. (required) + * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * * @return array */ - public function getApiKey($key) + public function get($path, $parameters = null) { - // verify the required parameter 'key' is set - if ($key === null || (is_array($key) && count($key) === 0)) { + // verify the required parameter 'path' is set + if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $key when calling getApiKey' + 'Missing the required parameter $path when calling get' ); } - $resourcePath = '/1/keys/{key}'; + $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params - if ($key !== null) { + if ($path !== null) { $resourcePath = str_replace( - '{' . 'key' . '}', - ObjectSerializer::toPathValue($key), + '{' . 'path' . '}', + ObjectSerializer::toPathValue($path), $resourcePath ); } @@ -956,40 +967,29 @@ public function getApiKey($key) } /** - * Send GET requests to the Algolia REST API. + * Get an API key. * - * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param string $key API Key string. (required) * * @return array */ - public function getCustomRequest($path, $parameters = null) + public function getApiKey($key) { - // verify the required parameter 'path' is set - if ($path === null || (is_array($path) && count($path) === 0)) { + // verify the required parameter 'key' is set + if ($key === null || (is_array($key) && count($key) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling getCustomRequest' + 'Missing the required parameter $key when calling getApiKey' ); } - $resourcePath = '/1{path}'; + $resourcePath = '/1/keys/{key}'; $queryParams = []; $httpBody = []; - - if ($parameters !== null) { - if ('form' === 'form' && is_array($parameters)) { - foreach ($parameters as $key => $value) { - $queryParams[$key] = $value; - } - } else { - $queryParams['parameters'] = $parameters; - } - } // path params - if ($path !== null) { + if ($key !== null) { $resourcePath = str_replace( - '{' . 'path' . '}', - ObjectSerializer::toPathValue($path), + '{' . 'key' . '}', + ObjectSerializer::toPathValue($key), $resourcePath ); } @@ -1698,12 +1698,12 @@ public function partialUpdateObject($indexName, $objectID, $oneOfStringBuiltInOp * * @return array */ - public function postCustomRequest($path, $body = null) + public function post($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling postCustomRequest' + 'Missing the required parameter $path when calling post' ); } @@ -1734,12 +1734,12 @@ public function postCustomRequest($path, $body = null) * * @return array */ - public function putCustomRequest($path, $body = null) + public function put($path, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $path when calling putCustomRequest' + 'Missing the required parameter $path when calling put' ); } diff --git a/specs/bundled/abtesting.yml b/specs/bundled/abtesting.yml index 8965b72b20..c80db84e08 100644 --- a/specs/bundled/abtesting.yml +++ b/specs/bundled/abtesting.yml @@ -268,11 +268,9 @@ tags: paths: /1{path}: get: - operationId: getCustomRequest + operationId: get summary: Send GET requests to the Algolia REST API. - description: >- - The getCustomRequest method allow you to send requests to the Algolia - REST API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - name: parameters @@ -301,11 +299,9 @@ paths: tags: - abtesting post: - operationId: postCustomRequest + operationId: post summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -332,11 +328,9 @@ paths: tags: - abtesting put: - operationId: putCustomRequest + operationId: put summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -363,11 +357,9 @@ paths: tags: - abtesting delete: - operationId: deleteCustomRequest + operationId: del summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: diff --git a/specs/bundled/analytics.yml b/specs/bundled/analytics.yml index e2d079342e..0756c65b36 100644 --- a/specs/bundled/analytics.yml +++ b/specs/bundled/analytics.yml @@ -429,11 +429,9 @@ tags: paths: /1{path}: get: - operationId: getCustomRequest + operationId: get summary: Send GET requests to the Algolia REST API. - description: >- - The getCustomRequest method allow you to send requests to the Algolia - REST API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - name: parameters @@ -462,11 +460,9 @@ paths: tags: - analytics post: - operationId: postCustomRequest + operationId: post summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -493,11 +489,9 @@ paths: tags: - analytics put: - operationId: putCustomRequest + operationId: put summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -524,11 +518,9 @@ paths: tags: - analytics delete: - operationId: deleteCustomRequest + operationId: del summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: diff --git a/specs/bundled/insights.yml b/specs/bundled/insights.yml index 6532cf7623..215ca4fc93 100644 --- a/specs/bundled/insights.yml +++ b/specs/bundled/insights.yml @@ -76,11 +76,9 @@ tags: paths: /1{path}: get: - operationId: getCustomRequest + operationId: get summary: Send GET requests to the Algolia REST API. - description: >- - The getCustomRequest method allow you to send requests to the Algolia - REST API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - name: parameters @@ -109,11 +107,9 @@ paths: tags: - insights post: - operationId: postCustomRequest + operationId: post summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -140,11 +136,9 @@ paths: tags: - insights put: - operationId: putCustomRequest + operationId: put summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -171,11 +165,9 @@ paths: tags: - insights delete: - operationId: deleteCustomRequest + operationId: del summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: diff --git a/specs/bundled/personalization.yml b/specs/bundled/personalization.yml index abdad0f9b3..48c88f41a5 100644 --- a/specs/bundled/personalization.yml +++ b/specs/bundled/personalization.yml @@ -144,11 +144,9 @@ tags: paths: /1{path}: get: - operationId: getCustomRequest + operationId: get summary: Send GET requests to the Algolia REST API. - description: >- - The getCustomRequest method allow you to send requests to the Algolia - REST API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - name: parameters @@ -177,11 +175,9 @@ paths: tags: - personalization post: - operationId: postCustomRequest + operationId: post summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -208,11 +204,9 @@ paths: tags: - personalization put: - operationId: putCustomRequest + operationId: put summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -239,11 +233,9 @@ paths: tags: - personalization delete: - operationId: deleteCustomRequest + operationId: del summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: diff --git a/specs/bundled/predict.yml b/specs/bundled/predict.yml index 587358cc41..e1c9cdc366 100644 --- a/specs/bundled/predict.yml +++ b/specs/bundled/predict.yml @@ -84,11 +84,9 @@ tags: paths: /1{path}: get: - operationId: getCustomRequest + operationId: get summary: Send GET requests to the Algolia REST API. - description: >- - The getCustomRequest method allow you to send requests to the Algolia - REST API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - name: parameters @@ -117,11 +115,9 @@ paths: tags: - predict post: - operationId: postCustomRequest + operationId: post summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -148,11 +144,9 @@ paths: tags: - predict put: - operationId: putCustomRequest + operationId: put summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -179,11 +173,9 @@ paths: tags: - predict delete: - operationId: deleteCustomRequest + operationId: del summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: diff --git a/specs/bundled/query-suggestions.yml b/specs/bundled/query-suggestions.yml index dae25c666f..a143485110 100644 --- a/specs/bundled/query-suggestions.yml +++ b/specs/bundled/query-suggestions.yml @@ -303,11 +303,9 @@ tags: paths: /1{path}: get: - operationId: getCustomRequest + operationId: get summary: Send GET requests to the Algolia REST API. - description: >- - The getCustomRequest method allow you to send requests to the Algolia - REST API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - name: parameters @@ -336,11 +334,9 @@ paths: tags: - query-suggestions post: - operationId: postCustomRequest + operationId: post summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -367,11 +363,9 @@ paths: tags: - query-suggestions put: - operationId: putCustomRequest + operationId: put summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -398,11 +392,9 @@ paths: tags: - query-suggestions delete: - operationId: deleteCustomRequest + operationId: del summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: diff --git a/specs/bundled/recommend.yml b/specs/bundled/recommend.yml index 714ccd27ba..eedc107c3a 100644 --- a/specs/bundled/recommend.yml +++ b/specs/bundled/recommend.yml @@ -884,11 +884,9 @@ tags: paths: /1{path}: get: - operationId: getCustomRequest + operationId: get summary: Send GET requests to the Algolia REST API. - description: >- - The getCustomRequest method allow you to send requests to the Algolia - REST API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - name: parameters @@ -917,11 +915,9 @@ paths: tags: - recommend post: - operationId: postCustomRequest + operationId: post summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -948,11 +944,9 @@ paths: tags: - recommend put: - operationId: putCustomRequest + operationId: put summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -979,11 +973,9 @@ paths: tags: - recommend delete: - operationId: deleteCustomRequest + operationId: del summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: diff --git a/specs/bundled/search.yml b/specs/bundled/search.yml index 58b8660836..9d2666d2bc 100644 --- a/specs/bundled/search.yml +++ b/specs/bundled/search.yml @@ -1864,11 +1864,9 @@ tags: paths: /1{path}: get: - operationId: getCustomRequest + operationId: get summary: Send GET requests to the Algolia REST API. - description: >- - The getCustomRequest method allow you to send requests to the Algolia - REST API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - name: parameters @@ -1897,11 +1895,9 @@ paths: tags: - search post: - operationId: postCustomRequest + operationId: post summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -1928,11 +1924,9 @@ paths: tags: - search put: - operationId: putCustomRequest + operationId: put summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -1959,11 +1953,9 @@ paths: tags: - search delete: - operationId: deleteCustomRequest + operationId: del summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: diff --git a/specs/bundled/sources.yml b/specs/bundled/sources.yml index 06483b4850..51e87e1463 100644 --- a/specs/bundled/sources.yml +++ b/specs/bundled/sources.yml @@ -92,11 +92,9 @@ tags: paths: /1{path}: get: - operationId: getCustomRequest + operationId: get summary: Send GET requests to the Algolia REST API. - description: >- - The getCustomRequest method allow you to send requests to the Algolia - REST API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - name: parameters @@ -125,11 +123,9 @@ paths: tags: - sources post: - operationId: postCustomRequest + operationId: post summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -156,11 +152,9 @@ paths: tags: - sources put: - operationId: putCustomRequest + operationId: put summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: @@ -187,11 +181,9 @@ paths: tags: - sources delete: - operationId: deleteCustomRequest + operationId: del summary: Send requests to the Algolia REST API. - description: >- - The customRequest method allow you to send requests to the Algolia REST - API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' requestBody: diff --git a/specs/common/paths/customRequest.yml b/specs/common/paths/customRequest.yml index fa392cc630..bdc8b551d5 100644 --- a/specs/common/paths/customRequest.yml +++ b/specs/common/paths/customRequest.yml @@ -2,13 +2,13 @@ get: $ref: ../schemas/CustomRequest.yml#/getCustomRequest post: - operationId: postCustomRequest + operationId: post $ref: ../schemas/CustomRequest.yml#/customRequest put: - operationId: putCustomRequest + operationId: put $ref: ../schemas/CustomRequest.yml#/customRequest delete: - operationId: deleteCustomRequest + operationId: del $ref: ../schemas/CustomRequest.yml#/customRequest diff --git a/specs/common/schemas/CustomRequest.yml b/specs/common/schemas/CustomRequest.yml index bf33eed3dd..5908849c70 100644 --- a/specs/common/schemas/CustomRequest.yml +++ b/specs/common/schemas/CustomRequest.yml @@ -1,6 +1,6 @@ customRequest: summary: Send requests to the Algolia REST API. - description: The customRequest method allow you to send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/PathInPath' requestBody: @@ -13,9 +13,9 @@ customRequest: $ref: '#/Responses' getCustomRequest: - operationId: getCustomRequest + operationId: get summary: Send GET requests to the Algolia REST API. - description: The getCustomRequest method allow you to send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/PathInPath' - name: parameters From d4cd0026da418c93974e2a8e3ad5a7a75cb47dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Tue, 1 Mar 2022 17:33:42 +0100 Subject: [PATCH 5/5] add query parameters to all methods --- .../com/algolia/search/SearchApi.java | 66 ++++++++++++++----- .../client-abtesting/src/abtestingApi.ts | 47 +++++++++++-- .../client-analytics/src/analyticsApi.ts | 47 +++++++++++-- .../client-insights/src/insightsApi.ts | 47 +++++++++++-- .../src/personalizationApi.ts | 47 +++++++++++-- .../packages/client-predict/src/predictApi.ts | 47 +++++++++++-- .../src/querySuggestionsApi.ts | 47 +++++++++++-- .../packages/client-search/src/searchApi.ts | 47 +++++++++++-- .../packages/client-sources/src/sourcesApi.ts | 47 +++++++++++-- .../packages/recommend/src/recommendApi.ts | 47 +++++++++++-- .../lib/Api/AbtestingApi.php | 41 ++++++++++-- .../lib/Api/AnalyticsApi.php | 41 ++++++++++-- .../lib/Api/InsightsApi.php | 41 ++++++++++-- .../lib/Api/PersonalizationApi.php | 41 ++++++++++-- .../lib/Api/QuerySuggestionsApi.php | 41 ++++++++++-- .../lib/Api/RecommendApi.php | 41 ++++++++++-- .../lib/Api/SearchApi.php | 41 ++++++++++-- specs/bundled/abtesting.yml | 47 +++++++------ specs/bundled/analytics.yml | 47 +++++++------ specs/bundled/insights.yml | 47 +++++++------ specs/bundled/personalization.yml | 47 +++++++------ specs/bundled/predict.yml | 47 +++++++------ specs/bundled/query-suggestions.yml | 47 +++++++------ specs/bundled/recommend.yml | 47 +++++++------ specs/bundled/search.yml | 47 +++++++------ specs/bundled/sources.yml | 47 +++++++------ specs/common/paths/customRequest.yml | 21 +++++- specs/common/schemas/CustomRequest.yml | 30 +++------ 28 files changed, 960 insertions(+), 290 deletions(-) diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java index c0d134b619..2a978f28df 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java @@ -1370,6 +1370,7 @@ public Call clearRulesAsync( */ private Call delCall( String path, + String parameters, Object body, final ApiCallback _callback ) throws ApiException { @@ -1385,6 +1386,10 @@ private Call delCall( List queryParams = new ArrayList(); Map headers = new HashMap(); + if (parameters != null) { + queryParams.addAll(this.parameterToPair("parameters", parameters)); + } + headers.put("Accept", "application/json"); headers.put("Content-Type", "application/json"); @@ -1400,6 +1405,7 @@ private Call delCall( private Call delValidateBeforeCall( String path, + String parameters, Object body, final ApiCallback _callback ) throws ApiException { @@ -1410,7 +1416,7 @@ private Call delValidateBeforeCall( ); } - return delCall(path, body, _callback); + return delCall(path, parameters, body, _callback); } /** @@ -1418,13 +1424,16 @@ private Call delValidateBeforeCall( * * @param path The path of the API endpoint to target, anything after the /1 needs to be * specified. (required) + * @param parameters URL-encoded query string. Force some query parameters to be applied for each + * query made with this API key. (optional) * @param body The parameters to send with the custom request. (optional) * @return Object * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body */ - public Object del(String path, Object body) throws ApiException { - Call req = delValidateBeforeCall(path, body, null); + public Object del(String path, String parameters, Object body) + throws ApiException { + Call req = delValidateBeforeCall(path, parameters, body, null); if (req instanceof CallEcho) { return new EchoResponse.Del(((CallEcho) req).request()); } @@ -1435,7 +1444,7 @@ public Object del(String path, Object body) throws ApiException { } public Object del(String path) throws ApiException { - return this.del(path, null); + return this.del(path, null, null); } /** @@ -1443,6 +1452,8 @@ public Object del(String path) throws ApiException { * * @param path The path of the API endpoint to target, anything after the /1 needs to be * specified. (required) + * @param parameters URL-encoded query string. Force some query parameters to be applied for each + * query made with this API key. (optional) * @param body The parameters to send with the custom request. (optional) * @param _callback The callback to be executed when the API call finishes * @return The request call @@ -1450,10 +1461,11 @@ public Object del(String path) throws ApiException { */ public Call delAsync( String path, + String parameters, Object body, final ApiCallback _callback ) throws ApiException { - Call call = delValidateBeforeCall(path, body, _callback); + Call call = delValidateBeforeCall(path, parameters, body, _callback); Type returnType = new TypeToken() {}.getType(); this.executeAsync(call, returnType, _callback); return call; @@ -4420,6 +4432,7 @@ public Call partialUpdateObjectAsync( */ private Call postCall( String path, + String parameters, Object body, final ApiCallback _callback ) throws ApiException { @@ -4435,6 +4448,10 @@ private Call postCall( List queryParams = new ArrayList(); Map headers = new HashMap(); + if (parameters != null) { + queryParams.addAll(this.parameterToPair("parameters", parameters)); + } + headers.put("Accept", "application/json"); headers.put("Content-Type", "application/json"); @@ -4450,6 +4467,7 @@ private Call postCall( private Call postValidateBeforeCall( String path, + String parameters, Object body, final ApiCallback _callback ) throws ApiException { @@ -4460,7 +4478,7 @@ private Call postValidateBeforeCall( ); } - return postCall(path, body, _callback); + return postCall(path, parameters, body, _callback); } /** @@ -4468,13 +4486,16 @@ private Call postValidateBeforeCall( * * @param path The path of the API endpoint to target, anything after the /1 needs to be * specified. (required) + * @param parameters URL-encoded query string. Force some query parameters to be applied for each + * query made with this API key. (optional) * @param body The parameters to send with the custom request. (optional) * @return Object * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body */ - public Object post(String path, Object body) throws ApiException { - Call req = postValidateBeforeCall(path, body, null); + public Object post(String path, String parameters, Object body) + throws ApiException { + Call req = postValidateBeforeCall(path, parameters, body, null); if (req instanceof CallEcho) { return new EchoResponse.Post(((CallEcho) req).request()); } @@ -4485,7 +4506,7 @@ public Object post(String path, Object body) throws ApiException { } public Object post(String path) throws ApiException { - return this.post(path, null); + return this.post(path, null, null); } /** @@ -4493,6 +4514,8 @@ public Object post(String path) throws ApiException { * * @param path The path of the API endpoint to target, anything after the /1 needs to be * specified. (required) + * @param parameters URL-encoded query string. Force some query parameters to be applied for each + * query made with this API key. (optional) * @param body The parameters to send with the custom request. (optional) * @param _callback The callback to be executed when the API call finishes * @return The request call @@ -4500,10 +4523,11 @@ public Object post(String path) throws ApiException { */ public Call postAsync( String path, + String parameters, Object body, final ApiCallback _callback ) throws ApiException { - Call call = postValidateBeforeCall(path, body, _callback); + Call call = postValidateBeforeCall(path, parameters, body, _callback); Type returnType = new TypeToken() {}.getType(); this.executeAsync(call, returnType, _callback); return call; @@ -4518,6 +4542,7 @@ public Call postAsync( */ private Call putCall( String path, + String parameters, Object body, final ApiCallback _callback ) throws ApiException { @@ -4533,6 +4558,10 @@ private Call putCall( List queryParams = new ArrayList(); Map headers = new HashMap(); + if (parameters != null) { + queryParams.addAll(this.parameterToPair("parameters", parameters)); + } + headers.put("Accept", "application/json"); headers.put("Content-Type", "application/json"); @@ -4548,6 +4577,7 @@ private Call putCall( private Call putValidateBeforeCall( String path, + String parameters, Object body, final ApiCallback _callback ) throws ApiException { @@ -4558,7 +4588,7 @@ private Call putValidateBeforeCall( ); } - return putCall(path, body, _callback); + return putCall(path, parameters, body, _callback); } /** @@ -4566,13 +4596,16 @@ private Call putValidateBeforeCall( * * @param path The path of the API endpoint to target, anything after the /1 needs to be * specified. (required) + * @param parameters URL-encoded query string. Force some query parameters to be applied for each + * query made with this API key. (optional) * @param body The parameters to send with the custom request. (optional) * @return Object * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body */ - public Object put(String path, Object body) throws ApiException { - Call req = putValidateBeforeCall(path, body, null); + public Object put(String path, String parameters, Object body) + throws ApiException { + Call req = putValidateBeforeCall(path, parameters, body, null); if (req instanceof CallEcho) { return new EchoResponse.Put(((CallEcho) req).request()); } @@ -4583,7 +4616,7 @@ public Object put(String path, Object body) throws ApiException { } public Object put(String path) throws ApiException { - return this.put(path, null); + return this.put(path, null, null); } /** @@ -4591,6 +4624,8 @@ public Object put(String path) throws ApiException { * * @param path The path of the API endpoint to target, anything after the /1 needs to be * specified. (required) + * @param parameters URL-encoded query string. Force some query parameters to be applied for each + * query made with this API key. (optional) * @param body The parameters to send with the custom request. (optional) * @param _callback The callback to be executed when the API call finishes * @return The request call @@ -4598,10 +4633,11 @@ public Object put(String path) throws ApiException { */ public Call putAsync( String path, + String parameters, Object body, final ApiCallback _callback ) throws ApiException { - Call call = putValidateBeforeCall(path, body, _callback); + Call call = putValidateBeforeCall(path, parameters, body, _callback); Type returnType = new TypeToken() {}.getType(); this.executeAsync(call, returnType, _callback); return call; diff --git a/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts b/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts index f933e350fd..7c3e778baf 100644 --- a/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts @@ -111,9 +111,14 @@ export function createAbtestingApi( * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param del.body - The parameters to send with the custom request. */ - function del({ path, body }: DelProps): Promise> { + function del({ + path, + parameters, + body, + }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -125,6 +130,10 @@ export function createAbtestingApi( throw new Error('Parameter `path` is required when calling `del`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'DELETE', path: requestPath, @@ -172,7 +181,7 @@ export function createAbtestingApi( /** * This method allow you to send requests to the Algolia REST API. * - * @summary Send GET requests to the Algolia REST API. + * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. @@ -275,9 +284,14 @@ export function createAbtestingApi( * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param post.body - The parameters to send with the custom request. */ - function post({ path, body }: PostProps): Promise> { + function post({ + path, + parameters, + body, + }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -289,6 +303,10 @@ export function createAbtestingApi( throw new Error('Parameter `path` is required when calling `post`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'POST', path: requestPath, @@ -307,9 +325,14 @@ export function createAbtestingApi( * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param put.body - The parameters to send with the custom request. */ - function put({ path, body }: PutProps): Promise> { + function put({ + path, + parameters, + body, + }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -321,6 +344,10 @@ export function createAbtestingApi( throw new Error('Parameter `path` is required when calling `put`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'PUT', path: requestPath, @@ -384,6 +411,10 @@ export type DelProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -431,6 +462,10 @@ export type PostProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -442,6 +477,10 @@ export type PutProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts index 5ef5e59515..e0c1930427 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts @@ -79,9 +79,14 @@ export function createAnalyticsApi( * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param del.body - The parameters to send with the custom request. */ - function del({ path, body }: DelProps): Promise> { + function del({ + path, + parameters, + body, + }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -93,6 +98,10 @@ export function createAnalyticsApi( throw new Error('Parameter `path` is required when calling `del`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'DELETE', path: requestPath, @@ -108,7 +117,7 @@ export function createAnalyticsApi( /** * This method allow you to send requests to the Algolia REST API. * - * @summary Send GET requests to the Algolia REST API. + * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. @@ -1186,9 +1195,14 @@ export function createAnalyticsApi( * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param post.body - The parameters to send with the custom request. */ - function post({ path, body }: PostProps): Promise> { + function post({ + path, + parameters, + body, + }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -1200,6 +1214,10 @@ export function createAnalyticsApi( throw new Error('Parameter `path` is required when calling `post`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'POST', path: requestPath, @@ -1218,9 +1236,14 @@ export function createAnalyticsApi( * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param put.body - The parameters to send with the custom request. */ - function put({ path, body }: PutProps): Promise> { + function put({ + path, + parameters, + body, + }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -1232,6 +1255,10 @@ export function createAnalyticsApi( throw new Error('Parameter `path` is required when calling `put`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'PUT', path: requestPath, @@ -1277,6 +1304,10 @@ export type DelProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -1714,6 +1745,10 @@ export type PostProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -1725,6 +1760,10 @@ export type PutProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts b/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts index 60313eff7b..efafcedb37 100644 --- a/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts @@ -62,9 +62,14 @@ export function createInsightsApi( * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param del.body - The parameters to send with the custom request. */ - function del({ path, body }: DelProps): Promise> { + function del({ + path, + parameters, + body, + }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -76,6 +81,10 @@ export function createInsightsApi( throw new Error('Parameter `path` is required when calling `del`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'DELETE', path: requestPath, @@ -91,7 +100,7 @@ export function createInsightsApi( /** * This method allow you to send requests to the Algolia REST API. * - * @summary Send GET requests to the Algolia REST API. + * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. @@ -129,9 +138,14 @@ export function createInsightsApi( * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param post.body - The parameters to send with the custom request. */ - function post({ path, body }: PostProps): Promise> { + function post({ + path, + parameters, + body, + }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -143,6 +157,10 @@ export function createInsightsApi( throw new Error('Parameter `path` is required when calling `post`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'POST', path: requestPath, @@ -198,9 +216,14 @@ export function createInsightsApi( * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param put.body - The parameters to send with the custom request. */ - function put({ path, body }: PutProps): Promise> { + function put({ + path, + parameters, + body, + }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -212,6 +235,10 @@ export function createInsightsApi( throw new Error('Parameter `path` is required when calling `put`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'PUT', path: requestPath, @@ -234,6 +261,10 @@ export type DelProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -256,6 +287,10 @@ export type PostProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -267,6 +302,10 @@ export type PutProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts b/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts index 4822a02a3f..1ea44d0358 100644 --- a/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts @@ -62,9 +62,14 @@ export function createPersonalizationApi( * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param del.body - The parameters to send with the custom request. */ - function del({ path, body }: DelProps): Promise> { + function del({ + path, + parameters, + body, + }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -76,6 +81,10 @@ export function createPersonalizationApi( throw new Error('Parameter `path` is required when calling `del`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'DELETE', path: requestPath, @@ -125,7 +134,7 @@ export function createPersonalizationApi( /** * This method allow you to send requests to the Algolia REST API. * - * @summary Send GET requests to the Algolia REST API. + * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. @@ -218,9 +227,14 @@ export function createPersonalizationApi( * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param post.body - The parameters to send with the custom request. */ - function post({ path, body }: PostProps): Promise> { + function post({ + path, + parameters, + body, + }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -232,6 +246,10 @@ export function createPersonalizationApi( throw new Error('Parameter `path` is required when calling `post`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'POST', path: requestPath, @@ -250,9 +268,14 @@ export function createPersonalizationApi( * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param put.body - The parameters to send with the custom request. */ - function put({ path, body }: PutProps): Promise> { + function put({ + path, + parameters, + body, + }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -264,6 +287,10 @@ export function createPersonalizationApi( throw new Error('Parameter `path` is required when calling `put`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'PUT', path: requestPath, @@ -343,6 +370,10 @@ export type DelProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -379,6 +410,10 @@ export type PostProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -390,6 +425,10 @@ export type PutProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts b/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts index 809e15d504..c4355243d8 100644 --- a/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts @@ -56,9 +56,14 @@ export function createPredictApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param del.body - The parameters to send with the custom request. */ - function del({ path, body }: DelProps): Promise> { + function del({ + path, + parameters, + body, + }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -70,6 +75,10 @@ export function createPredictApi(options: CreateClientOptions) { throw new Error('Parameter `path` is required when calling `del`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'DELETE', path: requestPath, @@ -128,7 +137,7 @@ export function createPredictApi(options: CreateClientOptions) { /** * This method allow you to send requests to the Algolia REST API. * - * @summary Send GET requests to the Algolia REST API. + * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. @@ -166,9 +175,14 @@ export function createPredictApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param post.body - The parameters to send with the custom request. */ - function post({ path, body }: PostProps): Promise> { + function post({ + path, + parameters, + body, + }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -180,6 +194,10 @@ export function createPredictApi(options: CreateClientOptions) { throw new Error('Parameter `path` is required when calling `post`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'POST', path: requestPath, @@ -198,9 +216,14 @@ export function createPredictApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param put.body - The parameters to send with the custom request. */ - function put({ path, body }: PutProps): Promise> { + function put({ + path, + parameters, + body, + }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -212,6 +235,10 @@ export function createPredictApi(options: CreateClientOptions) { throw new Error('Parameter `path` is required when calling `put`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'PUT', path: requestPath, @@ -234,6 +261,10 @@ export type DelProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -264,6 +295,10 @@ export type PostProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -275,6 +310,10 @@ export type PutProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts index 5f8234eacf..99bf88b466 100644 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts @@ -95,9 +95,14 @@ export function createQuerySuggestionsApi( * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param del.body - The parameters to send with the custom request. */ - function del({ path, body }: DelProps): Promise> { + function del({ + path, + parameters, + body, + }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -109,6 +114,10 @@ export function createQuerySuggestionsApi( throw new Error('Parameter `path` is required when calling `del`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'DELETE', path: requestPath, @@ -158,7 +167,7 @@ export function createQuerySuggestionsApi( /** * This method allow you to send requests to the Algolia REST API. * - * @summary Send GET requests to the Algolia REST API. + * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. @@ -317,9 +326,14 @@ export function createQuerySuggestionsApi( * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param post.body - The parameters to send with the custom request. */ - function post({ path, body }: PostProps): Promise> { + function post({ + path, + parameters, + body, + }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -331,6 +345,10 @@ export function createQuerySuggestionsApi( throw new Error('Parameter `path` is required when calling `post`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'POST', path: requestPath, @@ -349,9 +367,14 @@ export function createQuerySuggestionsApi( * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param put.body - The parameters to send with the custom request. */ - function put({ path, body }: PutProps): Promise> { + function put({ + path, + parameters, + body, + }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -363,6 +386,10 @@ export function createQuerySuggestionsApi( throw new Error('Parameter `path` is required when calling `put`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'PUT', path: requestPath, @@ -447,6 +474,10 @@ export type DelProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -497,6 +528,10 @@ export type PostProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -508,6 +543,10 @@ export type PutProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts index ebd8f4b032..91a66d3a0a 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts @@ -653,9 +653,14 @@ export function createSearchApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param del.body - The parameters to send with the custom request. */ - function del({ path, body }: DelProps): Promise> { + function del({ + path, + parameters, + body, + }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -667,6 +672,10 @@ export function createSearchApi(options: CreateClientOptions) { throw new Error('Parameter `path` is required when calling `del`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'DELETE', path: requestPath, @@ -962,7 +971,7 @@ export function createSearchApi(options: CreateClientOptions) { /** * This method allow you to send requests to the Algolia REST API. * - * @summary Send GET requests to the Algolia REST API. + * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. @@ -1736,9 +1745,14 @@ export function createSearchApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param post.body - The parameters to send with the custom request. */ - function post({ path, body }: PostProps): Promise> { + function post({ + path, + parameters, + body, + }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -1750,6 +1764,10 @@ export function createSearchApi(options: CreateClientOptions) { throw new Error('Parameter `path` is required when calling `post`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'POST', path: requestPath, @@ -1768,9 +1786,14 @@ export function createSearchApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param put.body - The parameters to send with the custom request. */ - function put({ path, body }: PutProps): Promise> { + function put({ + path, + parameters, + body, + }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -1782,6 +1805,10 @@ export function createSearchApi(options: CreateClientOptions) { throw new Error('Parameter `path` is required when calling `put`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'PUT', path: requestPath, @@ -2702,6 +2729,10 @@ export type DelProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -2934,6 +2965,10 @@ export type PostProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -2945,6 +2980,10 @@ export type PutProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts b/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts index b58d5c227f..d6fc1b0aa5 100644 --- a/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts @@ -60,9 +60,14 @@ export function createSourcesApi( * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param del.body - The parameters to send with the custom request. */ - function del({ path, body }: DelProps): Promise> { + function del({ + path, + parameters, + body, + }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -74,6 +79,10 @@ export function createSourcesApi( throw new Error('Parameter `path` is required when calling `del`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'DELETE', path: requestPath, @@ -89,7 +98,7 @@ export function createSourcesApi( /** * This method allow you to send requests to the Algolia REST API. * - * @summary Send GET requests to the Algolia REST API. + * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. @@ -127,9 +136,14 @@ export function createSourcesApi( * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param post.body - The parameters to send with the custom request. */ - function post({ path, body }: PostProps): Promise> { + function post({ + path, + parameters, + body, + }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -141,6 +155,10 @@ export function createSourcesApi( throw new Error('Parameter `path` is required when calling `post`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'POST', path: requestPath, @@ -206,9 +224,14 @@ export function createSourcesApi( * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param put.body - The parameters to send with the custom request. */ - function put({ path, body }: PutProps): Promise> { + function put({ + path, + parameters, + body, + }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -220,6 +243,10 @@ export function createSourcesApi( throw new Error('Parameter `path` is required when calling `put`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'PUT', path: requestPath, @@ -242,6 +269,10 @@ export type DelProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -264,6 +295,10 @@ export type PostProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -275,6 +310,10 @@ export type PutProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts b/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts index 9ee3728e43..189d94876f 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts +++ b/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts @@ -82,9 +82,14 @@ export function createRecommendApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param del.body - The parameters to send with the custom request. */ - function del({ path, body }: DelProps): Promise> { + function del({ + path, + parameters, + body, + }: DelProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -96,6 +101,10 @@ export function createRecommendApi(options: CreateClientOptions) { throw new Error('Parameter `path` is required when calling `del`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'DELETE', path: requestPath, @@ -111,7 +120,7 @@ export function createRecommendApi(options: CreateClientOptions) { /** * This method allow you to send requests to the Algolia REST API. * - * @summary Send GET requests to the Algolia REST API. + * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. @@ -186,9 +195,14 @@ export function createRecommendApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param post.body - The parameters to send with the custom request. */ - function post({ path, body }: PostProps): Promise> { + function post({ + path, + parameters, + body, + }: PostProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -200,6 +214,10 @@ export function createRecommendApi(options: CreateClientOptions) { throw new Error('Parameter `path` is required when calling `post`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'POST', path: requestPath, @@ -218,9 +236,14 @@ export function createRecommendApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. + * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. * @param put.body - The parameters to send with the custom request. */ - function put({ path, body }: PutProps): Promise> { + function put({ + path, + parameters, + body, + }: PutProps): Promise> { const requestPath = '/1{path}'.replace( '{path}', encodeURIComponent(String(path)) @@ -232,6 +255,10 @@ export function createRecommendApi(options: CreateClientOptions) { throw new Error('Parameter `path` is required when calling `put`.'); } + if (parameters !== undefined) { + queryParameters.parameters = parameters.toString(); + } + const request: Request = { method: 'PUT', path: requestPath, @@ -254,6 +281,10 @@ export type DelProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -276,6 +307,10 @@ export type PostProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ @@ -287,6 +322,10 @@ export type PutProps = { * The path of the API endpoint to target, anything after the /1 needs to be specified. */ path: string; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + parameters?: string; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php b/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php index 35abce834e..bc99187651 100644 --- a/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php +++ b/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php @@ -117,11 +117,12 @@ public function addABTests($addABTestsRequest) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function del($path, $body = null) + public function del($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -133,6 +134,16 @@ public function del($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -181,7 +192,7 @@ public function deleteABTest($id) } /** - * Send GET requests to the Algolia REST API. + * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) @@ -294,11 +305,12 @@ public function listABTests($offset = 0, $limit = 10) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function post($path, $body = null) + public function post($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -310,6 +322,16 @@ public function post($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -330,11 +352,12 @@ public function post($path, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function put($path, $body = null) + public function put($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -346,6 +369,16 @@ public function put($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( diff --git a/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php b/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php index 981262d35c..b2a6aa609e 100644 --- a/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php @@ -90,11 +90,12 @@ public function getClientConfig() * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function del($path, $body = null) + public function del($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -106,6 +107,16 @@ public function del($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -123,7 +134,7 @@ public function del($path, $body = null) } /** - * Send GET requests to the Algolia REST API. + * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) @@ -1648,11 +1659,12 @@ public function getUsersCount($index, $startDate = null, $endDate = null, $tags * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function post($path, $body = null) + public function post($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -1664,6 +1676,16 @@ public function post($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -1684,11 +1706,12 @@ public function post($path, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function put($path, $body = null) + public function put($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -1700,6 +1723,16 @@ public function put($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( diff --git a/clients/algoliasearch-client-php/lib/Api/InsightsApi.php b/clients/algoliasearch-client-php/lib/Api/InsightsApi.php index a32620e89d..a130b15d55 100644 --- a/clients/algoliasearch-client-php/lib/Api/InsightsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/InsightsApi.php @@ -90,11 +90,12 @@ public function getClientConfig() * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function del($path, $body = null) + public function del($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -106,6 +107,16 @@ public function del($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -123,7 +134,7 @@ public function del($path, $body = null) } /** - * Send GET requests to the Algolia REST API. + * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) @@ -168,11 +179,12 @@ public function get($path, $parameters = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function post($path, $body = null) + public function post($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -184,6 +196,16 @@ public function post($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -231,11 +253,12 @@ public function pushEvents($insightEvents) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function put($path, $body = null) + public function put($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -247,6 +270,16 @@ public function put($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( diff --git a/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php b/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php index 18b3b5b830..c2cf951d20 100644 --- a/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php +++ b/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php @@ -90,11 +90,12 @@ public function getClientConfig() * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function del($path, $body = null) + public function del($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -106,6 +107,16 @@ public function del($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -154,7 +165,7 @@ public function deleteUserProfile($userToken) } /** - * Send GET requests to the Algolia REST API. + * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) @@ -245,11 +256,12 @@ public function getUserTokenProfile($userToken) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function post($path, $body = null) + public function post($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -261,6 +273,16 @@ public function post($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -281,11 +303,12 @@ public function post($path, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function put($path, $body = null) + public function put($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -297,6 +320,16 @@ public function put($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( diff --git a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php index afba6f4e63..4080e10886 100644 --- a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php @@ -117,11 +117,12 @@ public function createConfig($querySuggestionsIndexWithIndexParam) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function del($path, $body = null) + public function del($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -133,6 +134,16 @@ public function del($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -181,7 +192,7 @@ public function deleteConfig($indexName) } /** - * Send GET requests to the Algolia REST API. + * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) @@ -334,11 +345,12 @@ public function getLogFile($indexName) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function post($path, $body = null) + public function post($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -350,6 +362,16 @@ public function post($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -370,11 +392,12 @@ public function post($path, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function put($path, $body = null) + public function put($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -386,6 +409,16 @@ public function put($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( diff --git a/clients/algoliasearch-client-php/lib/Api/RecommendApi.php b/clients/algoliasearch-client-php/lib/Api/RecommendApi.php index 3380cb28f6..05e4a5d148 100644 --- a/clients/algoliasearch-client-php/lib/Api/RecommendApi.php +++ b/clients/algoliasearch-client-php/lib/Api/RecommendApi.php @@ -91,11 +91,12 @@ public function getClientConfig() * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function del($path, $body = null) + public function del($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -107,6 +108,16 @@ public function del($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -124,7 +135,7 @@ public function del($path, $body = null) } /** - * Send GET requests to the Algolia REST API. + * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) @@ -196,11 +207,12 @@ public function getRecommendations($getRecommendationsParams) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function post($path, $body = null) + public function post($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -212,6 +224,16 @@ public function post($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -232,11 +254,12 @@ public function post($path, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function put($path, $body = null) + public function put($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -248,6 +271,16 @@ public function put($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( diff --git a/clients/algoliasearch-client-php/lib/Api/SearchApi.php b/clients/algoliasearch-client-php/lib/Api/SearchApi.php index 598d27bfc9..4db311d15e 100644 --- a/clients/algoliasearch-client-php/lib/Api/SearchApi.php +++ b/clients/algoliasearch-client-php/lib/Api/SearchApi.php @@ -597,11 +597,12 @@ public function clearRules($indexName, $forwardToReplicas = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function del($path, $body = null) + public function del($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -613,6 +614,16 @@ public function del($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -925,7 +936,7 @@ public function deleteSynonym($indexName, $objectID, $forwardToReplicas = null) } /** - * Send GET requests to the Algolia REST API. + * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) @@ -1694,11 +1705,12 @@ public function partialUpdateObject($indexName, $objectID, $oneOfStringBuiltInOp * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function post($path, $body = null) + public function post($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -1710,6 +1722,16 @@ public function post($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( @@ -1730,11 +1752,12 @@ public function post($path, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) + * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array */ - public function put($path, $body = null) + public function put($path, $parameters = null, $body = null) { // verify the required parameter 'path' is set if ($path === null || (is_array($path) && count($path) === 0)) { @@ -1746,6 +1769,16 @@ public function put($path, $body = null) $resourcePath = '/1{path}'; $queryParams = []; $httpBody = []; + + if ($parameters !== null) { + if ('form' === 'form' && is_array($parameters)) { + foreach ($parameters as $key => $value) { + $queryParams[$key] = $value; + } + } else { + $queryParams['parameters'] = $parameters; + } + } // path params if ($path !== null) { $resourcePath = str_replace( diff --git a/specs/bundled/abtesting.yml b/specs/bundled/abtesting.yml index c80db84e08..665ef12083 100644 --- a/specs/bundled/abtesting.yml +++ b/specs/bundled/abtesting.yml @@ -24,6 +24,15 @@ components: schema: type: string example: /keys + Parameters: + name: parameters + in: query + description: >- + URL-encoded query string. Force some query parameters to be applied for + each query made with this API key. + schema: + type: string + example: '?query=mySearchQuery&hitsPerPage=10' Offset: in: query name: offset @@ -269,18 +278,11 @@ paths: /1{path}: get: operationId: get - summary: Send GET requests to the Algolia REST API. + summary: Send requests to the Algolia REST API. description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - - name: parameters - in: query - description: >- - URL-encoded query string. Force some query parameters to be applied - for each query made with this API key. - schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -300,16 +302,17 @@ paths: - abtesting post: operationId: post - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -329,16 +332,17 @@ paths: - abtesting put: operationId: put - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -358,16 +362,17 @@ paths: - abtesting delete: operationId: del - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK diff --git a/specs/bundled/analytics.yml b/specs/bundled/analytics.yml index 0756c65b36..52c5efbad7 100644 --- a/specs/bundled/analytics.yml +++ b/specs/bundled/analytics.yml @@ -24,6 +24,15 @@ components: schema: type: string example: /keys + Parameters: + name: parameters + in: query + description: >- + URL-encoded query string. Force some query parameters to be applied for + each query made with this API key. + schema: + type: string + example: '?query=mySearchQuery&hitsPerPage=10' Index: in: query name: index @@ -430,18 +439,11 @@ paths: /1{path}: get: operationId: get - summary: Send GET requests to the Algolia REST API. + summary: Send requests to the Algolia REST API. description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - - name: parameters - in: query - description: >- - URL-encoded query string. Force some query parameters to be applied - for each query made with this API key. - schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -461,16 +463,17 @@ paths: - analytics post: operationId: post - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -490,16 +493,17 @@ paths: - analytics put: operationId: put - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -519,16 +523,17 @@ paths: - analytics delete: operationId: del - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK diff --git a/specs/bundled/insights.yml b/specs/bundled/insights.yml index 215ca4fc93..4f05ab4770 100644 --- a/specs/bundled/insights.yml +++ b/specs/bundled/insights.yml @@ -24,6 +24,15 @@ components: schema: type: string example: /keys + Parameters: + name: parameters + in: query + description: >- + URL-encoded query string. Force some query parameters to be applied for + each query made with this API key. + schema: + type: string + example: '?query=mySearchQuery&hitsPerPage=10' schemas: ErrorBase: description: Error. @@ -77,18 +86,11 @@ paths: /1{path}: get: operationId: get - summary: Send GET requests to the Algolia REST API. + summary: Send requests to the Algolia REST API. description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - - name: parameters - in: query - description: >- - URL-encoded query string. Force some query parameters to be applied - for each query made with this API key. - schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -108,16 +110,17 @@ paths: - insights post: operationId: post - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -137,16 +140,17 @@ paths: - insights put: operationId: put - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -166,16 +170,17 @@ paths: - insights delete: operationId: del - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK diff --git a/specs/bundled/personalization.yml b/specs/bundled/personalization.yml index 48c88f41a5..57913e9b42 100644 --- a/specs/bundled/personalization.yml +++ b/specs/bundled/personalization.yml @@ -24,6 +24,15 @@ components: schema: type: string example: /keys + Parameters: + name: parameters + in: query + description: >- + URL-encoded query string. Force some query parameters to be applied for + each query made with this API key. + schema: + type: string + example: '?query=mySearchQuery&hitsPerPage=10' UserToken: name: userToken in: path @@ -145,18 +154,11 @@ paths: /1{path}: get: operationId: get - summary: Send GET requests to the Algolia REST API. + summary: Send requests to the Algolia REST API. description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - - name: parameters - in: query - description: >- - URL-encoded query string. Force some query parameters to be applied - for each query made with this API key. - schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -176,16 +178,17 @@ paths: - personalization post: operationId: post - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -205,16 +208,17 @@ paths: - personalization put: operationId: put - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -234,16 +238,17 @@ paths: - personalization delete: operationId: del - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK diff --git a/specs/bundled/predict.yml b/specs/bundled/predict.yml index e1c9cdc366..7db2ab8bc7 100644 --- a/specs/bundled/predict.yml +++ b/specs/bundled/predict.yml @@ -24,6 +24,15 @@ components: schema: type: string example: /keys + Parameters: + name: parameters + in: query + description: >- + URL-encoded query string. Force some query parameters to be applied for + each query made with this API key. + schema: + type: string + example: '?query=mySearchQuery&hitsPerPage=10' userID: name: userID in: path @@ -85,18 +94,11 @@ paths: /1{path}: get: operationId: get - summary: Send GET requests to the Algolia REST API. + summary: Send requests to the Algolia REST API. description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - - name: parameters - in: query - description: >- - URL-encoded query string. Force some query parameters to be applied - for each query made with this API key. - schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -116,16 +118,17 @@ paths: - predict post: operationId: post - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -145,16 +148,17 @@ paths: - predict put: operationId: put - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -174,16 +178,17 @@ paths: - predict delete: operationId: del - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK diff --git a/specs/bundled/query-suggestions.yml b/specs/bundled/query-suggestions.yml index a143485110..4221d622e4 100644 --- a/specs/bundled/query-suggestions.yml +++ b/specs/bundled/query-suggestions.yml @@ -24,6 +24,15 @@ components: schema: type: string example: /keys + Parameters: + name: parameters + in: query + description: >- + URL-encoded query string. Force some query parameters to be applied for + each query made with this API key. + schema: + type: string + example: '?query=mySearchQuery&hitsPerPage=10' IndexName: name: indexName in: path @@ -304,18 +313,11 @@ paths: /1{path}: get: operationId: get - summary: Send GET requests to the Algolia REST API. + summary: Send requests to the Algolia REST API. description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - - name: parameters - in: query - description: >- - URL-encoded query string. Force some query parameters to be applied - for each query made with this API key. - schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -335,16 +337,17 @@ paths: - query-suggestions post: operationId: post - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -364,16 +367,17 @@ paths: - query-suggestions put: operationId: put - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -393,16 +397,17 @@ paths: - query-suggestions delete: operationId: del - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK diff --git a/specs/bundled/recommend.yml b/specs/bundled/recommend.yml index eedc107c3a..b510bc7e9e 100644 --- a/specs/bundled/recommend.yml +++ b/specs/bundled/recommend.yml @@ -24,6 +24,15 @@ components: schema: type: string example: /keys + Parameters: + name: parameters + in: query + description: >- + URL-encoded query string. Force some query parameters to be applied for + each query made with this API key. + schema: + type: string + example: '?query=mySearchQuery&hitsPerPage=10' schemas: ErrorBase: description: Error. @@ -885,18 +894,11 @@ paths: /1{path}: get: operationId: get - summary: Send GET requests to the Algolia REST API. + summary: Send requests to the Algolia REST API. description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - - name: parameters - in: query - description: >- - URL-encoded query string. Force some query parameters to be applied - for each query made with this API key. - schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -916,16 +918,17 @@ paths: - recommend post: operationId: post - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -945,16 +948,17 @@ paths: - recommend put: operationId: put - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -974,16 +978,17 @@ paths: - recommend delete: operationId: del - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK diff --git a/specs/bundled/search.yml b/specs/bundled/search.yml index 9d2666d2bc..ccdffbe8b2 100644 --- a/specs/bundled/search.yml +++ b/specs/bundled/search.yml @@ -24,6 +24,15 @@ components: schema: type: string example: /keys + Parameters: + name: parameters + in: query + description: >- + URL-encoded query string. Force some query parameters to be applied for + each query made with this API key. + schema: + type: string + example: '?query=mySearchQuery&hitsPerPage=10' IndexName: name: indexName in: path @@ -1865,18 +1874,11 @@ paths: /1{path}: get: operationId: get - summary: Send GET requests to the Algolia REST API. + summary: Send requests to the Algolia REST API. description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - - name: parameters - in: query - description: >- - URL-encoded query string. Force some query parameters to be applied - for each query made with this API key. - schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -1896,16 +1898,17 @@ paths: - search post: operationId: post - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -1925,16 +1928,17 @@ paths: - search put: operationId: put - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -1954,16 +1958,17 @@ paths: - search delete: operationId: del - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK diff --git a/specs/bundled/sources.yml b/specs/bundled/sources.yml index 51e87e1463..70db879857 100644 --- a/specs/bundled/sources.yml +++ b/specs/bundled/sources.yml @@ -24,6 +24,15 @@ components: schema: type: string example: /keys + Parameters: + name: parameters + in: query + description: >- + URL-encoded query string. Force some query parameters to be applied for + each query made with this API key. + schema: + type: string + example: '?query=mySearchQuery&hitsPerPage=10' schemas: ErrorBase: description: Error. @@ -93,18 +102,11 @@ paths: /1{path}: get: operationId: get - summary: Send GET requests to the Algolia REST API. + summary: Send requests to the Algolia REST API. description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/components/parameters/PathInPath' - - name: parameters - in: query - description: >- - URL-encoded query string. Force some query parameters to be applied - for each query made with this API key. - schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -124,16 +126,17 @@ paths: - sources post: operationId: post - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -153,16 +156,17 @@ paths: - sources put: operationId: put - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK @@ -182,16 +186,17 @@ paths: - sources delete: operationId: del - summary: Send requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/components/parameters/PathInPath' requestBody: description: The parameters to send with the custom request. content: application/json: schema: type: object + summary: Send requests to the Algolia REST API. + description: This method allow you to send requests to the Algolia REST API. + parameters: + - $ref: '#/components/parameters/PathInPath' + - $ref: '#/components/parameters/Parameters' responses: '200': description: OK diff --git a/specs/common/paths/customRequest.yml b/specs/common/paths/customRequest.yml index bdc8b551d5..68c1dc9a26 100644 --- a/specs/common/paths/customRequest.yml +++ b/specs/common/paths/customRequest.yml @@ -1,14 +1,33 @@ get: - $ref: ../schemas/CustomRequest.yml#/getCustomRequest + operationId: get + $ref: ../schemas/CustomRequest.yml#/customRequest post: operationId: post + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object $ref: ../schemas/CustomRequest.yml#/customRequest put: operationId: put + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object $ref: ../schemas/CustomRequest.yml#/customRequest delete: operationId: del + requestBody: + description: The parameters to send with the custom request. + content: + application/json: + schema: + type: object $ref: ../schemas/CustomRequest.yml#/customRequest diff --git a/specs/common/schemas/CustomRequest.yml b/specs/common/schemas/CustomRequest.yml index 5908849c70..052ed7e383 100644 --- a/specs/common/schemas/CustomRequest.yml +++ b/specs/common/schemas/CustomRequest.yml @@ -3,27 +3,7 @@ customRequest: description: This method allow you to send requests to the Algolia REST API. parameters: - $ref: '#/PathInPath' - requestBody: - description: The parameters to send with the custom request. - content: - application/json: - schema: - type: object - responses: - $ref: '#/Responses' - -getCustomRequest: - operationId: get - summary: Send GET requests to the Algolia REST API. - description: This method allow you to send requests to the Algolia REST API. - parameters: - - $ref: '#/PathInPath' - - name: parameters - in: query - description: URL-encoded query string. Force some query parameters to be applied for each query made with this API key. - schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + - $ref: '#/Parameters' responses: $ref: '#/Responses' @@ -51,3 +31,11 @@ PathInPath: schema: type: string example: /keys + +Parameters: + name: parameters + in: query + description: URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + schema: + type: string + example: '?query=mySearchQuery&hitsPerPage=10'