Skip to content

Commit f999138

Browse files
ColinKinlochsjoerdsimons
authored andcommitted
Add support for updating package meta
1 parent 6ccee34 commit f999138

File tree

1 file changed

+26
-3
lines changed
  • open-build-service-api/src

1 file changed

+26
-3
lines changed

open-build-service-api/src/lib.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,21 +424,21 @@ impl<'de> Deserialize<'de> for BranchStatus {
424424
}
425425
}
426426

427-
#[derive(Deserialize, Debug)]
427+
#[derive(Deserialize, Serialize, Debug, Clone)]
428428
pub struct PackageBuildMetaDisable {
429429
#[serde(default, rename = "@repository")]
430430
pub repository: Option<String>,
431431
#[serde(default, rename = "@arch")]
432432
pub arch: Option<String>,
433433
}
434434

435-
#[derive(Deserialize, Debug, Default)]
435+
#[derive(Deserialize, Serialize, Debug, Default, Clone)]
436436
pub struct PackageBuildMeta {
437437
#[serde(rename = "disable")]
438438
pub disabled: Vec<PackageBuildMetaDisable>,
439439
}
440440

441-
#[derive(Deserialize, Debug)]
441+
#[derive(Deserialize, Serialize, Debug, Clone)]
442442
pub struct PackageMeta {
443443
#[serde(rename = "@name")]
444444
pub name: String,
@@ -972,6 +972,29 @@ impl<'a> PackageBuilder<'a> {
972972
self.client.request(u).await
973973
}
974974

975+
pub async fn set_meta(&self, meta: &PackageMeta) -> Result<()> {
976+
let mut u = self.client.base.clone();
977+
u.path_segments_mut()
978+
.map_err(|_| Error::InvalidUrl)?
979+
.push("source")
980+
.push(&self.project)
981+
.push(&self.package)
982+
.push("_meta");
983+
984+
let mut body = Vec::new();
985+
quick_xml::se::to_writer(&mut body, meta)?;
986+
987+
Client::send_with_error(
988+
self.client
989+
.authenticated_request(Method::PUT, u)
990+
.header(CONTENT_TYPE, "application/xml")
991+
.body(body),
992+
)
993+
.await?;
994+
995+
Ok(())
996+
}
997+
975998
pub async fn source_file(&self, file: &str) -> Result<impl Stream<Item = Result<Bytes>>> {
976999
let mut u = self.client.base.clone();
9771000
u.path_segments_mut()

0 commit comments

Comments
 (0)