Skip to content

Commit 5f49bbc

Browse files
committed
Merge branch 'm-kovalsky/870-2'
2 parents 507b9ff + 68b1c5a commit 5f49bbc

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/sempy_labs/_sql_endpoints.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,25 @@ def refresh_sql_endpoint_metadata(
128128
else:
129129
raise ValueError("Invalid type. Must be 'Lakehouse' or 'MirroredDatabase'.")
130130

131-
payload = None
132131
timeout_unit = timeout_unit.capitalize()
133-
if timeout_unit != "Minutes" and timeout_value != 15:
134-
payload = {"timeout": {"timeUnit": timeout_unit, "value": timeout_value}}
132+
if timeout_unit not in ["Seconds", "Minutes", "Hours", "Days"]:
133+
raise ValueError(
134+
"Invalid timeout_unit. Must be 'Seconds', 'Minutes', 'Hours', or 'Days'."
135+
)
136+
if timeout_unit == "Hours" and timeout_value > 24:
137+
raise ValueError("timeout_value cannot exceed 24 when timeout_unit is 'Hours'.")
138+
if timeout_unit == "Days" and timeout_value > 1:
139+
raise ValueError("timeout_value cannot exceed 1 when timeout_unit is 'Days'.")
140+
if timeout_unit == "Minutes" and timeout_value > 1440:
141+
raise ValueError(
142+
"timeout_value cannot exceed 1440 when timeout_unit is 'Minutes'."
143+
)
144+
if timeout_unit == "Seconds" and timeout_value > 86400:
145+
raise ValueError(
146+
"timeout_value cannot exceed 86400 when timeout_unit is 'Seconds'."
147+
)
148+
149+
payload = {"timeout": {"timeUnit": timeout_unit, "value": timeout_value}}
135150

136151
result = _base_api(
137152
request=f"v1/workspaces/{workspace_id}/sqlEndpoints/{sql_endpoint_id}/refreshMetadata",

0 commit comments

Comments
 (0)