fiuai-sdk-python 0.2.6__tar.gz → 0.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/PKG-INFO +1 -1
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/pyproject.toml +1 -1
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/src/fiuai_sdk_python/client.py +30 -5
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/src/fiuai_sdk_python/util.py +0 -16
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/.gitignore +0 -0
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/CHANGELOG.md +0 -0
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/LICENSE +0 -0
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/README.md +0 -0
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/src/fiuai_sdk_python/__init__.py +0 -0
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/src/fiuai_sdk_python/bank.py +0 -0
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/src/fiuai_sdk_python/company.py +0 -0
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/src/fiuai_sdk_python/const.py +0 -0
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/src/fiuai_sdk_python/error.py +0 -0
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/src/fiuai_sdk_python/item.py +0 -0
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/src/fiuai_sdk_python/perm.py +0 -0
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/src/fiuai_sdk_python/setup.py +0 -0
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/src/fiuai_sdk_python/token.py +0 -0
- {fiuai_sdk_python-0.2.6 → fiuai_sdk_python-0.2.7}/src/fiuai_sdk_python/type.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fiuai_sdk_python
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: FiuAI Python SDK - 企业级AI服务集成开发工具包
|
|
5
5
|
Project-URL: Homepage, https://github.com/fiuai/fiuai-sdk-python
|
|
6
6
|
Project-URL: Documentation, https://github.com/fiuai/fiuai-sdk-python#readme
|
|
@@ -34,7 +34,16 @@ class FiuaiSDK(object):
|
|
|
34
34
|
self.username = username
|
|
35
35
|
|
|
36
36
|
self.auth_type = auth_type
|
|
37
|
-
self.headers =
|
|
37
|
+
self.headers = {
|
|
38
|
+
"Accept": "application/json",
|
|
39
|
+
"Fiuai-Internal-Auth": "false",
|
|
40
|
+
"Fiuai-Internal-Key": "",
|
|
41
|
+
"Fiuai-Internal-Secret": "",
|
|
42
|
+
"Fiuai-Internal-User": "",
|
|
43
|
+
"Fiuai-Internal-Tenant": "",
|
|
44
|
+
"Fiuai-Internal-Company": "",
|
|
45
|
+
"Fiuai-Internal-Current-Company": "",
|
|
46
|
+
}
|
|
38
47
|
self.verify = verify
|
|
39
48
|
self.url = url
|
|
40
49
|
self.max_api_retry = max_api_retry
|
|
@@ -50,12 +59,15 @@ class FiuaiSDK(object):
|
|
|
50
59
|
case "internal":
|
|
51
60
|
if token_key == "" or token_secret == "":
|
|
52
61
|
raise FiuaiGeneralError("Token key and secret are required")
|
|
53
|
-
self.headers =
|
|
62
|
+
self.headers["Fiuai-Internal-Auth"] = "true"
|
|
63
|
+
self.headers["Fiuai-Internal-Key"] = token_key
|
|
64
|
+
self.headers["Fiuai-Internal-Secret"] = token_secret
|
|
65
|
+
self.headers["Fiuai-Internal-User"] = username
|
|
54
66
|
case "password":
|
|
55
67
|
if username == "" or password == "":
|
|
56
68
|
raise FiuaiGeneralError("Username and password are required")
|
|
57
69
|
|
|
58
|
-
self.headers =
|
|
70
|
+
self.headers["Fiuai-Internal-Auth"] = "false"
|
|
59
71
|
self._login(username, password)
|
|
60
72
|
case _:
|
|
61
73
|
raise FiuaiGeneralError(f"Invalid auth type: {self.auth_type}")
|
|
@@ -71,6 +83,10 @@ class FiuaiSDK(object):
|
|
|
71
83
|
if r.json().get('message') == "Logged In":
|
|
72
84
|
self.can_download = []
|
|
73
85
|
logger.info(f"Login to {self.url} success")
|
|
86
|
+
|
|
87
|
+
### 获取cookie
|
|
88
|
+
self.headers["Fiuai-Internal-Company"] = r.cookies.get("current_company")
|
|
89
|
+
self.headers["Fiuai-Internal-Tenant"] = r.cookies.get("tenant")
|
|
74
90
|
return r.json()
|
|
75
91
|
else:
|
|
76
92
|
raise FiuaiAuthError(f"Login failed: {r.json().get('message')}")
|
|
@@ -96,14 +112,17 @@ class FiuaiSDK(object):
|
|
|
96
112
|
return self.post_process(r)
|
|
97
113
|
|
|
98
114
|
def swith_company(self, tenant: str = "", company: str = "") -> bool:
|
|
115
|
+
|
|
116
|
+
self.headers["Fiuai-Internal-Tenant"] = tenant
|
|
117
|
+
self.headers["Fiuai-Internal-Company"] = company
|
|
118
|
+
|
|
99
119
|
if company == "":
|
|
100
120
|
raise FiuaiAuthError("Company is required when using password auth")
|
|
101
121
|
|
|
102
122
|
if self.auth_type == "internal":
|
|
103
123
|
if tenant == "":
|
|
104
124
|
raise FiuaiAuthError("Tenant is required when using internal auth")
|
|
105
|
-
|
|
106
|
-
self.headers["Fiuai-Internal-Company"] = company
|
|
125
|
+
|
|
107
126
|
else:
|
|
108
127
|
r = self.client.post(self.url + "/api/method/frappe.sessions.change_current_company",
|
|
109
128
|
data={"auth_company_id": company})
|
|
@@ -113,6 +132,12 @@ class FiuaiSDK(object):
|
|
|
113
132
|
return False
|
|
114
133
|
else:
|
|
115
134
|
return True
|
|
135
|
+
|
|
136
|
+
def get_tenant(self) -> str:
|
|
137
|
+
return self.headers["Fiuai-Internal-Tenant"]
|
|
138
|
+
|
|
139
|
+
def get_company(self) -> str:
|
|
140
|
+
return self.headers["Fiuai-Internal-Company"]
|
|
116
141
|
|
|
117
142
|
def get_user_profile(self) -> UserProfile:
|
|
118
143
|
d = self.get_doc("User", self.username, fields=["name", "full_name", "email", "phone", "roles", "auth_tenant_id", "default_company_id"])
|
|
@@ -80,22 +80,6 @@ def get_client_config():
|
|
|
80
80
|
def is_initialized():
|
|
81
81
|
return _config.is_initialized()
|
|
82
82
|
|
|
83
|
-
def create_headers(key, secret, user, tenant="", company=""):
|
|
84
|
-
|
|
85
|
-
headers = {
|
|
86
|
-
"Fiuai-Internal-Auth": "true",
|
|
87
|
-
"Fiuai-Internal-Key": key,
|
|
88
|
-
"Fiuai-Internal-Secret": secret,
|
|
89
|
-
"Fiuai-Internal-User": user,
|
|
90
|
-
"Fiuai-Internal-Tenant": tenant,
|
|
91
|
-
"Fiuai-Internal-Company": company,
|
|
92
|
-
"Accept": "application/json",
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return headers
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
83
|
|
|
100
84
|
def init_fiuai(
|
|
101
85
|
url: str,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|