Skip to content

fix(specs): getApiKeyResponse, multipleBatch, partialUpdateObject #889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions specs/common/responses/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ createdAt:
type: string
description: Date of creation (ISO-8601 format).

createdAtTimestamp:
type: integer
format: int64
description: Time of the event expressed in milliseconds since the Unix epoch.

updatedAt:
type: string
description: Date of last update (ISO-8601 format).
Expand Down
40 changes: 29 additions & 11 deletions specs/search/paths/keys/common/schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ apiKey:
default: []
items:
$ref: '#/acl'

description:
type: string
description: A comment used to identify a key more easily in the dashboard. It is not interpreted by the API.
Expand Down Expand Up @@ -47,20 +46,24 @@ apiKey:

keyString:
type: string
description: Key string.
description: The API key.

getApiKeyResponse:
allOf:
- $ref: '#/baseGetApiKeyResponse'
- $ref: '#/apiKey'

createdAtObject:
baseGetApiKeyResponse:
type: object
required:
- createdAt
additionalProperties: false
properties:
value:
$ref: '#/keyString'
createdAt:
$ref: '../../../../common/responses/common.yml#/createdAt'

key:
allOf:
- $ref: '#/apiKey'
- $ref: '#/createdAtObject'
$ref: '../../../../common/responses/common.yml#/createdAtTimestamp'
required:
- key
- createdAt

addApiKeyResponse:
type: object
Expand All @@ -75,6 +78,21 @@ addApiKeyResponse:
- createdAt

acl:
description: |
List of rights for the API key. The following rights can be used:

addObject: allows to add/update an object in the index (copy/move index are also allowed with this right).
analytics: allows to retrieve the analytics through the Analytics API.
browse: allows to retrieve all index content via the browse API.
deleteIndex: allows to delete or clear index content.
deleteObject: allows to delete objects from the index.
editSettings: allows to change index settings.
listIndexes: allows to list all accessible indices.
logs: allows to get the logs.
recommendation: Allows usage of the Personalization dashboard and the Recommendation API.
search: allows to search the index.
seeUnretrievableAttributes: disable unretrievableAttributes feature for all operations returning records.
settings: allows to get index settings.
type: string
enum:
- addObject
Expand Down
2 changes: 1 addition & 1 deletion specs/search/paths/keys/key.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ get:
content:
application/json:
schema:
$ref: 'common/schemas.yml#/key'
$ref: 'common/schemas.yml#/getApiKeyResponse'
'400':
$ref: '../../../common/responses/BadRequest.yml'
'402':
Expand Down
2 changes: 1 addition & 1 deletion specs/search/paths/keys/keys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ get:
type: array
description: List of api keys.
items:
$ref: 'common/schemas.yml#/key'
$ref: 'common/schemas.yml#/getApiKeyResponse'
'400':
$ref: '../../../common/responses/BadRequest.yml'
'402':
Expand Down
2 changes: 1 addition & 1 deletion specs/search/paths/objects/common/schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ builtInOperation:
- _operation
- value

