Commit 952f8863 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'refactoring-ee-entities-7' into 'master'

Separate geo_node and license entities into own class files

See merge request gitlab-org/gitlab!26685
parents fb67968c 0c8e4aca
---
title: Separate geo_node and license entities into own class file
merge_request: 26685
author: Rajendra Kadam
type: added
......@@ -412,86 +412,6 @@ module EE
end
end
class LdapGroup < Grape::Entity
expose :cn
end
class GitlabLicense < Grape::Entity
expose :id,
:plan,
:created_at,
:starts_at,
:expires_at,
:historical_max,
:maximum_user_count,
:licensee,
:add_ons
expose :expired?, as: :expired
expose :overage do |license, options|
license.expired? ? license.overage_with_historical_max : license.overage(options[:current_active_users_count])
end
expose :user_limit do |license, options|
license.restricted?(:active_user_count) ? license.restrictions[:active_user_count] : 0
end
end
class GitlabLicenseWithActiveUsers < GitlabLicense
expose :active_users do |license, options|
::User.active.count
end
end
class GeoNode < Grape::Entity
include ::API::Helpers::RelatedResourcesHelpers
expose :id
expose :name
expose :url
expose :internal_url
expose :primary?, as: :primary
expose :enabled
expose :current?, as: :current
expose :files_max_capacity
expose :repos_max_capacity
expose :verification_max_capacity
expose :container_repositories_max_capacity
expose :selective_sync_type
expose :selective_sync_shards
expose :namespace_ids, as: :selective_sync_namespace_ids
expose :minimum_reverification_interval
expose :sync_object_storage, if: ->(geo_node, _) { geo_node.secondary? }
# Retained for backwards compatibility. Remove in API v5
expose :clone_protocol do |_record, _options|
'http'
end
expose :web_edit_url do |geo_node|
::Gitlab::Routing.url_helpers.edit_admin_geo_node_url(geo_node)
end
expose :web_geo_projects_url, if: ->(geo_node, _) { geo_node.secondary? } do |geo_node|
geo_node.geo_projects_url
end
expose :_links do
expose :self do |geo_node|
expose_url api_v4_geo_nodes_path(id: geo_node.id)
end
expose :status do |geo_node|
expose_url api_v4_geo_nodes_status_path(id: geo_node.id)
end
expose :repair do |geo_node|
expose_url api_v4_geo_nodes_repair_path(id: geo_node.id)
end
end
end
module ConanPackage
class ConanPackageManifest < Grape::Entity
expose :package_urls, merge: true
......
# frozen_string_literal: true
module EE
module API
module Entities
class GeoNode < Grape::Entity
include ::API::Helpers::RelatedResourcesHelpers
expose :id
expose :name
expose :url
expose :internal_url
expose :primary?, as: :primary
expose :enabled
expose :current?, as: :current
expose :files_max_capacity
expose :repos_max_capacity
expose :verification_max_capacity
expose :container_repositories_max_capacity
expose :selective_sync_type
expose :selective_sync_shards
expose :namespace_ids, as: :selective_sync_namespace_ids
expose :minimum_reverification_interval
expose :sync_object_storage, if: ->(geo_node, _) { geo_node.secondary? }
# Retained for backwards compatibility. Remove in API v5
expose :clone_protocol do |_record, _options|
'http'
end
expose :web_edit_url do |geo_node|
::Gitlab::Routing.url_helpers.edit_admin_geo_node_url(geo_node)
end
expose :web_geo_projects_url, if: ->(geo_node, _) { geo_node.secondary? } do |geo_node|
geo_node.geo_projects_url
end
expose :_links do
expose :self do |geo_node|
expose_url api_v4_geo_nodes_path(id: geo_node.id)
end
expose :status do |geo_node|
expose_url api_v4_geo_nodes_status_path(id: geo_node.id)
end
expose :repair do |geo_node|
expose_url api_v4_geo_nodes_repair_path(id: geo_node.id)
end
end
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class GitlabLicense < Grape::Entity
expose :id,
:plan,
:created_at,
:starts_at,
:expires_at,
:historical_max,
:maximum_user_count,
:licensee,
:add_ons
expose :expired?, as: :expired
expose :overage do |license, options|
license.expired? ? license.overage_with_historical_max : license.overage(options[:current_active_users_count])
end
expose :user_limit do |license, options|
license.restricted?(:active_user_count) ? license.restrictions[:active_user_count] : 0
end
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class GitlabLicenseWithActiveUsers < GitlabLicense
expose :active_users do |license, options|
::User.active.count
end
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class LdapGroup < Grape::Entity
expose :cn
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