33 lines
1.1 KiB
Python
Raw Normal View History

2024-04-18 17:33:32 +08:00
import os
import requests
class BaseRequest:
2024-10-11 11:35:01 +08:00
proxies = {
2024-12-24 18:38:51 +08:00
"http": "",
"https": "",
2024-10-11 11:35:01 +08:00
}
base_url = ""
secret_key = ""
secret_key_header = ""
2024-10-11 11:35:01 +08:00
2024-04-18 17:33:32 +08:00
@classmethod
def send_request(cls, method, endpoint, json=None, params=None):
headers = {"Content-Type": "application/json", cls.secret_key_header: cls.secret_key}
2024-10-22 15:56:53 +08:00
url = f"{cls.base_url}{endpoint}"
2024-10-11 11:35:01 +08:00
response = requests.request(method, url, json=json, params=params, headers=headers, proxies=cls.proxies)
2024-04-18 17:33:32 +08:00
return response.json()
class EnterpriseRequest(BaseRequest):
base_url = os.environ.get("ENTERPRISE_API_URL", "ENTERPRISE_API_URL")
secret_key = os.environ.get("ENTERPRISE_API_SECRET_KEY", "ENTERPRISE_API_SECRET_KEY")
secret_key_header = "Enterprise-Api-Secret-Key"
class EnterprisePluginManagerRequest(BaseRequest):
base_url = os.environ.get("ENTERPRISE_PLUGIN_MANAGER_API_URL", "ENTERPRISE_PLUGIN_MANAGER_API_URL")
secret_key = os.environ.get("ENTERPRISE_PLUGIN_MANAGER_API_SECRET_KEY", "ENTERPRISE_PLUGIN_MANAGER_API_SECRET_KEY")
secret_key_header = "Plugin-Manager-Inner-Api-Secret-Key"