2013-05-14 08:33:31 -04:00
|
|
|
module API
|
2012-06-27 07:32:56 -04:00
|
|
|
module Entities
|
|
|
|
class User < Grape::Entity
|
2012-12-10 17:46:31 -05:00
|
|
|
expose :id, :username, :email, :name, :bio, :skype, :linkedin, :twitter,
|
2013-05-28 19:41:15 -04:00
|
|
|
:theme_id, :color_scheme_id, :state, :created_at, :extern_uid, :provider
|
2013-07-31 06:52:23 -04:00
|
|
|
expose :is_admin?, as: :is_admin
|
|
|
|
expose :can_create_group?, as: :can_create_group
|
|
|
|
expose :can_create_project?, as: :can_create_project
|
2012-06-27 07:32:56 -04:00
|
|
|
end
|
2012-06-27 08:51:39 -04:00
|
|
|
|
2013-03-11 08:35:00 -04:00
|
|
|
class UserSafe < Grape::Entity
|
|
|
|
expose :name
|
|
|
|
end
|
|
|
|
|
2012-07-05 09:47:00 -04:00
|
|
|
class UserBasic < Grape::Entity
|
2013-03-04 09:52:30 -05:00
|
|
|
expose :id, :username, :email, :name, :state, :created_at
|
2012-07-05 09:47:00 -04:00
|
|
|
end
|
|
|
|
|
2013-03-18 17:06:24 -04:00
|
|
|
class UserLogin < User
|
2012-09-20 11:36:43 -04:00
|
|
|
expose :private_token
|
2012-09-20 10:44:44 -04:00
|
|
|
end
|
|
|
|
|
2012-09-08 13:51:12 -04:00
|
|
|
class Hook < Grape::Entity
|
2012-11-29 17:59:56 -05:00
|
|
|
expose :id, :url, :created_at
|
2012-09-08 13:51:12 -04:00
|
|
|
end
|
|
|
|
|
2013-06-27 17:49:26 -04:00
|
|
|
class ForkedFromProject < Grape::Entity
|
|
|
|
expose :id
|
|
|
|
expose :name, :name_with_namespace
|
|
|
|
expose :path, :path_with_namespace
|
|
|
|
end
|
|
|
|
|
2012-06-27 08:51:39 -04:00
|
|
|
class Project < Grape::Entity
|
2013-06-03 12:49:04 -04:00
|
|
|
expose :id, :description, :default_branch, :public, :ssh_url_to_repo, :http_url_to_repo, :web_url
|
2012-08-10 18:07:50 -04:00
|
|
|
expose :owner, using: Entities::UserBasic
|
2013-06-03 12:49:04 -04:00
|
|
|
expose :name, :name_with_namespace
|
2013-01-31 02:11:35 -05:00
|
|
|
expose :path, :path_with_namespace
|
2013-07-12 11:58:17 -04:00
|
|
|
expose :issues_enabled, :merge_requests_enabled, :wall_enabled, :wiki_enabled, :snippets_enabled, :created_at, :last_activity_at, :public
|
2013-01-02 15:31:20 -05:00
|
|
|
expose :namespace
|
2013-06-27 17:49:26 -04:00
|
|
|
expose :forked_from_project, using: Entities::ForkedFromProject, :if => lambda{ | project, options | project.forked? }
|
2012-06-27 08:51:39 -04:00
|
|
|
end
|
|
|
|
|
2012-09-21 06:23:17 -04:00
|
|
|
class ProjectMember < UserBasic
|
2013-03-18 16:11:28 -04:00
|
|
|
expose :project_access, as: :access_level do |user, options|
|
2012-09-21 06:23:17 -04:00
|
|
|
options[:project].users_projects.find_by_user_id(user.id).project_access
|
|
|
|
end
|
2012-09-06 16:49:29 -04:00
|
|
|
end
|
|
|
|
|
2013-05-21 17:13:30 -04:00
|
|
|
class TeamMember < UserBasic
|
|
|
|
expose :permission, as: :access_level do |user, options|
|
|
|
|
options[:user_team].user_team_user_relationships.find_by_user_id(user.id).permission
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class TeamProject < Project
|
|
|
|
expose :greatest_access, as: :greatest_access_level do |project, options|
|
|
|
|
options[:user_team].user_team_project_relationships.find_by_project_id(project.id).greatest_access
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-08 16:05:00 -05:00
|
|
|
class Group < Grape::Entity
|
2013-02-01 09:00:12 -05:00
|
|
|
expose :id, :name, :path, :owner_id
|
2013-01-08 16:05:00 -05:00
|
|
|
end
|
2013-02-18 04:10:58 -05:00
|
|
|
|
2013-02-03 13:38:33 -05:00
|
|
|
class GroupDetail < Group
|
2013-01-08 16:05:00 -05:00
|
|
|
expose :projects, using: Entities::Project
|
|
|
|
end
|
|
|
|
|
2013-09-04 11:19:03 -04:00
|
|
|
class GroupMember < UserBasic
|
|
|
|
expose :group_access, as: :access_level do |user, options|
|
|
|
|
options[:group].users_groups.find_by_user_id(user.id).group_access
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-06 09:08:17 -04:00
|
|
|
class RepoObject < Grape::Entity
|
2012-06-27 08:51:39 -04:00
|
|
|
expose :name, :commit
|
2013-01-28 12:22:44 -05:00
|
|
|
expose :protected do |repo, options|
|
|
|
|
if options[:project]
|
|
|
|
options[:project].protected_branch? repo.name
|
|
|
|
end
|
|
|
|
end
|
2012-06-27 08:51:39 -04:00
|
|
|
end
|
2012-06-29 09:34:08 -04:00
|
|
|
|
2012-09-21 07:34:07 -04:00
|
|
|
class RepoCommit < Grape::Entity
|
|
|
|
expose :id, :short_id, :title, :author_name, :author_email, :created_at
|
|
|
|
end
|
|
|
|
|
2012-06-29 09:34:08 -04:00
|
|
|
class ProjectSnippet < Grape::Entity
|
|
|
|
expose :id, :title, :file_name
|
2012-08-10 18:07:50 -04:00
|
|
|
expose :author, using: Entities::UserBasic
|
2012-06-29 09:34:08 -04:00
|
|
|
expose :expires_at, :updated_at, :created_at
|
|
|
|
end
|
2012-07-24 08:19:51 -04:00
|
|
|
|
2013-10-14 09:39:54 -04:00
|
|
|
class ProjectEntity < Grape::Entity
|
|
|
|
expose :id, :iid
|
|
|
|
expose (:project_id) { |entity| entity.project.id }
|
|
|
|
end
|
|
|
|
|
|
|
|
class Milestone < ProjectEntity
|
2013-02-18 04:10:58 -05:00
|
|
|
expose :title, :description, :due_date, :state, :updated_at, :created_at
|
2012-07-24 08:19:51 -04:00
|
|
|
end
|
|
|
|
|
2013-10-14 09:39:54 -04:00
|
|
|
class Issue < ProjectEntity
|
2012-07-25 07:22:21 -04:00
|
|
|
expose :title, :description
|
2012-08-10 18:07:50 -04:00
|
|
|
expose :label_list, as: :labels
|
|
|
|
expose :milestone, using: Entities::Milestone
|
|
|
|
expose :assignee, :author, using: Entities::UserBasic
|
2013-02-18 04:10:58 -05:00
|
|
|
expose :state, :updated_at, :created_at
|
2012-07-24 08:19:51 -04:00
|
|
|
end
|
2012-09-16 10:52:06 -04:00
|
|
|
|
2013-10-14 09:39:54 -04:00
|
|
|
class MergeRequest < ProjectEntity
|
|
|
|
expose :target_branch, :source_branch, :title, :state, :upvotes, :downvotes
|
|
|
|
expose :author, :assignee, using: Entities::UserBasic
|
|
|
|
expose :source_project_id, :target_project_id
|
2012-09-16 10:52:06 -04:00
|
|
|
end
|
2012-10-21 07:00:27 -04:00
|
|
|
|
2013-10-14 09:39:54 -04:00
|
|
|
class SSHKey < Grape::Entity
|
|
|
|
expose :id, :title, :key, :created_at
|
2012-10-21 07:00:27 -04:00
|
|
|
end
|
2012-10-21 12:48:56 -04:00
|
|
|
|
|
|
|
class Note < Grape::Entity
|
2012-11-27 14:43:39 -05:00
|
|
|
expose :id
|
|
|
|
expose :note, as: :body
|
2013-03-19 07:28:29 -04:00
|
|
|
expose :attachment_identifier, as: :attachment
|
2012-10-21 12:48:56 -04:00
|
|
|
expose :author, using: Entities::UserBasic
|
2012-11-29 17:41:24 -05:00
|
|
|
expose :created_at
|
2012-10-21 12:48:56 -04:00
|
|
|
end
|
2012-11-29 15:10:07 -05:00
|
|
|
|
|
|
|
class MRNote < Grape::Entity
|
|
|
|
expose :note
|
|
|
|
expose :author, using: Entities::UserBasic
|
|
|
|
end
|
2013-06-06 12:19:17 -04:00
|
|
|
|
|
|
|
class Event < Grape::Entity
|
|
|
|
expose :title, :project_id, :action_name
|
|
|
|
expose :target_id, :target_type, :author_id
|
|
|
|
expose :data, :target_title
|
|
|
|
end
|
2012-06-27 07:32:56 -04:00
|
|
|
end
|
|
|
|
end
|