Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-03 00:09:03 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-03 00:09:03 +0300
commit03cd2a56f32310def67fefdc34797833a5daf770 (patch)
tree1cefc8769ffc7752183cab6dd9974e259295324d /lib/api
parent983f6954d19f269a059aab1754568737d9ab6f64 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/api.rb1
-rw-r--r--lib/api/ci/job_artifacts.rb4
-rw-r--r--lib/api/ci/runner.rb2
-rw-r--r--lib/api/entities/protected_tag.rb2
-rw-r--r--lib/api/helpers.rb12
-rw-r--r--lib/api/protected_tags.rb44
6 files changed, 46 insertions, 19 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb
index 9bef9d826b3..fb71b8b048d 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -188,6 +188,7 @@ module API
mount ::API::ProjectRepositoryStorageMoves
mount ::API::Release::Links
mount ::API::ResourceAccessTokens
+ mount ::API::ProtectedTags
mount ::API::SnippetRepositoryStorageMoves
mount ::API::ProtectedBranches
mount ::API::Statistics
diff --git a/lib/api/ci/job_artifacts.rb b/lib/api/ci/job_artifacts.rb
index 37c7cc73c46..b3a0a9ef54a 100644
--- a/lib/api/ci/job_artifacts.rb
+++ b/lib/api/ci/job_artifacts.rb
@@ -38,7 +38,7 @@ module API
latest_build = user_project.latest_successful_build_for_ref!(params[:job], params[:ref_name])
authorize_read_job_artifacts!(latest_build)
- present_artifacts_file!(latest_build.artifacts_file, project: latest_build.project)
+ present_artifacts_file!(latest_build.artifacts_file)
end
desc 'Download a specific file from artifacts archive from a ref' do
@@ -80,7 +80,7 @@ module API
build = find_build!(params[:job_id])
authorize_read_job_artifacts!(build)
- present_artifacts_file!(build.artifacts_file, project: build.project)
+ present_artifacts_file!(build.artifacts_file)
end
desc 'Download a specific file from artifacts archive' do
diff --git a/lib/api/ci/runner.rb b/lib/api/ci/runner.rb
index a75741ac695..6497b8cadaf 100644
--- a/lib/api/ci/runner.rb
+++ b/lib/api/ci/runner.rb
@@ -349,7 +349,7 @@ module API
authenticate_job!(require_running: false)
end
- present_artifacts_file!(current_job.artifacts_file, project: current_job.project, supports_direct_download: params[:direct_download])
+ present_artifacts_file!(current_job.artifacts_file, supports_direct_download: params[:direct_download])
end
end
end
diff --git a/lib/api/entities/protected_tag.rb b/lib/api/entities/protected_tag.rb
index dc397f01af6..ba984ae79b8 100644
--- a/lib/api/entities/protected_tag.rb
+++ b/lib/api/entities/protected_tag.rb
@@ -3,7 +3,7 @@
module API
module Entities
class ProtectedTag < Grape::Entity
- expose :name
+ expose :name, documentation: { type: 'string', example: 'release-1-0' }
expose :create_access_levels, using: Entities::ProtectedRefAccess
end
end
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 99f759b50d2..75e7612bd5b 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -592,19 +592,19 @@ module API
end
end
- def present_artifacts_file!(file, project:, **args)
+ def present_artifacts_file!(file, **args)
log_artifacts_filesize(file&.model)
- present_carrierwave_file!(file, project: project, **args)
+ present_carrierwave_file!(file, **args)
end
- def present_carrierwave_file!(file, project: nil, supports_direct_download: true)
+ def present_carrierwave_file!(file, supports_direct_download: true)
return not_found! unless file&.exists?
if file.file_storage?
present_disk_file!(file.path, file.filename)
elsif supports_direct_download && file.class.direct_download_enabled?
- redirect(cdn_fronted_url(file, project))
+ redirect(cdn_fronted_url(file))
else
header(*Gitlab::Workhorse.send_url(file.url))
status :ok
@@ -612,9 +612,9 @@ module API
end
end
- def cdn_fronted_url(file, project)
+ def cdn_fronted_url(file)
if file.respond_to?(:cdn_enabled_url)
- result = file.cdn_enabled_url(project, ip_address)
+ result = file.cdn_enabled_url(ip_address)
Gitlab::ApplicationContext.push(artifact_used_cdn: result.used_cdn)
result.url
else
diff --git a/lib/api/protected_tags.rb b/lib/api/protected_tags.rb
index 4611ee58479..7d4d15ab4b3 100644
--- a/lib/api/protected_tags.rb
+++ b/lib/api/protected_tags.rb
@@ -18,7 +18,13 @@ module API
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc "Get a project's protected tags" do
detail 'This feature was introduced in GitLab 11.3.'
- success Entities::ProtectedTag
+ is_array true
+ success code: 200, model: Entities::ProtectedTag
+ failure [
+ { code: 403, message: 'Unauthenticated' },
+ { code: 404, message: 'Not found' }
+ ]
+ tags %w[protected_tags]
end
params do
use :pagination
@@ -33,10 +39,15 @@ module API
desc 'Get a single protected tag' do
detail 'This feature was introduced in GitLab 11.3.'
- success Entities::ProtectedTag
+ success code: 200, model: Entities::ProtectedTag
+ failure [
+ { code: 403, message: 'Unauthenticated' },
+ { code: 404, message: 'Not found' }
+ ]
+ tags %w[protected_tags]
end
params do
- requires :name, type: String, desc: 'The name of the tag or wildcard'
+ requires :name, type: String, desc: 'The name of the tag or wildcard', documentation: { example: 'release*' }
end
# rubocop: disable CodeReuse/ActiveRecord
get ':id/protected_tags/:name', requirements: TAG_ENDPOINT_REQUIREMENTS do
@@ -48,13 +59,21 @@ module API
desc 'Protect a single tag or wildcard' do
detail 'This feature was introduced in GitLab 11.3.'
- success Entities::ProtectedTag
+ success code: 201, model: Entities::ProtectedTag
+ failure [
+ { code: 403, message: 'Unauthenticated' },
+ { code: 404, message: 'Not found' },
+ { code: 422, message: 'Unprocessable entity' }
+ ]
+ tags %w[protected_tags]
end
params do
- requires :name, type: String, desc: 'The name of the protected tag'
- optional :create_access_level, type: Integer,
- values: ProtectedTag::CreateAccessLevel.allowed_access_levels,
- desc: 'Access levels allowed to create (defaults: `40`, maintainer access level)'
+ requires :name, type: String, desc: 'The name of the protected tag', documentation: { example: 'release-1-0' }
+ optional :create_access_level,
+ type: Integer,
+ values: ProtectedTag::CreateAccessLevel.allowed_access_levels,
+ desc: 'Access levels allowed to create (defaults: `40`, maintainer access level)',
+ documentation: { example: 30 }
use :optional_params_ee
end
post ':id/protected_tags' do
@@ -76,9 +95,16 @@ module API
desc 'Unprotect a single tag' do
detail 'This feature was introduced in GitLab 11.3.'
+ success code: 204
+ failure [
+ { code: 403, message: 'Unauthenticated' },
+ { code: 404, message: 'Not found' },
+ { code: 412, message: 'Precondition Failed' }
+ ]
+ tags %w[protected_tags]
end
params do
- requires :name, type: String, desc: 'The name of the protected tag'
+ requires :name, type: String, desc: 'The name of the protected tag', documentation: { example: 'release-1-0' }
end
# rubocop: disable CodeReuse/ActiveRecord
delete ':id/protected_tags/:name', requirements: TAG_ENDPOINT_REQUIREMENTS do