// @generated DO NOT EDIT.
//
// Generated from the CNB OpenAPI specification by `cnb-codegen`.
// Run `cargo run -p cnb-codegen --manifest-path codegen/Cargo.toml \
//      -- --spec codegen/spec/swagger.json --out src` to refresh.

#![allow(clippy::all)]
#![allow(missing_docs)]
#![allow(unused_imports)]
#![allow(unused_mut)]

use reqwest::Method;
use serde::Serialize;

use crate::error::{ApiError, Result};
use crate::http::HttpInner;
use crate::models;

// `Git` resource client (generated, 35 operations).

/// Resource client.
#[derive(Debug, Clone)]
pub struct GitClient {
    inner: HttpInner,
}

impl GitClient {
    /// Construct a new resource client. Normally obtained
    /// via [`crate::ApiClient`] rather than directly.
    pub fn new(inner: HttpInner) -> Self {
        Self { inner }
    }

    /// 创建一个 blob。Create a blob.
    ///
    /// `POST /{repo}/-/git/blobs`
    pub async fn create_blob(
        &self,
        repo: String,
        body: &crate::models::PostBlobForm,
    ) -> Result<crate::models::Blob> {
        let path = format!("/{}/-/git/blobs", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::Blob, _>(Method::POST, url, body)
            .await
    }

    /// 创建新分支。Create a new branch based on a start point.
    ///
    /// `POST /{repo}/-/git/branches`
    pub async fn create_branch(
        &self,
        repo: String,
        body: &crate::models::CreateBranchForm,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/branches", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<serde_json::Value, _>(Method::POST, url, body)
            .await
    }

    /// 锁定分支
    ///
    /// `POST /{repo}/-/git/branch-locks/{branch}`
    pub async fn create_branch_lock(
        &self,
        repo: String,
        branch: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/branch-locks/{}", repo, branch);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::POST, url)
            .await
    }

    /// 创建一个 tag。Create a tag.
    ///
    /// `POST /{repo}/-/git/tags`
    pub async fn create_tag(
        &self,
        repo: String,
        body: &crate::models::PostTagFrom,
    ) -> Result<crate::models::Tag> {
        let path = format!("/{}/-/git/tags", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::Tag, _>(Method::POST, url, body)
            .await
    }

    /// 删除指定分支。Delete the specified branch.
    ///
    /// `DELETE /{repo}/-/git/branches/{branch}`
    pub async fn delete_branch(&self, repo: String, branch: String) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/branches/{}", repo, branch);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 解除锁定分支
    ///
    /// `DELETE /{repo}/-/git/branch-locks/{branch}`
    pub async fn delete_branch_lock(
        &self,
        repo: String,
        branch: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/branch-locks/{}", repo, branch);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 删除指定 commit 的元数据。Delete commit annotation.
    ///
    /// `DELETE /{repo}/-/git/commit-annotations/{sha}/{key}`
    pub async fn delete_commit_annotation(
        &self,
        repo: String,
        sha: String,
        key: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/commit-annotations/{}/{}", repo, sha, key);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 删除指定 commit 的附件。Delete commit asset.
    ///
    /// `DELETE /{repo}/-/git/commit-assets/{sha1}/{asset_id}`
    pub async fn delete_commit_asset(
        &self,
        repo: String,
        sha1: String,
        asset_id: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/commit-assets/{}/{}", repo, sha1, asset_id);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 删除指定 tag。Delete the specified tag.
    ///
    /// `DELETE /{repo}/-/git/tags/{tag}`
    pub async fn delete_tag(&self, repo: String, tag: String) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/tags/{}", repo, tag);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 删除指定 tag 的元数据。Delete the metadata of the specified tag.
    ///
    /// `DELETE /{repo}/-/git/tag-annotations/{tag_with_key}`
    pub async fn delete_tag_annotation(
        &self,
        repo: String,
        tag_with_key: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/tag-annotations/{}", repo, tag_with_key);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 下载仓库内容
    ///
    /// `GET /{repo}/-/git/archive/{ref_with_path}`
    pub async fn get_archive(
        &self,
        repo: String,
        ref_with_path: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/archive/{}", repo, ref_with_path);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::GET, url)
            .await
    }

    /// 打包下载 commit 变更文件。Download archive of changed files for a commit.
    ///
    /// `GET /{repo}/-/git/archive-commit-changed-files/{sha1}`
    pub async fn get_archive_commit_changed_files(
        &self,
        repo: String,
        sha1: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/archive-commit-changed-files/{}", repo, sha1);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::GET, url)
            .await
    }

    /// 打包下载两次 ref 之间的变更文件。Download archive of changed files for a compare.
    ///
    /// `GET /{repo}/-/git/archive-compare-changed-files/{base_head}`
    pub async fn get_archive_compare_changed_files(
        &self,
        repo: String,
        base_head: String,
    ) -> Result<serde_json::Value> {
        let path = format!(
            "/{}/-/git/archive-compare-changed-files/{}",
            repo, base_head
        );
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::GET, url)
            .await
    }

    /// 查询指定分支。Get a branch.
    ///
    /// `GET /{repo}/-/git/branches/{branch}`
    pub async fn get_branch(
        &self,
        repo: String,
        branch: String,
    ) -> Result<crate::models::BranchDetail> {
        let path = format!("/{}/-/git/branches/{}", repo, branch);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::BranchDetail>(Method::GET, url)
            .await
    }

    /// 查询指定 commit。Get a commit.
    ///
    /// `GET /{repo}/-/git/commits/{ref}`
    pub async fn get_commit(&self, repo: String, ref_: String) -> Result<crate::models::Commit> {
        let path = format!("/{}/-/git/commits/{}", repo, ref_);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::Commit>(Method::GET, url)
            .await
    }

    /// 查询指定 commit 的元数据。Get commit annotations.
    ///
    /// `GET /{repo}/-/git/commit-annotations/{sha}`
    pub async fn get_commit_annotations(
        &self,
        repo: String,
        sha: String,
    ) -> Result<Vec<crate::models::CommitAnnotation>> {
        let path = format!("/{}/-/git/commit-annotations/{}", repo, sha);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<Vec<crate::models::CommitAnnotation>>(Method::GET, url)
            .await
    }

    /// 查询指定 commit 的元数据。Get commit annotations in batch.
    ///
    /// `POST /{repo}/-/git/commit-annotations-in-batch`
    pub async fn get_commit_annotations_in_batch(
        &self,
        repo: String,
        body: &crate::models::GetCommitAnnotationsInBatchForm,
    ) -> Result<Vec<crate::models::CommitAnnotationInBatch>> {
        let path = format!("/{}/-/git/commit-annotations-in-batch", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<Vec<crate::models::CommitAnnotationInBatch>, _>(
                Method::POST,
                url,
                body,
            )
            .await
    }

    /// 发起一个获取 commits 附件的请求， 302到有一定效期的下载地址。Get a request to fetch a commit assets and returns 302 redirect to the assets URL with specific valid time.
    ///
    /// `GET /{repo}/-/commit-assets/download/{commit_id}/{filename}`
    pub async fn get_commit_assets(
        &self,
        repo: String,
        commit_id: String,
        filename: String,
        query: &GetCommitAssetsQuery,
    ) -> Result<serde_json::Value> {
        let path = format!(
            "/{}/-/commit-assets/download/{}/{}",
            repo, commit_id, filename
        );
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(v) = query.share {
                pairs.append_pair("share", &v.to_string());
            }
            drop(pairs);
        }
        self.inner
            .execute::<serde_json::Value>(Method::GET, url)
            .await
    }

    /// 查询指定 commit 的附件。List commit assets.
    ///
    /// `GET /{repo}/-/git/commit-assets/{sha1}`
    pub async fn get_commit_assets_by_sha(
        &self,
        repo: String,
        sha1: String,
    ) -> Result<Vec<crate::models::CommitAsset>> {
        let path = format!("/{}/-/git/commit-assets/{}", repo, sha1);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<Vec<crate::models::CommitAsset>>(Method::GET, url)
            .await
    }

    /// 查询指定 commit 的提交状态。List commit check statuses.
    ///
    /// `GET /{repo}/-/git/commit-statuses/{commitish}`
    pub async fn get_commit_statuses(
        &self,
        repo: String,
        commitish: String,
    ) -> Result<Vec<crate::models::CommitStatus>> {
        let path = format!("/{}/-/git/commit-statuses/{}", repo, commitish);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<Vec<crate::models::CommitStatus>>(Method::GET, url)
            .await
    }

    /// 比较两个提交、分支或标签之间差异的接口。Compare two commits, branches, or tags.
    ///
    /// `GET /{repo}/-/git/compare/{base_head}`
    pub async fn get_compare_commits(
        &self,
        repo: String,
        base_head: String,
    ) -> Result<crate::models::CompareResponse> {
        let path = format!("/{}/-/git/compare/{}", repo, base_head);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::CompareResponse>(Method::GET, url)
            .await
    }

    /// 查询仓库文件列表或文件。List repository files or file.
    ///
    /// `GET /{repo}/-/git/contents/{file_path}`
    pub async fn get_content(
        &self,
        repo: String,
        file_path: String,
        query: &GetContentQuery,
    ) -> Result<crate::models::Content> {
        let path = format!("/{}/-/git/contents/{}", repo, file_path);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(ref v) = query.ref_ {
                pairs.append_pair("ref", v);
            }
            drop(pairs);
        }
        self.inner
            .execute::<crate::models::Content>(Method::GET, url)
            .await
    }

    /// 查询仓库文件和目录内容。List repository files and directories.
    ///
    /// `GET /{repo}/-/git/contents`
    pub async fn get_content_without_path(
        &self,
        repo: String,
        query: &GetContentWithoutPathQuery,
    ) -> Result<crate::models::Content> {
        let path = format!("/{}/-/git/contents", repo);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(ref v) = query.ref_ {
                pairs.append_pair("ref", v);
            }
            drop(pairs);
        }
        self.inner
            .execute::<crate::models::Content>(Method::GET, url)
            .await
    }

    /// 获取仓库默认分支。Get the default branch of the repository.
    ///
    /// `GET /{repo}/-/git/head`
    pub async fn get_head(&self, repo: String) -> Result<crate::models::HeadRef> {
        let path = format!("/{}/-/git/head", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::HeadRef>(Method::GET, url)
            .await
    }

    /// 获取 git lfs 文件下载链接
    ///
    /// `GET /{slug}/-/lfs/{oid}`
    pub async fn get_presigned_lfs_download_link(
        &self,
        slug: String,
        oid: String,
        query: &GetPresignedLFSDownloadLinkQuery,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/lfs/{}", slug, oid);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(ref v) = query.name {
                pairs.append_pair("name", v);
            }
            drop(pairs);
        }
        self.inner
            .execute::<serde_json::Value>(Method::GET, url)
            .await
    }

    /// 获得仓库指定文件内容
    ///
    /// `GET /{repo}/-/git/raw/{ref_with_path}`
    pub async fn get_raw(
        &self,
        repo: String,
        ref_with_path: String,
        query: &GetRawQuery,
    ) -> Result<String> {
        let path = format!("/{}/-/git/raw/{}", repo, ref_with_path);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(v) = query.max_in_byte {
                pairs.append_pair("max_in_byte", &v.to_string());
            }
            drop(pairs);
        }
        self.inner.execute::<String>(Method::GET, url).await
    }

    /// 查询指定 tag。Get a tag.
    ///
    /// `GET /{repo}/-/git/tags/{tag}`
    pub async fn get_tag(&self, repo: String, tag: String) -> Result<crate::models::Tag> {
        let path = format!("/{}/-/git/tags/{}", repo, tag);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::Tag>(Method::GET, url)
            .await
    }

    /// 查询指定 tag 的元数据。Query the metadata of the specified tag.
    ///
    /// `GET /{repo}/-/git/tag-annotations/{tag}`
    pub async fn get_tag_annotations(
        &self,
        repo: String,
        tag: String,
    ) -> Result<Vec<crate::models::TagAnnotation>> {
        let path = format!("/{}/-/git/tag-annotations/{}", repo, tag);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<Vec<crate::models::TagAnnotation>>(Method::GET, url)
            .await
    }

    /// 查询分支列表。List branches.
    ///
    /// `GET /{repo}/-/git/branches`
    pub async fn list_branches(
        &self,
        repo: String,
        query: &ListBranchesQuery,
    ) -> Result<Vec<crate::models::Branch>> {
        let path = format!("/{}/-/git/branches", repo);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(v) = query.page {
                pairs.append_pair("page", &v.to_string());
            }
            if let Some(v) = query.page_size {
                pairs.append_pair("page_size", &v.to_string());
            }
            drop(pairs);
        }
        self.inner
            .execute::<Vec<crate::models::Branch>>(Method::GET, url)
            .await
    }

