Skip to content

Fixing script get and delete by removing lang from endpoint url #814

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

Merged
merged 2 commits into from
Apr 19, 2019
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
3 changes: 0 additions & 3 deletions docs/build/Elasticsearch/Client.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,6 @@ $response = $client->updateByQuery($params);
----
/*
$params['id'] = (string) The script ID (Required)
['lang'] = (string) The script language (Required)
['body'] = (array) Request body
*/

Expand All @@ -953,7 +952,6 @@ $response = $client->getScript($params);
----
/*
$params['id'] = (string) The script ID (Required)
['lang'] = (string) The script language (Required)
['body'] = (array) Request body
*/

Expand All @@ -975,7 +973,6 @@ $response = $client->deleteScript($params);
----
/*
$params['id'] = (string) The script ID (Required)
['lang'] = (string) The script language (Required)
['body'] = (array) Request body
*/

Expand Down
12 changes: 2 additions & 10 deletions src/Elasticsearch/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,6 @@ public function updateByQuery($params = array())

/**
* $params['id'] = (string) The script ID (Required)
* ['lang'] = (string) The script language (Required)
*
* @param array $params Associative array of parameters
*
Expand All @@ -1213,23 +1212,20 @@ public function updateByQuery($params = array())
public function getScript($params)
{
$id = $this->extractArgument($params, 'id');
$lang = $this->extractArgument($params, 'lang');

/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;

/** @var \Elasticsearch\Endpoints\Script\Get $endpoint */
$endpoint = $endpointBuilder('Script\Get');
$endpoint->setID($id)
->setLang($lang);
$endpoint->setID($id);
$endpoint->setParams($params);

return $this->performRequest($endpoint);
}

/**
* $params['id'] = (string) The script ID (Required)
* ['lang'] = (string) The script language (Required)
*
* @param array $params Associative array of parameters
*
Expand All @@ -1238,23 +1234,20 @@ public function getScript($params)
public function deleteScript($params)
{
$id = $this->extractArgument($params, 'id');
$lang = $this->extractArgument($params, 'lang');

/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;

/** @var \Elasticsearch\Endpoints\Script\Delete $endpoint */
$endpoint = $endpointBuilder('Script\Delete');
$endpoint->setID($id)
->setLang($lang);
$endpoint->setID($id);
$endpoint->setParams($params);

return $this->performRequest($endpoint);
}

/**
* $params['id'] = (string) The script ID (Required)
* ['lang'] = (string) The script language (Required)
*
* @param array $params Associative array of parameters
*
Expand All @@ -1263,7 +1256,6 @@ public function deleteScript($params)
public function putScript($params)
{
$id = $this->extractArgument($params, 'id');
$lang = $this->extractArgument($params, 'lang');
$body = $this->extractArgument($params, 'body');

/** @var callback $endpointBuilder */
Expand Down
27 changes: 1 addition & 26 deletions src/Elasticsearch/Endpoints/Script/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,19 @@
*/
class Delete extends AbstractEndpoint
{
/** @var string */
private $lang;

/**
* @param string $lang
*
* @return $this
*/
public function setLang($lang)
{
if (isset($lang) !== true) {
return $this;
}

$this->lang = $lang;

return $this;
}

/**
* @throws \Elasticsearch\Common\Exceptions\RuntimeException
* @return string
*/
public function getURI()
{
if (isset($this->lang) !== true) {
throw new Exceptions\RuntimeException(
'lang is required for Put'
);
}
if (isset($this->id) !== true) {
throw new Exceptions\RuntimeException(
'id is required for put'
);
}
$id = $this->id;
$lang = $this->lang;
$uri = "/_scripts/$lang/$id";
$uri = "/_scripts/$id";

return $uri;
}
Expand Down
27 changes: 1 addition & 26 deletions src/Elasticsearch/Endpoints/Script/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,19 @@
*/
class Get extends AbstractEndpoint
{
/** @var string */
private $lang;

/**
* @param string $lang
*
* @return $this
*/
public function setLang($lang)
{
if (isset($lang) !== true) {
return $this;
}

$this->lang = $lang;

return $this;
}

/**
* @throws \Elasticsearch\Common\Exceptions\RuntimeException
* @return string
*/
public function getURI()
{
if (isset($this->lang) !== true) {
throw new Exceptions\RuntimeException(
'lang is required for Put'
);
}
if (isset($this->id) !== true) {
throw new Exceptions\RuntimeException(
'id is required for put'
);
}
$id = $this->id;
$lang = $this->lang;
$uri = "/_scripts/$lang/$id";
$uri = "/_scripts/$id";

return $uri;
}
Expand Down