Skip to content

8.3 #1228

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

Closed
wants to merge 2 commits into from
Closed

8.3 #1228

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
20 changes: 8 additions & 12 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
use Elastic\Elasticsearch\Transport\AsyncOnSuccess;
use Elastic\Elasticsearch\Transport\AsyncOnSuccessNoException;
use Elastic\Transport\Transport;
use Http\Promise\Promise;
use Psr\Http\Message\RequestInterface;
use Psr\Log\LoggerInterface;

final class Client
final class Client implements ClientInterface
{
const CLIENT_NAME = 'es';
const VERSION = '8.x';
Expand Down Expand Up @@ -86,7 +85,7 @@ protected function defaultTransportSettings(Transport $transport): void
}

/**
* Set the asyncronous HTTP request
* @inheritDoc
*/
public function setAsync(bool $async): self
{
Expand All @@ -95,15 +94,15 @@ public function setAsync(bool $async): self
}

/**
* Get the asyncronous HTTP request setting
* @inheritDoc
*/
public function getAsync(): bool
{
return $this->async;
}

/**
* Enable or disable the x-elastic-client-meta header
* @inheritDoc
*/
public function setElasticMetaHeader(bool $active): self
{
Expand All @@ -112,15 +111,15 @@ public function setElasticMetaHeader(bool $active): self
}

/**
* Get the status of x-elastic-client-meta header
* @inheritDoc
*/
public function getElasticMetaHeader(): bool
{
return $this->elasticMetaHeader;
}

/**
* Enable or disable the response Exception
* @inheritDoc
*/
public function setResponseException(bool $active): self
{
Expand All @@ -129,18 +128,15 @@ public function setResponseException(bool $active): self
}

/**
* Get the status of response Exception
* @inheritDoc
*/
public function getResponseException(): bool
{
return $this->responseException;
}

