|
12 | 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | 13 | # See the License for the specific language governing permissions and |
14 | 14 | # limitations under the License. |
| 15 | +from enum import Enum |
| 16 | +from typing import Dict, List |
| 17 | + |
15 | 18 | from pydantic import BaseModel, Field |
16 | 19 |
|
17 | 20 |
|
18 | 21 | class CreateApiTokenRequest(BaseModel): |
19 | 22 | WorkspaceID: str = Field( |
20 | | - title="工作空间 ID", |
21 | | - description="工作空间 ID", |
22 | | - example="wcxxxxxxxxxxxxxxxxxxx" |
| 23 | + title="工作空间 ID", description="工作空间 ID", example="wcxxxxxxxxxxxxxxxxxxx" |
23 | 24 | ) |
24 | 25 | CustomAppID: str = Field( |
25 | 26 | title="自定义应用 ID", |
26 | 27 | description="自定义应用 ID", |
27 | | - example="appxxxxxxxxxxxxxxxxxxx" |
| 28 | + example="appxxxxxxxxxxxxxxxxxxx", |
28 | 29 | ) |
29 | 30 |
|
30 | 31 |
|
31 | 32 | class CreateApiTokenResponse(BaseModel): |
32 | 33 | Token: str = Field( |
33 | | - title="API Token", |
34 | | - description="API Token", |
35 | | - example="wcxxxxxxxxxxxxxxxxxxx" |
| 34 | + title="API Token", description="API Token", example="wcxxxxxxxxxxxxxxxxxxx" |
36 | 35 | ) |
37 | 36 | ExpiresIn: int = Field( |
38 | | - title="有效时间", |
39 | | - description="有效时间,单位为秒", |
40 | | - example=3600 |
| 37 | + title="有效时间", description="有效时间,单位为秒", example=3600 |
| 38 | + ) |
| 39 | + |
| 40 | + |
| 41 | +class ListTraceSpansRequestSortBy(str, Enum): |
| 42 | + StartTime = "StartTime" |
| 43 | + Latency = "Latency" |
| 44 | + LatencyFirstResp = "LatencyFirstResp" |
| 45 | + TotalTokens = "TotalTokens" |
| 46 | + |
| 47 | + |
| 48 | +class SortOrderType(str, Enum): |
| 49 | + Desc = "Desc" |
| 50 | + Asc = "Asc" |
| 51 | + |
| 52 | + |
| 53 | +class ListTraceSpansRequestSort(BaseModel): |
| 54 | + SortOrder: SortOrderType = Field( |
| 55 | + title="排序顺序", description="排序顺序", example=SortOrderType.Desc |
| 56 | + ) |
| 57 | + SortBy: ListTraceSpansRequestSortBy = Field( |
| 58 | + title="排序字段", |
| 59 | + description="排序字段", |
| 60 | + example=ListTraceSpansRequestSortBy.StartTime, |
| 61 | + ) |
| 62 | + |
| 63 | + |
| 64 | +class ListTraceSpansRequest(BaseModel): |
| 65 | + WorkspaceID: str = Field( |
| 66 | + title="工作空间 ID", description="工作空间 ID", example="wcxxxxxxxxxxxxxxxxxxx" |
| 67 | + ) |
| 68 | + PageSize: int = Field(title="分页大小", description="分页大小", example=10) |
| 69 | + LastID: str = Field( |
| 70 | + title="上一页最后一条记录的 ID", |
| 71 | + description="上一页最后一条记录的 ID", |
| 72 | + example="xxxxxxxxxxxxxxxxxxx", |
| 73 | + ) |
| 74 | + Sort: List[ListTraceSpansRequestSort] = Field( |
| 75 | + title="排序条件", |
| 76 | + description="排序条件", |
| 77 | + example=[ |
| 78 | + { |
| 79 | + "SortOrder": SortOrderType.Desc, |
| 80 | + "SortBy": ListTraceSpansRequestSortBy.StartTime, |
| 81 | + } |
| 82 | + ], |
| 83 | + ) |
| 84 | + |
| 85 | + |
| 86 | +class TraceSpanContext(BaseModel): |
| 87 | + TraceID: str = Field( |
| 88 | + title="Trace ID", |
| 89 | + description="Trace ID", |
| 90 | + example="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", |
| 91 | + ) |
| 92 | + SpanID: str = Field( |
| 93 | + title="Span ID", |
| 94 | + description="Span ID", |
| 95 | + example="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", |
| 96 | + ) |
| 97 | + ParentSpanID: str = Field( |
| 98 | + title="Parent Span ID", |
| 99 | + description="Parent Span ID", |
| 100 | + example="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", |
| 101 | + ) |
| 102 | + |
| 103 | + |
| 104 | +class TraceSpanStatusCode(str, Enum): |
| 105 | + Unset = "UNSET" |
| 106 | + OK = "OK" |
| 107 | + Error = "ERROR" |
| 108 | + Unknown = "UNKNOWN" |
| 109 | + Cancelled = "CANCELLED" |
| 110 | + |
| 111 | + |
| 112 | +class TraceSpanStatus(BaseModel): |
| 113 | + Code: TraceSpanStatusCode = Field( |
| 114 | + title="状态码", |
| 115 | + description="状态码", |
| 116 | + ) |
| 117 | + Message: str = Field( |
| 118 | + title="状态信息", |
| 119 | + description="状态信息", |
| 120 | + ) |
| 121 | + |
| 122 | + |
| 123 | +class TraceSpanItem(BaseModel): |
| 124 | + DocID: str = Field( |
| 125 | + title="文档 ID", |
| 126 | + description="文档 ID", |
| 127 | + example="xxxxxxxxxxxxxxxxxxx", |
| 128 | + ) |
| 129 | + Context: TraceSpanContext = Field( |
| 130 | + title="Span 上下文信息", |
| 131 | + description="Span 上下文信息", |
| 132 | + ) |
| 133 | + Name: str = Field( |
| 134 | + title="Span 名称", |
| 135 | + description="Span 名称", |
| 136 | + ) |
| 137 | + Status: TraceSpanStatus = Field( |
| 138 | + title="Span 状态信息", |
| 139 | + description="Span 状态信息", |
| 140 | + ) |
| 141 | + StartTime: str = Field( |
| 142 | + title="Span 开始时间", |
| 143 | + description="Span 开始时间", |
| 144 | + ) |
| 145 | + EndTime: str = Field( |
| 146 | + title="Span 结束时间", |
| 147 | + description="Span 结束时间", |
| 148 | + ) |
| 149 | + Attributes: Dict[str, str] = Field( |
| 150 | + title="Span 属性信息", |
| 151 | + description="Span 属性信息", |
| 152 | + ) |
| 153 | + Resource: Dict[str, str] = Field( |
| 154 | + title="Span 资源信息", |
| 155 | + description="Span 资源信息", |
| 156 | + ) |
| 157 | + |
| 158 | + |
| 159 | +class ListTraceSpansResponse(BaseModel): |
| 160 | + Total: int = Field( |
| 161 | + title="总记录数", |
| 162 | + description="总记录数", |
| 163 | + example=1, |
| 164 | + ) |
| 165 | + HasMore: bool = Field( |
| 166 | + title="是否有更多数据", |
| 167 | + description="是否有更多数据", |
| 168 | + example=False, |
| 169 | + ) |
| 170 | + Items: List[TraceSpanItem] = Field( |
| 171 | + title="Span 列表", |
| 172 | + description="Span 列表", |
41 | 173 | ) |
0 commit comments