From 27614111c3edb40b797da47e483a03c85710ec6e Mon Sep 17 00:00:00 2001 From: kalyanr Date: Tue, 16 Apr 2024 05:27:29 +0530 Subject: [PATCH] update validators --- opensearch_py_ml/ml_commons/stats.py | 22 ---------------------- opensearch_py_ml/ml_commons/validators.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 22 deletions(-) delete mode 100644 opensearch_py_ml/ml_commons/stats.py diff --git a/opensearch_py_ml/ml_commons/stats.py b/opensearch_py_ml/ml_commons/stats.py deleted file mode 100644 index a2c4c8f7..00000000 --- a/opensearch_py_ml/ml_commons/stats.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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. -# Any modifications Copyright OpenSearch Contributors. See -# GitHub history for details. - -"""Module for validating Stats API parameters """ - - -def validate_stats_input(node_id, stat_id, payload): - if payload: - if node_id or stat_id: - raise ValueError( - "Stats API does not accept node_id or stat_id with payload" - ) - if payload is not None and not isinstance(payload, dict): - raise ValueError("payload needs to be a dictionary or None") - if node_id is not None and not isinstance(node_id, str): - raise ValueError("node_id needs to be a string or None") - if stat_id is not None and not isinstance(stat_id, str): - raise ValueError("stat_id needs to be a string or None") diff --git a/opensearch_py_ml/ml_commons/validators.py b/opensearch_py_ml/ml_commons/validators.py index 4224165c..685cc0bd 100644 --- a/opensearch_py_ml/ml_commons/validators.py +++ b/opensearch_py_ml/ml_commons/validators.py @@ -103,3 +103,17 @@ def validate_profile_input(path_parameter, payload): if payload is not None and not isinstance(payload, dict): raise ValueError("payload needs to be a dictionary or None") + + +def validate_stats_input(node_id, stat_id, payload): + if payload: + if node_id or stat_id: + raise ValueError( + "Stats API does not accept node_id or stat_id with payload" + ) + if payload is not None and not isinstance(payload, dict): + raise ValueError("payload needs to be a dictionary or None") + if node_id is not None and not isinstance(node_id, str): + raise ValueError("node_id needs to be a string or None") + if stat_id is not None and not isinstance(stat_id, str): + raise ValueError("stat_id needs to be a string or None")