summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsmaa Hassan <ahassanahmed@gitlab.com>2021-09-27 09:52:42 +0200
committerAsmaa Hassan <ahassanahmed@gitlab.com>2021-09-27 09:52:42 +0200
commit85ad62b9d45e8f772718735b9d9bf75e209786bf (patch)
tree89d6c48bf9d2fb3c0158c6efc26549b793b95f89
parent533785b08b52989b1435c8d0723b83c8e1b5d12a (diff)
downloadgitlab-ce-trigger-remote-mirror.tar.gz
Adding an option to manually trigger a mirror synctrigger-remote-mirror
-rw-r--r--lib/api/remote_mirrors.rb21
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
+