@@ -38,7 +38,7 @@ use agama_lib::{
3838 product:: { proxies:: RegistrationProxy , Product , ProductClient } ,
3939 software:: {
4040 model:: {
41- AddonParams , License , LicenseContent , LicensesRepo , RegistrationError ,
41+ AddonParams , AddonProperties , License , LicenseContent , LicensesRepo , RegistrationError ,
4242 RegistrationInfo , RegistrationParams , Repository , ResolvableParams , SoftwareConfig ,
4343 } ,
4444 proxies:: { Software1Proxy , SoftwareProductProxy } ,
@@ -218,6 +218,7 @@ pub async fn software_service(dbus: zbus::Connection) -> Result<Router, ServiceE
218218 "/registration/addons/registered" ,
219219 get ( get_registered_addons) ,
220220 )
221+ . route ( "/registration/addons/available" , get ( get_available_addons) )
221222 . route ( "/proposal" , get ( proposal) )
222223 . route ( "/config" , put ( set_config) . get ( get_config) )
223224 . route ( "/probe" , post ( probe) )
@@ -337,6 +338,26 @@ async fn get_registered_addons(
337338 Ok ( Json ( result) )
338339}
339340
341+ /// returns list of available addons
342+ ///
343+ /// * `state`: service state.
344+ #[ utoipa:: path(
345+ get,
346+ path = "/registration/addons/available" ,
347+ context_path = "/api/software" ,
348+ responses(
349+ ( status = 200 , description = "List of available addons" , body = Vec <AddonProperties >) ,
350+ ( status = 400 , description = "The D-Bus service could not perform the action" )
351+ )
352+ ) ]
353+ async fn get_available_addons (
354+ State ( state) : State < SoftwareState < ' _ > > ,
355+ ) -> Result < Json < Vec < AddonProperties > > , Error > {
356+ let result = state. product . available_addons ( ) . await ?;
357+
358+ Ok ( Json ( result) )
359+ }
360+
340361/// Register an addon
341362///
342363/// * `state`: service state.
@@ -484,7 +505,7 @@ pub struct SoftwareProposal {
484505 /// Space required for installation. It is returned as a formatted string which includes
485506 /// a number and a unit (e.g., "GiB").
486507 size : String ,
487- /// Patterns selection. It is respresented as a hash map where the key is the pattern's name
508+ /// Patterns selection. It is represented as a hash map where the key is the pattern's name
488509 /// and the value why the pattern is selected.
489510 patterns : HashMap < String , SelectedBy > ,
490511}
0 commit comments