Skip to content

Commit 7ac2b05

Browse files
committed
Updated endpoints to 9.0.0-SNAPSHOT + added integration tests
1 parent 32b8d25 commit 7ac2b05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+7500
-5553
lines changed
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: PHP integration tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
name: Test
8+
runs-on: ${{ matrix.os }}
9+
10+
strategy:
11+
matrix:
12+
php-version: [8.1, 8.2, 8.3, 8.4]
13+
os: [ubuntu-latest]
14+
es-version: [9.0.0-SNAPSHOT]
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Use PHP ${{ matrix.php-version }}
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php-version }}
24+
extensions: yaml, zip, curl
25+
coverage: none
26+
env:
27+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Get composer cache directory
30+
id: composercache
31+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
32+
- name: Cache dependencies
33+
uses: actions/cache@v4
34+
with:
35+
path: ${{ steps.composercache.outputs.dir }}
36+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}
37+
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-
38+
39+
- name: Install dependencies
40+
run: |
41+
composer install --prefer-dist
42+
43+
- name: Run Elasticsearch using start-local
44+
run: |
45+
curl -fsSL https://elastic.co/start-local | sh -s -- -v ${{ matrix.es-version }} -esonly
46+
47+
- name: Integration tests
48+
run: |
49+
source elastic-start-local/.env
50+
ELASTICSEARCH_URL="http://elastic:${ES_LOCAL_PASSWORD}@localhost:9200" TEST_SUITE="platinum" composer run-script integration-test

.github/workflows/test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PHP test
1+
name: PHP tests
22

33
on: [push, pull_request]
44

