gitea_sdk/api/
migrate.rs

1use build_it::Builder;
2use serde::Serialize;
3
4use crate::{model::repos::Repository, Result};
5
6#[derive(Debug, Clone, PartialEq, Serialize, Builder)]
7#[build_it(into)]
8#[serde(default)]
9pub struct MigrateRepoBuilder {
10    #[skip]
11    clone_addr: String,
12    #[skip]
13    repo_name: String,
14    auth_password: Option<String>,
15    auth_token: Option<String>,
16    auth_username: Option<String>,
17    description: Option<String>,
18    issues: Option<bool>,
19    labels: Option<bool>,
20    lfs: Option<bool>,
21    lfs_endpoint: Option<String>,
22    milestones: Option<bool>,
23    mirror: Option<bool>,
24    mirror_interval: Option<String>,
25    private: Option<bool>,
26    pull_requests: Option<bool>,
27    releases: Option<bool>,
28    repo_owner: Option<String>,
29    service: Option<String>,
30    wiki: Option<bool>,
31}
32
33impl MigrateRepoBuilder {
34    pub fn new(clone_addr: impl ToString, repo_name: impl ToString) -> Self {
35        Self {
36            clone_addr: clone_addr.to_string(),
37            repo_name: repo_name.to_string(),
38            auth_password: None,
39            auth_token: None,
40            auth_username: None,
41            description: None,
42            issues: None,
43            labels: None,
44            lfs: None,
45            lfs_endpoint: None,
46            milestones: None,
47            mirror: None,
48            mirror_interval: None,
49            private: None,
50            pull_requests: None,
51            releases: None,
52            repo_owner: None,
53            service: None,
54            wiki: None,
55        }
56    }
57
58    /// Send the request to migrate a repository.
59    pub async fn send(&self, client: &crate::Client) -> Result<Repository> {
60        let req = client.post("repos/migrate").json(&self).build()?;
61        let res = client.make_request(req).await?;
62        client.parse_response(res).await
63    }
64}