From b7997af8d438af27c7bf1a3eae1cc84fa1a68faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20FOUCRET?= Date: Wed, 12 Feb 2020 10:52:32 +0100 Subject: [PATCH] Meta engine sources management support. --- AbstractClient.php | 46 +++++++++++++++++++++++++++++ Endpoint/AddMetaEngineSource.php | 31 +++++++++++++++++++ Endpoint/DeleteMetaEngineSource.php | 31 +++++++++++++++++++ README.md | 2 ++ resources/api/api-spec.yml | 38 ++++++++++++++++++++++++ 5 files changed, 148 insertions(+) create mode 100644 Endpoint/AddMetaEngineSource.php create mode 100644 Endpoint/DeleteMetaEngineSource.php diff --git a/AbstractClient.php b/AbstractClient.php index eabb310..b42f297 100644 --- a/AbstractClient.php +++ b/AbstractClient.php @@ -17,6 +17,29 @@ abstract class AbstractClient extends \Elastic\OpenApi\Codegen\AbstractClient { // phpcs:disable + /** + * Add a source engine to an existing meta engine. + * + * Documentation: https://swiftype.com/documentation/app-search/api/meta-engines#add-source-engines + * + * @param string $engineName Name of the engine. + * @param array $sourceEngines List of engine ids. + * + * @return array + */ + public function addMetaEngineSource($engineName, $sourceEngines) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('AddMetaEngineSource'); + $endpoint->setParams($params); + $endpoint->setBody($sourceEngines); + + return $this->performRequest($endpoint); + } + /** * Create a new curation. * @@ -134,6 +157,29 @@ public function deleteEngine($engineName) return $this->performRequest($endpoint); } + /** + * Delete a source engine from a meta engine. + * + * Documentation: https://swiftype.com/documentation/app-search/api/meta-engines#remove-source-engines + * + * @param string $engineName Name of the engine. + * @param array $sourceEngines List of engine ids. + * + * @return array + */ + public function deleteMetaEngineSource($engineName, $sourceEngines) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('DeleteMetaEngineSource'); + $endpoint->setParams($params); + $endpoint->setBody($sourceEngines); + + return $this->performRequest($endpoint); + } + /** * Delete a synonym set by id. * diff --git a/Endpoint/AddMetaEngineSource.php b/Endpoint/AddMetaEngineSource.php new file mode 100644 index 0000000..7384fb5 --- /dev/null +++ b/Endpoint/AddMetaEngineSource.php @@ -0,0 +1,31 @@ +
**Parameters :**
- `$name` (required)
- `$language`
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#create) **`createMetaEngine`**| Creates a new meta engine.

**Parameters :**
- `$name` (required)
- `$sourceEngines` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#create) +**`addMetaEngineSource`**| Add a source engine to an existing meta engine.

**Parameters :**
- `$engineName` (required)
- `$sourceEngines` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/meta-engines#add-source-engines) **`createCuration`**| Create a new curation.

**Parameters :**
- `$engineName` (required)
- `$queries` (required)
- `$promotedDocIds`
- `$hiddenDocIds`
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/curations#create) **`createSynonymSet`**| Create a new synonym set.

**Parameters :**
- `$engineName` (required)
- `$synonyms` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/synonyms#create) **`deleteCuration`**| Delete a curation by id.

**Parameters :**
- `$engineName` (required)
- `$curationId` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/curations#destroy) **`deleteDocuments`**| Delete documents by id.

**Parameters :**
- `$engineName` (required)
- `$documentIds` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/documents#partial) **`deleteEngine`**| Delete an engine by name.

**Parameters :**
- `$engineName` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#delete) +**`deleteMetaEngineSource`**| Delete a source engine from a meta engine.

**Parameters :**
- `$engineName` (required)
- `$sourceEngines` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/meta-engines#remove-source-engines) **`deleteSynonymSet`**| Delete a synonym set by id.

**Parameters :**
- `$engineName` (required)
- `$synonymSetId` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/synonyms#delete) **`getApiLogs`**| The API Log displays API request and response data at the Engine level.

**Parameters :**
- `$engineName` (required)
- `$fromDate` (required)
- `$toDate` (required)
- `$currentPage`
- `$pageSize`
- `$query`
- `$httpStatusFilter`
- `$httpMethodFilter`
- `$sortDirection`
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/logs) **`getCountAnalytics`**| Returns the number of clicks and total number of queries over a period.

**Parameters :**
- `$engineName` (required)
- `$filters`
- `$interval`
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/analytics/counts) diff --git a/resources/api/api-spec.yml b/resources/api/api-spec.yml index 839f367..7dd9ad2 100644 --- a/resources/api/api-spec.yml +++ b/resources/api/api-spec.yml @@ -131,6 +131,14 @@ components: schema: $ref: "#/components/schemas/documentIds" + engineIdsRequest: + required: true + description: List of engine ids. + content: + application/json: + schema: + $ref: "#/components/schemas/documentIds" + documentsIndexingRequest: required: true description: List of document to index. @@ -305,6 +313,36 @@ paths: default: $ref: "#/components/responses/jsonResponse" + /engines/{engine_name}/source_engines: + parameters: + - $ref: "#/components/parameters/engineNameParam" + post: + operationId: addMetaEngineSource + summary: Add a source engine to an existing meta engine. + externalDocs: + url: https://swiftype.com/documentation/app-search/api/meta-engines#add-source-engines + tags: + - Engine API + requestBody: + $ref: "#/components/requestBodies/engineIdsRequest" + x-codegen-request-body-name: sourceEngines + responses: + default: + $ref: "#/components/responses/jsonResponse" + delete: + operationId: deleteMetaEngineSource + summary: Delete a source engine from a meta engine. + externalDocs: + url: https://swiftype.com/documentation/app-search/api/meta-engines#remove-source-engines + tags: + - Engine API + requestBody: + $ref: "#/components/requestBodies/engineIdsRequest" + x-codegen-request-body-name: sourceEngines + responses: + default: + $ref: "#/components/responses/jsonResponse" + /engines/{engine_name}/documents: parameters: - $ref: "#/components/parameters/engineNameParam"