bella-openapi 1.0.0.4__py3-none-any.whl → 1.0.1__py3-none-any.whl
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.
- {bella_openapi-1.0.0.4.dist-info → bella_openapi-1.0.1.dist-info}/METADATA +9 -9
- {bella_openapi-1.0.0.4.dist-info → bella_openapi-1.0.1.dist-info}/RECORD +5 -5
- {bella_openapi-1.0.0.4.dist-info → bella_openapi-1.0.1.dist-info}/WHEEL +0 -0
- {bella_openapi-1.0.0.4.dist-info → bella_openapi-1.0.1.dist-info}/licenses/LICENSE +0 -0
- {bella_openapi-1.0.0.4.dist-info → bella_openapi-1.0.1.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: bella-openapi
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.1
|
4
4
|
Summary: client for openapi service.
|
5
5
|
Home-page:
|
6
6
|
Author: ['tangxiaolong', 'fanqiangwei', 'zhangxiaojia', 'liumin', 'wangyukun']
|
@@ -33,7 +33,7 @@ OpenAPI网关服务客户端
|
|
33
33
|
### 安装
|
34
34
|
|
35
35
|
```shell
|
36
|
-
pip install
|
36
|
+
pip install bella-openapi
|
37
37
|
```
|
38
38
|
|
39
39
|
### 配置网关域名
|
@@ -49,14 +49,14 @@ OPENAPI_CONSOLE_KEY = "************"
|
|
49
49
|
### 配置校验
|
50
50
|
|
51
51
|
```python
|
52
|
-
from
|
52
|
+
from bella_openapi import check_configuration
|
53
53
|
# 该函数判断是否所有配置ok,只有所有配置ok的情况下,才能调用鉴权计费等接口
|
54
54
|
config_is_ok = check_configuration()
|
55
55
|
```
|
56
56
|
### token校验
|
57
57
|
|
58
58
|
```python
|
59
|
-
from
|
59
|
+
from bella_openapi import validate_token, support_model, account_balance_enough
|
60
60
|
|
61
61
|
token = "****"
|
62
62
|
# 根据token,解析用户身份
|
@@ -84,7 +84,7 @@ balance = account_balance_enough(token, cost=1.0)
|
|
84
84
|
日志上报,将采用异步io的方式,上报操作日志,这种方式,可以在单线程中,同时处理多个并发非阻塞IO操作
|
85
85
|
|
86
86
|
```python
|
87
|
-
from
|
87
|
+
from bella_openapi import operation_log
|
88
88
|
|
89
89
|
|
90
90
|
@operation_log()
|
@@ -97,7 +97,7 @@ def safety_check(request, *, validate_output: bool):
|
|
97
97
|
操作日志记录,需要传递一些动态参数,需导入预定义的contextvar,在请求起始处进行设置, 请求结束时清空contextvar
|
98
98
|
|
99
99
|
```python
|
100
|
-
from
|
100
|
+
from bella_openapi import trace_id_context, caller_id_context, request_url_context
|
101
101
|
|
102
102
|
# 整个链路处理前,设置
|
103
103
|
t_token = trace_id_context.set("*********") # trace_id 当前请求链路唯一标识
|
@@ -116,7 +116,7 @@ request_url_context.reset(r_token)
|
|
116
116
|
如果当前url不需要进行拦截,可以配置exclude_path进行过滤
|
117
117
|
|
118
118
|
```python
|
119
|
-
from
|
119
|
+
from bella_openapi.middleware import HttpContextMiddleware, WebSocketHttpContextMiddleware
|
120
120
|
from fastapi import FastAPI
|
121
121
|
|
122
122
|
app = FastAPI()
|
@@ -169,7 +169,7 @@ t.join()
|
|
169
169
|
为了进行调用计费,如果当前操作日志中的信息,需要用于回调计费,则需要在装饰器中传入is_cost_log=True
|
170
170
|
|
171
171
|
```python
|
172
|
-
from
|
172
|
+
from bella_openapi import operation_log
|
173
173
|
|
174
174
|
|
175
175
|
@operation_log(op_type='safety_check', is_cost_log=False, ucid="ucid")
|
@@ -186,7 +186,7 @@ async def safety_check(request, *, validate_output: bool):
|
|
186
186
|
##### 4.1 调用submit_log方法
|
187
187
|
|
188
188
|
```python
|
189
|
-
from
|
189
|
+
from bella_openapi import submit_log
|
190
190
|
# construct log
|
191
191
|
log = ...
|
192
192
|
submit_log(log)
|
@@ -15,8 +15,8 @@ bella_openapi/console/__init__.py,sha256=yUP83l7Hp-5qWT7uZ4QZoDfeWx7AjRguWBbPPfV
|
|
15
15
|
bella_openapi/console/models.py,sha256=HWn7AitLt73Ag2ROyKoUHK34QWtwQ9s_Vz9Wu4IB3cQ,1316
|
16
16
|
bella_openapi/middleware/__init__.py,sha256=ZzvwJ9NjB7bKs3LtyVnTp8msHyxLVQoWcyAVmP0k-XA,160
|
17
17
|
bella_openapi/middleware/context_middleware.py,sha256=aMNwteZIdJymqWwmkYPw1qw9QwpoNrKRdV2ObUa7LKI,3972
|
18
|
-
bella_openapi-1.0.
|
19
|
-
bella_openapi-1.0.
|
20
|
-
bella_openapi-1.0.
|
21
|
-
bella_openapi-1.0.
|
22
|
-
bella_openapi-1.0.
|
18
|
+
bella_openapi-1.0.1.dist-info/licenses/LICENSE,sha256=56xiUFcFori4XRJ1nMyyS7DXMSjzaBKWRaZbqCffoY8,1075
|
19
|
+
bella_openapi-1.0.1.dist-info/METADATA,sha256=zd0ki4-luOZXywgBst2DvB_3Te0RC2Df608Z6JkUg0w,9578
|
20
|
+
bella_openapi-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
+
bella_openapi-1.0.1.dist-info/top_level.txt,sha256=EZuq3F6tKeF-vmZQi6_S2XzmES7SPW7HAbGN1Uv9vN8,14
|
22
|
+
bella_openapi-1.0.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|