/**
* Send the HTTP request using the Elastic Transport.
* It manages syncronous and asyncronus requests using Client::getAsync()
*
* @return Elasticsearch|Promise
* @inheritDoc
*/
public function sendRequest(RequestInterface $request)
{
Expand Down
4 changes: 2 additions & 2 deletions src/ClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static function create(): ClientBuilder
* ignore unknown settings
* @throws ConfigException
*/
public static function fromConfig(array $config, bool $quiet = false): Client
public static function fromConfig(array $config, bool $quiet = false): \Elastic\Elasticsearch\ClientInterface
{
$builder = new static;
foreach ($config as $key => $value) {
Expand Down Expand Up @@ -325,7 +325,7 @@ public function setHttpClientOptions(array $options): ClientBuilder
/**
* Build and returns the Client object
*/
public function build(): Client
public function build(): \Elastic\Elasticsearch\ClientInterface
{
// Transport builder
$builder = TransportBuilder::create();
Expand Down
258 changes: 258 additions & 0 deletions src/ClientInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
<?php
/**
* Elasticsearch PHP Client interface
*
* @link https://github.com/elastic/elasticsearch-php
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license https://opensource.org/licenses/MIT MIT License
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the MIT License.
* See the LICENSE file in the project root for more information.
*/
declare(strict_types = 1);

namespace Elastic\Elasticsearch;

use Elastic\Elasticsearch\Endpoints\AsyncSearch;
use Elastic\Elasticsearch\Endpoints\Autoscaling;
use Elastic\Elasticsearch\Endpoints\Cat;
use Elastic\Elasticsearch\Endpoints\Ccr;
use Elastic\Elasticsearch\Endpoints\Cluster;
use Elastic\Elasticsearch\Endpoints\DanglingIndices;
use Elastic\Elasticsearch\Endpoints\Enrich;
use Elastic\Elasticsearch\Endpoints\Eql;
use Elastic\Elasticsearch\Endpoints\Features;
use Elastic\Elasticsearch\Endpoints\Fleet;
use Elastic\Elasticsearch\Endpoints\Graph;
use Elastic\Elasticsearch\Endpoints\Ilm;
use Elastic\Elasticsearch\Endpoints\Indices;
use Elastic\Elasticsearch\Endpoints\Ingest;
use Elastic\Elasticsearch\Endpoints\License;
use Elastic\Elasticsearch\Endpoints\Logstash;
use Elastic\Elasticsearch\Endpoints\Migration;
use Elastic\Elasticsearch\Endpoints\Ml;
use Elastic\Elasticsearch\Endpoints\Monitoring;
use Elastic\Elasticsearch\Endpoints\Nodes;
use Elastic\Elasticsearch\Endpoints\Rollup;
use Elastic\Elasticsearch\Endpoints\SearchableSnapshots;
use Elastic\Elasticsearch\Endpoints\Security;
use Elastic\Elasticsearch\Endpoints\Shutdown;
use Elastic\Elasticsearch\Endpoints\Slm;
use Elastic\Elasticsearch\Endpoints\Snapshot;
use Elastic\Elasticsearch\Endpoints\Sql;
use Elastic\Elasticsearch\Endpoints\Ssl;
use Elastic\Elasticsearch\Endpoints\Tasks;
use Elastic\Elasticsearch\Endpoints\TextStructure;
use Elastic\Elasticsearch\Endpoints\Transform;
use Elastic\Elasticsearch\Endpoints\Watcher;
use Elastic\Elasticsearch\Endpoints\Xpack;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Transport;
use Http\Promise\Promise;
use Psr\Http\Message\RequestInterface;
use Psr\Log\LoggerInterface;

interface ClientInterface
{
/**
* ClientEndpointsTrait
*/
public function bulk(array $params = []);

public function clearScroll(array $params = []);

public function closePointInTime(array $params = []);

public function count(array $params = []);

public function create(array $params = []);

public function delete(array $params = []);

public function deleteByQuery(array $params = []);

public function deleteByQueryRethrottle(array $params = []);

public function deleteScript(array $params = []);

public function exists(array $params = []);

public function existsSource(array $params = []);

public function explain(array $params = []);

public function fieldCaps(array $params = []);

public function get(array $params = []);

public function getScript(array $params = []);

public function getScriptContext(array $params = []);

public function getScriptLanguages(array $params = []);

public function index(array $params = []);

public function info(array $params = []);

public function knnSearch(array $params = []);

public function mget(array $params = []);

public function msearch(array $params = []);

public function msearchTemplate(array $params = []);

public function mtermvectors(array $params = []);

public function openPointInTime(array $params = []);

public function ping(array $params = []);

public function putScript(array $params = []);

public function rankEval(array $params = []);

public function reindex(array $params = []);

public function reindexRethrottle(array $params = []);

public function renderSearchTemplate(array $params = []);

public function scriptsPainlessExecute(array $params = []);

public function scroll(array $params = []);

public function search(array $params = []);

public function searchMvt(array $params = []);

public function searchShards(array $params = []);

public function searchTemplate(array $params = []);

public function termsEnum(array $params = []);

public function termvectors(array $params = []);

public function update(array $params = []);

public function updateByQuery(array $params = []);

public function updateByQueryRethrottle(array $params = []);

/**
* NamespaceTrait
*/
public function asyncSearch(): AsyncSearch;

public function autoscaling(): Autoscaling;

public function cat(): Cat;

public function ccr(): Ccr;

public function cluster(): Cluster;

public function danglingIndices(): DanglingIndices;

public function enrich(): Enrich;

public function eql(): Eql;

public function features(): Features;

public function fleet(): Fleet;

public function graph(): Graph;

public function ilm(): Ilm;

public function indices(): Indices;

public function ingest(): Ingest;

public function license(): License;

public function logstash(): Logstash;

public function migration(): Migration;

public function ml(): Ml;

public function monitoring(): Monitoring;

public function nodes(): Nodes;

public function rollup(): Rollup;

public function searchableSnapshots(): SearchableSnapshots;

public function security(): Security;

public function shutdown(): Shutdown;

public function slm(): Slm;

public function snapshot(): Snapshot;

public function sql(): Sql;

public function ssl(): Ssl;

public function tasks(): Tasks;

public function textStructure(): TextStructure;

public function transform(): Transform;

public function watcher(): Watcher;

public function xpack(): Xpack;

/**
* Client
*/
public function getTransport(): Transport;

public function getLogger(): LoggerInterface;

/**
* Set the asyncronous HTTP request
*/
public function setAsync(bool $async): self;

/**
* Get the asyncronous HTTP request setting
*/
public function getAsync(): bool;

/**
* Enable or disable the x-elastic-client-meta header
*/
public function setElasticMetaHeader(bool $active): self;

/**
* Get the status of x-elastic-client-meta header
*/
public function getElasticMetaHeader(): bool;

/**
* Enable or disable the response Exception
*/
public function setResponseException(bool $active): self;

/**
* Get the status of response Exception
*/
public function getResponseException(): bool;

/**
* Send the HTTP request using the Elastic Transport.
* It manages syncronous and asyncronus requests using Client::getAsync()
*
* @return Elasticsearch|Promise
*/
public function sendRequest(RequestInterface $request);
}
4 changes: 2 additions & 2 deletions tests/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Elastic\Elasticsearch\Tests;

use Exception;
use Elastic\Elasticsearch\ClientInterface;
use Elastic\Elasticsearch\Client;
use Elastic\Elasticsearch\ClientBuilder;
use Elastic\Elasticsearch\Exception\ClientResponseException;
Expand Down Expand Up @@ -76,7 +76,7 @@ public static function getHost(): ?string
/**
* Build a Client based on ENV variables
*/
public static function getClient(): Client
public static function getClient(): ClientInterface
{
if (getenv('TEST_SUITE') === 'free') {
return ClientBuilder::create()
Expand Down