File: group.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (60 lines) | stat: -rw-r--r-- 2,298 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true

module API
  module Entities
    class Group < BasicGroupDetails
      expose :path, :description, :visibility
      expose :share_with_group_lock
      expose :require_two_factor_authentication
      expose :two_factor_grace_period
      expose :project_creation_level_str, as: :project_creation_level
      expose :auto_devops_enabled
      expose :subgroup_creation_level_str, as: :subgroup_creation_level
      expose(:emails_disabled, documentation: { type: 'boolean' }) { |group, options| group.emails_disabled? }
      expose :emails_enabled, documentation: { type: 'boolean' }
      expose :mentions_disabled
      expose :lfs_enabled?, as: :lfs_enabled
      expose :math_rendering_limits_enabled, documentation: { type: 'boolean' }
      expose :lock_math_rendering_limits_enabled, documentation: { type: 'boolean' }
      expose :default_branch_name, as: :default_branch
      expose :default_branch_protection
      expose :default_branch_protection_settings, as: :default_branch_protection_defaults
      expose :avatar_url do |group, options|
        group.avatar_url(only_path: false)
      end
      expose :request_access_enabled
      expose :full_name, :full_path
      expose :created_at
      expose :parent_id
      expose :organization_id
      expose :shared_runners_setting

      expose :custom_attributes, using: 'API::Entities::CustomAttribute', if: :with_custom_attributes

      expose :statistics, if: :statistics do
        with_options format_with: ->(value) { value.to_i } do
          expose :storage_size
          expose :repository_size
          expose :wiki_size
          expose :lfs_objects_size
          expose :build_artifacts_size, as: :job_artifacts_size
          expose :pipeline_artifacts_size
          expose :packages_size
          expose :snippets_size
          expose :uploads_size
        end
      end

      expose :root_storage_statistics, using: Entities::Namespace::RootStorageStatistics,
        if: ->(group, opts) {
              expose_root_storage_statistics?(group, opts)
            }

      def expose_root_storage_statistics?(group, opts)
        opts[:statistics] && group.root?
      end
    end
  end
end

API::Entities::Group.prepend_mod_with('API::Entities::Group', with_descendants: true)