gitea_sdk/api/orgs/
create_repo.rs1use build_it::Builder;
2use serde::Serialize;
3
4use crate::{
5 error::Result,
6 model::repos::{ObjectFormatName, Repository, TrustModel},
7 Client,
8};
9
10#[derive(Debug, Clone, PartialEq, Serialize, Builder)]
13#[build_it(into)]
14#[serde(default)]
15pub struct CreateRepoBuilder {
16 #[build_it(skip)]
18 #[serde(skip)]
19 org: String,
20 #[build_it(skip)]
22 name: String,
23 auto_init: Option<bool>,
26 default_branch: Option<String>,
28 description: Option<String>,
30 gitignores: Option<String>,
33 issue_labels: Option<String>,
35 license: Option<String>,
37 object_format_name: Option<ObjectFormatName>,
39 private: Option<bool>,
41 readme: Option<String>,
44 template: Option<bool>,
46 trust_model: Option<TrustModel>,
48}
49
50impl CreateRepoBuilder {
51 pub fn new(org: impl ToString, name: impl ToString) -> Self {
52 Self {
53 org: org.to_string(),
54 name: name.to_string(),
55 auto_init: None,
56 default_branch: None,
57 description: None,
58 gitignores: None,
59 issue_labels: None,
60 license: None,
61 object_format_name: None,
62 private: None,
63 readme: None,
64 template: None,
65 trust_model: None,
66 }
67 }
68 pub async fn send(&self, client: &Client) -> Result<Repository> {
71 let org = &self.org;
72 let req = client.post(format!("orgs/{org}/repos")).json(self).build()?;
73 let res = client.make_request(req).await?;
74 client.parse_response(res).await
75 }
76}