2020-02-12 19:08:46 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
module Releases
|
|
|
|
class Link < Grape::Entity
|
|
|
|
expose :id
|
|
|
|
expose :name
|
|
|
|
expose :url
|
2020-02-27 10:09:24 -05:00
|
|
|
expose :direct_asset_url
|
2020-02-12 19:08:46 -05:00
|
|
|
expose :external?, as: :external
|
2020-02-27 10:09:24 -05:00
|
|
|
|
|
|
|
def direct_asset_url
|
|
|
|
return object.url unless object.filepath
|
|
|
|
|
|
|
|
release = object.release
|
|
|
|
project = release.project
|
|
|
|
|
|
|
|
Gitlab::Routing.url_helpers.project_release_url(project, release) << object.filepath
|
|
|
|
end
|
2020-02-12 19:08:46 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|