Skip to content

Commit 7ab2dca

Browse files
Abdullah AhmedAbdullah Ahmed
Abdullah Ahmed
authored and
Abdullah Ahmed
committed
add ca cert field to the bulk import functions
1 parent 87d5f48 commit 7ab2dca

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

Diff for: pymilvus/bulk_writer/bulk_import.py

+28-6
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,23 @@ def _handle_response(url: str, res: json):
4545

4646

4747
def _post_request(
48-
url: str, api_key: str, params: {}, timeout: int = 20, **kwargs
48+
url: str, api_key: str, params: {}, timeout: int = 20, cert_path: Optional[str] = None, **kwargs
4949
) -> requests.Response:
50+
"""Send a POST request with optional CA certificate verification
51+
52+
Args:
53+
url (str): The endpoint URL
54+
api_key (str): API key for authentication
55+
params (dict): JSON parameters for the request
56+
timeout (int): Timeout for the request
57+
cert_path (str, optional): Path to the CA certificate file
58+
59+
Returns:
60+
requests.Response: Response object.
61+
"""
5062
try:
5163
resp = requests.post(
52-
url=url, headers=_http_headers(api_key), json=params, timeout=timeout, **kwargs
64+
url=url, headers=_http_headers(api_key), json=params, timeout=timeout, verify=cert_path, **kwargs
5365
)
5466
if resp.status_code != 200:
5567
_throw(f"Failed to post url: {url}, status code: {resp.status_code}")
@@ -85,6 +97,7 @@ def bulk_import(
8597
api_key: str = "",
8698
access_key: str = "",
8799
secret_key: str = "",
100+
cert_path: Optional[str] = None,
88101
**kwargs,
89102
) -> requests.Response:
90103
"""call bulkinsert restful interface to import files
@@ -103,6 +116,7 @@ def bulk_import(
103116
api_key (str): API key to authenticate your requests.
104117
access_key (str): access key to access the object storage
105118
secret_key (str): secret key to access the object storage
119+
cert_path (str, optional): path to the CA certificate file
106120
107121
Returns:
108122
response of the restful interface
@@ -121,13 +135,18 @@ def bulk_import(
121135
"secretKey": secret_key,
122136
}
123137

124-
resp = _post_request(url=request_url, api_key=api_key, params=params, **kwargs)
138+
resp = _post_request(url=request_url, api_key=api_key, params=params, cert_path=cert_path, **kwargs)
125139
_handle_response(request_url, resp.json())
126140
return resp
127141

128142

129143
def get_import_progress(
130-
url: str, job_id: str, cluster_id: str = "", api_key: str = "", **kwargs
144+
url: str,
145+
job_id: str,
146+
cluster_id: str = "",
147+
api_key: str = "",
148+
cert_path: Optional[str] = None,
149+
**kwargs
131150
) -> requests.Response:
132151
"""get job progress
133152
@@ -136,6 +155,7 @@ def get_import_progress(
136155
job_id (str): a job id
137156
cluster_id (str): id of a milvus instance(for cloud)
138157
api_key (str): API key to authenticate your requests.
158+
cert_path (str, optional): path to the CA certificate file
139159
140160
Returns:
141161
response of the restful interface
@@ -147,7 +167,7 @@ def get_import_progress(
147167
"clusterId": cluster_id,
148168
}
149169

150-
resp = _post_request(url=request_url, api_key=api_key, params=params, **kwargs)
170+
resp = _post_request(url=request_url, api_key=api_key, params=params, cert_path=cert_path, **kwargs)
151171
_handle_response(request_url, resp.json())
152172
return resp
153173

@@ -159,6 +179,7 @@ def list_import_jobs(
159179
api_key: str = "",
160180
page_size: int = 10,
161181
current_page: int = 1,
182+
cert_path: Optional[str] = None,
162183
**kwargs,
163184
) -> requests.Response:
164185
"""list jobs in a cluster
@@ -170,6 +191,7 @@ def list_import_jobs(
170191
api_key (str): API key to authenticate your requests.
171192
page_size (int): pagination size
172193
current_page (int): pagination
194+
cert_path (str, optional): path to the CA certificate file
173195
174196
Returns:
175197
response of the restful interface
@@ -183,6 +205,6 @@ def list_import_jobs(
183205
"currentPage": current_page,
184206
}
185207

186-
resp = _post_request(url=request_url, api_key=api_key, params=params, **kwargs)
208+
resp = _post_request(url=request_url, api_key=api_key, params=params, cert_path=cert_path, **kwargs)
187209
_handle_response(request_url, resp.json())
188210
return resp

0 commit comments

Comments
 (0)