diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 18:09:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 18:09:08 +0300 |
commit | b3a736ed88a1db0391cd9881e70b987bab7d89d1 (patch) | |
tree | a91ca3a06abd4c3412775ac3c49b11e3151df2be /lib/api | |
parent | 5366964a10484c2783a646b35a6da9eece01b242 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/entities.rb | 44 | ||||
-rw-r--r-- | lib/api/entities/application.rb | 13 | ||||
-rw-r--r-- | lib/api/entities/application_with_secret.rb | 10 | ||||
-rw-r--r-- | lib/api/entities/blob.rb | 20 | ||||
-rw-r--r-- | lib/api/entities/custom_attribute.rb | 10 | ||||
-rw-r--r-- | lib/api/entities/pages_domain_certificate_expiration.rb | 10 | ||||
-rw-r--r-- | lib/api/entities/user_agent_detail.rb | 11 | ||||
-rw-r--r-- | lib/api/group_import.rb | 15 |
8 files changed, 87 insertions, 46 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index df7c7b15aeb..3435d1d6f11 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -199,50 +199,6 @@ module API end.compact end end - - class UserAgentDetail < Grape::Entity - expose :user_agent - expose :ip_address - expose :submitted, as: :akismet_submitted - end - - class CustomAttribute < Grape::Entity - expose :key - expose :value - end - - class PagesDomainCertificateExpiration < Grape::Entity - expose :expired?, as: :expired - expose :expiration - end - - class Application < Grape::Entity - expose :id - expose :uid, as: :application_id - expose :name, as: :application_name - expose :redirect_uri, as: :callback_url - expose :confidential - end - - # Use with care, this exposes the secret - class ApplicationWithSecret < Application - expose :secret - end - - class Blob < Grape::Entity - expose :basename - expose :data - expose :path - # TODO: :filename was renamed to :path but both still return the full path, - # in the future we can only return the filename here without the leading - # directory path. - # https://gitlab.com/gitlab-org/gitlab/issues/34521 - expose :filename, &:path - expose :id - expose :ref - expose :startline - expose :project_id - end end end diff --git a/lib/api/entities/application.rb b/lib/api/entities/application.rb new file mode 100644 index 00000000000..33514200424 --- /dev/null +++ b/lib/api/entities/application.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module API + module Entities + class Application < Grape::Entity + expose :id + expose :uid, as: :application_id + expose :name, as: :application_name + expose :redirect_uri, as: :callback_url + expose :confidential + end + end +end diff --git a/lib/api/entities/application_with_secret.rb b/lib/api/entities/application_with_secret.rb new file mode 100644 index 00000000000..3e540381d89 --- /dev/null +++ b/lib/api/entities/application_with_secret.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module API + module Entities + # Use with care, this exposes the secret + class ApplicationWithSecret < Entities::Application + expose :secret + end + end +end diff --git a/lib/api/entities/blob.rb b/lib/api/entities/blob.rb new file mode 100644 index 00000000000..b14ef127b68 --- /dev/null +++ b/lib/api/entities/blob.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module API + module Entities + class Blob < Grape::Entity + expose :basename + expose :data + expose :path + # TODO: :filename was renamed to :path but both still return the full path, + # in the future we can only return the filename here without the leading + # directory path. + # https://gitlab.com/gitlab-org/gitlab/issues/34521 + expose :filename, &:path + expose :id + expose :ref + expose :startline + expose :project_id + end + end +end diff --git a/lib/api/entities/custom_attribute.rb b/lib/api/entities/custom_attribute.rb new file mode 100644 index 00000000000..f949b709517 --- /dev/null +++ b/lib/api/entities/custom_attribute.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module API + module Entities + class CustomAttribute < Grape::Entity + expose :key + expose :value + end + end +end diff --git a/lib/api/entities/pages_domain_certificate_expiration.rb b/lib/api/entities/pages_domain_certificate_expiration.rb new file mode 100644 index 00000000000..bfc70f6657f --- /dev/null +++ b/lib/api/entities/pages_domain_certificate_expiration.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module API + module Entities + class PagesDomainCertificateExpiration < Grape::Entity + expose :expired?, as: :expired + expose :expiration + end + end +end diff --git a/lib/api/entities/user_agent_detail.rb b/lib/api/entities/user_agent_detail.rb new file mode 100644 index 00000000000..a2d02c16589 --- /dev/null +++ b/lib/api/entities/user_agent_detail.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module API + module Entities + class UserAgentDetail < Grape::Entity + expose :user_agent + expose :ip_address + expose :submitted, as: :akismet_submitted + end + end +end diff --git a/lib/api/group_import.rb b/lib/api/group_import.rb index de7fdc27243..3531abb2604 100644 --- a/lib/api/group_import.rb +++ b/lib/api/group_import.rb @@ -5,15 +5,25 @@ module API MAXIMUM_FILE_SIZE = 50.megabytes.freeze helpers do - def authorize_create_group! - parent_group = find_group!(params[:parent_id]) if params[:parent_id].present? + def parent_group + find_group!(params[:parent_id]) if params[:parent_id].present? + end + def authorize_create_group! if parent_group authorize! :create_subgroup, parent_group else authorize! :create_group end end + + def closest_allowed_visibility_level + if parent_group + Gitlab::VisibilityLevel.closest_allowed_level(parent_group.visibility_level) + else + Gitlab::VisibilityLevel::PRIVATE + end + end end resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do @@ -59,6 +69,7 @@ module API path: params[:path], name: params[:name], parent_id: params[:parent_id], + visibility_level: closest_allowed_visibility_level, import_export_upload: ImportExportUpload.new(import_file: uploaded_file) } |