@@ -2,17 +2,18 @@ use hippo_openapi::models::GetChannelLogsVm;
22use hippo_openapi:: models:: PatchChannelCommand ;
33use std:: collections:: HashMap ;
44
5- use hippo_openapi:: apis:: account_api:: { api_account_createtoken_post, api_account_post} ;
6- use hippo_openapi:: apis:: app_api:: { api_app_get, api_app_id_delete, api_app_post} ;
7- use hippo_openapi:: apis:: certificate_api:: {
8- api_certificate_get, api_certificate_id_delete, api_certificate_post,
5+ use hippo_openapi:: apis:: accounts_api:: api_accounts_post;
6+ use hippo_openapi:: apis:: apps_api:: { api_apps_get, api_apps_id_delete, api_apps_post} ;
7+ use hippo_openapi:: apis:: auth_tokens_api:: api_auth_tokens_post;
8+ use hippo_openapi:: apis:: certificates_api:: {
9+ api_certificates_get, api_certificates_id_delete, api_certificates_post,
910} ;
10- use hippo_openapi:: apis:: channel_api :: {
11- api_channel_get , api_channel_id_delete , api_channel_id_get , api_channel_id_patch ,
12- api_channel_post , api_channel_logs_id_get
11+ use hippo_openapi:: apis:: channels_api :: {
12+ api_channels_get , api_channels_id_delete , api_channels_id_get , api_channels_id_logs_get ,
13+ api_channels_id_patch , api_channels_post ,
1314} ;
1415use hippo_openapi:: apis:: configuration:: { ApiKey , Configuration } ;
15- use hippo_openapi:: apis:: revision_api :: { api_revision_get , api_revision_post } ;
16+ use hippo_openapi:: apis:: revisions_api :: { api_revisions_get , api_revisions_post } ;
1617use hippo_openapi:: apis:: Error ;
1718use hippo_openapi:: models:: {
1819 AppItemPage , CertificateItemPage , ChannelItem , ChannelItemPage ,
@@ -22,6 +23,8 @@ use hippo_openapi::models::{
2223 UpdateEnvironmentVariableDtoListField ,
2324} ;
2425
26+ use uuid:: Uuid ;
27+
2528use reqwest:: header;
2629use serde:: Deserialize ;
2730
@@ -45,7 +48,7 @@ impl Client {
4548
4649 let base_path = match conn_info. url . strip_suffix ( "/" ) {
4750 Some ( s) => s. to_owned ( ) ,
48- None => conn_info. url
51+ None => conn_info. url ,
4952 } ;
5053 let configuration = Configuration {
5154 base_path : base_path,
@@ -74,7 +77,7 @@ impl Client {
7477 }
7578
7679 pub async fn register ( & self , username : String , password : String ) -> anyhow:: Result < String > {
77- api_account_post (
80+ api_accounts_post (
7881 & self . configuration ,
7982 Some ( CreateAccountCommand {
8083 user_name : username,
@@ -86,7 +89,7 @@ impl Client {
8689 }
8790
8891 pub async fn login ( & self , username : String , password : String ) -> anyhow:: Result < TokenInfo > {
89- api_account_createtoken_post (
92+ api_auth_tokens_post (
9093 & self . configuration ,
9194 Some ( CreateTokenCommand {
9295 user_name : username,
@@ -97,8 +100,8 @@ impl Client {
97100 . map_err ( format_response_error)
98101 }
99102
100- pub async fn add_app ( & self , name : String , storage_id : String ) -> anyhow:: Result < String > {
101- api_app_post (
103+ pub async fn add_app ( & self , name : String , storage_id : String ) -> anyhow:: Result < Uuid > {
104+ api_apps_post (
102105 & self . configuration ,
103106 Some ( CreateAppCommand {
104107 name : name,
@@ -110,13 +113,13 @@ impl Client {
110113 }
111114
112115 pub async fn remove_app ( & self , id : String ) -> anyhow:: Result < ( ) > {
113- api_app_id_delete ( & self . configuration , & id)
116+ api_apps_id_delete ( & self . configuration , & id)
114117 . await
115118 . map_err ( format_response_error)
116119 }
117120
118121 pub async fn list_apps ( & self ) -> anyhow:: Result < AppItemPage > {
119- api_app_get ( & self . configuration , None , None , None , None , None )
122+ api_apps_get ( & self . configuration , None , None , None , None , None )
120123 . await
121124 . map_err ( format_response_error)
122125 }
@@ -126,8 +129,8 @@ impl Client {
126129 name : String ,
127130 public_key : String ,
128131 private_key : String ,
129- ) -> anyhow:: Result < String > {
130- api_certificate_post (
132+ ) -> anyhow:: Result < Uuid > {
133+ api_certificates_post (
131134 & self . configuration ,
132135 Some ( CreateCertificateCommand {
133136 name : name,
@@ -140,27 +143,27 @@ impl Client {
140143 }
141144
142145 pub async fn list_certificates ( & self ) -> anyhow:: Result < CertificateItemPage > {
143- api_certificate_get ( & self . configuration , None , None , None , None , None )
146+ api_certificates_get ( & self . configuration , None , None , None , None , None )
144147 . await
145148 . map_err ( format_response_error)
146149 }
147150
148151 pub async fn remove_certificate ( & self , id : String ) -> anyhow:: Result < ( ) > {
149- api_certificate_id_delete ( & self . configuration , & id)
152+ api_certificates_id_delete ( & self . configuration , & id)
150153 . await
151154 . map_err ( format_response_error)
152155 }
153156
154157 pub async fn add_channel (
155158 & self ,
156- app_id : String ,
159+ app_id : Uuid ,
157160 name : String ,
158161 domain : Option < String > ,
159162 revision_selection_strategy : ChannelRevisionSelectionStrategy ,
160163 range_rule : Option < String > ,
161- active_revision_id : Option < String > ,
162- certificate_id : Option < String > ,
163- ) -> anyhow:: Result < String > {
164+ active_revision_id : Option < Uuid > ,
165+ certificate_id : Option < Uuid > ,
166+ ) -> anyhow:: Result < Uuid > {
164167 let command = CreateChannelCommand {
165168 app_id : app_id,
166169 name : name,
@@ -170,31 +173,31 @@ impl Client {
170173 active_revision_id,
171174 certificate_id,
172175 } ;
173- api_channel_post ( & self . configuration , Some ( command) )
176+ api_channels_post ( & self . configuration , Some ( command) )
174177 . await
175178 . map_err ( format_response_error)
176179 }
177180
178181 pub async fn get_channel_by_id ( & self , id : & str ) -> anyhow:: Result < ChannelItem > {
179- api_channel_id_get ( & self . configuration , id)
182+ api_channels_id_get ( & self . configuration , id)
180183 . await
181184 . map_err ( format_response_error)
182185 }
183186
184187 pub async fn list_channels ( & self ) -> anyhow:: Result < ChannelItemPage > {
185- api_channel_get ( & self . configuration , None , None , None , None , None )
188+ api_channels_get ( & self . configuration , Some ( "" ) , None , None , Some ( "Name" ) , None )
186189 . await
187190 . map_err ( format_response_error)
188191 }
189192
190193 pub async fn remove_channel ( & self , id : String ) -> anyhow:: Result < ( ) > {
191- api_channel_id_delete ( & self . configuration , & id)
194+ api_channels_id_delete ( & self . configuration , & id)
192195 . await
193196 . map_err ( format_response_error)
194197 }
195198
196199 pub async fn channel_logs ( & self , id : String ) -> anyhow:: Result < GetChannelLogsVm > {
197- api_channel_logs_id_get ( & self . configuration , & id)
200+ api_channels_id_logs_get ( & self . configuration , & id)
198201 . await
199202 . map_err ( format_response_error)
200203 }
@@ -203,7 +206,7 @@ impl Client {
203206 & self ,
204207 key : String ,
205208 value : String ,
206- channel_id : String ,
209+ channel_id : Uuid ,
207210 ) -> anyhow:: Result < ( ) > {
208211 let mut environment_variables = self . list_environment_variables ( channel_id. clone ( ) ) . await ?;
209212 environment_variables. push ( EnvironmentVariableItem {
@@ -212,9 +215,9 @@ impl Client {
212215 key : key,
213216 value : value,
214217 } ) ;
215- api_channel_id_patch (
218+ api_channels_id_patch (
216219 & self . configuration ,
217- & channel_id,
220+ & channel_id. to_string ( ) ,
218221 Some ( PatchChannelCommand {
219222 // TODO: fix this in hippo 0.19 - this is a very ugly type cast that shouldn't exist
220223 environment_variables : Some ( Box :: new ( UpdateEnvironmentVariableDtoListField {
@@ -237,15 +240,15 @@ impl Client {
237240
238241 pub async fn list_environment_variables (
239242 & self ,
240- channel_id : String ,
243+ channel_id : Uuid ,
241244 ) -> anyhow:: Result < Vec < EnvironmentVariableItem > > {
242- let channel = self . get_channel_by_id ( & channel_id) . await ?;
245+ let channel = self . get_channel_by_id ( & channel_id. to_string ( ) ) . await ?;
243246 Ok ( channel. environment_variables )
244247 }
245248
246249 pub async fn remove_environment_variable (
247250 & self ,
248- channel_id : String ,
251+ channel_id : Uuid ,
249252 key : String ,
250253 ) -> anyhow:: Result < ( ) > {
251254 let mut environment_variables = self . list_environment_variables ( channel_id. clone ( ) ) . await ?;
@@ -254,9 +257,9 @@ impl Client {
254257 . position ( |e| e. key == key)
255258 . unwrap ( ) ;
256259 environment_variables. remove ( index) ;
257- api_channel_id_patch (
260+ api_channels_id_patch (
258261 & self . configuration ,
259- & channel_id,
262+ & channel_id. to_string ( ) ,
260263 Some ( PatchChannelCommand {
261264 // TODO: fix this in hippo 0.19 - this is a very ugly type cast that shouldn't exist
262265 environment_variables : Some ( Box :: new ( UpdateEnvironmentVariableDtoListField {
@@ -282,7 +285,7 @@ impl Client {
282285 app_storage_id : String ,
283286 revision_number : String ,
284287 ) -> anyhow:: Result < ( ) > {
285- api_revision_post (
288+ api_revisions_post (
286289 & self . configuration ,
287290 Some ( RegisterRevisionCommand {
288291 app_storage_id : app_storage_id,
@@ -294,7 +297,7 @@ impl Client {
294297 }
295298
296299 pub async fn list_revisions ( & self ) -> anyhow:: Result < RevisionItemPage > {
297- api_revision_get ( & self . configuration , None , None )
300+ api_revisions_get ( & self . configuration , None , None )
298301 . await
299302 . map_err ( format_response_error)
300303 }
@@ -314,6 +317,9 @@ fn format_response_error<T>(e: Error<T>) -> anyhow::Error {
314317 _ => anyhow:: anyhow!( r. content) ,
315318 }
316319 }
320+ Error :: Serde ( err ) => {
321+ anyhow:: anyhow!( format!( "could not parse JSON object: {}" , err) )
322+ }
317323 _ => anyhow:: anyhow!( e. to_string( ) ) ,
318324 }
319325}
0 commit comments