
# 获取个人首页mr列表 - ListPersonalMergeRequests
#### 功能介绍
获取个人首页mr列表
#### 调试
您可以在[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/CodeArtsRepo/doc?api=ListPersonalMergeRequests&version=v4)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### 授权信息
账号根用户具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备如下身份策略权限，更多的权限说明请参见[权限和授权项](https://support.huaweicloud.com/api-codeartsrepo/codeartsrepo_05_0036.html)。
| 授权项                                     | 访问级别 | 资源类型（\*为必须） | 条件键 | 别名 | 依赖的授权项 |
|:---|:---|:---|:---|:---|:---|
| codeartsrepo:repository:getMergeRequest | Read | -           | -   | -  | -      |
   
#### URI
GET /v4/merge-requests
表1Query参数 
| 参数             | 是否必选 | 参数类型    | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|:---|:---|:---|:---|
| state          | 否    | String  | **参数解释：** 合并请求状态 **约束限制：** - all，返回所有状态的合并请求。   - opened，返回开启中的合并请求。   - closed，返回关闭的合并请求。   - locked，返回锁定的合并请求。   - merged，返回已合并的合并请求。    **默认取值：** all |
| order_by       | 否    | String  | **参数解释：** 排序方式 **约束限制：** - created_at，根据创建时间排序。   - updated_at，根据更新时间排序。   - merged_at，根据合并时间排序。    **默认取值：** created_at                                                                                                                                                                                                                                                                                                                                                   |
| sort           | 否    | String  | **参数解释：** 排序顺序 **约束限制：** - asc，正序排序。   - desc，倒序排序。    **默认取值：** desc                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| labels         | 否    | String  | **参数解释：** 合并请求关联标签                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| created_before | 否    | String  | **参数解释：** 指定时间前创建                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| created_after  | 否    | String  | **参数解释：** 指定时间后创建                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| updated_after  | 否    | String  | **参数解释：** 指定时间后更新                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| updated_before | 否    | String  | **参数解释：** 指定时间前更新                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| view           | 否    | String  | **参数解释：** 结果集属性，根据给定的参数返回不同的结果， simple，返回简单数据，basic返回基本数据。 **默认取值：** simple                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| author_id      | 否    | String  | **参数解释：** 合并请求创建人                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| scope          | 否    | String  | **参数解释：** - created_by_me 我创建的合并请求   - assigned_to_me 待我合并的合并请求   - need_my_review 待我检视的合并请求   - need_my_approve 待我审核的合并请求   - all 所有有权限访问的合并请求    **默认取值：** created_by_me                                                                         |
| source_branch  | 否    | String  | **参数解释：** 合并请求原分支                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| target_branch  | 否    | String  | **参数解释：** 合并请求目标分支                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| search         | 否    | String  | **参数解释：** 根据合并请求标题、描述信息过滤关键字                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| wip            | 否    | String  | **参数解释：** 合并请求标题是否有WIP关键字                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| merged_by      | 否    | String  | **参数解释：** 合并请求合并人                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| merged_after   | 否    | String  | **参数解释：** 指定时间后合入                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| merged_before  | 否    | String  | **参数解释：** 指定时间前合入                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| offset         | 否    | Integer | **参数解释：** 分页参数偏移量                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| limit          | 否    | Integer | **参数解释：** 分页参数结果数量限制                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| only_count     | 否    | Boolean | **参数解释：** 是否只返回合并请求总数 **默认取值：** false                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | **参数解释：** 用户Token。 通过调用IAM服务[获取用户Token](https://support.huaweicloud.com/api-iam/iam_30_0001.html)接口获取（响应消息头中X-Subject-Token的值）。 **约束限制：** 不涉及。 **取值范围：** 字符串长度不少于1，不超过10万。 **默认取值：** 不涉及。 |
   
#### 响应参数
**状态码：200**
表3响应Header参数 
| 参数      | 参数类型   | 描述                                                                 |
|:---|:---|:---|
| X-Total | String | **参数解释：** 个人首页mr列表的总数 |
   
表4响应Body参数 
| 参数       | 参数类型                                                                                                       | 描述       |
|:---|:---|:---|
| \[数组元素\] | Array of [MergeRequestListBasicDto] objects | 合并请求基本信息 |
   
 表5MergeRequestListBasicDto 
| 参数                                | 参数类型                                                                             | 描述                                                                   |
|:---|:---|:---|
| id                                | Integer                                                                          | **参数解释：** 合并请求ID。       |
| iid                               | Integer                                                                          | **参数解释：** 合并请求位于当前仓库序号。 |
| title                             | String                                                                           | **参数解释：** 合并请求标题。       |
| source_branch                     | String                                                                           | **参数解释：** 合并请求源分支。      |
| target_branch                     | String                                                                           | **参数解释：** 合并请求目标分支。     |
| state                             | String                                                                           | **参数解释：** 合并请求状态。       |
| created_at                        | String                                                                           | **参数解释：** 合并请求创建时间。     |
| updated_at                        | String                                                                           | **参数解释：** 合并请求更新时间。     |
| source_repository_id              | Integer                                                                          | **参数解释：** 合并请求源仓库ID。    |
| review_mode                       | String                                                                           | **参数解释：** 合并请求检视模式。     |
| author                            | [UserBasicDto] object         | **参数解释：** 合并请求作者。       |
| closed_at                         | String                                                                           | **参数解释：** 合并请求关闭时间。     |
| closed_by                         | [UserBasicDto] object         | **参数解释：** 合并请求关闭人。      |
| merged_at                         | String                                                                           | **参数解释：** 合并请求合并时间。     |
| merged_by                         | [UserBasicDto] object         | **参数解释：** 合并请求合并人。      |
| pipeline_status                   | String                                                                           | **参数解释：** 合并请求流水线状态。    |
| codequality_status                | String                                                                           | **参数解释：** 合并请求代码质量状态。   |
| pipeline_status_with_code_quality | String                                                                           | **参数解释：** 合并请求流水线状态。    |
| notes                             | Integer                                                                          | **参数解释：** 合并请求检视意见。     |
| source_repository                 | [ProjectSimpleDto] object | **参数解释：** 合并请求源仓库信息。    |
| target_repository                 | [ProjectSimpleDto] object | **参数解释：** 合并请求目标仓库信息。   |
| web_url                           | String                                                                           | **参数解释：** 合并请求URL地址。    |
| added_lines                       | Integer                                                                          | **参数解释：** 合并请求新增代码行数。   |
| removed_lines                     | Integer                                                                          | **参数解释：** 合并请求删除代码行数。   |
| merge_request_type                | String                                                                           | **参数解释：** 合并请求检视模式。     |
| source_git_url                    | String                                                                           | **参数解释：** 合并请求git地址。    |
| labels                            | Array of Map\<String,Object\> objects                                            | **参数解释：** 合并请求标签。       |
| score                             | Integer                                                                          | **参数解释：** 合并请求分数。       |
| min_merged_score                  | Integer                                                                          | **参数解释：** 合并请求最小合入分数。   |
| source_product_id                 | String                                                                           | **参数解释：** 合并请求源项目ID。    |
| target_product_id                 | String                                                                           | **参数解释：** 合并请求目标项目ID。   |
| product_name                      | String                                                                           | **参数解释：** 合并请求项目名。      |
| notes_count                       | [NotesCountDto] object       | **参数解释：** 合并请求检视意见计数。   |
| moderation_result                 | Boolean                                                                          | **参数解释：** 合并请求审核结果。     |
| moderation_time                   | Long                                                                             | **参数解释：** 合并请求审核时间。     |
| moderation_status                 | Integer                                                                          | **参数解释：** 合并请求审核状态。     |
   
 表6UserBasicDto 
| 参数                     | 参数类型    | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|:---|:---|:---|
| id                     | Integer | **参数解释：** 用户id。 **取值范围：** 1\~2147483647                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| name                   | String  | **参数解释：** 用户名称。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| username               | String  | **参数解释：** 用户名。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| state                  | String  | **参数解释：** 用户状态。 **取值范围：** - active: 可用账户。   - blocked: 被锁定用户。   - error: 未查询到该用户。    |
| service_license_status | Integer | 服务级权限状态 0：停用 1：启用                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| avatar_url             | String  | 用户头像url                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| avatar_path            | String  | 用户头像路径                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| email                  | String  | 用户邮箱                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| name_cn                | String  | 用户中文名称                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| web_url                | String  | 用户个人首页                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| nick_name              | String  | 用户昵称                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| tenant_name            | String  | 租户名称                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| error_message          | String  | **参数解释：** 部分查询接口校验到传参里的用户权限不足或不存在时，返回该用户但该字段不为空用于提示。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
   
 表7ProjectSimpleDto 
| 参数                  | 参数类型    | 描述               |
|:---|:---|:---|
| id                  | Integer | 仓库id             |
| description         | String  | 仓库描述信息           |
| name                | String  | 仓库名称             |
| name_with_namespace | String  | 组织名/组织名.../仓库名   |
| path                | String  | 仓库路径             |
| path_with_namespace | String  | 仓库完整路径           |
| created_at          | String  | 创建时间             |
| updated_at          | String  | 更新时间             |
| archived            | Boolean | 是否归档             |
| is_kia              | Boolean | 是否机密             |
| ssh_url_to_repo     | String  | 仓库ssh地址          |
| http_url_to_repo    | String  | 仓库http地址         |
| web_url             | String  | 仓库页面链接           |
| readme_url          | String  | 仓库readme文件链接     |
| project_id          | String  | 项目id             |
| project_name        | String  | 项目名称             |
| develop_mode        | String  | 仓库开发模式：normal、CR |
| moderation_result   | Boolean | 审核状态             |
   
 表8NotesCountDto 
| 参数                     | 参数类型    | 描述          |
|:---|:---|:---|
| notes_count            | Integer | 检视意见总数      |
| unresolved_notes_count | Integer | 未解决的检视意见数量  |
| already_resolved_count | Integer | 已解决的检视意见数量  |
| need_resolved_count    | Integer | 需要解决的检视意见总数 |
   
**状态码：401**
表9响应Body参数 
| 参数         | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code | String | **参数解释：** 错误码。  |
| error_msg  | String | **参数解释：** 错误信息。 |
   
#### 请求示例
```
/v4/merge-requests
```
#### 响应示例
**状态码：200**
OK
```
{
  "id" : 72674,
  "iid" : 7,
  "title" : "新建文件",
  "source_branch" : "ddd1",
  "target_branch" : "master",
  "state" : "opened",
  "created_at" : "2025-05-21T12:03:32.000+08:00",
  "updated_at" : "2025-06-17T15:30:02.000+08:00",
  "source_repository_id" : 2111983939,
  "review_mode" : "approval",
  "author" : {
    "id" : 9124,
    "name" : "test",
    "username" : "c369c68f1ff84679b5a8ed904d8bff1c",
    "state" : "active",
    "service_license_status" : null,
    "name_cn" : "test",
    "nick_name" : "beta_dv",
    "tenant_name" : "example_name",
    "error_message" : null
  },
  "closed_at" : "2025-05-21T12:03:32.000+08:00",
  "closed_by" : null,
  "merged_at" : null,
  "merged_by" : null,
  "pipeline_status" : "",
  "codequality_status" : null,
  "pipeline_status_with_code_quality" : "",
  "notes" : 0,
  "web_url" : "https://example.com/********/2111983939/7/mergedetail?source=ddd1&target=master",
  "added_lines" : 0,
  "removed_lines" : 0,
  "merge_request_type" : "MergeRequest",
  "source_git_url" : "git@example.com:3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
  "labels" : [ {
    "color" : "#000",
    "name" : "Bug",
    "description" : "456",
    "id" : 8,
    "title" : "Bug",
    "type" : null,
    "textColor" : "#FFFFFF"
  }, {
    "color" : "#000",
    "name" : "bug",
    "description" : "456",
    "id" : 7,
    "title" : "bug",
    "type" : null,
    "textColor" : "#FFFFFF"
  } ],
  "score" : 0,
  "min_merged_score" : null,
  "source_project_id" : "3e1f6634946144c2b1ccb46fb8152b8f",
  "target_project_id" : null,
  "product_name" : null,
  "notes_count" : null,
  "moderation_result" : null,
  "moderation_time" : null,
  "moderation_status" : null,
  "source_repository" : {
    "id" : 2111983939,
    "description" : "ddd",
    "name" : "dddd",
    "name_with_namespace" : "3e1f6634946144c2b1ccb46fb8152b8f / dddd",
    "path" : "dddd",
    "path_with_namespace" : "3e1f6634946144c2b1ccb46fb8152b8f/dddd",
    "created_at" : "2024-11-30T17:46:46.000+08:00",
    "updated_at" : "2024-11-30T17:46:46.000+08:00",
    "archived" : false,
    "ssh_url_to_repo" : "git@example.com:3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
    "http_url_to_repo" : "https://example.com/3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
    "project_id" : null,
    "project_name" : null,
    "develop_mode" : null,
    "moderation_result" : null
  },
  "target_repository" : {
    "id" : 2111983939,
    "description" : "ddd",
    "name" : "dddd",
    "name_with_namespace" : "3e1f6634946144c2b1ccb46fb8152b8f / dddd",
    "path" : "dddd",
    "path_with_namespace" : "3e1f6634946144c2b1ccb46fb8152b8f/dddd",
    "created_at" : "2024-11-30T17:46:46.000+08:00",
    "updated_at" : "2024-11-30T17:46:46.000+08:00",
    "archived" : false,
    "ssh_url_to_repo" : "git@example.com:3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
    "http_url_to_repo" : "https://example.com/3e1f6634946144c2b1ccb46fb8152b8f/dddd.git",
    "project_id" : null,
    "project_name" : null,
    "develop_mode" : null,
    "moderation_result" : null
  }
}
```
**状态码：401**
Unauthorized
```
{
  "error_code" : "CH.00000002",
  "error_msg" : "认证信息无法识别"
}
```
#### SDK代码示例
SDK代码示例如下。
#### Java
```
package com.huaweicloud.sdk.test;
import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.codeartsrepo.v4.region.CodeArtsRepoRegion;
import com.huaweicloud.sdk.codeartsrepo.v4.*;
import com.huaweicloud.sdk.codeartsrepo.v4.model.*;
public class ListPersonalMergeRequestsSolution {
    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        ICredential auth = new BasicCredentials()
                .withAk(ak)
                .withSk(sk);
        CodeArtsRepoClient client = CodeArtsRepoClient.newBuilder()
                .withCredential(auth)
                .withRegion(CodeArtsRepoRegion.valueOf("<YOUR REGION>"))
                .build();
        ListPersonalMergeRequestsRequest request = new ListPersonalMergeRequestsRequest();
        try {
            ListPersonalMergeRequestsResponse response = client.listPersonalMergeRequests(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
```
#### Python
```
# coding: utf-8
import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcodeartsrepo.v4.region.codeartsrepo_region import CodeArtsRepoRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcodeartsrepo.v4 import *
if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    credentials = BasicCredentials(ak, sk)
    client = CodeArtsRepoClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CodeArtsRepoRegion.value_of("<YOUR REGION>")) \
        .build()
    try:
        request = ListPersonalMergeRequestsRequest()
        response = client.list_personal_merge_requests(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
```
#### Go
```
package main
import (
"fmt"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    codeartsrepo "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartsrepo/v4"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartsrepo/v4/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartsrepo/v4/region"
)
func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    auth, err := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        SafeBuild()
    if err != nil {
        fmt.Println(err)
        return
    }
    hcClient, err := codeartsrepo.CodeArtsRepoClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()
    if err != nil {
        fmt.Println(err)
        return
    }
    client := codeartsrepo.NewCodeArtsRepoClient(hcClient)
    request := &model.ListPersonalMergeRequestsRequest{}
response, err := client.ListPersonalMergeRequests(request)
if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}
```
#### 更多
更多编程语言的SDK代码示例，请参见[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/CodeArtsRepo/sdk?api=ListPersonalMergeRequests&version=v4)的代码示例页签，可生成自动对应的SDK代码示例。
#### 状态码
| 状态码 | 描述           |
|:---|:---|
| 200 | OK           |
| 401 | Unauthorized |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-codeartsrepo/ErrorCode.html)。
