entities.rb 21.8 KB
Newer Older
1
module API
N
Nihad Abbasov 已提交
2
  module Entities
3 4 5
    class UserSafe < Grape::Entity
      expose :name, :username
    end
6

7 8
    class UserBasic < UserSafe
      expose :id, :state, :avatar_url
D
Douwe Maan 已提交
9 10

      expose :web_url do |user, options|
11
        Gitlab::Routing.url_helpers.user_url(user)
D
Douwe Maan 已提交
12
      end
N
Nihad Abbasov 已提交
13
    end
N
Nihad Abbasov 已提交
14

15 16 17
    class User < UserBasic
      expose :created_at
      expose :is_admin?, as: :is_admin
18
      expose :bio, :location, :skype, :linkedin, :twitter, :website_url, :organization
19 20
    end

21 22 23 24
    class Identity < Grape::Entity
      expose :provider, :extern_uid
    end

25
    class UserPublic < User
26 27
      expose :last_sign_in_at
      expose :confirmed_at
28
      expose :email
29
      expose :color_scheme_id, :projects_limit, :current_sign_in_at
30
      expose :identities, using: Entities::Identity
31 32
      expose :can_create_group?, as: :can_create_group
      expose :can_create_project?, as: :can_create_project
33
      expose :two_factor_enabled?, as: :two_factor_enabled
34
      expose :external
35 36
    end

37
    class UserWithPrivateToken < UserPublic
38
      expose :private_token
39 40
    end

41 42 43 44
    class Email < Grape::Entity
      expose :id, :email
    end

M
miks 已提交
45
    class Hook < Grape::Entity
46
      expose :id, :url, :created_at, :push_events, :tag_push_events
47
      expose :enable_ssl_verification
M
miks 已提交
48 49
    end

50
    class ProjectHook < Hook
51
      expose :project_id, :issues_events, :merge_requests_events
52
      expose :note_events, :build_events, :pipeline_events, :wiki_page_events
53 54
    end

55
    class BasicProjectDetails < Grape::Entity
56
      expose :id
57
      expose :http_url_to_repo, :web_url
58 59 60 61
      expose :name, :name_with_namespace
      expose :path, :path_with_namespace
    end

62 63 64 65 66 67 68 69
    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

N
Nihad Abbasov 已提交
70
    class Project < Grape::Entity
71
      expose :id, :description, :default_branch, :tag_list
72
      expose :archived?, as: :archived
73 74
      expose :ssh_url_to_repo, :http_url_to_repo, :web_url
      expose(:visibility) { |project, _options| Gitlab::VisibilityLevel.string_level(project.visibility_level) }
75
      expose :owner, using: Entities::UserBasic, unless: ->(project, options) { project.group }
76
      expose :name, :name_with_namespace
77
      expose :path, :path_with_namespace
F
Felipe Artur 已提交
78 79 80
      expose :container_registry_enabled

      # Expose old field names with the new permissions methods to keep API compatible
81 82 83 84 85
      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]) }
      expose(:builds_enabled) { |project, options| project.feature_available?(:builds, options[:current_user]) }
      expose(:snippets_enabled) { |project, options| project.feature_available?(:snippets, options[:current_user]) }
F
Felipe Artur 已提交
86

87
      expose :created_at, :last_activity_at
88 89
      expose :shared_runners_enabled
      expose :lfs_enabled?, as: :lfs_enabled
90
      expose :creator_id
91
      expose :namespace, using: 'API::Entities::Namespace'
92
      expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? }
S
sue445 已提交
93
      expose :avatar_url
94
      expose :star_count, :forks_count
95
      expose :open_issues_count, if: lambda { |project, options| project.feature_available?(:issues, options[:current_user]) && project.default_issues_tracker? }
96
      expose :runners_token, if: lambda { |_project, options| options[:user_can_admin_project] }
97
      expose :public_builds
98 99 100
      expose :shared_with_groups do |project, options|
        SharedGroup.represent(project.project_group_links.all, options)
      end
J
James Lopez 已提交
101
      expose :only_allow_merge_if_pipeline_succeeds
