Skip to content

Commit cf42042

Browse files
authored
Merge pull request #814 from feydan/master
Fixing script get and delete by removing lang from endpoint url
2 parents 50485d7 + 834c6f6 commit cf42042

File tree

4 files changed

+4
-65
lines changed

4 files changed

+4
-65
lines changed

docs/build/Elasticsearch/Client.asciidoc

-3
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,6 @@ $response = $client->updateByQuery($params);
931931
----
932932
/*
933933
$params['id'] = (string) The script ID (Required)
934-
['lang'] = (string) The script language (Required)
935934
['body'] = (array) Request body
936935
*/
937936
@@ -953,7 +952,6 @@ $response = $client->getScript($params);
953952
----
954953
/*
955954
$params['id'] = (string) The script ID (Required)
956-
['lang'] = (string) The script language (Required)
957955
['body'] = (array) Request body
958956
*/
959957
@@ -975,7 +973,6 @@ $response = $client->deleteScript($params);
975973
----
976974
/*
977975
$params['id'] = (string) The script ID (Required)
978-
['lang'] = (string) The script language (Required)
979976
['body'] = (array) Request body
980977
*/
981978

src/Elasticsearch/Client.php

+2-10
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,6 @@ public function updateByQuery($params = array())
12041204

12051205
/**
12061206
* $params['id'] = (string) The script ID (Required)
1207-
* ['lang'] = (string) The script language (Required)
12081207
*
12091208
* @param array $params Associative array of parameters
12101209
*
@@ -1213,23 +1212,20 @@ public function updateByQuery($params = array())
12131212
public function getScript($params)
12141213
{
12151214
$id = $this->extractArgument($params, 'id');
1216-
$lang = $this->extractArgument($params, 'lang');
12171215

12181216
/** @var callable $endpointBuilder */
12191217
$endpointBuilder = $this->endpoints;
12201218

12211219
/** @var \Elasticsearch\Endpoints\Script\Get $endpoint */
12221220
$endpoint = $endpointBuilder('Script\Get');
1223-
$endpoint->setID($id)
1224-
->setLang($lang);
1221+
$endpoint->setID($id);
12251222
$endpoint->setParams($params);
12261223

12271224
return $this->performRequest($endpoint);
12281225
}
12291226

12301227
/**
12311228
* $params['id'] = (string) The script ID (Required)
1232-
* ['lang'] = (string) The script language (Required)
12331229
*
12341230
* @param array $params Associative array of parameters
12351231
*
@@ -1238,23 +1234,20 @@ public function getScript($params)
12381234
public function deleteScript($params)
12391235
{
12401236
$id = $this->extractArgument($params, 'id');
1241-
$lang = $this->extractArgument($params, 'lang');
12421237

12431238
/** @var callable $endpointBuilder */
12441239
$endpointBuilder = $this->endpoints;
12451240

12461241
/** @var \Elasticsearch\Endpoints\Script\Delete $endpoint */
12471242
$endpoint = $endpointBuilder('Script\Delete');
1248-
$endpoint->setID($id)
1249-
->setLang($lang);
1243+
$endpoint->setID($id);
12501244
$endpoint->setParams($params);
12511245

12521246
return $this->performRequest($endpoint);
12531247
}
12541248

12551249
/**
12561250
* $params['id'] = (string) The script ID (Required)
1257-
* ['lang'] = (string) The script language (Required)
12581251
*
12591252
* @param array $params Associative array of parameters
12601253
*
@@ -1263,7 +1256,6 @@ public function deleteScript($params)
12631256
public function putScript($params)
12641257
{
12651258
$id = $this->extractArgument($params, 'id');
1266-
$lang = $this->extractArgument($params, 'lang');
12671259
$body = $this->extractArgument($params, 'body');
12681260

12691261
/** @var callable $endpointBuilder */

src/Elasticsearch/Endpoints/Script/Delete.php

+1-26
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,19 @@
1818
*/
1919
class Delete extends AbstractEndpoint
2020
{
21-
/** @var string */
22-
private $lang;
23-
24-
/**
25-
* @param string $lang
26-
*
27-
* @return $this
28-
*/
29-
public function setLang($lang)
30-
{
31-
if (isset($lang) !== true) {
32-
return $this;
33-
}
34-
35-
$this->lang = $lang;
36-
37-
return $this;
38-
}
39-
4021
/**
4122
* @throws \Elasticsearch\Common\Exceptions\RuntimeException
4223
* @return string
4324
*/
4425
public function getURI()
4526
{
46-
if (isset($this->lang) !== true) {
47-
throw new Exceptions\RuntimeException(
48-
'lang is required for Put'
49-
);
50-
}
5127
if (isset($this->id) !== true) {
5228
throw new Exceptions\RuntimeException(
5329
'id is required for put'
5430
);
5531
}
5632
$id = $this->id;
57-
$lang = $this->lang;
58-
$uri = "/_scripts/$lang/$id";
33+
$uri = "/_scripts/$id";
5934

6035
return $uri;
6136
}

src/Elasticsearch/Endpoints/Script/Get.php

+1-26
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,19 @@
1818
*/
1919
class Get extends AbstractEndpoint
2020
{
21-
/** @var string */
22-
private $lang;
23-
24-
/**
25-
* @param string $lang
26-
*
27-
* @return $this
28-
*/
29-
public function setLang($lang)
30-
{
31-
if (isset($lang) !== true) {
32-
return $this;
33-
}
34-
35-
$this->lang = $lang;
36-
37-
return $this;
38-
}
39-
4021
/**
4122
* @throws \Elasticsearch\Common\Exceptions\RuntimeException
4223
* @return string
4324
*/
4425
public function getURI()
4526
{
46-
if (isset($this->lang) !== true) {
47-
throw new Exceptions\RuntimeException(
48-
'lang is required for Put'
49-
);
50-
}
5127
if (isset($this->id) !== true) {
5228
throw new Exceptions\RuntimeException(
5329
'id is required for put'
5430
);
5531
}
5632
$id = $this->id;
57-
$lang = $this->lang;
58-
$uri = "/_scripts/$lang/$id";
33+
$uri = "/_scripts/$id";
5934

6035
return $uri;
6136
}

0 commit comments

Comments
 (0)