4
4
* An open source search engine for building delightful search experiences.
5
5
*
6
6
* The version of the OpenAPI document: 0.23.0
7
- *
7
+ *
8
8
* Generated by: https://openapi-generator.tech
9
9
*/
10
10
11
-
12
11
use reqwest;
13
12
13
+ use super :: { configuration, Error } ;
14
14
use crate :: apis:: ResponseContent ;
15
- use super :: { Error , configuration} ;
16
-
17
15
18
16
/// struct for typed errors of method [`create_key`]
19
17
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
@@ -43,26 +41,31 @@ pub enum GetKeysError {
43
41
UnknownValue ( serde_json:: Value ) ,
44
42
}
45
43
46
-
47
44
/// Create an API Key with fine-grain access control. You can restrict access on both a per-collection and per-action level. The generated key is returned only during creation. You want to store this key carefully in a secure place.
48
- pub async fn create_key ( configuration : & configuration:: Configuration , api_key_schema : Option < crate :: models:: ApiKeySchema > ) -> Result < crate :: models:: ApiKey , Error < CreateKeyError > > {
45
+ pub async fn create_key (
46
+ configuration : & configuration:: Configuration ,
47
+ api_key_schema : Option < crate :: models:: ApiKeySchema > ,
48
+ ) -> Result < crate :: models:: ApiKey , Error < CreateKeyError > > {
49
49
let local_var_configuration = configuration;
50
50
51
51
let local_var_client = & local_var_configuration. client ;
52
52
53
53
let local_var_uri_str = format ! ( "{}/keys" , local_var_configuration. base_path) ;
54
- let mut local_var_req_builder = local_var_client. request ( reqwest:: Method :: POST , local_var_uri_str. as_str ( ) ) ;
54
+ let mut local_var_req_builder =
55
+ local_var_client. request ( reqwest:: Method :: POST , local_var_uri_str. as_str ( ) ) ;
55
56
56
57
if let Some ( ref local_var_user_agent) = local_var_configuration. user_agent {
57
- local_var_req_builder = local_var_req_builder. header ( reqwest:: header:: USER_AGENT , local_var_user_agent. clone ( ) ) ;
58
+ local_var_req_builder =
59
+ local_var_req_builder. header ( reqwest:: header:: USER_AGENT , local_var_user_agent. clone ( ) ) ;
58
60
}
59
61
if let Some ( ref local_var_apikey) = local_var_configuration. api_key {
60
62
let local_var_key = local_var_apikey. key . clone ( ) ;
61
63
let local_var_value = match local_var_apikey. prefix {
62
64
Some ( ref local_var_prefix) => format ! ( "{} {}" , local_var_prefix, local_var_key) ,
63
65
None => local_var_key,
64
66
} ;
65
- local_var_req_builder = local_var_req_builder. header ( "X-TYPESENSE-API-KEY" , local_var_value) ;
67
+ local_var_req_builder =
68
+ local_var_req_builder. header ( "X-TYPESENSE-API-KEY" , local_var_value) ;
66
69
} ;
67
70
local_var_req_builder = local_var_req_builder. json ( & api_key_schema) ;
68
71
@@ -75,30 +78,45 @@ pub async fn create_key(configuration: &configuration::Configuration, api_key_sc
75
78
if !local_var_status. is_client_error ( ) && !local_var_status. is_server_error ( ) {
76
79
serde_json:: from_str ( & local_var_content) . map_err ( Error :: from)
77
80
} else {
78
- let local_var_entity: Option < CreateKeyError > = serde_json:: from_str ( & local_var_content) . ok ( ) ;
79
- let local_var_error = ResponseContent { status : local_var_status, content : local_var_content, entity : local_var_entity } ;
81
+ let local_var_entity: Option < CreateKeyError > =
82
+ serde_json:: from_str ( & local_var_content) . ok ( ) ;
83
+ let local_var_error = ResponseContent {
84
+ status : local_var_status,
85
+ content : local_var_content,
86
+ entity : local_var_entity,
87
+ } ;
80
88
Err ( Error :: ResponseError ( local_var_error) )
81
89
}
82
90
}
83
91
84
- pub async fn delete_key ( configuration : & configuration:: Configuration , key_id : i64 ) -> Result < crate :: models:: ApiKey , Error < DeleteKeyError > > {
92
+ pub async fn delete_key (
93
+ configuration : & configuration:: Configuration ,
94
+ key_id : i64 ,
95
+ ) -> Result < crate :: models:: ApiKey , Error < DeleteKeyError > > {
85
96
let local_var_configuration = configuration;
86
97
87
98
let local_var_client = & local_var_configuration. client ;
88
99
89
- let local_var_uri_str = format ! ( "{}/keys/{keyId}" , local_var_configuration. base_path, keyId=key_id) ;
90
- let mut local_var_req_builder = local_var_client. request ( reqwest:: Method :: DELETE , local_var_uri_str. as_str ( ) ) ;
100
+ let local_var_uri_str = format ! (
101
+ "{}/keys/{keyId}" ,
102
+ local_var_configuration. base_path,
103
+ keyId = key_id
104
+ ) ;
105
+ let mut local_var_req_builder =
106
+ local_var_client. request ( reqwest:: Method :: DELETE , local_var_uri_str. as_str ( ) ) ;
91
107
92
108
if let Some ( ref local_var_user_agent) = local_var_configuration. user_agent {
93
- local_var_req_builder = local_var_req_builder. header ( reqwest:: header:: USER_AGENT , local_var_user_agent. clone ( ) ) ;
109
+ local_var_req_builder =
110
+ local_var_req_builder. header ( reqwest:: header:: USER_AGENT , local_var_user_agent. clone ( ) ) ;
94
111
}
95
112
if let Some ( ref local_var_apikey) = local_var_configuration. api_key {
96
113
let local_var_key = local_var_apikey. key . clone ( ) ;
97
114
let local_var_value = match local_var_apikey. prefix {
98
115
Some ( ref local_var_prefix) => format ! ( "{} {}" , local_var_prefix, local_var_key) ,
99
116
None => local_var_key,
100
117
} ;
101
- local_var_req_builder = local_var_req_builder. header ( "X-TYPESENSE-API-KEY" , local_var_value) ;
118
+ local_var_req_builder =
119
+ local_var_req_builder. header ( "X-TYPESENSE-API-KEY" , local_var_value) ;
102
120
} ;
103
121
104
122
let local_var_req = local_var_req_builder. build ( ) ?;
@@ -110,31 +128,46 @@ pub async fn delete_key(configuration: &configuration::Configuration, key_id: i6
110
128
if !local_var_status. is_client_error ( ) && !local_var_status. is_server_error ( ) {
111
129
serde_json:: from_str ( & local_var_content) . map_err ( Error :: from)
112
130
} else {
113
- let local_var_entity: Option < DeleteKeyError > = serde_json:: from_str ( & local_var_content) . ok ( ) ;
114
- let local_var_error = ResponseContent { status : local_var_status, content : local_var_content, entity : local_var_entity } ;
131
+ let local_var_entity: Option < DeleteKeyError > =
132
+ serde_json:: from_str ( & local_var_content) . ok ( ) ;
133
+ let local_var_error = ResponseContent {
134
+ status : local_var_status,
135
+ content : local_var_content,
136
+ entity : local_var_entity,
137
+ } ;
115
138
Err ( Error :: ResponseError ( local_var_error) )
116
139
}
117
140
}
118
141
119
142
/// Retrieve (metadata about) a key. Only the key prefix is returned when you retrieve a key. Due to security reasons, only the create endpoint returns the full API key.
120
- pub async fn get_key ( configuration : & configuration:: Configuration , key_id : i64 ) -> Result < crate :: models:: ApiKey , Error < GetKeyError > > {
143
+ pub async fn get_key (
144
+ configuration : & configuration:: Configuration ,
145
+ key_id : i64 ,
146
+ ) -> Result < crate :: models:: ApiKey , Error < GetKeyError > > {
121
147
let local_var_configuration = configuration;
122
148
123
149
let local_var_client = & local_var_configuration. client ;
124
150
125
- let local_var_uri_str = format ! ( "{}/keys/{keyId}" , local_var_configuration. base_path, keyId=key_id) ;
126
- let mut local_var_req_builder = local_var_client. request ( reqwest:: Method :: GET , local_var_uri_str. as_str ( ) ) ;
151
+ let local_var_uri_str = format ! (
152
+ "{}/keys/{keyId}" ,
153
+ local_var_configuration. base_path,
154
+ keyId = key_id
155
+ ) ;
156
+ let mut local_var_req_builder =
157
+ local_var_client. request ( reqwest:: Method :: GET , local_var_uri_str. as_str ( ) ) ;
127
158
128
159
if let Some ( ref local_var_user_agent) = local_var_configuration. user_agent {
129
- local_var_req_builder = local_var_req_builder. header ( reqwest:: header:: USER_AGENT , local_var_user_agent. clone ( ) ) ;
160
+ local_var_req_builder =
161
+ local_var_req_builder. header ( reqwest:: header:: USER_AGENT , local_var_user_agent. clone ( ) ) ;
130
162
}
131
163
if let Some ( ref local_var_apikey) = local_var_configuration. api_key {
132
164
let local_var_key = local_var_apikey. key . clone ( ) ;
133
165
let local_var_value = match local_var_apikey. prefix {
134
166
Some ( ref local_var_prefix) => format ! ( "{} {}" , local_var_prefix, local_var_key) ,
135
167
None => local_var_key,
136
168
} ;
137
- local_var_req_builder = local_var_req_builder. header ( "X-TYPESENSE-API-KEY" , local_var_value) ;
169
+ local_var_req_builder =
170
+ local_var_req_builder. header ( "X-TYPESENSE-API-KEY" , local_var_value) ;
138
171
} ;
139
172
140
173
let local_var_req = local_var_req_builder. build ( ) ?;
@@ -147,29 +180,38 @@ pub async fn get_key(configuration: &configuration::Configuration, key_id: i64)
147
180
serde_json:: from_str ( & local_var_content) . map_err ( Error :: from)
148
181
} else {
149
182
let local_var_entity: Option < GetKeyError > = serde_json:: from_str ( & local_var_content) . ok ( ) ;
150
- let local_var_error = ResponseContent { status : local_var_status, content : local_var_content, entity : local_var_entity } ;
183
+ let local_var_error = ResponseContent {
184
+ status : local_var_status,
185
+ content : local_var_content,
186
+ entity : local_var_entity,
187
+ } ;
151
188
Err ( Error :: ResponseError ( local_var_error) )
152
189
}
153
190
}
154
191
155
- pub async fn get_keys ( configuration : & configuration:: Configuration , ) -> Result < crate :: models:: ApiKeysResponse , Error < GetKeysError > > {
192
+ pub async fn get_keys (
193
+ configuration : & configuration:: Configuration ,
194
+ ) -> Result < crate :: models:: ApiKeysResponse , Error < GetKeysError > > {
156
195
let local_var_configuration = configuration;
157
196
158
197
let local_var_client = & local_var_configuration. client ;
159
198
160
199
let local_var_uri_str = format ! ( "{}/keys" , local_var_configuration. base_path) ;
161
- let mut local_var_req_builder = local_var_client. request ( reqwest:: Method :: GET , local_var_uri_str. as_str ( ) ) ;
200
+ let mut local_var_req_builder =
201
+ local_var_client. request ( reqwest:: Method :: GET , local_var_uri_str. as_str ( ) ) ;
162
202
163
203
if let Some ( ref local_var_user_agent) = local_var_configuration. user_agent {
164
- local_var_req_builder = local_var_req_builder. header ( reqwest:: header:: USER_AGENT , local_var_user_agent. clone ( ) ) ;
204
+ local_var_req_builder =
205
+ local_var_req_builder. header ( reqwest:: header:: USER_AGENT , local_var_user_agent. clone ( ) ) ;
165
206
}
166
207
if let Some ( ref local_var_apikey) = local_var_configuration. api_key {
167
208
let local_var_key = local_var_apikey. key . clone ( ) ;
168
209
let local_var_value = match local_var_apikey. prefix {
169
210
Some ( ref local_var_prefix) => format ! ( "{} {}" , local_var_prefix, local_var_key) ,
170
211
None => local_var_key,
171
212
} ;
172
- local_var_req_builder = local_var_req_builder. header ( "X-TYPESENSE-API-KEY" , local_var_value) ;
213
+ local_var_req_builder =
214
+ local_var_req_builder. header ( "X-TYPESENSE-API-KEY" , local_var_value) ;
173
215
} ;
174
216
175
217
let local_var_req = local_var_req_builder. build ( ) ?;
@@ -182,8 +224,11 @@ pub async fn get_keys(configuration: &configuration::Configuration, ) -> Result<
182
224
serde_json:: from_str ( & local_var_content) . map_err ( Error :: from)
183
225
} else {
184
226
let local_var_entity: Option < GetKeysError > = serde_json:: from_str ( & local_var_content) . ok ( ) ;
185
- let local_var_error = ResponseContent { status : local_var_status, content : local_var_content, entity : local_var_entity } ;
227
+ let local_var_error = ResponseContent {
228
+ status : local_var_status,
229
+ content : local_var_content,
230
+ entity : local_var_entity,
231
+ } ;
186
232
Err ( Error :: ResponseError ( local_var_error) )
187
233
}
188
234
}
189
-
0 commit comments