Skip to content
Snippets Groups Projects

Expose project settings in REST API only for maintainer+ users

Merged Hinam Mehra requested to merge 442899-update-project-rest-api into master
All threads resolved!
+ 21
21
@@ -42,7 +42,6 @@ class Project < BasicProjectDetails
@@ -42,7 +42,6 @@ class Project < BasicProjectDetails
end
end
with_options if: -> (project, options) { Ability.allowed?(options[:current_user], :read_project, project) } do
with_options if: -> (project, options) { Ability.allowed?(options[:current_user], :read_project, project) } do
expose :empty_repo?, as: :empty_repo, documentation: { type: 'boolean' }
expose :archived?, as: :archived, documentation: { type: 'boolean' }
expose :archived?, as: :archived, documentation: { type: 'boolean' }
expose :visibility, documentation: { type: 'string', example: 'public' }
expose :visibility, documentation: { type: 'string', example: 'public' }
expose :owner, using: Entities::UserBasic, unless: ->(project, _) { project.group }
expose :owner, using: Entities::UserBasic, unless: ->(project, _) { project.group }
@@ -53,7 +52,7 @@ class Project < BasicProjectDetails
@@ -53,7 +52,7 @@ class Project < BasicProjectDetails
end
end
with_options if: -> (project, options) { Ability.allowed?(options[:current_user], :read_code, project) } do
with_options if: -> (project, options) { Ability.allowed?(options[:current_user], :read_code, project) } do
expose :ci_config_path, documentation: { type: 'string', example: '' }
expose :empty_repo?, as: :empty_repo, documentation: { type: 'boolean' }
expose(:can_create_merge_request_in, documentation: { type: 'boolean' }) do |project, options|
expose(:can_create_merge_request_in, documentation: { type: 'boolean' }) do |project, options|
Ability.allowed?(options[:current_user], :create_merge_request_in, project)
Ability.allowed?(options[:current_user], :create_merge_request_in, project)
end
end
@@ -91,10 +90,11 @@ class Project < BasicProjectDetails
@@ -91,10 +90,11 @@ class Project < BasicProjectDetails
end
end
# CI/CD Settings
# CI/CD Settings
 
expose :ci_config_path, documentation: { type: 'string', example: '' }
expose :ci_default_git_depth, documentation: { type: 'integer', example: 20 }
expose :ci_default_git_depth, documentation: { type: 'integer', example: 20 }
expose :ci_forward_deployment_enabled, documentation: { type: 'boolean' }
expose :ci_forward_deployment_enabled, documentation: { type: 'boolean' }
expose :ci_forward_deployment_rollback_allowed, documentation: { type: 'boolean' }
expose :ci_forward_deployment_rollback_allowed, documentation: { type: 'boolean' }
expose(:ci_job_token_scope_enabled, documentation: { type: 'boolean' }) { |p, _| p.ci_outbound_job_token_scope_enabled? }
expose :ci_outbound_job_token_scope_enabled?, as: :ci_outbound_job_token_scope_enabled, documentation: { type: 'boolean' }
expose :ci_separated_caches, documentation: { type: 'boolean' }
expose :ci_separated_caches, documentation: { type: 'boolean' }
expose :ci_allow_fork_pipelines_to_run_in_parent_project, documentation: { type: 'boolean' }
expose :ci_allow_fork_pipelines_to_run_in_parent_project, documentation: { type: 'boolean' }
expose :build_git_strategy, documentation: { type: 'string', example: 'fetch' } do |project, options|
expose :build_git_strategy, documentation: { type: 'string', example: 'fetch' } do |project, options|
@@ -151,24 +151,24 @@ class Project < BasicProjectDetails
@@ -151,24 +151,24 @@ class Project < BasicProjectDetails
expose(:container_registry_enabled, documentation: { type: 'boolean' }) { |project, options| project.feature_available?(:container_registry, options[:current_user]) }
expose(:container_registry_enabled, documentation: { type: 'boolean' }) { |project, options| project.feature_available?(:container_registry, options[:current_user]) }
# Visibility, project features, permissions settings
# Visibility, project features, permissions settings
expose(:issues_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :issues) }
expose(:issues_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :issues) }
expose(:repository_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :repository) }
expose(:repository_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :repository) }
expose(:merge_requests_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :merge_requests) }
expose(:merge_requests_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :merge_requests) }
expose(:forking_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :forking) }
expose(:forking_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :forking) }
expose(:wiki_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :wiki) }
expose(:wiki_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :wiki) }
expose(:builds_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :builds) }
expose(:builds_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :builds) }
expose(:snippets_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :snippets) }
expose(:snippets_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :snippets) }
expose(:pages_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :pages) }
expose(:pages_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :pages) }
expose(:analytics_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :analytics) }
expose(:analytics_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :analytics) }
expose(:container_registry_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :container_registry) }
expose(:container_registry_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :container_registry) }
expose(:security_and_compliance_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :security_and_compliance) }
expose(:security_and_compliance_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :security_and_compliance) }
expose(:releases_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :releases) }
expose(:releases_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :releases) }
expose(:environments_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :environments) }
expose(:environments_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :environments) }
expose(:feature_flags_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :feature_flags) }
expose(:feature_flags_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :feature_flags) }
expose(:infrastructure_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :infrastructure) }
expose(:infrastructure_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :infrastructure) }
expose(:monitor_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :monitor) }
expose(:monitor_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :monitor) }
expose(:model_experiments_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :model_experiments) }
expose(:model_experiments_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :model_experiments) }
expose(:model_registry_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :model_registry) }
expose(:model_registry_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, _| project_feature_string_access_level(project, :model_registry) }
end
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
Loading