Skip to content

Commit

Permalink
Updated opensearch-php to reflect the latest OpenSearch API spec (202…
Browse files Browse the repository at this point in the history
…4-09-10)

Signed-off-by: GitHub <noreply@github.com>
  • Loading branch information
dblock committed Sep 10, 2024
1 parent 1866e6e commit 24b4a69
Show file tree
Hide file tree
Showing 27 changed files with 1,115 additions and 94 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed
- Fixed upcomming PHP 8.4 deprecations
### Updated APIs
- Updated opensearch-php APIs to reflect [opensearch-api-specification@3dcced9](https://github.com/opensearch-project/opensearch-api-specification/commit/3dcced99f99f8374f0b0f56eaf9ccd813c31f796)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@cb320b5](https://github.com/opensearch-project/opensearch-api-specification/commit/cb320b5482551c4f28afa26ff0d1653332699722)
### Security
### Dependencies
Expand Down
50 changes: 39 additions & 11 deletions src/OpenSearch/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
use OpenSearch\Namespaces\NamespaceBuilderInterface;
use OpenSearch\Namespaces\BooleanRequestWrapper;
use OpenSearch\Namespaces\AsyncSearchNamespace;
use OpenSearch\Namespaces\AsynchronousSearchNamespace;
use OpenSearch\Namespaces\CatNamespace;
use OpenSearch\Namespaces\ClusterNamespace;
use OpenSearch\Namespaces\DanglingIndicesNamespace;
use OpenSearch\Namespaces\DataFrameTransformDeprecatedNamespace;
use OpenSearch\Namespaces\FlowFrameworkNamespace;
use OpenSearch\Namespaces\IndicesNamespace;
use OpenSearch\Namespaces\IngestNamespace;
use OpenSearch\Namespaces\KnnNamespace;
Expand Down Expand Up @@ -86,6 +88,11 @@ class Client
*/
protected $asyncSearch;

/**
* @var AsynchronousSearchNamespace
*/
protected $asynchronousSearch;

/**
* @var CatNamespace
*/
Expand All @@ -106,6 +113,11 @@ class Client
*/
protected $dataFrameTransformDeprecated;

/**
* @var FlowFrameworkNamespace
*/
protected $flowFramework;

/**
* @var IndicesNamespace
*/
Expand Down Expand Up @@ -219,10 +231,12 @@ public function __construct(Transport $transport, callable $endpoint, array $reg
$this->transport = $transport;
$this->endpoints = $endpoint;
$this->asyncSearch = new AsyncSearchNamespace($transport, $endpoint);
$this->asynchronousSearch = new AsynchronousSearchNamespace($transport, $endpoint);
$this->cat = new CatNamespace($transport, $endpoint);
$this->cluster = new ClusterNamespace($transport, $endpoint);
$this->danglingIndices = new DanglingIndicesNamespace($transport, $endpoint);
$this->dataFrameTransformDeprecated = new DataFrameTransformDeprecatedNamespace($transport, $endpoint);
$this->flowFramework = new FlowFrameworkNamespace($transport, $endpoint);
$this->indices = new IndicesNamespace($transport, $endpoint);
$this->ingest = new IngestNamespace($transport, $endpoint);
$this->knn = new KnnNamespace($transport, $endpoint);
Expand Down Expand Up @@ -386,11 +400,11 @@ public function createPit(array $params = [])
* $params['id'] = (string) Unique identifier for the document. (Required)
* $params['index'] = (string) Name of the target index. (Required)
* $params['if_primary_term'] = (number) Only perform the operation if the document has this primary term.
* $params['if_seq_no'] = (number) Only perform the operation if the document has this sequence number.
* $params['if_seq_no'] = (integer) Only perform the operation if the document has this sequence number.
* $params['refresh'] = (enum) If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes.Valid values: `true`, `false`, `wait_for`. (Options = false,true,wait_for)
* $params['routing'] = (string) Custom value used to route operations to a specific shard.
* $params['timeout'] = (string) Period to wait for active shards.
* $params['version'] = (number) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed.
* $params['version'] = (integer) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed.
* $params['version_type'] = (enum) Specific version type: `external`, `external_gte`. (Options = external,external_gte,force,internal)
* $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operation.Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response.
Expand Down Expand Up @@ -584,7 +598,7 @@ public function deleteScript(array $params = [])
* $params['refresh'] = (boolean) If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes.
* $params['routing'] = (string) Target the specified primary shard.
* $params['stored_fields'] = (any) List of stored fields to return as part of a hit.If no fields are specified, no stored fields are included in the response.If this field is specified, the `_source` parameter defaults to false.
* $params['version'] = (number) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed.
* $params['version'] = (integer) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed.
* $params['version_type'] = (enum) Specific version type: `external`, `external_gte`. (Options = external,external_gte,force,internal)
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response.
* $params['human'] = (boolean) Whether to return human readable values for statistics.
Expand Down Expand Up @@ -623,7 +637,7 @@ public function exists(array $params = []): bool
* $params['realtime'] = (boolean) If true, the request is real-time as opposed to near-real-time.
* $params['refresh'] = (boolean) If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes.
* $params['routing'] = (string) Target the specified primary shard.
* $params['version'] = (number) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed.
* $params['version'] = (integer) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed.
* $params['version_type'] = (enum) Specific version type: `external`, `external_gte`. (Options = external,external_gte,force,internal)
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response.
* $params['human'] = (boolean) Whether to return human readable values for statistics.
Expand Down Expand Up @@ -737,7 +751,7 @@ public function fieldCaps(array $params = [])
* $params['refresh'] = (boolean) If true, OpenSearch refreshes the affected shards to make this operation visible to search. If false, do nothing with refreshes.
* $params['routing'] = (string) Target the specified primary shard.
* $params['stored_fields'] = (any) List of stored fields to return as part of a hit.If no fields are specified, no stored fields are included in the response.If this field is specified, the `_source` parameter defaults to false.
* $params['version'] = (number) Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.
* $params['version'] = (integer) Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.
* $params['version_type'] = (enum) Specific version type: internal, external, external_gte. (Options = external,external_gte,force,internal)
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response.
* $params['human'] = (boolean) Whether to return human readable values for statistics.
Expand Down Expand Up @@ -859,7 +873,7 @@ public function getScriptLanguages(array $params = [])
* $params['realtime'] = (boolean) Boolean) If true, the request is real-time as opposed to near-real-time.
* $params['refresh'] = (boolean) If true, OpenSearch refreshes the affected shards to make this operation visible to search. If false, do nothing with refreshes.
* $params['routing'] = (string) Target the specified primary shard.
* $params['version'] = (number) Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.
* $params['version'] = (integer) Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.
* $params['version_type'] = (enum) Specific version type: internal, external, external_gte. (Options = external,external_gte,force,internal)
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response.
* $params['human'] = (boolean) Whether to return human readable values for statistics.
Expand Down Expand Up @@ -889,14 +903,14 @@ public function getSource(array $params = [])
* $params['index'] = (string) Name of the data stream or index to target. (Required)
* $params['id'] = (string) Unique identifier for the document.
* $params['if_primary_term'] = (number) Only perform the operation if the document has this primary term.
* $params['if_seq_no'] = (number) Only perform the operation if the document has this sequence number.
* $params['if_seq_no'] = (integer) Only perform the operation if the document has this sequence number.
* $params['op_type'] = (enum) Set to create to only index the document if it does not already exist (put if absent).If a document with the specified `_id` already exists, the indexing operation will fail.Same as using the `<index>/_create` endpoint.Valid values: `index`, `create`.If document id is specified, it defaults to `index`.Otherwise, it defaults to `create`. (Options = create,index)
* $params['pipeline'] = (string) ID of the pipeline to use to preprocess incoming documents.If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request.If a final pipeline is configured it will always run, regardless of the value of this parameter.
* $params['refresh'] = (enum) If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes.Valid values: `true`, `false`, `wait_for`. (Options = false,true,wait_for)
* $params['require_alias'] = (boolean) If `true`, the destination must be an index alias. (Default = false)
* $params['routing'] = (string) Custom value used to route operations to a specific shard.
* $params['timeout'] = (string) Period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards.
* $params['version'] = (number) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed.
* $params['version'] = (integer) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed.
* $params['version_type'] = (enum) Specific version type: `external`, `external_gte`. (Options = external,external_gte,force,internal)
* $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operation.Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response.
Expand Down Expand Up @@ -1059,7 +1073,7 @@ public function msearchTemplate(array $params = [])
* $params['realtime'] = (boolean) If true, the request is real-time as opposed to near-real-time. (Default = true)
* $params['routing'] = (string) Custom value used to route operations to a specific shard.
* $params['term_statistics'] = (boolean) If true, the response includes term frequency and document frequency. (Default = false)
* $params['version'] = (number) If `true`, returns the document version as part of a hit.
* $params['version'] = (integer) If `true`, returns the document version as part of a hit.
* $params['version_type'] = (enum) Specific version type. (Options = external,external_gte,force,internal)
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response.
* $params['human'] = (boolean) Whether to return human readable values for statistics.
Expand Down Expand Up @@ -1465,7 +1479,7 @@ public function searchTemplate(array $params = [])
* $params['realtime'] = (boolean) If true, the request is real-time as opposed to near-real-time. (Default = true)
* $params['routing'] = (string) Custom value used to route operations to a specific shard.
* $params['term_statistics'] = (boolean) If `true`, the response includes term frequency and document frequency. (Default = false)
* $params['version'] = (number) If `true`, returns the document version as part of a hit.
* $params['version'] = (integer) If `true`, returns the document version as part of a hit.
* $params['version_type'] = (enum) Specific version type. (Options = external,external_gte,force,internal)
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response.
* $params['human'] = (boolean) Whether to return human readable values for statistics.
Expand Down Expand Up @@ -1501,7 +1515,7 @@ public function termvectors(array $params = [])
* $params['_source_excludes'] = (any) Specify the source fields you want to exclude.
* $params['_source_includes'] = (any) Specify the source fields you want to retrieve.
* $params['if_primary_term'] = (number) Only perform the operation if the document has this primary term.
* $params['if_seq_no'] = (number) Only perform the operation if the document has this sequence number.
* $params['if_seq_no'] = (integer) Only perform the operation if the document has this sequence number.
* $params['lang'] = (string) The script language. (Default = painless)
* $params['refresh'] = (enum) If 'true', OpenSearch refreshes the affected shards to make this operationvisible to search, if 'wait_for' then wait for a refresh to make this operationvisible to search, if 'false' do nothing with refreshes. (Options = false,true,wait_for)
* $params['require_alias'] = (boolean) If true, the destination must be an index alias. (Default = false)
Expand Down Expand Up @@ -1680,6 +1694,13 @@ public function asyncSearch(): AsyncSearchNamespace
{
return $this->asyncSearch;
}
/**
* Returns the asynchronousSearch namespace
*/
public function asynchronousSearch(): AsynchronousSearchNamespace
{
return $this->asynchronousSearch;
}
/**
* Returns the cat namespace
*/
Expand Down Expand Up @@ -1708,6 +1729,13 @@ public function dataFrameTransformDeprecated(): DataFrameTransformDeprecatedName
{
return $this->dataFrameTransformDeprecated;
}
/**
* Returns the flowFramework namespace
*/
public function flowFramework(): FlowFrameworkNamespace
{
return $this->flowFramework;
}
/**
* Returns the indices namespace
*/
Expand Down
52 changes: 52 additions & 0 deletions src/OpenSearch/Endpoints/AsynchronousSearch/Delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

namespace OpenSearch\Endpoints\AsynchronousSearch;

use OpenSearch\Common\Exceptions\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Delete extends AbstractEndpoint
{
public function getURI(): string
{
if (isset($this->id) !== true) {
throw new RuntimeException(
'id is required for delete'
);
}
$id = $this->id;
return "/_plugins/_asynchronous_search/$id";
}

public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

public function getMethod(): string
{
return 'DELETE';
}
}
52 changes: 52 additions & 0 deletions src/OpenSearch/Endpoints/AsynchronousSearch/Get.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

namespace OpenSearch\Endpoints\AsynchronousSearch;

use OpenSearch\Common\Exceptions\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Get extends AbstractEndpoint
{
public function getURI(): string
{
if (isset($this->id) !== true) {
throw new RuntimeException(
'id is required for get'
);
}
$id = $this->id;
return "/_plugins/_asynchronous_search/$id";
}

public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

public function getMethod(): string
{
return 'GET';
}
}
59 changes: 59 additions & 0 deletions src/OpenSearch/Endpoints/AsynchronousSearch/Search.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

declare(strict_types=1);

/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

namespace OpenSearch\Endpoints\AsynchronousSearch;

use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class Search extends AbstractEndpoint
{
public function getURI(): string
{
return "/_plugins/_asynchronous_search";
}

public function getParamWhitelist(): array
{
return [
'index',
'keep_alive',
'keep_on_completion',
'wait_for_completion_timeout',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

public function getMethod(): string
{
return 'POST';
}

public function setBody($body): Search
{
if (isset($body) !== true) {
return $this;
}
$this->body = $body;

return $this;
}
}
Loading

0 comments on commit 24b4a69

Please sign in to comment.