debian-mirror-gitlab/lib/api/admin/plan_limits.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

89 lines
4.1 KiB
Ruby
Raw Normal View History

2021-04-17 20:07:23 +05:30
# frozen_string_literal: true
module API
module Admin
class PlanLimits < ::API::Base
before { authenticated_as_admin! }
2023-01-13 00:05:48 +05:30
PLAN_LIMITS_TAGS = %w[plan_limits].freeze
2022-06-21 17:19:12 +05:30
feature_category :not_owned # rubocop:todo Gitlab/AvoidFeatureCategoryNotOwned
2021-04-17 20:07:23 +05:30
helpers do
def current_plan(name)
plan = ::Admin::PlansFinder.new({ name: name }).execute
not_found!('Plan') unless plan
plan
end
end
desc 'Get current plan limits' do
2023-01-13 00:05:48 +05:30
detail 'List the current limits of a plan on the GitLab instance.'
2021-04-17 20:07:23 +05:30
success Entities::PlanLimit
2023-01-13 00:05:48 +05:30
failure [
{ code: 401, message: 'Unauthorized' },
{ code: 403, message: 'Forbidden' }
]
tags PLAN_LIMITS_TAGS
2021-04-17 20:07:23 +05:30
end
params do
2023-01-13 00:05:48 +05:30
optional :plan_name, type: String, values: Plan.all_plans, default: Plan::DEFAULT,
desc: 'Name of the plan to get the limits from. Default: default.'
2021-04-17 20:07:23 +05:30
end
get "application/plan_limits" do
params = declared_params(include_missing: false)
plan = current_plan(params.delete(:plan_name))
present plan.actual_limits, with: Entities::PlanLimit
end
2023-01-13 00:05:48 +05:30
desc 'Change plan limits' do
detail 'Modify the limits of a plan on the GitLab instance.'
2021-04-17 20:07:23 +05:30
success Entities::PlanLimit
2023-01-13 00:05:48 +05:30
failure [
{ code: 400, message: 'Bad request' },
{ code: 401, message: 'Unauthorized' },
{ code: 403, message: 'Forbidden' }
]
tags PLAN_LIMITS_TAGS
2021-04-17 20:07:23 +05:30
end
params do
2023-01-13 00:05:48 +05:30
requires :plan_name, type: String, values: Plan.all_plans, desc: 'Name of the plan to update'
2021-04-17 20:07:23 +05:30
2022-07-16 23:28:13 +05:30
optional :ci_pipeline_size, type: Integer, desc: 'Maximum number of jobs in a single pipeline'
optional :ci_active_jobs, type: Integer, desc: 'Total number of jobs in currently active pipelines'
optional :ci_active_pipelines, type: Integer, desc: 'Maximum number of active pipelines per project'
2023-01-13 00:05:48 +05:30
optional :ci_project_subscriptions, type: Integer,
desc: 'Maximum number of pipeline subscriptions to and from a project'
2022-07-16 23:28:13 +05:30
optional :ci_pipeline_schedules, type: Integer, desc: 'Maximum number of pipeline schedules'
optional :ci_needs_size_limit, type: Integer, desc: 'Maximum number of DAG dependencies that a job can have'
optional :ci_registered_group_runners, type: Integer, desc: 'Maximum number of runners registered per group'
optional :ci_registered_project_runners, type: Integer, desc: 'Maximum number of runners registered per project'
2021-04-17 20:07:23 +05:30
optional :conan_max_file_size, type: Integer, desc: 'Maximum Conan package file size in bytes'
optional :generic_packages_max_file_size, type: Integer, desc: 'Maximum generic package file size in bytes'
2022-01-26 12:08:38 +05:30
optional :helm_max_file_size, type: Integer, desc: 'Maximum Helm chart file size in bytes'
2021-04-17 20:07:23 +05:30
optional :maven_max_file_size, type: Integer, desc: 'Maximum Maven package file size in bytes'
optional :npm_max_file_size, type: Integer, desc: 'Maximum NPM package file size in bytes'
optional :nuget_max_file_size, type: Integer, desc: 'Maximum NuGet package file size in bytes'
optional :pypi_max_file_size, type: Integer, desc: 'Maximum PyPI package file size in bytes'
2023-01-13 00:05:48 +05:30
optional :terraform_module_max_file_size, type: Integer,
desc: 'Maximum Terraform Module package file size in bytes'
2022-07-16 23:28:13 +05:30
optional :storage_size_limit, type: Integer, desc: 'Maximum storage size for the root namespace in megabytes'
2023-03-04 22:38:38 +05:30
optional :pipeline_hierarchy_size, type: Integer,
desc: "Maximum number of downstream pipelines in a pipeline's hierarchy tree"
2021-04-17 20:07:23 +05:30
end
put "application/plan_limits" do
params = declared_params(include_missing: false)
plan = current_plan(params.delete(:plan_name))
if plan.actual_limits.update(params)
present plan.actual_limits, with: Entities::PlanLimit
else
render_validation_error!(plan.actual_limits)
end
end
end
end
end