Merge pull request #4 from Karaka-Management/develop

Develop
This commit is contained in:
Dennis Eichhorn 2023-09-30 01:40:08 +02:00 committed by GitHub
commit 03b1888a88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5594 changed files with 1028455 additions and 315958 deletions

2
.github/contributing.md vendored Normal file → Executable file
View File

@ -1 +1 @@
A developer and contribution documentation can be found at https://orange-management.gitbooks.io/developer-guide/content/index.html.
A developer and contribution documentation can be found at https://Karaka.gitbooks.io/developer-guide/content/index.html.

0
.github/issue_template.md vendored Normal file → Executable file
View File

2
.gitignore vendored Executable file
View File

@ -0,0 +1,2 @@
*/tmp/*
.directory

298
DeepCopy/DeepCopy.php Executable file
View File

@ -0,0 +1,298 @@
<?php
namespace DeepCopy;
use ArrayObject;
use DateInterval;
use DateTimeInterface;
use DateTimeZone;
use DeepCopy\Exception\CloneException;
use DeepCopy\Filter\Filter;
use DeepCopy\Matcher\Matcher;
use DeepCopy\Reflection\ReflectionHelper;
use DeepCopy\TypeFilter\Date\DateIntervalFilter;
use DeepCopy\TypeFilter\Spl\ArrayObjectFilter;
use DeepCopy\TypeFilter\Spl\SplDoublyLinkedListFilter;
use DeepCopy\TypeFilter\TypeFilter;
use DeepCopy\TypeMatcher\TypeMatcher;
use ReflectionObject;
use ReflectionProperty;
use SplDoublyLinkedList;
/**
* @final
*/
class DeepCopy
{
/**
* @var object[] List of objects copied.
*/
private $hashMap = [];
/**
* Filters to apply.
*
* @var array Array of ['filter' => Filter, 'matcher' => Matcher] pairs.
*/
private $filters = [];
/**
* Type Filters to apply.
*
* @var array Array of ['filter' => Filter, 'matcher' => Matcher] pairs.
*/
private $typeFilters = [];
/**
* @var bool
*/
private $skipUncloneable = false;
/**
* @var bool
*/
private $useCloneMethod;
/**
* @param bool $useCloneMethod If set to true, when an object implements the __clone() function, it will be used
* instead of the regular deep cloning.
*/
public function __construct($useCloneMethod = false)
{
$this->useCloneMethod = $useCloneMethod;
$this->addTypeFilter(new ArrayObjectFilter($this), new TypeMatcher(ArrayObject::class));
$this->addTypeFilter(new DateIntervalFilter(), new TypeMatcher(DateInterval::class));
$this->addTypeFilter(new SplDoublyLinkedListFilter($this), new TypeMatcher(SplDoublyLinkedList::class));
}
/**
* If enabled, will not throw an exception when coming across an uncloneable property.
*
* @param $skipUncloneable
*
* @return $this
*/
public function skipUncloneable($skipUncloneable = true)
{
$this->skipUncloneable = $skipUncloneable;
return $this;
}
/**
* Deep copies the given object.
*
* @param mixed $object
*
* @return mixed
*/
public function copy($object)
{
$this->hashMap = [];
return $this->recursiveCopy($object);
}
public function addFilter(Filter $filter, Matcher $matcher)
{
$this->filters[] = [
'matcher' => $matcher,
'filter' => $filter,
];
}
public function prependFilter(Filter $filter, Matcher $matcher)
{
array_unshift($this->filters, [
'matcher' => $matcher,
'filter' => $filter,
]);
}
public function addTypeFilter(TypeFilter $filter, TypeMatcher $matcher)
{
$this->typeFilters[] = [
'matcher' => $matcher,
'filter' => $filter,
];
}
private function recursiveCopy($var)
{
// Matches Type Filter
if ($filter = $this->getFirstMatchedTypeFilter($this->typeFilters, $var)) {
return $filter->apply($var);
}
// Resource
if (is_resource($var)) {
return $var;
}
// Array
if (is_array($var)) {
return $this->copyArray($var);
}
// Scalar
if (! is_object($var)) {
return $var;
}
// Object
return $this->copyObject($var);
}
/**
* Copy an array
* @param array $array
* @return array
*/
private function copyArray(array $array)
{
foreach ($array as $key => $value) {
$array[$key] = $this->recursiveCopy($value);
}
return $array;
}
/**
* Copies an object.
*
* @param object $object
*
* @throws CloneException
*
* @return object
*/
private function copyObject($object)
{
$objectHash = spl_object_hash($object);
if (isset($this->hashMap[$objectHash])) {
return $this->hashMap[$objectHash];
}
$reflectedObject = new ReflectionObject($object);
$isCloneable = $reflectedObject->isCloneable();
if (false === $isCloneable) {
if ($this->skipUncloneable) {
$this->hashMap[$objectHash] = $object;
return $object;
}
throw new CloneException(
sprintf(
'The class "%s" is not cloneable.',
$reflectedObject->getName()
)
);
}
$newObject = clone $object;
$this->hashMap[$objectHash] = $newObject;
if ($this->useCloneMethod && $reflectedObject->hasMethod('__clone')) {
return $newObject;
}
if ($newObject instanceof DateTimeInterface || $newObject instanceof DateTimeZone) {
return $newObject;
}
foreach (ReflectionHelper::getProperties($reflectedObject) as $property) {
$this->copyObjectProperty($newObject, $property);
}
return $newObject;
}
private function copyObjectProperty($object, ReflectionProperty $property)
{
// Ignore static properties
if ($property->isStatic()) {
return;
}
// Apply the filters
foreach ($this->filters as $item) {
/** @var Matcher $matcher */
$matcher = $item['matcher'];
/** @var Filter $filter */
$filter = $item['filter'];
if ($matcher->matches($object, $property->getName())) {
$filter->apply(
$object,
$property->getName(),
function ($object) {
return $this->recursiveCopy($object);
}
);
// If a filter matches, we stop processing this property
return;
}
}
$property->setAccessible(true);
// Ignore uninitialized properties (for PHP >7.4)
if (method_exists($property, 'isInitialized') && !$property->isInitialized($object)) {
return;
}
$propertyValue = $property->getValue($object);
// Copy the property
$property->setValue($object, $this->recursiveCopy($propertyValue));
}
/**
* Returns first filter that matches variable, `null` if no such filter found.
*
* @param array $filterRecords Associative array with 2 members: 'filter' with value of type {@see TypeFilter} and
* 'matcher' with value of type {@see TypeMatcher}
* @param mixed $var
*
* @return TypeFilter|null
*/
private function getFirstMatchedTypeFilter(array $filterRecords, $var)
{
$matched = $this->first(
$filterRecords,
function (array $record) use ($var) {
/* @var TypeMatcher $matcher */
$matcher = $record['matcher'];
return $matcher->matches($var);
}
);
return isset($matched) ? $matched['filter'] : null;
}
/**
* Returns first element that matches predicate, `null` if no such element found.
*
* @param array $elements Array of ['filter' => Filter, 'matcher' => Matcher] pairs.
* @param callable $predicate Predicate arguments are: element.
*
* @return array|null Associative array with 2 members: 'filter' with value of type {@see TypeFilter} and 'matcher'
* with value of type {@see TypeMatcher} or `null`.
*/
private function first(array $elements, callable $predicate)
{
foreach ($elements as $element) {
if (call_user_func($predicate, $element)) {
return $element;
}
}
return null;
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace DeepCopy\Exception;
use UnexpectedValueException;
class CloneException extends UnexpectedValueException
{
}

View File

@ -0,0 +1,9 @@
<?php
namespace DeepCopy\Exception;
use ReflectionException;
class PropertyException extends ReflectionException
{
}

View File

@ -0,0 +1,33 @@
<?php
namespace DeepCopy\Filter\Doctrine;
use DeepCopy\Filter\Filter;
use DeepCopy\Reflection\ReflectionHelper;
/**
* @final
*/
class DoctrineCollectionFilter implements Filter
{
/**
* Copies the object property doctrine collection.
*
* {@inheritdoc}
*/
public function apply($object, $property, $objectCopier)
{
$reflectionProperty = ReflectionHelper::getProperty($object, $property);
$reflectionProperty->setAccessible(true);
$oldCollection = $reflectionProperty->getValue($object);
$newCollection = $oldCollection->map(
function ($item) use ($objectCopier) {
return $objectCopier($item);
}
);
$reflectionProperty->setValue($object, $newCollection);
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace DeepCopy\Filter\Doctrine;
use DeepCopy\Filter\Filter;
use DeepCopy\Reflection\ReflectionHelper;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @final
*/
class DoctrineEmptyCollectionFilter implements Filter
{
/**
* Sets the object property to an empty doctrine collection.
*
* @param object $object
* @param string $property
* @param callable $objectCopier
*/
public function apply($object, $property, $objectCopier)
{
$reflectionProperty = ReflectionHelper::getProperty($object, $property);
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($object, new ArrayCollection());
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace DeepCopy\Filter\Doctrine;
use DeepCopy\Filter\Filter;
/**
* @final
*/
class DoctrineProxyFilter implements Filter
{
/**
* Triggers the magic method __load() on a Doctrine Proxy class to load the
* actual entity from the database.
*
* {@inheritdoc}
*/
public function apply($object, $property, $objectCopier)
{
$object->__load();
}
}

18
DeepCopy/Filter/Filter.php Executable file
View File

@ -0,0 +1,18 @@
<?php
namespace DeepCopy\Filter;
/**
* Filter to apply to a property while copying an object
*/
interface Filter
{
/**
* Applies the filter to the object.
*
* @param object $object
* @param string $property
* @param callable $objectCopier
*/
public function apply($object, $property, $objectCopier);
}

16
DeepCopy/Filter/KeepFilter.php Executable file
View File

@ -0,0 +1,16 @@
<?php
namespace DeepCopy\Filter;
class KeepFilter implements Filter
{
/**
* Keeps the value of the object property.
*
* {@inheritdoc}
*/
public function apply($object, $property, $objectCopier)
{
// Nothing to do
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace DeepCopy\Filter;
use DeepCopy\Reflection\ReflectionHelper;
/**
* @final
*/
class ReplaceFilter implements Filter
{
/**
* @var callable
*/
protected $callback;
/**
* @param callable $callable Will be called to get the new value for each property to replace
*/
public function __construct(callable $callable)
{
$this->callback = $callable;
}
/**
* Replaces the object property by the result of the callback called with the object property.
*
* {@inheritdoc}
*/
public function apply($object, $property, $objectCopier)
{
$reflectionProperty = ReflectionHelper::getProperty($object, $property);
$reflectionProperty->setAccessible(true);
$value = call_user_func($this->callback, $reflectionProperty->getValue($object));
$reflectionProperty->setValue($object, $value);
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace DeepCopy\Filter;
use DeepCopy\Reflection\ReflectionHelper;
/**
* @final
*/
class SetNullFilter implements Filter
{
/**
* Sets the object property to null.
*
* {@inheritdoc}
*/
public function apply($object, $property, $objectCopier)
{
$reflectionProperty = ReflectionHelper::getProperty($object, $property);
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($object, null);
}
}

20
DeepCopy/LICENSE Executable file
View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 My C-Sense
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,22 @@
<?php
namespace DeepCopy\Matcher\Doctrine;
use DeepCopy\Matcher\Matcher;
use Doctrine\Common\Persistence\Proxy;
/**
* @final
*/
class DoctrineProxyMatcher implements Matcher
{
/**
* Matches a Doctrine Proxy class.
*
* {@inheritdoc}
*/
public function matches($object, $property)
{
return $object instanceof Proxy;
}
}

14
DeepCopy/Matcher/Matcher.php Executable file
View File

@ -0,0 +1,14 @@
<?php
namespace DeepCopy\Matcher;
interface Matcher
{
/**
* @param object $object
* @param string $property
*
* @return boolean
*/
public function matches($object, $property);
}

View File

@ -0,0 +1,39 @@
<?php
namespace DeepCopy\Matcher;
/**
* @final
*/
class PropertyMatcher implements Matcher
{
/**
* @var string
*/
private $class;
/**
* @var string
*/
private $property;
/**
* @param string $class Class name
* @param string $property Property name
*/
public function __construct($class, $property)
{
$this->class = $class;
$this->property = $property;
}
/**
* Matches a specific property of a specific class.
*
* {@inheritdoc}
*/
public function matches($object, $property)
{
return ($object instanceof $this->class) && $property == $this->property;
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace DeepCopy\Matcher;
/**
* @final
*/
class PropertyNameMatcher implements Matcher
{
/**
* @var string
*/
private $property;
/**
* @param string $property Property name
*/
public function __construct($property)
{
$this->property = $property;
}
/**
* Matches a property by its name.
*
* {@inheritdoc}
*/
public function matches($object, $property)
{
return $property == $this->property;
}
}

View File

@ -0,0 +1,46 @@
<?php
namespace DeepCopy\Matcher;
use DeepCopy\Reflection\ReflectionHelper;
use ReflectionException;
/**
* Matches a property by its type.
*
* It is recommended to use {@see DeepCopy\TypeFilter\TypeFilter} instead, as it applies on all occurrences
* of given type in copied context (eg. array elements), not just on object properties.
*
* @final
*/
class PropertyTypeMatcher implements Matcher
{
/**
* @var string
*/
private $propertyType;
/**
* @param string $propertyType Property type
*/
public function __construct($propertyType)
{
$this->propertyType = $propertyType;
}
/**
* {@inheritdoc}
*/
public function matches($object, $property)
{
try {
$reflectionProperty = ReflectionHelper::getProperty($object, $property);
} catch (ReflectionException $exception) {
return false;
}
$reflectionProperty->setAccessible(true);
return $reflectionProperty->getValue($object) instanceof $this->propertyType;
}
}

View File

@ -0,0 +1,78 @@
<?php
namespace DeepCopy\Reflection;
use DeepCopy\Exception\PropertyException;
use ReflectionClass;
use ReflectionException;
use ReflectionObject;
use ReflectionProperty;
class ReflectionHelper
{
/**
* Retrieves all properties (including private ones), from object and all its ancestors.
*
* Standard \ReflectionClass->getProperties() does not return private properties from ancestor classes.
*
* @author muratyaman@gmail.com
* @see http://php.net/manual/en/reflectionclass.getproperties.php
*
* @param ReflectionClass $ref
*
* @return ReflectionProperty[]
*/
public static function getProperties(ReflectionClass $ref)
{
$props = $ref->getProperties();
$propsArr = array();
foreach ($props as $prop) {
$propertyName = $prop->getName();
$propsArr[$propertyName] = $prop;
}
if ($parentClass = $ref->getParentClass()) {
$parentPropsArr = self::getProperties($parentClass);
foreach ($propsArr as $key => $property) {
$parentPropsArr[$key] = $property;
}
return $parentPropsArr;
}
return $propsArr;
}
/**
* Retrieves property by name from object and all its ancestors.
*
* @param object|string $object
* @param string $name
*
* @throws PropertyException
* @throws ReflectionException
*
* @return ReflectionProperty
*/
public static function getProperty($object, $name)
{
$reflection = is_object($object) ? new ReflectionObject($object) : new ReflectionClass($object);
if ($reflection->hasProperty($name)) {
return $reflection->getProperty($name);
}
if ($parentClass = $reflection->getParentClass()) {
return self::getProperty($parentClass->getName(), $name);
}
throw new PropertyException(
sprintf(
'The class "%s" doesn\'t have a property with the given name: "%s".',
is_object($object) ? get_class($object) : $object,
$name
)
);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace DeepCopy\TypeFilter\Date;
use DateInterval;
use DeepCopy\TypeFilter\TypeFilter;
/**
* @final
*
* @deprecated Will be removed in 2.0. This filter will no longer be necessary in PHP 7.1+.
*/
class DateIntervalFilter implements TypeFilter
{
/**
* {@inheritdoc}
*
* @param DateInterval $element
*
* @see http://news.php.net/php.bugs/205076
*/
public function apply($element)
{
$copy = new DateInterval('P0D');
foreach ($element as $propertyName => $propertyValue) {
$copy->{$propertyName} = $propertyValue;
}
return $copy;
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace DeepCopy\TypeFilter;
/**
* @final
*/
class ReplaceFilter implements TypeFilter
{
/**
* @var callable
*/
protected $callback;
/**
* @param callable $callable Will be called to get the new value for each element to replace
*/
public function __construct(callable $callable)
{
$this->callback = $callable;
}
/**
* {@inheritdoc}
*/
public function apply($element)
{
return call_user_func($this->callback, $element);
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace DeepCopy\TypeFilter;
/**
* @final
*/
class ShallowCopyFilter implements TypeFilter
{
/**
* {@inheritdoc}
*/
public function apply($element)
{
return clone $element;
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace DeepCopy\TypeFilter\Spl;
use DeepCopy\DeepCopy;
use DeepCopy\TypeFilter\TypeFilter;
/**
* In PHP 7.4 the storage of an ArrayObject isn't returned as
* ReflectionProperty. So we deep copy its array copy.
*/
final class ArrayObjectFilter implements TypeFilter
{
/**
* @var DeepCopy
*/
private $copier;
public function __construct(DeepCopy $copier)
{
$this->copier = $copier;
}
/**
* {@inheritdoc}
*/
public function apply($arrayObject)
{
$clone = clone $arrayObject;
foreach ($arrayObject->getArrayCopy() as $k => $v) {
$clone->offsetSet($k, $this->copier->copy($v));
}
return $clone;
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace DeepCopy\TypeFilter\Spl;
/**
* @deprecated Use {@see SplDoublyLinkedListFilter} instead.
*/
class SplDoublyLinkedList extends SplDoublyLinkedListFilter
{
}

View File

@ -0,0 +1,51 @@
<?php
namespace DeepCopy\TypeFilter\Spl;
use Closure;
use DeepCopy\DeepCopy;
use DeepCopy\TypeFilter\TypeFilter;
use SplDoublyLinkedList;
/**
* @final
*/
class SplDoublyLinkedListFilter implements TypeFilter
{
private $copier;
public function __construct(DeepCopy $copier)
{
$this->copier = $copier;
}
/**
* {@inheritdoc}
*/
public function apply($element)
{
$newElement = clone $element;
$copy = $this->createCopyClosure();
return $copy($newElement);
}
private function createCopyClosure()
{
$copier = $this->copier;
$copy = function (SplDoublyLinkedList $list) use ($copier) {
// Replace each element in the list with a deep copy of itself
for ($i = 1; $i <= $list->count(); $i++) {
$copy = $copier->recursiveCopy($list->shift());
$list->push($copy);
}
return $list;
};
return Closure::bind($copy, null, DeepCopy::class);
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace DeepCopy\TypeFilter;
interface TypeFilter
{
/**
* Applies the filter to the object.
*
* @param mixed $element
*/
public function apply($element);
}

View File

@ -0,0 +1,29 @@
<?php
namespace DeepCopy\TypeMatcher;
class TypeMatcher
{
/**
* @var string
*/
private $type;
/**
* @param string $type
*/
public function __construct($type)
{
$this->type = $type;
}
/**
* @param mixed $element
*
* @return boolean
*/
public function matches($element)
{
return is_object($element) ? is_a($element, $this->type) : gettype($element) === $this->type;
}
}

20
DeepCopy/deep_copy.php Executable file
View File

@ -0,0 +1,20 @@
<?php
namespace DeepCopy;
use function function_exists;
if (false === function_exists('DeepCopy\deep_copy')) {
/**
* Deep copies the given value.
*
* @param mixed $value
* @param bool $useCloneMethod
*
* @return mixed
*/
function deep_copy($value, $useCloneMethod = false)
{
return (new DeepCopy($useCloneMethod))->copy($value);
}
}

175
Elastic/Elasticsearch/Client.php Executable file
View File

@ -0,0 +1,175 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Response\Elasticsearch;
use Elastic\Elasticsearch\Traits\ClientEndpointsTrait;
use Elastic\Elasticsearch\Traits\EndpointTrait;
use Elastic\Elasticsearch\Traits\NamespaceTrait;
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 implements ClientInterface
{
const CLIENT_NAME = 'es';
const VERSION = '8.7.0';
const API_COMPATIBILITY_HEADER = '%s/vnd.elasticsearch+%s; compatible-with=8';
use ClientEndpointsTrait;
use EndpointTrait;
use NamespaceTrait;
protected Transport $transport;
protected LoggerInterface $logger;
/**
* Specify is the request is asyncronous
*/
protected bool $async = false;
/**
* Enable or disable the x-elastic-meta-header
*/
protected bool $elasticMetaHeader = true;
/**
* Enable or disable the response Exception
*/
protected bool $responseException = true;
/**
* The endpoint namespace storage
*/
protected array $namespace;
public function __construct(
Transport $transport,
LoggerInterface $logger
) {
$this->transport = $transport;
$this->logger = $logger;
$this->defaultTransportSettings($this->transport);
}
/**
* @inheritdoc
*/
public function getTransport(): Transport
{
return $this->transport;
}
/**
* @inheritdoc
*/
public function getLogger(): LoggerInterface
{
return $this->logger;
}
/**
* Set the default settings for Elasticsearch
*/
protected function defaultTransportSettings(Transport $transport): void
{
$transport->setUserAgent('elasticsearch-php', self::VERSION);
}
/**
* @inheritdoc
*/
public function setAsync(bool $async): self
{
$this->async = $async;
return $this;
}
/**
* @inheritdoc
*/
public function getAsync(): bool
{
return $this->async;
}
/**
* @inheritdoc
*/
public function setElasticMetaHeader(bool $active): self
{
$this->elasticMetaHeader = $active;
return $this;
}
/**
* @inheritdoc
*/
public function getElasticMetaHeader(): bool
{
return $this->elasticMetaHeader;
}
/**
* @inheritdoc
*/
public function setResponseException(bool $active): self
{
$this->responseException = $active;
return $this;
}
/**
* @inheritdoc
*/
public function getResponseException(): bool
{
return $this->responseException;
}
/**
* @inheritdoc
*/
public function sendRequest(RequestInterface $request)
{
// If async returns a Promise
if ($this->getAsync()) {
if ($this->getElasticMetaHeader()) {
$this->transport->setElasticMetaHeader(Client::CLIENT_NAME, Client::VERSION, true);
}
$this->transport->setAsyncOnSuccess(
$request->getMethod() === 'HEAD'
? new AsyncOnSuccessNoException
: ($this->getResponseException() ? new AsyncOnSuccess : new AsyncOnSuccessNoException)
);
return $this->transport->sendAsyncRequest($request);
}
if ($this->getElasticMetaHeader()) {
$this->transport->setElasticMetaHeader(Client::CLIENT_NAME, Client::VERSION, false);
}
$start = microtime(true);
$response = $this->transport->sendRequest($request);
$this->logger->info(sprintf("Response time in %.3f sec", microtime(true) - $start));
$result = new Elasticsearch;
$result->setResponse($response, $request->getMethod() === 'HEAD' ? false : $this->getResponseException());
return $result;
}
}

View File

@ -0,0 +1,467 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Exception\AuthenticationException;
use Elastic\Elasticsearch\Exception\ConfigException;
use Elastic\Elasticsearch\Exception\HttpClientException;
use Elastic\Elasticsearch\Exception\InvalidArgumentException;
use Elastic\Elasticsearch\Transport\Adapter\AdapterInterface;
use Elastic\Elasticsearch\Transport\Adapter\AdapterOptions;
use Elastic\Elasticsearch\Transport\RequestOptions;
use Elastic\Transport\NodePool\NodePoolInterface;
use Elastic\Transport\Transport;
use Elastic\Transport\TransportBuilder;
use GuzzleHttp\Client as GuzzleHttpClient;
use Http\Client\HttpAsyncClient;
use Psr\Http\Client\ClientInterface;
use Psr\Log\LoggerInterface;
use ReflectionClass;
class ClientBuilder
{
const DEFAULT_HOST = 'localhost:9200';
/**
* PSR-18 client
*/
private ClientInterface $httpClient;
/**
* The HTTP async client
*/
private HttpAsyncClient $asyncHttpClient;
/**
* PSR-3 Logger
*/
private LoggerInterface $logger;
/**
* The NodelPool
*/
private NodePoolInterface $nodePool;
/**
* Hosts (elasticsearch nodes)
*/
private array $hosts;
/**
* Elasticsearch API key
*/
private string $apiKey;
/**
* Basic authentication username
*/
private string $username;
/**
* Basic authentication password
*/
private string $password;
/**
* Elastic cloud Id
*/
private string $cloudId;
/**
* Retries
*
* The default value is calculated during the client build
* and it is equal to the number of hosts
*/
private int $retries;
/**
* SSL certificate
* @var array [$cert, $password] $cert is the name of a file containing a PEM formatted certificate,
* $password if the certificate requires a password
*/
private array $sslCert;
/**
* SSL key
* @var array [$key, $password] $key is the name of a file containing a private SSL key,
* $password if the private key requires a password
*/
private array $sslKey;
/**
* SSL verification
*
* Enable or disable the SSL verfiication (default is true)
*/
private bool $sslVerification = true;
/**
* SSL CA bundle
*/
private string $sslCA;
/**
* Elastic meta header
*
* Enable or disable the x-elastic-client-meta header (default is true)
*/
private bool $elasticMetaHeader = true;
/**
* HTTP client options
*/
private array $httpClientOptions = [];
/**
* Make the constructor final so cannot be overwritten
*/
final public function __construct()
{
}
/**
* Create an instance of ClientBuilder
*/
public static function create(): ClientBuilder
{
return new static();
}
/**
* Build a new client from the provided config. Hash keys
* should correspond to the method name e.g. ['nodePool']
* corresponds to setNodePool().
*
* Missing keys will use the default for that setting if applicable
*
* Unknown keys will throw an exception by default, but this can be silenced
* by setting `quiet` to true
*
* @param array $config
* @param bool $quiet False if unknown settings throw exception, true to silently
* ignore unknown settings
* @throws ConfigException
*/
public static function fromConfig(array $config, bool $quiet = false): Client
{
$builder = new static;
foreach ($config as $key => $value) {
$method = "set$key";
$reflection = new ReflectionClass($builder);
if ($reflection->hasMethod($method)) {
$func = $reflection->getMethod($method);
if ($func->getNumberOfParameters() > 1) {
$builder->$method(...$value);
} else {
$builder->$method($value);
}
unset($config[$key]);
}
}
if ($quiet === false && count($config) > 0) {
$unknown = implode(array_keys($config));
throw new ConfigException("Unknown parameters provided: $unknown");
}
return $builder->build();
}
public function setHttpClient(ClientInterface $httpClient): ClientBuilder
{
$this->httpClient = $httpClient;
return $this;
}
public function setAsyncHttpClient(HttpAsyncClient $asyncHttpClient): ClientBuilder
{
$this->asyncHttpClient = $asyncHttpClient;
return $this;
}
/**
* Set the PSR-3 Logger
*/
public function setLogger(LoggerInterface $logger): ClientBuilder
{
$this->logger = $logger;
return $this;
}
/**
* Set the NodePool
*/
public function setNodePool(NodePoolInterface $nodePool): ClientBuilder
{
$this->nodePool = $nodePool;
return $this;
}
/**
* Set the hosts (nodes)
*/
public function setHosts(array $hosts): ClientBuilder
{
$this->hosts = $hosts;
return $this;
}
/**
* Set the ApiKey
* If the id is not specified we store the ApiKey otherwise
* we store as Base64(id:ApiKey)
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html
*/
public function setApiKey(string $apiKey, string $id = null): ClientBuilder
{
if (empty($id)) {
$this->apiKey = $apiKey;
} else {
$this->apiKey = base64_encode($id . ':' . $apiKey);
}
return $this;
}
/**
* Set the Basic Authentication
*/
public function setBasicAuthentication(string $username, string $password): ClientBuilder
{
$this->username = $username;
$this->password = $password;
return $this;
}
public function setElasticCloudId(string $cloudId)
{
$this->cloudId = $cloudId;
return $this;
}
/**
* Set number or retries
*
* @param int $retries
*/
public function setRetries(int $retries): ClientBuilder
{
if ($retries < 0) {
throw new InvalidArgumentException('The retries number must be >= 0');
}
$this->retries = $retries;
return $this;
}
/**
* Set SSL certificate
*
* @param string $cert The name of a file containing a PEM formatted certificate
* @param string $password if the certificate requires a password
*/
public function setSSLCert(string $cert, string $password = null): ClientBuilder
{
$this->sslCert = [$cert, $password];
return $this;
}
/**
* Set the Certificate Authority (CA) bundle
*
* @param string $cert The name of a file containing a PEM formatted certificate
*/
public function setCABundle(string $cert): ClientBuilder
{
$this->sslCA = $cert;
return $this;
}
/**
* Set SSL key
*
* @param string $key The name of a file containing a private SSL key
* @param string $password if the private key requires a password
*/
public function setSSLKey(string $key, string $password = null): ClientBuilder
{
$this->sslKey = [$key, $password];
return $this;
}
/**
* Enable or disable the SSL verification
*/
public function setSSLVerification(bool $value = true): ClientBuilder
{
$this->sslVerification = $value;
return $this;
}
/**
* Enable or disable the x-elastic-client-meta header
*/
public function setElasticMetaHeader(bool $value = true): ClientBuilder
{
$this->elasticMetaHeader = $value;
return $this;
}
public function setHttpClientOptions(array $options): ClientBuilder
{
$this->httpClientOptions = $options;
return $this;
}
/**
* Build and returns the Client object
*/
public function build(): Client
{
// Transport builder
$builder = TransportBuilder::create();
// Set the default hosts if empty
if (empty($this->hosts)) {
$this->hosts = [self::DEFAULT_HOST];
}
$builder->setHosts($this->hosts);
// Logger
if (!empty($this->logger)) {
$builder->setLogger($this->logger);
}
// Http client
if (!empty($this->httpClient)) {
$builder->setClient($this->httpClient);
}
// Set HTTP client options
$builder->setClient(
$this->setOptions($builder->getClient(), $this->getConfig(), $this->httpClientOptions)
);
// Cloud id
if (!empty($this->cloudId)) {
$builder->setCloudId($this->cloudId);
}
// Node Pool
if (!empty($this->nodePool)) {
$builder->setNodePool($this->nodePool);
}
$transport = $builder->build();
// The default retries is equal to the number of hosts
if (empty($this->retries)) {
$this->retries = count($this->hosts);
}
$transport->setRetries($this->retries);
// Async client
if (!empty($this->asyncHttpClient)) {
$transport->setAsyncClient($this->asyncHttpClient);
}
// Basic authentication
if (!empty($this->username) && !empty($this->password)) {
$transport->setUserInfo($this->username, $this->password);
}
// API key
if (!empty($this->apiKey)) {
if (!empty($this->username)) {
throw new AuthenticationException('You cannot use APIKey and Basic Authenication together');
}
$transport->setHeader('Authorization', sprintf("ApiKey %s", $this->apiKey));
}
/**
* Elastic cloud optimized with gzip
* @see https://github.com/elastic/elasticsearch-php/issues/1241 omit for Symfony HTTP Client
*/
if (!empty($this->cloudId) && !$this->isSymfonyHttpClient($transport)) {
$transport->setHeader('Accept-Encoding', 'gzip');
}
$client = new Client($transport, $transport->getLogger());
// Enable or disable the x-elastic-client-meta header
$client->setElasticMetaHeader($this->elasticMetaHeader);
return $client;
}
/**
* Returns true if the transport HTTP client is Symfony
*/
protected function isSymfonyHttpClient(Transport $transport): bool
{
if (false !== strpos(get_class($transport->getClient()), 'Symfony\Component\HttpClient')) {
return true;
}
if (false !== strpos(get_class($transport->getAsyncClient()), 'Symfony\Component\HttpClient')) {
return true;
}
return false;
}
/**
* Returns the configuration to be used in the HTTP client
*/
protected function getConfig(): array
{
$config = [];
if (!empty($this->sslCert)) {
$config[RequestOptions::SSL_CERT] = $this->sslCert;
}
if (!empty($this->sslKey)) {
$config[RequestOptions::SSL_KEY] = $this->sslKey;
}
if (!$this->sslVerification) {
$config[RequestOptions::SSL_VERIFY] = false;
}
if (!empty($this->sslCA)) {
$config[RequestOptions::SSL_CA] = $this->sslCA;
}
return $config;
}
/**
* Set the configuration for the specific HTTP client using an adapter
*/
protected function setOptions(ClientInterface $client, array $config, array $clientOptions = []): ClientInterface
{
if (empty($config) && empty($clientOptions)) {
return $client;
}
$class = get_class($client);
if (!isset(AdapterOptions::HTTP_ADAPTERS[$class])) {
throw new HttpClientException(sprintf(
"The HTTP client %s is not supported for custom options",
$class
));
}
$adapterClass = AdapterOptions::HTTP_ADAPTERS[$class];
if (!class_exists($adapterClass) || !in_array(AdapterInterface::class, class_implements($adapterClass))) {
throw new HttpClientException(sprintf(
"The class %s does not exists or does not implement %s",
$adapterClass,
AdapterInterface::class
));
}
$adapter = new $adapterClass;
return $adapter->setConfig($client, $config, $clientOptions);
}
}

View File

@ -0,0 +1,72 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Response\Elasticsearch;
use Elastic\Transport\Transport;
use Http\Promise\Promise;
use Psr\Http\Message\RequestInterface;
use Psr\Log\LoggerInterface;
interface ClientInterface
{
/**
* Get the Elastic\Transport\Transport
*/
public function getTransport(): Transport;
/**
* Get the PSR-3 logger
*/
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);
}

View File

@ -0,0 +1,30 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\ClientInterface;
use Elastic\Elasticsearch\Traits\EndpointTrait;
abstract class AbstractEndpoint
{
use EndpointTrait;
protected ClientInterface $client;
public function __construct(ClientInterface $client)
{
$this->client = $client;
}
}

View File

@ -0,0 +1,217 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class AsyncSearch extends AbstractEndpoint
{
/**
* Deletes an async search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
*
* @param array{
* id: string, // (REQUIRED) The async search ID
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function delete(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_async_search/' . $this->encode($params['id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves the results of a previously submitted async search request given its ID.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
*
* @param array{
* id: string, // (REQUIRED) The async search ID
* wait_for_completion_timeout: time, // Specify the time that the request should block waiting for the final response
* keep_alive: time, // Specify the time interval in which the results (partial or final) for this search will be available
* typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function get(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_async_search/' . $this->encode($params['id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_alive','typed_keys','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves the status of a previously submitted async search request given its ID.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
*
* @param array{
* id: string, // (REQUIRED) The async search ID
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function status(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_async_search/status/' . $this->encode($params['id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Executes a search request asynchronously.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
*
* @param array{
* index: list, // A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* wait_for_completion_timeout: time, // Specify the time that the request should block waiting for the final response
* keep_on_completion: boolean, // Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false)
* keep_alive: time, // Update the time interval in which the results (partial or final) for this search will be available
* batched_reduce_size: number, // The number of shard results that should be reduced at once on the coordinating node. This value should be used as the granularity at which progress results will be made available.
* request_cache: boolean, // Specify if request cache should be used for this request or not, defaults to true
* analyzer: string, // The analyzer to use for the query string
* analyze_wildcard: boolean, // Specify whether wildcard and prefix queries should be analyzed (default: false)
* default_operator: enum, // The default operator for query string query (AND or OR)
* df: string, // The field to use as default where no field prefix is given in the query string
* explain: boolean, // Specify whether to return detailed information about score computation as part of a hit
* stored_fields: list, // A comma-separated list of stored fields to return as part of a hit
* docvalue_fields: list, // A comma-separated list of fields to return as the docvalue representation of a field for each hit
* from: number, // Starting offset (default: 0)
* ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed)
* ignore_throttled: boolean, // Whether specified concrete, expanded or aliased indices should be ignored when throttled
* allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both.
* lenient: boolean, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* preference: string, // Specify the node or shard the operation should be performed on (default: random)
* q: string, // Query in the Lucene query string syntax
* routing: list, // A comma-separated list of specific routing values
* search_type: enum, // Search operation type
* size: number, // Number of hits to return (default: 10)
* sort: list, // A comma-separated list of <field>:<direction> pairs
* _source: list, // True or false to return the _source field or not, or a list of fields to return
* _source_excludes: list, // A list of fields to exclude from the returned _source field
* _source_includes: list, // A list of fields to extract and return from the _source field
* terminate_after: number, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
* stats: list, // Specific 'tag' of the request for logging and statistical purposes
* suggest_field: string, // Specify which field to use for suggestions
* suggest_mode: enum, // Specify suggest mode
* suggest_size: number, // How many suggestions to return in response
* suggest_text: string, // The source text for which the suggestions should be returned
* timeout: time, // Explicit operation timeout
* track_scores: boolean, // Whether to calculate and return scores even if they are not used for sorting
* track_total_hits: boolean|long, // Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number.
* allow_partial_search_results: boolean, // Indicate if an error should be returned if there is a partial search failure or timeout
* typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response
* version: boolean, // Specify whether to return document version as part of a hit
* seq_no_primary_term: boolean, // Specify whether to return sequence number and primary term of the last modification of each hit
* max_concurrent_shard_requests: number, // The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The search definition using the Query DSL
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function submit(array $params = [])
{
if (isset($params['index'])) {
$url = '/' . $this->encode($params['index']) . '/_async_search';
$method = 'POST';
} else {
$url = '/_async_search';
$method = 'POST';
}
$url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_on_completion','keep_alive','batched_reduce_size','request_cache','analyzer','analyze_wildcard','default_operator','df','explain','stored_fields','docvalue_fields','from','ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','lenient','preference','q','routing','search_type','size','sort','_source','_source_excludes','_source_includes','terminate_after','stats','suggest_field','suggest_mode','suggest_size','suggest_text','timeout','track_scores','track_total_hits','allow_partial_search_results','typed_keys','version','seq_no_primary_term','max_concurrent_shard_requests','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,168 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Autoscaling extends AbstractEndpoint
{
/**
* Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-delete-autoscaling-policy.html
*
* @param array{
* name: string, // (REQUIRED) the name of the autoscaling policy
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteAutoscalingPolicy(array $params = [])
{
$this->checkRequiredParameters(['name'], $params);
$url = '/_autoscaling/policy/' . $this->encode($params['name']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Gets the current autoscaling capacity based on the configured autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-capacity.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getAutoscalingCapacity(array $params = [])
{
$url = '/_autoscaling/capacity';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-policy.html
*
* @param array{
* name: string, // (REQUIRED) the name of the autoscaling policy
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getAutoscalingPolicy(array $params = [])
{
$this->checkRequiredParameters(['name'], $params);
$url = '/_autoscaling/policy/' . $this->encode($params['name']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-put-autoscaling-policy.html
*
* @param array{
* name: string, // (REQUIRED) the name of the autoscaling policy
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) the specification of the autoscaling policy
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function putAutoscalingPolicy(array $params = [])
{
$this->checkRequiredParameters(['name','body'], $params);
$url = '/_autoscaling/policy/' . $this->encode($params['name']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,492 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Ccr extends AbstractEndpoint
{
/**
* Deletes auto-follow patterns.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html
*
* @param array{
* name: string, // (REQUIRED) The name of the auto follow pattern.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteAutoFollowPattern(array $params = [])
{
$this->checkRequiredParameters(['name'], $params);
$url = '/_ccr/auto_follow/' . $this->encode($params['name']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Creates a new follower index configured to follow the referenced leader index.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html
*
* @param array{
* index: string, // (REQUIRED) The name of the follower index
* wait_for_active_shards: string, // Sets the number of shard copies that must be active before returning. Defaults to 0. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The name of the leader index and other optional ccr related parameters
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function follow(array $params = [])
{
$this->checkRequiredParameters(['index','body'], $params);
$url = '/' . $this->encode($params['index']) . '/_ccr/follow';
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['wait_for_active_shards','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves information about all follower indices, including parameters and status for each follower index
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html
*
* @param array{
* index: list, // (REQUIRED) A comma-separated list of index patterns; use `_all` to perform the operation on all indices
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function followInfo(array $params = [])
{
$this->checkRequiredParameters(['index'], $params);
$url = '/' . $this->encode($params['index']) . '/_ccr/info';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves follower stats. return shard-level stats about the following tasks associated with each shard for the specified indices.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html
*
* @param array{
* index: list, // (REQUIRED) A comma-separated list of index patterns; use `_all` to perform the operation on all indices
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function followStats(array $params = [])
{
$this->checkRequiredParameters(['index'], $params);
$url = '/' . $this->encode($params['index']) . '/_ccr/stats';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Removes the follower retention leases from the leader.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-forget-follower.html
*
* @param array{
* index: string, // (REQUIRED) the name of the leader index for which specified follower retention leases should be removed
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) the name and UUID of the follower index, the name of the cluster containing the follower index, and the alias from the perspective of that cluster for the remote cluster containing the leader index
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function forgetFollower(array $params = [])
{
$this->checkRequiredParameters(['index','body'], $params);
$url = '/' . $this->encode($params['index']) . '/_ccr/forget_follower';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Gets configured auto-follow patterns. Returns the specified auto-follow pattern collection.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html
*
* @param array{
* name: string, // The name of the auto follow pattern.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getAutoFollowPattern(array $params = [])
{
if (isset($params['name'])) {
$url = '/_ccr/auto_follow/' . $this->encode($params['name']);
$method = 'GET';
} else {
$url = '/_ccr/auto_follow';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Pauses an auto-follow pattern
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-auto-follow-pattern.html
*
* @param array{
* name: string, // (REQUIRED) The name of the auto follow pattern that should pause discovering new indices to follow.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function pauseAutoFollowPattern(array $params = [])
{
$this->checkRequiredParameters(['name'], $params);
$url = '/_ccr/auto_follow/' . $this->encode($params['name']) . '/pause';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Pauses a follower index. The follower index will not fetch any additional operations from the leader index.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html
*
* @param array{
* index: string, // (REQUIRED) The name of the follower index that should pause following its leader index.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function pauseFollow(array $params = [])
{
$this->checkRequiredParameters(['index'], $params);
$url = '/' . $this->encode($params['index']) . '/_ccr/pause_follow';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Creates a new named collection of auto-follow patterns against a specified remote cluster. Newly created indices on the remote cluster matching any of the specified patterns will be automatically configured as follower indices.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html
*
* @param array{
* name: string, // (REQUIRED) The name of the auto follow pattern.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The specification of the auto follow pattern
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function putAutoFollowPattern(array $params = [])
{
$this->checkRequiredParameters(['name','body'], $params);
$url = '/_ccr/auto_follow/' . $this->encode($params['name']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Resumes an auto-follow pattern that has been paused
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-resume-auto-follow-pattern.html
*
* @param array{
* name: string, // (REQUIRED) The name of the auto follow pattern to resume discovering new indices to follow.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function resumeAutoFollowPattern(array $params = [])
{
$this->checkRequiredParameters(['name'], $params);
$url = '/_ccr/auto_follow/' . $this->encode($params['name']) . '/resume';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Resumes a follower index that has been paused
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html
*
* @param array{
* index: string, // (REQUIRED) The name of the follow index to resume following.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The name of the leader index and other optional ccr related parameters
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function resumeFollow(array $params = [])
{
$this->checkRequiredParameters(['index'], $params);
$url = '/' . $this->encode($params['index']) . '/_ccr/resume_follow';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Gets all stats related to cross-cluster replication.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function stats(array $params = [])
{
$url = '/_ccr/stats';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Stops the following task associated with a follower index and removes index metadata and settings associated with cross-cluster replication.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-unfollow.html
*
* @param array{
* index: string, // (REQUIRED) The name of the follower index that should be turned into a regular index.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function unfollow(array $params = [])
{
$this->checkRequiredParameters(['index'], $params);
$url = '/' . $this->encode($params['index']) . '/_ccr/unfollow';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,605 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Cluster extends AbstractEndpoint
{
/**
* Provides explanations for shard allocations in the cluster.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html
*
* @param array{
* include_yes_decisions: boolean, // Return 'YES' decisions in explanation (default: false)
* include_disk_info: boolean, // Return information about disk usage and shard sizes (default: false)
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The index, shard, and primary flag to explain. Empty means 'explain a randomly-chosen unassigned shard'
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function allocationExplain(array $params = [])
{
$url = '/_cluster/allocation/explain';
$method = empty($params['body']) ? 'GET' : 'POST';
$url = $this->addQueryString($url, $params, ['include_yes_decisions','include_disk_info','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes a component template
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html
*
* @param array{
* name: string, // (REQUIRED) The name of the template
* timeout: time, // Explicit operation timeout
* master_timeout: time, // Specify timeout for connection to master
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteComponentTemplate(array $params = [])
{
$this->checkRequiredParameters(['name'], $params);
$url = '/_component_template/' . $this->encode($params['name']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['timeout','master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Clears cluster voting config exclusions.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html
*
* @param array{
* wait_for_removal: boolean, // Specifies whether to wait for all excluded nodes to be removed from the cluster before clearing the voting configuration exclusions list.
* master_timeout: time, // Timeout for submitting request to master
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteVotingConfigExclusions(array $params = [])
{
$url = '/_cluster/voting_config_exclusions';
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['wait_for_removal','master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns information about whether a particular component template exist
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html
*
* @param array{
* name: string, // (REQUIRED) The name of the template
* master_timeout: time, // Explicit operation timeout for connection to master node
* local: boolean, // Return local information, do not retrieve the state from master node (default: false)
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function existsComponentTemplate(array $params = [])
{
$this->checkRequiredParameters(['name'], $params);
$url = '/_component_template/' . $this->encode($params['name']);
$method = 'HEAD';
$url = $this->addQueryString($url, $params, ['master_timeout','local','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns one or more component templates
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html
*
* @param array{
* name: list, // The comma separated names of the component templates
* master_timeout: time, // Explicit operation timeout for connection to master node
* local: boolean, // Return local information, do not retrieve the state from master node (default: false)
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getComponentTemplate(array $params = [])
{
if (isset($params['name'])) {
$url = '/_component_template/' . $this->encode($params['name']);
$method = 'GET';
} else {
$url = '/_component_template';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['master_timeout','local','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns cluster settings.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-get-settings.html
*
* @param array{
* flat_settings: boolean, // Return settings in flat format (default: false)
* master_timeout: time, // Explicit operation timeout for connection to master node
* timeout: time, // Explicit operation timeout
* include_defaults: boolean, // Whether to return all default clusters setting.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getSettings(array $params = [])
{
$url = '/_cluster/settings';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['flat_settings','master_timeout','timeout','include_defaults','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns basic information about the health of the cluster.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html
*
* @param array{
* index: list, // Limit the information returned to a specific index
* expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both.
* level: enum, // Specify the level of detail for returned information
* local: boolean, // Return local information, do not retrieve the state from master node (default: false)
* master_timeout: time, // Explicit operation timeout for connection to master node
* timeout: time, // Explicit operation timeout
* wait_for_active_shards: string, // Wait until the specified number of shards is active
* wait_for_nodes: string, // Wait until the specified number of nodes is available
* wait_for_events: enum, // Wait until all currently queued events with the given priority are processed
* wait_for_no_relocating_shards: boolean, // Whether to wait until there are no relocating shards in the cluster
* wait_for_no_initializing_shards: boolean, // Whether to wait until there are no initializing shards in the cluster
* wait_for_status: enum, // Wait until cluster is in a specific state
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function health(array $params = [])
{
if (isset($params['index'])) {
$url = '/_cluster/health/' . $this->encode($params['index']);
$method = 'GET';
} else {
$url = '/_cluster/health';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['expand_wildcards','level','local','master_timeout','timeout','wait_for_active_shards','wait_for_nodes','wait_for_events','wait_for_no_relocating_shards','wait_for_no_initializing_shards','wait_for_status','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns a list of any cluster-level changes (e.g. create index, update mapping,
* allocate or fail shard) which have not yet been executed.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html
*
* @param array{
* local: boolean, // Return local information, do not retrieve the state from master node (default: false)
* master_timeout: time, // Specify timeout for connection to master
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function pendingTasks(array $params = [])
{
$url = '/_cluster/pending_tasks';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['local','master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Updates the cluster voting config exclusions by node ids or node names.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html
*
* @param array{
* node_ids: string, // A comma-separated list of the persistent ids of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_names.
* node_names: string, // A comma-separated list of the names of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_ids.
* timeout: time, // Explicit operation timeout
* master_timeout: time, // Timeout for submitting request to master
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function postVotingConfigExclusions(array $params = [])
{
$url = '/_cluster/voting_config_exclusions';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['node_ids','node_names','timeout','master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Creates or updates a component template
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html
*
* @param array{
* name: string, // (REQUIRED) The name of the template
* create: boolean, // Whether the index template should only be added if new or can also replace an existing one
* timeout: time, // Explicit operation timeout
* master_timeout: time, // Specify timeout for connection to master
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The template definition
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function putComponentTemplate(array $params = [])
{
$this->checkRequiredParameters(['name','body'], $params);
$url = '/_component_template/' . $this->encode($params['name']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['create','timeout','master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Updates the cluster settings.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html
*
* @param array{
* flat_settings: boolean, // Return settings in flat format (default: false)
* master_timeout: time, // Explicit operation timeout for connection to master node
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart).
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function putSettings(array $params = [])
{
$this->checkRequiredParameters(['body'], $params);
$url = '/_cluster/settings';
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['flat_settings','master_timeout','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns the information about configured remote clusters.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function remoteInfo(array $params = [])
{
$url = '/_remote/info';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Allows to manually change the allocation of individual shards in the cluster.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html
*
* @param array{
* dry_run: boolean, // Simulate the operation only and return the resulting state
* explain: boolean, // Return an explanation of why the commands can or cannot be executed
* retry_failed: boolean, // Retries allocation of shards that are blocked due to too many subsequent allocation failures
* metric: list, // Limit the information returned to the specified metrics. Defaults to all but metadata
* master_timeout: time, // Explicit operation timeout for connection to master node
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The definition of `commands` to perform (`move`, `cancel`, `allocate`)
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function reroute(array $params = [])
{
$url = '/_cluster/reroute';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['dry_run','explain','retry_failed','metric','master_timeout','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns a comprehensive information about the state of the cluster.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html
*
* @param array{
* metric: list, // Limit the information returned to the specified metrics
* index: list, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
* local: boolean, // Return local information, do not retrieve the state from master node (default: false)
* master_timeout: time, // Specify timeout for connection to master
* flat_settings: boolean, // Return settings in flat format (default: false)
* wait_for_metadata_version: number, // Wait for the metadata version to be equal or greater than the specified metadata version
* wait_for_timeout: time, // The maximum time to wait for wait_for_metadata_version before timing out
* ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed)
* allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function state(array $params = [])
{
if (isset($params['index']) && isset($params['metric'])) {
$url = '/_cluster/state/' . $this->encode($params['metric']) . '/' . $this->encode($params['index']);
$method = 'GET';
} elseif (isset($params['metric'])) {
$url = '/_cluster/state/' . $this->encode($params['metric']);
$method = 'GET';
} else {
$url = '/_cluster/state';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['local','master_timeout','flat_settings','wait_for_metadata_version','wait_for_timeout','ignore_unavailable','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns high-level overview of cluster statistics.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html
*
* @param array{
* node_id: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* flat_settings: boolean, // Return settings in flat format (default: false)
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function stats(array $params = [])
{
if (isset($params['node_id'])) {
$url = '/_cluster/stats/nodes/' . $this->encode($params['node_id']);
$method = 'GET';
} else {
$url = '/_cluster/stats';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['flat_settings','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,137 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class DanglingIndices extends AbstractEndpoint
{
/**
* Deletes the specified dangling index
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html
*
* @param array{
* index_uuid: string, // (REQUIRED) The UUID of the dangling index
* accept_data_loss: boolean, // Must be set to true in order to delete the dangling index
* timeout: time, // Explicit operation timeout
* master_timeout: time, // Specify timeout for connection to master
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteDanglingIndex(array $params = [])
{
$this->checkRequiredParameters(['index_uuid'], $params);
$url = '/_dangling/' . $this->encode($params['index_uuid']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['accept_data_loss','timeout','master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Imports the specified dangling index
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html
*
* @param array{
* index_uuid: string, // (REQUIRED) The UUID of the dangling index
* accept_data_loss: boolean, // Must be set to true in order to import the dangling index
* timeout: time, // Explicit operation timeout
* master_timeout: time, // Specify timeout for connection to master
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function importDanglingIndex(array $params = [])
{
$this->checkRequiredParameters(['index_uuid'], $params);
$url = '/_dangling/' . $this->encode($params['index_uuid']);
$method = 'POST';
$url = $this->addQueryString($url, $params, ['accept_data_loss','timeout','master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns all dangling indices.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function listDanglingIndices(array $params = [])
{
$url = '/_dangling';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,206 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Enrich extends AbstractEndpoint
{
/**
* Deletes an existing enrich policy and its enrich index.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-enrich-policy-api.html
*
* @param array{
* name: string, // (REQUIRED) The name of the enrich policy
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deletePolicy(array $params = [])
{
$this->checkRequiredParameters(['name'], $params);
$url = '/_enrich/policy/' . $this->encode($params['name']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Creates the enrich index for an existing enrich policy.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/execute-enrich-policy-api.html
*
* @param array{
* name: string, // (REQUIRED) The name of the enrich policy
* wait_for_completion: boolean, // Should the request should block until the execution is complete.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function executePolicy(array $params = [])
{
$this->checkRequiredParameters(['name'], $params);
$url = '/_enrich/policy/' . $this->encode($params['name']) . '/_execute';
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['wait_for_completion','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Gets information about an enrich policy.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-enrich-policy-api.html
*
* @param array{
* name: list, // A comma-separated list of enrich policy names
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getPolicy(array $params = [])
{
if (isset($params['name'])) {
$url = '/_enrich/policy/' . $this->encode($params['name']);
$method = 'GET';
} else {
$url = '/_enrich/policy';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Creates a new enrich policy.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-enrich-policy-api.html
*
* @param array{
* name: string, // (REQUIRED) The name of the enrich policy
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The enrich policy to register
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function putPolicy(array $params = [])
{
$this->checkRequiredParameters(['name','body'], $params);
$url = '/_enrich/policy/' . $this->encode($params['name']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Gets enrich coordinator statistics and information about enrich policies that are currently executing.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-stats-api.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function stats(array $params = [])
{
$url = '/_enrich/_stats';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,176 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Eql extends AbstractEndpoint
{
/**
* Deletes an async EQL search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html
*
* @param array{
* id: string, // (REQUIRED) The async search ID
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function delete(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_eql/search/' . $this->encode($params['id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns async results from previously executed Event Query Language (EQL) search
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html
*
* @param array{
* id: string, // (REQUIRED) The async search ID
* wait_for_completion_timeout: time, // Specify the time that the request should block waiting for the final response
* keep_alive: time, // Update the time interval in which the results (partial or final) for this search will be available
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function get(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_eql/search/' . $this->encode($params['id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_alive','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns the status of a previously submitted async or stored Event Query Language (EQL) search
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html
*
* @param array{
* id: string, // (REQUIRED) The async search ID
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getStatus(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_eql/search/status/' . $this->encode($params['id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns results matching a query expressed in Event Query Language (EQL)
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html
*
* @param array{
* index: string, // (REQUIRED) The name of the index to scope the operation
* wait_for_completion_timeout: time, // Specify the time that the request should block waiting for the final response
* keep_on_completion: boolean, // Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false)
* keep_alive: time, // Update the time interval in which the results (partial or final) for this search will be available
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) Eql request body. Use the `query` to limit the query scope.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function search(array $params = [])
{
$this->checkRequiredParameters(['index','body'], $params);
$url = '/' . $this->encode($params['index']) . '/_eql/search';
$method = empty($params['body']) ? 'GET' : 'POST';
$url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_on_completion','keep_alive','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,95 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Features extends AbstractEndpoint
{
/**
* Gets a list of features which can be included in snapshots using the feature_states field when creating a snapshot
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-features-api.html
*
* @param array{
* master_timeout: time, // Explicit operation timeout for connection to master node
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getFeatures(array $params = [])
{
$url = '/_features';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Resets the internal state of features, usually by deleting system indices
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function resetFeatures(array $params = [])
{
$url = '/_features/_reset';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,149 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Fleet extends AbstractEndpoint
{
/**
* Returns the current global checkpoints for an index. This API is design for internal use by the fleet server project.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-global-checkpoints.html
*
* @param array{
* index: string, // (REQUIRED) The name of the index.
* wait_for_advance: boolean, // Whether to wait for the global checkpoint to advance past the specified current checkpoints
* wait_for_index: boolean, // Whether to wait for the target index to exist and all primary shards be active
* checkpoints: list, // Comma separated list of checkpoints
* timeout: time, // Timeout to wait for global checkpoint to advance
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function globalCheckpoints(array $params = [])
{
$this->checkRequiredParameters(['index'], $params);
$url = '/' . $this->encode($params['index']) . '/_fleet/global_checkpoints';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['wait_for_advance','wait_for_index','checkpoints','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Multi Search API where the search will only be executed after specified checkpoints are available due to a refresh. This API is designed for internal use by the fleet server project.
*
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* index: string, // The index name to use as the default
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The request definitions (metadata-fleet search request definition pairs), separated by newlines
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function msearch(array $params = [])
{
$this->checkRequiredParameters(['body'], $params);
if (isset($params['index'])) {
$url = '/' . $this->encode($params['index']) . '/_fleet/_fleet_msearch';
$method = empty($params['body']) ? 'GET' : 'POST';
} else {
$url = '/_fleet/_fleet_msearch';
$method = empty($params['body']) ? 'GET' : 'POST';
}
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/x-ndjson',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Search API where the search will only be executed after specified checkpoints are available due to a refresh. This API is designed for internal use by the fleet server project.
*
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* index: string, // (REQUIRED) The index name to search.
* wait_for_checkpoints: list, // Comma separated list of checkpoints, one per shard
* wait_for_checkpoints_timeout: time, // Explicit wait_for_checkpoints timeout
* allow_partial_search_results: boolean, // Indicate if an error should be returned if there is a partial search failure or timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The search definition using the Query DSL
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function search(array $params = [])
{
$this->checkRequiredParameters(['index'], $params);
$url = '/' . $this->encode($params['index']) . '/_fleet/_fleet_search';
$method = empty($params['body']) ? 'GET' : 'POST';
$url = $this->addQueryString($url, $params, ['wait_for_checkpoints','wait_for_checkpoints_timeout','allow_partial_search_results','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,68 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Graph extends AbstractEndpoint
{
/**
* Explore extracted and summarized information about the documents and terms in an index.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html
*
* @param array{
* index: list, // (REQUIRED) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* routing: string, // Specific routing value
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // Graph Query DSL
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function explore(array $params = [])
{
$this->checkRequiredParameters(['index'], $params);
$url = '/' . $this->encode($params['index']) . '/_graph/explore';
$method = empty($params['body']) ? 'GET' : 'POST';
$url = $this->addQueryString($url, $params, ['routing','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,413 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Ilm extends AbstractEndpoint
{
/**
* Deletes the specified lifecycle policy definition. A currently used policy cannot be deleted.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html
*
* @param array{
* policy: string, // (REQUIRED) The name of the index lifecycle policy
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteLifecycle(array $params = [])
{
$this->checkRequiredParameters(['policy'], $params);
$url = '/_ilm/policy/' . $this->encode($params['policy']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves information about the index's current lifecycle state, such as the currently executing phase, action, and step.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html
*
* @param array{
* index: string, // (REQUIRED) The name of the index to explain
* only_managed: boolean, // filters the indices included in the response to ones managed by ILM
* only_errors: boolean, // filters the indices included in the response to ones in an ILM error state, implies only_managed
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function explainLifecycle(array $params = [])
{
$this->checkRequiredParameters(['index'], $params);
$url = '/' . $this->encode($params['index']) . '/_ilm/explain';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['only_managed','only_errors','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns the specified policy definition. Includes the policy version and last modified date.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html
*
* @param array{
* policy: string, // The name of the index lifecycle policy
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getLifecycle(array $params = [])
{
if (isset($params['policy'])) {
$url = '/_ilm/policy/' . $this->encode($params['policy']);
$method = 'GET';
} else {
$url = '/_ilm/policy';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves the current index lifecycle management (ILM) status.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getStatus(array $params = [])
{
$url = '/_ilm/status';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Migrates the indices and ILM policies away from custom node attribute allocation routing to data tiers routing
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-migrate-to-data-tiers.html
*
* @param array{
* dry_run: boolean, // If set to true it will simulate the migration, providing a way to retrieve the ILM policies and indices that need to be migrated. The default is false
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // Optionally specify a legacy index template name to delete and optionally specify a node attribute name used for index shard routing (defaults to "data")
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function migrateToDataTiers(array $params = [])
{
$url = '/_ilm/migrate_to_data_tiers';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['dry_run','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Manually moves an index into the specified step and executes that step.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html
*
* @param array{
* index: string, // (REQUIRED) The name of the index whose lifecycle step is to change
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The new lifecycle step to move to
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function moveToStep(array $params = [])
{
$this->checkRequiredParameters(['index'], $params);
$url = '/_ilm/move/' . $this->encode($params['index']);
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Creates a lifecycle policy
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html
*
* @param array{
* policy: string, // (REQUIRED) The name of the index lifecycle policy
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The lifecycle policy definition to register
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function putLifecycle(array $params = [])
{
$this->checkRequiredParameters(['policy'], $params);
$url = '/_ilm/policy/' . $this->encode($params['policy']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Removes the assigned lifecycle policy and stops managing the specified index
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html
*
* @param array{
* index: string, // (REQUIRED) The name of the index to remove policy on
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function removePolicy(array $params = [])
{
$this->checkRequiredParameters(['index'], $params);
$url = '/' . $this->encode($params['index']) . '/_ilm/remove';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retries executing the policy for an index that is in the ERROR step.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html
*
* @param array{
* index: string, // (REQUIRED) The name of the indices (comma-separated) whose failed lifecycle step is to be retry
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function retry(array $params = [])
{
$this->checkRequiredParameters(['index'], $params);
$url = '/' . $this->encode($params['index']) . '/_ilm/retry';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Start the index lifecycle management (ILM) plugin.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function start(array $params = [])
{
$url = '/_ilm/start';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Halts all lifecycle management operations and stops the index lifecycle management (ILM) plugin
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function stop(array $params = [])
{
$url = '/_ilm/stop';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,250 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Ingest extends AbstractEndpoint
{
/**
* Deletes a pipeline.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-pipeline-api.html
*
* @param array{
* id: string, // (REQUIRED) Pipeline ID
* master_timeout: time, // Explicit operation timeout for connection to master node
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deletePipeline(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_ingest/pipeline/' . $this->encode($params['id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns statistical information about geoip databases
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/geoip-stats-api.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function geoIpStats(array $params = [])
{
$url = '/_ingest/geoip/stats';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns a pipeline.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-pipeline-api.html
*
* @param array{
* id: string, // Comma separated list of pipeline ids. Wildcards supported
* summary: boolean, // Return pipelines without their definitions (default: false)
* master_timeout: time, // Explicit operation timeout for connection to master node
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getPipeline(array $params = [])
{
if (isset($params['id'])) {
$url = '/_ingest/pipeline/' . $this->encode($params['id']);
$method = 'GET';
} else {
$url = '/_ingest/pipeline';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['summary','master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns a list of the built-in patterns.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/grok-processor.html#grok-processor-rest-get
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function processorGrok(array $params = [])
{
$url = '/_ingest/processor/grok';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Creates or updates a pipeline.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-pipeline-api.html
*
* @param array{
* id: string, // (REQUIRED) Pipeline ID
* if_version: int, // Required version for optimistic concurrency control for pipeline updates
* master_timeout: time, // Explicit operation timeout for connection to master node
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The ingest definition
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function putPipeline(array $params = [])
{
$this->checkRequiredParameters(['id','body'], $params);
$url = '/_ingest/pipeline/' . $this->encode($params['id']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['if_version','master_timeout','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Allows to simulate a pipeline with example documents.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-pipeline-api.html
*
* @param array{
* id: string, // Pipeline ID
* verbose: boolean, // Verbose mode. Display data output for each processor in executed pipeline
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The simulate definition
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function simulate(array $params = [])
{
$this->checkRequiredParameters(['body'], $params);
if (isset($params['id'])) {
$url = '/_ingest/pipeline/' . $this->encode($params['id']) . '/_simulate';
$method = empty($params['body']) ? 'GET' : 'POST';
} else {
$url = '/_ingest/pipeline/_simulate';
$method = empty($params['body']) ? 'GET' : 'POST';
}
$url = $this->addQueryString($url, $params, ['verbose','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,261 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class License extends AbstractEndpoint
{
/**
* Deletes licensing information for the cluster
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-license.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function delete(array $params = [])
{
$url = '/_license';
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves licensing information for the cluster
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-license.html
*
* @param array{
* local: boolean, // Return local information, do not retrieve the state from master node (default: false)
* accept_enterprise: boolean, // Supported for backwards compatibility with 7.x. If this param is used it must be set to true
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function get(array $params = [])
{
$url = '/_license';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['local','accept_enterprise','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves information about the status of the basic license.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-basic-status.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getBasicStatus(array $params = [])
{
$url = '/_license/basic_status';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves information about the status of the trial license.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-trial-status.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getTrialStatus(array $params = [])
{
$url = '/_license/trial_status';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Updates the license for the cluster.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-license.html
*
* @param array{
* acknowledge: boolean, // whether the user has acknowledged acknowledge messages (default: false)
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // licenses to be installed
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function post(array $params = [])
{
$url = '/_license';
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['acknowledge','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Starts an indefinite basic license.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/start-basic.html
*
* @param array{
* acknowledge: boolean, // whether the user has acknowledged acknowledge messages (default: false)
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function postStartBasic(array $params = [])
{
$url = '/_license/start_basic';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['acknowledge','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* starts a limited time trial license.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/start-trial.html
*
* @param array{
* type: string, // The type of trial license to generate (default: "trial")
* acknowledge: boolean, // whether the user has acknowledged acknowledge messages (default: false)
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function postStartTrial(array $params = [])
{
$url = '/_license/start_trial';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['type','acknowledge','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,136 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Logstash extends AbstractEndpoint
{
/**
* Deletes Logstash Pipelines used by Central Management
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-delete-pipeline.html
*
* @param array{
* id: string, // (REQUIRED) The ID of the Pipeline
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deletePipeline(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_logstash/pipeline/' . $this->encode($params['id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves Logstash Pipelines used by Central Management
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-get-pipeline.html
*
* @param array{
* id: string, // (REQUIRED) A comma-separated list of Pipeline IDs
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getPipeline(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_logstash/pipeline/' . $this->encode($params['id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Adds and updates Logstash Pipelines used for Central Management
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-put-pipeline.html
*
* @param array{
* id: string, // (REQUIRED) The ID of the Pipeline
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The Pipeline to add or update
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function putPipeline(array $params = [])
{
$this->checkRequiredParameters(['id','body'], $params);
$url = '/_logstash/pipeline/' . $this->encode($params['id']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,130 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Migration extends AbstractEndpoint
{
/**
* Retrieves information about different cluster, node, and index level settings that use deprecated features that will be removed or changed in the next major version.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-deprecation.html
*
* @param array{
* index: string, // Index pattern
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deprecations(array $params = [])
{
if (isset($params['index'])) {
$url = '/' . $this->encode($params['index']) . '/_migration/deprecations';
$method = 'GET';
} else {
$url = '/_migration/deprecations';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Find out whether system features need to be upgraded or not
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-feature-upgrade.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getFeatureUpgradeStatus(array $params = [])
{
$url = '/_migration/system_features';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Begin upgrades for system features
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-feature-upgrade.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function postFeatureUpgrade(array $params = [])
{
$url = '/_migration/system_features';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,72 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Monitoring extends AbstractEndpoint
{
/**
* Used by the monitoring features to send monitoring data.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/monitor-elasticsearch-cluster.html
*
* @param array{
* type: string, // Default document type for items which don't provide one
* system_id: string, // Identifier of the monitored system
* system_api_version: string, // API Version of the monitored system
* interval: string, // Collection interval (e.g., '10s' or '10000ms') of the payload
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The operation definition and data (action-data pairs), separated by newlines
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function bulk(array $params = [])
{
$this->checkRequiredParameters(['body'], $params);
if (isset($params['type'])) {
$url = '/_monitoring/' . $this->encode($params['type']) . '/bulk';
$method = 'POST';
} else {
$url = '/_monitoring/bulk';
$method = 'POST';
}
$url = $this->addQueryString($url, $params, ['system_id','system_api_version','interval','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/x-ndjson',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,337 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Nodes extends AbstractEndpoint
{
/**
* Removes the archived repositories metering information present in the cluster.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-repositories-metering-archive-api.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* node_id: list, // (REQUIRED) Comma-separated list of node IDs or names used to limit returned information.
* max_archive_version: long, // (REQUIRED) Specifies the maximum archive_version to be cleared from the archive.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function clearRepositoriesMeteringArchive(array $params = [])
{
$this->checkRequiredParameters(['node_id','max_archive_version'], $params);
$url = '/_nodes/' . $this->encode($params['node_id']) . '/_repositories_metering/' . $this->encode($params['max_archive_version']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns cluster repositories metering information.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-repositories-metering-api.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* node_id: list, // (REQUIRED) A comma-separated list of node IDs or names to limit the returned information.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getRepositoriesMeteringInfo(array $params = [])
{
$this->checkRequiredParameters(['node_id'], $params);
$url = '/_nodes/' . $this->encode($params['node_id']) . '/_repositories_metering';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns information about hot threads on each node in the cluster.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-hot-threads.html
*
* @param array{
* node_id: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* interval: time, // The interval for the second sampling of threads
* snapshots: number, // Number of samples of thread stacktrace (default: 10)
* threads: number, // Specify the number of threads to provide information for (default: 3)
* ignore_idle_threads: boolean, // Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true)
* type: enum, // The type to sample (default: cpu)
* sort: enum, // The sort order for 'cpu' type (default: total)
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function hotThreads(array $params = [])
{
if (isset($params['node_id'])) {
$url = '/_nodes/' . $this->encode($params['node_id']) . '/hot_threads';
$method = 'GET';
} else {
$url = '/_nodes/hot_threads';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['interval','snapshots','threads','ignore_idle_threads','type','sort','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'text/plain',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns information about nodes in the cluster.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-info.html
*
* @param array{
* node_id: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* metric: list, // A comma-separated list of metrics you wish returned. Use `_all` to retrieve all metrics and `_none` to retrieve the node identity without any additional metrics.
* flat_settings: boolean, // Return settings in flat format (default: false)
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function info(array $params = [])
{
if (isset($params['node_id']) && isset($params['metric'])) {
$url = '/_nodes/' . $this->encode($params['node_id']) . '/' . $this->encode($params['metric']);
$method = 'GET';
} elseif (isset($params['node_id'])) {
$url = '/_nodes/' . $this->encode($params['node_id']);
$method = 'GET';
} elseif (isset($params['metric'])) {
$url = '/_nodes/' . $this->encode($params['metric']);
$method = 'GET';
} else {
$url = '/_nodes';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['flat_settings','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Reloads secure settings.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/secure-settings.html#reloadable-secure-settings
*
* @param array{
* node_id: list, // A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes.
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // An object containing the password for the elasticsearch keystore
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function reloadSecureSettings(array $params = [])
{
if (isset($params['node_id'])) {
$url = '/_nodes/' . $this->encode($params['node_id']) . '/reload_secure_settings';
$method = 'POST';
} else {
$url = '/_nodes/reload_secure_settings';
$method = 'POST';
}
$url = $this->addQueryString($url, $params, ['timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns statistical information about nodes in the cluster.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html
*
* @param array{
* node_id: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* metric: list, // Limit the information returned to the specified metrics
* index_metric: list, // Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified.
* completion_fields: list, // A comma-separated list of fields for the `completion` index metric (supports wildcards)
* fielddata_fields: list, // A comma-separated list of fields for the `fielddata` index metric (supports wildcards)
* fields: list, // A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards)
* groups: boolean, // A comma-separated list of search groups for `search` index metric
* level: enum, // Return indices stats aggregated at index, node or shard level
* types: list, // A comma-separated list of document types for the `indexing` index metric
* timeout: time, // Explicit operation timeout
* include_segment_file_sizes: boolean, // Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested)
* include_unloaded_segments: boolean, // If set to true segment stats will include stats for segments that are not currently loaded into memory
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function stats(array $params = [])
{
if (isset($params['metric']) && isset($params['index_metric']) && isset($params['node_id'])) {
$url = '/_nodes/' . $this->encode($params['node_id']) . '/stats/' . $this->encode($params['metric']) . '/' . $this->encode($params['index_metric']);
$method = 'GET';
} elseif (isset($params['metric']) && isset($params['node_id'])) {
$url = '/_nodes/' . $this->encode($params['node_id']) . '/stats/' . $this->encode($params['metric']);
$method = 'GET';
} elseif (isset($params['metric']) && isset($params['index_metric'])) {
$url = '/_nodes/stats/' . $this->encode($params['metric']) . '/' . $this->encode($params['index_metric']);
$method = 'GET';
} elseif (isset($params['node_id'])) {
$url = '/_nodes/' . $this->encode($params['node_id']) . '/stats';
$method = 'GET';
} elseif (isset($params['metric'])) {
$url = '/_nodes/stats/' . $this->encode($params['metric']);
$method = 'GET';
} else {
$url = '/_nodes/stats';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['completion_fields','fielddata_fields','fields','groups','level','types','timeout','include_segment_file_sizes','include_unloaded_segments','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns low-level information about REST actions usage on nodes.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html
*
* @param array{
* node_id: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* metric: list, // Limit the information returned to the specified metrics
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function usage(array $params = [])
{
if (isset($params['metric']) && isset($params['node_id'])) {
$url = '/_nodes/' . $this->encode($params['node_id']) . '/usage/' . $this->encode($params['metric']);
$method = 'GET';
} elseif (isset($params['node_id'])) {
$url = '/_nodes/' . $this->encode($params['node_id']) . '/usage';
$method = 'GET';
} elseif (isset($params['metric'])) {
$url = '/_nodes/usage/' . $this->encode($params['metric']);
$method = 'GET';
} else {
$url = '/_nodes/usage';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,329 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Rollup extends AbstractEndpoint
{
/**
* Deletes an existing rollup job.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-delete-job.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* id: string, // (REQUIRED) The ID of the job to delete
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteJob(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_rollup/job/' . $this->encode($params['id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves the configuration, stats, and status of rollup jobs.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-job.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* id: string, // The ID of the job(s) to fetch. Accepts glob patterns, or left blank for all jobs
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getJobs(array $params = [])
{
if (isset($params['id'])) {
$url = '/_rollup/job/' . $this->encode($params['id']);
$method = 'GET';
} else {
$url = '/_rollup/job/';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns the capabilities of any rollup jobs that have been configured for a specific index or index pattern.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-caps.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* id: string, // The ID of the index to check rollup capabilities on, or left blank for all jobs
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getRollupCaps(array $params = [])
{
if (isset($params['id'])) {
$url = '/_rollup/data/' . $this->encode($params['id']);
$method = 'GET';
} else {
$url = '/_rollup/data/';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns the rollup capabilities of all jobs inside of a rollup index (e.g. the index where rollup data is stored).
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-index-caps.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* index: string, // (REQUIRED) The rollup index or index pattern to obtain rollup capabilities from.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getRollupIndexCaps(array $params = [])
{
$this->checkRequiredParameters(['index'], $params);
$url = '/' . $this->encode($params['index']) . '/_rollup/data';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Creates a rollup job.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-put-job.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* id: string, // (REQUIRED) The ID of the job to create
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The job configuration
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function putJob(array $params = [])
{
$this->checkRequiredParameters(['id','body'], $params);
$url = '/_rollup/job/' . $this->encode($params['id']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Enables searching rolled-up data using the standard query DSL.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-search.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* index: list, // (REQUIRED) The indices or index-pattern(s) (containing rollup or regular data) that should be searched
* typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response
* rest_total_hits_as_int: boolean, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The search request body
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function rollupSearch(array $params = [])
{
$this->checkRequiredParameters(['index','body'], $params);
$url = '/' . $this->encode($params['index']) . '/_rollup_search';
$method = empty($params['body']) ? 'GET' : 'POST';
$url = $this->addQueryString($url, $params, ['typed_keys','rest_total_hits_as_int','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Starts an existing, stopped rollup job.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-start-job.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* id: string, // (REQUIRED) The ID of the job to start
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function startJob(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_rollup/job/' . $this->encode($params['id']) . '/_start';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Stops an existing, started rollup job.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-stop-job.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* id: string, // (REQUIRED) The ID of the job to stop
* wait_for_completion: boolean, // True if the API should block until the job has fully stopped, false if should be executed async. Defaults to false.
* timeout: time, // Block for (at maximum) the specified duration while waiting for the job to stop. Defaults to 30s.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function stopJob(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_rollup/job/' . $this->encode($params['id']) . '/_stop';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['wait_for_completion','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,187 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class SearchableSnapshots extends AbstractEndpoint
{
/**
* Retrieve node-level cache statistics about searchable snapshots.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-apis.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* node_id: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function cacheStats(array $params = [])
{
if (isset($params['node_id'])) {
$url = '/_searchable_snapshots/' . $this->encode($params['node_id']) . '/cache/stats';
$method = 'GET';
} else {
$url = '/_searchable_snapshots/cache/stats';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Clear the cache of searchable snapshots.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-apis.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* index: list, // A comma-separated list of index names
* ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed)
* allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function clearCache(array $params = [])
{
if (isset($params['index'])) {
$url = '/' . $this->encode($params['index']) . '/_searchable_snapshots/cache/clear';
$method = 'POST';
} else {
$url = '/_searchable_snapshots/cache/clear';
$method = 'POST';
}
$url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Mount a snapshot as a searchable index.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-api-mount-snapshot.html
*
* @param array{
* repository: string, // (REQUIRED) The name of the repository containing the snapshot of the index to mount
* snapshot: string, // (REQUIRED) The name of the snapshot of the index to mount
* master_timeout: time, // Explicit operation timeout for connection to master node
* wait_for_completion: boolean, // Should this request wait until the operation has completed before returning
* storage: string, // Selects the kind of local storage used to accelerate searches. Experimental, and defaults to `full_copy`
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The restore configuration for mounting the snapshot as searchable
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function mount(array $params = [])
{
$this->checkRequiredParameters(['repository','snapshot','body'], $params);
$url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']) . '/_mount';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['master_timeout','wait_for_completion','storage','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieve shard-level statistics about searchable snapshots.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-apis.html
*
* @param array{
* index: list, // A comma-separated list of index names
* level: enum, // Return stats aggregated at cluster, index or shard level
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function stats(array $params = [])
{
if (isset($params['index'])) {
$url = '/' . $this->encode($params['index']) . '/_searchable_snapshots/stats';
$method = 'GET';
} else {
$url = '/_searchable_snapshots/stats';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['level','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,140 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Shutdown extends AbstractEndpoint
{
/**
* Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current
*
* @param array{
* node_id: string, // (REQUIRED) The node id of node to be removed from the shutdown state
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteNode(array $params = [])
{
$this->checkRequiredParameters(['node_id'], $params);
$url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown';
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieve status of a node or nodes that are currently marked as shutting down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current
*
* @param array{
* node_id: string, // Which node for which to retrieve the shutdown status
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getNode(array $params = [])
{
if (isset($params['node_id'])) {
$url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown';
$method = 'GET';
} else {
$url = '/_nodes/shutdown';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current
*
* @param array{
* node_id: string, // (REQUIRED) The node id of node to be shut down
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The shutdown type definition to register
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function putNode(array $params = [])
{
$this->checkRequiredParameters(['node_id','body'], $params);
$url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown';
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,333 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Slm extends AbstractEndpoint
{
/**
* Deletes an existing snapshot lifecycle policy.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete-policy.html
*
* @param array{
* policy_id: string, // (REQUIRED) The id of the snapshot lifecycle policy to remove
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteLifecycle(array $params = [])
{
$this->checkRequiredParameters(['policy_id'], $params);
$url = '/_slm/policy/' . $this->encode($params['policy_id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Immediately creates a snapshot according to the lifecycle policy, without waiting for the scheduled time.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-lifecycle.html
*
* @param array{
* policy_id: string, // (REQUIRED) The id of the snapshot lifecycle policy to be executed
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function executeLifecycle(array $params = [])
{
$this->checkRequiredParameters(['policy_id'], $params);
$url = '/_slm/policy/' . $this->encode($params['policy_id']) . '/_execute';
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes any snapshots that are expired according to the policy's retention rules.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-retention.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function executeRetention(array $params = [])
{
$url = '/_slm/_execute_retention';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves one or more snapshot lifecycle policy definitions and information about the latest snapshot attempts.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-policy.html
*
* @param array{
* policy_id: list, // Comma-separated list of snapshot lifecycle policies to retrieve
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getLifecycle(array $params = [])
{
if (isset($params['policy_id'])) {
$url = '/_slm/policy/' . $this->encode($params['policy_id']);
$method = 'GET';
} else {
$url = '/_slm/policy';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns global and policy-level statistics about actions taken by snapshot lifecycle management.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-get-stats.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getStats(array $params = [])
{
$url = '/_slm/stats';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves the status of snapshot lifecycle management (SLM).
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-status.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getStatus(array $params = [])
{
$url = '/_slm/status';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Creates or updates a snapshot lifecycle policy.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put-policy.html
*
* @param array{
* policy_id: string, // (REQUIRED) The id of the snapshot lifecycle policy
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The snapshot lifecycle policy definition to register
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function putLifecycle(array $params = [])
{
$this->checkRequiredParameters(['policy_id'], $params);
$url = '/_slm/policy/' . $this->encode($params['policy_id']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Turns on snapshot lifecycle management (SLM).
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-start.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function start(array $params = [])
{
$url = '/_slm/start';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Turns off snapshot lifecycle management (SLM).
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-stop.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function stop(array $params = [])
{
$url = '/_slm/stop';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,514 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Snapshot extends AbstractEndpoint
{
/**
* Removes stale data from repository.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/clean-up-snapshot-repo-api.html
*
* @param array{
* repository: string, // (REQUIRED) A repository name
* master_timeout: time, // Explicit operation timeout for connection to master node
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function cleanupRepository(array $params = [])
{
$this->checkRequiredParameters(['repository'], $params);
$url = '/_snapshot/' . $this->encode($params['repository']) . '/_cleanup';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Clones indices from one snapshot into another snapshot in the same repository.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html
*
* @param array{
* repository: string, // (REQUIRED) A repository name
* snapshot: string, // (REQUIRED) The name of the snapshot to clone from
* target_snapshot: string, // (REQUIRED) The name of the cloned snapshot to create
* master_timeout: time, // Explicit operation timeout for connection to master node
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The snapshot clone definition
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function clone(array $params = [])
{
$this->checkRequiredParameters(['repository','snapshot','target_snapshot','body'], $params);
$url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']) . '/_clone/' . $this->encode($params['target_snapshot']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Creates a snapshot in a repository.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html
*
* @param array{
* repository: string, // (REQUIRED) A repository name
* snapshot: string, // (REQUIRED) A snapshot name
* master_timeout: time, // Explicit operation timeout for connection to master node
* wait_for_completion: boolean, // Should this request wait until the operation has completed before returning
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The snapshot definition
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function create(array $params = [])
{
$this->checkRequiredParameters(['repository','snapshot'], $params);
$url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['master_timeout','wait_for_completion','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Creates a repository.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html
*
* @param array{
* repository: string, // (REQUIRED) A repository name
* master_timeout: time, // Explicit operation timeout for connection to master node
* timeout: time, // Explicit operation timeout
* verify: boolean, // Whether to verify the repository after creation
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The repository definition
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function createRepository(array $params = [])
{
$this->checkRequiredParameters(['repository','body'], $params);
$url = '/_snapshot/' . $this->encode($params['repository']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['master_timeout','timeout','verify','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes one or more snapshots.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html
*
* @param array{
* repository: string, // (REQUIRED) A repository name
* snapshot: list, // (REQUIRED) A comma-separated list of snapshot names
* master_timeout: time, // Explicit operation timeout for connection to master node
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function delete(array $params = [])
{
$this->checkRequiredParameters(['repository','snapshot'], $params);
$url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes a repository.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html
*
* @param array{
* repository: list, // (REQUIRED) Name of the snapshot repository to unregister. Wildcard (`*`) patterns are supported.
* master_timeout: time, // Explicit operation timeout for connection to master node
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteRepository(array $params = [])
{
$this->checkRequiredParameters(['repository'], $params);
$url = '/_snapshot/' . $this->encode($params['repository']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns information about a snapshot.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html
*
* @param array{
* repository: string, // (REQUIRED) A repository name
* snapshot: list, // (REQUIRED) A comma-separated list of snapshot names
* master_timeout: time, // Explicit operation timeout for connection to master node
* ignore_unavailable: boolean, // Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown
* index_names: boolean, // Whether to include the name of each index in the snapshot. Defaults to true.
* index_details: boolean, // Whether to include details of each index in the snapshot, if those details are available. Defaults to false.
* include_repository: boolean, // Whether to include the repository name in the snapshot info. Defaults to true.
* sort: enum, // Allows setting a sort order for the result. Defaults to start_time
* size: integer, // Maximum number of snapshots to return. Defaults to 0 which means return all that match without limit.
* order: enum, // Sort order
* from_sort_value: string, // Value of the current sort column at which to start retrieval.
* after: string, // Offset identifier to start pagination from as returned by the 'next' field in the response body.
* offset: integer, // Numeric offset to start pagination based on the snapshots matching the request. Defaults to 0
* slm_policy_filter: string, // Filter snapshots by a comma-separated list of SLM policy names that snapshots belong to. Accepts wildcards. Use the special pattern '_none' to match snapshots without an SLM policy
* verbose: boolean, // Whether to show verbose snapshot info or only show the basic info found in the repository index blob
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function get(array $params = [])
{
$this->checkRequiredParameters(['repository','snapshot'], $params);
$url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['master_timeout','ignore_unavailable','index_names','index_details','include_repository','sort','size','order','from_sort_value','after','offset','slm_policy_filter','verbose','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns information about a repository.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html
*
* @param array{
* repository: list, // A comma-separated list of repository names
* master_timeout: time, // Explicit operation timeout for connection to master node
* local: boolean, // Return local information, do not retrieve the state from master node (default: false)
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getRepository(array $params = [])
{
if (isset($params['repository'])) {
$url = '/_snapshot/' . $this->encode($params['repository']);
$method = 'GET';
} else {
$url = '/_snapshot';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['master_timeout','local','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Analyzes a repository for correctness and performance
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html
*
* @param array{
* repository: string, // (REQUIRED) A repository name
* blob_count: number, // Number of blobs to create during the test. Defaults to 100.
* concurrency: number, // Number of operations to run concurrently during the test. Defaults to 10.
* read_node_count: number, // Number of nodes on which to read a blob after writing. Defaults to 10.
* early_read_node_count: number, // Number of nodes on which to perform an early read on a blob, i.e. before writing has completed. Early reads are rare actions so the 'rare_action_probability' parameter is also relevant. Defaults to 2.
* seed: number, // Seed for the random number generator used to create the test workload. Defaults to a random value.
* rare_action_probability: number, // Probability of taking a rare action such as an early read or an overwrite. Defaults to 0.02.
* max_blob_size: string, // Maximum size of a blob to create during the test, e.g '1gb' or '100mb'. Defaults to '10mb'.
* max_total_data_size: string, // Maximum total size of all blobs to create during the test, e.g '1tb' or '100gb'. Defaults to '1gb'.
* timeout: time, // Explicit operation timeout. Defaults to '30s'.
* detailed: boolean, // Whether to return detailed results or a summary. Defaults to 'false' so that only the summary is returned.
* rarely_abort_writes: boolean, // Whether to rarely abort writes before they complete. Defaults to 'true'.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function repositoryAnalyze(array $params = [])
{
$this->checkRequiredParameters(['repository'], $params);
$url = '/_snapshot/' . $this->encode($params['repository']) . '/_analyze';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['blob_count','concurrency','read_node_count','early_read_node_count','seed','rare_action_probability','max_blob_size','max_total_data_size','timeout','detailed','rarely_abort_writes','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Restores a snapshot.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html
*
* @param array{
* repository: string, // (REQUIRED) A repository name
* snapshot: string, // (REQUIRED) A snapshot name
* master_timeout: time, // Explicit operation timeout for connection to master node
* wait_for_completion: boolean, // Should this request wait until the operation has completed before returning
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // Details of what to restore
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function restore(array $params = [])
{
$this->checkRequiredParameters(['repository','snapshot'], $params);
$url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']) . '/_restore';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['master_timeout','wait_for_completion','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns information about the status of a snapshot.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html
*
* @param array{
* repository: string, // A repository name
* snapshot: list, // A comma-separated list of snapshot names
* master_timeout: time, // Explicit operation timeout for connection to master node
* ignore_unavailable: boolean, // Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function status(array $params = [])
{
if (isset($params['repository']) && isset($params['snapshot'])) {
$url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']) . '/_status';
$method = 'GET';
} elseif (isset($params['repository'])) {
$url = '/_snapshot/' . $this->encode($params['repository']) . '/_status';
$method = 'GET';
} else {
$url = '/_snapshot/_status';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['master_timeout','ignore_unavailable','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Verifies a repository.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html
*
* @param array{
* repository: string, // (REQUIRED) A repository name
* master_timeout: time, // Explicit operation timeout for connection to master node
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function verifyRepository(array $params = [])
{
$this->checkRequiredParameters(['repository'], $params);
$url = '/_snapshot/' . $this->encode($params['repository']) . '/_verify';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,244 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Sql extends AbstractEndpoint
{
/**
* Clears the SQL cursor
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-sql-cursor-api.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) Specify the cursor value in the `cursor` element to clean the cursor.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function clearCursor(array $params = [])
{
$this->checkRequiredParameters(['body'], $params);
$url = '/_sql/close';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes an async SQL search or a stored synchronous SQL search. If the search is still running, the API cancels it.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-async-sql-search-api.html
*
* @param array{
* id: string, // (REQUIRED) The async search ID
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteAsync(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_sql/async/delete/' . $this->encode($params['id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns the current status and available results for an async SQL search or stored synchronous SQL search
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-async-sql-search-api.html
*
* @param array{
* id: string, // (REQUIRED) The async search ID
* delimiter: string, // Separator for CSV results
* format: string, // Short version of the Accept header, e.g. json, yaml
* keep_alive: time, // Retention period for the search and its results
* wait_for_completion_timeout: time, // Duration to wait for complete results
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getAsync(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_sql/async/' . $this->encode($params['id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['delimiter','format','keep_alive','wait_for_completion_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns the current status of an async SQL search or a stored synchronous SQL search
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-async-sql-search-status-api.html
*
* @param array{
* id: string, // (REQUIRED) The async search ID
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getAsyncStatus(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_sql/async/status/' . $this->encode($params['id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Executes a SQL request
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-search-api.html
*
* @param array{
* format: string, // a short version of the Accept header, e.g. json, yaml
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) Use the `query` element to start a query. Use the `cursor` element to continue a query.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function query(array $params = [])
{
$this->checkRequiredParameters(['body'], $params);
$url = '/_sql';
$method = empty($params['body']) ? 'GET' : 'POST';
$url = $this->addQueryString($url, $params, ['format','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Translates SQL into Elasticsearch queries
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-translate-api.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) Specify the query in the `query` element.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function translate(array $params = [])
{
$this->checkRequiredParameters(['body'], $params);
$url = '/_sql/translate';
$method = empty($params['body']) ? 'GET' : 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,61 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Ssl extends AbstractEndpoint
{
/**
* Retrieves information about the X.509 certificates used to encrypt communications in the cluster.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function certificates(array $params = [])
{
$url = '/_ssl/certificates';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,149 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Tasks extends AbstractEndpoint
{
/**
* Cancels a task, if it can be cancelled through an API.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* task_id: string, // Cancel the task with specified task id (node_id:task_number)
* nodes: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* actions: list, // A comma-separated list of actions that should be cancelled. Leave empty to cancel all.
* parent_task_id: string, // Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all.
* wait_for_completion: boolean, // Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function cancel(array $params = [])
{
if (isset($params['task_id'])) {
$url = '/_tasks/' . $this->encode($params['task_id']) . '/_cancel';
$method = 'POST';
} else {
$url = '/_tasks/_cancel';
$method = 'POST';
}
$url = $this->addQueryString($url, $params, ['nodes','actions','parent_task_id','wait_for_completion','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns information about a task.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* task_id: string, // (REQUIRED) Return the task with specified id (node_id:task_number)
* wait_for_completion: boolean, // Wait for the matching tasks to complete (default: false)
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function get(array $params = [])
{
$this->checkRequiredParameters(['task_id'], $params);
$url = '/_tasks/' . $this->encode($params['task_id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['wait_for_completion','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns a list of tasks.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html
* @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
*
* @param array{
* nodes: list, // A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* actions: list, // A comma-separated list of actions that should be returned. Leave empty to return all.
* detailed: boolean, // Return detailed task information (default: false)
* parent_task_id: string, // Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all.
* wait_for_completion: boolean, // Wait for the matching tasks to complete (default: false)
* group_by: enum, // Group tasks by nodes or parent/child relationships
* timeout: time, // Explicit operation timeout
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function list(array $params = [])
{
$url = '/_tasks';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['nodes','actions','detailed','parent_task_id','wait_for_completion','group_by','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,79 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class TextStructure extends AbstractEndpoint
{
/**
* Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/find-structure.html
*
* @param array{
* lines_to_sample: int, // How many lines of the file should be included in the analysis
* line_merge_size_limit: int, // Maximum number of characters permitted in a single message when lines are merged to create messages.
* timeout: time, // Timeout after which the analysis will be aborted
* charset: string, // Optional parameter to specify the character set of the file
* format: enum, // Optional parameter to specify the high level file format
* has_header_row: boolean, // Optional parameter to specify whether a delimited file includes the column names in its first row
* column_names: list, // Optional parameter containing a comma separated list of the column names for a delimited file
* delimiter: string, // Optional parameter to specify the delimiter character for a delimited file - must be a single character
* quote: string, // Optional parameter to specify the quote character for a delimited file - must be a single character
* should_trim_fields: boolean, // Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them
* grok_pattern: string, // Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file
* ecs_compatibility: string, // Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either 'v1' or 'disabled'
* timestamp_field: string, // Optional parameter to specify the timestamp field in the file
* timestamp_format: string, // Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format
* explain: boolean, // Whether to include a commentary on how the structure was derived
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The contents of the file to be analyzed
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function findStructure(array $params = [])
{
$this->checkRequiredParameters(['body'], $params);
$url = '/_text_structure/find_structure';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['lines_to_sample','line_merge_size_limit','timeout','charset','format','has_header_row','column_names','delimiter','quote','should_trim_fields','grok_pattern','ecs_compatibility','timestamp_field','timestamp_format','explain','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/x-ndjson',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,411 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Transform extends AbstractEndpoint
{
/**
* Deletes an existing transform.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-transform.html
*
* @param array{
* transform_id: string, // (REQUIRED) The id of the transform to delete
* force: boolean, // When `true`, the transform is deleted regardless of its current state. The default value is `false`, meaning that the transform must be `stopped` before it can be deleted.
* timeout: time, // Controls the time to wait for the transform deletion
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteTransform(array $params = [])
{
$this->checkRequiredParameters(['transform_id'], $params);
$url = '/_transform/' . $this->encode($params['transform_id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['force','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves configuration information for transforms.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform.html
*
* @param array{
* transform_id: string, // The id or comma delimited list of id expressions of the transforms to get, '_all' or '*' implies get all transforms
* from: int, // skips a number of transform configs, defaults to 0
* size: int, // specifies a max number of transforms to get, defaults to 100
* allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified)
* exclude_generated: boolean, // Omits fields that are illegal to set on transform PUT
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getTransform(array $params = [])
{
if (isset($params['transform_id'])) {
$url = '/_transform/' . $this->encode($params['transform_id']);
$method = 'GET';
} else {
$url = '/_transform';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['from','size','allow_no_match','exclude_generated','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves usage information for transforms.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-stats.html
*
* @param array{
* transform_id: string, // (REQUIRED) The id of the transform for which to get stats. '_all' or '*' implies all transforms
* from: number, // skips a number of transform stats, defaults to 0
* size: number, // specifies a max number of transform stats to get, defaults to 100
* allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified)
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getTransformStats(array $params = [])
{
$this->checkRequiredParameters(['transform_id'], $params);
$url = '/_transform/' . $this->encode($params['transform_id']) . '/_stats';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['from','size','allow_no_match','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Previews a transform.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-transform.html
*
* @param array{
* transform_id: string, // The id of the transform to preview.
* timeout: time, // Controls the time to wait for the preview
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The definition for the transform to preview
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function previewTransform(array $params = [])
{
if (isset($params['transform_id'])) {
$url = '/_transform/' . $this->encode($params['transform_id']) . '/_preview';
$method = empty($params['body']) ? 'GET' : 'POST';
} else {
$url = '/_transform/_preview';
$method = empty($params['body']) ? 'GET' : 'POST';
}
$url = $this->addQueryString($url, $params, ['timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Instantiates a transform.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html
*
* @param array{
* transform_id: string, // (REQUIRED) The id of the new transform.
* defer_validation: boolean, // If validations should be deferred until transform starts, defaults to false.
* timeout: time, // Controls the time to wait for the transform to start
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The transform definition
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function putTransform(array $params = [])
{
$this->checkRequiredParameters(['transform_id','body'], $params);
$url = '/_transform/' . $this->encode($params['transform_id']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['defer_validation','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Resets an existing transform.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/reset-transform.html
*
* @param array{
* transform_id: string, // (REQUIRED) The id of the transform to reset
* force: boolean, // When `true`, the transform is reset regardless of its current state. The default value is `false`, meaning that the transform must be `stopped` before it can be reset.
* timeout: time, // Controls the time to wait for the transform to reset
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function resetTransform(array $params = [])
{
$this->checkRequiredParameters(['transform_id'], $params);
$url = '/_transform/' . $this->encode($params['transform_id']) . '/_reset';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['force','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Starts one or more transforms.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/start-transform.html
*
* @param array{
* transform_id: string, // (REQUIRED) The id of the transform to start
* timeout: time, // Controls the time to wait for the transform to start
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function startTransform(array $params = [])
{
$this->checkRequiredParameters(['transform_id'], $params);
$url = '/_transform/' . $this->encode($params['transform_id']) . '/_start';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Stops one or more transforms.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-transform.html
*
* @param array{
* transform_id: string, // (REQUIRED) The id of the transform to stop
* force: boolean, // Whether to force stop a failed transform or not. Default to false
* wait_for_completion: boolean, // Whether to wait for the transform to fully stop before returning or not. Default to false
* timeout: time, // Controls the time to wait until the transform has stopped. Default to 30 seconds
* allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified)
* wait_for_checkpoint: boolean, // Whether to wait for the transform to reach a checkpoint before stopping. Default to false
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function stopTransform(array $params = [])
{
$this->checkRequiredParameters(['transform_id'], $params);
$url = '/_transform/' . $this->encode($params['transform_id']) . '/_stop';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['force','wait_for_completion','timeout','allow_no_match','wait_for_checkpoint','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Updates certain properties of a transform.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/update-transform.html
*
* @param array{
* transform_id: string, // (REQUIRED) The id of the transform.
* defer_validation: boolean, // If validations should be deferred until transform starts, defaults to false.
* timeout: time, // Controls the time to wait for the update
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The update transform definition
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function updateTransform(array $params = [])
{
$this->checkRequiredParameters(['transform_id','body'], $params);
$url = '/_transform/' . $this->encode($params['transform_id']) . '/_update';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['defer_validation','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Upgrades all transforms.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/upgrade-transforms.html
*
* @param array{
* dry_run: boolean, // Whether to only check for updates but don't execute
* timeout: time, // Controls the time to wait for the upgrade
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function upgradeTransforms(array $params = [])
{
$url = '/_transform/_upgrade';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['dry_run','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,426 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Watcher extends AbstractEndpoint
{
/**
* Acknowledges a watch, manually throttling the execution of the watch's actions.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html
*
* @param array{
* watch_id: string, // (REQUIRED) Watch ID
* action_id: list, // A comma-separated list of the action ids to be acked
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function ackWatch(array $params = [])
{
$this->checkRequiredParameters(['watch_id'], $params);
if (isset($params['action_id'])) {
$url = '/_watcher/watch/' . $this->encode($params['watch_id']) . '/_ack/' . $this->encode($params['action_id']);
$method = 'PUT';
} else {
$url = '/_watcher/watch/' . $this->encode($params['watch_id']) . '/_ack';
$method = 'PUT';
}
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Activates a currently inactive watch.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html
*
* @param array{
* watch_id: string, // (REQUIRED) Watch ID
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function activateWatch(array $params = [])
{
$this->checkRequiredParameters(['watch_id'], $params);
$url = '/_watcher/watch/' . $this->encode($params['watch_id']) . '/_activate';
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deactivates a currently active watch.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html
*
* @param array{
* watch_id: string, // (REQUIRED) Watch ID
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deactivateWatch(array $params = [])
{
$this->checkRequiredParameters(['watch_id'], $params);
$url = '/_watcher/watch/' . $this->encode($params['watch_id']) . '/_deactivate';
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Removes a watch from Watcher.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html
*
* @param array{
* id: string, // (REQUIRED) Watch ID
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteWatch(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_watcher/watch/' . $this->encode($params['id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Forces the execution of a stored watch.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html
*
* @param array{
* id: string, // Watch ID
* debug: boolean, // indicates whether the watch should execute in debug mode
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // Execution control
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function executeWatch(array $params = [])
{
if (isset($params['id'])) {
$url = '/_watcher/watch/' . $this->encode($params['id']) . '/_execute';
$method = 'PUT';
} else {
$url = '/_watcher/watch/_execute';
$method = 'PUT';
}
$url = $this->addQueryString($url, $params, ['debug','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves a watch by its ID.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html
*
* @param array{
* id: string, // (REQUIRED) Watch ID
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getWatch(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_watcher/watch/' . $this->encode($params['id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Creates a new watch, or updates an existing one.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html
*
* @param array{
* id: string, // (REQUIRED) Watch ID
* active: boolean, // Specify whether the watch is in/active by default
* version: number, // Explicit version number for concurrency control
* if_seq_no: number, // only update the watch if the last operation that has changed the watch has the specified sequence number
* if_primary_term: number, // only update the watch if the last operation that has changed the watch has the specified primary term
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The watch
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function putWatch(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_watcher/watch/' . $this->encode($params['id']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['active','version','if_seq_no','if_primary_term','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves stored watches.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-query-watches.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // From, size, query, sort and search_after
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function queryWatches(array $params = [])
{
$url = '/_watcher/_query/watches';
$method = empty($params['body']) ? 'GET' : 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Starts Watcher if it is not already running.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function start(array $params = [])
{
$url = '/_watcher/_start';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves the current Watcher metrics.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html
*
* @param array{
* metric: list, // Controls what additional stat metrics should be include in the response
* emit_stacktraces: boolean, // Emits stack traces of currently running watches
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function stats(array $params = [])
{
if (isset($params['metric'])) {
$url = '/_watcher/stats/' . $this->encode($params['metric']);
$method = 'GET';
} else {
$url = '/_watcher/stats';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['emit_stacktraces','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Stops Watcher if it is running.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function stop(array $params = [])
{
$url = '/_watcher/_stop';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,96 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Xpack extends AbstractEndpoint
{
/**
* Retrieves information about the installed X-Pack features.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html
*
* @param array{
* categories: list, // Comma-separated list of info categories. Can be any of: build, license, features
* accept_enterprise: boolean, // If this param is used it must be set to true
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function info(array $params = [])
{
$url = '/_xpack';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['categories','accept_enterprise','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves usage information about the installed X-Pack features.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/usage-api.html
*
* @param array{
* master_timeout: time, // Specify timeout for watch write operation
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function usage(array $params = [])
{
$url = '/_xpack/usage';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Exception;
use Exception;
class ArrayAccessException extends Exception implements ElasticsearchException
{
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Exception;
use Exception;
class AuthenticationException extends Exception implements ElasticsearchException
{
}

View File

@ -0,0 +1,26 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Exception;
use Elastic\Elasticsearch\Traits\ResponseTrait;
use Exception;
/**
* HTTP client error with 4xx status code
*/
class ClientResponseException extends Exception implements ElasticsearchException
{
use ResponseTrait;
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Exception;
use Exception;
class ConfigException extends Exception implements ElasticsearchException
{
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Exception;
use Exception;
class ContentTypeException extends Exception implements ElasticsearchException
{
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Exception;
use Throwable;
interface ElasticsearchException extends Throwable
{
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Exception;
use Exception;
class HttpClientException extends Exception implements ElasticsearchException
{
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Exception;
use InvalidArgumentException as InvalidArgument;
class InvalidArgumentException extends InvalidArgument implements ElasticsearchException
{
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Exception;
use Exception;
class MissingParameterException extends Exception implements ElasticsearchException
{
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Exception;
use RuntimeException;
class ProductCheckException extends RuntimeException implements ElasticsearchException
{
}

View File

@ -0,0 +1,26 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Exception;
use Elastic\Elasticsearch\Traits\ResponseTrait;
use Exception;
/**
* HTTP server error with 5xx status code
*/
class ServerResponseException extends Exception implements ElasticsearchException
{
use ResponseTrait;
}

19
Elastic/Elasticsearch/LICENSE Executable file
View File

@ -0,0 +1,19 @@
Copyright 2022 Elasticsearch B.V (https://www.elastic.co)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,225 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Response;
use ArrayAccess;
use Elastic\Elasticsearch\Exception\ArrayAccessException;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Traits\MessageResponseTrait;
use Elastic\Elasticsearch\Traits\ProductCheckTrait;
use Elastic\Transport\Exception\UnknownContentTypeException;
use Elastic\Transport\Serializer\CsvSerializer;
use Elastic\Transport\Serializer\JsonSerializer;
use Elastic\Transport\Serializer\NDJsonSerializer;
use Elastic\Transport\Serializer\XmlSerializer;
use Psr\Http\Message\ResponseInterface;
/**
* Wraps a PSR-7 ResponseInterface offering helpers to deserialize the body response
*/
class Elasticsearch implements ElasticsearchInterface, ResponseInterface, ArrayAccess
{
const HEADER_CHECK = 'X-Elastic-Product';
const PRODUCT_NAME = 'Elasticsearch';
use ProductCheckTrait;
use MessageResponseTrait;
protected array $asArray;
protected object $asObject;
protected string $asString;
/**
* The PSR-7 response
*/
protected ResponseInterface $response;
/**
* Enable or disable the response Exception
*/
protected bool $responseException;
/**
* @throws ClientResponseException if status code 4xx
* @throws ServerResponseException if status code 5xx
*/
public function setResponse(ResponseInterface $response, bool $throwException = true): void
{
$this->productCheck($response);
$this->response = $response;
$status = $response->getStatusCode();
if ($throwException && $status > 399 && $status < 500) {
$error = new ClientResponseException(
sprintf("%s %s: %s", $status, $response->getReasonPhrase(), (string) $response->getBody()),
$status
);
throw $error->setResponse($response);
} elseif ($throwException && $status > 499 && $status < 600) {
$error = new ServerResponseException(
sprintf("%s %s: %s", $status, $response->getReasonPhrase(), (string) $response->getBody()),
$status
);
throw $error->setResponse($response);
}
}
/**
* Return true if status code is 2xx
*/
public function asBool(): bool
{
return $this->response->getStatusCode() >=200 && $this->response->getStatusCode() < 300;
}
/**
* Converts the body content to array, if possible.
* Otherwise, it throws an UnknownContentTypeException
* if Content-Type is not specified or unknown.
*
* @throws UnknownContentTypeException
*/
public function asArray(): array
{
if (isset($this->asArray)) {
return $this->asArray;
}
if (!$this->response->hasHeader('Content-Type')) {
throw new UnknownContentTypeException('No Content-Type specified in the response');
}
$contentType = $this->response->getHeaderLine('Content-Type');
if (strpos($contentType, 'application/json') !== false ||
strpos($contentType, 'application/vnd.elasticsearch+json') !== false) {
$this->asArray = JsonSerializer::unserialize($this->asString());
return $this->asArray;
}
if (strpos($contentType, 'application/x-ndjson') !== false ||
strpos($contentType, 'application/vnd.elasticsearch+x-ndjson') !== false) {
$this->asArray = NDJsonSerializer::unserialize($this->asString());
return $this->asArray;
}
if (strpos($contentType, 'text/csv') !== false) {
$this->asArray = CsvSerializer::unserialize($this->asString());
return $this->asArray;
}
throw new UnknownContentTypeException(sprintf(
"Cannot deserialize the reponse as array with Content-Type: %s",
$contentType
));
}
/**
* Converts the body content to object, if possible.
* Otherwise, it throws an UnknownContentTypeException
* if Content-Type is not specified or unknown.
*
* @throws UnknownContentTypeException
*/
public function asObject(): object
{
if (isset($this->asObject)) {
return $this->asObject;
}
$contentType = $this->response->getHeaderLine('Content-Type');
if (strpos($contentType, 'application/json') !== false ||
strpos($contentType, 'application/vnd.elasticsearch+json') !== false) {
$this->asObject = JsonSerializer::unserialize($this->asString(), ['type' => 'object']);
return $this->asObject;
}
if (strpos($contentType, 'application/x-ndjson') !== false ||
strpos($contentType, 'application/vnd.elasticsearch+x-ndjson') !== false) {
$this->asObject = NDJsonSerializer::unserialize($this->asString(), ['type' => 'object']);
return $this->asObject;
}
if (strpos($contentType, 'text/xml') !== false || strpos($contentType, 'application/xml') !== false) {
$this->asObject = XmlSerializer::unserialize($this->asString());
return $this->asObject;
}
throw new UnknownContentTypeException(sprintf(
"Cannot deserialize the reponse as object with Content-Type: %s",
$contentType
));
}
/**
* Converts the body content to string
*/
public function asString(): string
{
if (empty($this->asString)) {
$this->asString = (string) $this->response->getBody();
}
return $this->asString;
}
/**
* Converts the body content to string
*/
public function __toString(): string
{
return $this->asString();
}
/**
* Access the body content as object properties
*
* @see https://www.php.net/manual/en/language.oop5.overloading.php#object.get
*/
public function __get($name)
{
return $this->asObject()->$name ?? null;
}
/**
* ArrayAccess interface
*
* @see https://www.php.net/manual/en/class.arrayaccess.php
*/
public function offsetExists($offset): bool
{
return isset($this->asArray()[$offset]);
}
/**
* ArrayAccess interface
*
* @see https://www.php.net/manual/en/class.arrayaccess.php
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->asArray()[$offset];
}
/**
* ArrayAccess interface
*
* @see https://www.php.net/manual/en/class.arrayaccess.php
*/
public function offsetSet($offset, $value): void
{
throw new ArrayAccessException('The array is reading only');
}
/**
* ArrayAccess interface
*
* @see https://www.php.net/manual/en/class.arrayaccess.php
*/
public function offsetUnset($offset): void
{
throw new ArrayAccessException('The array is reading only');
}
}

View File

@ -0,0 +1,25 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Response;
use Psr\Http\Message\ResponseInterface;
interface ElasticsearchInterface
{
/**
* Set the HTTP PSR-7 response
*/
public function setResponse(ResponseInterface $response, bool $throwException = true): void;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,196 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Traits;
use Elastic\Elasticsearch\Client;
use Elastic\Elasticsearch\Exception\ContentTypeException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Transport\Serializer\JsonSerializer;
use Elastic\Transport\Serializer\NDJsonSerializer;
use Http\Discovery\Psr17FactoryDiscovery;
use Psr\Http\Message\RequestInterface;
use function http_build_query;
use function strpos;
use function sprintf;
trait EndpointTrait
{
/**
* Check if an array containts nested array
*/
private function isNestedArray(array $a): bool
{
foreach ($a as $v) {
if (is_array($v)) {
return true;
}
}
return false;
}
/**
* Check if an array is associative, i.e. has a string as key
*/
protected function isAssociativeArray(array $array): bool
{
foreach ($array as $k => $v) {
if (is_string($k)) {
return true;
}
}
return false;
}
/**
* Converts array to comma-separated list;
* Converts boolean value to true', 'false' string
*
* @param mixed $value
*/
private function convertValue($value): string
{
// Convert a boolean value in 'true' or 'false' string
if (is_bool($value)) {
return $value ? 'true' : 'false';
// Convert to comma-separated list if array
} elseif (is_array($value) && $this->isNestedArray($value) === false) {
return implode(',', $value);
}
return (string) $value;
}
/**
* Encode a value for a valid URL
*
* @param mixed $value
*/
protected function encode($value): string
{
return urlencode($this->convertValue($value));
}
/**
* Returns the URL with the query string from $params
* extracting the array keys specified in $keys
*/
protected function addQueryString(string $url, array $params, array $keys): string
{
$queryParams = [];
foreach ($keys as $k) {
if (isset($params[$k])) {
$queryParams[$k] = $this->convertValue($params[$k]);
}
}
if (empty($queryParams)) {
return $url;
}
return $url . '?' . http_build_query($queryParams);
}
/**
* Serialize the body using the Content-Type
*
* @param mixed $body
*/
protected function bodySerialize($body, string $contentType): string
{
if (strpos($contentType, 'application/x-ndjson') !== false ||
strpos($contentType, 'application/vnd.elasticsearch+x-ndjson') !== false) {
return NDJsonSerializer::serialize($body, ['remove_null' => false]);
}
if (strpos($contentType, 'application/json') !== false ||
strpos($contentType, 'application/vnd.elasticsearch+json') !== false) {
return JsonSerializer::serialize($body, ['remove_null' => false]);
}
throw new ContentTypeException(sprintf(
"The Content-Type %s is not managed by Elasticsearch serializer",
$contentType
));
}
/**
* Create a PSR-7 request
*
* @param array|string $body
*/
protected function createRequest(string $method, string $url, array $headers, $body = null): RequestInterface
{
$requestFactory = Psr17FactoryDiscovery::findRequestFactory();
$streamFactory = Psr17FactoryDiscovery::findStreamFactory();
$request = $requestFactory->createRequest($method, $url);
// Body request
if (!empty($body)) {
if (!isset($headers['Content-Type'])) {
throw new ContentTypeException(sprintf(
"The Content-Type is missing for %s %s",
$method,
$url
));
}
$content = is_string($body) ? $body : $this->bodySerialize($body, $headers['Content-Type']);
$request = $request->withBody($streamFactory->createStream($content));
}
$headers = $this->buildCompatibilityHeaders($headers);
// Headers
foreach ($headers as $name => $value) {
$request = $request->withHeader($name, $value);
}
return $request;
}
/**
* Build the API compatibility headers
* transfrom Content-Type and Accept adding vnd.elasticsearch+ and compatible-with
*
* @see https://github.com/elastic/elasticsearch-php/pull/1142
*/
protected function buildCompatibilityHeaders(array $headers): array
{
if (isset($headers['Content-Type'])) {
if (preg_match('/application\/([^,]+)$/', $headers['Content-Type'], $matches)) {
$headers['Content-Type'] = sprintf(Client::API_COMPATIBILITY_HEADER, 'application', $matches[1]);
}
}
if (isset($headers['Accept'])) {
$values = explode(',', $headers['Accept']);
foreach ($values as &$value) {
if (preg_match('/(application|text)\/([^,]+)/', $value, $matches)) {
$value = sprintf(Client::API_COMPATIBILITY_HEADER, $matches[1], $matches[2]);
}
}
$headers['Accept'] = implode(',', $values);
}
return $headers;
}
/**
* Check if the $required parameters are present in $params
* @throws MissingParameterException
*/
protected function checkRequiredParameters(array $required, array $params): void
{
foreach ($required as $req) {
if (!isset($params[$req])) {
throw new MissingParameterException(sprintf(
'The parameter %s is required',
$req
));
}
}
}
}

View File

@ -0,0 +1,94 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Traits;
use Psr\Http\Message\StreamInterface;
/**
* Proxy class for Psr\Http\Message\ResponseInterface using
* $this->response as source object
*/
trait MessageResponseTrait
{
public function getProtocolVersion()
{
return $this->response->getProtocolVersion();
}
public function withProtocolVersion($version)
{
return $this->response->withProtocolVersion($version);
}
public function getHeaders()
{
return $this->response->getHeaders();
}
public function hasHeader($name)
{
return $this->response->hasHeader($name);
}
public function getHeader($name)
{
return $this->response->getHeader($name);
}
public function getHeaderLine($name)
{
return $this->response->getHeaderLine($name);
}
public function withHeader($name, $value)
{
return $this->response->withHeader($name, $value);
}
public function withAddedHeader($name, $value)
{
return $this->response->withAddedHeader($name, $value);
}
public function withoutHeader($name)
{
return $this->response->withoutHeader($name);
}
public function getBody()
{
return $this->response->getBody();
}
public function withBody(StreamInterface $body)
{
return $this->response->withBody($body);
}
public function getStatusCode()
{
return $this->response->getStatusCode();
}
public function withStatus($code, $reasonPhrase = '')
{
return $this->response->withStatus($code, $reasonPhrase);
}
public function getReasonPhrase()
{
return $this->response->getReasonPhrase();
}
}

View File

@ -0,0 +1,357 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Traits;
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;
/**
* @generated This file is generated, please do not edit
*/
trait NamespaceTrait
{
/** The endpoint namespace storage */
protected array $namespace;
public function asyncSearch(): AsyncSearch
{
if (!isset($this->namespace['AsyncSearch'])) {
$this->namespace['AsyncSearch'] = new AsyncSearch($this);
}
return $this->namespace['AsyncSearch'];
}
public function autoscaling(): Autoscaling
{
if (!isset($this->namespace['Autoscaling'])) {
$this->namespace['Autoscaling'] = new Autoscaling($this);
}
return $this->namespace['Autoscaling'];
}
public function cat(): Cat
{
if (!isset($this->namespace['Cat'])) {
$this->namespace['Cat'] = new Cat($this);
}
return $this->namespace['Cat'];
}
public function ccr(): Ccr
{
if (!isset($this->namespace['Ccr'])) {
$this->namespace['Ccr'] = new Ccr($this);
}
return $this->namespace['Ccr'];
}
public function cluster(): Cluster
{
if (!isset($this->namespace['Cluster'])) {
$this->namespace['Cluster'] = new Cluster($this);
}
return $this->namespace['Cluster'];
}
public function danglingIndices(): DanglingIndices
{
if (!isset($this->namespace['DanglingIndices'])) {
$this->namespace['DanglingIndices'] = new DanglingIndices($this);
}
return $this->namespace['DanglingIndices'];
}
public function enrich(): Enrich
{
if (!isset($this->namespace['Enrich'])) {
$this->namespace['Enrich'] = new Enrich($this);
}
return $this->namespace['Enrich'];
}
public function eql(): Eql
{
if (!isset($this->namespace['Eql'])) {
$this->namespace['Eql'] = new Eql($this);
}
return $this->namespace['Eql'];
}
public function features(): Features
{
if (!isset($this->namespace['Features'])) {
$this->namespace['Features'] = new Features($this);
}
return $this->namespace['Features'];
}
public function fleet(): Fleet
{
if (!isset($this->namespace['Fleet'])) {
$this->namespace['Fleet'] = new Fleet($this);
}
return $this->namespace['Fleet'];
}
public function graph(): Graph
{
if (!isset($this->namespace['Graph'])) {
$this->namespace['Graph'] = new Graph($this);
}
return $this->namespace['Graph'];
}
public function ilm(): Ilm
{
if (!isset($this->namespace['Ilm'])) {
$this->namespace['Ilm'] = new Ilm($this);
}
return $this->namespace['Ilm'];
}
public function indices(): Indices
{
if (!isset($this->namespace['Indices'])) {
$this->namespace['Indices'] = new Indices($this);
}
return $this->namespace['Indices'];
}
public function ingest(): Ingest
{
if (!isset($this->namespace['Ingest'])) {
$this->namespace['Ingest'] = new Ingest($this);
}
return $this->namespace['Ingest'];
}
public function license(): License
{
if (!isset($this->namespace['License'])) {
$this->namespace['License'] = new License($this);
}
return $this->namespace['License'];
}
public function logstash(): Logstash
{
if (!isset($this->namespace['Logstash'])) {
$this->namespace['Logstash'] = new Logstash($this);
}
return $this->namespace['Logstash'];
}
public function migration(): Migration
{
if (!isset($this->namespace['Migration'])) {
$this->namespace['Migration'] = new Migration($this);
}
return $this->namespace['Migration'];
}
public function ml(): Ml
{
if (!isset($this->namespace['Ml'])) {
$this->namespace['Ml'] = new Ml($this);
}
return $this->namespace['Ml'];
}
public function monitoring(): Monitoring
{
if (!isset($this->namespace['Monitoring'])) {
$this->namespace['Monitoring'] = new Monitoring($this);
}
return $this->namespace['Monitoring'];
}
public function nodes(): Nodes
{
if (!isset($this->namespace['Nodes'])) {
$this->namespace['Nodes'] = new Nodes($this);
}
return $this->namespace['Nodes'];
}
public function rollup(): Rollup
{
if (!isset($this->namespace['Rollup'])) {
$this->namespace['Rollup'] = new Rollup($this);
}
return $this->namespace['Rollup'];
}
public function searchableSnapshots(): SearchableSnapshots
{
if (!isset($this->namespace['SearchableSnapshots'])) {
$this->namespace['SearchableSnapshots'] = new SearchableSnapshots($this);
}
return $this->namespace['SearchableSnapshots'];
}
public function security(): Security
{
if (!isset($this->namespace['Security'])) {
$this->namespace['Security'] = new Security($this);
}
return $this->namespace['Security'];
}
public function shutdown(): Shutdown
{
if (!isset($this->namespace['Shutdown'])) {
$this->namespace['Shutdown'] = new Shutdown($this);
}
return $this->namespace['Shutdown'];
}
public function slm(): Slm
{
if (!isset($this->namespace['Slm'])) {
$this->namespace['Slm'] = new Slm($this);
}
return $this->namespace['Slm'];
}
public function snapshot(): Snapshot
{
if (!isset($this->namespace['Snapshot'])) {
$this->namespace['Snapshot'] = new Snapshot($this);
}
return $this->namespace['Snapshot'];
}
public function sql(): Sql
{
if (!isset($this->namespace['Sql'])) {
$this->namespace['Sql'] = new Sql($this);
}
return $this->namespace['Sql'];
}
public function ssl(): Ssl
{
if (!isset($this->namespace['Ssl'])) {
$this->namespace['Ssl'] = new Ssl($this);
}
return $this->namespace['Ssl'];
}
public function tasks(): Tasks
{
if (!isset($this->namespace['Tasks'])) {
$this->namespace['Tasks'] = new Tasks($this);
}
return $this->namespace['Tasks'];
}
public function textStructure(): TextStructure
{
if (!isset($this->namespace['TextStructure'])) {
$this->namespace['TextStructure'] = new TextStructure($this);
}
return $this->namespace['TextStructure'];
}
public function transform(): Transform
{
if (!isset($this->namespace['Transform'])) {
$this->namespace['Transform'] = new Transform($this);
}
return $this->namespace['Transform'];
}
public function watcher(): Watcher
{
if (!isset($this->namespace['Watcher'])) {
$this->namespace['Watcher'] = new Watcher($this);
}
return $this->namespace['Watcher'];
}
public function xpack(): Xpack
{
if (!isset($this->namespace['Xpack'])) {
$this->namespace['Xpack'] = new Xpack($this);
}
return $this->namespace['Xpack'];
}
}

View File

@ -0,0 +1,38 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Traits;
use Elastic\Elasticsearch\Exception\ProductCheckException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Psr\Http\Message\ResponseInterface;
trait ProductCheckTrait
{
/**
* Check if the response comes from Elasticsearch server
*/
private function productCheck(ResponseInterface $response): void
{
$statusCode = (int) $response->getStatusCode();
if ($statusCode >= 200 && $statusCode < 300) {
$product = $response->getHeaderLine(Elasticsearch::HEADER_CHECK);
if (empty($product) || $product !== Elasticsearch::PRODUCT_NAME) {
throw new ProductCheckException(
'The client noticed that the server is not Elasticsearch and we do not support this unknown product'
);
}
}
}
}

View File

@ -0,0 +1,33 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Traits;
use Psr\Http\Message\ResponseInterface;
trait ResponseTrait
{
protected ResponseInterface $response;
public function setResponse(ResponseInterface $response): self
{
$this->response = $response;
return $this;
}
public function getResponse(): ResponseInterface
{
return $this->response;
}
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Transport\Adapter;
use Psr\Http\Client\ClientInterface;
interface AdapterInterface
{
public function setConfig(ClientInterface $client, array $config, array $clientOptions): ClientInterface;
}

View File

@ -0,0 +1,27 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Transport\Adapter;
/**
* The HTTP client adapters supported
*/
final class AdapterOptions
{
const HTTP_ADAPTERS = [
"GuzzleHttp\\Client" => "Elastic\\Elasticsearch\\Transport\\Adapter\\Guzzle",
"Symfony\\Component\\HttpClient\\HttplugClient" => "Elastic\\Elasticsearch\\Transport\\Adapter\\Symfony",
"Symfony\\Component\\HttpClient\\Psr18Client" => "Elastic\\Elasticsearch\\Transport\\Adapter\\Symfony"
];
}

View File

@ -0,0 +1,44 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Transport\Adapter;
use Elastic\Elasticsearch\Transport\RequestOptions;
use GuzzleHttp\RequestOptions As GuzzleOptions;
use Psr\Http\Client\ClientInterface;
class Guzzle implements AdapterInterface
{
public function setConfig(ClientInterface $client, array $config, array $clientOptions): ClientInterface
{
$guzzleConfig = [];
foreach ($config as $key => $value) {
switch ($key) {
case RequestOptions::SSL_CERT:
$guzzleConfig[GuzzleOptions::CERT] = $value;
break;
case RequestOptions::SSL_KEY:
$guzzleConfig[GuzzleOptions::SSL_KEY] = $value;
break;
case RequestOptions::SSL_VERIFY:
$guzzleConfig[GuzzleOptions::VERIFY] = $value;
break;
case RequestOptions::SSL_CA:
$guzzleConfig[GuzzleOptions::VERIFY] = $value;
}
}
$class = get_class($client);
return new $class(array_merge($clientOptions, $guzzleConfig));
}
}

View File

@ -0,0 +1,46 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Transport\Adapter;
use Elastic\Elasticsearch\Transport\RequestOptions;
use Psr\Http\Client\ClientInterface;
use Symfony\Component\HttpClient\HttpClient;
class Symfony implements AdapterInterface
{
public function setConfig(ClientInterface $client, array $config, array $clientOptions): ClientInterface
{
$symfonyConfig = [];
foreach ($config as $key => $value) {
switch ($key) {
case RequestOptions::SSL_CERT:
$symfonyConfig['local_cert'] = $value;
break;
case RequestOptions::SSL_KEY:
$symfonyConfig['local_pk'] = $value;
break;
case RequestOptions::SSL_VERIFY:
$symfonyConfig['verify_host'] = $value;
$symfonyConfig['verify_peer'] = $value;
break;
case RequestOptions::SSL_CA:
$symfonyConfig['cafile'] = $value;
}
}
$class = get_class($client);
$httpClient = HttpClient::create(array_merge($clientOptions, $symfonyConfig));
return new $class($httpClient);
}
}

View File

@ -0,0 +1,29 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Transport;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Async\OnSuccessInterface;
use Psr\Http\Message\ResponseInterface;
class AsyncOnSuccess implements OnSuccessInterface
{
public function success(ResponseInterface $response, int $count): Elasticsearch
{
$result = new Elasticsearch;
$result->setResponse($response, true);
return $result;
}
}

View File

@ -0,0 +1,29 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Transport;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Async\OnSuccessInterface;
use Psr\Http\Message\ResponseInterface;
class AsyncOnSuccessNoException implements OnSuccessInterface
{
public function success(ResponseInterface $response, int $count): Elasticsearch
{
$result = new Elasticsearch;
$result->setResponse($response, false);
return $result;
}
}

View File

@ -0,0 +1,38 @@
<?php
/**
* Elasticsearch PHP Client
*
* @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\Transport;
final class RequestOptions
{
/**
* Enable or sidable the SSL verification
*/
public const SSL_VERIFY = 'ssl_verify';
/**
* SSL certificate
*/
public const SSL_CERT = 'ssl_cert';
/**
* SSL key
*/
public const SSL_KEY = 'ssl_key';
/**
* SSL Certificate Authority (CA) bundle
*/
public const SSL_CA = 'ssl_ca';
}

View File

@ -0,0 +1,26 @@
<?php
/**
* Elastic Transport
*
* @link https://github.com/elastic/elastic-transport-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\Transport\Async;
use Elastic\Transport\NodePool\Node;
use Exception;
use Psr\Http\Message\RequestInterface;
class OnFailureDefault implements OnFailureInterface
{
public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null): void
{
}
}

View File

@ -0,0 +1,24 @@
<?php
/**
* Elastic Transport
*
* @link https://github.com/elastic/elastic-transport-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\Transport\Async;
use Elastic\Transport\NodePool\Node;
use Exception;
use Psr\Http\Message\RequestInterface;
interface OnFailureInterface
{
public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null): void;
}

View File

@ -0,0 +1,25 @@
<?php
/**
* Elastic Transport
*
* @link https://github.com/elastic/elastic-transport-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\Transport\Async;
use Psr\Http\Message\ResponseInterface;
class OnSuccessDefault implements OnSuccessInterface
{
public function success(ResponseInterface $response, int $count)
{
return $response;
}
}

View File

@ -0,0 +1,25 @@
<?php
/**
* Elastic Transport
*
* @link https://github.com/elastic/elastic-transport-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\Transport\Async;
use Psr\Http\Message\ResponseInterface;
interface OnSuccessInterface
{
/**
* @return mixed
*/
public function success(ResponseInterface $request, int $count);
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Elastic Transport
*
* @link https://github.com/elastic/elastic-transport-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\Transport\Exception;
use RuntimeException;
class CloudIdParseException extends RuntimeException implements TransportException
{
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Elastic Transport
*
* @link https://github.com/elastic/elastic-transport-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\Transport\Exception;
use RuntimeException;
class InvalidArgumentException extends RuntimeException implements TransportException
{
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Elastic Transport
*
* @link https://github.com/elastic/elastic-transport-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\Transport\Exception;
use RuntimeException;
class InvalidArrayException extends RuntimeException implements TransportException
{
}

Some files were not shown because too many files have changed in this diff Show More