Commit fe5a94c2 authored by Timo Furrer's avatar Timo Furrer

Implement API to get single Project Remote Mirror

This change implements the `GET` API to retrieve a single projects
remote mirror.

Changelog: added
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82770
parent 3480111a
...@@ -51,6 +51,43 @@ NOTE: ...@@ -51,6 +51,43 @@ NOTE:
For security reasons, the `url` attribute is always scrubbed of username For security reasons, the `url` attribute is always scrubbed of username
and password information. and password information.
## Get a single project's remote mirror
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82770) in GitLab 14.10.
Returns a remote mirror and its statuses:
```plaintext
GET /projects/:id/remote_mirrors/:mirror_id
```
Example request:
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/remote_mirrors/101486"
```
Example response:
```json
{
"enabled": true,
"id": 101486,
"last_error": null,
"last_successful_update_at": "2020-01-06T17:32:02.823Z",
"last_update_at": "2020-01-06T17:32:02.823Z",
"last_update_started_at": "2020-01-06T17:31:55.864Z",
"only_protected_branches": true,
"keep_divergent_refs": true,
"update_status": "finished",
"url": "https://*****:*****@gitlab.com/gitlab-org/security/gitlab.git"
}
```
NOTE:
For security reasons, the `url` attribute is always scrubbed of username
and password information.
## Create a pull mirror ## Create a pull mirror
Learn how to [configure a pull mirror](projects.md#configure-pull-mirroring-for-a-project) using the Projects API. Learn how to [configure a pull mirror](projects.md#configure-pull-mirroring-for-a-project) using the Projects API.
......
...@@ -25,6 +25,18 @@ module API ...@@ -25,6 +25,18 @@ module API
with: Entities::RemoteMirror with: Entities::RemoteMirror
end end
desc 'Get a single remote mirror' do
success Entities::RemoteMirror
end
params do
requires :mirror_id, type: String, desc: 'The ID of a remote mirror'
end
get ':id/remote_mirrors/:mirror_id' do
mirror = user_project.remote_mirrors.find(params[:mirror_id])
present mirror, with: Entities::RemoteMirror
end
desc 'Create remote mirror for a project' do desc 'Create remote mirror for a project' do
success Entities::RemoteMirror success Entities::RemoteMirror
end end
......
...@@ -26,6 +26,26 @@ RSpec.describe API::RemoteMirrors do ...@@ -26,6 +26,26 @@ RSpec.describe API::RemoteMirrors do
end end
end end
describe 'GET /projects/:id/remote_mirrors/:mirror_id' do
let(:route) { "/projects/#{project.id}/remote_mirrors/#{mirror.id}" }
let(:mirror) { project.remote_mirrors.first }
it 'requires `admin_remote_mirror` permission' do
get api(route, developer)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns at remote mirror' do
project.add_maintainer(user)
get api(route, user)
expect(response).to have_gitlab_http_status(:success)
expect(response).to match_response_schema('remote_mirror')
end
end
describe 'POST /projects/:id/remote_mirrors' do describe 'POST /projects/:id/remote_mirrors' do
let(:route) { "/projects/#{project.id}/remote_mirrors" } let(:route) { "/projects/#{project.id}/remote_mirrors" }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment