Skip to content

Commit e404235

Browse files
committed
Fixed query string in API endpoints + added a first integration test
1 parent 50de3e6 commit e404235

40 files changed

+710
-57
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
"test" : [
4343
"vendor/bin/phpunit"
4444
],
45+
"integration-test" : [
46+
"vendor/bin/phpunit -c phpunit-integration-tests.xml"
47+
],
4548
"phpstan": [
4649
"phpstan analyse src --level 2 --no-progress"
4750
]

phpunit-integration-tests.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" failOnRisky="true" verbose="true" beStrictAboutChangesToGlobalState="true" beStrictAboutOutputDuringTests="true" beStrictAboutTestsThatDoNotTestAnything="false">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">src</directory>
6+
</include>
7+
</coverage>
8+
<php>
9+
<!-- Disable E_USER_DEPRECATED setting E_ALL & ~E_USER_DEPRECATED-->
10+
<ini name="error_reporting" value="16383"/>
11+
<ini name="memory_limit" value="-1"/>
12+
</php>
13+
<testsuites>
14+
<testsuite name="Integration tests">
15+
<directory>tests/Integration</directory>
16+
</testsuite>
17+
</testsuites>
18+
<groups>
19+
<include>
20+
<group>integration</group>
21+
</include>
22+
</groups>
23+
</phpunit>

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</testsuites>
1313
<groups>
1414
<exclude>
15-
<group>Integration</group>
15+
<group>integration</group>
1616
<group>free</group>
1717
<group>platinum</group>
1818
</exclude>

src/Endpoints/AsyncSearch.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function delete(array $params = [])
4545
$url = '/_async_search/' . urlencode((string) $params['id']);
4646
$method = 'DELETE';
4747

48+
$url = $this->addQueryString($url, $params, []);
4849
$headers = array (
4950
'Accept' => 'application/json',
5051
);
@@ -72,6 +73,7 @@ public function get(array $params = [])
7273
$url = '/_async_search/' . urlencode((string) $params['id']);
7374
$method = 'GET';
7475

76+
$url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_alive','typed_keys']);
7577
$headers = array (
7678
'Accept' => 'application/json',
7779
);
@@ -96,6 +98,7 @@ public function status(array $params = [])
9698
$url = '/_async_search/status/' . urlencode((string) $params['id']);
9799
$method = 'GET';
98100

101+
$url = $this->addQueryString($url, $params, []);
99102
$headers = array (
100103
'Accept' => 'application/json',
101104
);
@@ -165,6 +168,7 @@ public function submit(array $params = [])
165168
$url = '/_async_search';
166169
$method = 'POST';
167170
}
171+
$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']);
168172
$headers = array (
169173
'Accept' => 'application/json',
170174
'Content-Type' => 'application/json',

src/Endpoints/Autoscaling.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function deleteAutoscalingPolicy(array $params = [])
4545
$url = '/_autoscaling/policy/' . urlencode((string) $params['name']);
4646
$method = 'DELETE';
4747

48+
$url = $this->addQueryString($url, $params, []);
4849
$headers = array (
4950
'Accept' => 'application/json',
5051
);
@@ -62,6 +63,7 @@ public function getAutoscalingCapacity(array $params = [])
6263
$url = '/_autoscaling/capacity';
6364
$method = 'GET';
6465

66+
$url = $this->addQueryString($url, $params, []);
6567
$headers = array (
6668
'Accept' => 'application/json',
6769
);
@@ -86,6 +88,7 @@ public function getAutoscalingPolicy(array $params = [])
8688
$url = '/_autoscaling/policy/' . urlencode((string) $params['name']);
8789
$method = 'GET';
8890

91+
$url = $this->addQueryString($url, $params, []);
8992
$headers = array (
9093
'Accept' => 'application/json',
9194
);
@@ -107,10 +110,11 @@ public function getAutoscalingPolicy(array $params = [])
107110
*/
108111
public function putAutoscalingPolicy(array $params = [])
109112
{
110-
$this->checkRequiredParameters(['name','body'], $params);
113+
$this->checkRequiredParameters(['name'], $params);
111114
$url = '/_autoscaling/policy/' . urlencode((string) $params['name']);
112115
$method = 'PUT';
113116

117+
$url = $this->addQueryString($url, $params, []);
114118
$headers = array (
115119
'Accept' => 'application/json',
116120
'Content-Type' => 'application/json',

src/Endpoints/Cat.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function aliases(array $params = [])
5555
$url = '/_cat/aliases';
5656
$method = 'GET';
5757
}
58+
$url = $this->addQueryString($url, $params, ['format','local','h','help','s','v','expand_wildcards']);
5859
$headers = array (
5960
'Accept' => 'text/plain,application/json',
6061
);
@@ -90,6 +91,7 @@ public function allocation(array $params = [])
9091
$url = '/_cat/allocation';
9192
$method = 'GET';
9293
}
94+
$url = $this->addQueryString($url, $params, ['format','bytes','local','master_timeout','h','help','s','v']);
9395
$headers = array (
9496
'Accept' => 'text/plain,application/json',
9597
);
@@ -122,6 +124,7 @@ public function count(array $params = [])
122124
$url = '/_cat/count';
123125
$method = 'GET';
124126
}
127+
$url = $this->addQueryString($url, $params, ['format','h','help','s','v']);
125128
$headers = array (
126129
'Accept' => 'text/plain,application/json',
127130
);
@@ -142,7 +145,6 @@ public function count(array $params = [])
142145
* help: boolean, // Return help information
143146
* s: list, // Comma-separated list of column names or column aliases to sort by
144147
* v: boolean, // Verbose mode. Display column headers
145-
* fields: list, // A comma-separated list of fields to return in the output
146148
* } $params
147149
* @throws MissingParameterException if a required parameter is missing
148150
* @return Elasticsearch|Promise
@@ -156,6 +158,7 @@ public function fielddata(array $params = [])
156158
$url = '/_cat/fielddata';
157159
$method = 'GET';
158160
}
161+
$url = $this->addQueryString($url, $params, ['format','bytes','h','help','s','v']);
159162
$headers = array (
160163
'Accept' => 'text/plain,application/json',
161164
);
@@ -185,6 +188,7 @@ public function health(array $params = [])
185188
$url = '/_cat/health';
186189
$method = 'GET';
187190

