BigW Consortium Gitlab

environment_entity.rb 927 Bytes
Newer Older
1 2 3 4 5
class EnvironmentEntity < Grape::Entity
  include RequestAwareEntity

  expose :id
  expose :name
6 7 8 9
  expose :state
  expose :external_url
  expose :environment_type
  expose :last_deployment, using: DeploymentEntity
Kamil Trzcinski committed
10
  expose :stop_action?
11

12
  expose :metrics_path, if: -> (environment, _) { environment.has_metrics? } do |environment|
13
    metrics_project_environment_path(environment.project, environment)
14 15
  end

16
  expose :environment_path do |environment|
17
    project_environment_path(environment.project, environment)
18 19
  end

20
  expose :stop_path do |environment|
21
    stop_project_environment_path(environment.project, environment)
22 23
  end

24
  expose :terminal_path, if: ->(environment, _) { environment.has_terminals? } do |environment|
25
    can?(request.current_user, :admin_environment, environment.project) &&
26
      terminal_project_environment_path(environment.project, environment)
27 28
  end

29
  expose :created_at, :updated_at
30
end