diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /lib/api/entities | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'lib/api/entities')
46 files changed, 383 insertions, 263 deletions
diff --git a/lib/api/entities/basic_project_details.rb b/lib/api/entities/basic_project_details.rb index c75b74b4368..0b231906ccd 100644 --- a/lib/api/entities/basic_project_details.rb +++ b/lib/api/entities/basic_project_details.rb @@ -6,7 +6,7 @@ module API include ::API::ProjectsRelationBuilder include Gitlab::Utils::StrongMemoize - expose :default_branch, if: -> (project, options) { Ability.allowed?(options[:current_user], :download_code, project) } + expose :default_branch_or_main, as: :default_branch, if: -> (project, options) { Ability.allowed?(options[:current_user], :download_code, project) } # Avoids an N+1 query: https://github.com/mbleigh/acts-as-taggable-on/issues/91#issuecomment-168273770 expose :topic_names, as: :tag_list diff --git a/lib/api/entities/bulk_import.rb b/lib/api/entities/bulk_import.rb new file mode 100644 index 00000000000..373ae486dcf --- /dev/null +++ b/lib/api/entities/bulk_import.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module API + module Entities + class BulkImport < Grape::Entity + expose :id + expose :status_name, as: :status + expose :source_type + expose :created_at + expose :updated_at + end + end +end diff --git a/lib/api/entities/bulk_imports/entity.rb b/lib/api/entities/bulk_imports/entity.rb new file mode 100644 index 00000000000..e8c31256b17 --- /dev/null +++ b/lib/api/entities/bulk_imports/entity.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module API + module Entities + module BulkImports + class Entity < Grape::Entity + expose :id + expose :bulk_import_id + expose :status_name, as: :status + expose :source_full_path + expose :destination_name + expose :destination_namespace + expose :parent_id + expose :namespace_id + expose :project_id + expose :created_at + expose :updated_at + expose :failures, using: EntityFailure + end + end + end +end diff --git a/lib/api/entities/bulk_imports/entity_failure.rb b/lib/api/entities/bulk_imports/entity_failure.rb new file mode 100644 index 00000000000..a3dbe3280ee --- /dev/null +++ b/lib/api/entities/bulk_imports/entity_failure.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module API + module Entities + module BulkImports + class EntityFailure < Grape::Entity + expose :pipeline_class + expose :pipeline_step + expose :exception_class + expose :correlation_id_value + expose :created_at + end + end + end +end diff --git a/lib/api/entities/ci/job.rb b/lib/api/entities/ci/job.rb index 76487ed01dc..cf87684ce55 100644 --- a/lib/api/entities/ci/job.rb +++ b/lib/api/entities/ci/job.rb @@ -7,7 +7,7 @@ module API # artifacts_file is included in job_artifacts, but kept for backward compatibility (remove in api/v5) expose :artifacts_file, using: ::API::Entities::Ci::JobArtifactFile, if: -> (job, opts) { job.artifacts? } expose :job_artifacts, as: :artifacts, using: ::API::Entities::Ci::JobArtifact - expose :runner, with: ::API::Entities::Runner + expose :runner, with: ::API::Entities::Ci::Runner expose :artifacts_expire_at expose :tag_list do |job| job.tags.map(&:name).sort diff --git a/lib/api/entities/ci/job_request/artifacts.rb b/lib/api/entities/ci/job_request/artifacts.rb new file mode 100644 index 00000000000..4b09db40504 --- /dev/null +++ b/lib/api/entities/ci/job_request/artifacts.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + module JobRequest + class Artifacts < Grape::Entity + expose :name + expose :untracked + expose :paths + expose :exclude, expose_nil: false + expose :when + expose :expire_in + expose :artifact_type + expose :artifact_format + end + end + end + end +end diff --git a/lib/api/entities/ci/job_request/cache.rb b/lib/api/entities/ci/job_request/cache.rb new file mode 100644 index 00000000000..9820719b4f0 --- /dev/null +++ b/lib/api/entities/ci/job_request/cache.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + module JobRequest + class Cache < Grape::Entity + expose :key, :untracked, :paths, :policy, :when + end + end + end + end +end diff --git a/lib/api/entities/ci/job_request/credentials.rb b/lib/api/entities/ci/job_request/credentials.rb new file mode 100644 index 00000000000..57cdd9c9b19 --- /dev/null +++ b/lib/api/entities/ci/job_request/credentials.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + module JobRequest + class Credentials < Grape::Entity + expose :type, :url, :username, :password + end + end + end + end +end diff --git a/lib/api/entities/ci/job_request/dependency.rb b/lib/api/entities/ci/job_request/dependency.rb new file mode 100644 index 00000000000..2c6ed417714 --- /dev/null +++ b/lib/api/entities/ci/job_request/dependency.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + module JobRequest + class Dependency < Grape::Entity + expose :id, :name, :token + expose :artifacts_file, using: Entities::Ci::JobArtifactFile, if: ->(job, _) { job.artifacts? } + end + end + end + end +end diff --git a/lib/api/entities/ci/job_request/git_info.rb b/lib/api/entities/ci/job_request/git_info.rb new file mode 100644 index 00000000000..872c896b870 --- /dev/null +++ b/lib/api/entities/ci/job_request/git_info.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + module JobRequest + class GitInfo < Grape::Entity + expose :repo_url, :ref, :sha, :before_sha + expose :ref_type + expose :refspecs + expose :git_depth, as: :depth + end + end + end + end +end diff --git a/lib/api/entities/ci/job_request/image.rb b/lib/api/entities/ci/job_request/image.rb new file mode 100644 index 00000000000..8e404a8fa02 --- /dev/null +++ b/lib/api/entities/ci/job_request/image.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + module JobRequest + class Image < Grape::Entity + expose :name, :entrypoint + expose :ports, using: Entities::Ci::JobRequest::Port + end + end + end + end +end diff --git a/lib/api/entities/ci/job_request/job_info.rb b/lib/api/entities/ci/job_request/job_info.rb new file mode 100644 index 00000000000..5c3f4b08af2 --- /dev/null +++ b/lib/api/entities/ci/job_request/job_info.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + module JobRequest + class JobInfo < Grape::Entity + expose :id, :name, :stage + expose :project_id, :project_name + end + end + end + end +end diff --git a/lib/api/entities/ci/job_request/port.rb b/lib/api/entities/ci/job_request/port.rb new file mode 100644 index 00000000000..31aa06ff843 --- /dev/null +++ b/lib/api/entities/ci/job_request/port.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + module JobRequest + class Port < Grape::Entity + expose :number, :protocol, :name + end + end + end + end +end diff --git a/lib/api/entities/ci/job_request/response.rb b/lib/api/entities/ci/job_request/response.rb new file mode 100644 index 00000000000..86c945cb236 --- /dev/null +++ b/lib/api/entities/ci/job_request/response.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + module JobRequest + class Response < Grape::Entity + expose :id + expose :token + expose :allow_git_fetch + + expose :job_info, using: Entities::Ci::JobRequest::JobInfo do |model| + model + end + + expose :git_info, using: Entities::Ci::JobRequest::GitInfo do |model| + model + end + + expose :runner_info, using: Entities::Ci::JobRequest::RunnerInfo do |model| + model + end + + expose :runner_variables, as: :variables + expose :steps, using: Entities::Ci::JobRequest::Step + expose :image, using: Entities::Ci::JobRequest::Image + expose :services, using: Entities::Ci::JobRequest::Service + expose :artifacts, using: Entities::Ci::JobRequest::Artifacts + expose :cache, using: Entities::Ci::JobRequest::Cache + expose :credentials, using: Entities::Ci::JobRequest::Credentials + expose :all_dependencies, as: :dependencies, using: Entities::Ci::JobRequest::Dependency + expose :features + end + end + end + end +end + +API::Entities::Ci::JobRequest::Response.prepend_mod_with('API::Entities::Ci::JobRequest::Response') diff --git a/lib/api/entities/ci/job_request/runner_info.rb b/lib/api/entities/ci/job_request/runner_info.rb new file mode 100644 index 00000000000..96336a1080e --- /dev/null +++ b/lib/api/entities/ci/job_request/runner_info.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + module JobRequest + class RunnerInfo < Grape::Entity + expose :metadata_timeout, as: :timeout + expose :runner_session_url + end + end + end + end +end diff --git a/lib/api/entities/ci/job_request/service.rb b/lib/api/entities/ci/job_request/service.rb new file mode 100644 index 00000000000..f89b95c1d5c --- /dev/null +++ b/lib/api/entities/ci/job_request/service.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + module JobRequest + class Service < Entities::Ci::JobRequest::Image + expose :alias, :command + end + end + end + end +end diff --git a/lib/api/entities/ci/job_request/step.rb b/lib/api/entities/ci/job_request/step.rb new file mode 100644 index 00000000000..2a0c4cd032e --- /dev/null +++ b/lib/api/entities/ci/job_request/step.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + module JobRequest + class Step < Grape::Entity + expose :name, :script, :timeout, :when, :allow_failure + end + end + end + end +end diff --git a/lib/api/entities/ci/runner.rb b/lib/api/entities/ci/runner.rb new file mode 100644 index 00000000000..ede698696de --- /dev/null +++ b/lib/api/entities/ci/runner.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + class Runner < Grape::Entity + expose :id + expose :description + expose :ip_address + expose :active + expose :instance_type?, as: :is_shared + expose :runner_type + expose :name + expose :online?, as: :online + expose :status + end + end + end +end diff --git a/lib/api/entities/ci/runner_details.rb b/lib/api/entities/ci/runner_details.rb new file mode 100644 index 00000000000..9d44da7e5b3 --- /dev/null +++ b/lib/api/entities/ci/runner_details.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + class RunnerDetails < Runner + expose :tag_list + expose :run_untagged + expose :locked + expose :maximum_timeout + expose :access_level + expose :version, :revision, :platform, :architecture + expose :contacted_at + + # rubocop: disable CodeReuse/ActiveRecord + expose :projects, with: Entities::BasicProjectDetails do |runner, options| + if options[:current_user].admin? # rubocop: disable Cop/UserAdmin + runner.projects + else + options[:current_user].authorized_projects.where(id: runner.projects) + end + end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord + expose :groups, with: Entities::BasicGroupDetails do |runner, options| + if options[:current_user].admin? # rubocop: disable Cop/UserAdmin + runner.groups + else + options[:current_user].authorized_groups.where(id: runner.groups) + end + end + # rubocop: enable CodeReuse/ActiveRecord + end + end + end +end diff --git a/lib/api/entities/ci/runner_registration_details.rb b/lib/api/entities/ci/runner_registration_details.rb new file mode 100644 index 00000000000..fa7e44c9e40 --- /dev/null +++ b/lib/api/entities/ci/runner_registration_details.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module API + module Entities + module Ci + class RunnerRegistrationDetails < Grape::Entity + expose :id, :token + end + end + end +end diff --git a/lib/api/entities/group_detail.rb b/lib/api/entities/group_detail.rb index 408254a89be..61f35d0f784 100644 --- a/lib/api/entities/group_detail.rb +++ b/lib/api/entities/group_detail.rb @@ -7,6 +7,7 @@ module API SharedGroupWithGroup.represent(group.shared_with_group_links.public_or_visible_to_user(group, options[:current_user])) end expose :runners_token, if: lambda { |group, options| options[:user_can_admin_group] } + expose :prevent_sharing_groups_outside_hierarchy, if: ->(group) { group.root? } expose :projects, using: Entities::Project do |group, options| projects = GroupProjectsFinder.new( diff --git a/lib/api/entities/helm/index.rb b/lib/api/entities/helm/index.rb new file mode 100644 index 00000000000..168298f24b6 --- /dev/null +++ b/lib/api/entities/helm/index.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module API + module Entities + module Helm + class Index < Grape::Entity + expose :api_version, as: :apiVersion + expose :entries + expose :generated + expose :server_info, as: :serverInfo + end + end + end +end diff --git a/lib/api/entities/job_request/artifacts.rb b/lib/api/entities/job_request/artifacts.rb deleted file mode 100644 index 0d27f5a9189..00000000000 --- a/lib/api/entities/job_request/artifacts.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - module JobRequest - class Artifacts < Grape::Entity - expose :name - expose :untracked - expose :paths - expose :exclude, expose_nil: false - expose :when - expose :expire_in - expose :artifact_type - expose :artifact_format - end - end - end -end diff --git a/lib/api/entities/job_request/cache.rb b/lib/api/entities/job_request/cache.rb deleted file mode 100644 index cd533d7e5b3..00000000000 --- a/lib/api/entities/job_request/cache.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - module JobRequest - class Cache < Grape::Entity - expose :key, :untracked, :paths, :policy, :when - end - end - end -end diff --git a/lib/api/entities/job_request/credentials.rb b/lib/api/entities/job_request/credentials.rb deleted file mode 100644 index cdac5566cbd..00000000000 --- a/lib/api/entities/job_request/credentials.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - module JobRequest - class Credentials < Grape::Entity - expose :type, :url, :username, :password - end - end - end -end diff --git a/lib/api/entities/job_request/dependency.rb b/lib/api/entities/job_request/dependency.rb deleted file mode 100644 index 7d6ec832ba1..00000000000 --- a/lib/api/entities/job_request/dependency.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - module JobRequest - class Dependency < Grape::Entity - expose :id, :name, :token - expose :artifacts_file, using: Entities::Ci::JobArtifactFile, if: ->(job, _) { job.artifacts? } - end - end - end -end diff --git a/lib/api/entities/job_request/git_info.rb b/lib/api/entities/job_request/git_info.rb deleted file mode 100644 index e07099263b5..00000000000 --- a/lib/api/entities/job_request/git_info.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - module JobRequest - class GitInfo < Grape::Entity - expose :repo_url, :ref, :sha, :before_sha - expose :ref_type - expose :refspecs - expose :git_depth, as: :depth - end - end - end -end diff --git a/lib/api/entities/job_request/image.rb b/lib/api/entities/job_request/image.rb deleted file mode 100644 index 47f4542d2d5..00000000000 --- a/lib/api/entities/job_request/image.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - module JobRequest - class Image < Grape::Entity - expose :name, :entrypoint - expose :ports, using: Entities::JobRequest::Port - end - end - end -end diff --git a/lib/api/entities/job_request/job_info.rb b/lib/api/entities/job_request/job_info.rb deleted file mode 100644 index a4bcc9726d0..00000000000 --- a/lib/api/entities/job_request/job_info.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - module JobRequest - class JobInfo < Grape::Entity - expose :id, :name, :stage - expose :project_id, :project_name - end - end - end -end diff --git a/lib/api/entities/job_request/port.rb b/lib/api/entities/job_request/port.rb deleted file mode 100644 index ee427da8657..00000000000 --- a/lib/api/entities/job_request/port.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - module JobRequest - class Port < Grape::Entity - expose :number, :protocol, :name - end - end - end -end diff --git a/lib/api/entities/job_request/response.rb b/lib/api/entities/job_request/response.rb deleted file mode 100644 index 2e8dfc5bde0..00000000000 --- a/lib/api/entities/job_request/response.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - module JobRequest - class Response < Grape::Entity - expose :id - expose :token - expose :allow_git_fetch - - expose :job_info, using: Entities::JobRequest::JobInfo do |model| - model - end - - expose :git_info, using: Entities::JobRequest::GitInfo do |model| - model - end - - expose :runner_info, using: Entities::JobRequest::RunnerInfo do |model| - model - end - - expose :runner_variables, as: :variables - expose :steps, using: Entities::JobRequest::Step - expose :image, using: Entities::JobRequest::Image - expose :services, using: Entities::JobRequest::Service - expose :artifacts, using: Entities::JobRequest::Artifacts - expose :cache, using: Entities::JobRequest::Cache - expose :credentials, using: Entities::JobRequest::Credentials - expose :all_dependencies, as: :dependencies, using: Entities::JobRequest::Dependency - expose :features - end - end - end -end - -API::Entities::JobRequest::Response.prepend_mod_with('API::Entities::JobRequest::Response') diff --git a/lib/api/entities/job_request/runner_info.rb b/lib/api/entities/job_request/runner_info.rb deleted file mode 100644 index e6d2e8d9e85..00000000000 --- a/lib/api/entities/job_request/runner_info.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - module JobRequest - class RunnerInfo < Grape::Entity - expose :metadata_timeout, as: :timeout - expose :runner_session_url - end - end - end -end diff --git a/lib/api/entities/job_request/service.rb b/lib/api/entities/job_request/service.rb deleted file mode 100644 index 9ad5abf4e9e..00000000000 --- a/lib/api/entities/job_request/service.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - module JobRequest - class Service < Entities::JobRequest::Image - expose :alias, :command - end - end - end -end diff --git a/lib/api/entities/job_request/step.rb b/lib/api/entities/job_request/step.rb deleted file mode 100644 index 498dd017fb4..00000000000 --- a/lib/api/entities/job_request/step.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - module JobRequest - class Step < Grape::Entity - expose :name, :script, :timeout, :when, :allow_failure - end - end - end -end diff --git a/lib/api/entities/label.rb b/lib/api/entities/label.rb index ca9a0912331..dc147f33671 100644 --- a/lib/api/entities/label.rb +++ b/lib/api/entities/label.rb @@ -18,7 +18,9 @@ module API end expose :subscribed do |label, options| - label.subscribed?(options[:current_user], options[:parent]) + label.subscribed?(options[:current_user]) || ( + options[:parent].is_a?(::Project) && label.subscribed?(options[:current_user], options[:parent]) + ) end end end diff --git a/lib/api/entities/plan_limit.rb b/lib/api/entities/plan_limit.rb index 40e8b348c18..04ec44b5167 100644 --- a/lib/api/entities/plan_limit.rb +++ b/lib/api/entities/plan_limit.rb @@ -9,6 +9,7 @@ module API expose :npm_max_file_size expose :nuget_max_file_size expose :pypi_max_file_size + expose :terraform_module_max_file_size end end end diff --git a/lib/api/entities/project.rb b/lib/api/entities/project.rb index 68d91fc6970..f5f565e5b07 100644 --- a/lib/api/entities/project.rb +++ b/lib/api/entities/project.rb @@ -53,13 +53,7 @@ module API expose(:wiki_enabled) { |project, options| project.feature_available?(:wiki, options[:current_user]) } expose(:jobs_enabled) { |project, options| project.feature_available?(:builds, options[:current_user]) } expose(:snippets_enabled) { |project, options| project.feature_available?(:snippets, options[:current_user]) } - expose(:container_registry_enabled) do |project, options| - if ::Feature.enabled?(:read_container_registry_access_level, project.namespace, default_enabled: :yaml) - project.feature_available?(:container_registry, options[:current_user]) - else - project.read_attribute(:container_registry_enabled) - end - end + expose(:container_registry_enabled) { |project, options| project.feature_available?(:container_registry, options[:current_user]) } expose :service_desk_enabled expose :service_desk_address diff --git a/lib/api/entities/project_integration.rb b/lib/api/entities/project_integration.rb new file mode 100644 index 00000000000..649e4d015b8 --- /dev/null +++ b/lib/api/entities/project_integration.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module API + module Entities + class ProjectIntegration < Entities::ProjectIntegrationBasic + # Expose serialized properties + expose :properties do |integration, options| + # TODO: Simplify as part of https://gitlab.com/gitlab-org/gitlab/issues/29404 + + attributes = + if integration.data_fields_present? + integration.data_fields.as_json.keys + else + integration.properties.keys + end + + attributes &= integration.api_field_names + + attributes.each_with_object({}) do |attribute, hash| + hash[attribute] = integration.public_send(attribute) # rubocop:disable GitlabSecurity/PublicSend + end + end + end + end +end diff --git a/lib/api/entities/project_service_basic.rb b/lib/api/entities/project_integration_basic.rb index eb97ca69a82..2870123b83d 100644 --- a/lib/api/entities/project_service_basic.rb +++ b/lib/api/entities/project_integration_basic.rb @@ -2,10 +2,10 @@ module API module Entities - class ProjectServiceBasic < Grape::Entity + class ProjectIntegrationBasic < Grape::Entity expose :id, :title - expose :slug do |service| - service.to_param.dasherize + expose :slug do |integration| + integration.to_param.dasherize end expose :created_at, :updated_at, :active expose :commit_events, :push_events, :issues_events, :confidential_issues_events diff --git a/lib/api/entities/project_service.rb b/lib/api/entities/project_service.rb deleted file mode 100644 index 947cec1e3cd..00000000000 --- a/lib/api/entities/project_service.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - class ProjectService < Entities::ProjectServiceBasic - # Expose serialized properties - expose :properties do |service, options| - # TODO: Simplify as part of https://gitlab.com/gitlab-org/gitlab/issues/29404 - if service.data_fields_present? - service.data_fields.as_json.slice(*service.api_field_names) - else - service.properties.slice(*service.api_field_names) - end - end - end - end -end diff --git a/lib/api/entities/resource_access_token.rb b/lib/api/entities/resource_access_token.rb new file mode 100644 index 00000000000..a1c7b28af45 --- /dev/null +++ b/lib/api/entities/resource_access_token.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module API + module Entities + class ResourceAccessToken < Entities::PersonalAccessToken + expose :access_level do |token, options| + options[:project].project_member(token.user).access_level + end + end + end +end diff --git a/lib/api/entities/resource_access_token_with_token.rb b/lib/api/entities/resource_access_token_with_token.rb new file mode 100644 index 00000000000..edbd9b285de --- /dev/null +++ b/lib/api/entities/resource_access_token_with_token.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module API + module Entities + class ResourceAccessTokenWithToken < Entities::ResourceAccessToken + expose :token + end + end +end diff --git a/lib/api/entities/runner.rb b/lib/api/entities/runner.rb deleted file mode 100644 index e78f14cf920..00000000000 --- a/lib/api/entities/runner.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - class Runner < Grape::Entity - expose :id - expose :description - expose :ip_address - expose :active - expose :instance_type?, as: :is_shared - expose :runner_type - expose :name - expose :online?, as: :online - expose :status - end - end -end diff --git a/lib/api/entities/runner_details.rb b/lib/api/entities/runner_details.rb deleted file mode 100644 index 0afe298ef64..00000000000 --- a/lib/api/entities/runner_details.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - class RunnerDetails < Runner - expose :tag_list - expose :run_untagged - expose :locked - expose :maximum_timeout - expose :access_level - expose :version, :revision, :platform, :architecture - expose :contacted_at - - # rubocop: disable CodeReuse/ActiveRecord - expose :projects, with: Entities::BasicProjectDetails do |runner, options| - if options[:current_user].admin? - runner.projects - else - options[:current_user].authorized_projects.where(id: runner.projects) - end - end - # rubocop: enable CodeReuse/ActiveRecord - # rubocop: disable CodeReuse/ActiveRecord - expose :groups, with: Entities::BasicGroupDetails do |runner, options| - if options[:current_user].admin? - runner.groups - else - options[:current_user].authorized_groups.where(id: runner.groups) - end - end - # rubocop: enable CodeReuse/ActiveRecord - end - end -end diff --git a/lib/api/entities/runner_registration_details.rb b/lib/api/entities/runner_registration_details.rb deleted file mode 100644 index c8ed88ba10a..00000000000 --- a/lib/api/entities/runner_registration_details.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - class RunnerRegistrationDetails < Grape::Entity - expose :id, :token - end - end -end diff --git a/lib/api/entities/user.rb b/lib/api/entities/user.rb index 3ce6d03e236..973e80dd5ef 100644 --- a/lib/api/entities/user.rb +++ b/lib/api/entities/user.rb @@ -5,7 +5,7 @@ module API class User < UserBasic include UsersHelper expose :created_at, if: ->(user, opts) { Ability.allowed?(opts[:current_user], :read_user_profile, user) } - expose :bio, :bio_html, :location, :public_email, :skype, :linkedin, :twitter, :website_url, :organization, :job_title + expose :bio, :bio_html, :location, :public_email, :skype, :linkedin, :twitter, :website_url, :organization, :job_title, :pronouns expose :bot?, as: :bot expose :work_information do |user| work_information(user) |