2013-05-14 12:33:31 +00:00
|
|
|
module API
|
2012-06-27 11:32:56 +00:00
|
|
|
module Entities
|
2014-06-13 14:46:48 +00:00
|
|
|
class UserSafe < Grape::Entity
|
|
|
|
expose :name, :username
|
|
|
|
end
|
2014-02-13 13:45:24 +00:00
|
|
|
|
2014-06-13 14:46:48 +00:00
|
|
|
class UserBasic < UserSafe
|
|
|
|
expose :id, :state, :avatar_url
|
2015-07-30 09:56:15 +00:00
|
|
|
|
|
|
|
expose :web_url do |user, options|
|
2016-03-24 16:00:26 +00:00
|
|
|
Gitlab::Routing.url_helpers.user_url(user)
|
2015-07-30 09:56:15 +00:00
|
|
|
end
|
2012-06-27 11:32:56 +00:00
|
|
|
end
|
2012-06-27 12:51:39 +00:00
|
|
|
|
2014-06-13 14:46:48 +00:00
|
|
|
class User < UserBasic
|
|
|
|
expose :created_at
|
|
|
|
expose :is_admin?, as: :is_admin
|
2016-04-05 23:57:21 +00:00
|
|
|
expose :bio, :location, :skype, :linkedin, :twitter, :website_url
|
2013-03-11 12:35:00 +00:00
|
|
|
end
|
|
|
|
|
2014-11-27 11:34:39 +00:00
|
|
|
class Identity < Grape::Entity
|
|
|
|
expose :provider, :extern_uid
|
|
|
|
end
|
|
|
|
|
2014-06-13 14:46:48 +00:00
|
|
|
class UserFull < User
|
2016-02-24 12:14:37 +00:00
|
|
|
expose :last_sign_in_at
|
|
|
|
expose :confirmed_at
|
2014-06-13 14:46:48 +00:00
|
|
|
expose :email
|
2015-02-09 12:52:42 +00:00
|
|
|
expose :theme_id, :color_scheme_id, :projects_limit, :current_sign_in_at
|
2014-11-27 11:34:39 +00:00
|
|
|
expose :identities, using: Entities::Identity
|
2014-06-13 14:46:48 +00:00
|
|
|
expose :can_create_group?, as: :can_create_group
|
|
|
|
expose :can_create_project?, as: :can_create_project
|
2016-06-06 04:38:42 +00:00
|
|
|
expose :two_factor_enabled?, as: :two_factor_enabled
|
2016-03-14 23:11:20 +00:00
|
|
|
expose :external
|
2012-07-05 13:47:00 +00:00
|
|
|
end
|
|
|
|
|
2014-06-13 14:46:48 +00:00
|
|
|
class UserLogin < UserFull
|
2012-09-20 15:36:43 +00:00
|
|
|
expose :private_token
|
2012-09-20 14:44:44 +00:00
|
|
|
end
|
|
|
|
|
2015-07-29 13:40:08 +00:00
|
|
|
class Email < Grape::Entity
|
|
|
|
expose :id, :email
|
|
|
|
end
|
|
|
|
|
2012-09-08 17:51:12 +00:00
|
|
|
class Hook < Grape::Entity
|
2012-11-29 22:59:56 +00:00
|
|
|
expose :id, :url, :created_at
|
2012-09-08 17:51:12 +00:00
|
|
|
end
|
|
|
|
|
2013-12-04 11:19:53 +00:00
|
|
|
class ProjectHook < Hook
|
2014-09-19 08:23:18 +00:00
|
|
|
expose :project_id, :push_events
|
2016-08-02 10:06:31 +00:00
|
|
|
expose :issues_events, :merge_requests_events, :tag_push_events
|
2016-08-23 18:54:44 +00:00
|
|
|
expose :note_events, :build_events, :pipeline_events, :wiki_page_events
|
2015-12-07 12:23:23 +00:00
|
|
|
expose :enable_ssl_verification
|
2013-12-04 11:19:53 +00:00
|
|
|
end
|
|
|
|
|
2016-02-19 12:00:36 +00:00
|
|
|
class BasicProjectDetails < Grape::Entity
|
2013-06-27 21:49:26 +00:00
|
|
|
expose :id
|
2016-07-08 11:06:39 +00:00
|
|
|
expose :http_url_to_repo, :web_url
|
2013-06-27 21:49:26 +00:00
|
|
|
expose :name, :name_with_namespace
|
|
|
|
expose :path, :path_with_namespace
|
|
|
|
end
|
|
|
|
|
2016-07-08 07:34:36 +00:00
|
|
|
class SharedGroup < Grape::Entity
|
|
|
|
expose :group_id
|
|
|
|
expose :group_name do |group_link, options|
|
|
|
|
group_link.group.name
|
|
|
|
end
|
|
|
|
expose :group_access, as: :group_access_level
|
|
|
|
end
|
|
|
|
|
2012-06-27 12:51:39 +00:00
|
|
|
class Project < Grape::Entity
|
2015-02-05 01:42:34 +00:00
|
|
|
expose :id, :description, :default_branch, :tag_list
|
2013-11-06 15:13:21 +00:00
|
|
|
expose :public?, as: :public
|
2014-04-18 15:55:06 +00:00
|
|
|
expose :archived?, as: :archived
|
2013-11-06 15:13:21 +00:00
|
|
|
expose :visibility_level, :ssh_url_to_repo, :http_url_to_repo, :web_url
|
2014-03-17 12:33:41 +00:00
|
|
|
expose :owner, using: Entities::UserBasic, unless: ->(project, options) { project.group }
|
2013-06-03 16:49:04 +00:00
|
|
|
expose :name, :name_with_namespace
|
2013-01-31 07:11:35 +00:00
|
|
|
expose :path, :path_with_namespace
|
2016-05-09 17:29:57 +00:00
|
|
|
expose :issues_enabled, :merge_requests_enabled, :wiki_enabled, :builds_enabled, :snippets_enabled, :container_registry_enabled
|
2016-04-18 12:23:17 +00:00
|
|
|
expose :created_at, :last_activity_at
|
2016-08-24 22:36:58 +00:00
|
|
|
expose :shared_runners_enabled, :enable_lfs
|
2015-04-10 16:35:05 +00:00
|
|
|
expose :creator_id
|
2013-01-02 20:31:20 +00:00
|
|
|
expose :namespace
|
2016-02-19 12:00:36 +00:00
|
|
|
expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? }
|
2015-02-28 17:07:53 +00:00
|
|
|
expose :avatar_url
|
2015-07-28 13:49:44 +00:00
|
|
|
expose :star_count, :forks_count
|
2015-12-16 19:40:16 +00:00
|
|
|
expose :open_issues_count, if: lambda { |project, options| project.issues_enabled? && project.default_issues_tracker? }
|
2016-01-11 14:27:20 +00:00
|
|
|
expose :runners_token, if: lambda { |_project, options| options[:user_can_admin_project] }
|
2016-02-04 11:57:46 +00:00
|
|
|
expose :public_builds
|
2016-07-08 07:34:36 +00:00
|
|
|
expose :shared_with_groups do |project, options|
|
|
|
|
SharedGroup.represent(project.project_group_links.all, options)
|
|
|
|
end
|
2016-08-22 03:47:58 +00:00
|
|
|
expose :only_allow_merge_if_build_succeeds
|
2012-06-27 12:51:39 +00:00
|
|
|
end
|
|
|
|
|
2016-06-23 15:14:31 +00:00
|
|
|
class Member < UserBasic
|
2014-09-15 08:55:36 +00:00
|
|
|
expose :access_level do |user, options|
|
Improve the performance of the GET /:sources/:id/{access_requests,members} API endpoints
The performance was greatly improved by removing two N+1 queries issues
for each endpoint.
For comparison:
1. `GET /projects/:id/members`
With two N+1 queries issues (one was already fxed in the following
snippet):
```
ProjectMember Load (0.2ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND "members"."requested_at" IS
NULL ORDER BY "members"."id" DESC [["source_type", "Project"],
["source_id", 1], ["source_type", "Project"]]
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" IN
(5, 22, 16, 13) ORDER BY "users"."id" DESC
ActiveRecord::SchemaMigration Load (0.2ms) SELECT
"schema_migrations".* FROM "schema_migrations"
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND "members"."requested_at" IS
NULL AND "members"."user_id" = $4 ORDER BY "members"."id" DESC LIMIT 1
[["source_type", "Project"], ["source_id", 1], ["source_type",
"Project"], ["user_id", 5]]
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND "members"."requested_at" IS
NULL AND "members"."user_id" = $4 ORDER BY "members"."id" DESC LIMIT 1
[["source_type", "Project"], ["source_id", 1], ["source_type",
"Project"], ["user_id", 22]]
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND "members"."requested_at" IS
NULL AND "members"."user_id" = $4 ORDER BY "members"."id" DESC LIMIT 1
[["source_type", "Project"], ["source_id", 1], ["source_type",
"Project"], ["user_id", 16]]
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND "members"."requested_at" IS
NULL AND "members"."user_id" = $4 ORDER BY "members"."id" DESC LIMIT 1
[["source_type", "Project"], ["source_id", 1], ["source_type",
"Project"], ["user_id", 13]]
```
Without the N+1 queries issues:
```
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND "members"."requested_at" IS
NULL ORDER BY "members"."id" DESC LIMIT 20 OFFSET 0 [["source_type",
"Project"], ["source_id", 1], ["source_type", "Project"]]
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" IN
(5, 22, 16, 13) ORDER BY "users"."id" DESC
```
2. `GET /projects/:id/access_requests`
With two N+1 queries issues:
```
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND ("members"."requested_at" IS
NOT NULL) ORDER BY "members"."id" DESC [["source_type", "Project"],
["source_id", 8], ["source_type", "Project"]]
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" =
$1 ORDER BY "users"."id" DESC LIMIT 1 [["id", 24]]
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" =
$1 ORDER BY "users"."id" DESC LIMIT 1 [["id", 23]]
ActiveRecord::SchemaMigration Load (0.2ms) SELECT
"schema_migrations".* FROM "schema_migrations"
ProjectMember Load (0.1ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND ("members"."requested_at" IS
NOT NULL) AND "members"."user_id" = $4 ORDER BY "members"."id" DESC
LIMIT 1 [["source_type", "Project"], ["source_id", 8], ["source_type",
"Project"], ["user_id", 24]]
ProjectMember Load (0.2ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND ("members"."requested_at" IS
NOT NULL) AND "members"."user_id" = $4 ORDER BY "members"."id" DESC
LIMIT 1 [["source_type", "Project"], ["source_id", 8], ["source_type",
"Project"], ["user_id", 23]]
```
Without the N+1 queries issues:
```
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND ("members"."requested_at" IS
NOT NULL) ORDER BY "members"."id" DESC LIMIT 20 OFFSET 0
[["source_type", "Project"], ["source_id", 8], ["source_type",
"Project"]]
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" IN
(24, 23) ORDER BY "users"."id" DESC
```
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-08-09 10:20:09 +00:00
|
|
|
member = options[:member] || options[:members].find { |m| m.user_id == user.id }
|
2016-06-23 15:14:31 +00:00
|
|
|
member.access_level
|
|
|
|
end
|
2016-08-18 16:01:50 +00:00
|
|
|
expose :expires_at do |user, options|
|
|
|
|
member = options[:member] || options[:members].find { |m| m.user_id == user.id }
|
|
|
|
member.expires_at
|
|
|
|
end
|
2016-06-23 15:14:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
class AccessRequester < UserBasic
|
|
|
|
expose :requested_at do |user, options|
|
Improve the performance of the GET /:sources/:id/{access_requests,members} API endpoints
The performance was greatly improved by removing two N+1 queries issues
for each endpoint.
For comparison:
1. `GET /projects/:id/members`
With two N+1 queries issues (one was already fxed in the following
snippet):
```
ProjectMember Load (0.2ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND "members"."requested_at" IS
NULL ORDER BY "members"."id" DESC [["source_type", "Project"],
["source_id", 1], ["source_type", "Project"]]
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" IN
(5, 22, 16, 13) ORDER BY "users"."id" DESC
ActiveRecord::SchemaMigration Load (0.2ms) SELECT
"schema_migrations".* FROM "schema_migrations"
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND "members"."requested_at" IS
NULL AND "members"."user_id" = $4 ORDER BY "members"."id" DESC LIMIT 1
[["source_type", "Project"], ["source_id", 1], ["source_type",
"Project"], ["user_id", 5]]
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND "members"."requested_at" IS
NULL AND "members"."user_id" = $4 ORDER BY "members"."id" DESC LIMIT 1
[["source_type", "Project"], ["source_id", 1], ["source_type",
"Project"], ["user_id", 22]]
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND "members"."requested_at" IS
NULL AND "members"."user_id" = $4 ORDER BY "members"."id" DESC LIMIT 1
[["source_type", "Project"], ["source_id", 1], ["source_type",
"Project"], ["user_id", 16]]
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND "members"."requested_at" IS
NULL AND "members"."user_id" = $4 ORDER BY "members"."id" DESC LIMIT 1
[["source_type", "Project"], ["source_id", 1], ["source_type",
"Project"], ["user_id", 13]]
```
Without the N+1 queries issues:
```
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND "members"."requested_at" IS
NULL ORDER BY "members"."id" DESC LIMIT 20 OFFSET 0 [["source_type",
"Project"], ["source_id", 1], ["source_type", "Project"]]
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" IN
(5, 22, 16, 13) ORDER BY "users"."id" DESC
```
2. `GET /projects/:id/access_requests`
With two N+1 queries issues:
```
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND ("members"."requested_at" IS
NOT NULL) ORDER BY "members"."id" DESC [["source_type", "Project"],
["source_id", 8], ["source_type", "Project"]]
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" =
$1 ORDER BY "users"."id" DESC LIMIT 1 [["id", 24]]
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" =
$1 ORDER BY "users"."id" DESC LIMIT 1 [["id", 23]]
ActiveRecord::SchemaMigration Load (0.2ms) SELECT
"schema_migrations".* FROM "schema_migrations"
ProjectMember Load (0.1ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND ("members"."requested_at" IS
NOT NULL) AND "members"."user_id" = $4 ORDER BY "members"."id" DESC
LIMIT 1 [["source_type", "Project"], ["source_id", 8], ["source_type",
"Project"], ["user_id", 24]]
ProjectMember Load (0.2ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND ("members"."requested_at" IS
NOT NULL) AND "members"."user_id" = $4 ORDER BY "members"."id" DESC
LIMIT 1 [["source_type", "Project"], ["source_id", 8], ["source_type",
"Project"], ["user_id", 23]]
```
Without the N+1 queries issues:
```
ProjectMember Load (0.3ms) SELECT "members".* FROM "members" WHERE
"members"."source_type" = $1 AND "members"."type" IN ('ProjectMember')
AND "members"."source_id" = $2 AND "members"."source_type" = $3 AND
"members"."type" IN ('ProjectMember') AND ("members"."requested_at" IS
NOT NULL) ORDER BY "members"."id" DESC LIMIT 20 OFFSET 0
[["source_type", "Project"], ["source_id", 8], ["source_type",
"Project"]]
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" IN
(24, 23) ORDER BY "users"."id" DESC
```
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-08-09 10:20:09 +00:00
|
|
|
access_requester = options[:access_requester] || options[:access_requesters].find { |m| m.user_id == user.id }
|
2016-06-23 15:14:31 +00:00
|
|
|
access_requester.requested_at
|
2012-09-21 10:23:17 +00:00
|
|
|
end
|
2012-09-06 20:49:29 +00:00
|
|
|
end
|
|
|
|
|
2013-01-08 21:05:00 +00:00
|
|
|
class Group < Grape::Entity
|
2016-03-18 12:28:16 +00:00
|
|
|
expose :id, :name, :path, :description, :visibility_level
|
2015-07-30 09:56:15 +00:00
|
|
|
expose :avatar_url
|
2016-06-02 16:05:06 +00:00
|
|
|
expose :web_url
|
2013-01-08 21:05:00 +00:00
|
|
|
end
|
2013-02-18 09:10:58 +00:00
|
|
|
|
2013-02-03 18:38:33 +00:00
|
|
|
class GroupDetail < Group
|
2013-01-08 21:05:00 +00:00
|
|
|
expose :projects, using: Entities::Project
|
2016-07-08 08:59:52 +00:00
|
|
|
expose :shared_projects, using: Entities::Project
|
2013-01-08 21:05:00 +00:00
|
|
|
end
|
|
|
|
|
2016-07-19 11:30:23 +00:00
|
|
|
class RepoBranch < Grape::Entity
|
2014-02-04 12:46:15 +00:00
|
|
|
expose :name
|
|
|
|
|
2016-07-19 11:30:23 +00:00
|
|
|
expose :commit do |repo_branch, options|
|
|
|
|
options[:project].repository.commit(repo_branch.target)
|
2014-02-04 12:46:15 +00:00
|
|
|
end
|
|
|
|
|
2016-07-19 11:30:23 +00:00
|
|
|
expose :protected do |repo_branch, options|
|
|
|
|
options[:project].protected_branch? repo_branch.name
|
2016-07-12 14:31:55 +00:00
|
|
|
end
|
|
|
|
|
2016-07-19 11:30:23 +00:00
|
|
|
expose :developers_can_push do |repo_branch, options|
|
2016-07-25 14:44:53 +00:00
|
|
|
project = options[:project]
|
2016-08-16 06:30:56 +00:00
|
|
|
access_levels = project.protected_branches.matching(repo_branch.name).map(&:push_access_levels).flatten
|
|
|
|
access_levels.any? { |access_level| access_level.access_level == Gitlab::Access::DEVELOPER }
|
2013-01-28 17:22:44 +00:00
|
|
|
end
|
2016-07-19 08:36:18 +00:00
|
|
|
|
2016-07-19 11:30:23 +00:00
|
|
|
expose :developers_can_merge do |repo_branch, options|
|
2016-07-25 14:44:53 +00:00
|
|
|
project = options[:project]
|
2016-08-16 06:30:56 +00:00
|
|
|
access_levels = project.protected_branches.matching(repo_branch.name).map(&:merge_access_levels).flatten
|
|
|
|
access_levels.any? { |access_level| access_level.access_level == Gitlab::Access::DEVELOPER }
|
2016-07-19 08:36:18 +00:00
|
|
|
end
|
2012-06-27 12:51:39 +00:00
|
|
|
end
|
2012-06-29 13:34:08 +00:00
|
|
|
|
2014-02-04 12:46:15 +00:00
|
|
|
class RepoTreeObject < Grape::Entity
|
|
|
|
expose :id, :name, :type
|
|
|
|
|
|
|
|
expose :mode do |obj, options|
|
|
|
|
filemode = obj.mode.to_s(8)
|
|
|
|
filemode = "0" + filemode if filemode.length < 6
|
|
|
|
filemode
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-09-21 11:34:07 +00:00
|
|
|
class RepoCommit < Grape::Entity
|
|
|
|
expose :id, :short_id, :title, :author_name, :author_email, :created_at
|
2014-07-01 19:05:29 +00:00
|
|
|
expose :safe_message, as: :message
|
2012-09-21 11:34:07 +00:00
|
|
|
end
|
|
|
|
|
2016-07-27 09:02:49 +00:00
|
|
|
class RepoCommitStats < Grape::Entity
|
|
|
|
expose :additions, :deletions, :total
|
|
|
|
end
|
|
|
|
|
2013-12-11 13:41:07 +00:00
|
|
|
class RepoCommitDetail < RepoCommit
|
|
|
|
expose :parent_ids, :committed_date, :authored_date
|
2016-07-27 09:02:49 +00:00
|
|
|
expose :stats, using: Entities::RepoCommitStats
|
2015-10-06 10:01:16 +00:00
|
|
|
expose :status
|
2013-12-11 13:41:07 +00:00
|
|
|
end
|
|
|
|
|
2012-06-29 13:34:08 +00:00
|
|
|
class ProjectSnippet < Grape::Entity
|
|
|
|
expose :id, :title, :file_name
|
2012-08-10 22:07:50 +00:00
|
|
|
expose :author, using: Entities::UserBasic
|
2016-03-05 22:17:49 +00:00
|
|
|
expose :updated_at, :created_at
|
2016-03-09 18:25:39 +00:00
|
|
|
|
|
|
|
# TODO (rspeicher): Deprecated; remove in 9.0
|
|
|
|
expose(:expires_at) { |snippet| nil }
|
2016-08-02 17:37:04 +00:00
|
|
|
|
|
|
|
expose :web_url do |snippet, options|
|
|
|
|
Gitlab::UrlBuilder.build(snippet)
|
|
|
|
end
|
2012-06-29 13:34:08 +00:00
|
|
|
end
|
2012-07-24 12:19:51 +00:00
|
|
|
|
2013-10-14 13:39:54 +00:00
|
|
|
class ProjectEntity < Grape::Entity
|
|
|
|
expose :id, :iid
|
2015-03-03 02:45:28 +00:00
|
|
|
expose(:project_id) { |entity| entity.project.id }
|
2014-04-09 15:24:12 +00:00
|
|
|
expose :title, :description
|
|
|
|
expose :state, :created_at, :updated_at
|
2013-10-14 13:39:54 +00:00
|
|
|
end
|
|
|
|
|
2015-02-02 21:08:10 +00:00
|
|
|
class RepoDiff < Grape::Entity
|
|
|
|
expose :old_path, :new_path, :a_mode, :b_mode, :diff
|
|
|
|
expose :new_file, :renamed_file, :deleted_file
|
|
|
|
end
|
|
|
|
|
2013-10-14 13:39:54 +00:00
|
|
|
class Milestone < ProjectEntity
|
2014-04-09 15:24:12 +00:00
|
|
|
expose :due_date
|
2012-07-24 12:19:51 +00:00
|
|
|
end
|
|
|
|
|
2013-10-14 13:39:54 +00:00
|
|
|
class Issue < ProjectEntity
|
2014-07-30 14:17:29 +00:00
|
|
|
expose :label_names, as: :labels
|
2012-08-10 22:07:50 +00:00
|
|
|
expose :milestone, using: Entities::Milestone
|
|
|
|
expose :assignee, :author, using: Entities::UserBasic
|
2016-04-08 06:41:10 +00:00
|
|
|
|
|
|
|
expose :subscribed do |issue, options|
|
|
|
|
issue.subscribed?(options[:current_user])
|
|
|
|
end
|
2016-06-01 09:23:09 +00:00
|
|
|
expose :user_notes_count
|
2016-05-11 20:43:58 +00:00
|
|
|
expose :upvotes, :downvotes
|
2016-07-12 15:59:21 +00:00
|
|
|
expose :due_date
|
2016-08-02 17:37:04 +00:00
|
|
|
|
|
|
|
expose :web_url do |issue, options|
|
|
|
|
Gitlab::UrlBuilder.build(issue)
|
|
|
|
end
|
2012-07-24 12:19:51 +00:00
|
|
|
end
|
2012-09-16 14:52:06 +00:00
|
|
|
|
2016-06-11 14:16:32 +00:00
|
|
|
class ExternalIssue < Grape::Entity
|
|
|
|
expose :title
|
|
|
|
expose :id
|
|
|
|
end
|
|
|
|
|
2013-10-14 13:39:54 +00:00
|
|
|
class MergeRequest < ProjectEntity
|
2015-11-11 13:12:51 +00:00
|
|
|
expose :target_branch, :source_branch
|
2016-04-16 19:09:08 +00:00
|
|
|
expose :upvotes, :downvotes
|
2013-10-14 13:39:54 +00:00
|
|
|
expose :author, :assignee, using: Entities::UserBasic
|
|
|
|
expose :source_project_id, :target_project_id
|
2014-07-30 14:17:29 +00:00
|
|
|
expose :label_names, as: :labels
|
2015-07-09 17:21:37 +00:00
|
|
|
expose :work_in_progress?, as: :work_in_progress
|
2014-04-16 02:14:05 +00:00
|
|
|
expose :milestone, using: Entities::Milestone
|
2015-11-24 13:59:02 +00:00
|
|
|
expose :merge_when_build_succeeds
|
2016-01-17 18:59:43 +00:00
|
|
|
expose :merge_status
|
2016-04-08 06:41:10 +00:00
|
|
|
expose :subscribed do |merge_request, options|
|
|
|
|
merge_request.subscribed?(options[:current_user])
|
|
|
|
end
|
2016-06-01 09:23:09 +00:00
|
|
|
expose :user_notes_count
|
2016-07-11 15:25:01 +00:00
|
|
|
expose :should_remove_source_branch?, as: :should_remove_source_branch
|
|
|
|
expose :force_remove_source_branch?, as: :force_remove_source_branch
|
2016-08-02 17:37:04 +00:00
|
|
|
|
|
|
|
expose :web_url do |merge_request, options|
|
|
|
|
Gitlab::UrlBuilder.build(merge_request)
|
|
|
|
end
|
2012-09-16 14:52:06 +00:00
|
|
|
end
|
2012-10-21 11:00:27 +00:00
|
|
|
|
2015-02-02 21:08:10 +00:00
|
|
|
class MergeRequestChanges < MergeRequest
|
|
|
|
expose :diffs, as: :changes, using: Entities::RepoDiff do |compare, _|
|
2016-07-27 17:00:34 +00:00
|
|
|
compare.raw_diffs(all_diffs: true).to_a
|
2015-02-02 21:08:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-03 08:32:29 +00:00
|
|
|
class MergeRequestDiff < Grape::Entity
|
|
|
|
expose :id, :head_commit_sha, :base_commit_sha, :start_commit_sha,
|
|
|
|
:created_at, :merge_request_id, :state, :real_size
|
2016-08-12 11:44:49 +00:00
|
|
|
end
|
2016-08-03 08:32:29 +00:00
|
|
|
|
2016-08-12 11:44:49 +00:00
|
|
|
class MergeRequestDiffFull < MergeRequestDiff
|
2016-08-03 08:32:29 +00:00
|
|
|
expose :commits, using: Entities::RepoCommit
|
|
|
|
|
|
|
|
expose :diffs, using: Entities::RepoDiff do |compare, _|
|
2016-08-22 12:30:23 +00:00
|
|
|
compare.raw_diffs(all_diffs: true).to_a
|
2016-08-03 08:32:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-10-14 13:39:54 +00:00
|
|
|
class SSHKey < Grape::Entity
|
|
|
|
expose :id, :title, :key, :created_at
|
2012-10-21 11:00:27 +00:00
|
|
|
end
|
2012-10-21 16:48:56 +00:00
|
|
|
|
2015-08-29 09:52:21 +00:00
|
|
|
class SSHKeyWithUser < SSHKey
|
|
|
|
expose :user, using: Entities::UserFull
|
|
|
|
end
|
|
|
|
|
2012-10-21 16:48:56 +00:00
|
|
|
class Note < Grape::Entity
|
2012-11-27 19:43:39 +00:00
|
|
|
expose :id
|
|
|
|
expose :note, as: :body
|
2013-03-19 11:28:29 +00:00
|
|
|
expose :attachment_identifier, as: :attachment
|
2012-10-21 16:48:56 +00:00
|
|
|
expose :author, using: Entities::UserBasic
|
2016-04-12 10:32:34 +00:00
|
|
|
expose :created_at, :updated_at
|
2015-08-12 19:39:58 +00:00
|
|
|
expose :system?, as: :system
|
2015-12-04 11:21:06 +00:00
|
|
|
expose :noteable_id, :noteable_type
|
2015-11-21 20:36:31 +00:00
|
|
|
# upvote? and downvote? are deprecated, always return false
|
2016-04-16 19:09:08 +00:00
|
|
|
expose(:upvote?) { |note| false }
|
|
|
|
expose(:downvote?) { |note| false }
|
2012-10-21 16:48:56 +00:00
|
|
|
end
|
2012-11-29 20:10:07 +00:00
|
|
|
|
2016-06-08 07:33:41 +00:00
|
|
|
class AwardEmoji < Grape::Entity
|
|
|
|
expose :id
|
|
|
|
expose :name
|
|
|
|
expose :user, using: Entities::UserBasic
|
|
|
|
expose :created_at, :updated_at
|
|
|
|
expose :awardable_id, :awardable_type
|
|
|
|
end
|
|
|
|
|
2012-11-29 20:10:07 +00:00
|
|
|
class MRNote < Grape::Entity
|
|
|
|
expose :note
|
|
|
|
expose :author, using: Entities::UserBasic
|
|
|
|
end
|
2013-06-06 16:19:17 +00:00
|
|
|
|
2014-06-27 14:48:30 +00:00
|
|
|
class CommitNote < Grape::Entity
|
|
|
|
expose :note
|
2016-06-20 17:15:44 +00:00
|
|
|
expose(:path) { |note| note.diff_file.try(:file_path) if note.diff_note? }
|
|
|
|
expose(:line) { |note| note.diff_line.try(:new_line) if note.diff_note? }
|
|
|
|
expose(:line_type) { |note| note.diff_line.try(:type) if note.diff_note? }
|
2014-06-27 14:48:30 +00:00
|
|
|
expose :author, using: Entities::UserBasic
|
2015-08-19 06:29:18 +00:00
|
|
|
expose :created_at
|
2014-06-27 14:48:30 +00:00
|
|
|
end
|
|
|
|
|
2015-10-06 10:01:16 +00:00
|
|
|
class CommitStatus < Grape::Entity
|
|
|
|
expose :id, :sha, :ref, :status, :name, :target_url, :description,
|
2015-10-26 06:26:03 +00:00
|
|
|
:created_at, :started_at, :finished_at, :allow_failure
|
2015-10-12 10:15:48 +00:00
|
|
|
expose :author, using: Entities::UserBasic
|
2015-10-06 10:01:16 +00:00
|
|
|
end
|
|
|
|
|
2013-06-06 16:19:17 +00:00
|
|
|
class Event < Grape::Entity
|
|
|
|
expose :title, :project_id, :action_name
|
|
|
|
expose :target_id, :target_type, :author_id
|
|
|
|
expose :data, :target_title
|
2014-04-09 15:24:12 +00:00
|
|
|
expose :created_at
|
2015-12-04 11:21:06 +00:00
|
|
|
expose :note, using: Entities::Note, if: ->(event, options) { event.note? }
|
|
|
|
expose :author, using: Entities::UserBasic, if: ->(event, options) { event.author }
|
2014-10-31 10:08:45 +00:00
|
|
|
|
|
|
|
expose :author_username do |event, options|
|
|
|
|
if event.author
|
|
|
|
event.author.username
|
|
|
|
end
|
|
|
|
end
|
2013-06-06 16:19:17 +00:00
|
|
|
end
|
2013-11-15 13:24:10 +00:00
|
|
|
|
2016-03-13 10:46:16 +00:00
|
|
|
class ProjectGroupLink < Grape::Entity
|
|
|
|
expose :id, :project_id, :group_id, :group_access
|
|
|
|
end
|
|
|
|
|
2016-03-11 19:04:42 +00:00
|
|
|
class Todo < Grape::Entity
|
|
|
|
expose :id
|
|
|
|
expose :project, using: Entities::BasicProjectDetails
|
|
|
|
expose :author, using: Entities::UserBasic
|
2016-06-15 11:20:30 +00:00
|
|
|
expose :action_name
|
2016-03-11 19:04:42 +00:00
|
|
|
expose :target_type
|
2016-06-22 17:15:09 +00:00
|
|
|
|
|
|
|
expose :target do |todo, options|
|
|
|
|
Entities.const_get(todo.target_type).represent(todo.target, options)
|
2016-03-11 19:04:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expose :target_url do |todo, options|
|
|
|
|
target_type = todo.target_type.underscore
|
|
|
|
target_url = "namespace_project_#{target_type}_url"
|
2016-06-22 17:15:09 +00:00
|
|
|
target_anchor = "note_#{todo.note_id}" if todo.note_id?
|
2016-03-11 19:04:42 +00:00
|
|
|
|
|
|
|
Gitlab::Application.routes.url_helpers.public_send(target_url,
|
|
|
|
todo.project.namespace, todo.project, todo.target, anchor: target_anchor)
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :body
|
|
|
|
expose :state
|
|
|
|
expose :created_at
|
|
|
|
end
|
|
|
|
|
2013-11-15 13:24:10 +00:00
|
|
|
class Namespace < Grape::Entity
|
|
|
|
expose :id, :path, :kind
|
|
|
|
end
|
2014-03-17 12:33:41 +00:00
|
|
|
|
2016-06-23 15:14:31 +00:00
|
|
|
class MemberAccess < Grape::Entity
|
2014-09-15 08:55:36 +00:00
|
|
|
expose :access_level
|
2016-03-29 20:19:00 +00:00
|
|
|
expose :notification_level do |member, options|
|
|
|
|
if member.notification_setting
|
|
|
|
NotificationSetting.levels[member.notification_setting.level]
|
|
|
|
end
|
|
|
|
end
|
2014-03-17 12:33:41 +00:00
|
|
|
end
|
|
|
|
|
2016-06-23 15:14:31 +00:00
|
|
|
class ProjectAccess < MemberAccess
|
2016-03-29 20:19:00 +00:00
|
|
|
end
|
|
|
|
|
2016-06-23 15:14:31 +00:00
|
|
|
class GroupAccess < MemberAccess
|
2014-03-17 12:33:41 +00:00
|
|
|
end
|
|
|
|
|
2015-10-12 13:24:00 +00:00
|
|
|
class ProjectService < Grape::Entity
|
|
|
|
expose :id, :title, :created_at, :updated_at, :active
|
2016-08-02 10:06:31 +00:00
|
|
|
expose :push_events, :issues_events, :merge_requests_events
|
|
|
|
expose :tag_push_events, :note_events, :build_events, :pipeline_events
|
2015-10-12 13:24:00 +00:00
|
|
|
# Expose serialized properties
|
|
|
|
expose :properties do |service, options|
|
|
|
|
field_names = service.fields.
|
|
|
|
select { |field| options[:include_passwords] || field[:type] != 'password' }.
|
|
|
|
map { |field| field[:name] }
|
|
|
|
service.properties.slice(*field_names)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-03-17 12:33:41 +00:00
|
|
|
class ProjectWithAccess < Project
|
|
|
|
expose :permissions do
|
|
|
|
expose :project_access, using: Entities::ProjectAccess do |project, options|
|
2014-09-14 16:32:51 +00:00
|
|
|
project.project_members.find_by(user_id: options[:user].id)
|
2014-03-17 12:33:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expose :group_access, using: Entities::GroupAccess do |project, options|
|
2014-03-17 13:14:27 +00:00
|
|
|
if project.group
|
2014-09-14 16:32:51 +00:00
|
|
|
project.group.group_members.find_by(user_id: options[:user].id)
|
2014-03-17 13:14:27 +00:00
|
|
|
end
|
2014-03-17 12:33:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-03-21 09:18:19 +00:00
|
|
|
|
|
|
|
class Label < Grape::Entity
|
2016-03-24 18:38:37 +00:00
|
|
|
expose :name, :color, :description
|
2016-04-06 12:32:36 +00:00
|
|
|
expose :open_issues_count, :closed_issues_count, :open_merge_requests_count
|
2016-05-12 20:48:09 +00:00
|
|
|
|
|
|
|
expose :subscribed do |label, options|
|
|
|
|
label.subscribed?(options[:current_user])
|
|
|
|
end
|
2014-03-21 09:18:19 +00:00
|
|
|
end
|
2014-05-26 13:08:22 +00:00
|
|
|
|
|
|
|
class Compare < Grape::Entity
|
|
|
|
expose :commit, using: Entities::RepoCommit do |compare, options|
|
2015-04-21 13:09:15 +00:00
|
|
|
Commit.decorate(compare.commits, nil).last
|
2014-05-26 13:08:22 +00:00
|
|
|
end
|
2014-07-29 11:29:59 +00:00
|
|
|
|
2014-05-26 13:08:22 +00:00
|
|
|
expose :commits, using: Entities::RepoCommit do |compare, options|
|
2015-04-21 13:09:15 +00:00
|
|
|
Commit.decorate(compare.commits, nil)
|
2014-05-26 13:08:22 +00:00
|
|
|
end
|
2014-07-29 11:29:59 +00:00
|
|
|
|
2014-05-26 13:08:22 +00:00
|
|
|
expose :diffs, using: Entities::RepoDiff do |compare, options|
|
2016-03-03 17:38:44 +00:00
|
|
|
compare.diffs(all_diffs: true).to_a
|
2014-05-26 13:08:22 +00:00
|
|
|
end
|
2014-05-27 08:16:50 +00:00
|
|
|
|
|
|
|
expose :compare_timeout do |compare, options|
|
2016-03-03 17:38:44 +00:00
|
|
|
compare.diffs.overflow?
|
2014-05-27 08:16:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expose :same, as: :compare_same_ref
|
2014-05-26 13:08:22 +00:00
|
|
|
end
|
2014-07-02 12:09:06 +00:00
|
|
|
|
|
|
|
class Contributor < Grape::Entity
|
|
|
|
expose :name, :email, :commits, :additions, :deletions
|
|
|
|
end
|
2015-02-07 15:41:30 +00:00
|
|
|
|
|
|
|
class BroadcastMessage < Grape::Entity
|
|
|
|
expose :message, :starts_at, :ends_at, :color, :font
|
|
|
|
end
|
2015-07-03 14:50:21 +00:00
|
|
|
|
|
|
|
class ApplicationSetting < Grape::Entity
|
|
|
|
expose :id
|
|
|
|
expose :default_projects_limit
|
|
|
|
expose :signup_enabled
|
|
|
|
expose :signin_enabled
|
|
|
|
expose :gravatar_enabled
|
|
|
|
expose :sign_in_text
|
2016-05-09 15:12:53 +00:00
|
|
|
expose :after_sign_up_text
|
2015-07-03 14:50:21 +00:00
|
|
|
expose :created_at
|
|
|
|
expose :updated_at
|
|
|
|
expose :home_page_url
|
|
|
|
expose :default_branch_protection
|
|
|
|
expose :restricted_visibility_levels
|
|
|
|
expose :max_attachment_size
|
|
|
|
expose :session_expire_delay
|
|
|
|
expose :default_project_visibility
|
|
|
|
expose :default_snippet_visibility
|
2016-03-09 00:01:33 +00:00
|
|
|
expose :default_group_visibility
|
2016-07-15 23:30:38 +00:00
|
|
|
expose :domain_whitelist
|
2016-07-14 18:19:40 +00:00
|
|
|
expose :domain_blacklist_enabled
|
|
|
|
expose :domain_blacklist
|
2015-07-03 14:50:21 +00:00
|
|
|
expose :user_oauth_applications
|
|
|
|
expose :after_sign_out_path
|
2016-05-30 15:12:50 +00:00
|
|
|
expose :container_registry_token_expire_delay
|
2016-06-30 03:35:00 +00:00
|
|
|
expose :repository_storage
|
2015-07-03 14:50:21 +00:00
|
|
|
end
|
2015-11-12 15:26:39 +00:00
|
|
|
|
|
|
|
class Release < Grape::Entity
|
2015-11-21 16:29:26 +00:00
|
|
|
expose :tag, as: :tag_name
|
|
|
|
expose :description
|
2015-11-12 15:26:39 +00:00
|
|
|
end
|
2015-11-12 22:52:02 +00:00
|
|
|
|
|
|
|
class RepoTag < Grape::Entity
|
2016-07-19 11:30:23 +00:00
|
|
|
expose :name, :message
|
2015-11-12 22:52:02 +00:00
|
|
|
|
2016-07-19 11:30:23 +00:00
|
|
|
expose :commit do |repo_tag, options|
|
|
|
|
options[:project].repository.commit(repo_tag.target)
|
2015-11-12 22:52:02 +00:00
|
|
|
end
|
|
|
|
|
2016-07-19 11:30:23 +00:00
|
|
|
expose :release, using: Entities::Release do |repo_tag, options|
|
|
|
|
options[:project].releases.find_by(tag: repo_tag.name)
|
2015-11-12 22:52:02 +00:00
|
|
|
end
|
|
|
|
end
|
2015-12-10 17:04:40 +00:00
|
|
|
|
|
|
|
class TriggerRequest < Grape::Entity
|
|
|
|
expose :id, :variables
|
|
|
|
end
|
2016-01-04 15:38:32 +00:00
|
|
|
|
2016-01-08 21:57:42 +00:00
|
|
|
class Runner < Grape::Entity
|
2015-12-28 12:09:51 +00:00
|
|
|
expose :id
|
|
|
|
expose :description
|
|
|
|
expose :active
|
|
|
|
expose :is_shared
|
|
|
|
expose :name
|
|
|
|
end
|
|
|
|
|
2016-01-26 16:03:38 +00:00
|
|
|
class RunnerDetails < Runner
|
|
|
|
expose :tag_list
|
2016-05-06 10:32:17 +00:00
|
|
|
expose :run_untagged
|
2016-06-02 11:06:01 +00:00
|
|
|
expose :locked
|
2016-01-26 16:03:38 +00:00
|
|
|
expose :version, :revision, :platform, :architecture
|
2016-02-17 20:23:14 +00:00
|
|
|
expose :contacted_at
|
2016-02-10 11:26:56 +00:00
|
|
|
expose :token, if: lambda { |runner, options| options[:current_user].is_admin? || !runner.is_shared? }
|
2016-02-19 12:00:36 +00:00
|
|
|
expose :projects, with: Entities::BasicProjectDetails do |runner, options|
|
2016-02-10 11:26:56 +00:00
|
|
|
if options[:current_user].is_admin?
|
2016-02-04 13:53:53 +00:00
|
|
|
runner.projects
|
|
|
|
else
|
2016-02-10 11:26:56 +00:00
|
|
|
options[:current_user].authorized_projects.where(id: runner.projects)
|
2016-02-04 13:53:53 +00:00
|
|
|
end
|
|
|
|
end
|
2016-01-26 16:03:38 +00:00
|
|
|
end
|
|
|
|
|
2016-02-08 21:32:36 +00:00
|
|
|
class BuildArtifactFile < Grape::Entity
|
|
|
|
expose :filename, :size
|
|
|
|
end
|
|
|
|
|
2015-12-24 18:05:57 +00:00
|
|
|
class Build < Grape::Entity
|
2016-01-11 10:15:04 +00:00
|
|
|
expose :id, :status, :stage, :name, :ref, :tag, :coverage
|
2016-01-08 21:57:42 +00:00
|
|
|
expose :created_at, :started_at, :finished_at
|
2016-01-12 17:32:18 +00:00
|
|
|
expose :user, with: User
|
2016-02-19 17:07:05 +00:00
|
|
|
expose :artifacts_file, using: BuildArtifactFile, if: -> (build, opts) { build.artifacts? }
|
2016-06-21 12:26:57 +00:00
|
|
|
expose :commit, with: RepoCommit
|
2016-01-08 21:57:42 +00:00
|
|
|
expose :runner, with: Runner
|
2015-12-24 18:05:57 +00:00
|
|
|
end
|
2016-01-14 12:30:18 +00:00
|
|
|
|
2016-01-04 15:38:32 +00:00
|
|
|
class Trigger < Grape::Entity
|
2016-01-13 11:16:27 +00:00
|
|
|
expose :token, :created_at, :updated_at, :deleted_at, :last_used
|
2016-01-04 15:38:32 +00:00
|
|
|
end
|
2016-01-14 12:09:54 +00:00
|
|
|
|
2015-12-31 14:19:13 +00:00
|
|
|
class Variable < Grape::Entity
|
2016-01-07 13:10:49 +00:00
|
|
|
expose :key, :value
|
2015-12-31 14:19:13 +00:00
|
|
|
end
|
2016-04-11 13:49:25 +00:00
|
|
|
|
2016-08-17 08:09:42 +00:00
|
|
|
class Pipeline < Grape::Entity
|
2016-08-17 13:23:58 +00:00
|
|
|
expose :id, :status, :ref, :sha, :before_sha, :tag, :yaml_errors
|
2016-08-17 08:09:42 +00:00
|
|
|
|
|
|
|
expose :user, with: Entities::UserBasic
|
|
|
|
expose :created_at, :updated_at, :started_at, :finished_at, :committed_at
|
|
|
|
expose :duration
|
|
|
|
end
|
|
|
|
|
2016-08-23 14:25:17 +00:00
|
|
|
class EnvironmentBasic < Grape::Entity
|
2016-07-26 07:37:02 +00:00
|
|
|
expose :id, :name, :external_url
|
|
|
|
end
|
|
|
|
|
2016-08-23 14:25:17 +00:00
|
|
|
class Environment < EnvironmentBasic
|
|
|
|
expose :project, using: Entities::Project
|
2016-08-16 06:45:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
class Deployment < Grape::Entity
|
|
|
|
expose :id, :iid, :ref, :sha, :created_at
|
2016-08-18 19:10:20 +00:00
|
|
|
expose :user, using: Entities::UserBasic
|
|
|
|
expose :environment, using: Entities::EnvironmentBasic
|
|
|
|
expose :deployable, using: Entities::Build
|
2016-07-26 07:37:02 +00:00
|
|
|
end
|
|
|
|
|
2016-04-19 09:08:48 +00:00
|
|
|
class RepoLicense < Grape::Entity
|
2016-04-13 13:56:37 +00:00
|
|
|
expose :key, :name, :nickname
|
|
|
|
expose :featured, as: :popular
|
2016-04-11 13:49:25 +00:00
|
|
|
expose :url, as: :html_url
|
|
|
|
expose(:source_url) { |license| license.meta['source'] }
|
|
|
|
expose(:description) { |license| license.meta['description'] }
|
2016-04-13 13:56:37 +00:00
|
|
|
expose(:conditions) { |license| license.meta['conditions'] }
|
|
|
|
expose(:permissions) { |license| license.meta['permissions'] }
|
|
|
|
expose(:limitations) { |license| license.meta['limitations'] }
|
2016-04-11 13:49:25 +00:00
|
|
|
expose :content
|
|
|
|
end
|
2016-04-29 14:25:03 +00:00
|
|
|
|
2016-05-27 09:00:56 +00:00
|
|
|
class TemplatesList < Grape::Entity
|
2016-04-29 14:25:03 +00:00
|
|
|
expose :name
|
|
|
|
end
|
|
|
|
|
2016-05-27 09:00:56 +00:00
|
|
|
class Template < Grape::Entity
|
2016-04-29 14:25:03 +00:00
|
|
|
expose :name, :content
|
|
|
|
end
|
2012-06-27 11:32:56 +00:00
|
|
|
end
|
|
|
|
end
|