102
      expose :request_access_enabled
103
      expose :only_allow_merge_if_all_discussions_are_resolved
M
Markus Koller 已提交
104 105 106 107 108 109 110 111 112 113

      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
      expose :build_artifacts_size
N
Nihad Abbasov 已提交
114 115
    end

116
    class Member < UserBasic
D
Dmitriy Zaporozhets 已提交
117
      expose :access_level do |user, options|
118
        member = options[:member] || options[:source].members.find_by(user_id: user.id)
119 120
        member.access_level
      end
121
      expose :expires_at do |user, options|
122
        member = options[:member] || options[:source].members.find_by(user_id: user.id)
123 124
        member.expires_at
      end
125 126 127 128
    end

    class AccessRequester < UserBasic
      expose :requested_at do |user, options|
129
        access_requester = options[:access_requester] || options[:source].requesters.find_by(user_id: user.id)
130
        access_requester.requested_at
N
Nihad Abbasov 已提交
131
      end
M
miks 已提交
132 133
    end

134
    class Group < Grape::Entity
135 136
      expose :id, :name, :path, :description, :visibility_level
      expose :lfs_enabled?, as: :lfs_enabled
D
Douwe Maan 已提交
137
      expose :avatar_url
R
Rémy Coutable 已提交
138
      expose :web_url
139
      expose :request_access_enabled
140
      expose :full_name, :full_path
141
      expose :parent_id
M
Markus Koller 已提交
142 143 144 145 146 147 148 149 150

      expose :statistics, if: :statistics do
        with_options format_with: -> (value) { value.to_i } do
          expose :storage_size
          expose :repository_size
          expose :lfs_objects_size
          expose :build_artifacts_size
        end
      end
151
    end
A
Andrew8xx8 已提交
152

153
    class GroupDetail < Group
154
      expose :projects, using: Entities::Project
155
      expose :shared_projects, using: Entities::Project
156 157
    end

158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
    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

175
    class RepoBranch < Grape::Entity
176 177
      expose :name

178
      expose :commit, using: Entities::RepoCommit do |repo_branch, options|
179
        options[:project].repository.commit(repo_branch.dereferenced_target)
180 181
      end

R
Robert Schilling 已提交
182 183 184 185
      expose :merged do |repo_branch, options|
        options[:project].repository.merged_to_root_ref?(repo_branch.name)
      end

186
      expose :protected do |repo_branch, options|
R
Robert Schilling 已提交
187
        options[:project].protected_branch?(repo_branch.name)
188 189
      end

190
      expose :developers_can_push do |repo_branch, options|
191
        project = options[:project]
192 193
        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 }
194
      end
195

196
      expose :developers_can_merge do |repo_branch, options|
197
        project = options[:project]
198 199
        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 }
200
      end
N
Nihad Abbasov 已提交
201
    end
N
Nihad Abbasov 已提交
202

203
    class RepoTreeObject < Grape::Entity
204
      expose :id, :name, :type, :path
205 206 207 208 209 210 211 212

      expose :mode do |obj, options|
        filemode = obj.mode.to_s(8)
        filemode = "0" + filemode if filemode.length < 6
        filemode
      end
    end

N
Nihad Abbasov 已提交
213 214
    class ProjectSnippet < Grape::Entity
      expose :id, :title, :file_name
215
      expose :author, using: Entities::UserBasic
R
Robert Speicher 已提交
216
      expose :updated_at, :created_at
217

218 219 220
      expose :web_url do |snippet, options|
        Gitlab::UrlBuilder.build(snippet)
      end
N
Nihad Abbasov 已提交
221
    end
N
Nihad Abbasov 已提交
222

223 224 225 226 227 228 229 230 231 232 233 234 235
    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

236 237
    class ProjectEntity < Grape::Entity
      expose :id, :iid
238
      expose(:project_id) { |entity| entity.project.id }
239 240
      expose :title, :description
      expose :state, :created_at, :updated_at
241 242
    end

243 244 245 246 247
    class RepoDiff < Grape::Entity
      expose :old_path, :new_path, :a_mode, :b_mode, :diff
      expose :new_file, :renamed_file, :deleted_file
    end

