diff options
author | Asmaa Hassan <ahassanahmed@gitlab.com> | 2021-09-27 09:52:42 +0200 |
---|---|---|
committer | Asmaa Hassan <ahassanahmed@gitlab.com> | 2021-09-27 09:52:42 +0200 |
commit | 85ad62b9d45e8f772718735b9d9bf75e209786bf (patch) | |
tree | 89d6c48bf9d2fb3c0158c6efc26549b793b95f89 /lib/api/remote_mirrors.rb | |
parent | 533785b08b52989b1435c8d0723b83c8e1b5d12a (diff) | |
download | gitlab-ce-85ad62b9d45e8f772718735b9d9bf75e209786bf.tar.gz |
Adding an option to manually trigger a mirror synctrigger-remote-mirror
Diffstat (limited to 'lib/api/remote_mirrors.rb')
-rw-r--r-- | lib/api/remote_mirrors.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/api/remote_mirrors.rb b/lib/api/remote_mirrors.rb index 83096772d32..ebb906300c0 100644 --- a/lib/api/remote_mirrors.rb +++ b/lib/api/remote_mirrors.rb @@ -73,6 +73,27 @@ module API render_api_error!(result[:message], result[:http_status]) end end + + desc 'Trigger a mirror sync of a simgle remote mirror' do + success Entities::RemoteMirror + end + params do + requires :mirror_id, type: String, desc: 'The ID of a remote mirror' + end + post ':id/remote_mirrors/:mirror_id/trigger' do + mirror = user_project.remote_mirrors.find(params[:mirror_id]) + + project = mirror.project + current_user = project.creator + result = Projects::UpdateRemoteMirrorService.new(project, current_user).execute(mirror, 1) + + if result[:status] == :success + present mirror.reset, with: Entities::RemoteMirror + else + render_api_error!(result[:message], result[:http_status]) + end + end end end end + |