Skip to content

Commit

Permalink
Merge pull request #29 from afoucret/meta-engine
Browse files Browse the repository at this point in the history
Meta engine API support.
  • Loading branch information
afoucret authored Feb 12, 2020
2 parents 3277c1c + b7997af commit 08f86f8
Show file tree
Hide file tree
Showing 10 changed files with 972 additions and 741 deletions.
824 changes: 824 additions & 0 deletions AbstractClient.php

Large diffs are not rendered by default.

743 changes: 8 additions & 735 deletions Client.php

Large diffs are not rendered by default.

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
}
6 changes: 3 additions & 3 deletions Endpoint/CreateEngine.php → Endpoint/DoCreateEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
namespace Elastic\AppSearch\Client\Endpoint;

/**
* Implementation of the CreateEngine endpoint.
* Implementation of the DoCreateEngine endpoint.
*
* @package Elastic\AppSearch\Client\Endpoint
*/
class CreateEngine extends \Elastic\OpenApi\Codegen\Endpoint\AbstractEndpoint
class DoCreateEngine extends \Elastic\OpenApi\Codegen\Endpoint\AbstractEndpoint
{
// phpcs:disable
/**
Expand All @@ -26,6 +26,6 @@ class CreateEngine extends \Elastic\OpenApi\Codegen\Endpoint\AbstractEndpoint
*/
protected $uri = '/engines';

protected $paramWhitelist = ['name', 'language'];
protected $paramWhitelist = ['name', 'language', 'type', 'source_engines'];
// phpcs:enable
}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,15 @@ The search response will contains at least a meta field and a results field as s

Method | Description | Documentation
------------|-------------|--------------
**`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)
**`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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"require" : {
"php" : "^5.6|^7.0",
"elastic/openapi-codegen" : "^1.0.3",
"elastic/openapi-codegen" : "^1.0.4",
"psr/log" : "^1.0."
},
"require-dev" : {
Expand Down
54 changes: 53 additions & 1 deletion 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 @@ -245,7 +253,8 @@ paths:
default:
$ref: "#/components/responses/jsonResponse"
post:
operationId: createEngine
operationId: doCreateEngine
x-operation-scope: protected
summary: Creates a new engine.
externalDocs:
url: https://swiftype.com/documentation/app-search/api/engines#create
Expand All @@ -263,6 +272,19 @@ paths:
description: Engine language (null for universal).
schema:
type: string
- name: type
in: query
description: Engine type.
schema:
type: string
default: 'default'
- name: source_engines
in: query
description: Sources engines list.
schema:
type: array
items:
type: string
responses:
default:
$ref: "#/components/responses/jsonResponse"
Expand Down Expand Up @@ -291,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
1 change: 1 addition & 0 deletions resources/api/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"clientClass": "AbstractClient",
"gitUserId": "elastic",
"gitRepoId": "app-search-php",
"artifactVersion": "1.0.0",
Expand Down
16 changes: 16 additions & 0 deletions resources/api/templates/README.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{>readme_title}}
{{>readme_content}}
{{>readme_install}}
{{>readme_usage}}
### Clients methods

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)
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#vendorExtensions.x-add-to-documentation}}**`{{operationId}}`**| {{#summary}}{{.}}{{/summary}}{{#allParams.0}}<br/> <br/> **Parameters :** <br />{{#allParams}} - `${{paramName}}`{{#required}} (required) {{/required}}{{#hasMore}}<br /> {{/hasMore}}{{/allParams}}{{/allParams.0}}<br/>{{#externalDocs}}|[Endpoint Documentation]({{url}}){{/externalDocs}}
{{/vendorExtensions.x-add-to-documentation}}{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
{{>readme_dev}}
{{>readme_faq}}
{{>readme_contrib}}
{{>readme_licence}}

0 comments on commit 08f86f8

Please sign in to comment.