248
    class Milestone < ProjectEntity
249
      expose :due_date
V
Valery Sizov 已提交
250
      expose :start_date
N
Nihad Abbasov 已提交
251 252
    end

253
    class Issue < ProjectEntity
254
      expose :label_names, as: :labels
255 256
      expose :milestone, using: Entities::Milestone
      expose :assignee, :author, using: Entities::UserBasic
257 258

      expose :subscribed do |issue, options|
259
        issue.subscribed?(options[:current_user], options[:project] || issue.project)
260
      end
Z
Z.J. van de Weg 已提交
261
      expose :user_notes_count
Z
Zeger-Jan van de Weg 已提交
262
      expose :upvotes, :downvotes
263
      expose :due_date
264
      expose :confidential
265 266 267 268

      expose :web_url do |issue, options|
        Gitlab::UrlBuilder.build(issue)
      end
N
Nihad Abbasov 已提交
269
    end
A
Alex Denisov 已提交
270

271 272 273 274 275 276 277
    class IssuableTimeStats < Grape::Entity
      expose :time_estimate
      expose :total_time_spent
      expose :human_time_estimate
      expose :human_total_time_spent
    end

278 279 280 281 282
    class ExternalIssue < Grape::Entity
      expose :title
      expose :id
    end

283
    class MergeRequest < ProjectEntity
V
Valery Sizov 已提交
284
      expose :target_branch, :source_branch
285
      expose :upvotes, :downvotes
286 287
      expose :author, :assignee, using: Entities::UserBasic
      expose :source_project_id, :target_project_id
288
      expose :label_names, as: :labels
B
Ben Boeckel 已提交
289
      expose :work_in_progress?, as: :work_in_progress
290
      expose :milestone, using: Entities::Milestone
J
James Lopez 已提交
291
      expose :merge_when_pipeline_succeeds
292
      expose :merge_status
293 294
      expose :diff_head_sha, as: :sha
      expose :merge_commit_sha
295
      expose :subscribed do |merge_request, options|
296
        merge_request.subscribed?(options[:current_user], options[:project])
297
      end
Z
Z.J. van de Weg 已提交
298
      expose :user_notes_count
299 300
      expose :should_remove_source_branch?, as: :should_remove_source_branch
      expose :force_remove_source_branch?, as: :force_remove_source_branch
301 302 303 304

      expose :web_url do |merge_request, options|
        Gitlab::UrlBuilder.build(merge_request)
      end
A
Alex Denisov 已提交
305
    end
V
Valeriy Sizov 已提交
306

307 308
    class MergeRequestChanges < MergeRequest
      expose :diffs, as: :changes, using: Entities::RepoDiff do |compare, _|
309
        compare.raw_diffs(all_diffs: true).to_a
310 311 312
      end
    end

313 314 315
    class MergeRequestDiff < Grape::Entity
      expose :id, :head_commit_sha, :base_commit_sha, :start_commit_sha,
        :created_at, :merge_request_id, :state, :real_size
316
    end
317

318
    class MergeRequestDiffFull < MergeRequestDiff
319 320 321
      expose :commits, using: Entities::RepoCommit

      expose :diffs, using: Entities::RepoDiff do |compare, _|
D
Dmitriy Zaporozhets 已提交
322
        compare.raw_diffs(all_diffs: true).to_a
323 324 325
      end
    end

326
    class SSHKey < Grape::Entity
327
      expose :id, :title, :key, :created_at, :can_push
V
Valeriy Sizov 已提交
328
    end
329

330
    class SSHKeyWithUser < SSHKey
331
      expose :user, using: Entities::UserPublic
332 333
    end

334
    class Note < Grape::Entity
335 336
      expose :id
      expose :note, as: :body
337
      expose :attachment_identifier, as: :attachment
338
      expose :author, using: Entities::UserBasic
339
      expose :created_at, :updated_at
340
      expose :system?, as: :system
D
Dmitriy Zaporozhets 已提交
341
      expose :noteable_id, :noteable_type
342
    end
343

