Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support inclusive #65

Merged
merged 3 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/OpenSearch/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public function deleteByQueryRethrottle(array $params = [])
/**
* $params['id'] = (string) Script ID
* $params['timeout'] = (time) Explicit operation timeout
* $params['master_timeout'] = (time) Specify timeout for connection to master
* $params['cluster_manager_timeout'] = (time) Specify timeout for connection to cluster_manager
*
* @param array $params Associative array of parameters
* @return array
Expand Down Expand Up @@ -568,7 +568,7 @@ public function get(array $params = [])
}
/**
* $params['id'] = (string) Script ID
* $params['master_timeout'] = (time) Specify timeout for connection to master
* $params['cluster_manager_timeout'] = (time) Specify timeout for connection to cluster_manager
*
* @param array $params Associative array of parameters
* @return array
Expand Down Expand Up @@ -827,7 +827,7 @@ public function ping(array $params = []): bool
* $params['id'] = (string) Script ID (Required)
* $params['context'] = (string) Script context
* $params['timeout'] = (time) Explicit operation timeout
* $params['master_timeout'] = (time) Specify timeout for connection to master
* $params['cluster_manager_timeout'] = (time) Specify timeout for connection to cluster_manager
* $params['body'] = (array) The document (Required)
*
* @param array $params Associative array of parameters
Expand Down Expand Up @@ -1048,7 +1048,7 @@ public function search(array $params = [])
* $params['index'] = (list) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* $params['preference'] = (string) Specify the node or shard the operation should be performed on (default: random)
* $params['routing'] = (string) Specific routing value
* $params['local'] = (boolean) Return local information, do not retrieve the state from master node (default: false)
* $params['local'] = (boolean) Return local information, do not retrieve the state from cluster manager node (default: false)
* $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
* $params['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)
* $params['expand_wildcards'] = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both. (Options = open,closed,hidden,none,all) (Default = open)
Expand Down
37 changes: 37 additions & 0 deletions src/OpenSearch/Endpoints/AbstractEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public function setParams(array $params)
$params = $this->convertCustom($params);
$this->params = $this->convertArraysToStrings($params);

$this->checkForDeprecations();

return $this;
}

Expand Down Expand Up @@ -280,4 +282,39 @@ private function isNestedArray(array $a): bool

return false;
}

/**
* This function returns all param deprecations also optional with an replacement field
*
* @return array<string, string|null>
*/
protected function getParamDeprecation(): array
{
return [];
}

private function checkForDeprecations(): void
{
$deprecations = $this->getParamDeprecation();

if ($deprecations === []) {
return;
}

$keys = array_keys($this->params);

foreach ($keys as $key) {
shyim marked this conversation as resolved.
Show resolved Hide resolved
if (array_key_exists($key, $deprecations)) {
$val = $deprecations[$key];

$msg = sprintf('The parameter "%s" is deprecated and will be removed without replacement in the next major version', $key);

if ($val) {
$msg = sprintf('The parameter "%s" is deprecated and will be replaced with parameter "%s" in the next major version', $key, $val);
}

trigger_error($msg, E_USER_DEPRECATED);
}
}
}
}
8 changes: 7 additions & 1 deletion src/OpenSearch/Endpoints/Cat/Allocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public function getParamWhitelist(): array
'h',
'help',
's',
'v'
'v',
'cluster_manager_timeout'
];
}

Expand All @@ -68,4 +69,9 @@ public function setNodeId($node_id): Allocation

return $this;
}

protected function getParamDeprecation(): array
shyim marked this conversation as resolved.
Show resolved Hide resolved
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
50 changes: 50 additions & 0 deletions src/OpenSearch/Endpoints/Cat/ClusterManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

/**
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* Elasticsearch PHP client
*
* @link https://github.com/elastic/elasticsearch-php/
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
* the GNU Lesser General Public License, Version 2.1, at your option.
* See the LICENSE file in the project root for more information.
*/

namespace OpenSearch\Endpoints\Cat;

use OpenSearch\Endpoints\AbstractEndpoint;

