2020-05-15 05:07:59 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
2020-10-14 20:08:42 -04:00
|
|
|
class ProjectRepositoryStorageMoves < ::API::Base
|
2020-05-15 05:07:59 -04:00
|
|
|
include PaginationParams
|
|
|
|
|
|
|
|
before { authenticated_as_admin! }
|
|
|
|
|
2020-10-30 11:08:59 -04:00
|
|
|
feature_category :gitaly
|
|
|
|
|
2020-05-15 05:07:59 -04:00
|
|
|
resource :project_repository_storage_moves do
|
|
|
|
desc 'Get a list of all project repository storage moves' do
|
|
|
|
detail 'This feature was introduced in GitLab 13.0.'
|
2021-02-22 13:10:55 -05:00
|
|
|
success Entities::Projects::RepositoryStorageMove
|
2020-05-15 05:07:59 -04:00
|
|
|
end
|
|
|
|
params do
|
|
|
|
use :pagination
|
|
|
|
end
|
|
|
|
get do
|
2021-02-22 13:10:55 -05:00
|
|
|
storage_moves = ::Projects::RepositoryStorageMove.with_projects.order_created_at_desc
|
2020-05-15 05:07:59 -04:00
|
|
|
|
2021-02-22 13:10:55 -05:00
|
|
|
present paginate(storage_moves), with: Entities::Projects::RepositoryStorageMove, current_user: current_user
|
2020-05-15 05:07:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Get a project repository storage move' do
|
|
|
|
detail 'This feature was introduced in GitLab 13.0.'
|
2021-02-22 13:10:55 -05:00
|
|
|
success Entities::Projects::RepositoryStorageMove
|
2020-05-15 05:07:59 -04:00
|
|
|
end
|
2020-05-29 17:08:35 -04:00
|
|
|
params do
|
|
|
|
requires :repository_storage_move_id, type: Integer, desc: 'The ID of a project repository storage move'
|
|
|
|
end
|
|
|
|
get ':repository_storage_move_id' do
|
2021-02-22 13:10:55 -05:00
|
|
|
storage_move = ::Projects::RepositoryStorageMove.find(params[:repository_storage_move_id])
|
2020-05-29 17:08:35 -04:00
|
|
|
|
2021-02-22 13:10:55 -05:00
|
|
|
present storage_move, with: Entities::Projects::RepositoryStorageMove, current_user: current_user
|
2020-05-29 17:08:35 -04:00
|
|
|
end
|
2020-11-26 07:09:48 -05:00
|
|
|
|
|
|
|
desc 'Schedule bulk project repository storage moves' do
|
|
|
|
detail 'This feature was introduced in GitLab 13.7.'
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :source_storage_name, type: String, desc: 'The source storage shard', values: -> { Gitlab.config.repositories.storages.keys }
|
|
|
|
optional :destination_storage_name, type: String, desc: 'The destination storage shard', values: -> { Gitlab.config.repositories.storages.keys }
|
|
|
|
end
|
|
|
|
post do
|
|
|
|
::Projects::ScheduleBulkRepositoryShardMovesService.enqueue(
|
|
|
|
declared_params[:source_storage_name],
|
|
|
|
declared_params[:destination_storage_name]
|
|
|
|
)
|
|
|
|
|
|
|
|
accepted!
|
|
|
|
end
|
2020-05-29 17:08:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: 'The ID of a project'
|
|
|
|
end
|
|
|
|
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
|
|
|
desc 'Get a list of all project repository storage moves' do
|
|
|
|
detail 'This feature was introduced in GitLab 13.1.'
|
2021-02-22 13:10:55 -05:00
|
|
|
success Entities::Projects::RepositoryStorageMove
|
2020-05-29 17:08:35 -04:00
|
|
|
end
|
|
|
|
params do
|
|
|
|
use :pagination
|
|
|
|
end
|
|
|
|
get ':id/repository_storage_moves' do
|
|
|
|
storage_moves = user_project.repository_storage_moves.with_projects.order_created_at_desc
|
|
|
|
|
2021-02-22 13:10:55 -05:00
|
|
|
present paginate(storage_moves), with: Entities::Projects::RepositoryStorageMove, current_user: current_user
|
2020-05-29 17:08:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Get a project repository storage move' do
|
|
|
|
detail 'This feature was introduced in GitLab 13.1.'
|
2021-02-22 13:10:55 -05:00
|
|
|
success Entities::Projects::RepositoryStorageMove
|
2020-05-29 17:08:35 -04:00
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :repository_storage_move_id, type: Integer, desc: 'The ID of a project repository storage move'
|
|
|
|
end
|
|
|
|
get ':id/repository_storage_moves/:repository_storage_move_id' do
|
|
|
|
storage_move = user_project.repository_storage_moves.find(params[:repository_storage_move_id])
|
2020-05-15 05:07:59 -04:00
|
|
|
|
2021-02-22 13:10:55 -05:00
|
|
|
present storage_move, with: Entities::Projects::RepositoryStorageMove, current_user: current_user
|
2020-05-15 05:07:59 -04:00
|
|
|
end
|
2020-06-15 20:08:33 -04:00
|
|
|
|
|
|
|
desc 'Schedule a project repository storage move' do
|
|
|
|
detail 'This feature was introduced in GitLab 13.1.'
|
2021-02-22 13:10:55 -05:00
|
|
|
success Entities::Projects::RepositoryStorageMove
|
2020-06-15 20:08:33 -04:00
|
|
|
end
|
|
|
|
params do
|
2020-10-19 08:09:20 -04:00
|
|
|
optional :destination_storage_name, type: String, desc: 'The destination storage shard'
|
2020-06-15 20:08:33 -04:00
|
|
|
end
|
|
|
|
post ':id/repository_storage_moves' do
|
|
|
|
storage_move = user_project.repository_storage_moves.build(
|
|
|
|
declared_params.merge(source_storage_name: user_project.repository_storage)
|
|
|
|
)
|
|
|
|
|
|
|
|
if storage_move.schedule
|
2021-02-22 13:10:55 -05:00
|
|
|
present storage_move, with: Entities::Projects::RepositoryStorageMove, current_user: current_user
|
2020-06-15 20:08:33 -04:00
|
|
|
else
|
|
|
|
render_validation_error!(storage_move)
|
|
|
|
end
|
|
|
|
end
|
2020-05-15 05:07:59 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|