gitlab-org--gitlab-foss/lib/api/entities.rb

151 lines
4.5 KiB
Ruby
Raw Normal View History

module API
2012-06-27 07:32:56 -04:00
module Entities
class User < Grape::Entity
expose :id, :username, :email, :name, :bio, :skype, :linkedin, :twitter,
:theme_id, :color_scheme_id, :state, :created_at, :extern_uid, :provider
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
class UserSafe < Grape::Entity
expose :name
end
class UserBasic < Grape::Entity
expose :id, :username, :email, :name, :state, :created_at
end
2013-03-18 17:06:24 -04:00
class UserLogin < User
expose :private_token
end
2012-09-08 13:51:12 -04:00
class Hook < Grape::Entity
expose :id, :url, :created_at
2012-09-08 13:51:12 -04:00
end
class ProjectHook < Hook
expose :project_id, :push_events, :issues_events, :merge_requests_events
end
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
expose :id, :description, :default_branch
expose :public?, as: :public
expose :visibility_level, :ssh_url_to_repo, :http_url_to_repo, :web_url
expose :owner, using: Entities::UserBasic
expose :name, :name_with_namespace
expose :path, :path_with_namespace
expose :issues_enabled, :merge_requests_enabled, :wall_enabled, :wiki_enabled, :snippets_enabled, :created_at, :last_activity_at
expose :namespace
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
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
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
class Group < Grape::Entity
expose :id, :name, :path, :owner_id
end
2013-02-18 04:10:58 -05:00
class GroupDetail < Group
expose :projects, using: Entities::Project
end
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
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
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
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
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
class Issue < ProjectEntity
2012-07-25 07:22:21 -04:00
expose :title, :description
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
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
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
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
expose :created_at
2012-10-21 12:48:56 -04:00
end
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
class Namespace < Grape::Entity
expose :id, :path, :kind
end
2012-06-27 07:32:56 -04:00
end
end