44 * An open source search engine for building delightful search experiences.
55 *
66 * The version of the OpenAPI document: 0.23.0
7- *
7+ *
88 * Generated by: https://openapi-generator.tech
99 */
1010
11-
1211use reqwest;
1312
13+ use super :: { configuration, Error } ;
1414use crate :: apis:: ResponseContent ;
15- use super :: { Error , configuration} ;
16-
1715
1816/// struct for typed errors of method [`create_key`]
1917#[ derive( Debug , Clone , Serialize , Deserialize ) ]
@@ -43,26 +41,31 @@ pub enum GetKeysError {
4341 UnknownValue ( serde_json:: Value ) ,
4442}
4543
46-
4744/// 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 > > {
4949 let local_var_configuration = configuration;
5050
5151 let local_var_client = & local_var_configuration. client ;
5252
5353 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 ( ) ) ;
5556
5657 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 ( ) ) ;
5860 }
5961 if let Some ( ref local_var_apikey) = local_var_configuration. api_key {
6062 let local_var_key = local_var_apikey. key . clone ( ) ;
6163 let local_var_value = match local_var_apikey. prefix {
6264 Some ( ref local_var_prefix) => format ! ( "{} {}" , local_var_prefix, local_var_key) ,
6365 None => local_var_key,
6466 } ;
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) ;
6669 } ;
6770 local_var_req_builder = local_var_req_builder. json ( & api_key_schema) ;
6871
@@ -75,30 +78,45 @@ pub async fn create_key(configuration: &configuration::Configuration, api_key_sc
7578 if !local_var_status. is_client_error ( ) && !local_var_status. is_server_error ( ) {
7679 serde_json:: from_str ( & local_var_content) . map_err ( Error :: from)
7780 } 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+ } ;
8088 Err ( Error :: ResponseError ( local_var_error) )
8189 }
8290}
8391
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 > > {
8596 let local_var_configuration = configuration;
8697
8798 let local_var_client = & local_var_configuration. client ;
8899
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 ( ) ) ;
91107
92108 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 ( ) ) ;
94111 }
95112 if let Some ( ref local_var_apikey) = local_var_configuration. api_key {
96113 let local_var_key = local_var_apikey. key . clone ( ) ;
97114 let local_var_value = match local_var_apikey. prefix {
98115 Some ( ref local_var_prefix) => format ! ( "{} {}" , local_var_prefix, local_var_key) ,
99116 None => local_var_key,
100117 } ;
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) ;
102120 } ;
103121
104122 let local_var_req = local_var_req_builder. build ( ) ?;
@@ -110,31 +128,46 @@ pub async fn delete_key(configuration: &configuration::Configuration, key_id: i6
110128 if !local_var_status. is_client_error ( ) && !local_var_status. is_server_error ( ) {
111129 serde_json:: from_str ( & local_var_content) . map_err ( Error :: from)
112130 } 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+ } ;
115138 Err ( Error :: ResponseError ( local_var_error) )
116139 }
117140}
118141
119142/// 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 > > {
121147 let local_var_configuration = configuration;
122148
123149 let local_var_client = & local_var_configuration. client ;
124150
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 ( ) ) ;
127158
128159 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 ( ) ) ;
130162 }
131163 if let Some ( ref local_var_apikey) = local_var_configuration. api_key {
132164 let local_var_key = local_var_apikey. key . clone ( ) ;
133165 let local_var_value = match local_var_apikey. prefix {
134166 Some ( ref local_var_prefix) => format ! ( "{} {}" , local_var_prefix, local_var_key) ,
135167 None => local_var_key,
136168 } ;
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) ;
138171 } ;
139172
140173 let local_var_req = local_var_req_builder. build ( ) ?;
@@ -147,29 +180,38 @@ pub async fn get_key(configuration: &configuration::Configuration, key_id: i64)
147180 serde_json:: from_str ( & local_var_content) . map_err ( Error :: from)
148181 } else {
149182 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+ } ;
151188 Err ( Error :: ResponseError ( local_var_error) )
152189 }
153190}
154191
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 > > {
156195 let local_var_configuration = configuration;
157196
158197 let local_var_client = & local_var_configuration. client ;
159198
160199 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 ( ) ) ;
162202
163203 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 ( ) ) ;
165206 }
166207 if let Some ( ref local_var_apikey) = local_var_configuration. api_key {
167208 let local_var_key = local_var_apikey. key . clone ( ) ;
168209 let local_var_value = match local_var_apikey. prefix {
169210 Some ( ref local_var_prefix) => format ! ( "{} {}" , local_var_prefix, local_var_key) ,
170211 None => local_var_key,
171212 } ;
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) ;
173215 } ;
174216
175217 let local_var_req = local_var_req_builder. build ( ) ?;
@@ -182,8 +224,11 @@ pub async fn get_keys(configuration: &configuration::Configuration, ) -> Result<
182224 serde_json:: from_str ( & local_var_content) . map_err ( Error :: from)
183225 } else {
184226 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+ } ;
186232 Err ( Error :: ResponseError ( local_var_error) )
187233 }
188234}
189-
0 commit comments