attributeOrBuiltInOperation:
attributeToUpdate:
oneOf:
- $ref: '#/attribute'
- $ref: '#/builtInOperation'
2 changes: 2 additions & 0 deletions specs/search/paths/objects/getObjects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ post:
indexName:
type: string
description: name of the index containing the object.
required:
- requests
responses:
'200':
description: OK
Expand Down
11 changes: 11 additions & 0 deletions specs/search/paths/objects/multipleBatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ post:
indexName:
type: string
description: Index to target for this operation.
required:
- action
- body
- indexName
required:
- requests
responses:
'200':
description: OK
Expand All @@ -42,8 +48,13 @@ post:
taskID:
type: object
description: List of tasksIDs per index.
additionalProperties:
$ref: '../../../common/responses/common.yml#/taskID'
objectIDs:
$ref: '../../../common/responses/common.yml#/objectIDs'
required:
- taskID
- objectIDs
'400':
$ref: '../../../common/responses/BadRequest.yml'
'402':
Expand Down
3 changes: 1 addition & 2 deletions specs/search/paths/objects/partialUpdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ post:
type: array
items:
type: object
title: attributeToUpdate
description: Attribute to update.
additionalProperties:
$ref: 'common/schemas.yml#/attributeOrBuiltInOperation'
$ref: 'common/schemas.yml#/attributeToUpdate'
responses:
'200':
$ref: '../../../common/responses/UpdatedAtWithObjectId.yml'
Expand Down
20 changes: 10 additions & 10 deletions templates/java/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public class {{classname}} extends ApiClient {
* @param timeout The function to decide how long to wait between retries. min(retries * 200, 5000) by default. (optional)
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions. (optional)
*/
public Key waitForApiKey(
public GetApiKeyResponse waitForApiKey(
ApiKeyOperation operation,
String key,
ApiKey apiKey,
Expand All @@ -358,7 +358,7 @@ public class {{classname}} extends ApiClient {
() -> {
return this.getApiKey(key, requestOptions);
},
(Key respKey) -> {
(GetApiKeyResponse respKey) -> {
// we need to convert to an ApiKey object to use the `equals` method
ApiKey sameType = new ApiKey()
.setAcl(respKey.getAcl())
Expand All @@ -378,7 +378,7 @@ public class {{classname}} extends ApiClient {
}

// bypass lambda restriction to modify final object
final Key[] addedKey = new Key[] { null };
final GetApiKeyResponse[] addedKey = new GetApiKeyResponse[] { null };

// check the status of the getApiKey method
TaskUtils.retryUntil(
Expand Down Expand Up @@ -421,7 +421,7 @@ public class {{classname}} extends ApiClient {
* @param timeout The function to decide how long to wait between retries. min(retries * 200, 5000) by default. (optional)
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions. (optional)
*/
public Key waitForApiKey(ApiKeyOperation operation, String key, int maxRetries, IntUnaryOperator timeout, RequestOptions requestOptions) {
public GetApiKeyResponse waitForApiKey(ApiKeyOperation operation, String key, int maxRetries, IntUnaryOperator timeout, RequestOptions requestOptions) {
return this.waitForApiKey(operation, key, null, maxRetries, timeout, requestOptions);
}

Expand All @@ -434,7 +434,7 @@ public class {{classname}} extends ApiClient {
* @param apiKey Necessary to know if an `update` operation has been processed, compare fields of the response with it.
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions. (optional)
*/
public Key waitForApiKey(ApiKeyOperation operation, String key, ApiKey apiKey, RequestOptions requestOptions) {
public GetApiKeyResponse waitForApiKey(ApiKeyOperation operation, String key, ApiKey apiKey, RequestOptions requestOptions) {
return this.waitForApiKey(operation, key, apiKey, TaskUtils.DEFAULT_MAX_RETRIES, TaskUtils.DEFAULT_TIMEOUT, requestOptions);
}

Expand All @@ -446,7 +446,7 @@ public class {{classname}} extends ApiClient {
* @param key The `key` that has been added, deleted or updated.
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions. (optional)
*/
public Key waitForApiKey(ApiKeyOperation operation, String key, RequestOptions requestOptions) {
public GetApiKeyResponse waitForApiKey(ApiKeyOperation operation, String key, RequestOptions requestOptions) {
return this.waitForApiKey(operation, key, null, TaskUtils.DEFAULT_MAX_RETRIES, TaskUtils.DEFAULT_TIMEOUT, requestOptions);
}

Expand All @@ -460,7 +460,7 @@ public class {{classname}} extends ApiClient {
* @param maxRetries The maximum number of retry. 50 by default. (optional)
* @param timeout The function to decide how long to wait between retries. min(retries * 200, 5000) by default. (optional)
*/
public Key waitForApiKey(ApiKeyOperation operation, String key, ApiKey apiKey, int maxRetries, IntUnaryOperator timeout) {
public GetApiKeyResponse waitForApiKey(ApiKeyOperation operation, String key, ApiKey apiKey, int maxRetries, IntUnaryOperator timeout) {
return this.waitForApiKey(operation, key, apiKey, maxRetries, timeout, null);
}

Expand All @@ -473,7 +473,7 @@ public class {{classname}} extends ApiClient {
* @param maxRetries The maximum number of retry. 50 by default. (optional)
* @param timeout The function to decide how long to wait between retries. min(retries * 200, 5000) by default. (optional)
*/
public Key waitForApiKey(ApiKeyOperation operation, String key, int maxRetries, IntUnaryOperator timeout) {
public GetApiKeyResponse waitForApiKey(ApiKeyOperation operation, String key, int maxRetries, IntUnaryOperator timeout) {
return this.waitForApiKey(operation, key, null, maxRetries, timeout, null);
}

Expand All @@ -485,7 +485,7 @@ public class {{classname}} extends ApiClient {
* @param key The `key` that has been added, deleted or updated.
* @param apiKey Necessary to know if an `update` operation has been processed, compare fields of the response with it.
*/
public Key waitForApiKey(ApiKeyOperation operation, String key, ApiKey apiKey) {
public GetApiKeyResponse waitForApiKey(ApiKeyOperation operation, String key, ApiKey apiKey) {
return this.waitForApiKey(operation, key, apiKey, TaskUtils.DEFAULT_MAX_RETRIES, TaskUtils.DEFAULT_TIMEOUT, null);
}

Expand All @@ -496,7 +496,7 @@ public class {{classname}} extends ApiClient {
* @param operation The `operation` that was done on a `key`. (ADD or DELETE only)
* @param key The `key` that has been added, deleted or updated.
*/
public Key waitForApiKey(ApiKeyOperation operation, String key) {
public GetApiKeyResponse waitForApiKey(ApiKeyOperation operation, String key) {
return this.waitForApiKey(operation, key, null, TaskUtils.DEFAULT_MAX_RETRIES, TaskUtils.DEFAULT_TIMEOUT, null);
}
{{/isSearchClient}}
Expand Down
4 changes: 2 additions & 2 deletions templates/javascript/clients/client/api/helpers.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ waitForApiKey(
Math.min(retryCount * 200, 5000),
}: WaitForApiKeyOptions,
requestOptions?: RequestOptions
): Promise<ApiError | Key> {
): Promise<ApiError | GetApiKeyResponse> {
let retryCount = 0;
const baseIteratorOptions: IterableOptions<ApiError | Key> = {
const baseIteratorOptions: IterableOptions<ApiError | GetApiKeyResponse> = {
aggregator: () => (retryCount += 1),
error: {
validate: () => retryCount >= maxRetries,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export type WaitForTaskOptions = WaitForOptions<GetTaskResponse> & {
taskID: number;
};

export type WaitForApiKeyOptions = WaitForOptions<Key> & {
export type WaitForApiKeyOptions = WaitForOptions<GetApiKeyResponse> & {
/**
* The API Key.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"parameters": {
"indexName": "theIndexName",
"objectID": "uniqueID",
"attributeOrBuiltInOperation": [
"attributeToUpdate": [
{
"id1": "test",
"id2": {
Expand Down