From ba0e38154e52356663c4fb63395a4784c444d96e Mon Sep 17 00:00:00 2001 From: dblock Date: Fri, 16 Aug 2024 03:37:16 +0000 Subject: [PATCH] Updated opensearch-php to reflect the latest OpenSearch API spec (2024-08-16) Signed-off-by: GitHub --- CHANGELOG.md | 1 + src/OpenSearch/Endpoints/Ml/DeployModel.php | 47 ++++---- src/OpenSearch/Endpoints/Ml/UndeployModel.php | 47 ++++---- .../Endpoints/Security/ConfigUpgradeCheck.php | 2 +- .../Security/ConfigUpgradePerform.php | 2 +- .../Endpoints/Security/GetAllCertificates.php | 47 ++++++++ .../Security/GetNodeCertificates.php | 64 +++++++++++ .../Endpoints/Security/PostDashboardsInfo.php | 10 -- .../Namespaces/SecurityNamespace.php | 105 +++++++++++++----- 9 files changed, 245 insertions(+), 80 deletions(-) create mode 100644 src/OpenSearch/Endpoints/Security/GetAllCertificates.php create mode 100644 src/OpenSearch/Endpoints/Security/GetNodeCertificates.php diff --git a/CHANGELOG.md b/CHANGELOG.md index fd78e7b6..51f92854 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Removed ### Fixed ### Updated APIs +- Updated opensearch-php APIs to reflect [opensearch-api-specification@3b02ba3](https://github.com/opensearch-project/opensearch-api-specification/commit/3b02ba3af21935c0c17c2e7e307c766697f42e93) - Updated opensearch-php APIs to reflect [opensearch-api-specification@cb320b5](https://github.com/opensearch-project/opensearch-api-specification/commit/cb320b5482551c4f28afa26ff0d1653332699722) ### Security ### Dependencies diff --git a/src/OpenSearch/Endpoints/Ml/DeployModel.php b/src/OpenSearch/Endpoints/Ml/DeployModel.php index ba181822..0d9cf4cb 100644 --- a/src/OpenSearch/Endpoints/Ml/DeployModel.php +++ b/src/OpenSearch/Endpoints/Ml/DeployModel.php @@ -16,36 +16,45 @@ use OpenSearch\Common\Exceptions\RuntimeException; use OpenSearch\Endpoints\AbstractEndpoint; +/** + * NOTE: This file is autogenerated using util/GenerateEndpoints.php + */ class DeployModel 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/_deploy"; + $model_id = $this->model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/models/$model_id/_deploy"; } + throw new RuntimeException('Missing parameter for the endpoint ml.deploy_model'); + } - throw new RuntimeException( - 'id is required for deploy' - ); - + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; } - /** - * @return string - */ public function getMethod(): string { return 'POST'; } + + public function setModelId($model_id): DeployModel + { + if (isset($model_id) !== true) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } } diff --git a/src/OpenSearch/Endpoints/Ml/UndeployModel.php b/src/OpenSearch/Endpoints/Ml/UndeployModel.php index 1b9dd7fd..2dd63058 100644 --- a/src/OpenSearch/Endpoints/Ml/UndeployModel.php +++ b/src/OpenSearch/Endpoints/Ml/UndeployModel.php @@ -16,36 +16,45 @@ use OpenSearch\Common\Exceptions\RuntimeException; use OpenSearch\Endpoints\AbstractEndpoint; +/** + * NOTE: This file is autogenerated using util/GenerateEndpoints.php + */ class UndeployModel 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/_undeploy"; + $model_id = $this->model_id ?? null; + if (isset($model_id)) { + return "/_plugins/_ml/models/$model_id/_undeploy"; } + throw new RuntimeException('Missing parameter for the endpoint ml.undeploy_model'); + } - throw new RuntimeException( - 'id is required for undeploy' - ); - + public function getParamWhitelist(): array + { + return [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; } - /** - * @return string - */ public function getMethod(): string { return 'POST'; } + + public function setModelId($model_id): UndeployModel + { + if (isset($model_id) !== true) { + return $this; + } + $this->model_id = $model_id; + + return $this; + } } diff --git a/src/OpenSearch/Endpoints/Security/ConfigUpgradeCheck.php b/src/OpenSearch/Endpoints/Security/ConfigUpgradeCheck.php index 7f105c3d..217d9978 100644 --- a/src/OpenSearch/Endpoints/Security/ConfigUpgradeCheck.php +++ b/src/OpenSearch/Endpoints/Security/ConfigUpgradeCheck.php @@ -24,7 +24,7 @@ class ConfigUpgradeCheck extends AbstractEndpoint { public function getURI(): string { - return "/_plugins/_security/_upgrade_check"; + return "/_plugins/_security/api/_upgrade_check"; } public function getParamWhitelist(): array diff --git a/src/OpenSearch/Endpoints/Security/ConfigUpgradePerform.php b/src/OpenSearch/Endpoints/Security/ConfigUpgradePerform.php index 25425359..ad049f47 100644 --- a/src/OpenSearch/Endpoints/Security/ConfigUpgradePerform.php +++ b/src/OpenSearch/Endpoints/Security/ConfigUpgradePerform.php @@ -24,7 +24,7 @@ class ConfigUpgradePerform extends AbstractEndpoint { public function getURI(): string { - return "/_plugins/_security/_upgrade_perform"; + return "/_plugins/_security/api/_upgrade_perform"; } public function getParamWhitelist(): array diff --git a/src/OpenSearch/Endpoints/Security/GetAllCertificates.php b/src/OpenSearch/Endpoints/Security/GetAllCertificates.php new file mode 100644 index 00000000..06b5fd43 --- /dev/null +++ b/src/OpenSearch/Endpoints/Security/GetAllCertificates.php @@ -0,0 +1,47 @@ +node_id ?? null; + if (isset($node_id)) { + return "/_plugins/_security/api/certificates/$node_id"; + } + throw new RuntimeException('Missing parameter for the endpoint security.get_node_certificates'); + } + + public function getParamWhitelist(): array + { + return [ + 'cert_type', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ]; + } + + public function getMethod(): string + { + return 'GET'; + } + + public function setNodeId($node_id): GetNodeCertificates + { + if (isset($node_id) !== true) { + return $this; + } + $this->node_id = $node_id; + + return $this; + } +} diff --git a/src/OpenSearch/Endpoints/Security/PostDashboardsInfo.php b/src/OpenSearch/Endpoints/Security/PostDashboardsInfo.php index 75bff211..87fff406 100644 --- a/src/OpenSearch/Endpoints/Security/PostDashboardsInfo.php +++ b/src/OpenSearch/Endpoints/Security/PostDashboardsInfo.php @@ -42,14 +42,4 @@ public function getMethod(): string { return 'POST'; } - - public function setBody($body): PostDashboardsInfo - { - if (isset($body) !== true) { - return $this; - } - $this->body = $body; - - return $this; - } } diff --git a/src/OpenSearch/Namespaces/SecurityNamespace.php b/src/OpenSearch/Namespaces/SecurityNamespace.php index bf7a5937..a804ce9b 100644 --- a/src/OpenSearch/Namespaces/SecurityNamespace.php +++ b/src/OpenSearch/Namespaces/SecurityNamespace.php @@ -178,7 +178,7 @@ public function createUpdateTenancyConfig(array $params = []) /** * Creates or replaces the specified user. Legacy API. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user to be created. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -204,7 +204,7 @@ public function createUserLegacy(array $params = []) /** * Delete a specified action group. * - * $params['action_group'] = (string) Action group to delete. (Required) + * $params['action_group'] = (string) The name of the action group to delete. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -228,7 +228,7 @@ public function deleteActionGroup(array $params = []) /** * Deletes all distinguished names in the specified cluster or node allow list. Only accessible to super-admins and with rest-api permissions when enabled. * - * $params['cluster_name'] = (string) (Required) + * $params['cluster_name'] = (string) The cluster-name to delete from list of distinguished names. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -252,7 +252,7 @@ public function deleteDistinguishedName(array $params = []) /** * Delete the specified role. * - * $params['role'] = (string) (Required) + * $params['role'] = (string) The name of the role to delete. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -276,7 +276,7 @@ public function deleteRole(array $params = []) /** * Deletes the specified role mapping. * - * $params['role'] = (string) (Required) + * $params['role'] = (string) The name of the role whose mapping needs to delete. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -300,7 +300,7 @@ public function deleteRoleMapping(array $params = []) /** * Delete the specified tenant. * - * $params['tenant'] = (string) (Required) + * $params['tenant'] = (string) The name of the tenant to delete. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -324,7 +324,7 @@ public function deleteTenant(array $params = []) /** * Delete the specified user. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user to delete. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -348,7 +348,7 @@ public function deleteUser(array $params = []) /** * Delete the specified user. Legacy API. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user to delete. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -415,7 +415,7 @@ public function generateOboToken(array $params = []) /** * Generates authorization token for the given user. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user for whom an auth token is to be vended. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -437,9 +437,9 @@ public function generateUserToken(array $params = []) return $this->performRequest($endpoint); } /** - * Generates authorization token for the given user. Legacy API. + * Generates authorization token for the given user. Legacy API. Not Implemented. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user for whom an auth token is to be vended. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -483,7 +483,7 @@ public function getAccountDetails(array $params = []) /** * Retrieves one action group. * - * $params['action_group'] = (string) Action group to retrieve. (Required) + * $params['action_group'] = (string) The name of the action group to retrieve. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -504,6 +504,28 @@ public function getActionGroup(array $params = []) return $this->performRequest($endpoint); } + /** + * Retrieves the cluster security certificates. + * + * $params['cert_type'] = (string) The type of certificates (HTTP, TRANSPORT, ALL) to retrieve from all nodes. + * $params['timeout'] = (string) The maximum duration, in seconds, to be spent to retrieve certificates from all nodes. + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * $params['filter_path'] = (any) Comma-separated list of filters used to reduce the response. + * + * @param array $params Associative array of parameters + * @return array + */ + public function getAllCertificates(array $params = []) + { + $endpointBuilder = $this->endpoints; + $endpoint = $endpointBuilder('Security\GetAllCertificates'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } /** * Retrieves the current list of allowed API accessible to normal user. * @@ -607,8 +629,8 @@ public function getDashboardsInfo(array $params = []) /** * Retrieves distinguished names. Only accessible to super-admins and with rest-api permissions when enabled. * - * $params['cluster_name'] = (string) (Required) - * $params['show_all'] = (boolean) + * $params['cluster_name'] = (string) The cluster-name to retrieve nodes DN setting for. (Required) + * $params['show_all'] = (boolean) A boolean flag to include/exclude static nodes DN from final result. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -629,6 +651,32 @@ public function getDistinguishedName(array $params = []) return $this->performRequest($endpoint); } + /** + * Retrieves the given node's security certificates. + * + * $params['node_id'] = (string) The full-id of the node to retrieve certificates. + * $params['cert_type'] = (string) The type of certificates (HTTP, TRANSPORT, ALL) to retrieve for a node. + * $params['timeout'] = (string) The maximum duration, in seconds, to be spent to retrieve a node's certificates. + * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. + * $params['human'] = (boolean) Whether to return human readable values for statistics. + * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. + * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + * $params['filter_path'] = (any) Comma-separated list of filters used to reduce the response. + * + * @param array $params Associative array of parameters + * @return array + */ + public function getNodeCertificates(array $params = []) + { + $node_id = $this->extractArgument($params, 'node_id'); + + $endpointBuilder = $this->endpoints; + $endpoint = $endpointBuilder('Security\GetNodeCertificates'); + $endpoint->setParams($params); + $endpoint->setNodeId($node_id); + + return $this->performRequest($endpoint); + } /** * Gets the evaluated REST API permissions for the currently logged in user. * @@ -700,7 +748,7 @@ public function getRoleMapping(array $params = []) /** * Retrieves the SSL configuration information. * - * $params['show_dn'] = (string) The domain names from all certificates. + * $params['show_dn'] = (Array) A boolean flag to indicate whether all domain names should be returned. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -741,7 +789,7 @@ public function getTenancyConfig(array $params = []) /** * Retrieves one tenant. * - * $params['tenant'] = (string) (Required) + * $params['tenant'] = (string) The name of the tenant to retrieve. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -765,7 +813,7 @@ public function getTenant(array $params = []) /** * Retrieve one internal user. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user to retrieve. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -789,7 +837,7 @@ public function getUser(array $params = []) /** * Retrieve one user. Legacy API. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user to retrieve. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -833,7 +881,7 @@ public function getUsersLegacy(array $params = []) /** * Checks to see if the Security plugin is up and running. * - * $params['mode'] = (string) + * $params['mode'] = (string) A flag to indicate whether service should consider security-plugin's status before returning health response. `strict` mode indicates service should check security plugin status. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -874,7 +922,7 @@ public function migrate(array $params = []) /** * Updates individual attributes of an action group. * - * $params['action_group'] = (string) (Required) + * $params['action_group'] = (string) The name of the action group to update. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -969,7 +1017,7 @@ public function patchConfiguration(array $params = []) /** * Updates a distinguished cluster name for a specific cluster. Only accessible to super-admins and with rest-api permissions when enabled. * - * $params['cluster_name'] = (string) (Required) + * $params['cluster_name'] = (string) The cluster-name to update nodesDn value. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -1018,7 +1066,7 @@ public function patchDistinguishedNames(array $params = []) /** * Updates individual attributes of a role. * - * $params['role'] = (string) (Required) + * $params['role'] = (string) The name of the role to update. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -1044,7 +1092,7 @@ public function patchRole(array $params = []) /** * Updates individual attributes of a role mapping. * - * $params['role'] = (string) (Required) + * $params['role'] = (string) The name of the role to update role-mapping for. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -1070,7 +1118,7 @@ public function patchRoleMapping(array $params = []) /** * Add, delete, or modify a single tenant. * - * $params['tenant'] = (string) (Required) + * $params['tenant'] = (string) The name of the tenant to update. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -1096,7 +1144,7 @@ public function patchTenant(array $params = []) /** * Updates individual attributes of an internal user. * - * $params['username'] = (string) (Required) + * $params['username'] = (string) The name of the user to update. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -1133,12 +1181,9 @@ public function patchUser(array $params = []) */ public function postDashboardsInfo(array $params = []) { - $body = $this->extractArgument($params, 'body'); - $endpointBuilder = $this->endpoints; $endpoint = $endpointBuilder('Security\PostDashboardsInfo'); $endpoint->setParams($params); - $endpoint->setBody($body); return $this->performRequest($endpoint); } @@ -1251,7 +1296,7 @@ public function updateConfiguration(array $params = []) /** * Adds or updates the specified distinguished names in the cluster or node allow list. Only accessible to super-admins and with rest-api permissions when enabled. * - * $params['cluster_name'] = (string) (Required) + * $params['cluster_name'] = (string) The cluster-name to create/update nodesDn value for. (Required) * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. @@ -1277,7 +1322,7 @@ public function updateDistinguishedName(array $params = []) /** * Checks whether the v6 security configuration is valid and ready to be migrated to v7. * - * $params['accept_invalid'] = (boolean) + * $params['accept_invalid'] = (boolean) A boolean flag to indicate whether invalid v6 configuration should be allowed. * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. * $params['human'] = (boolean) Whether to return human readable values for statistics. * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors.