From 6379525007ac1dcd188ec074ba8635a70edd70b8 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Thu, 25 Apr 2024 12:08:37 -0400 Subject: [PATCH] regenerate source --- src/generated/methods.rs | 305 +++++++++++++++++++++++++++++++++++++++ src/generated/structs.rs | 134 +++++++++++++++-- 2 files changed, 426 insertions(+), 13 deletions(-) diff --git a/src/generated/methods.rs b/src/generated/methods.rs index efbdb64..9cc914f 100644 --- a/src/generated/methods.rs +++ b/src/generated/methods.rs @@ -169,6 +169,18 @@ impl crate::Forgejo { } } + /// Get an global actions runner registration token + pub async fn admin_get_runner_registration_token( + &self, + ) -> Result { + let request = self.get("admin/runners/registration-token").build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.headers().try_into()?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// List unadopted repositories /// pub async fn admin_unadopted_list( @@ -664,6 +676,23 @@ impl crate::Forgejo { } } + /// Get an organization's actions runner registration token + /// + /// - `org`: name of the organization + pub async fn org_get_runner_registration_token( + &self, + org: &str, + ) -> Result { + let request = self + .get(&format!("orgs/{org}/actions/runners/registration-token")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.headers().try_into()?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// List an organization's actions secrets /// /// - `org`: name of the organization @@ -1884,6 +1913,27 @@ impl crate::Forgejo { } } + /// Get the pull request of the commit + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `sha`: SHA of the commit to get + pub async fn repo_get_commit_pull_request( + &self, + owner: &str, + repo: &str, + sha: &str, + ) -> Result { + let request = self + .get(&format!("repos/{owner}/{repo}/commits/{sha}/pull")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// Gets the metadata of all the entries of the root dir /// /// - `owner`: owner of the repo @@ -2066,6 +2116,123 @@ impl crate::Forgejo { } } + /// List a repository's flags + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_list_flags( + &self, + owner: &str, + repo: &str, + ) -> Result, ForgejoError> { + let request = self.get(&format!("repos/{owner}/{repo}/flags")).build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Replace all flags of a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `body`: See [`ReplaceFlagsOption`] + pub async fn repo_replace_all_flags( + &self, + owner: &str, + repo: &str, + body: ReplaceFlagsOption, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!("repos/{owner}/{repo}/flags")) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Remove all flags from a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_delete_all_flags(&self, owner: &str, repo: &str) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("repos/{owner}/{repo}/flags")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Check if a repository has a given flag + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `flag`: name of the flag + pub async fn repo_check_flag( + &self, + owner: &str, + repo: &str, + flag: &str, + ) -> Result<(), ForgejoError> { + let request = self + .get(&format!("repos/{owner}/{repo}/flags/{flag}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Add a flag to a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `flag`: name of the flag + pub async fn repo_add_flag( + &self, + owner: &str, + repo: &str, + flag: &str, + ) -> Result<(), ForgejoError> { + let request = self + .put(&format!("repos/{owner}/{repo}/flags/{flag}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Remove a flag from a repository + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `flag`: name of the flag + pub async fn repo_delete_flag( + &self, + owner: &str, + repo: &str, + flag: &str, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!("repos/{owner}/{repo}/flags/{flag}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// List a repository's forks /// /// - `owner`: owner of the repo @@ -4396,6 +4563,29 @@ impl crate::Forgejo { } } + /// Get a pull request by base and head + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `base`: base of the pull request to get + /// - `head`: head of the pull request to get + pub async fn repo_get_pull_request_by_base_head( + &self, + owner: &str, + repo: &str, + base: &str, + head: &str, + ) -> Result { + let request = self + .get(&format!("repos/{owner}/{repo}/pulls/{base}/{head}")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// Get a pull request /// /// - `owner`: owner of the repo @@ -4776,6 +4966,88 @@ impl crate::Forgejo { } } + /// Add a new comment to a pull request review + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + /// - `id`: id of the review + /// - `body`: See [`serde_json::Value`] + pub async fn repo_create_pull_review_comment( + &self, + owner: &str, + repo: &str, + index: u64, + id: u64, + body: serde_json::Value, + ) -> Result { + let request = self + .post(&format!( + "repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments" + )) + .json(&body) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Get a pull review comment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + /// - `id`: id of the review + /// - `comment`: id of the comment + pub async fn repo_get_pull_review_comment( + &self, + owner: &str, + repo: &str, + index: u64, + id: u64, + comment: u64, + ) -> Result { + let request = self + .get(&format!( + "repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments/{comment}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.json().await?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + + /// Delete a pull review comment + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + /// - `index`: index of the pull request + /// - `id`: id of the review + /// - `comment`: id of the comment + pub async fn repo_delete_pull_review_comment( + &self, + owner: &str, + repo: &str, + index: u64, + id: u64, + comment: u64, + ) -> Result<(), ForgejoError> { + let request = self + .delete(&format!( + "repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments/{comment}" + )) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 204 => Ok(()), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// Dismiss a review for a pull request /// /// - `owner`: owner of the repo @@ -5296,6 +5568,25 @@ impl crate::Forgejo { } } + /// Get a repository's actions runner registration token + /// + /// - `owner`: owner of the repo + /// - `repo`: name of the repo + pub async fn repo_get_runner_registration_token( + &self, + owner: &str, + repo: &str, + ) -> Result { + let request = self + .get(&format!("repos/{owner}/{repo}/runners/registration-token")) + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.headers().try_into()?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// Get signing-key.gpg for given repository /// /// - `owner`: owner of the repo @@ -6252,6 +6543,20 @@ impl crate::Forgejo { } } + /// Get an user's actions runner registration token + pub async fn user_get_runner_registration_token( + &self, + ) -> Result { + let request = self + .get("user/actions/runners/registration-token") + .build()?; + let response = self.execute(request).await?; + match response.status().as_u16() { + 200 => Ok(response.headers().try_into()?), + _ => Err(ForgejoError::UnexpectedStatusCode(response.status())), + } + } + /// Create or Update a secret value in a user scope /// /// - `secretname`: name of the secret diff --git a/src/generated/structs.rs b/src/generated/structs.rs index 1a0dee8..6fc1a3a 100644 --- a/src/generated/structs.rs +++ b/src/generated/structs.rs @@ -120,6 +120,7 @@ pub struct Branch { /// BranchProtection represents a branch protection for a repository #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct BranchProtection { + pub apply_to_admins: Option, pub approvals_whitelist_teams: Option>, pub approvals_whitelist_username: Option>, pub block_on_official_review_requests: Option, @@ -135,6 +136,7 @@ pub struct BranchProtection { pub enable_push: Option, pub enable_push_whitelist: Option, pub enable_status_check: Option, + pub ignore_stale_approvals: Option, pub merge_whitelist_teams: Option>, pub merge_whitelist_usernames: Option>, pub protected_file_patterns: Option, @@ -371,6 +373,7 @@ pub struct CreateAccessTokenOption { /// CreateBranchProtectionOption options for creating a branch protection #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CreateBranchProtectionOption { + pub apply_to_admins: Option, pub approvals_whitelist_teams: Option>, pub approvals_whitelist_username: Option>, pub block_on_official_review_requests: Option, @@ -384,6 +387,7 @@ pub struct CreateBranchProtectionOption { pub enable_push: Option, pub enable_push_whitelist: Option, pub enable_status_check: Option, + pub ignore_stale_approvals: Option, pub merge_whitelist_teams: Option>, pub merge_whitelist_usernames: Option>, pub protected_file_patterns: Option, @@ -632,6 +636,10 @@ pub struct CreatePullReviewComment { pub path: Option, } +/// CreatePullReviewCommentOptions are options to create a pull review comment +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct CreatePullReviewCommentOptions {} + /// CreatePullReviewOptions are options to create a pull review #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct CreatePullReviewOptions { @@ -678,6 +686,8 @@ pub struct CreateRepoOption { pub license: Option, /// Name of the repository to create pub name: String, + /// ObjectFormatName of the underlying git repository + pub object_format_name: Option, /// Whether the repository is private pub private: Option, /// Readme of the repository to create @@ -688,6 +698,15 @@ pub struct CreateRepoOption { pub trust_model: Option, } +/// ObjectFormatName of the underlying git repository + +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub enum CreateRepoOptionObjectFormatName { + #[serde(rename = "sha1")] + Sha1, + #[serde(rename = "sha256")] + Sha256, +} /// TrustModel of the repository #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] @@ -851,6 +870,7 @@ pub struct EditAttachmentOptions { /// EditBranchProtectionOption options for editing a branch protection #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EditBranchProtectionOption { + pub apply_to_admins: Option, pub approvals_whitelist_teams: Option>, pub approvals_whitelist_username: Option>, pub block_on_official_review_requests: Option, @@ -862,6 +882,7 @@ pub struct EditBranchProtectionOption { pub enable_push: Option, pub enable_push_whitelist: Option, pub enable_status_check: Option, + pub ignore_stale_approvals: Option, pub merge_whitelist_teams: Option>, pub merge_whitelist_usernames: Option>, pub protected_file_patterns: Option, @@ -1005,6 +1026,8 @@ pub struct EditReleaseOption { /// EditRepoOption options when editing a repository's properties #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct EditRepoOption { + /// either `true` to allow fast-forward-only merging pull requests, or `false` to prevent fast-forward-only merging. + pub allow_fast_forward_only_merge: Option, /// either `true` to allow mark pr as merged manually, or `false` to prevent it. pub allow_manual_merge: Option, /// either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. @@ -1027,7 +1050,7 @@ pub struct EditRepoOption { pub default_branch: Option, /// set to `true` to delete pr branch after merge by default pub default_delete_branch_after_merge: Option, - /// set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", or "squash". + /// set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", "squash", or "fast-forward-only". pub default_merge_style: Option, /// a short description of the repository. pub description: Option, @@ -1066,6 +1089,8 @@ pub struct EditRepoOption { pub template: Option, /// a URL with more information about the repository. pub website: Option, + /// sets the branch used for this repository's wiki. + pub wiki_branch: Option, } /// EditTeamOption options for editing a team @@ -1106,6 +1131,7 @@ pub struct EditUserOption { pub must_change_password: Option, pub password: Option, pub prohibit_login: Option, + pub pronouns: Option, pub restricted: Option, pub source_id: u64, pub visibility: Option, @@ -1241,6 +1267,7 @@ pub struct GeneralAttachmentSettings { /// GeneralRepoSettings contains global repository settings exposed by API #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct GeneralRepoSettings { + pub forks_disabled: Option, pub http_git_disabled: Option, pub lfs_disabled: Option, pub migrations_disabled: Option, @@ -1352,15 +1379,20 @@ pub struct Hook { pub active: Option, pub authorization_header: Option, pub branch_filter: Option, + /// Deprecated: use Metadata instead pub config: Option>, + pub content_type: Option, #[serde(with = "time::serde::rfc3339::option")] pub created_at: Option, pub events: Option>, pub id: Option, + pub metadata: Option, #[serde(rename = "type")] pub r#type: Option, #[serde(with = "time::serde::rfc3339::option")] pub updated_at: Option, + #[serde(deserialize_with = "crate::none_if_blank_url")] + pub url: Option, } /// Identity for a person's identity like an author or committer @@ -1453,11 +1485,16 @@ pub struct IssueFormField { #[serde(rename = "type")] pub r#type: Option, pub validations: Option>, + pub visible: Option>, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct IssueFormFieldType {} +/// IssueFormFieldVisible defines issue form field visible +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct IssueFormFieldVisible {} + /// IssueLabelsOption a collection of labels #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct IssueLabelsOption { @@ -1631,6 +1668,8 @@ pub enum MergePullRequestOptionDo { RebaseMerge, #[serde(rename = "squash")] Squash, + #[serde(rename = "fast-forward-only")] + FastForwardOnly, #[serde(rename = "manually-merged")] ManuallyMerged, } @@ -1995,6 +2034,7 @@ pub struct PullRequest { /// PullRequestMeta PR info if an issue is a PR #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct PullRequestMeta { + pub draft: Option, pub merged: Option, #[serde(with = "time::serde::rfc3339::option")] pub merged_at: Option, @@ -2057,10 +2097,12 @@ pub struct PullReviewRequestOptions { /// PushMirror represents information of a push mirror #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct PushMirror { - pub created: Option, + #[serde(with = "time::serde::rfc3339::option")] + pub created: Option, pub interval: Option, pub last_error: Option, - pub last_update: Option, + #[serde(with = "time::serde::rfc3339::option")] + pub last_update: Option, pub remote_address: Option, pub remote_name: Option, pub repo_name: Option, @@ -2120,6 +2162,12 @@ pub struct RenameUserOption { pub new_username: String, } +/// ReplaceFlagsOption options when replacing the flags of a repository +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct ReplaceFlagsOption { + pub flags: Option>, +} + /// RepoCollaboratorPermission to get repository permission for a collaborator #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct RepoCollaboratorPermission { @@ -2157,6 +2205,7 @@ pub struct RepoTransfer { /// Repository represents a repository #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Repository { + pub allow_fast_forward_only_merge: Option, pub allow_merge_commits: Option, pub allow_rebase: Option, pub allow_rebase_explicit: Option, @@ -2204,6 +2253,8 @@ pub struct Repository { #[serde(with = "time::serde::rfc3339::option")] pub mirror_updated: Option, pub name: Option, + /// ObjectFormatName of the underlying git repository + pub object_format_name: Option, pub open_issues_count: Option, pub open_pr_counter: Option, #[serde(deserialize_with = "crate::none_if_blank_url")] @@ -2224,8 +2275,18 @@ pub struct Repository { pub url: Option, pub watchers_count: Option, pub website: Option, + pub wiki_branch: Option, } +/// ObjectFormatName of the underlying git repository + +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub enum RepositoryObjectFormatName { + #[serde(rename = "sha1")] + Sha1, + #[serde(rename = "sha256")] + Sha256, +} /// RepositoryMeta basic repository information #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct RepositoryMeta { @@ -2485,6 +2546,8 @@ pub struct User { pub login_name: Option, /// Is user login prohibited pub prohibit_login: Option, + /// the user's pronouns + pub pronouns: Option, /// Is user restricted pub restricted: Option, pub starred_repos_count: Option, @@ -2506,12 +2569,14 @@ pub struct UserHeatmapData { pub struct UserSettings { pub description: Option, pub diff_view_style: Option, + pub enable_repo_unit_hints: Option, pub full_name: Option, pub hide_activity: Option, /// Privacy pub hide_email: Option, pub language: Option, pub location: Option, + pub pronouns: Option, pub theme: Option, pub website: Option, } @@ -2521,12 +2586,14 @@ pub struct UserSettings { pub struct UserSettingsOptions { pub description: Option, pub diff_view_style: Option, + pub enable_repo_unit_hints: Option, pub full_name: Option, pub hide_activity: Option, /// Privacy pub hide_email: Option, pub language: Option, pub location: Option, + pub pronouns: Option, pub theme: Option, pub website: Option, } @@ -2593,7 +2660,7 @@ pub struct ChangedFileListHeaders { pub x_page: Option, pub x_page_count: Option, pub x_per_page: Option, - pub x_total: Option, + pub x_total_count: Option, } impl TryFrom<&reqwest::header::HeaderMap> for ChangedFileListHeaders { @@ -2632,8 +2699,8 @@ impl TryFrom<&reqwest::header::HeaderMap> for ChangedFileListHeaders { .map_err(|_| StructureError::HeaderParseFailed) }) .transpose()?; - let x_total = map - .get("X-Total") + let x_total_count = map + .get("X-Total-Count") .map(|s| -> Result<_, _> { let s = s.to_str().map_err(|_| StructureError::HeaderNotAscii)?; s.parse::() @@ -2645,7 +2712,7 @@ impl TryFrom<&reqwest::header::HeaderMap> for ChangedFileListHeaders { x_page, x_page_count, x_per_page, - x_total, + x_total_count, }) } } @@ -2712,6 +2779,25 @@ impl TryFrom<&reqwest::header::HeaderMap> for CommitListHeaders { } } +pub struct RegistrationTokenHeaders { + pub token: Option, +} + +impl TryFrom<&reqwest::header::HeaderMap> for RegistrationTokenHeaders { + type Error = StructureError; + + fn try_from(map: &reqwest::header::HeaderMap) -> Result { + let token = map + .get("token") + .map(|s| -> Result<_, _> { + let s = s.to_str().map_err(|_| StructureError::HeaderNotAscii)?; + Ok(s.to_string()) + }) + .transpose()?; + Ok(Self { token }) + } +} + pub struct ErrorHeaders { pub message: Option, pub url: Option, @@ -2796,6 +2882,33 @@ impl TryFrom<&reqwest::header::HeaderMap> for InvalidTopicsErrorHeaders { } } +pub struct RepoArchivedErrorHeaders { + pub message: Option, + pub url: Option, +} + +impl TryFrom<&reqwest::header::HeaderMap> for RepoArchivedErrorHeaders { + type Error = StructureError; + + fn try_from(map: &reqwest::header::HeaderMap) -> Result { + let message = map + .get("message") + .map(|s| -> Result<_, _> { + let s = s.to_str().map_err(|_| StructureError::HeaderNotAscii)?; + Ok(s.to_string()) + }) + .transpose()?; + let url = map + .get("url") + .map(|s| -> Result<_, _> { + let s = s.to_str().map_err(|_| StructureError::HeaderNotAscii)?; + Ok(s.to_string()) + }) + .transpose()?; + Ok(Self { message, url }) + } +} + pub struct ValidationErrorHeaders { pub message: Option, pub url: Option, @@ -4145,7 +4258,7 @@ pub struct IssueListIssuesQuery { pub since: Option, /// Only show items updated before the given time. This is a timestamp in RFC 3339 format pub before: Option, - /// Only show items which were created by the the given user + /// Only show items which were created by the given user pub created_by: Option, /// Only show items for which the given user is assigned pub assigned_by: Option, @@ -5078,8 +5191,6 @@ pub struct RepoListReleasesQuery { pub draft: Option, /// filter (exclude / include) pre-releases pub pre_release: Option, - /// page size of results, deprecated - use limit - pub per_page: Option, /// page number of results to return (1-based) pub page: Option, /// page size of results @@ -5094,9 +5205,6 @@ impl std::fmt::Display for RepoListReleasesQuery { if let Some(pre_release) = &self.pre_release { write!(f, "pre-release={pre_release}&")?; } - if let Some(per_page) = &self.per_page { - write!(f, "per_page={per_page}&")?; - } if let Some(page) = &self.page { write!(f, "page={page}&")?; }