191+
$url = $this->addQueryString($url, $params, ['format','h','help','s','time','ts','v']);
188192
$headers = array (
189193
'Accept' => 'text/plain,application/json',
190194
);
@@ -209,6 +213,7 @@ public function help(array $params = [])
209213
$url = '/_cat';
210214
$method = 'GET';
211215

216+
$url = $this->addQueryString($url, $params, ['help','s']);
212217
$headers = array (
213218
'Accept' => 'text/plain',
214219
);
@@ -248,6 +253,7 @@ public function indices(array $params = [])
248253
$url = '/_cat/indices';
249254
$method = 'GET';
250255
}
256+
$url = $this->addQueryString($url, $params, ['format','bytes','master_timeout','h','health','help','pri','s','time','v','include_unloaded_segments','expand_wildcards']);
251257
$headers = array (
252258
'Accept' => 'text/plain,application/json',
253259
);
@@ -277,6 +283,7 @@ public function master(array $params = [])
277283
$url = '/_cat/master';
278284
$method = 'GET';
279285

286+
$url = $this->addQueryString($url, $params, ['format','local','master_timeout','h','help','s','v']);
280287
$headers = array (
281288
'Accept' => 'text/plain,application/json',
282289
);
@@ -312,6 +319,7 @@ public function mlDataFrameAnalytics(array $params = [])
312319
$url = '/_cat/ml/data_frame/analytics';
313320
$method = 'GET';
314321
}
322+
$url = $this->addQueryString($url, $params, ['allow_no_match','bytes','format','h','help','s','time','v']);
315323
$headers = array (
316324
'Accept' => 'text/plain,application/json',
317325
);
@@ -346,6 +354,7 @@ public function mlDatafeeds(array $params = [])
346354
$url = '/_cat/ml/datafeeds';
347355
$method = 'GET';
348356
}
357+
$url = $this->addQueryString($url, $params, ['allow_no_match','format','h','help','s','time','v']);
349358
$headers = array (
350359
'Accept' => 'text/plain,application/json',
351360
);
@@ -381,6 +390,7 @@ public function mlJobs(array $params = [])
381390
$url = '/_cat/ml/anomaly_detectors';
382391
$method = 'GET';
383392
}
393+
$url = $this->addQueryString($url, $params, ['allow_no_match','bytes','format','h','help','s','time','v']);
384394
$headers = array (
385395
'Accept' => 'text/plain,application/json',
386396
);
@@ -418,6 +428,7 @@ public function mlTrainedModels(array $params = [])
418428
$url = '/_cat/ml/trained_models';
419429
$method = 'GET';
420430
}
431+
$url = $this->addQueryString($url, $params, ['allow_no_match','from','size','bytes','format','h','help','s','time','v']);
421432
$headers = array (
422433
'Accept' => 'text/plain,application/json',
423434
);
@@ -447,6 +458,7 @@ public function nodeattrs(array $params = [])
447458
$url = '/_cat/nodeattrs';
448459
$method = 'GET';
449460

461+
$url = $this->addQueryString($url, $params, ['format','local','master_timeout','h','help','s','v']);
450462
$headers = array (
451463
'Accept' => 'text/plain,application/json',
452464
);
@@ -479,6 +491,7 @@ public function nodes(array $params = [])
479491
$url = '/_cat/nodes';
480492
$method = 'GET';
481493

