gitlab-org--gitlab-foss/app/serializers/environment_entity.rb

35 lines
1 KiB
Ruby
Raw Normal View History

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