debian-mirror-gitlab/lib/api/entities/namespace.rb

18 lines
627 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module API
module Entities
class Namespace < Entities::NamespaceBasic
2023-03-04 22:38:38 +05:30
expose :members_count_with_descendants, documentation: { type: 'integer', example: 5 }, if: -> (namespace, opts) { expose_members_count_with_descendants?(namespace, opts) } do |namespace, _|
2020-03-13 15:44:24 +05:30
namespace.users_with_descendants.count
end
def expose_members_count_with_descendants?(namespace, opts)
namespace.kind == 'group' && Ability.allowed?(opts[:current_user], :admin_group, namespace)
end
end
end
end
2021-06-08 01:23:25 +05:30
API::Entities::Namespace.prepend_mod_with('API::Entities::Namespace')