Commit e6426836 authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Stan Hu

Separate package, build info and project alias into own classes

parent 8cc37ed4
---
title: Separate project alias, build info, package entities into own class files
merge_request: 26493
author: Rajendra Kadam
type: added
...@@ -779,57 +779,6 @@ module EE ...@@ -779,57 +779,6 @@ module EE
expose :dist_tags, merge: true expose :dist_tags, merge: true
end end
class Package < Grape::Entity
include ::API::Helpers::RelatedResourcesHelpers
extend EntityHelpers
class BuildInfo < Grape::Entity
expose :pipeline, using: ::API::Entities::PipelineBasic
end
expose :id
expose :name
expose :version
expose :package_type
expose :_links do
expose :web_path do |package|
::Gitlab::Routing.url_helpers.project_package_path(package.project, package)
end
expose :delete_api_path, if: can_destroy(:package, &:project) do |package|
expose_url api_v4_projects_packages_path(package_id: package.id, id: package.project_id)
end
end
expose :created_at
expose :project_id, if: ->(_, opts) { opts[:group] }
expose :project_path, if: ->(obj, opts) { opts[:group] && Ability.allowed?(opts[:user], :read_project, obj.project) }
expose :build_info, using: BuildInfo
expose :tags
private
def project_path
object.project.full_path
end
end
class PackageFile < Grape::Entity
expose :id, :package_id, :created_at
expose :file_name, :size
expose :file_md5, :file_sha1
end
class ManagedLicense < Grape::Entity
expose :id, :name
expose :approval_status
end
class ProjectAlias < Grape::Entity
expose :id, :project_id, :name
end
module Analytics module Analytics
module CodeReview module CodeReview
class MergeRequest < ::API::Entities::MergeRequestSimple class MergeRequest < ::API::Entities::MergeRequestSimple
......
# frozen_string_literal: true
module EE
module API
module Entities
class ManagedLicense < Grape::Entity
expose :id, :name
expose :approval_status
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class Package < Grape::Entity
include ::API::Helpers::RelatedResourcesHelpers
extend EntityHelpers
expose :id
expose :name
expose :version
expose :package_type
expose :_links do
expose :web_path do |package|
::Gitlab::Routing.url_helpers.project_package_path(package.project, package)
end
expose :delete_api_path, if: can_destroy(:package, &:project) do |package|
expose_url api_v4_projects_packages_path(package_id: package.id, id: package.project_id)
end
end
expose :created_at
expose :project_id, if: ->(_, opts) { opts[:group] }
expose :project_path, if: ->(obj, opts) { opts[:group] && Ability.allowed?(opts[:user], :read_project, obj.project) }
expose :build_info, using: Package::BuildInfo
expose :tags
private
def project_path
object.project.full_path
end
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class Package < Grape::Entity
class BuildInfo < Grape::Entity
expose :pipeline, using: ::API::Entities::PipelineBasic
end
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class PackageFile < Grape::Entity
expose :id, :package_id, :created_at
expose :file_name, :size
expose :file_md5, :file_sha1
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class ProjectAlias < Grape::Entity
expose :id, :project_id, :name
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment