Skip to content

Commit

Permalink
Updated APIs to 8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimuel committed Mar 27, 2023
1 parent 015bca9 commit 439a83e
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 5 deletions.
46 changes: 43 additions & 3 deletions src/Endpoints/Ml.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ public function deleteForecast(array $params = [])
* job_id: string, // (REQUIRED) The ID of the job to delete
* force: boolean, // True if the job should be forcefully deleted
* wait_for_completion: boolean, // Should this request wait until the operation has completed before returning
* delete_user_annotations: boolean, // Should annotations added by the user be deleted
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
Expand All @@ -431,7 +432,7 @@ public function deleteJob(array $params = [])
$url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']);
$method = 'DELETE';

$url = $this->addQueryString($url, $params, ['force','wait_for_completion','pretty','human','error_trace','source','filter_path']);
$url = $this->addQueryString($url, $params, ['force','wait_for_completion','delete_user_annotations','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
Expand Down Expand Up @@ -2186,6 +2187,7 @@ public function putTrainedModelVocabulary(array $params = [])
* @param array{
* job_id: string, // (REQUIRED) The ID of the job to reset
* wait_for_completion: boolean, // Should this request wait until the operation has completed before returning
* delete_user_annotations: boolean, // Should annotations added by the user be deleted
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
Expand All @@ -2206,7 +2208,7 @@ public function resetJob(array $params = [])
$url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_reset';
$method = 'POST';

$url = $this->addQueryString($url, $params, ['wait_for_completion','pretty','human','error_trace','source','filter_path']);
$url = $this->addQueryString($url, $params, ['wait_for_completion','delete_user_annotations','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
Expand Down Expand Up @@ -2375,6 +2377,7 @@ public function startDatafeed(array $params = [])
* cache_size: string, // A byte-size value for configuring the inference cache size. For example, 20mb.
* number_of_allocations: int, // The total number of allocations this model is assigned across machine learning nodes.
* threads_per_allocation: int, // The number of threads used by each model allocation during inference.
* priority: string, // The deployment priority.
* queue_capacity: int, // Controls how many inference requests are allowed in the queue at a time.
* timeout: time, // Controls the amount of time to wait for the model to deploy.
* wait_for: string, // The allocation status for which to wait
Expand All @@ -2398,7 +2401,7 @@ public function startTrainedModelDeployment(array $params = [])
$url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/deployment/_start';
$method = 'POST';

$url = $this->addQueryString($url, $params, ['cache_size','number_of_allocations','threads_per_allocation','queue_capacity','timeout','wait_for','pretty','human','error_trace','source','filter_path']);
$url = $this->addQueryString($url, $params, ['cache_size','number_of_allocations','threads_per_allocation','priority','queue_capacity','timeout','wait_for','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
Expand Down Expand Up @@ -2717,6 +2720,43 @@ public function updateModelSnapshot(array $params = [])
}


/**
* Updates certain properties of trained model deployment.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/update-trained-model-deployment.html
*
* @param array{
* model_id: string, // (REQUIRED) The unique identifier of the trained model.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The updated trained model deployment settings
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function updateTrainedModelDeployment(array $params = [])
{
$this->checkRequiredParameters(['model_id','body'], $params);
$url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/deployment/_update';
$method = 'POST';

$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}


/**
* Upgrades a given job snapshot to the current major version.
*
Expand Down
43 changes: 41 additions & 2 deletions src/Endpoints/Transform.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public function getTransform(array $params = [])
* transform_id: string, // (REQUIRED) The id of the transform for which to get stats. '_all' or '*' implies all transforms
* from: number, // skips a number of transform stats, defaults to 0
* size: number, // specifies a max number of transform stats to get, defaults to 100
* timeout: time, // Controls the time to wait for the stats
* allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified)
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
Expand All @@ -136,7 +137,7 @@ public function getTransformStats(array $params = [])
$url = '/_transform/' . $this->encode($params['transform_id']) . '/_stats';
$method = 'GET';

$url = $this->addQueryString($url, $params, ['from','size','allow_no_match','pretty','human','error_trace','source','filter_path']);
$url = $this->addQueryString($url, $params, ['from','size','timeout','allow_no_match','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
Expand Down Expand Up @@ -260,13 +261,51 @@ public function resetTransform(array $params = [])
}


/**
* Schedules now a transform.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/schedule-now-transform.html
*
* @param array{
* transform_id: string, // (REQUIRED) The id of the transform.
* timeout: time, // Controls the time to wait for the scheduling to take place
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function scheduleNowTransform(array $params = [])
{
$this->checkRequiredParameters(['transform_id'], $params);
$url = '/_transform/' . $this->encode($params['transform_id']) . '/_schedule_now';
$method = 'POST';

$url = $this->addQueryString($url, $params, ['timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}


/**
* Starts one or more transforms.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/start-transform.html
*
* @param array{
* transform_id: string, // (REQUIRED) The id of the transform to start
* from: string, // Restricts the set of transformed entities to those changed after this time
* timeout: time, // Controls the time to wait for the transform to start
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
Expand All @@ -288,7 +327,7 @@ public function startTransform(array $params = [])
$url = '/_transform/' . $this->encode($params['transform_id']) . '/_start';
$method = 'POST';

$url = $this->addQueryString($url, $params, ['timeout','pretty','human','error_trace','source','filter_path']);
$url = $this->addQueryString($url, $params, ['from','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
Expand Down
40 changes: 40 additions & 0 deletions src/Traits/ClientEndpointsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,46 @@ public function getSource(array $params = [])
}


/**
* Returns the health of the cluster.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/health-api.html
*
* @param array{
* feature: string, // A feature of the cluster, as returned by the top-level health API
* timeout: time, // Explicit operation timeout
* verbose: boolean, // Opt in for more information about the health of the system
* size: int, // Limit the number of affected resources the health API returns
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function healthReport(array $params = [])
{
if (isset($params['feature'])) {
$url = '/_health_report/' . $this->encode($params['feature']);
$method = 'GET';
} else {
$url = '/_health_report';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['timeout','verbose','size','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}


/**
* Creates or updates a document in an index.
*
Expand Down

0 comments on commit 439a83e

Please sign in to comment.