1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use build_it::Builder;
use serde::Serialize;

use crate::{model::repos::Repository, Result};

#[derive(Debug, Clone, PartialEq, Serialize, Builder)]
#[serde(default)]
pub struct MigrateRepoBuilder {
    #[skip]
    clone_addr: String,
    #[skip]
    repo_name: String,
    auth_password: Option<String>,
    auth_token: Option<String>,
    auth_username: Option<String>,
    description: Option<String>,
    issues: Option<bool>,
    labels: Option<bool>,
    lfs: Option<bool>,
    lfs_endpoint: Option<String>,
    milestones: Option<bool>,
    mirror: Option<bool>,
    mirror_interval: Option<String>,
    private: Option<bool>,
    pull_requests: Option<bool>,
    releases: Option<bool>,
    repo_owner: Option<String>,
    service: Option<String>,
    wiki: Option<bool>,
}

impl MigrateRepoBuilder {
    pub fn new(clone_addr: impl ToString, repo_name: impl ToString) -> Self {
        Self {
            clone_addr: clone_addr.to_string(),
            repo_name: repo_name.to_string(),
            auth_password: None,
            auth_token: None,
            auth_username: None,
            description: None,
            issues: None,
            labels: None,
            lfs: None,
            lfs_endpoint: None,
            milestones: None,
            mirror: None,
            mirror_interval: None,
            private: None,
            pull_requests: None,
            releases: None,
            repo_owner: None,
            service: None,
            wiki: None,
        }
    }

    /// Send the request to migrate a repository.
    pub async fn send(&self, client: &crate::Client) -> Result<Repository> {
        let req = client.post("repos/migrate").json(&self).build()?;
        let res = client.make_request(req).await?;
        client.parse_response(res).await
    }
}