@@ -9,9 +9,9 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
php-version: [7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
12+
php-version: [8.1, 8.2, 8.3, 8.4]
1313
os: [ubuntu-latest]
14-
es-version: [8.16-SNAPSHOT]
14+
es-version: [9.0.0-SNAPSHOT]
1515

1616
steps:
1717
- name: Checkout

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"type": "library",
1111
"license": "MIT",
1212
"require": {
13-
"php": "^7.4 || ^8.0",
13+
"php": "^8.1",
1414
"elastic/transport": "^8.10",
1515
"psr/http-client": "^1.0",
1616
"psr/http-message": "^1.1 || ^2.0",

phpstan.neon

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
parameters:
2-
level: 2
2+
level: 5
33
paths:
44
- src
55
ignoreErrors:
6-
- '#PHPDoc tag @param has invalid value#'
6+
- '#Offset ''body'' on array\{\}\|array\{#'

src/Endpoints/AsyncSearch.php

+87-78
Large diffs are not rendered by default.

src/Endpoints/Autoscaling.php

+39-35
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ class Autoscaling extends AbstractEndpoint
3131
/**
3232
* Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
3333
*
34-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-delete-autoscaling-policy.html
34+
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-delete-autoscaling-policy.html
3535
*
3636
* @param array{
3737
* name: string, // (REQUIRED) the name of the autoscaling policy
38-
* master_timeout: time, // Timeout for processing on master node
39-
* timeout: time, // Timeout for acknowledgement of update from all nodes in cluster
40-
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
41-
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
42-
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
43-
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
44-
* filter_path: list, // A comma-separated list of filters used to reduce the response.
38+
* master_timeout?: int|string, // Timeout for processing on master node
39+
* timeout?: int|string, // Timeout for acknowledgement of update from all nodes in cluster
40+
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
41+
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
42+
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
43+
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
44+
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
4545
* } $params
4646
*
4747
* @throws MissingParameterException if a required parameter is missing
@@ -51,8 +51,9 @@ class Autoscaling extends AbstractEndpoint
5151
*
5252
* @return Elasticsearch|Promise
5353
*/
54-
public function deleteAutoscalingPolicy(array $params = [])
54+
public function deleteAutoscalingPolicy(?array $params = null)
5555
{
56+
$params = $params ?? [];
5657
$this->checkRequiredParameters(['name'], $params);
5758
$url = '/_autoscaling/policy/' . $this->encode($params['name']);
5859
$method = 'DELETE';
@@ -70,15 +71,15 @@ public function deleteAutoscalingPolicy(array $params = [])
7071
/**
7172
* Gets the current autoscaling capacity based on the configured autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
7273
*
73-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-capacity.html
74+
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-capacity.html
7475
*
7576
* @param array{
76-
* master_timeout: time, // Timeout for processing on master node
77-
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
78-
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
79-
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
80-
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
81-
* filter_path: list, // A comma-separated list of filters used to reduce the response.
77+
* master_timeout?: int|string, // Timeout for processing on master node
78+
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
79+
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
80+
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
81+
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
82+
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
8283
* } $params
8384
*
8485
* @throws NoNodeAvailableException if all the hosts are offline
@@ -87,8 +88,9 @@ public function deleteAutoscalingPolicy(array $params = [])
8788
*
8889
* @return Elasticsearch|Promise
8990
*/
90-
public function getAutoscalingCapacity(array $params = [])
91+
public function getAutoscalingCapacity(?array $params = null)
9192
{
93+
$params = $params ?? [];
9294
$url = '/_autoscaling/capacity';
9395
$method = 'GET';
9496

@@ -105,16 +107,16 @@ public function getAutoscalingCapacity(array $params = [])
105107
/**
106108
* Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
107109
*
108-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-policy.html
110+
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-policy.html
109111
*
110112
* @param array{
111113
* name: string, // (REQUIRED) the name of the autoscaling policy
112-
* master_timeout: time, // Timeout for processing on master node
113-
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
114-
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
115-
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
116-
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
117-
* filter_path: list, // A comma-separated list of filters used to reduce the response.
114+
* master_timeout?: int|string, // Timeout for processing on master node
115+
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
116+
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
117+
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
118+
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
119+
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
118120
* } $params
119121
*
120122
* @throws MissingParameterException if a required parameter is missing
@@ -124,8 +126,9 @@ public function getAutoscalingCapacity(array $params = [])
124126
*
125127
* @return Elasticsearch|Promise
126128
*/
127-
public function getAutoscalingPolicy(array $params = [])
129+
public function getAutoscalingPolicy(?array $params = null)
128130
{
131+
$params = $params ?? [];
129132
$this->checkRequiredParameters(['name'], $params);
130133
$url = '/_autoscaling/policy/' . $this->encode($params['name']);
131134
$method = 'GET';
@@ -143,18 +146,18 @@ public function getAutoscalingPolicy(array $params = [])
143146
/**
144147
* Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
145148
*
146-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-put-autoscaling-policy.html
149+
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-put-autoscaling-policy.html
147150
*
148151
* @param array{
149152
* name: string, // (REQUIRED) the name of the autoscaling policy
150-
* master_timeout: time, // Timeout for processing on master node
151-
* timeout: time, // Timeout for acknowledgement of update from all nodes in cluster
152-
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
153-
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
154-
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
155-
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
156-
* filter_path: list, // A comma-separated list of filters used to reduce the response.
157-
* body: array, // (REQUIRED) the specification of the autoscaling policy
153+
* master_timeout?: int|string, // Timeout for processing on master node
154+
* timeout?: int|string, // Timeout for acknowledgement of update from all nodes in cluster
155+
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
156+
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
157+
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
158+
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
159+
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
160+
* body: string|array<mixed>, // (REQUIRED) the specification of the autoscaling policy. If body is a string must be a valid JSON.
158161
* } $params
159162
*
160163
* @throws MissingParameterException if a required parameter is missing
@@ -164,8 +167,9 @@ public function getAutoscalingPolicy(array $params = [])
164167
*
165168
* @return Elasticsearch|Promise
166169
*/
167-
public function putAutoscalingPolicy(array $params = [])
170+
public function putAutoscalingPolicy(?array $params = null)
168171
{
172+
$params = $params ?? [];
169173
$this->checkRequiredParameters(['name','body'], $params);
170174
$url = '/_autoscaling/policy/' . $this->encode($params['name']);
171175
$method = 'PUT';

0 commit comments

Comments
 (0)