Skip to content

Commit

Permalink
Meta engine sources management support.
Browse files Browse the repository at this point in the history
  • Loading branch information
afoucret committed Feb 12, 2020
1 parent 942d8a8 commit b7997af
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 0 deletions.
46 changes: 46 additions & 0 deletions AbstractClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
31 changes: 31 additions & 0 deletions Endpoint/AddMetaEngineSource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* This file is part of the Elastic App Search PHP Client package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Elastic\AppSearch\Client\Endpoint;

/**
* Implementation of the AddMetaEngineSource endpoint.
*
* @package Elastic\AppSearch\Client\Endpoint
*/
class AddMetaEngineSource extends \Elastic\OpenApi\Codegen\Endpoint\AbstractEndpoint
{
// phpcs:disable
/**
* @var string
*/
protected $method = 'POST';

/**
* @var string
*/
protected $uri = '/engines/{engine_name}/source_engines';

protected $routeParams = ['engine_name'];
// phpcs:enable
}
31 changes: 31 additions & 0 deletions Endpoint/DeleteMetaEngineSource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* This file is part of the Elastic App Search PHP Client package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Elastic\AppSearch\Client\Endpoint;

/**
* Implementation of the DeleteMetaEngineSource endpoint.
*
* @package Elastic\AppSearch\Client\Endpoint
*/
class DeleteMetaEngineSource extends \Elastic\OpenApi\Codegen\Endpoint\AbstractEndpoint
{
// phpcs:disable
/**
* @var string
*/
protected $method = 'DELETE';

/**
* @var string
*/
protected $uri = '/engines/{engine_name}/source_engines';

protected $routeParams = ['engine_name'];
// phpcs:enable
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,13 @@ Method | Description | Documentation
------------|-------------|--------------
**`createEngine`**| Creates a new engine.<br/> <br/> **Parameters :** <br /> - `$name` (required) <br /> - `$language`<br/>|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#create)
**`createMetaEngine`**| Creates a new meta engine.<br/> <br/> **Parameters :** <br /> - `$name` (required) <br /> - `$sourceEngines` (required)<br/>|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#create)
**`addMetaEngineSource`**| Add a source engine to an existing meta engine.<br/> <br/> **Parameters :** <br /> - `$engineName` (required) <br /> - `$sourceEngines` (required) <br/>|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/meta-engines#add-source-engines)
**`createCuration`**| Create a new curation.<br/> <br/> **Parameters :** <br /> - `$engineName` (required) <br /> - `$queries` (required) <br /> - `$promotedDocIds`<br /> - `$hiddenDocIds`<br/>|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/curations#create)
**`createSynonymSet`**| Create a new synonym set.<br/> <br/> **Parameters :** <br /> - `$engineName` (required) <br /> - `$synonyms` (required) <br/>|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/synonyms#create)
**`deleteCuration`**| Delete a curation by id.<br/> <br/> **Parameters :** <br /> - `$engineName` (required) <br /> - `$curationId` (required) <br/>|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/curations#destroy)
**`deleteDocuments`**| Delete documents by id.<br/> <br/> **Parameters :** <br /> - `$engineName` (required) <br /> - `$documentIds` (required) <br/>|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/documents#partial)
**`deleteEngine`**| Delete an engine by name.<br/> <br/> **Parameters :** <br /> - `$engineName` (required) <br/>|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#delete)
**`deleteMetaEngineSource`**| Delete a source engine from a meta engine.<br/> <br/> **Parameters :** <br /> - `$engineName` (required) <br /> - `$sourceEngines` (required) <br/>|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/meta-engines#remove-source-engines)
**`deleteSynonymSet`**| Delete a synonym set by id.<br/> <br/> **Parameters :** <br /> - `$engineName` (required) <br /> - `$synonymSetId` (required) <br/>|[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.<br/> <br/> **Parameters :** <br /> - `$engineName` (required) <br /> - `$fromDate` (required) <br /> - `$toDate` (required) <br /> - `$currentPage`<br /> - `$pageSize`<br /> - `$query`<br /> - `$httpStatusFilter`<br /> - `$httpMethodFilter`<br /> - `$sortDirection`<br/>|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/logs)
**`getCountAnalytics`**| Returns the number of clicks and total number of queries over a period.<br/> <br/> **Parameters :** <br /> - `$engineName` (required) <br /> - `$filters`<br /> - `$interval`<br/>|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/analytics/counts)
Expand Down
38 changes: 38 additions & 0 deletions resources/api/api-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit b7997af

Please sign in to comment.