// @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;

// `Pulls` resource client (generated, 32 operations).

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

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

    /// 检查用户是否可以被添加到合并请求的处理人中。 Checks if a user can be assigned to a pull request.
    ///
    /// `GET /{repo}/-/pulls/{number}/assignees/{assignee}`
    pub async fn can_user_be_assigned_to_pull(
        &self,
        repo: String,
        number: String,
        assignee: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/pulls/{}/assignees/{}", repo, number, assignee);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::GET, url)
            .await
    }

    /// 删除合并请求中的处理人 Removes one or more assignees from a pull request.
    ///
    /// `DELETE /{repo}/-/pulls/{number}/assignees`
    pub async fn delete_pull_assignees(
        &self,
        repo: String,
        number: String,
        body: &crate::models::DeletePullAssigneesForm,
    ) -> Result<crate::models::Pull> {
        let path = format!("/{}/-/pulls/{}/assignees", repo, number);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::Pull, _>(Method::DELETE, url, body)
            .await
    }

    /// 删除合并请求标签。Remove a label from a pull.
    ///
    /// `DELETE /{repo}/-/pulls/{number}/labels/{name}`
    pub async fn delete_pull_label(
        &self,
        repo: String,
        number: String,
        name: String,
    ) -> Result<crate::models::Label> {
        let path = format!("/{}/-/pulls/{}/labels/{}", repo, number, name);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::Label>(Method::DELETE, url)
            .await
    }

    /// 清空合并请求标签。Remove all labels from a pull.
    ///
    /// `DELETE /{repo}/-/pulls/{number}/labels`
    pub async fn delete_pull_labels(
        &self,
        repo: String,
        number: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/pulls/{}/labels", repo, number);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 删除 UploadFiles 上传的附件
    ///
    /// `DELETE /{repo}/-/files/{filePath}`
    pub async fn delete_repo_files(
        &self,
        repo: String,
        file_path: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/files/{}", repo, file_path);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 删除 UploadImgs 上传的图片
    ///
    /// `DELETE /{repo}/-/imgs/{imgPath}`
    pub async fn delete_repo_imgs(
        &self,
        repo: String,
        img_path: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/imgs/{}", repo, img_path);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 获取合并请求文件，返回文件二进制内容。Request to retrieve file of pull requests, returns binary content.
    ///
    /// `GET /{repo}/-/files/pulls/{file_path}`
    pub async fn get_pr_files(&self, repo: String, file_path: String) -> Result<serde_json::Value> {
        let path = format!("/{}/-/files/pulls/{}", repo, file_path);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::GET, url)
            .await
    }

    /// 获取合并请求图片，返回图片二进制内容。Request to retrieve image of pull requests, returns binary content.
    ///
    /// `GET /{repo}/-/imgs/pulls/{img_path}`
    pub async fn get_pr_imgs(&self, repo: String, img_path: String) -> Result<serde_json::Value> {
        let path = format!("/{}/-/imgs/pulls/{}", repo, img_path);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::GET, url)
            .await
    }

    /// 查询指定合并请求。Get a pull request.
    ///
    /// `GET /{repo}/-/pulls/{number}`
    pub async fn get_pull(&self, repo: String, number: String) -> Result<crate::models::Pull> {
        let path = format!("/{}/-/pulls/{}", repo, number);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::Pull>(Method::GET, url)
            .await
    }

    /// 获取一个合并请求评论。Get a pull comment.
    ///
    /// `GET /{repo}/-/pulls/{number}/comments/{comment_id}`
    pub async fn get_pull_comment(
        &self,
        repo: String,
        number: String,
        comment_id: i64,
    ) -> Result<crate::models::PullRequestComment> {
        let path = format!("/{}/-/pulls/{}/comments/{}", repo, number, comment_id);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::PullRequestComment>(Method::GET, url)
            .await
    }

    /// 查询指定合并请求的处理人。List repository pull request assignees.
    ///
    /// `GET /{repo}/-/pulls/{number}/assignees`
    pub async fn list_pull_assignees(
        &self,
        repo: String,
        number: String,
    ) -> Result<Vec<crate::models::UserInfo>> {
        let path = format!("/{}/-/pulls/{}/assignees", repo, number);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<Vec<crate::models::UserInfo>>(Method::GET, url)
            .await
    }

    /// 查询合并请求评论列表。List pull comments requests.
    ///
    /// `GET /{repo}/-/pulls/{number}/comments`
    pub async fn list_pull_comments(
        &self,
        repo: String,
        number: String,
        query: &ListPullCommentsQuery,
    ) -> Result<Vec<crate::models::PullRequestComment>> {
        let path = format!("/{}/-/pulls/{}/comments", repo, number);
        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::PullRequestComment>>(Method::GET, url)
            .await
    }

    /// 查询 Pull Request 的状态检查
    ///
    /// `GET /{repo}/-/pulls/{number}/commit-statuses`
    pub async fn list_pull_commit_statuses(
        &self,
        repo: String,
        number: i64,
    ) -> Result<crate::models::CommitStatuses> {
        let path = format!("/{}/-/pulls/{}/commit-statuses", repo, number);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::CommitStatuses>(Method::GET, url)
            .await
    }

    /// 查询指定合并请求的提交列表。Lists the commits in a specified pull request.
    ///
    /// `GET /{repo}/-/pulls/{number}/commits`
    pub async fn list_pull_commits(
        &self,
        repo: String,
        number: String,
        query: &ListPullCommitsQuery,
    ) -> Result<Vec<crate::models::Commit>> {
        let path = format!("/{}/-/pulls/{}/commits", repo, number);
        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::Commit>>(Method::GET, url)
            .await
    }

    /// 查询指定合并请求的文件列表。Lists the files in a specified pull request.
    ///
    /// `GET /{repo}/-/pulls/{number}/files`
    pub async fn list_pull_files(
        &self,
        repo: String,
        number: String,
    ) -> Result<Vec<crate::models::PullFile>> {
        let path = format!("/{}/-/pulls/{}/files", repo, number);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<Vec<crate::models::PullFile>>(Method::GET, url)
            .await
    }

    /// 查询指定合并请求的标签列表。List labels for a pull.
    ///
    /// `GET /{repo}/-/pulls/{number}/labels`
    pub async fn list_pull_labels(
        &self,
        repo: String,
        number: i64,
        query: &ListPullLabelsQuery,
    ) -> Result<Vec<crate::models::Label>> {
        let path = format!("/{}/-/pulls/{}/labels", repo, number);
        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::Label>>(Method::GET, url)
            .await
    }

    /// 查询指定合并请求评审评论列表。List pull review comments.
    ///
    /// `GET /{repo}/-/pulls/{number}/reviews/{review_id}/comments`
    pub async fn list_pull_review_comments(
        &self,
        repo: String,
        number: i64,
        review_id: i64,
        query: &ListPullReviewCommentsQuery,
    ) -> Result<Vec<crate::models::PullReviewComment>> {
        let path = format!(
            "/{}/-/pulls/{}/reviews/{}/comments",
            repo, number, review_id
        );
        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::PullReviewComment>>(Method::GET, url)
            .await
    }

    /// 查询特定合并请求的评审列表。List pull reviews.
    ///
    /// `GET /{repo}/-/pulls/{number}/reviews`
    pub async fn list_pull_reviews(
        &self,
        repo: String,
        number: String,
        query: &ListPullReviewsQuery,
    ) -> Result<Vec<crate::models::PullReview>> {
        let path = format!("/{}/-/pulls/{}/reviews", repo, number);
        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::PullReview>>(Method::GET, url)
            .await
    }

    /// 查询合并请求列表。List pull requests.
    ///
    /// `GET /{repo}/-/pulls`
    pub async fn list_pulls(
        &self,
        repo: String,
        query: &ListPullsQuery,
    ) -> Result<Vec<crate::models::PullRequest>> {
        let path = format!("/{}/-/pulls", 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());
            }
            if let Some(ref v) = query.state {
                pairs.append_pair("state", v);
            }
            if let Some(ref v) = query.authors {
                pairs.append_pair("authors", v);
            }
            if let Some(ref v) = query.reviewers {
                pairs.append_pair("reviewers", v);
            }
            if let Some(ref v) = query.reviewers_operator {
                pairs.append_pair("reviewers_operator", v);
            }
            if let Some(ref v) = query.assignees {
                pairs.append_pair("assignees", v);
            }
            if let Some(ref v) = query.assignees_operator {
                pairs.append_pair("assignees_operator", v);
            }
            if let Some(ref v) = query.labels {
                pairs.append_pair("labels", v);
            }
            if let Some(ref v) = query.labels_operator {
                pairs.append_pair("labels_operator", v);
            }
            if let Some(ref v) = query.base_ref {
                pairs.append_pair("base_ref", v);
            }
            if let Some(ref v) = query.updated_time_begin {
                pairs.append_pair("updated_time_begin", v);
            }
            if let Some(ref v) = query.updated_time_end {
                pairs.append_pair("updated_time_end", v);
            }
            if let Some(ref v) = query.order_by {
                pairs.append_pair("order_by", v);
            }
            drop(pairs);
        }
        self.inner
            .execute::<Vec<crate::models::PullRequest>>(Method::GET, url)
            .await
    }

    /// 根据 number 列表查询合并请求列表。List pull requests by numbers.
    ///
    /// `GET /{repo}/-/pull-in-batch`
    pub async fn list_pulls_by_numbers(
        &self,
        repo: String,
        query: &ListPullsByNumbersQuery,
    ) -> Result<Vec<crate::models::PullRequestInfo>> {
        let path = format!("/{}/-/pull-in-batch", repo);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(ref vs) = query.n {
                for v in vs {
                    pairs.append_pair("n", v);
                }
            }
            drop(pairs);
        }
        self.inner
            .execute::<Vec<crate::models::PullRequestInfo>>(Method::GET, url)
            .await
    }

    /// 合并一个合并请求。Merge a pull request.
    ///
    /// `PUT /{repo}/-/pulls/{number}/merge`
    pub async fn merge_pull(
        &self,
        repo: String,
        number: String,
        body: &crate::models::MergePullRequest,
    ) -> Result<crate::models::MergePullResponse> {
        let path = format!("/{}/-/pulls/{}/merge", repo, number);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::MergePullResponse, _>(Method::PUT, url, body)
            .await
    }

    /// 更新一个合并请求。Update a pull request.
    ///
    /// `PATCH /{repo}/-/pulls/{number}`
    pub async fn patch_pull(
        &self,
        repo: String,
        number: String,
        body: &crate::models::PatchPullRequest,
    ) -> Result<crate::models::Pull> {
        let path = format!("/{}/-/pulls/{}", repo, number);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::Pull, _>(Method::PATCH, url, body)
            .await
    }

    /// 更新一个合并请求评论。Update a pull comment.
    ///
    /// `PATCH /{repo}/-/pulls/{number}/comments/{comment_id}`
    pub async fn patch_pull_comment(
        &self,
        repo: String,
        number: String,
        comment_id: i64,
        body: &crate::models::PatchPullCommentForm,
    ) -> Result<crate::models::PullRequestComment> {
        let path = format!("/{}/-/pulls/{}/comments/{}", repo, number, comment_id);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::PullRequestComment, _>(Method::PATCH, url, body)
            .await
    }

    /// 新增一个合并请求。Create a pull request.
    ///
    /// `POST /{repo}/-/pulls`
    pub async fn post_pull(
        &self,
        repo: String,
        body: &crate::models::PullCreationForm,
    ) -> Result<crate::models::Pull> {
        let path = format!("/{}/-/pulls", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::Pull, _>(Method::POST, url, body)
            .await
    }

    /// 添加处理人到指定的合并请求。 Adds up to assignees to a pull request. Users already assigned to an issue are not replaced.
    ///
    /// `POST /{repo}/-/pulls/{number}/assignees`
    pub async fn post_pull_assignees(
        &self,
        repo: String,
        number: String,
        body: &crate::models::PostPullAssigneesForm,
    ) -> Result<crate::models::Pull> {
        let path = format!("/{}/-/pulls/{}/assignees", repo, number);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::Pull, _>(Method::POST, url, body)
            .await
    }

    /// 新增一个合并请求评论。Create a pull comment.
    ///
    /// `POST /{repo}/-/pulls/{number}/comments`
    pub async fn post_pull_comment(
        &self,
        repo: String,
        number: String,
        body: &crate::models::PullCommentCreationForm,
    ) -> Result<crate::models::PullRequestComment> {
        let path = format!("/{}/-/pulls/{}/comments", repo, number);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::PullRequestComment, _>(Method::POST, url, body)
            .await
    }

    /// 新增合并请求标签。Add labels to a pull.
    ///
    /// `POST /{repo}/-/pulls/{number}/labels`
    pub async fn post_pull_labels(
        &self,
        repo: String,
        number: String,
        body: &crate::models::PostPullLabelsForm,
    ) -> Result<crate::models::Label> {
        let path = format!("/{}/-/pulls/{}/labels", repo, number);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::Label, _>(Method::POST, url, body)
            .await
    }

    /// 回复一个 review 评审
    ///
    /// `POST /{repo}/-/pulls/{number}/reviews/{review_id}/replies`
    pub async fn post_pull_request_review_reply(
        &self,
        repo: String,
        number: i64,
        review_id: i64,
        body: &crate::models::PostPullRequestReviewReplyForm,
    ) -> Result<crate::models::PullReviewComment> {
        let path = format!("/{}/-/pulls/{}/reviews/{}/replies", repo, number, review_id);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::PullReviewComment, _>(Method::POST, url, body)
            .await
    }

    /// 新增一次合并请求评审。Create a pull review.
    ///
    /// `POST /{repo}/-/pulls/{number}/reviews`
    pub async fn post_pull_review(
        &self,
        repo: String,
        number: String,
        body: &crate::models::PullReviewCreationForm,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/pulls/{}/reviews", repo, number);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<serde_json::Value, _>(Method::POST, url, body)
            .await
    }

    /// 设置合并请求标签。Set the new labels for a pull.
    ///
    /// `PUT /{repo}/-/pulls/{number}/labels`
    pub async fn put_pull_labels(
        &self,
        repo: String,
        number: String,
        body: &crate::models::PutPullLabelsForm,
    ) -> Result<crate::models::Label> {
        let path = format!("/{}/-/pulls/{}/labels", repo, number);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::Label, _>(Method::PUT, url, body)
            .await
    }

    /// 发起一个上传 files 的请求，返回上传文件的url，请使用 put 发起流式上传。Initiate a request to upload files,returns upload URL.Use PUT to initiate a stream upload.
    ///
    /// `POST /{repo}/-/upload/files`
    pub async fn upload_files(
        &self,
        repo: String,
        body: &crate::models::UploadRequestParams,
    ) -> Result<crate::models::UploadAssetsResponse> {
        let path = format!("/{}/-/upload/files", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::UploadAssetsResponse, _>(Method::POST, url, body)
            .await
    }

    /// 发起一个上传 imgs 的请求，返回上传文件的url，请使用 put 发起流式上传。Initiate a request to upload images,returns upload URL.Use PUT to initiate a stream upload.
    ///
    /// `POST /{repo}/-/upload/imgs`
    pub async fn upload_imgs(
        &self,
        repo: String,
        body: &crate::models::UploadRequestParams,
    ) -> Result<crate::models::UploadAssetsResponse> {
        let path = format!("/{}/-/upload/imgs", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::UploadAssetsResponse, _>(Method::POST, url, body)
            .await
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListPullCommentsQuery {
    /// 分页页码。
    #[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 ListPullCommentsQuery {
    /// 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 ListPullCommitsQuery {
    /// 分页页码。
    #[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 ListPullCommitsQuery {
    /// 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 ListPullLabelsQuery {
    /// 分页页码。
    #[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 ListPullLabelsQuery {
    /// 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 ListPullReviewCommentsQuery {
    /// 分页页码。
    #[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 ListPullReviewCommentsQuery {
    /// 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 ListPullReviewsQuery {
    /// 分页页码。
    #[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 ListPullReviewsQuery {
    /// 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 ListPullsQuery {
    /// 分页页码。
    #[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>,
    /// 合并请求状态过滤。可选值：`open`,`closed`,`all`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub state: Option<String>,
    /// 作者名称过滤。示例值：`张三,李四`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub authors: Option<String>,
    /// 评审人名称过滤，-表示无评审人。示例值：`张三,李四`,`-`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub reviewers: Option<String>,
    /// 评审者操作符。示例值：`contains_any`,`contains_all`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub reviewers_operator: Option<String>,
    /// 处理人名称过滤，-表示无处理人。示例值：`张三,李四`,`-`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub assignees: Option<String>,
    /// 处理人操作符。示例值：`contains_any`,`contains_all`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub assignees_operator: Option<String>,
    /// 标签过滤。示例值：`git,bug,feature`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub labels: Option<String>,
    /// 标签操作符。示例值：`contains_any`,`contains_all`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub labels_operator: Option<String>,
    /// 目标分支引用。示例值：`master`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub base_ref: Option<String>,
    /// 合并请求更新时间范围开始。示例：`2022-01-31`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub updated_time_begin: Option<String>,
    /// 合并请求更新时间范围结束。示例：`2022-02-16`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub updated_time_end: Option<String>,
    /// 合并请求排序字段，-前缀表示倒序。可选值：`created_at`,`-created_at`,`-updated_at`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub order_by: Option<String>,
}

impl ListPullsQuery {
    /// 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
    }
    /// Set `state` query parameter.
    pub fn state(mut self, v: impl Into<String>) -> Self {
        self.state = Some(v.into());
        self
    }
    /// Set `authors` query parameter.
    pub fn authors(mut self, v: impl Into<String>) -> Self {
        self.authors = Some(v.into());
        self
    }
    /// Set `reviewers` query parameter.
    pub fn reviewers(mut self, v: impl Into<String>) -> Self {
        self.reviewers = Some(v.into());
        self
    }
    /// Set `reviewers_operator` query parameter.
    pub fn reviewers_operator(mut self, v: impl Into<String>) -> Self {
        self.reviewers_operator = Some(v.into());
        self
    }
    /// Set `assignees` query parameter.
    pub fn assignees(mut self, v: impl Into<String>) -> Self {
        self.assignees = Some(v.into());
        self
    }
    /// Set `assignees_operator` query parameter.
    pub fn assignees_operator(mut self, v: impl Into<String>) -> Self {
        self.assignees_operator = Some(v.into());
        self
    }
    /// Set `labels` query parameter.
    pub fn labels(mut self, v: impl Into<String>) -> Self {
        self.labels = Some(v.into());
        self
    }
    /// Set `labels_operator` query parameter.
    pub fn labels_operator(mut self, v: impl Into<String>) -> Self {
        self.labels_operator = Some(v.into());
        self
    }
    /// Set `base_ref` query parameter.
    pub fn base_ref(mut self, v: impl Into<String>) -> Self {
        self.base_ref = Some(v.into());
        self
    }
    /// Set `updated_time_begin` query parameter.
    pub fn updated_time_begin(mut self, v: impl Into<String>) -> Self {
        self.updated_time_begin = Some(v.into());
        self
    }
    /// Set `updated_time_end` query parameter.
    pub fn updated_time_end(mut self, v: impl Into<String>) -> Self {
        self.updated_time_end = Some(v.into());
        self
    }
    /// Set `order_by` query parameter.
    pub fn order_by(mut self, v: impl Into<String>) -> Self {
        self.order_by = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListPullsByNumbersQuery {
    /// Pull唯一标识编号
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub n: Option<Vec<String>>,
}

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