-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodels.rs
More file actions
157 lines (142 loc) · 4.45 KB
/
models.rs
File metadata and controls
157 lines (142 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
cfg_if::cfg_if! {
if #[cfg(feature = "default-server")] {
use executor::models::ColumnInfo as ColumnInfoModel;
}
}
use serde::{Deserialize, Serialize};
use serde_json::value::RawValue;
use std::collections::HashMap;
use uuid::Uuid;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LoginRequestQueryParams {
#[serde(rename = "request_id")]
pub request_id: String,
pub database_name: Option<String>,
pub schema_name: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct LoginRequestBody {
pub data: LoginRequestData,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct LoginResponse {
pub data: Option<LoginResponseData>,
pub success: bool,
pub message: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct LoginResponseData {
pub token: String,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
pub struct LoginRequestData {
pub client_app_id: String,
pub client_app_version: String,
pub svn_revision: Option<String>,
pub account_name: String,
pub login_name: String,
pub client_environment: ClientEnvironment,
pub password: String,
pub session_parameters: HashMap<String, serde_json::Value>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
pub struct ClientEnvironment {
pub application: String,
pub os: String,
pub os_version: String,
pub python_version: String,
pub python_runtime: String,
pub python_compiler: String,
pub ocsp_mode: String,
pub tracing: u32,
pub login_timeout: Option<u32>,
pub network_timeout: Option<u32>,
pub socket_timeout: Option<u32>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct QueryRequest {
pub request_id: Uuid,
#[serde(skip_serializing_if = "Option::is_none")]
pub retry_count: Option<u16>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct QueryRequestBody {
pub sql_text: String,
pub async_exec: bool,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AbortRequestBody {
pub sql_text: String,
pub request_id: Uuid, // duplicate in body, taken from snowflake connector
}
#[derive(Serialize, Deserialize, Debug, Default)]
#[serde(rename_all = "camelCase")]
pub struct ResponseData {
#[serde(rename = "rowtype")]
pub row_type: Vec<ColumnInfo>,
#[serde(rename = "rowsetBase64")]
pub row_set_base_64: Option<String>,
#[serde(rename = "rowset")]
pub row_set: Option<Box<RawValue>>,
pub total: Option<u32>,
#[serde(rename = "queryResultFormat")]
pub query_result_format: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub error_code: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub sql_state: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub query_id: Option<String>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct JsonResponse {
pub data: Option<ResponseData>,
pub success: bool,
pub message: Option<String>,
pub code: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ColumnInfo {
name: String,
database: String,
schema: String,
table: String,
nullable: bool,
#[serde(rename = "type")]
r#type: String,
#[serde(rename = "byteLength")]
byte_length: Option<i32>,
length: Option<i32>,
scale: Option<i32>,
precision: Option<i32>,
collation: Option<String>,
}
#[cfg(feature = "default-server")]
impl From<ColumnInfoModel> for ColumnInfo {
fn from(column_info: ColumnInfoModel) -> Self {
Self {
name: column_info.name,
database: column_info.database,
schema: column_info.schema,
table: column_info.table,
nullable: column_info.nullable,
r#type: column_info.r#type,
byte_length: column_info.byte_length,
length: column_info.length,
scale: column_info.scale,
precision: column_info.precision,
collation: column_info.collation,
}
}
}
#[derive(Clone, Default)]
pub struct Auth {
pub demo_user: String,
pub demo_password: String,
}