Z
Z.J. van de Weg 已提交
344 345 346 347 348 349 350 351
    class AwardEmoji < Grape::Entity
      expose :id
      expose :name
      expose :user, using: Entities::UserBasic
      expose :created_at, :updated_at
      expose :awardable_id, :awardable_type
    end

352 353 354 355
    class MRNote < Grape::Entity
      expose :note
      expose :author, using: Entities::UserBasic
    end
D
Dmitriy Zaporozhets 已提交
356

357 358
    class CommitNote < Grape::Entity
      expose :note
359 360 361
      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? }
362
      expose :author, using: Entities::UserBasic
363
      expose :created_at
364 365
    end

K
Kamil Trzcinski 已提交
366 367
    class CommitStatus < Grape::Entity
      expose :id, :sha, :ref, :status, :name, :target_url, :description,
368
             :created_at, :started_at, :finished_at, :allow_failure, :coverage
K
Kamil Trzcinski 已提交
369
      expose :author, using: Entities::UserBasic
K
Kamil Trzcinski 已提交
370 371
    end

D
Dmitriy Zaporozhets 已提交
372 373 374 375
    class Event < Grape::Entity
      expose :title, :project_id, :action_name
      expose :target_id, :target_type, :author_id
      expose :data, :target_title
376
      expose :created_at
D
Dmitriy Zaporozhets 已提交
377 378
      expose :note, using: Entities::Note, if: ->(event, options) { event.note? }
      expose :author, using: Entities::UserBasic, if: ->(event, options) { event.author }
379 380

      expose :author_username do |event, options|
Z
Z.J. van de Weg 已提交
381
        event.author&.username
382
      end
D
Dmitriy Zaporozhets 已提交
383
    end
384

385
    class ProjectGroupLink < Grape::Entity
386
      expose :id, :project_id, :group_id, :group_access, :expires_at
387 388
    end

D
Douglas Barbosa Alexandre 已提交
389 390 391 392
    class Todo < Grape::Entity
      expose :id
      expose :project, using: Entities::BasicProjectDetails
      expose :author, using: Entities::UserBasic
R
Robert Schilling 已提交
393
      expose :action_name
D
Douglas Barbosa Alexandre 已提交
394
      expose :target_type
395 396

      expose :target do |todo, options|
397 398
        target = todo.target_type == 'Commit' ? 'RepoCommit' : todo.target_type
        Entities.const_get(target).represent(todo.target, options)
D
Douglas Barbosa Alexandre 已提交
399 400 401 402 403
      end

      expose :target_url do |todo, options|
        target_type   = todo.target_type.underscore
        target_url    = "namespace_project_#{target_type}_url"
404
        target_anchor = "note_#{todo.note_id}" if todo.note_id?
D
Douglas Barbosa Alexandre 已提交
405 406 407 408 409 410 411 412 413 414

        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

415
    class Namespace < Grape::Entity
416
      expose :id, :name, :path, :kind, :full_path
417
    end
418

419
    class MemberAccess < Grape::Entity
D
Dmitriy Zaporozhets 已提交
420
      expose :access_level
421 422
      expose :notification_level do |member, options|
        if member.notification_setting
423
          ::NotificationSetting.levels[member.notification_setting.level]
424 425
        end
      end
426 427
    end

428
    class ProjectAccess < MemberAccess
429 430
    end

431
    class GroupAccess < MemberAccess
432 433
    end

434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
    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

449 450
    class ProjectService < Grape::Entity
      expose :id, :title, :created_at, :updated_at, :active
451 452
      expose :push_events, :issues_events, :merge_requests_events
      expose :tag_push_events, :note_events, :build_events, :pipeline_events
453 454 455 456 457 458 459 460 461
      # 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

462 463 464
    class ProjectWithAccess < Project
      expose :permissions do
        expose :project_access, using: Entities::ProjectAccess do |project, options|
465
          project.project_members.find_by(user_id: options[:current_user].id)
466 467 468
        end

        expose :group_access, using: Entities::GroupAccess do |project, options|
469
          if project.group
470
            project.group.group_members.find_by(user_id: options[:current_user].id)
