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: Option<String>,
12    pub description: Option<String>,
13    pub is_private: Option<bool>,
14    pub scm: Option<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    #[serde(rename = "type")]
28    pub repo_type: Option<String>,
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
32pub struct RepositoryLinks {
33    #[serde(rename = "self")]
34    pub self_link: Option<Link>,
35    pub html: Option<Link>,
36    pub avatar: Option<Link>,
37    pub clone: Option<Vec<CloneLink>>,
38    pub pullrequests: Option<Link>,
39    pub commits: Option<Link>,
40    pub forks: Option<Link>,
41    pub watchers: Option<Link>,
42    pub branches: Option<Link>,
43    pub tags: Option<Link>,
44    pub downloads: Option<Link>,
45    pub source: Option<Link>,
46    pub issues: Option<Link>,
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct CloneLink {
51    pub href: String,
52    pub name: String,
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
56pub struct Branch {
57    pub name: String,
58    #[serde(rename = "type")]
59    pub branch_type: Option<String>,
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
63pub struct Project {
64    pub uuid: String,
65    pub key: String,
66    pub name: String,
67    #[serde(rename = "type")]
68    pub project_type: String,
69    pub links: Option<ProjectLinks>,
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize)]
73pub struct ProjectLinks {
74    pub html: Option<Link>,
75    pub avatar: Option<Link>,
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
79pub struct CreateRepositoryRequest {
80    pub scm: String,
81    pub name: Option<String>,
82    pub description: Option<String>,
83    pub is_private: Option<bool>,
84    pub project: Option<ProjectKey>,
85    pub fork_policy: Option<String>,
86    pub language: Option<String>,
87    pub has_issues: Option<bool>,
88    pub has_wiki: Option<bool>,
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize)]
92pub struct ProjectKey {
93    pub key: String,
94}
95
96impl Default for CreateRepositoryRequest {
97    fn default() -> Self {
98        Self {
99            scm: "git".to_string(),
100            name: None,
101            description: None,
102            is_private: Some(true),
103            project: None,
104            fork_policy: Some("no_public_forks".to_string()),
105            language: None,
106            has_issues: Some(true),
107            has_wiki: Some(false),
108        }
109    }
110}