|
12 | 12 | from migas.config import Config, logger, telemetry_enabled |
13 | 13 | from migas.request import request |
14 | 14 |
|
15 | | -class TextType(enum.Enum): |
16 | | - LITERAL = 1 |
17 | | - FREE = 2 |
| 15 | +class QueryParamType(enum.Enum): |
| 16 | + LITERAL = enum.auto() |
| 17 | + TEXT = enum.auto() |
18 | 18 |
|
19 | 19 | ERROR = '[migas-py] An error occurred.' |
20 | 20 |
|
@@ -52,23 +52,23 @@ class AddBreadcrumb(Operation): |
52 | 52 | operation_type = "mutation" |
53 | 53 | operation_name = "add_breadcrumb" |
54 | 54 | query_args = { |
55 | | - "project": TextType.FREE, |
56 | | - "project_version": TextType.FREE, |
57 | | - "language": TextType.FREE, |
58 | | - "language_version": TextType.FREE, |
| 55 | + "project": QueryParamType.TEXT, |
| 56 | + "project_version": QueryParamType.TEXT, |
| 57 | + "language": QueryParamType.TEXT, |
| 58 | + "language_version": QueryParamType.TEXT, |
59 | 59 | "ctx": { |
60 | | - "session_id": TextType.FREE, |
61 | | - "user_id": TextType.FREE, |
62 | | - "user_type": TextType.LITERAL, |
63 | | - "platform": TextType.FREE, |
64 | | - "container": TextType.LITERAL, |
65 | | - "is_ci": TextType.LITERAL, |
| 60 | + "session_id": QueryParamType.TEXT, |
| 61 | + "user_id": QueryParamType.TEXT, |
| 62 | + "user_type": QueryParamType.LITERAL, |
| 63 | + "platform": QueryParamType.TEXT, |
| 64 | + "container": QueryParamType.LITERAL, |
| 65 | + "is_ci": QueryParamType.LITERAL, |
66 | 66 | }, |
67 | 67 | "proc": { |
68 | | - "status": TextType.LITERAL, |
69 | | - "status_desc": TextType.FREE, |
70 | | - "error_type": TextType.FREE, |
71 | | - "error_desc": TextType.FREE, |
| 68 | + "status": QueryParamType.LITERAL, |
| 69 | + "status_desc": QueryParamType.TEXT, |
| 70 | + "error_type": QueryParamType.TEXT, |
| 71 | + "error_desc": QueryParamType.TEXT, |
72 | 72 | }, |
73 | 73 | } |
74 | 74 | fingerprint = True |
@@ -118,21 +118,21 @@ class AddProject(Operation): |
118 | 118 | operation_name = "add_project" |
119 | 119 | query_args = { |
120 | 120 | "p": { |
121 | | - "project": TextType.FREE, |
122 | | - "project_version": TextType.FREE, |
123 | | - "language": TextType.FREE, |
124 | | - "language_version": TextType.FREE, |
125 | | - "is_ci": TextType.LITERAL, |
126 | | - "status": TextType.LITERAL, |
127 | | - "status_desc": TextType.FREE, |
128 | | - "error_type": TextType.FREE, |
129 | | - "error_desc": TextType.FREE, |
130 | | - "user_id": TextType.FREE, |
131 | | - "session_id": TextType.FREE, |
132 | | - "container": TextType.LITERAL, |
133 | | - "user_type": TextType.LITERAL, |
134 | | - "platform": TextType.FREE, |
135 | | - "arguments": TextType.FREE, |
| 121 | + "project": QueryParamType.TEXT, |
| 122 | + "project_version": QueryParamType.TEXT, |
| 123 | + "language": QueryParamType.TEXT, |
| 124 | + "language_version": QueryParamType.TEXT, |
| 125 | + "is_ci": QueryParamType.LITERAL, |
| 126 | + "status": QueryParamType.LITERAL, |
| 127 | + "status_desc": QueryParamType.TEXT, |
| 128 | + "error_type": QueryParamType.TEXT, |
| 129 | + "error_desc": QueryParamType.TEXT, |
| 130 | + "user_id": QueryParamType.TEXT, |
| 131 | + "session_id": QueryParamType.TEXT, |
| 132 | + "container": QueryParamType.LITERAL, |
| 133 | + "user_type": QueryParamType.LITERAL, |
| 134 | + "platform": QueryParamType.TEXT, |
| 135 | + "arguments": QueryParamType.TEXT, |
136 | 136 | }, |
137 | 137 | } |
138 | 138 | fingerprint = True |
@@ -178,20 +178,20 @@ class CheckProject(Operation): |
178 | 178 | operation_type = "query" |
179 | 179 | operation_name = "check_project" |
180 | 180 | query_args = { |
181 | | - "project": TextType.FREE, |
182 | | - "project_version": TextType.FREE, |
183 | | - "language": TextType.FREE, |
184 | | - "language_version": TextType.FREE, |
185 | | - "is_ci": TextType.LITERAL, |
186 | | - "status": TextType.LITERAL, |
187 | | - "status_desc": TextType.FREE, |
188 | | - "error_type": TextType.FREE, |
189 | | - "error_desc": TextType.FREE, |
190 | | - "user_id": TextType.FREE, |
191 | | - "session_id": TextType.FREE, |
192 | | - "container": TextType.LITERAL, |
193 | | - "platform": TextType.FREE, |
194 | | - "arguments": TextType.FREE, |
| 181 | + "project": QueryParamType.TEXT, |
| 182 | + "project_version": QueryParamType.TEXT, |
| 183 | + "language": QueryParamType.TEXT, |
| 184 | + "language_version": QueryParamType.TEXT, |
| 185 | + "is_ci": QueryParamType.LITERAL, |
| 186 | + "status": QueryParamType.LITERAL, |
| 187 | + "status_desc": QueryParamType.TEXT, |
| 188 | + "error_type": QueryParamType.TEXT, |
| 189 | + "error_desc": QueryParamType.TEXT, |
| 190 | + "user_id": QueryParamType.TEXT, |
| 191 | + "session_id": QueryParamType.TEXT, |
| 192 | + "container": QueryParamType.LITERAL, |
| 193 | + "platform": QueryParamType.TEXT, |
| 194 | + "arguments": QueryParamType.TEXT, |
195 | 195 | } |
196 | 196 | selections = ('success', 'flagged', 'latest', 'message') |
197 | 197 |
|
@@ -220,10 +220,10 @@ class GetUsage(Operation): |
220 | 220 | operation_type = 'query' |
221 | 221 | operation_name = 'get_usage' |
222 | 222 | query_args = { |
223 | | - "project": TextType.FREE, |
224 | | - "start": TextType.FREE, |
225 | | - "end": TextType.FREE, |
226 | | - "unique": TextType.LITERAL, |
| 223 | + "project": QueryParamType.TEXT, |
| 224 | + "start": QueryParamType.TEXT, |
| 225 | + "end": QueryParamType.TEXT, |
| 226 | + "unique": QueryParamType.LITERAL, |
227 | 227 | } |
228 | 228 |
|
229 | 229 |
|
@@ -278,7 +278,7 @@ def _parse_format_params(params: dict, query_args: dict) -> str: |
278 | 278 | if isinstance(val, bool): |
279 | 279 | val = str(val).lower() |
280 | 280 |
|
281 | | - if qval.name == 'FREE': |
| 281 | + if qval.name == 'TEXT': |
282 | 282 | fval = json.dumps(val) |
283 | 283 | elif qval.name == 'LITERAL': |
284 | 284 | fval = val |
|
0 commit comments