rahgadda commited on
Commit
46eae16
·
verified ·
1 Parent(s): ea4fe04

Initial Draft

Browse files
Files changed (1) hide show
  1. lib/ui/apiClient/APIClient.py +61 -0
lib/ui/apiClient/APIClient.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import lib.ui.util.CONFIG as CONFIG
3
+
4
+ def fn_create_vector_store(ip_file_name:str, ip_domain:str):
5
+ # Endpoint URL
6
+ lv_url = CONFIG.VECTOR_STORE_API_URL
7
+
8
+ # Payload
9
+ lv_payload = {'domain': ip_domain}
10
+ lv_files=[
11
+ ('file',
12
+ (
13
+ ip_file_name,
14
+ open(ip_file_name,'rb'),
15
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
16
+ )
17
+ )
18
+ ]
19
+ lv_headers = {}
20
+
21
+ try:
22
+ # Send POST request to the API
23
+ lv_response = requests.request("POST", lv_url, headers=lv_headers, data=lv_payload, files=lv_files)
24
+
25
+ # Print the response JSON
26
+ return lv_response
27
+
28
+ except Exception as e:
29
+ # Handle any request exceptions
30
+ print(f"An error occurred: {e}")
31
+ raise e
32
+
33
+
34
+ def fn_create_data_mapping(ip_file_name:str, ip_source_domain:str):
35
+ # Endpoint URL
36
+ lv_url = CONFIG.MAPPING_API_URL
37
+
38
+ # Payload
39
+ lv_payload = {'source_domain': ip_source_domain}
40
+ lv_files=[
41
+ ('file',
42
+ (
43
+ ip_file_name,
44
+ open(ip_file_name,'rb'),
45
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
46
+ )
47
+ )
48
+ ]
49
+ lv_headers = {}
50
+
51
+ try:
52
+ # Send POST request to the API
53
+ lv_response = requests.request("POST", lv_url, headers=lv_headers, data=lv_payload, files=lv_files)
54
+
55
+ # Print the response JSON
56
+ return lv_response
57
+
58
+ except Exception as e:
59
+ # Handle any request exceptions
60
+ print(f"An error occurred: {e}")
61
+ raise e