@@ -45,11 +45,23 @@ def _handle_response(url: str, res: json):
45
45
46
46
47
47
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
49
49
) -> 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
+ """
50
62
try :
51
63
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
53
65
)
54
66
if resp .status_code != 200 :
55
67
_throw (f"Failed to post url: { url } , status code: { resp .status_code } " )
@@ -85,6 +97,7 @@ def bulk_import(
85
97
api_key : str = "" ,
86
98
access_key : str = "" ,
87
99
secret_key : str = "" ,
100
+ cert_path : Optional [str ] = None ,
88
101
** kwargs ,
89
102
) -> requests .Response :
90
103
"""call bulkinsert restful interface to import files
@@ -103,6 +116,7 @@ def bulk_import(
103
116
api_key (str): API key to authenticate your requests.
104
117
access_key (str): access key to access the object storage
105
118
secret_key (str): secret key to access the object storage
119
+ cert_path (str, optional): path to the CA certificate file
106
120
107
121
Returns:
108
122
response of the restful interface
@@ -121,13 +135,18 @@ def bulk_import(
121
135
"secretKey" : secret_key ,
122
136
}
123
137
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 )
125
139
_handle_response (request_url , resp .json ())
126
140
return resp
127
141
128
142
129
143
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
131
150
) -> requests .Response :
132
151
"""get job progress
133
152
@@ -136,6 +155,7 @@ def get_import_progress(
136
155
job_id (str): a job id
137
156
cluster_id (str): id of a milvus instance(for cloud)
138
157
api_key (str): API key to authenticate your requests.
158
+ cert_path (str, optional): path to the CA certificate file
139
159
140
160
Returns:
141
161
response of the restful interface
@@ -147,7 +167,7 @@ def get_import_progress(
147
167
"clusterId" : cluster_id ,
148
168
}
149
169
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 )
151
171
_handle_response (request_url , resp .json ())
152
172
return resp
153
173
@@ -159,6 +179,7 @@ def list_import_jobs(
159
179
api_key : str = "" ,
160
180
page_size : int = 10 ,
161
181
current_page : int = 1 ,
182
+ cert_path : Optional [str ] = None ,
162
183
** kwargs ,
163
184
) -> requests .Response :
164
185
"""list jobs in a cluster
@@ -170,6 +191,7 @@ def list_import_jobs(
170
191
api_key (str): API key to authenticate your requests.
171
192
page_size (int): pagination size
172
193
current_page (int): pagination
194
+ cert_path (str, optional): path to the CA certificate file
173
195
174
196
Returns:
175
197
response of the restful interface
@@ -183,6 +205,6 @@ def list_import_jobs(
183
205
"currentPage" : current_page ,
184
206
}
185
207
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 )
187
209
_handle_response (request_url , resp .json ())
188
210
return resp
0 commit comments