File size: 1,441 Bytes
46eae16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import requests
import lib.ui.util.CONFIG as CONFIG

def fn_create_vector_store(ip_file_name:str, ip_domain:str):
  # Endpoint URL
  lv_url = CONFIG.VECTOR_STORE_API_URL 
  
  # Payload
  lv_payload = {'domain': ip_domain}
  lv_files=[
    ('file',
     (
      ip_file_name,
      open(ip_file_name,'rb'),
      'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
     )
    )
  ]
  lv_headers = {}
  
  try:
    # Send POST request to the API
    lv_response = requests.request("POST", lv_url, headers=lv_headers, data=lv_payload, files=lv_files)
    
    # Print the response JSON
    return lv_response
    
  except Exception as e:
    # Handle any request exceptions
    print(f"An error occurred: {e}")
    raise e


def fn_create_data_mapping(ip_file_name:str, ip_source_domain:str):
  # Endpoint URL
  lv_url = CONFIG.MAPPING_API_URL 
  
  # Payload
  lv_payload = {'source_domain': ip_source_domain}
  lv_files=[
    ('file',
     (
      ip_file_name,
      open(ip_file_name,'rb'),
      'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
     )
    )
  ]
  lv_headers = {}
  
  try:
    # Send POST request to the API
    lv_response = requests.request("POST", lv_url, headers=lv_headers, data=lv_payload, files=lv_files)
    
    # Print the response JSON
    return lv_response
    
  except Exception as e:
    # Handle any request exceptions
    print(f"An error occurred: {e}")
    raise e