2017-08-17 22:00:37 +05:30
|
|
|
class EnvironmentEntity < Grape::Entity
|
|
|
|
include RequestAwareEntity
|
|
|
|
|
|
|
|
expose :id
|
|
|
|
expose :name
|
|
|
|
expose :state
|
|
|
|
expose :external_url
|
|
|
|
expose :environment_type
|
|
|
|
expose :last_deployment, using: DeploymentEntity
|
|
|
|
expose :stop_action?
|
|
|
|
|
|
|
|
expose :metrics_path, if: -> (environment, _) { environment.has_metrics? } do |environment|
|
2017-09-10 17:25:29 +05:30
|
|
|
metrics_project_environment_path(environment.project, environment)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
expose :environment_path do |environment|
|
2017-09-10 17:25:29 +05:30
|
|
|
project_environment_path(environment.project, environment)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
expose :stop_path do |environment|
|
2017-09-10 17:25:29 +05:30
|
|
|
stop_project_environment_path(environment.project, environment)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
expose :terminal_path, if: ->(environment, _) { environment.has_terminals? } do |environment|
|
|
|
|
can?(request.current_user, :admin_environment, environment.project) &&
|
2017-09-10 17:25:29 +05:30
|
|
|
terminal_project_environment_path(environment.project, environment)
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :folder_path do |environment|
|
|
|
|
folder_project_environments_path(environment.project, environment.folder_name)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
expose :created_at, :updated_at
|
|
|
|
end
|