bitbucket_cli/models/
repo.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4use super::user::{Link, User, Workspace};
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct Repository {
8    pub uuid: String,
9    pub name: String,
10    pub full_name: String,
11    pub slug: String,
12    pub description: Option<String>,
13    pub is_private: bool,
14    pub scm: String,
15    pub owner: Option<User>,
16    pub workspace: Option<Workspace>,
17    pub project: Option<Project>,
18    pub created_on: Option<DateTime<Utc>>,
19    pub updated_on: Option<DateTime<Utc>>,
20    pub size: Option<u64>,
21    pub language: Option<String>,
22    pub has_issues: Option<bool>,
23    pub has_wiki: Option<bool>,
24    pub fork_policy: Option<String>,
25    pub mainbranch: Option<Branch>,
26    pub links: Option<RepositoryLinks>,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct RepositoryLinks {
31    pub self_link: Option<Link>,
32    pub html: Option<Link>,
33    pub clone: Option<Vec<CloneLink>>,
34    pub pullrequests: Option<Link>,
35    pub commits: Option<Link>,
36    pub forks: Option<Link>,
37    pub watchers: Option<Link>,
38    pub branches: Option<Link>,
39    pub tags: Option<Link>,
40    pub downloads: Option<Link>,
41    pub source: Option<Link>,
42    pub issues: Option<Link>,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct CloneLink {
47    pub href: String,
48    pub name: String,
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
52pub struct Branch {
53    pub name: String,
54    #[serde(rename = "type")]
55    pub branch_type: Option<String>,
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
59pub struct Project {
60    pub uuid: String,
61    pub key: String,
62    pub name: String,
63    #[serde(rename = "type")]
64    pub project_type: String,
65    pub links: Option<ProjectLinks>,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct ProjectLinks {
70    pub html: Option<Link>,
71    pub avatar: Option<Link>,
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
75pub struct CreateRepositoryRequest {
76    pub scm: String,
77    pub name: Option<String>,
78    pub description: Option<String>,
79    pub is_private: Option<bool>,
80    pub project: Option<ProjectKey>,
81    pub fork_policy: Option<String>,
82    pub language: Option<String>,
83    pub has_issues: Option<bool>,
84    pub has_wiki: Option<bool>,
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize)]
88pub struct ProjectKey {
89    pub key: String,
90}
91
92impl Default for CreateRepositoryRequest {
93    fn default() -> Self {
94        Self {
95            scm: "git".to_string(),
96            name: None,
97            description: None,
98            is_private: Some(true),
99            project: None,
100            fork_policy: Some("no_public_forks".to_string()),
101            language: None,
102            has_issues: Some(true),
103            has_wiki: Some(false),
104        }
105    }
106}