1
0
Fork 0

Merge pull request 'update to Forgejo 7.0's API' (#46) from v7.0 into main

Reviewed-on: https://codeberg.org/Cyborus/forgejo-api/pulls/46
This commit is contained in:
Cyborus 2024-04-26 15:36:30 +00:00
commit c8251debb6
4 changed files with 1211 additions and 31 deletions

View file

@ -5,10 +5,10 @@ steps:
image: rust image: rust
environment: environment:
- "FORGEJO_API_CI_INSTANCE_URL=http://forgejo-testing:3000/" - "FORGEJO_API_CI_INSTANCE_URL=http://forgejo-testing:3000/"
- FORGEJO_API_CI_TOKEN=3226a46b52e29804bfb9b8ba21a5f91291fb86eb - FORGEJO_API_CI_TOKEN=6c340bf9ed25adf28701f618fda5f82c934db1f3
commands: commands:
- cargo test - cargo test
services: services:
forgejo-testing: forgejo-testing:
image: code.cartoon-aa.xyz/cyborus/ci-forgejo:1.21.2-0 image: code.cartoon-aa.xyz/cyborus/ci-forgejo:7.0.0

View file

@ -169,6 +169,18 @@ impl crate::Forgejo {
} }
} }
/// Get an global actions runner registration token
pub async fn admin_get_runner_registration_token(
&self,
) -> Result<RegistrationTokenHeaders, ForgejoError> {
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 /// List unadopted repositories
/// ///
pub async fn admin_unadopted_list( 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<RegistrationTokenHeaders, ForgejoError> {
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 /// List an organization's actions secrets
/// ///
/// - `org`: name of the organization /// - `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<PullRequest, ForgejoError> {
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 /// Gets the metadata of all the entries of the root dir
/// ///
/// - `owner`: owner of the repo /// - `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<Vec<String>, 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 /// List a repository's forks
/// ///
/// - `owner`: owner of the repo /// - `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<PullRequest, ForgejoError> {
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 /// Get a pull request
/// ///
/// - `owner`: owner of the repo /// - `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<PullReviewComment, ForgejoError> {
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<PullReviewComment, ForgejoError> {
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 /// Dismiss a review for a pull request
/// ///
/// - `owner`: owner of the repo /// - `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<RegistrationTokenHeaders, ForgejoError> {
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 /// Get signing-key.gpg for given repository
/// ///
/// - `owner`: owner of the repo /// - `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<RegistrationTokenHeaders, ForgejoError> {
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 /// Create or Update a secret value in a user scope
/// ///
/// - `secretname`: name of the secret /// - `secretname`: name of the secret

View file

@ -120,6 +120,7 @@ pub struct Branch {
/// BranchProtection represents a branch protection for a repository /// BranchProtection represents a branch protection for a repository
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct BranchProtection { pub struct BranchProtection {
pub apply_to_admins: Option<bool>,
pub approvals_whitelist_teams: Option<Vec<String>>, pub approvals_whitelist_teams: Option<Vec<String>>,
pub approvals_whitelist_username: Option<Vec<String>>, pub approvals_whitelist_username: Option<Vec<String>>,
pub block_on_official_review_requests: Option<bool>, pub block_on_official_review_requests: Option<bool>,
@ -135,6 +136,7 @@ pub struct BranchProtection {
pub enable_push: Option<bool>, pub enable_push: Option<bool>,
pub enable_push_whitelist: Option<bool>, pub enable_push_whitelist: Option<bool>,
pub enable_status_check: Option<bool>, pub enable_status_check: Option<bool>,
pub ignore_stale_approvals: Option<bool>,
pub merge_whitelist_teams: Option<Vec<String>>, pub merge_whitelist_teams: Option<Vec<String>>,
pub merge_whitelist_usernames: Option<Vec<String>>, pub merge_whitelist_usernames: Option<Vec<String>>,
pub protected_file_patterns: Option<String>, pub protected_file_patterns: Option<String>,
@ -371,6 +373,7 @@ pub struct CreateAccessTokenOption {
/// CreateBranchProtectionOption options for creating a branch protection /// CreateBranchProtectionOption options for creating a branch protection
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct CreateBranchProtectionOption { pub struct CreateBranchProtectionOption {
pub apply_to_admins: Option<bool>,
pub approvals_whitelist_teams: Option<Vec<String>>, pub approvals_whitelist_teams: Option<Vec<String>>,
pub approvals_whitelist_username: Option<Vec<String>>, pub approvals_whitelist_username: Option<Vec<String>>,
pub block_on_official_review_requests: Option<bool>, pub block_on_official_review_requests: Option<bool>,
@ -384,6 +387,7 @@ pub struct CreateBranchProtectionOption {
pub enable_push: Option<bool>, pub enable_push: Option<bool>,
pub enable_push_whitelist: Option<bool>, pub enable_push_whitelist: Option<bool>,
pub enable_status_check: Option<bool>, pub enable_status_check: Option<bool>,
pub ignore_stale_approvals: Option<bool>,
pub merge_whitelist_teams: Option<Vec<String>>, pub merge_whitelist_teams: Option<Vec<String>>,
pub merge_whitelist_usernames: Option<Vec<String>>, pub merge_whitelist_usernames: Option<Vec<String>>,
pub protected_file_patterns: Option<String>, pub protected_file_patterns: Option<String>,
@ -632,6 +636,10 @@ pub struct CreatePullReviewComment {
pub path: Option<String>, pub path: Option<String>,
} }
/// 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 /// CreatePullReviewOptions are options to create a pull review
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct CreatePullReviewOptions { pub struct CreatePullReviewOptions {
@ -851,6 +859,7 @@ pub struct EditAttachmentOptions {
/// EditBranchProtectionOption options for editing a branch protection /// EditBranchProtectionOption options for editing a branch protection
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct EditBranchProtectionOption { pub struct EditBranchProtectionOption {
pub apply_to_admins: Option<bool>,
pub approvals_whitelist_teams: Option<Vec<String>>, pub approvals_whitelist_teams: Option<Vec<String>>,
pub approvals_whitelist_username: Option<Vec<String>>, pub approvals_whitelist_username: Option<Vec<String>>,
pub block_on_official_review_requests: Option<bool>, pub block_on_official_review_requests: Option<bool>,
@ -862,6 +871,7 @@ pub struct EditBranchProtectionOption {
pub enable_push: Option<bool>, pub enable_push: Option<bool>,
pub enable_push_whitelist: Option<bool>, pub enable_push_whitelist: Option<bool>,
pub enable_status_check: Option<bool>, pub enable_status_check: Option<bool>,
pub ignore_stale_approvals: Option<bool>,
pub merge_whitelist_teams: Option<Vec<String>>, pub merge_whitelist_teams: Option<Vec<String>>,
pub merge_whitelist_usernames: Option<Vec<String>>, pub merge_whitelist_usernames: Option<Vec<String>>,
pub protected_file_patterns: Option<String>, pub protected_file_patterns: Option<String>,
@ -1005,6 +1015,8 @@ pub struct EditReleaseOption {
/// EditRepoOption options when editing a repository's properties /// EditRepoOption options when editing a repository's properties
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct EditRepoOption { 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<bool>,
/// either `true` to allow mark pr as merged manually, or `false` to prevent it. /// either `true` to allow mark pr as merged manually, or `false` to prevent it.
pub allow_manual_merge: Option<bool>, pub allow_manual_merge: Option<bool>,
/// either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. /// either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits.
@ -1027,7 +1039,7 @@ pub struct EditRepoOption {
pub default_branch: Option<String>, pub default_branch: Option<String>,
/// set to `true` to delete pr branch after merge by default /// set to `true` to delete pr branch after merge by default
pub default_delete_branch_after_merge: Option<bool>, pub default_delete_branch_after_merge: Option<bool>,
/// 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<String>, pub default_merge_style: Option<String>,
/// a short description of the repository. /// a short description of the repository.
pub description: Option<String>, pub description: Option<String>,
@ -1066,6 +1078,8 @@ pub struct EditRepoOption {
pub template: Option<bool>, pub template: Option<bool>,
/// a URL with more information about the repository. /// a URL with more information about the repository.
pub website: Option<String>, pub website: Option<String>,
/// sets the branch used for this repository's wiki.
pub wiki_branch: Option<String>,
} }
/// EditTeamOption options for editing a team /// EditTeamOption options for editing a team
@ -1106,6 +1120,7 @@ pub struct EditUserOption {
pub must_change_password: Option<bool>, pub must_change_password: Option<bool>,
pub password: Option<String>, pub password: Option<String>,
pub prohibit_login: Option<bool>, pub prohibit_login: Option<bool>,
pub pronouns: Option<String>,
pub restricted: Option<bool>, pub restricted: Option<bool>,
pub source_id: u64, pub source_id: u64,
pub visibility: Option<String>, pub visibility: Option<String>,
@ -1241,6 +1256,7 @@ pub struct GeneralAttachmentSettings {
/// GeneralRepoSettings contains global repository settings exposed by API /// GeneralRepoSettings contains global repository settings exposed by API
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct GeneralRepoSettings { pub struct GeneralRepoSettings {
pub forks_disabled: Option<bool>,
pub http_git_disabled: Option<bool>, pub http_git_disabled: Option<bool>,
pub lfs_disabled: Option<bool>, pub lfs_disabled: Option<bool>,
pub migrations_disabled: Option<bool>, pub migrations_disabled: Option<bool>,
@ -1352,15 +1368,20 @@ pub struct Hook {
pub active: Option<bool>, pub active: Option<bool>,
pub authorization_header: Option<String>, pub authorization_header: Option<String>,
pub branch_filter: Option<String>, pub branch_filter: Option<String>,
/// Deprecated: use Metadata instead
pub config: Option<BTreeMap<String, String>>, pub config: Option<BTreeMap<String, String>>,
pub content_type: Option<String>,
#[serde(with = "time::serde::rfc3339::option")] #[serde(with = "time::serde::rfc3339::option")]
pub created_at: Option<time::OffsetDateTime>, pub created_at: Option<time::OffsetDateTime>,
pub events: Option<Vec<String>>, pub events: Option<Vec<String>>,
pub id: Option<u64>, pub id: Option<u64>,
pub metadata: Option<serde_json::Value>,
#[serde(rename = "type")] #[serde(rename = "type")]
pub r#type: Option<String>, pub r#type: Option<String>,
#[serde(with = "time::serde::rfc3339::option")] #[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<time::OffsetDateTime>, pub updated_at: Option<time::OffsetDateTime>,
#[serde(deserialize_with = "crate::none_if_blank_url")]
pub url: Option<url::Url>,
} }
/// Identity for a person's identity like an author or committer /// Identity for a person's identity like an author or committer
@ -1453,11 +1474,16 @@ pub struct IssueFormField {
#[serde(rename = "type")] #[serde(rename = "type")]
pub r#type: Option<String>, pub r#type: Option<String>,
pub validations: Option<BTreeMap<String, serde_json::Value>>, pub validations: Option<BTreeMap<String, serde_json::Value>>,
pub visible: Option<Vec<String>>,
} }
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct IssueFormFieldType {} 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 /// IssueLabelsOption a collection of labels
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct IssueLabelsOption { pub struct IssueLabelsOption {
@ -1631,6 +1657,8 @@ pub enum MergePullRequestOptionDo {
RebaseMerge, RebaseMerge,
#[serde(rename = "squash")] #[serde(rename = "squash")]
Squash, Squash,
#[serde(rename = "fast-forward-only")]
FastForwardOnly,
#[serde(rename = "manually-merged")] #[serde(rename = "manually-merged")]
ManuallyMerged, ManuallyMerged,
} }
@ -1995,6 +2023,7 @@ pub struct PullRequest {
/// PullRequestMeta PR info if an issue is a PR /// PullRequestMeta PR info if an issue is a PR
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct PullRequestMeta { pub struct PullRequestMeta {
pub draft: Option<bool>,
pub merged: Option<bool>, pub merged: Option<bool>,
#[serde(with = "time::serde::rfc3339::option")] #[serde(with = "time::serde::rfc3339::option")]
pub merged_at: Option<time::OffsetDateTime>, pub merged_at: Option<time::OffsetDateTime>,
@ -2057,10 +2086,12 @@ pub struct PullReviewRequestOptions {
/// PushMirror represents information of a push mirror /// PushMirror represents information of a push mirror
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct PushMirror { pub struct PushMirror {
pub created: Option<String>, #[serde(with = "time::serde::rfc3339::option")]
pub created: Option<time::OffsetDateTime>,
pub interval: Option<String>, pub interval: Option<String>,
pub last_error: Option<String>, pub last_error: Option<String>,
pub last_update: Option<String>, #[serde(with = "time::serde::rfc3339::option")]
pub last_update: Option<time::OffsetDateTime>,
pub remote_address: Option<String>, pub remote_address: Option<String>,
pub remote_name: Option<String>, pub remote_name: Option<String>,
pub repo_name: Option<String>, pub repo_name: Option<String>,
@ -2120,6 +2151,12 @@ pub struct RenameUserOption {
pub new_username: String, 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<Vec<String>>,
}
/// RepoCollaboratorPermission to get repository permission for a collaborator /// RepoCollaboratorPermission to get repository permission for a collaborator
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct RepoCollaboratorPermission { pub struct RepoCollaboratorPermission {
@ -2157,6 +2194,7 @@ pub struct RepoTransfer {
/// Repository represents a repository /// Repository represents a repository
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Repository { pub struct Repository {
pub allow_fast_forward_only_merge: Option<bool>,
pub allow_merge_commits: Option<bool>, pub allow_merge_commits: Option<bool>,
pub allow_rebase: Option<bool>, pub allow_rebase: Option<bool>,
pub allow_rebase_explicit: Option<bool>, pub allow_rebase_explicit: Option<bool>,
@ -2224,6 +2262,7 @@ pub struct Repository {
pub url: Option<url::Url>, pub url: Option<url::Url>,
pub watchers_count: Option<u64>, pub watchers_count: Option<u64>,
pub website: Option<String>, pub website: Option<String>,
pub wiki_branch: Option<String>,
} }
/// RepositoryMeta basic repository information /// RepositoryMeta basic repository information
@ -2485,6 +2524,8 @@ pub struct User {
pub login_name: Option<String>, pub login_name: Option<String>,
/// Is user login prohibited /// Is user login prohibited
pub prohibit_login: Option<bool>, pub prohibit_login: Option<bool>,
/// the user's pronouns
pub pronouns: Option<String>,
/// Is user restricted /// Is user restricted
pub restricted: Option<bool>, pub restricted: Option<bool>,
pub starred_repos_count: Option<u64>, pub starred_repos_count: Option<u64>,
@ -2506,12 +2547,14 @@ pub struct UserHeatmapData {
pub struct UserSettings { pub struct UserSettings {
pub description: Option<String>, pub description: Option<String>,
pub diff_view_style: Option<String>, pub diff_view_style: Option<String>,
pub enable_repo_unit_hints: Option<bool>,
pub full_name: Option<String>, pub full_name: Option<String>,
pub hide_activity: Option<bool>, pub hide_activity: Option<bool>,
/// Privacy /// Privacy
pub hide_email: Option<bool>, pub hide_email: Option<bool>,
pub language: Option<String>, pub language: Option<String>,
pub location: Option<String>, pub location: Option<String>,
pub pronouns: Option<String>,
pub theme: Option<String>, pub theme: Option<String>,
pub website: Option<String>, pub website: Option<String>,
} }
@ -2521,12 +2564,14 @@ pub struct UserSettings {
pub struct UserSettingsOptions { pub struct UserSettingsOptions {
pub description: Option<String>, pub description: Option<String>,
pub diff_view_style: Option<String>, pub diff_view_style: Option<String>,
pub enable_repo_unit_hints: Option<bool>,
pub full_name: Option<String>, pub full_name: Option<String>,
pub hide_activity: Option<bool>, pub hide_activity: Option<bool>,
/// Privacy /// Privacy
pub hide_email: Option<bool>, pub hide_email: Option<bool>,
pub language: Option<String>, pub language: Option<String>,
pub location: Option<String>, pub location: Option<String>,
pub pronouns: Option<String>,
pub theme: Option<String>, pub theme: Option<String>,
pub website: Option<String>, pub website: Option<String>,
} }
@ -2593,7 +2638,7 @@ pub struct ChangedFileListHeaders {
pub x_page: Option<u64>, pub x_page: Option<u64>,
pub x_page_count: Option<u64>, pub x_page_count: Option<u64>,
pub x_per_page: Option<u64>, pub x_per_page: Option<u64>,
pub x_total: Option<u64>, pub x_total_count: Option<u64>,
} }
impl TryFrom<&reqwest::header::HeaderMap> for ChangedFileListHeaders { impl TryFrom<&reqwest::header::HeaderMap> for ChangedFileListHeaders {
@ -2632,8 +2677,8 @@ impl TryFrom<&reqwest::header::HeaderMap> for ChangedFileListHeaders {
.map_err(|_| StructureError::HeaderParseFailed) .map_err(|_| StructureError::HeaderParseFailed)
}) })
.transpose()?; .transpose()?;
let x_total = map let x_total_count = map
.get("X-Total") .get("X-Total-Count")
.map(|s| -> Result<_, _> { .map(|s| -> Result<_, _> {
let s = s.to_str().map_err(|_| StructureError::HeaderNotAscii)?; let s = s.to_str().map_err(|_| StructureError::HeaderNotAscii)?;
s.parse::<u64>() s.parse::<u64>()
@ -2645,7 +2690,7 @@ impl TryFrom<&reqwest::header::HeaderMap> for ChangedFileListHeaders {
x_page, x_page,
x_page_count, x_page_count,
x_per_page, x_per_page,
x_total, x_total_count,
}) })
} }
} }
@ -2712,6 +2757,25 @@ impl TryFrom<&reqwest::header::HeaderMap> for CommitListHeaders {
} }
} }
pub struct RegistrationTokenHeaders {
pub token: Option<String>,
}
impl TryFrom<&reqwest::header::HeaderMap> for RegistrationTokenHeaders {
type Error = StructureError;
fn try_from(map: &reqwest::header::HeaderMap) -> Result<Self, Self::Error> {
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 struct ErrorHeaders {
pub message: Option<String>, pub message: Option<String>,
pub url: Option<String>, pub url: Option<String>,
@ -2796,6 +2860,33 @@ impl TryFrom<&reqwest::header::HeaderMap> for InvalidTopicsErrorHeaders {
} }
} }
pub struct RepoArchivedErrorHeaders {
pub message: Option<String>,
pub url: Option<String>,
}
impl TryFrom<&reqwest::header::HeaderMap> for RepoArchivedErrorHeaders {
type Error = StructureError;
fn try_from(map: &reqwest::header::HeaderMap) -> Result<Self, Self::Error> {
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 struct ValidationErrorHeaders {
pub message: Option<String>, pub message: Option<String>,
pub url: Option<String>, pub url: Option<String>,
@ -4145,7 +4236,7 @@ pub struct IssueListIssuesQuery {
pub since: Option<time::OffsetDateTime>, pub since: Option<time::OffsetDateTime>,
/// Only show items updated before the given time. This is a timestamp in RFC 3339 format /// Only show items updated before the given time. This is a timestamp in RFC 3339 format
pub before: Option<time::OffsetDateTime>, pub before: Option<time::OffsetDateTime>,
/// 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<String>, pub created_by: Option<String>,
/// Only show items for which the given user is assigned /// Only show items for which the given user is assigned
pub assigned_by: Option<String>, pub assigned_by: Option<String>,
@ -5078,8 +5169,6 @@ pub struct RepoListReleasesQuery {
pub draft: Option<bool>, pub draft: Option<bool>,
/// filter (exclude / include) pre-releases /// filter (exclude / include) pre-releases
pub pre_release: Option<bool>, pub pre_release: Option<bool>,
/// page size of results, deprecated - use limit
pub per_page: Option<u32>,
/// page number of results to return (1-based) /// page number of results to return (1-based)
pub page: Option<u32>, pub page: Option<u32>,
/// page size of results /// page size of results
@ -5094,9 +5183,6 @@ impl std::fmt::Display for RepoListReleasesQuery {
if let Some(pre_release) = &self.pre_release { if let Some(pre_release) = &self.pre_release {
write!(f, "pre-release={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 { if let Some(page) = &self.page {
write!(f, "page={page}&")?; write!(f, "page={page}&")?;
} }

File diff suppressed because it is too large Load diff