diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-01 15:08:00 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-01 15:08:00 +0300 |
commit | 1a0d6dbdc2ac3047f4953a359ef27ba6e26074ae (patch) | |
tree | ddb78a8a0d1350dc767f049a21e0f7d37edaa82c /lib/api | |
parent | b11f7057d067885619ee3e513751f180b2e8ad85 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/api.rb | 1 | ||||
-rw-r--r-- | lib/api/api_guard.rb | 4 | ||||
-rw-r--r-- | lib/api/deploy_tokens.rb | 16 | ||||
-rw-r--r-- | lib/api/helpers/merge_requests_helpers.rb | 4 | ||||
-rw-r--r-- | lib/api/runner.rb | 5 | ||||
-rw-r--r-- | lib/api/terraform/state.rb | 44 |
6 files changed, 66 insertions, 8 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb index bc333880bbd..51fc006ec08 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -172,6 +172,7 @@ module API mount ::API::ProjectSnippets mount ::API::ProjectStatistics mount ::API::ProjectTemplates + mount ::API::Terraform::State mount ::API::ProtectedBranches mount ::API::ProtectedTags mount ::API::Releases diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb index 5cab13f001e..9dd2de5c7ba 100644 --- a/lib/api/api_guard.rb +++ b/lib/api/api_guard.rb @@ -46,6 +46,10 @@ module API prepend_if_ee('EE::API::APIGuard::HelperMethods') # rubocop: disable Cop/InjectEnterpriseEditionModule include Gitlab::Auth::AuthFinders + def access_token + super || find_personal_access_token_from_http_basic_auth + end + def find_current_user! user = find_user_from_sources return unless user diff --git a/lib/api/deploy_tokens.rb b/lib/api/deploy_tokens.rb index a637bfcb180..fb4c4265aef 100644 --- a/lib/api/deploy_tokens.rb +++ b/lib/api/deploy_tokens.rb @@ -65,11 +65,15 @@ module API post ':id/deploy_tokens' do authorize!(:create_deploy_token, user_project) - deploy_token = ::Projects::DeployTokens::CreateService.new( + result = ::Projects::DeployTokens::CreateService.new( user_project, current_user, scope_params.merge(declared(params, include_missing: false, include_parent_namespaces: false)) ).execute - present deploy_token, with: Entities::DeployTokenWithToken + if result[:status] == :success + present result[:deploy_token], with: Entities::DeployTokenWithToken + else + render_api_error!(result[:message], result[:http_status]) + end end desc 'Delete a project deploy token' do @@ -126,11 +130,15 @@ module API post ':id/deploy_tokens' do authorize!(:create_deploy_token, user_group) - deploy_token = ::Groups::DeployTokens::CreateService.new( + result = ::Groups::DeployTokens::CreateService.new( user_group, current_user, scope_params.merge(declared(params, include_missing: false, include_parent_namespaces: false)) ).execute - present deploy_token, with: Entities::DeployTokenWithToken + if result[:status] == :success + present result[:deploy_token], with: Entities::DeployTokenWithToken + else + render_api_error!(result[:message], result[:http_status]) + end end desc 'Delete a group deploy token' do diff --git a/lib/api/helpers/merge_requests_helpers.rb b/lib/api/helpers/merge_requests_helpers.rb index 0126d7a3756..e0753254002 100644 --- a/lib/api/helpers/merge_requests_helpers.rb +++ b/lib/api/helpers/merge_requests_helpers.rb @@ -36,7 +36,11 @@ module API type: String, values: %w[simple], desc: 'If simple, returns the `iid`, URL, title, description, and basic state of merge request' + optional :author_id, type: Integer, desc: 'Return merge requests which are authored by the user with the given ID' + optional :author_username, type: String, desc: 'Return merge requests which are authored by the user with the given username' + mutually_exclusive :author_id, :author_username + optional :assignee_id, types: [Integer, String], integer_none_any: true, diff --git a/lib/api/runner.rb b/lib/api/runner.rb index 0b6bad6708b..f97e28de628 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -207,10 +207,7 @@ module API status 202 header 'Job-Status', job.status header 'Range', "0-#{stream_size}" - - if Feature.enabled?(:runner_job_trace_update_interval_header, default_enabled: true) - header 'X-GitLab-Trace-Update-Interval', job.trace.update_interval.to_s - end + header 'X-GitLab-Trace-Update-Interval', job.trace.update_interval.to_s end desc 'Authorize artifacts uploading for job' do diff --git a/lib/api/terraform/state.rb b/lib/api/terraform/state.rb new file mode 100644 index 00000000000..7e55dfedfeb --- /dev/null +++ b/lib/api/terraform/state.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +module API + module Terraform + class State < Grape::API + before { authenticate! } + before { authorize! :admin_terraform_state, user_project } + + params do + requires :id, type: String, desc: 'The ID of a project' + end + resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do + params do + requires :name, type: String, desc: 'The name of a terraform state' + end + namespace ':id/terraform/state/:name' do + desc 'Get a terraform state by its name' + route_setting :authentication, basic_auth_personal_access_token: true + get do + status 501 + content_type 'text/plain' + body 'not implemented' + end + + desc 'Add a new terraform state or update an existing one' + route_setting :authentication, basic_auth_personal_access_token: true + post do + status 501 + content_type 'text/plain' + body 'not implemented' + end + + desc 'Delete a terraform state of certain name' + route_setting :authentication, basic_auth_personal_access_token: true + delete do + status 501 + content_type 'text/plain' + body 'not implemented' + end + end + end + end + end +end |