    /// 查询 commit 列表。List commits.
    ///
    /// `GET /{repo}/-/git/commits`
    pub async fn list_commits(
        &self,
        repo: String,
        query: &ListCommitsQuery,
    ) -> Result<Vec<crate::models::Commit>> {
        let path = format!("/{}/-/git/commits", repo);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(ref v) = query.sha {
                pairs.append_pair("sha", v);
            }
            if let Some(ref v) = query.author {
                pairs.append_pair("author", v);
            }
            if let Some(ref v) = query.committer {
                pairs.append_pair("committer", v);
            }
            if let Some(ref v) = query.since {
                pairs.append_pair("since", v);
            }
            if let Some(ref v) = query.until {
                pairs.append_pair("until", v);
            }
            if let Some(v) = query.page {
                pairs.append_pair("page", &v.to_string());
            }
            if let Some(v) = query.page_size {
                pairs.append_pair("page_size", &v.to_string());
            }
            drop(pairs);
        }
        self.inner
            .execute::<Vec<crate::models::Commit>>(Method::GET, url)
            .await
    }

    /// 查询 tag 列表。List tags.
    ///
    /// `GET /{repo}/-/git/tags`
    pub async fn list_tags(
        &self,
        repo: String,
        query: &ListTagsQuery,
    ) -> Result<Vec<crate::models::Tag>> {
        let path = format!("/{}/-/git/tags", repo);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(v) = query.page {
                pairs.append_pair("page", &v.to_string());
            }
            if let Some(v) = query.page_size {
                pairs.append_pair("page_size", &v.to_string());
            }
            drop(pairs);
        }
        self.inner
            .execute::<Vec<crate::models::Tag>>(Method::GET, url)
            .await
    }

    /// 确认 commit 附件上传完成。Confirm commit asset upload.
    ///
    /// `POST /{repo}/-/git/commit-assets/{sha1}/asset-upload-confirmation/{upload_token}/{asset_path}`
    pub async fn post_commit_asset_upload_confirmation(
        &self,
        repo: String,
        sha1: String,
        upload_token: String,
        asset_path: String,
        query: &PostCommitAssetUploadConfirmationQuery,
    ) -> Result<serde_json::Value> {
        let path = format!(
            "/{}/-/git/commit-assets/{}/asset-upload-confirmation/{}/{}",
            repo, sha1, upload_token, asset_path
        );
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(v) = query.ttl {
                pairs.append_pair("ttl", &v.to_string());
            }
            drop(pairs);
        }
        self.inner
            .execute::<serde_json::Value>(Method::POST, url)
            .await
    }

    /// 新增一个 commit 附件。Create a commit asset.
    ///
    /// `POST /{repo}/-/git/commit-assets/{sha1}/asset-upload-url`
    pub async fn post_commit_asset_upload_url(
        &self,
        repo: String,
        sha1: String,
        body: &crate::models::PostCommitAssetUploadUrlForm,
    ) -> Result<crate::models::CommitAssetUploadUrl> {
        let path = format!("/{}/-/git/commit-assets/{}/asset-upload-url", repo, sha1);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::CommitAssetUploadUrl, _>(Method::POST, url, body)
            .await
    }

    /// 设定指定 commit 的元数据。Put commit annotations.
    ///
    /// `PUT /{repo}/-/git/commit-annotations/{sha}`
    pub async fn put_commit_annotations(
        &self,
        repo: String,
        sha: String,
        body: &crate::models::PutCommitAnnotationsForm,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/commit-annotations/{}", repo, sha);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<serde_json::Value, _>(Method::PUT, url, body)
            .await
    }

    /// 设定指定 tag 的元数据。Set the metadata of the specified tag.
    ///
    /// `PUT /{repo}/-/git/tag-annotations/{tag}`
    pub async fn put_tag_annotations(
        &self,
        repo: String,
        tag: String,
        body: &crate::models::PutTagAnnotationsForm,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/tag-annotations/{}", repo, tag);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<serde_json::Value, _>(Method::PUT, url, body)
            .await
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetCommitAssetsQuery {
    /// 是否可以下载，true表示302的下载地址有效期12小时，最多下载10次。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub share: Option<bool>,
}

impl GetCommitAssetsQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `share` query parameter.
    pub fn share(mut self, v: impl Into<bool>) -> Self {
        self.share = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetContentQuery {
    /// 提交的哈希值或分支名称。
    #[serde(rename = "ref", default, skip_serializing_if = "Option::is_none")]
    pub ref_: Option<String>,
}

impl GetContentQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `ref` query parameter.
    pub fn ref_(mut self, v: impl Into<String>) -> Self {
        self.ref_ = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetContentWithoutPathQuery {
    /// 提交的哈希值或分支名称。
    #[serde(rename = "ref", default, skip_serializing_if = "Option::is_none")]
    pub ref_: Option<String>,
}

impl GetContentWithoutPathQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `ref` query parameter.
    pub fn ref_(mut self, v: impl Into<String>) -> Self {
        self.ref_ = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetPresignedLFSDownloadLinkQuery {
    /// LFS文件名称。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
}

impl GetPresignedLFSDownloadLinkQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `name` query parameter.
    pub fn name(mut self, v: impl Into<String>) -> Self {
        self.name = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetRawQuery {
    /// 获得文件内容大小限制（字节），0表示使用gitConfig.RawFileLimitInByte配置值。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub max_in_byte: Option<i64>,
}

impl GetRawQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `max_in_byte` query parameter.
    pub fn max_in_byte(mut self, v: impl Into<i64>) -> Self {
        self.max_in_byte = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListBranchesQuery {
    /// 分页页码。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
    /// 分页页大小。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page_size: Option<i64>,
}

impl ListBranchesQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `page` query parameter.
    pub fn page(mut self, v: impl Into<i64>) -> Self {
        self.page = Some(v.into());
        self
    }
    /// Set `page_size` query parameter.
    pub fn page_size(mut self, v: impl Into<i64>) -> Self {
        self.page_size = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListCommitsQuery {
    /// 提交标识符。格式：`分支名称`,`提交哈希值`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sha: Option<String>,
    /// 作者匹配模式，支持Git原生正则表达式匹配作者信息。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub author: Option<String>,
    /// 提交者匹配模式，支持Git原生正则表达式匹配提交者信息。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub committer: Option<String>,
    /// 提交时间起始范围。示例：`2025-01-01T00:00:00Z`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub since: Option<String>,
    /// 提交时间结束范围。示例：`2025-12-31T23:59:59Z`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub until: Option<String>,
    /// 分页页码。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
    /// 分页页大小。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page_size: Option<i64>,
}

impl ListCommitsQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `sha` query parameter.
    pub fn sha(mut self, v: impl Into<String>) -> Self {
        self.sha = Some(v.into());
        self
    }
    /// Set `author` query parameter.
    pub fn author(mut self, v: impl Into<String>) -> Self {
        self.author = Some(v.into());
        self
    }
    /// Set `committer` query parameter.
    pub fn committer(mut self, v: impl Into<String>) -> Self {
        self.committer = Some(v.into());
        self
    }
    /// Set `since` query parameter.
    pub fn since(mut self, v: impl Into<String>) -> Self {
        self.since = Some(v.into());
        self
    }
    /// Set `until` query parameter.
    pub fn until(mut self, v: impl Into<String>) -> Self {
        self.until = Some(v.into());
        self
    }
    /// Set `page` query parameter.
    pub fn page(mut self, v: impl Into<i64>) -> Self {
        self.page = Some(v.into());
        self
    }
    /// Set `page_size` query parameter.
    pub fn page_size(mut self, v: impl Into<i64>) -> Self {
        self.page_size = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListTagsQuery {
    /// 分页页码。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
    /// 分页页大小。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page_size: Option<i64>,
}

impl ListTagsQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `page` query parameter.
    pub fn page(mut self, v: impl Into<i64>) -> Self {
        self.page = Some(v.into());
        self
    }
    /// Set `page_size` query parameter.
    pub fn page_size(mut self, v: impl Into<i64>) -> Self {
        self.page_size = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
pub struct PostCommitAssetUploadConfirmationQuery {
    /// 附件保持的天数。0 表示永久，最大不能超过 180 天
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ttl: Option<i64>,
}

impl PostCommitAssetUploadConfirmationQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `ttl` query parameter.
    pub fn ttl(mut self, v: impl Into<i64>) -> Self {
        self.ttl = Some(v.into());
        self
    }
}
