environment_entity.rb 933 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's avatar
Kamil Trzcinski committed
10
  expose :stop_action?
11

12 13
  expose :environment_path do |environment|
    namespace_project_environment_path(
14 15
      environment.project.namespace,
      environment.project,
16
      environment)
17 18
  end

19 20 21 22 23 24 25
  expose :stop_path do |environment|
    stop_namespace_project_environment_path(
      environment.project.namespace,
      environment.project,
      environment)
  end

26
  expose :terminal_path, if: ->(environment, _) { environment.has_terminals? } do |environment|
27 28 29 30 31
    can?(request.user, :admin_environment, environment.project) &&
      terminal_namespace_project_environment_path(
        environment.project.namespace,
        environment.project,
        environment)
32 33
  end

34
  expose :created_at, :updated_at
35
end