From b90bef2614a11f70b031aa22639a36240e981ba6 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 2 Aug 2024 10:37:35 +0200 Subject: [PATCH] feat(specs): add runSource endpoint (#3453) --- specs/ingestion/common/schemas/source.yml | 29 +++++++++++++++ specs/ingestion/paths/sources/runSource.yml | 39 +++++++++++++++++++++ specs/ingestion/spec.yml | 2 ++ tests/CTS/requests/ingestion/runSource.json | 33 +++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 specs/ingestion/paths/sources/runSource.yml create mode 100644 tests/CTS/requests/ingestion/runSource.json diff --git a/specs/ingestion/common/schemas/source.yml b/specs/ingestion/common/schemas/source.yml index 1bc6fa5a30..f3b3020f9d 100644 --- a/specs/ingestion/common/schemas/source.yml +++ b/specs/ingestion/common/schemas/source.yml @@ -492,3 +492,32 @@ SourceWatchResponse: type: string required: - message + +RunSourcePayload: + type: object + additionalProperties: false + properties: + indexToInclude: + type: array + description: List of index names to include in reidexing/update. + items: + type: string + indexToExclude: + type: array + description: List of index names to exclude in reidexing/update. + items: + type: string + entityIDs: + type: array + items: + type: string + description: List of entityID to update. + entityType: + $ref: '#/EntityType' + +EntityType: + type: string + description: Type of entity to update. + enum: + - product + - collection diff --git a/specs/ingestion/paths/sources/runSource.yml b/specs/ingestion/paths/sources/runSource.yml new file mode 100644 index 0000000000..f81d6bc79a --- /dev/null +++ b/specs/ingestion/paths/sources/runSource.yml @@ -0,0 +1,39 @@ +post: + tags: + - sources + summary: Run all tasks linked to a source + description: Runs all tasks linked to a source, only available for Shopify sources. It will create 1 run per task. + operationId: runSource + x-acl: + - addObject + - deleteIndex + - editSettings + parameters: + - $ref: '../../common/parameters.yml#/pathSourceID' + requestBody: + description: '' + content: + application/json: + schema: + $ref: '../../common/schemas/source.yml#/RunSourcePayload' + responses: + '200': + description: OK + content: + application/json: + schema: + title: runSourceResponse + type: object + properties: + taskWithRunID: + type: object + description: Map of taskID sent for reindex with the corresponding runID. + additionalProperties: + type: string + createdAt: + $ref: '../../common/schemas/common.yml#/createdAt' + required: + - taskWithRunID + - createdAt + '400': + $ref: '../../../common/responses/BadRequest.yml' diff --git a/specs/ingestion/spec.yml b/specs/ingestion/spec.yml index 56b12b90e0..9473dde507 100644 --- a/specs/ingestion/spec.yml +++ b/specs/ingestion/spec.yml @@ -137,6 +137,8 @@ paths: $ref: 'paths/sources/validateID.yml' /1/sources/{sourceID}/discover: $ref: 'paths/sources/discover.yml' + /1/sources/{sourceID}/run: + $ref: 'paths/sources/runSource.yml' # tasks API. /1/tasks: diff --git a/tests/CTS/requests/ingestion/runSource.json b/tests/CTS/requests/ingestion/runSource.json new file mode 100644 index 0000000000..50b4a94433 --- /dev/null +++ b/tests/CTS/requests/ingestion/runSource.json @@ -0,0 +1,33 @@ +[ + { + "parameters": { + "sourceID": "6c02aeb1-775e-418e-870b-1faccd4b2c0f", + "runSourcePayload": { + "indexToInclude": [ + "products_us", + "products eu" + ], + "entityIDs": [ + "1234", + "5678" + ], + "entityType": "product" + } + }, + "request": { + "path": "/1/sources/6c02aeb1-775e-418e-870b-1faccd4b2c0f/run", + "method": "POST", + "body": { + "indexToInclude": [ + "products_us", + "products eu" + ], + "entityIDs": [ + "1234", + "5678" + ], + "entityType": "product" + } + } + } +]