Skip to content

Commit 1f85b82

Browse files
committed
Move action to api
1 parent e9f72d7 commit 1f85b82

File tree

10 files changed

+77
-34
lines changed

10 files changed

+77
-34
lines changed

rust/agama-l10n/src/message.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use agama_locale_data::{KeymapId, LocaleId};
2222
use agama_utils::actor::Message;
2323
use agama_utils::api;
2424
use agama_utils::api::l10n::{Proposal, SystemInfo};
25-
use serde::Deserialize;
2625

2726
#[derive(Clone)]
2827
pub struct GetSystem;
@@ -45,12 +44,6 @@ impl<T> SetSystem<T> {
4544
}
4645
}
4746

48-
#[derive(Clone, Debug, Deserialize, utoipa::ToSchema)]
49-
pub struct SystemConfig {
50-
pub locale: Option<String>,
51-
pub keymap: Option<String>,
52-
}
53-
5447
pub struct GetConfig;
5548

5649
impl Message for GetConfig {

rust/agama-l10n/src/service.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use agama_locale_data::{InvalidKeymapId, InvalidLocaleId, InvalidTimezoneId, Key
2525
use agama_utils::actor::{self, Actor, Handler, MessageHandler};
2626
use agama_utils::api;
2727
use agama_utils::api::event::{self, Event};
28-
use agama_utils::api::l10n::{Proposal, SystemInfo};
28+
use agama_utils::api::l10n::{Proposal, SystemConfig, SystemInfo};
2929
use agama_utils::api::scope::Scope;
3030
use agama_utils::issue::{self, Issue};
3131
use async_trait::async_trait;
@@ -157,11 +157,8 @@ impl MessageHandler<message::GetSystem> for Service {
157157
}
158158

159159
#[async_trait]
160-
impl MessageHandler<message::SetSystem<message::SystemConfig>> for Service {
161-
async fn handle(
162-
&mut self,
163-
message: message::SetSystem<message::SystemConfig>,
164-
) -> Result<(), Error> {
160+
impl MessageHandler<message::SetSystem<SystemConfig>> for Service {
161+
async fn handle(&mut self, message: message::SetSystem<SystemConfig>) -> Result<(), Error> {
165162
let config = &message.config;
166163
if let Some(locale) = &config.locale {
167164
self.model.set_locale(locale.parse()?)?;

rust/agama-manager/src/message.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
// To contact SUSE LLC about this file by physical or electronic mail, you may
1919
// find current contact information at www.suse.com.
2020

21-
use crate::l10n;
2221
use agama_lib::install_settings::InstallSettings;
2322
use agama_utils::actor::Message;
24-
use agama_utils::api::{Proposal, Scope, Status, SystemInfo};
23+
use agama_utils::api::{Action, Proposal, Scope, Status, SystemInfo};
2524
use agama_utils::issue::Issue;
26-
use serde::Deserialize;
2725
use std::collections::HashMap;
2826

2927
/// Gets the installation status.
@@ -121,11 +119,3 @@ impl RunAction {
121119
impl Message for RunAction {
122120
type Reply = ();
123121
}
124-
125-
#[derive(Debug, Deserialize, utoipa::ToSchema)]
126-
pub enum Action {
127-
#[serde(rename = "configureL10n")]
128-
ConfigureL10n(l10n::message::SystemConfig),
129-
#[serde(rename = "install")]
130-
Install,
131-
}

rust/agama-manager/src/service.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
// find current contact information at www.suse.com.
2020

2121
use crate::l10n;
22-
use crate::message::{self, Action};
22+
use crate::message;
2323
use agama_lib::install_settings::InstallSettings;
2424
use agama_utils::actor::{self, Actor, Handler, MessageHandler};
2525
use agama_utils::api::status::State;
26-
use agama_utils::api::{event, Event, Proposal, Scope, Status, SystemInfo};
26+
use agama_utils::api::{event, Action, Event, Proposal, Scope, Status, SystemInfo};
2727
use agama_utils::issue;
2828
use agama_utils::progress;
2929
use async_trait::async_trait;

rust/agama-server/src/server/web.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use agama_lib::install_settings::InstallSettings;
2626
use agama_manager::message;
2727
use agama_manager::{self as manager};
2828
use agama_utils::actor::Handler;
29-
use agama_utils::api::{event, Status, SystemInfo};
29+
use agama_utils::api::{event, Action, Status, SystemInfo};
3030
use anyhow;
3131
use axum::extract::State;
3232
use axum::response::{IntoResponse, Response};
@@ -242,12 +242,12 @@ async fn get_issues(State(state): State<ServerState>) -> ServerResult<Json<Issue
242242
(status = 400, description = "Not possible to run the action.", body = Object)
243243
),
244244
params(
245-
("action" = message::Action, description = "Description of the action to run."),
245+
("action" = Action, description = "Description of the action to run."),
246246
)
247247
)]
248248
async fn run_action(
249249
State(state): State<ServerState>,
250-
Json(action): Json<message::Action>,
250+
Json(action): Json<Action>,
251251
) -> ServerResult<()> {
252252
state.manager.call(message::RunAction::new(action)).await?;
253253
Ok(())

rust/agama-server/src/web/docs/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ impl ApiDocBuilder for ConfigApiDocBuilder {
4646
.schema("IpAddr", schemas::ip_addr())
4747
.schema("IpInet", schemas::ip_inet())
4848
.schema("macaddr.MacAddr6", schemas::mac_addr6())
49-
.schema_from::<agama_l10n::message::SystemConfig>()
5049
.schema_from::<agama_lib::bootloader::model::BootloaderSettings>()
5150
.schema_from::<agama_lib::file_source::FileSource>()
5251
.schema_from::<agama_lib::files::model::UserFile>()
@@ -161,13 +160,14 @@ impl ApiDocBuilder for ConfigApiDocBuilder {
161160
.schema_from::<crate::server::types::ConfigPatch>()
162161
.schema_from::<crate::server::types::IssuesMap>()
163162
.schema_from::<crate::software::web::SoftwareProposal>()
164-
.schema_from::<agama_manager::message::Action>()
165163
.schema_from::<agama_utils::api::Status>()
166-
.schema_from::<agama_utils::api::Progress>()
167164
.schema_from::<agama_utils::api::status::State>()
165+
.schema_from::<agama_utils::api::Progress>()
168166
.schema_from::<agama_utils::api::Scope>()
167+
.schema_from::<agama_utils::api::Action>()
169168
.schema_from::<agama_utils::api::SystemInfo>()
170169
.schema_from::<agama_utils::api::l10n::SystemInfo>()
170+
.schema_from::<agama_utils::api::l10n::SystemConfig>()
171171
.schema_from::<agama_utils::api::l10n::LocaleEntry>()
172172
.schema_from::<agama_utils::api::l10n::Keymap>()
173173
.schema_from::<agama_utils::api::l10n::TimezoneEntry>()

rust/agama-utils/src/api.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ pub use scope::Scope;
3333
pub mod status;
3434
pub use status::Status;
3535

36-
pub mod system_info;
36+
mod system_info;
3737
pub use system_info::SystemInfo;
3838

39-
pub mod proposal;
39+
mod proposal;
4040
pub use proposal::Proposal;
4141

42+
mod action;
43+
pub use action::Action;
44+
4245
pub mod l10n;

rust/agama-utils/src/api/action.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) [2025] SUSE LLC
2+
//
3+
// All Rights Reserved.
4+
//
5+
// This program is free software; you can redistribute it and/or modify it
6+
// under the terms of the GNU General Public License as published by the Free
7+
// Software Foundation; either version 2 of the License, or (at your option)
8+
// any later version.
9+
//
10+
// This program is distributed in the hope that it will be useful, but WITHOUT
11+
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13+
// more details.
14+
//
15+
// You should have received a copy of the GNU General Public License along
16+
// with this program; if not, contact SUSE LLC.
17+
//
18+
// To contact SUSE LLC about this file by physical or electronic mail, you may
19+
// find current contact information at www.suse.com.
20+
21+
use crate::api::l10n;
22+
use serde::Deserialize;
23+
24+
#[derive(Debug, Deserialize, utoipa::ToSchema)]
25+
pub enum Action {
26+
#[serde(rename = "configureL10n")]
27+
ConfigureL10n(l10n::SystemConfig),
28+
#[serde(rename = "install")]
29+
Install,
30+
}

rust/agama-utils/src/api/l10n.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@ pub use config::Config;
2727
mod system_info;
2828
pub use system_info::{Keymap, LocaleEntry, SystemInfo, TimezoneEntry};
2929

30+
mod system_config;
31+
pub use system_config::SystemConfig;
32+
3033
mod proposal;
3134
pub use proposal::Proposal;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) [2025] SUSE LLC
2+
//
3+
// All Rights Reserved.
4+
//
5+
// This program is free software; you can redistribute it and/or modify it
6+
// under the terms of the GNU General Public License as published by the Free
7+
// Software Foundation; either version 2 of the License, or (at your option)
8+
// any later version.
9+
//
10+
// This program is distributed in the hope that it will be useful, but WITHOUT
11+
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13+
// more details.
14+
//
15+
// You should have received a copy of the GNU General Public License along
16+
// with this program; if not, contact SUSE LLC.
17+
//
18+
// To contact SUSE LLC about this file by physical or electronic mail, you may
19+
// find current contact information at www.suse.com.
20+
21+
use serde::Deserialize;
22+
23+
#[derive(Clone, Debug, Deserialize, utoipa::ToSchema)]
24+
pub struct SystemConfig {
25+
pub locale: Option<String>,
26+
pub keymap: Option<String>,
27+
}

0 commit comments

Comments
 (0)