Skip to content

Commit

Permalink
Generate API
Browse files Browse the repository at this point in the history
Signed-off-by: Kim Pepper <[email protected]>
  • Loading branch information
kimpepper committed Jan 10, 2025
1 parent 0a21165 commit e096386
Show file tree
Hide file tree
Showing 44 changed files with 1,300 additions and 436 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fixed PHP 8.4 deprecations
- Fixed outdated tests
### Updated APIs
- Updated opensearch-php APIs to reflect [opensearch-api-specification@5177c0a](https://github.com/opensearch-project/opensearch-api-specification/commit/5177c0ae97f89dea4c02785071b147511e147aaf)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@2395cb4](https://github.com/opensearch-project/opensearch-api-specification/commit/2395cb472ec5581656aac184f7b20548cd5b06ac)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@ebe0f8a](https://github.com/opensearch-project/opensearch-api-specification/commit/ebe0f8a885f7db7e882d160c101055a5aa70a707)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@398481e](https://github.com/opensearch-project/opensearch-api-specification/commit/398481e5bd1cc590d947c35379c47096f2114f00)
Expand Down
106 changes: 52 additions & 54 deletions src/OpenSearch/Client.php

Large diffs are not rendered by default.

87 changes: 87 additions & 0 deletions src/OpenSearch/Endpoints/Ml/ChunkModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

declare(strict_types=1);

/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

namespace OpenSearch\Endpoints\Ml;

use OpenSearch\Common\Exceptions\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
/**
* @deprecated Use `upload_chunk` instead.
*/
class ChunkModel extends AbstractEndpoint
{
protected $chunk_number;
protected $model_id;

public function getURI(): string
{
$chunk_number = $this->chunk_number ?? null;
$model_id = $this->model_id ?? null;
if (isset($model_id) && isset($chunk_number)) {
return "/_plugins/_ml/models/$model_id/chunk/$chunk_number";
}
throw new RuntimeException('Missing parameter for the endpoint ml.chunk_model');
}

public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

public function getMethod(): string
{
return 'POST';
}

public function setBody($body): static
{
if (is_null($body)) {
return $this;
}
$this->body = $body;

return $this;
}

public function setChunkNumber($chunk_number): static
{
if (is_null($chunk_number)) {
return $this;
}
$this->chunk_number = $chunk_number;

return $this;
}

public function setModelId($model_id): static
{
if (is_null($model_id)) {
return $this;
}
$this->model_id = $model_id;

return $this;
}
}
58 changes: 58 additions & 0 deletions src/OpenSearch/Endpoints/Ml/CreateModelMeta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

namespace OpenSearch\Endpoints\Ml;

use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
/**
* @deprecated Use `_register_meta` instead.
*/
class CreateModelMeta extends AbstractEndpoint
{
public function getURI(): string
{
return "/_plugins/_ml/models/meta";
}

public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

public function getMethod(): string
{
return 'POST';
}

public function setBody($body): static
{
if (is_null($body)) {
return $this;
}
$this->body = $body;

return $this;
}
}
47 changes: 28 additions & 19 deletions src/OpenSearch/Endpoints/Ml/GetModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,45 @@
use OpenSearch\Common\Exceptions\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class GetModel extends AbstractEndpoint
{
/**
* @return string[]
*/
public function getParamWhitelist(): array
{
return [];
}
protected $model_id;

/**
* @return string
*/
public function getURI(): string
{
if ($this->id) {
return "/_plugins/_ml/models/$this->id";
$model_id = $this->model_id ?? null;
if (isset($model_id)) {
return "/_plugins/_ml/models/$model_id";
}
throw new RuntimeException('Missing parameter for the endpoint ml.get_model');
}

throw new RuntimeException(
'id is required for get'
);

public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

/**
* @return string
*/
public function getMethod(): string
{
return 'GET';
}

public function setModelId($model_id): static
{
if (is_null($model_id)) {
return $this;
}
$this->model_id = $model_id;

return $this;
}
}
65 changes: 65 additions & 0 deletions src/OpenSearch/Endpoints/Ml/LoadModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

declare(strict_types=1);

/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

namespace OpenSearch\Endpoints\Ml;

use OpenSearch\Common\Exceptions\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
/**
* @deprecated Use `deploy_model` instead.
*/
class LoadModel extends AbstractEndpoint
{
protected $model_id;

public function getURI(): string
{
$model_id = $this->model_id ?? null;
if (isset($model_id)) {
return "/_plugins/_ml/models/$model_id/_load";
}
throw new RuntimeException('Missing parameter for the endpoint ml.load_model');
}

public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

public function getMethod(): string
{
return 'POST';
}

public function setModelId($model_id): static
{
if (is_null($model_id)) {
return $this;
}
$this->model_id = $model_id;

return $this;
}
}
72 changes: 72 additions & 0 deletions src/OpenSearch/Endpoints/Ml/PredictModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

declare(strict_types=1);

/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

namespace OpenSearch\Endpoints\Ml;

use OpenSearch\Common\Exceptions\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class PredictModel extends AbstractEndpoint
{
protected $model_id;

public function getURI(): string
{
$model_id = $this->model_id ?? null;
if (isset($model_id)) {
return "/_plugins/_ml/models/$model_id/_predict";
}
throw new RuntimeException('Missing parameter for the endpoint ml.predict_model');
}

public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

public function getMethod(): string
{
return 'POST';
}

public function setBody($body): static
{
if (is_null($body)) {
return $this;
}
$this->body = $body;

return $this;
}

public function setModelId($model_id): static
{
if (is_null($model_id)) {
return $this;
}
$this->model_id = $model_id;

return $this;
}
}
Loading

0 comments on commit e096386

Please sign in to comment.