494+
$url = $this->addQueryString($url, $params, ['bytes','format','full_id','master_timeout','h','help','s','time','v','include_unloaded_segments']);
482495
$headers = array (
483496
'Accept' => 'text/plain,application/json',
484497
);
@@ -509,6 +522,7 @@ public function pendingTasks(array $params = [])
509522
$url = '/_cat/pending_tasks';
510523
$method = 'GET';
511524

525+
$url = $this->addQueryString($url, $params, ['format','local','master_timeout','h','help','s','time','v']);
512526
$headers = array (
513527
'Accept' => 'text/plain,application/json',
514528
);
@@ -539,6 +553,7 @@ public function plugins(array $params = [])
539553
$url = '/_cat/plugins';
540554
$method = 'GET';
541555

556+
$url = $this->addQueryString($url, $params, ['format','local','master_timeout','h','help','include_bootstrap','s','v']);
542557
$headers = array (
543558
'Accept' => 'text/plain,application/json',
544559
);
@@ -559,7 +574,6 @@ public function plugins(array $params = [])
559574
* detailed: boolean, // If `true`, the response includes detailed information about shard recoveries
560575
* h: list, // Comma-separated list of column names to display
561576
* help: boolean, // Return help information
562-
* index: list, // Comma-separated list or wildcard expression of index names to limit the returned information
563577
* s: list, // Comma-separated list of column names or column aliases to sort by
564578
* time: enum, // The unit in which to display time values
565579
* v: boolean, // Verbose mode. Display column headers
@@ -576,6 +590,7 @@ public function recovery(array $params = [])
576590
$url = '/_cat/recovery';
577591
$method = 'GET';
578592
}
593+
$url = $this->addQueryString($url, $params, ['format','active_only','bytes','detailed','h','help','s','time','v']);
579594
$headers = array (
580595
'Accept' => 'text/plain,application/json',
581596
);
@@ -605,6 +620,7 @@ public function repositories(array $params = [])
605620
$url = '/_cat/repositories';
606621
$method = 'GET';
607622

623+
$url = $this->addQueryString($url, $params, ['format','local','master_timeout','h','help','s','v']);
608624
$headers = array (
609625
'Accept' => 'text/plain,application/json',
610626
);
@@ -638,6 +654,7 @@ public function segments(array $params = [])
638654
$url = '/_cat/segments';
639655
$method = 'GET';
640656
}
657+
$url = $this->addQueryString($url, $params, ['format','bytes','h','help','s','v']);
641658
$headers = array (
642659
'Accept' => 'text/plain,application/json',
643660
);
@@ -673,6 +690,7 @@ public function shards(array $params = [])
673690
$url = '/_cat/shards';
674691
$method = 'GET';
675692
}
693+
$url = $this->addQueryString($url, $params, ['format','bytes','master_timeout','h','help','s','time','v']);
676694
$headers = array (
677695
'Accept' => 'text/plain,application/json',
678696
);
@@ -708,6 +726,7 @@ public function snapshots(array $params = [])
708726
$url = '/_cat/snapshots';
709727
$method = 'GET';
710728
}
729+
$url = $this->addQueryString($url, $params, ['format','ignore_unavailable','master_timeout','h','help','s','time','v']);
711730
$headers = array (
712731
'Accept' => 'text/plain,application/json',
713732
);
@@ -741,6 +760,7 @@ public function tasks(array $params = [])
741760
$url = '/_cat/tasks';
742761
$method = 'GET';
743762

763+
$url = $this->addQueryString($url, $params, ['format','nodes','actions','detailed','parent_task_id','h','help','s','time','v']);
744764
$headers = array (
745765
'Accept' => 'text/plain,application/json',
746766
);
@@ -775,6 +795,7 @@ public function templates(array $params = [])
775795
$url = '/_cat/templates';
776796
$method = 'GET';
777797
}
798+
$url = $this->addQueryString($url, $params, ['format','local','master_timeout','h','help','s','v']);
778799
$headers = array (
779800
'Accept' => 'text/plain,application/json',
780801
);
@@ -811,6 +832,7 @@ public function threadPool(array $params = [])
811832
$url = '/_cat/thread_pool';
812833
$method = 'GET';
813834
}
835+
$url = $this->addQueryString($url, $params, ['format','time','local','master_timeout','h','help','s','v']);
814836
$headers = array (
815837
'Accept' => 'text/plain,application/json',
816838
);
@@ -847,6 +869,7 @@ public function transforms(array $params = [])
847869
$url = '/_cat/transforms';
848870
$method = 'GET';
849871
}
872+
$url = $this->addQueryString($url, $params, ['from','size','allow_no_match','format','h','help','s','time','v']);
850873
$headers = array (
851874
'Accept' => 'text/plain,application/json',
852875
);

0 commit comments

Comments
 (0)