Skip to content

Commit 6a17773

Browse files
reduce redundancy, params and data separate
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent c0b63b2 commit 6a17773

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/databricks/sql/backend/utils/http_client.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ def _get_auth_headers(self) -> Dict[str, str]:
8888
return headers
8989

9090
def _make_request(
91-
self, method: str, path: str, data: Optional[Dict[str, Any]] = None
91+
self,
92+
method: str,
93+
path: str,
94+
data: Optional[Dict[str, Any]] = None,
95+
params: Optional[Dict[str, Any]] = None,
9296
) -> Dict[str, Any]:
9397
"""
9498
Make an HTTP request to the SEA endpoint.
@@ -97,6 +101,7 @@ def _make_request(
97101
method: HTTP method (GET, POST, DELETE)
98102
path: API endpoint path
99103
data: Request payload data
104+
params: Query parameters
100105
101106
Returns:
102107
Dict[str, Any]: Response data parsed from JSON
@@ -111,12 +116,18 @@ def _make_request(
111116
logger.debug(f"making {method} request to {url}")
112117

113118
try:
119+
kwargs = {
120+
"url": url,
121+
"headers": headers,
122+
"json": data,
123+
"params": params,
124+
}
114125
if method.upper() == "GET":
115-
response = self.session.get(url, headers=headers, params=data)
126+
response = self.session.get(**kwargs)
116127
elif method.upper() == "POST":
117-
response = self.session.post(url, headers=headers, json=data)
128+
response = self.session.post(**kwargs)
118129
elif method.upper() == "DELETE":
119-
response = self.session.delete(url, headers=headers, params=data)
130+
response = self.session.delete(**kwargs)
120131
else:
121132
raise ValueError(f"Unsupported HTTP method: {method}")
122133

0 commit comments

Comments
 (0)