2016-10-28 08:32:07 -04:00
|
|
|
class EnvironmentEntity < Grape::Entity
|
|
|
|
include RequestAwareEntity
|
|
|
|
|
|
|
|
expose :id
|
|
|
|
expose :name
|
2016-11-03 07:54:10 -04:00
|
|
|
expose :state
|
|
|
|
expose :external_url
|
|
|
|
expose :environment_type
|
|
|
|
expose :last_deployment, using: DeploymentEntity
|
|
|
|
expose :stoppable?
|
2016-10-28 08:32:07 -04:00
|
|
|
|
2016-11-17 10:08:05 -05:00
|
|
|
expose :environment_path do |environment|
|
|
|
|
namespace_project_environment_path(
|
2016-11-02 09:36:21 -04:00
|
|
|
environment.project.namespace,
|
|
|
|
environment.project,
|
2016-11-03 07:54:10 -04:00
|
|
|
environment)
|
2016-11-02 09:36:21 -04:00
|
|
|
end
|
|
|
|
|
2016-11-18 16:31:53 -05:00
|
|
|
expose :stop_path do |environment|
|
|
|
|
stop_namespace_project_environment_path(
|
|
|
|
environment.project.namespace,
|
|
|
|
environment.project,
|
|
|
|
environment)
|
|
|
|
end
|
|
|
|
|
2016-11-22 14:55:56 -05:00
|
|
|
expose :terminal_path, if: ->(environment, _) { environment.has_terminals? } do |environment|
|
2016-12-14 19:59:04 -05:00
|
|
|
can?(request.user, :admin_environment, environment.project) &&
|
|
|
|
terminal_namespace_project_environment_path(
|
|
|
|
environment.project.namespace,
|
|
|
|
environment.project,
|
|
|
|
environment)
|
2016-11-22 14:55:56 -05:00
|
|
|
end
|
|
|
|
|
2016-11-03 07:54:10 -04:00
|
|
|
expose :created_at, :updated_at
|
2016-10-28 08:32:07 -04:00
|
|
|
end
|