class ClusterManager extends AbstractEndpoint
{
public function getURI(): string
{
return "/_cat/cluster_manager";
}

public function getParamWhitelist(): array
{
return [
'format',
'local',
'cluster_manager_timeout',
'h',
'help',
's',
'v'
];
}

public function getMethod(): string
{
return 'GET';
}
}
7 changes: 6 additions & 1 deletion src/OpenSearch/Endpoints/Cat/Indices.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,17 @@ public function getParamWhitelist(): array
'time',
'v',
'include_unloaded_segments',
'expand_wildcards'
'expand_wildcards',
'cluster_manager_timeout'
];
}

public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
10 changes: 9 additions & 1 deletion src/OpenSearch/Endpoints/Cat/Master.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

use OpenSearch\Endpoints\AbstractEndpoint;

/**
* @deprecated use \OpenSearch\Endpoints\Cat\ClusterManager instead
*/
class Master extends AbstractEndpoint
{
public function getURI(): string
Expand All @@ -39,12 +42,17 @@ public function getParamWhitelist(): array
'h',
'help',
's',
'v'
'v',
'cluster_manager_timeout'
];
}

public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
7 changes: 6 additions & 1 deletion src/OpenSearch/Endpoints/Cat/NodeAttrs.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ public function getParamWhitelist(): array
'h',
'help',
's',
'v'
'v',
'cluster_manager_timeout'
];
}

public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
7 changes: 6 additions & 1 deletion src/OpenSearch/Endpoints/Cat/Nodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ public function getParamWhitelist(): array
'help',
's',
'time',
'v'
'v',
'cluster_manager_timeout'
];
}

public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
7 changes: 6 additions & 1 deletion src/OpenSearch/Endpoints/Cat/PendingTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,17 @@ public function getParamWhitelist(): array
'help',
's',
'time',
'v'
'v',
'cluster_manager_timeout'
];
}

public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
7 changes: 6 additions & 1 deletion src/OpenSearch/Endpoints/Cat/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ public function getParamWhitelist(): array
'h',
'help',
's',
'v'
'v',
'cluster_manager_timeout'
];
}

public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
7 changes: 6 additions & 1 deletion src/OpenSearch/Endpoints/Cat/Repositories.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ public function getParamWhitelist(): array
'h',
'help',
's',
'v'
'v',
'cluster_manager_timeout'
];
}

public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
7 changes: 6 additions & 1 deletion src/OpenSearch/Endpoints/Cat/Shards.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ public function getParamWhitelist(): array
'help',
's',
'time',
'v'
'v',
'cluster_manager_timeout'
];
}

public function getMethod(): string
{
return 'GET';
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
7 changes: 6 additions & 1 deletion src/OpenSearch/Endpoints/Cat/Snapshots.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public function getParamWhitelist(): array
'help',
's',
'time',
'v'
'v',
'cluster_manager_timeout'
];
}

Expand All @@ -68,4 +69,8 @@ public function setRepository($repository): Snapshots

return $this;
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
7 changes: 6 additions & 1 deletion src/OpenSearch/Endpoints/Cat/Templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function getParamWhitelist(): array
'h',
'help',
's',
'v'
'v',
'cluster_manager_timeout'
];
}

Expand All @@ -64,4 +65,8 @@ public function setName($name): Templates

return $this;
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
7 changes: 6 additions & 1 deletion src/OpenSearch/Endpoints/Cat/ThreadPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public function getParamWhitelist(): array
'h',
'help',
's',
'v'
'v',
'cluster_manager_timeout'
];
}

Expand All @@ -68,4 +69,8 @@ public function setThreadPoolPatterns($thread_pool_patterns): ThreadPool

return $this;
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public function getParamWhitelist(): array
{
return [
'timeout',
'master_timeout'
'master_timeout',
'cluster_manager_timeout'
];
}

Expand All @@ -60,4 +61,8 @@ public function setName($name): DeleteComponentTemplate

return $this;
}
protected function getParamDeprecation(): array
{
return ['master_timeout' => 'cluster_manager_timeout'];
}
}
Loading