2019-01-10 09:22:58 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
module ContainerRegistry
|
2019-08-05 16:00:50 -04:00
|
|
|
class Tag < Grape::Entity
|
2019-01-10 09:22:58 -05:00
|
|
|
expose :name
|
|
|
|
expose :path
|
|
|
|
expose :location
|
|
|
|
end
|
|
|
|
|
2019-08-05 16:00:50 -04:00
|
|
|
class Repository < Grape::Entity
|
2020-10-30 08:08:44 -04:00
|
|
|
include ::API::Helpers::RelatedResourcesHelpers
|
|
|
|
|
2019-08-05 16:00:50 -04:00
|
|
|
expose :id
|
2019-01-10 09:22:58 -05:00
|
|
|
expose :name
|
|
|
|
expose :path
|
2019-08-05 16:00:50 -04:00
|
|
|
expose :project_id
|
2019-01-10 09:22:58 -05:00
|
|
|
expose :location
|
2019-08-05 16:00:50 -04:00
|
|
|
expose :created_at
|
2020-09-22 20:09:45 -04:00
|
|
|
expose :expiration_policy_started_at, as: :cleanup_policy_started_at
|
2020-05-25 17:08:00 -04:00
|
|
|
expose :tags_count, if: -> (_, options) { options[:tags_count] }
|
2019-08-05 16:00:50 -04:00
|
|
|
expose :tags, using: Tag, if: -> (_, options) { options[:tags] }
|
2020-10-30 08:08:44 -04:00
|
|
|
expose :delete_api_path, if: ->(object, options) { Ability.allowed?(options[:user], :admin_container_image, object) }
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def delete_api_path
|
|
|
|
expose_url api_v4_projects_registry_repositories_path(repository_id: object.id, id: object.project_id)
|
|
|
|
end
|
2019-01-10 09:22:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
class TagDetails < Tag
|
|
|
|
expose :revision
|
|
|
|
expose :short_revision
|
|
|
|
expose :digest
|
|
|
|
expose :created_at
|
|
|
|
expose :total_size
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|