Skip to content

Commit 6a33cec

Browse files
committed
Remove scope from HTTP API
1 parent 556725d commit 6a33cec

File tree

6 files changed

+3
-317
lines changed

6 files changed

+3
-317
lines changed

rust/agama-manager/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ pub use start::start;
2424
pub mod service;
2525
pub use service::Service;
2626

27-
mod scope;
28-
pub use scope::{ConfigScope, Scope};
29-
3027
mod system_info;
3128
pub use system_info::SystemInfo;
3229

rust/agama-manager/src/message.rs

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
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::{
22-
l10n, proposal::Proposal, scope::ConfigScope, scope::Scope, service, system_info::SystemInfo,
23-
};
21+
use crate::{l10n, proposal::Proposal, service, system_info::SystemInfo};
2422
use agama_lib::{install_settings::InstallSettings, issue::Issue};
2523
use agama_utils::{actor::Message, progress::Progress};
2624
use serde::{Deserialize, Serialize};
@@ -61,22 +59,6 @@ impl Message for GetExtendedConfig {
6159
type Reply = InstallSettings;
6260
}
6361

64-
/// Gets a scope from the full config.
65-
#[derive(Debug)]
66-
pub struct GetExtendedConfigScope {
67-
pub scope: Scope,
68-
}
69-
70-
impl GetExtendedConfigScope {
71-
pub fn new(scope: Scope) -> Self {
72-
Self { scope }
73-
}
74-
}
75-
76-
impl Message for GetExtendedConfigScope {
77-
type Reply = Option<ConfigScope>;
78-
}
79-
8062
/// Gets the current config set by the user.
8163
#[derive(Debug)]
8264
pub struct GetConfig;
@@ -117,54 +99,6 @@ impl Message for UpdateConfig {
11799
type Reply = ();
118100
}
119101

120-
/// Gets a scope from the config.
121-
#[derive(Debug)]
122-
pub struct GetConfigScope {
123-
pub scope: Scope,
124-
}
125-
126-
impl GetConfigScope {
127-
pub fn new(scope: Scope) -> Self {
128-
Self { scope }
129-
}
130-
}
131-
132-
impl Message for GetConfigScope {
133-
type Reply = Option<ConfigScope>;
134-
}
135-
136-
/// Sets a config scope
137-
#[derive(Debug)]
138-
pub struct SetConfigScope {
139-
pub config: ConfigScope,
140-
}
141-
142-
impl SetConfigScope {
143-
pub fn new(config: ConfigScope) -> Self {
144-
Self { config }
145-
}
146-
}
147-
148-
impl Message for SetConfigScope {
149-
type Reply = ();
150-
}
151-
152-
/// Updates a config scope
153-
#[derive(Debug)]
154-
pub struct UpdateConfigScope {
155-
pub config: ConfigScope,
156-
}
157-
158-
impl UpdateConfigScope {
159-
pub fn new(config: ConfigScope) -> Self {
160-
Self { config }
161-
}
162-
}
163-
164-
impl Message for UpdateConfigScope {
165-
type Reply = ();
166-
}
167-
168102
/// Gets the proposal.
169103
#[derive(Debug)]
170104
pub struct GetProposal;

rust/agama-manager/src/scope.rs

Lines changed: 0 additions & 45 deletions
This file was deleted.

rust/agama-manager/src/service.rs

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use crate::{
2222
l10n,
2323
message::{self, Action},
2424
proposal::Proposal,
25-
scope::{ConfigScope, Scope},
2625
system_info::SystemInfo,
2726
};
2827
use agama_lib::install_settings::InstallSettings;
@@ -147,23 +146,6 @@ impl MessageHandler<message::GetExtendedConfig> for Service {
147146
}
148147
}
149148

150-
#[async_trait]
151-
impl MessageHandler<message::GetExtendedConfigScope> for Service {
152-
/// It returns the configuration for the given scope.
153-
async fn handle(
154-
&mut self,
155-
message: message::GetExtendedConfigScope,
156-
) -> Result<Option<ConfigScope>, Error> {
157-
let option = match message.scope {
158-
Scope::L10n => {
159-
let l10n_config = self.l10n.call(l10n::message::GetConfig).await?;
160-
Some(ConfigScope::L10n(l10n_config))
161-
}
162-
};
163-
Ok(option)
164-
}
165-
}
166-
167149
#[async_trait]
168150
impl MessageHandler<message::GetConfig> for Service {
169151
/// Gets the current configuration set by the user.
@@ -205,63 +187,6 @@ impl MessageHandler<message::UpdateConfig> for Service {
205187
}
206188
}
207189

208-
#[async_trait]
209-
impl MessageHandler<message::GetConfigScope> for Service {
210-
/// It returns the configuration set by the user for the given scope.
211-
async fn handle(
212-
&mut self,
213-
message: message::GetConfigScope,
214-
) -> Result<Option<ConfigScope>, Error> {
215-
// FIXME: implement this logic at InstallSettings level: self.get_config().by_scope(...)
216-
// It would allow us to drop this method.
217-
let option = match message.scope {
218-
Scope::L10n => self
219-
.config
220-
.localization
221-
.clone()
222-
.map(|c| ConfigScope::L10n(c)),
223-
};
224-
Ok(option)
225-
}
226-
}
227-
228-
#[async_trait]
229-
impl MessageHandler<message::SetConfigScope> for Service {
230-
/// Sets the user configuration within the given scope.
231-
///
232-
/// It replaces the current configuration with the given one and calculates a
233-
/// new proposal. Only the configuration in the given scope is affected.
234-
async fn handle(&mut self, message: message::SetConfigScope) -> Result<(), Error> {
235-
match message.config {
236-
ConfigScope::L10n(l10n_config) => {
237-
self.l10n
238-
.call(l10n::message::SetConfig::new(l10n_config.clone()))
239-
.await?;
240-
self.config.localization = Some(l10n_config);
241-
}
242-
}
243-
Ok(())
244-
}
245-
}
246-
247-
#[async_trait]
248-
impl MessageHandler<message::UpdateConfigScope> for Service {
249-
/// Patches the user configuration within the given scope.
250-
///
251-
/// It merges the current configuration with the given one.
252-
async fn handle(&mut self, message: message::UpdateConfigScope) -> Result<(), Error> {
253-
match message.config {
254-
ConfigScope::L10n(l10n_config) => {
255-
let base_config = self.config.localization.clone().unwrap_or_default();
256-
let config = merge(&base_config, &l10n_config).map_err(|_| Error::MergeConfig)?;
257-
self.handle(message::SetConfigScope::new(ConfigScope::L10n(config)))
258-
.await?;
259-
}
260-
}
261-
Ok(())
262-
}
263-
}
264-
265190
#[async_trait]
266191
impl MessageHandler<message::GetProposal> for Service {
267192
/// It returns the current proposal, if any.

0 commit comments

Comments
 (0)