471
          end
472 473 474
        end
      end
    end
475

A
Andre Guedes 已提交
476
    class LabelBasic < Grape::Entity
R
Rares Sfirlogea 已提交
477
      expose :id, :name, :color, :description
A
Andre Guedes 已提交
478 479 480
    end

    class Label < LabelBasic
481
      expose :open_issues_count do |label, options|
F
Francesco Coda Zabetta 已提交
482 483
        label.open_issues_count(options[:current_user])
      end
484

F
Francesco Coda Zabetta 已提交
485 486 487
      expose :closed_issues_count do |label, options|
        label.closed_issues_count(options[:current_user])
      end
488

F
Francesco Coda Zabetta 已提交
489 490
      expose :open_merge_requests_count do |label, options|
        label.open_merge_requests_count(options[:current_user])
491 492
      end

493 494 495
      expose :priority do |label, options|
        label.priority(options[:project])
      end
496 497

      expose :subscribed do |label, options|
498
        label.subscribed?(options[:current_user], options[:project])
499
      end
500
    end
501

A
Andre Guedes 已提交
502 503 504 505 506 507 508 509 510 511 512 513 514
    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

515 516
    class Compare < Grape::Entity
      expose :commit, using: Entities::RepoCommit do |compare, options|
517
        Commit.decorate(compare.commits, nil).last
518
      end
519

520
      expose :commits, using: Entities::RepoCommit do |compare, options|
521
        Commit.decorate(compare.commits, nil)
522
      end
523

524
      expose :diffs, using: Entities::RepoDiff do |compare, options|
J
Jacob Vosmaer 已提交
525
        compare.diffs(all_diffs: true).to_a
526
      end
527 528

      expose :compare_timeout do |compare, options|
J
Jacob Vosmaer 已提交
529
        compare.diffs.overflow?
530 531 532
      end

      expose :same, as: :compare_same_ref
533
    end
534 535 536 537

    class Contributor < Grape::Entity
      expose :name, :email, :commits, :additions, :deletions
    end
D
Douwe Maan 已提交
538 539 540 541

    class BroadcastMessage < Grape::Entity
      expose :message, :starts_at, :ends_at, :color, :font
    end
542 543 544 545 546 547 548 549

    class ApplicationSetting < Grape::Entity
      expose :id
      expose :default_projects_limit
      expose :signup_enabled
      expose :signin_enabled
      expose :gravatar_enabled
      expose :sign_in_text
550
      expose :after_sign_up_text
551 552 553 554 555 556 557 558 559
      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
560
      expose :default_group_visibility
561
      expose :default_artifacts_expire_in
562
      expose :domain_whitelist
563 564
      expose :domain_blacklist_enabled
      expose :domain_blacklist
565 566
      expose :user_oauth_applications
      expose :after_sign_out_path
567
      expose :container_registry_token_expire_delay
568
      expose :repository_storage
569
      expose :repository_storages
570 571
      expose :koding_enabled
      expose :koding_url
572 573
      expose :plantuml_enabled
      expose :plantuml_url
574
      expose :terminal_max_session_time
575
    end
D
Dmitriy Zaporozhets 已提交
576 577

    class Release < Grape::Entity
578 579
      expose :tag, as: :tag_name
      expose :description
D
Dmitriy Zaporozhets 已提交
580
    end
581 582

    class RepoTag < Grape::Entity
583
      expose :name, :message
584

585
      expose :commit do |repo_tag, options|
586
        options[:project].repository.commit(repo_tag.dereferenced_target)
587 588
      end

589 590
      expose :release, using: Entities::Release do |repo_tag, options|
        options[:project].releases.find_by(tag: repo_tag.name)
591 592
      end
    end
K
Kamil Trzcinski 已提交
593 594 595 596

    class TriggerRequest < Grape::Entity
      expose :id, :variables
    end
T
Tomasz Maczukin 已提交
597

T
Tomasz Maczukin 已提交
598
    class Runner < Grape::Entity
T
Tomasz Maczukin 已提交
599 600 601 602 603 604 605
      expose :id
      expose :description
      expose :active
      expose :is_shared
      expose :name
    end

