Skip to content

Commit

Permalink
update validators
Browse files Browse the repository at this point in the history
  • Loading branch information
rawwar committed Apr 15, 2024
1 parent 04a2f24 commit 2761411
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
22 changes: 0 additions & 22 deletions opensearch_py_ml/ml_commons/stats.py

This file was deleted.

14 changes: 14 additions & 0 deletions opensearch_py_ml/ml_commons/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 2761411

Please sign in to comment.