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
|
2017-05-10 04:26:17 +00:00
|
|
|
expose :id, :state
|
|
|
|
expose :avatar_url do |user, options|
|
|
|
|
user.avatar_url(only_path: false)
|
|
|
|
end
|
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
|
2016-09-26 17:33:00 +00:00
|
|
|
expose :bio, :location, :skype, :linkedin, :twitter, :website_url, :organization
|
2013-03-11 12:35:00 +00:00
|
|
|
end
|
|
|
|
|
2017-04-12 11:19:45 +00:00
|
|
|
class UserActivity < Grape::Entity
|
|
|
|
expose :username
|
2017-03-27 13:43:10 +00:00
|
|
|
expose :last_activity_on
|
|
|
|
expose :last_activity_on, as: :last_activity_at # Back-compat
|
2017-04-12 11:19:45 +00:00
|
|
|
end
|
|
|
|
|
2014-11-27 11:34:39 +00:00
|
|
|
class Identity < Grape::Entity
|
|
|
|
expose :provider, :extern_uid
|
|
|
|
end
|
|
|
|
|
2016-11-21 12:59:37 +00:00
|
|
|
class UserPublic < User
|
2016-02-24 12:14:37 +00:00
|
|
|
expose :last_sign_in_at
|
|
|
|
expose :confirmed_at
|
2017-03-27 13:43:10 +00:00
|
|
|
expose :last_activity_on
|
2014-06-13 14:46:48 +00:00
|
|
|
expose :email
|
2017-02-13 17:50:13 +00:00
|
|
|
expose :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
|
|
|
|
|
2017-04-21 09:47:58 +00:00
|
|
|
class UserWithPrivateDetails < UserPublic
|
2012-09-20 15:36:43 +00:00
|
|
|
expose :private_token
|
2017-04-21 09:47:58 +00:00
|
|
|
expose :admin?, as: :is_admin
|
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
|
2017-05-05 16:00:32 +00:00
|
|
|
expose :id, :url, :created_at, :push_events, :tag_push_events, :repository_update_events
|
2016-10-19 14:08:30 +00:00
|
|
|
expose :enable_ssl_verification
|
2012-09-08 17:51:12 +00:00
|
|
|
end
|
|
|
|
|
2013-12-04 11:19:53 +00:00
|
|
|
class ProjectHook < Hook
|
2016-10-18 18:07:56 +00:00
|
|
|
expose :project_id, :issues_events, :merge_requests_events
|
2017-02-22 10:13:59 +00:00
|
|
|
expose :note_events, :pipeline_events, :wiki_page_events
|
2017-05-15 15:11:45 +00:00
|
|
|
expose :job_events
|
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
|
2014-04-18 15:55:06 +00:00
|
|
|
expose :archived?, as: :archived
|
2017-03-01 20:23:00 +00:00
|
|
|
expose :visibility, :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-08-01 22:31:21 +00:00
|
|
|
expose :container_registry_enabled
|
|
|
|
|
|
|
|
# Expose old field names with the new permissions methods to keep API compatible
|
2016-11-29 19:21:39 +00:00
|
|
|
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]) }
|
2017-02-22 10:13:59 +00:00
|
|
|
expose(:jobs_enabled) { |project, options| project.feature_available?(:builds, options[:current_user]) }
|
2016-11-29 19:21:39 +00:00
|
|
|
expose(:snippets_enabled) { |project, options| project.feature_available?(:snippets, options[:current_user]) }
|
2016-08-01 22:31:21 +00:00
|
|
|
|
2016-04-18 12:23:17 +00:00
|
|
|
expose :created_at, :last_activity_at
|
2016-09-06 16:48:00 +00:00
|
|
|
expose :shared_runners_enabled
|
|
|
|
expose :lfs_enabled?, as: :lfs_enabled
|
2015-04-10 16:35:05 +00:00
|
|
|
expose :creator_id
|
2016-11-29 19:25:41 +00:00
|
|
|
expose :namespace, using: 'API::Entities::Namespace'
|
2016-02-19 12:00:36 +00:00
|
|
|
expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? }
|
2017-05-10 04:26:17 +00:00
|
|
|
expose :avatar_url do |user, options|
|
|
|
|
user.avatar_url(only_path: false)
|
|
|
|
end
|
2015-07-28 13:49:44 +00:00
|
|
|
expose :star_count, :forks_count
|
2016-11-29 19:21:39 +00:00
|
|
|
expose :open_issues_count, if: lambda { |project, options| project.feature_available?(:issues, options[:current_user]) && project.default_issues_tracker? }
|
2016-01-11 14:27:20 +00:00
|
|
|
expose :runners_token, if: lambda { |_project, options| options[:user_can_admin_project] }
|
2017-02-23 08:16:20 +00:00
|
|
|
expose :public_builds, as: :public_jobs
|
2016-07-08 07:34:36 +00:00
|
|
|
expose :shared_with_groups do |project, options|
|
|
|
|
SharedGroup.represent(project.project_group_links.all, options)
|
|
|
|
end
|
2017-02-17 13:56:13 +00:00
|
|
|
expose :only_allow_merge_if_pipeline_succeeds
|
2016-09-14 22:04:27 +00:00
|
|
|
expose :request_access_enabled
|
2016-09-16 11:02:42 +00:00
|
|
|
expose :only_allow_merge_if_all_discussions_are_resolved
|
2016-11-22 16:58:10 +00:00
|
|
|
|
|
|
|
expose :statistics, using: 'API::Entities::ProjectStatistics', if: :statistics
|
|
|
|
end
|
|
|
|
|
|
|
|
class ProjectStatistics < Grape::Entity
|
|
|
|
expose :commit_count
|
|
|
|
expose :storage_size
|
|
|
|
expose :repository_size
|
|
|
|
expose :lfs_objects_size
|
2017-02-23 08:16:20 +00:00
|
|
|
expose :build_artifacts_size, as: :job_artifacts_size
|
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|
|
2016-09-15 16:34:57 +00:00
|
|
|
member = options[:member] || options[:source].members.find_by(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|
|
2016-09-15 16:34:57 +00:00
|
|
|
member = options[:member] || options[:source].members.find_by(user_id: user.id)
|
2016-08-18 16:01:50 +00:00
|
|
|
member.expires_at
|
|
|
|
end
|
2016-06-23 15:14:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
class AccessRequester < UserBasic
|
|
|
|
expose :requested_at do |user, options|
|
2016-09-15 16:34:57 +00:00
|
|
|
access_requester = options[:access_requester] || options[:source].requesters.find_by(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
|
2017-03-01 20:23:00 +00:00
|
|
|
expose :id, :name, :path, :description, :visibility
|
2016-09-06 16:48:00 +00:00
|
|
|
expose :lfs_enabled?, as: :lfs_enabled
|
2017-05-10 04:26:17 +00:00
|
|
|
expose :avatar_url do |user, options|
|
|
|
|
user.avatar_url(only_path: false)
|
|
|
|
end
|
2016-06-02 16:05:06 +00:00
|
|
|
expose :web_url
|
2016-09-14 22:04:27 +00:00
|
|
|
expose :request_access_enabled
|
2017-01-26 19:31:32 +00:00
|
|
|
expose :full_name, :full_path
|
2017-05-03 12:49:37 +00:00
|
|
|
|
|
|
|
if ::Group.supports_nested_groups?
|
|
|
|
expose :parent_id
|
|
|
|
end
|
2016-11-22 16:58:10 +00:00
|
|
|
|
|
|
|
expose :statistics, if: :statistics do
|
|
|
|
with_options format_with: -> (value) { value.to_i } do
|
|
|
|
expose :storage_size
|
|
|
|
expose :repository_size
|
|
|
|
expose :lfs_objects_size
|
2017-02-23 08:16:20 +00:00
|
|
|
expose :build_artifacts_size, as: :job_artifacts_size
|
2016-11-22 16:58:10 +00:00
|
|
|
end
|
|
|
|
end
|
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-10-27 13:26:58 +00:00
|
|
|
class RepoCommit < Grape::Entity
|
|
|
|
expose :id, :short_id, :title, :created_at
|
|
|
|
expose :parent_ids
|
|
|
|
expose :safe_message, as: :message
|
|
|
|
expose :author_name, :author_email, :authored_date
|
|
|
|
expose :committer_name, :committer_email, :committed_date
|
|
|
|
end
|
|
|
|
|
|
|
|
class RepoCommitStats < Grape::Entity
|
|
|
|
expose :additions, :deletions, :total
|
|
|
|
end
|
|
|
|
|
|
|
|
class RepoCommitDetail < RepoCommit
|
|
|
|
expose :stats, using: Entities::RepoCommitStats
|
|
|
|
expose :status
|
|
|
|
end
|
|
|
|
|
2016-07-19 11:30:23 +00:00
|
|
|
class RepoBranch < Grape::Entity
|
2014-02-04 12:46:15 +00:00
|
|
|
expose :name
|
|
|
|
|
2016-10-27 13:26:58 +00:00
|
|
|
expose :commit, using: Entities::RepoCommit do |repo_branch, options|
|
2016-09-27 03:07:31 +00:00
|
|
|
options[:project].repository.commit(repo_branch.dereferenced_target)
|
2014-02-04 12:46:15 +00:00
|
|
|
end
|
|
|
|
|
2016-11-28 18:16:15 +00:00
|
|
|
expose :merged do |repo_branch, options|
|
|
|
|
options[:project].repository.merged_to_root_ref?(repo_branch.name)
|
|
|
|
end
|
|
|
|
|
2016-07-19 11:30:23 +00:00
|
|
|
expose :protected do |repo_branch, options|
|
2017-04-03 17:59:58 +00:00
|
|
|
ProtectedBranch.protected?(options[:project], 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|
|
2017-04-04 00:39:34 +00:00
|
|
|
options[:project].protected_branches.developers_can?(:push, repo_branch.name)
|
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|
|
2017-04-04 00:39:34 +00:00
|
|
|
options[:project].protected_branches.developers_can?(:merge, repo_branch.name)
|
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
|
2016-08-29 15:23:40 +00:00
|
|
|
expose :id, :name, :type, :path
|
2014-02-04 12:46:15 +00:00
|
|
|
|
|
|
|
expose :mode do |obj, options|
|
2017-04-01 15:55:14 +00:00
|
|
|
filemode = obj.mode
|
2014-02-04 12:46:15 +00:00
|
|
|
filemode = "0" + filemode if filemode.length < 6
|
|
|
|
filemode
|
|
|
|
end
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2016-11-26 15:37:26 +00:00
|
|
|
class PersonalSnippet < Grape::Entity
|
|
|
|
expose :id, :title, :file_name
|
|
|
|
expose :author, using: Entities::UserBasic
|
|
|
|
expose :updated_at, :created_at
|
|
|
|
|
|
|
|
expose :web_url do |snippet|
|
|
|
|
Gitlab::UrlBuilder.build(snippet)
|
|
|
|
end
|
|
|
|
expose :raw_url do |snippet|
|
|
|
|
Gitlab::UrlBuilder.build(snippet) + "/raw"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
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
|
2017-05-15 17:10:29 +00:00
|
|
|
expose :new_file?, as: :new_file
|
|
|
|
expose :renamed_file?, as: :renamed_file
|
|
|
|
expose :deleted_file?, as: :deleted_file
|
2015-02-02 21:08:10 +00:00
|
|
|
end
|
|
|
|
|
2013-10-14 13:39:54 +00:00
|
|
|
class Milestone < ProjectEntity
|
2014-04-09 15:24:12 +00:00
|
|
|
expose :due_date
|
2016-11-15 17:48:30 +00:00
|
|
|
expose :start_date
|
2012-07-24 12:19:51 +00:00
|
|
|
end
|
|
|
|
|
2017-03-06 11:48:10 +00:00
|
|
|
class IssueBasic < 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
|
2017-05-04 12:11:15 +00:00
|
|
|
expose :assignees, :author, using: Entities::UserBasic
|
|
|
|
|
|
|
|
expose :assignee, using: ::API::Entities::UserBasic do |issue, options|
|
|
|
|
issue.assignees.first
|
|
|
|
end
|
2016-04-08 06:41:10 +00:00
|
|
|
|
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-07-15 14:21:53 +00:00
|
|
|
expose :confidential
|
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
|
|
|
|
2017-03-06 11:48:10 +00:00
|
|
|
class Issue < IssueBasic
|
|
|
|
expose :subscribed do |issue, options|
|
|
|
|
issue.subscribed?(options[:current_user], options[:project] || issue.project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-18 16:48:16 +00:00
|
|
|
class IssuableTimeStats < Grape::Entity
|
|
|
|
expose :time_estimate
|
|
|
|
expose :total_time_spent
|
|
|
|
expose :human_time_estimate
|
|
|
|
expose :human_total_time_spent
|
|
|
|
end
|
|
|
|
|
2016-06-11 14:16:32 +00:00
|
|
|
class ExternalIssue < Grape::Entity
|
|
|
|
expose :title
|
|
|
|
expose :id
|
|
|
|
end
|
|
|
|
|
2017-03-06 11:48:10 +00:00
|
|
|
class MergeRequestBasic < 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
|
2017-02-17 13:56:13 +00:00
|
|
|
expose :merge_when_pipeline_succeeds
|
2016-01-17 18:59:43 +00:00
|
|
|
expose :merge_status
|
2016-08-23 17:29:59 +00:00
|
|
|
expose :diff_head_sha, as: :sha
|
|
|
|
expose :merge_commit_sha
|
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
|
|
|
|
2017-03-06 11:48:10 +00:00
|
|
|
class MergeRequest < MergeRequestBasic
|
|
|
|
expose :subscribed do |merge_request, options|
|
|
|
|
merge_request.subscribed?(options[:current_user], options[:project])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
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
|
2016-08-18 07:27:45 +00:00
|
|
|
expose :id, :title, :key, :created_at, :can_push
|
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
|
2016-11-21 12:59:37 +00:00
|
|
|
expose :user, using: Entities::UserPublic
|
2015-08-29 09:52:21 +00:00
|
|
|
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
|
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,
|
2017-02-14 02:28:45 +00:00
|
|
|
:created_at, :started_at, :finished_at, :allow_failure, :coverage
|
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|
|
2017-02-07 14:16:46 +00:00
|
|
|
event.author&.username
|
2014-10-31 10:08:45 +00:00
|
|
|
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
|
2016-09-22 20:31:18 +00:00
|
|
|
expose :id, :project_id, :group_id, :group_access, :expires_at
|
2016-03-13 10:46:16 +00:00
|
|
|
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|
|
2017-02-21 13:44:21 +00:00
|
|
|
target = todo.target_type == 'Commit' ? 'RepoCommit' : todo.target_type
|
|
|
|
Entities.const_get(target).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
|
2017-02-14 13:34:36 +00:00
|
|
|
expose :id, :name, :path, :kind, :full_path
|
2013-11-15 13:24:10 +00:00
|
|
|
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
|
2016-08-02 20:52:55 +00:00
|
|
|
::NotificationSetting.levels[member.notification_setting.level]
|
2016-03-29 20:19:00 +00:00
|
|
|
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
|
|
|
|
|
2016-08-02 20:52:55 +00:00
|
|
|
class NotificationSetting < Grape::Entity
|
|
|
|
expose :level
|
|
|
|
expose :events, if: ->(notification_setting, _) { notification_setting.custom? } do
|
|
|
|
::NotificationSetting::EMAIL_EVENTS.each do |event|
|
|
|
|
expose event
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class GlobalNotificationSetting < NotificationSetting
|
|
|
|
expose :notification_email do |notification_setting, options|
|
|
|
|
notification_setting.user.notification_email
|
|
|
|
end
|
|
|
|
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
|
2017-02-22 10:13:59 +00:00
|
|
|
expose :tag_push_events, :note_events, :pipeline_events
|
2017-05-15 15:11:45 +00:00
|
|
|
expose :job_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|
|
2016-11-29 19:21:39 +00:00
|
|
|
project.project_members.find_by(user_id: options[:current_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
|
2016-11-29 19:21:39 +00:00
|
|
|
project.group.group_members.find_by(user_id: options[:current_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
|
|
|
|
2016-10-03 03:12:59 +00:00
|
|
|
class LabelBasic < Grape::Entity
|
2016-11-04 11:52:38 +00:00
|
|
|
expose :id, :name, :color, :description
|
2016-10-03 03:12:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
class Label < LabelBasic
|
2016-11-14 14:52:43 +00:00
|
|
|
expose :open_issues_count do |label, options|
|
2016-11-14 15:04:07 +00:00
|
|
|
label.open_issues_count(options[:current_user])
|
|
|
|
end
|
2016-11-14 14:52:43 +00:00
|
|
|
|
2016-11-14 15:04:07 +00:00
|
|
|
expose :closed_issues_count do |label, options|
|
|
|
|
label.closed_issues_count(options[:current_user])
|
|
|
|
end
|
2016-11-14 14:52:43 +00:00
|
|
|
|
2016-11-14 15:04:07 +00:00
|
|
|
expose :open_merge_requests_count do |label, options|
|
|
|
|
label.open_merge_requests_count(options[:current_user])
|
2016-11-14 14:52:43 +00:00
|
|
|
end
|
|
|
|
|
2016-09-29 14:33:38 +00:00
|
|
|
expose :priority do |label, options|
|
|
|
|
label.priority(options[:project])
|
|
|
|
end
|
2016-05-12 20:48:09 +00:00
|
|
|
|
|
|
|
expose :subscribed do |label, options|
|
2016-11-01 16:06:05 +00:00
|
|
|
label.subscribed?(options[:current_user], options[:project])
|
2016-05-12 20:48:09 +00:00
|
|
|
end
|
2014-03-21 09:18:19 +00:00
|
|
|
end
|
2014-05-26 13:08:22 +00:00
|
|
|
|
2016-10-03 03:12:59 +00:00
|
|
|
class List < Grape::Entity
|
|
|
|
expose :id
|
|
|
|
expose :label, using: Entities::LabelBasic
|
|
|
|
expose :position
|
|
|
|
end
|
|
|
|
|
|
|
|
class Board < Grape::Entity
|
|
|
|
expose :id
|
|
|
|
expose :lists, using: Entities::List do |board|
|
|
|
|
board.lists.destroyable
|
|
|
|
end
|
|
|
|
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
|
2017-02-17 13:50:02 +00:00
|
|
|
expose(:restricted_visibility_levels) do |setting, _options|
|
|
|
|
setting.restricted_visibility_levels.map { |level| Gitlab::VisibilityLevel.string_level(level) }
|
|
|
|
end
|
2015-07-03 14:50:21 +00:00
|
|
|
expose :max_attachment_size
|
|
|
|
expose :session_expire_delay
|
2017-02-17 13:50:02 +00:00
|
|
|
expose(:default_project_visibility) { |setting, _options| Gitlab::VisibilityLevel.string_level(setting.default_project_visibility) }
|
|
|
|
expose(:default_snippet_visibility) { |setting, _options| Gitlab::VisibilityLevel.string_level(setting.default_snippet_visibility) }
|
|
|
|
expose(:default_group_visibility) { |setting, _options| Gitlab::VisibilityLevel.string_level(setting.default_group_visibility) }
|
2017-02-15 07:31:25 +00:00
|
|
|
expose :default_artifacts_expire_in
|
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
|
2016-11-03 14:12:20 +00:00
|
|
|
expose :repository_storages
|
2016-09-28 00:56:02 +00:00
|
|
|
expose :koding_enabled
|
|
|
|
expose :koding_url
|
2016-11-28 17:41:29 +00:00
|
|
|
expose :plantuml_enabled
|
|
|
|
expose :plantuml_url
|
2017-01-26 18:16:50 +00:00
|
|
|
expose :terminal_max_session_time
|
2017-04-03 13:17:04 +00:00
|
|
|
expose :polling_interval_multiplier
|
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|
|
2016-09-27 03:07:31 +00:00
|
|
|
options[:project].repository.commit(repo_tag.dereferenced_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
|
|
|
|
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
|
2017-04-09 02:20:57 +00:00
|
|
|
expose :token, if: lambda { |runner, options| options[:current_user].admin? || !runner.is_shared? }
|
2016-02-19 12:00:36 +00:00
|
|
|
expose :projects, with: Entities::BasicProjectDetails do |runner, options|
|
2017-04-09 02:20:57 +00:00
|
|
|
if options[:current_user].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
|
|
|
|
|
2017-02-14 22:52:02 +00:00
|
|
|
class RunnerRegistrationDetails < Grape::Entity
|
|
|
|
expose :id, :token
|
|
|
|
end
|
|
|
|
|
2017-02-22 10:13:59 +00:00
|
|
|
class JobArtifactFile < Grape::Entity
|
2016-02-08 21:32:36 +00:00
|
|
|
expose :filename, :size
|
|
|
|
end
|
|
|
|
|
2016-09-23 23:43:57 +00:00
|
|
|
class PipelineBasic < Grape::Entity
|
|
|
|
expose :id, :sha, :ref, :status
|
|
|
|
end
|
|
|
|
|
2017-02-22 10:13:59 +00:00
|
|
|
class Job < 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
|
2017-03-06 08:31:37 +00:00
|
|
|
expose :artifacts_file, using: JobArtifactFile, if: -> (job, opts) { job.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
|
2016-09-23 23:43:57 +00:00
|
|
|
expose :pipeline, with: PipelineBasic
|
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
|
2017-03-05 20:18:00 +00:00
|
|
|
expose :id
|
2017-03-05 19:58:08 +00:00
|
|
|
expose :token, :description
|
|
|
|
expose :created_at, :updated_at, :deleted_at, :last_used
|
|
|
|
expose :owner, using: Entities::UserBasic
|
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-09-23 23:43:57 +00:00
|
|
|
class Pipeline < PipelineBasic
|
|
|
|
expose :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
|
2016-11-22 16:28:58 +00:00
|
|
|
expose :coverage
|
2016-08-17 08:09:42 +00:00
|
|
|
end
|
|
|
|
|
2017-05-11 19:12:04 +00:00
|
|
|
class PipelineSchedule < Grape::Entity
|
|
|
|
expose :id
|
|
|
|
expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active
|
|
|
|
expose :created_at, :updated_at, :deleted_at
|
2017-05-18 17:42:23 +00:00
|
|
|
expose :last_pipeline, using: Entities::PipelineBasic, if: { type: :full }
|
2017-05-11 19:12:04 +00:00
|
|
|
expose :owner, using: Entities::UserBasic
|
|
|
|
end
|
|
|
|
|
2016-08-23 14:25:17 +00:00
|
|
|
class EnvironmentBasic < Grape::Entity
|
2016-12-08 01:09:18 +00:00
|
|
|
expose :id, :name, :slug, :external_url
|
2016-07-26 07:37:02 +00:00
|
|
|
end
|
|
|
|
|
2016-08-23 14:25:17 +00:00
|
|
|
class Environment < EnvironmentBasic
|
2017-03-02 20:36:21 +00:00
|
|
|
expose :project, using: Entities::BasicProjectDetails
|
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
|
2017-02-22 10:13:59 +00:00
|
|
|
expose :deployable, using: Entities::Job
|
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
|
2016-08-25 23:34:01 +00:00
|
|
|
|
|
|
|
class BroadcastMessage < Grape::Entity
|
|
|
|
expose :id, :message, :starts_at, :ends_at, :color, :font
|
|
|
|
expose :active?, as: :active
|
|
|
|
end
|
2017-02-15 17:08:29 +00:00
|
|
|
|
2017-02-23 17:47:06 +00:00
|
|
|
class PersonalAccessToken < Grape::Entity
|
2016-12-27 16:26:57 +00:00
|
|
|
expose :id, :name, :revoked, :created_at, :scopes
|
|
|
|
expose :active?, as: :active
|
|
|
|
expose :expires_at do |personal_access_token|
|
|
|
|
personal_access_token.expires_at ? personal_access_token.expires_at.strftime("%Y-%m-%d") : nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-23 17:47:06 +00:00
|
|
|
class PersonalAccessTokenWithToken < PersonalAccessToken
|
2016-12-27 16:26:57 +00:00
|
|
|
expose :token
|
|
|
|
end
|
2017-02-23 17:47:06 +00:00
|
|
|
|
|
|
|
class ImpersonationToken < PersonalAccessTokenWithToken
|
|
|
|
expose :impersonation
|
|
|
|
end
|
2017-03-07 15:29:55 +00:00
|
|
|
|
2017-02-16 00:05:44 +00:00
|
|
|
module JobRequest
|
|
|
|
class JobInfo < Grape::Entity
|
|
|
|
expose :name, :stage
|
|
|
|
expose :project_id, :project_name
|
|
|
|
end
|
|
|
|
|
|
|
|
class GitInfo < Grape::Entity
|
|
|
|
expose :repo_url, :ref, :sha, :before_sha
|
|
|
|
expose :ref_type do |model|
|
|
|
|
if model.tag
|
|
|
|
'tag'
|
|
|
|
else
|
|
|
|
'branch'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-02-15 17:08:29 +00:00
|
|
|
|
2017-02-16 00:05:44 +00:00
|
|
|
class RunnerInfo < Grape::Entity
|
|
|
|
expose :timeout
|
|
|
|
end
|
2017-02-15 17:08:29 +00:00
|
|
|
|
2017-02-16 00:05:44 +00:00
|
|
|
class Step < Grape::Entity
|
2017-02-27 15:05:44 +00:00
|
|
|
expose :name, :script, :timeout, :when, :allow_failure
|
2017-02-16 00:05:44 +00:00
|
|
|
end
|
2017-02-15 17:08:29 +00:00
|
|
|
|
2017-02-16 00:05:44 +00:00
|
|
|
class Image < Grape::Entity
|
|
|
|
expose :name
|
|
|
|
end
|
2017-02-15 17:08:29 +00:00
|
|
|
|
2017-02-16 00:05:44 +00:00
|
|
|
class Artifacts < Grape::Entity
|
|
|
|
expose :name, :untracked, :paths, :when, :expire_in
|
2017-02-15 17:08:29 +00:00
|
|
|
end
|
|
|
|
|
2017-02-16 00:05:44 +00:00
|
|
|
class Cache < Grape::Entity
|
|
|
|
expose :key, :untracked, :paths
|
2017-02-15 17:08:29 +00:00
|
|
|
end
|
|
|
|
|
2017-02-16 00:05:44 +00:00
|
|
|
class Credentials < Grape::Entity
|
|
|
|
expose :type, :url, :username, :password
|
|
|
|
end
|
2017-02-15 17:08:29 +00:00
|
|
|
|
2017-02-16 00:05:44 +00:00
|
|
|
class ArtifactFile < Grape::Entity
|
|
|
|
expose :filename, :size
|
|
|
|
end
|
|
|
|
|
|
|
|
class Dependency < Grape::Entity
|
2017-03-16 04:18:37 +00:00
|
|
|
expose :id, :name, :token
|
2017-02-16 00:05:44 +00:00
|
|
|
expose :artifacts_file, using: ArtifactFile, if: ->(job, _) { job.artifacts? }
|
|
|
|
end
|
|
|
|
|
|
|
|
class Response < Grape::Entity
|
|
|
|
expose :id
|
|
|
|
expose :token
|
|
|
|
expose :allow_git_fetch
|
|
|
|
|
|
|
|
expose :job_info, using: JobInfo do |model|
|
|
|
|
model
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :git_info, using: GitInfo do |model|
|
|
|
|
model
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :runner_info, using: RunnerInfo do |model|
|
|
|
|
model
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :variables
|
|
|
|
expose :steps, using: Step
|
|
|
|
expose :image, using: Image
|
|
|
|
expose :services, using: Image
|
|
|
|
expose :artifacts, using: Artifacts
|
|
|
|
expose :cache, using: Cache
|
|
|
|
expose :credentials, using: Credentials
|
2017-03-16 13:45:05 +00:00
|
|
|
expose :dependencies, using: Dependency
|
2017-02-16 00:05:44 +00:00
|
|
|
end
|
2017-02-15 17:08:29 +00:00
|
|
|
end
|
2012-06-27 11:32:56 +00:00
|
|
|
end
|
|
|
|
end
|