summaryrefslogtreecommitdiff
path: root/lib/api/v3/entities.rb
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2017-02-24 09:23:19 +0100
committerZ.J. van de Weg <git@zjvandeweg.nl>2017-03-03 10:29:37 +0100
commitb795e3a069ec3d6fdfb5fc5942310166de349cd9 (patch)
treebea0b9710e628ab1e26fc48fcf6204869592a716 /lib/api/v3/entities.rb
parent93ed053359f7ece17c97f7c3d15f79821159a522 (diff)
downloadgitlab-ce-zj-api-rename-v2.tar.gz
Update tests to passzj-api-rename-v2
Diffstat (limited to 'lib/api/v3/entities.rb')
-rw-r--r--lib/api/v3/entities.rb96
1 files changed, 48 insertions, 48 deletions
diff --git a/lib/api/v3/entities.rb b/lib/api/v3/entities.rb
index 4c5dbebf150..b488e850093 100644
--- a/lib/api/v3/entities.rb
+++ b/lib/api/v3/entities.rb
@@ -191,12 +191,47 @@ module API
expose :id, :status, :stage, :name, :ref, :tag, :coverage
expose :created_at, :started_at, :finished_at
expose :user, with: ::API::Entities::User
- expose :artifacts_file, using: ::API::Entities::JobArtifactFile, if: -> (build, opts) { build.artifacts? }
+ expose :artifacts_file, using: ::API::Entities::JobArtifactFile, if: -> (build, _opts) { build.artifacts? }
expose :commit, with: ::API::Entities::RepoCommit
expose :runner, with: ::API::Entities::Runner
expose :pipeline, with: ::API::Entities::PipelineBasic
end
+ class Project < Grape::Entity
+ expose :id, :description, :default_branch, :tag_list
+ expose :public?, as: :public
+ expose :archived?, as: :archived
+ expose :visibility_level, :ssh_url_to_repo, :http_url_to_repo, :web_url
+ expose :owner, using: ::API::Entities::UserBasic, unless: ->(project, options) { project.group }
+ expose :name, :name_with_namespace
+ expose :path, :path_with_namespace
+ expose :container_registry_enabled
+ # Expose old field names with the new permissions methods to keep API compatible
+ expose(:issues_enabled) { |project, options| project.feature_available?(:issues, options[:current_user]) }
+ expose(:merge_requests_enabled) { |project, options| project.feature_available?(:merge_requests, options[:current_user]) }
+ expose(:wiki_enabled) { |project, options| project.feature_available?(:wiki, options[:current_user]) }
+ expose(:builds_enabled) { |project, options| project.feature_available?(:builds, options[:current_user]) }
+ expose(:snippets_enabled) { |project, options| project.feature_available?(:snippets, options[:current_user]) }
+ expose :created_at, :last_activity_at
+ expose :shared_runners_enabled
+ expose :lfs_enabled?, as: :lfs_enabled
+ expose :creator_id
+ expose :namespace, using: ::API::Entities::Namespace
+ expose :forked_from_project, using: ::API::Entities::BasicProjectDetails, if: lambda{ |project, _options| project.forked? }
+ expose :avatar_url
+ expose :star_count, :forks_count
+ expose :open_issues_count, if: lambda { |project, options| project.feature_available?(:issues, options[:current_user]) && project.default_issues_tracker? }
+ expose :runners_token, if: lambda { |_project, options| options[:user_can_admin_project] }
+ expose :public_builds
+ expose :shared_with_groups do |project, options|
+ ::API::Entities::SharedGroup.represent(project.project_group_links.all, options)
+ end
+ expose :only_allow_merge_if_build_succeeds
+ expose :request_access_enabled
+ expose :only_allow_merge_if_all_discussions_are_resolved
+ expose :statistics, using: ::API::V3::Entities::ProjectStatistics, if: :statistics
+ end
+
class BuildArtifactFile < Grape::Entity
expose :filename, :size
end
@@ -206,14 +241,14 @@ module API
end
class Environment < EnvironmentBasic
- expose :project, using: Entities::Project
+ expose :project, using: ::API::V3::Entities::Project
end
class Deployment < Grape::Entity
expose :id, :iid, :ref, :sha, :created_at
- expose :user, using: Entities::UserBasic
- expose :environment, using: Entities::EnvironmentBasic
- expose :deployable, using: Entities::Build
+ expose :user, using: ::API::Entities::UserBasic
+ expose :environment, using: V3::Entities::EnvironmentBasic
+ expose :deployable, using: V3::Entities::Build
end
class Group < Grape::Entity
@@ -237,14 +272,14 @@ module API
expose :shared_projects, using: Entities::Project
end
- class MergeRequest < ProjectEntity
+ class MergeRequest < ::API::Entities::ProjectEntity
expose :target_branch, :source_branch
expose :upvotes, :downvotes
- expose :author, :assignee, using: Entities::UserBasic
+ expose :author, :assignee, using: ::API::Entities::UserBasic
expose :source_project_id, :target_project_id
expose :label_names, as: :labels
expose :work_in_progress?, as: :work_in_progress
- expose :milestone, using: Entities::Milestone
+ expose :milestone, using: ::API::Entities::Milestone
expose :merge_when_build_succeeds
expose :merge_status
expose :diff_head_sha, as: :sha
@@ -261,46 +296,11 @@ module API
end
class MergeRequestChanges < MergeRequest
- expose :diffs, as: :changes, using: Entities::RepoDiff do |compare, _|
+ expose :diffs, as: :changes, using: ::API::Entities::RepoDiff do |compare, _|
compare.raw_diffs(all_diffs: true).to_a
end
end
- class Project < Grape::Entity
- expose :id, :description, :default_branch, :tag_list
- expose :public?, as: :public
- expose :archived?, as: :archived
- expose :visibility_level, :ssh_url_to_repo, :http_url_to_repo, :web_url
- expose :owner, using: Entities::UserBasic, unless: ->(project, options) { project.group }
- expose :name, :name_with_namespace
- expose :path, :path_with_namespace
- expose :container_registry_enabled
- # Expose old field names with the new permissions methods to keep API compatible
- expose(:issues_enabled) { |project, options| project.feature_available?(:issues, options[:current_user]) }
- expose(:merge_requests_enabled) { |project, options| project.feature_available?(:merge_requests, options[:current_user]) }
- expose(:wiki_enabled) { |project, options| project.feature_available?(:wiki, options[:current_user]) }
- expose(:builds_enabled) { |project, options| project.feature_available?(:builds, options[:current_user]) }
- expose(:snippets_enabled) { |project, options| project.feature_available?(:snippets, options[:current_user]) }
- expose :created_at, :last_activity_at
- expose :shared_runners_enabled
- expose :lfs_enabled?, as: :lfs_enabled
- expose :creator_id
- expose :namespace, using: 'API::Entities::Namespace'
- expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? }
- expose :avatar_url
- expose :star_count, :forks_count
- expose :open_issues_count, if: lambda { |project, options| project.feature_available?(:issues, options[:current_user]) && project.default_issues_tracker? }
- expose :runners_token, if: lambda { |_project, options| options[:user_can_admin_project] }
- expose :public_builds
- expose :shared_with_groups do |project, options|
- SharedGroup.represent(project.project_group_links.all, options)
- end
- expose :only_allow_merge_if_build_succeeds
- expose :request_access_enabled
- expose :only_allow_merge_if_all_discussions_are_resolved
- expose :statistics, using: 'API::Entities::ProjectStatistics', if: :statistics
- end
-
class ProjectStatistics < Grape::Entity
expose :commit_count
expose :storage_size
@@ -322,17 +322,17 @@ module API
end
end
- class ProjectHook < Hook
+ class ProjectHook < ::API::Entities::Hook
expose :project_id, :issues_events, :merge_requests_events
expose :note_events, :build_events, :pipeline_events, :wiki_page_events
end
- class ProjectWithAccess < Project
+ class ProjectWithAccess < V3::Entities::Project
expose :permissions do
- expose :project_access, using: Entities::ProjectAccess do |project, options|
+ expose :project_access, using: ::API::Entities::ProjectAccess do |project, options|
project.project_members.find_by(user_id: options[:current_user].id)
end
- expose :group_access, using: Entities::GroupAccess do |project, options|
+ expose :group_access, using: ::API::Entities::GroupAccess do |project, options|
if project.group
project.group.group_members.find_by(user_id: options[:current_user].id)
end