606 607
    class RunnerDetails < Runner
      expose :tag_list
608
      expose :run_untagged
609
      expose :locked
610
      expose :version, :revision, :platform, :architecture
611
      expose :contacted_at
612
      expose :token, if: lambda { |runner, options| options[:current_user].is_admin? || !runner.is_shared? }
613
      expose :projects, with: Entities::BasicProjectDetails do |runner, options|
614
        if options[:current_user].is_admin?
615 616
          runner.projects
        else
617
          options[:current_user].authorized_projects.where(id: runner.projects)
618 619
        end
      end
620 621
    end

622 623 624 625
    class RunnerRegistrationDetails < Grape::Entity
      expose :id, :token
    end

626 627 628 629
    class BuildArtifactFile < Grape::Entity
      expose :filename, :size
    end

630 631 632 633
    class PipelineBasic < Grape::Entity
      expose :id, :sha, :ref, :status
    end

634
    class Build < Grape::Entity
T
Tomasz Maczukin 已提交
635
      expose :id, :status, :stage, :name, :ref, :tag, :coverage
T
Tomasz Maczukin 已提交
636
      expose :created_at, :started_at, :finished_at
T
Tomasz Maczukin 已提交
637
      expose :user, with: User
K
Kamil Trzcinski 已提交
638
      expose :artifacts_file, using: BuildArtifactFile, if: -> (build, opts) { build.artifacts? }
639
      expose :commit, with: RepoCommit
T
Tomasz Maczukin 已提交
640
      expose :runner, with: Runner
641
      expose :pipeline, with: PipelineBasic
642
    end
643

T
Tomasz Maczukin 已提交
644
    class Trigger < Grape::Entity
T
Tomasz Maczukin 已提交
645
      expose :token, :created_at, :updated_at, :deleted_at, :last_used
T
Tomasz Maczukin 已提交
646
    end
647

648
    class Variable < Grape::Entity
T
Tomasz Maczukin 已提交
649
      expose :key, :value
650
    end
651

652 653
    class Pipeline < PipelineBasic
      expose :before_sha, :tag, :yaml_errors
Z
Z.J. van de Weg 已提交
654 655 656 657

      expose :user, with: Entities::UserBasic
      expose :created_at, :updated_at, :started_at, :finished_at, :committed_at
      expose :duration
658
      expose :coverage
Z
Z.J. van de Weg 已提交
659 660
    end

661
    class EnvironmentBasic < Grape::Entity
N
Nick Thomas 已提交
662
      expose :id, :name, :slug, :external_url
663 664
    end

665 666
    class Environment < EnvironmentBasic
      expose :project, using: Entities::Project
Z
Z.J. van de Weg 已提交
667 668 669 670
    end

    class Deployment < Grape::Entity
      expose :id, :iid, :ref, :sha, :created_at
671 672 673
      expose :user,        using: Entities::UserBasic
      expose :environment, using: Entities::EnvironmentBasic
      expose :deployable,  using: Entities::Build
674 675
    end

676
    class RepoLicense < Grape::Entity
677 678
      expose :key, :name, :nickname
      expose :featured, as: :popular
679 680 681
      expose :url, as: :html_url
      expose(:source_url) { |license| license.meta['source'] }
      expose(:description) { |license| license.meta['description'] }
682 683 684
      expose(:conditions) { |license| license.meta['conditions'] }
      expose(:permissions) { |license| license.meta['permissions'] }
      expose(:limitations) { |license| license.meta['limitations'] }
685 686
      expose :content
    end
687

Z
ZJ van de Weg 已提交
688
    class TemplatesList < Grape::Entity
689 690 691
      expose :name
    end

Z
ZJ van de Weg 已提交
692
    class Template < Grape::Entity
693 694
      expose :name, :content
    end
695 696 697 698 699

    class BroadcastMessage < Grape::Entity
      expose :id, :message, :starts_at, :ends_at, :color, :font
      expose :active?, as: :active
    end
N
Nihad Abbasov 已提交
700 701
  end
end