1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
module API
module Entities
class User < Grape::Entity
expose :id, :username, :email, :name, :bio, :skype, :linkedin, :twitter,
:dark_scheme, :theme_id, :state, :created_at, :extern_uid, :provider
end
class UserSafe < Grape::Entity
expose :name
end
class UserBasic < Grape::Entity
expose :id, :username, :email, :name, :state, :created_at
end
class UserLogin < User
expose :private_token
expose :is_admin?, as: :is_admin
expose :can_create_group?, as: :can_create_group
expose :can_create_project?, as: :can_create_project
expose :can_create_team?, as: :can_create_team
end
class Hook < Grape::Entity
expose :id, :url, :created_at
end
class Project < Grape::Entity
expose :id, :name, :description, :default_branch
expose :owner, using: Entities::UserBasic
expose :public
expose :path, :path_with_namespace
expose :issues_enabled, :merge_requests_enabled, :wall_enabled, :wiki_enabled, :created_at
expose :namespace
end
class ProjectMember < UserBasic
expose :project_access, as: :access_level do |user, options|
options[:project].users_projects.find_by_user_id(user.id).project_access
end
end
class Group < Grape::Entity
expose :id, :name, :path, :owner_id
end
class GroupDetail < Group
expose :projects, using: Entities::Project
end
class RepoObject < Grape::Entity
expose :name, :commit
expose :protected do |repo, options|
if options[:project]
options[:project].protected_branch? repo.name
end
end
end
class RepoCommit < Grape::Entity
expose :id, :short_id, :title, :author_name, :author_email, :created_at
end
class ProjectSnippet < Grape::Entity
expose :id, :title, :file_name
expose :author, using: Entities::UserBasic
expose :expires_at, :updated_at, :created_at
end
class Milestone < Grape::Entity
expose :id
expose (:project_id) {|milestone| milestone.project.id}
expose :title, :description, :due_date, :state, :updated_at, :created_at
end
class Issue < Grape::Entity
expose :id
expose (:project_id) {|issue| issue.project.id}
expose :title, :description
expose :label_list, as: :labels
expose :milestone, using: Entities::Milestone
expose :assignee, :author, using: Entities::UserBasic
expose :state, :updated_at, :created_at
end
class SSHKey < Grape::Entity
expose :id, :title, :key, :created_at
end
class MergeRequest < Grape::Entity
expose :id, :target_branch, :source_branch, :project_id, :title, :state
expose :author, :assignee, using: Entities::UserBasic
end
class Note < Grape::Entity
expose :id
expose :note, as: :body
expose :attachment_identifier, as: :attachment
expose :author, using: Entities::UserBasic
expose :created_at
end
class MRNote < Grape::Entity
expose :note
expose :author, using: Entities::UserBasic
end
end
end
|