Skip to content
代码片段 群组 项目
未验证 提交 a2929c51 编辑于 作者: Vasilii Iakliushin's avatar Vasilii Iakliushin 提交者: GitLab
浏览文件

Pull mirror API: extend response with mirror related fields

Contributes to https://gitlab.com/gitlab-org/gitlab/-/issues/494294

**Problem**

Existing endpoint does not return information about mirror configuration
state. It's not possible to see mirror settings using Pull mirror API.

**Solution*

Expose missing settings.

Changelog: added
上级 bd451a65
No related branches found
No related tags found
无相关合并请求
---
stage: Data Stores
group: Tenant Scale
stage: Create
group: Source Code
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments
---
......@@ -15,6 +15,7 @@ You can manage project [pull mirroring](../user/project/repository/mirror/pull.m
## Get a project's pull mirror details
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/354506) in GitLab 15.6.
> - [Extended response](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/168377) to include mirror configuration information in GitLab 17.5. The following configuration settings are included: `enabled`, `mirror_trigger_builds`, `only_mirror_protected_branches`, `mirror_overwrites_diverged_branches`, and `mirror_branch_regex`.
Return the details of a project's [pull mirror](../user/project/repository/mirror/index.md).
......@@ -34,6 +35,24 @@ Example request:
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/:id/mirror/pull"
```
If successful, returns [`200 OK`](rest/troubleshooting.md#status-codes) and the
following response attributes:
| Attribute | Type | Description |
|---------------------------------------|-----------------|-----------------------------------------------------------------------------|
| `id` | integer | The unique identifier of the mirror configuration. |
| `last_error` | string or null | The most recent error message, if any. `null` if no errors occurred. |
| `last_successful_update_at` | string | Timestamp of the last successful mirror update. |
| `last_update_at` | string | Timestamp of the most recent mirror update attempt. |
| `last_update_started_at` | string | Timestamp when the last mirror update process started. |
| `update_status` | string | The status of the mirror update process. |
| `url` | string | URL of the mirrored repository. |
| `enabled` | boolean | Indicates whether the mirror is active or inactive. |
| `mirror_trigger_builds` | boolean | Determines if builds should be triggered for mirror updates. |
| `only_mirror_protected_branches` | boolean or null | Specifies if only protected branches should be mirrored. `null` if not set. |
| `mirror_overwrites_diverged_branches` | boolean | Indicates if diverged branches should be overwritten during mirroring. |
| `mirror_branch_regex` | string or null | Regex pattern for filtering which branches to mirror. `null` if not set. |
Example response:
```json
......@@ -44,7 +63,12 @@ Example response:
"last_update_at": "2020-01-06T17:32:02.823Z",
"last_update_started_at": "2020-01-06T17:31:55.864Z",
"update_status": "finished",
"url": "https://*****:*****@gitlab.com/gitlab-org/security/gitlab.git"
"url": "https://*****:*****@gitlab.com/gitlab-org/security/gitlab.git",
"enabled": true,
"mirror_trigger_builds": true,
"only_mirror_protected_branches": null,
"mirror_overwrites_diverged_branches": false,
"mirror_branch_regex": null
}
```
......
......@@ -14,6 +14,19 @@ class PullMirror < Grape::Entity
expose :last_update_at, documentation: { type: 'dateTime', example: '2020-01-06T17:32:02.823Z' }
expose :last_update_started_at, documentation: { type: 'dateTime', example: '2020-01-06T17:32:02.823Z' }
expose :last_successful_update_at, documentation: { type: 'dateTime', example: '2020-01-06T17:32:02.823Z' }
expose :enabled, documentation: { type: 'boolean', example: false }
expose :mirror_trigger_builds, documentation: { type: 'boolean', example: false }
expose :only_mirror_protected_branches, documentation: { type: 'boolean', example: false }
expose :mirror_overwrites_diverged_branches, documentation: { type: 'boolean', example: false }
expose :mirror_branch_regex, documentation: { type: 'string', example: 'branch_name' }
delegate :project, to: :object
delegate :mirror_trigger_builds, :only_mirror_protected_branches, :mirror_overwrites_diverged_branches,
:mirror_branch_regex, to: :project
def enabled
object.project.mirror
end
end
end
end
......@@ -7,7 +7,12 @@
"last_update_at",
"last_update_started_at",
"last_successful_update_at",
"last_error"
"last_error",
"enabled",
"mirror_trigger_builds",
"only_mirror_protected_branches",
"mirror_overwrites_diverged_branches",
"mirror_branch_regex"
],
"properties": {
"id": {
......@@ -42,7 +47,31 @@
"string",
"null"
]
},
"enabled": {
"type": "boolean"
},
"mirror_trigger_builds": {
"type": "boolean"
},
"only_mirror_protected_branches": {
"type": [
"boolean",
"null"
]
},
"mirror_overwrites_diverged_branches": {
"type": [
"boolean",
"null"
]
},
"mirror_branch_regex": {
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
}
\ No newline at end of file
}
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册