summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2018-07-18 21:58:49 +0300
committerValery Sizov <valery@gitlab.com>2018-07-18 21:58:49 +0300
commit4adba01c1c6c51a22343b102b952248afa01cbe5 (patch)
tree140d05defa268045f916f4eca8fee8d2ff7e2a2a
parent1df32177a8dfd0f1f948a48ee9cf87ba74f43417 (diff)
downloadgitlab-ce-5594-geo-add-repository-verification-failures-to-api.tar.gz
Backport of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/61375594-geo-add-repository-verification-failures-to-api
-rw-r--r--doc/api/projects.md2
-rw-r--r--lib/api/projects.rb23
2 files changed, 22 insertions, 3 deletions
diff --git a/doc/api/projects.md b/doc/api/projects.md
index a35c2a56992..5d0dbbadb3c 100644
--- a/doc/api/projects.md
+++ b/doc/api/projects.md
@@ -55,6 +55,8 @@ GET /projects
| `with_custom_attributes` | boolean | no | Include [custom attributes](custom_attributes.md) in response (admins only) |
| `with_issues_enabled` | boolean | no | Limit by enabled issues feature |
| `with_merge_requests_enabled` | boolean | no | Limit by enabled merge requests feature |
+| `wiki_checksum_failed` | boolean | no | Limit projects where the wiki checksum calculation has failed. Only available in GitLab EE with Geo enabled |
+| `repository_checksum_failed` | boolean | no | Limit projects where the repository checksum calculation has failed. Only available in GitLab EE with Geo enabled |
When `simple=true` or the user is unauthenticated this returns something like:
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 0888e3befac..dd79ead5aae 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -9,6 +9,23 @@ module API
before { authenticate_non_get! }
helpers do
+ params :optional_filter_params_ee do
+ # EE::API::Projects would override this helper
+ end
+
+ # EE::API::Projects would override this method
+ def apply_filters(projects)
+ projects = projects.with_issues_available_for_user(current_user) if params[:with_issues_enabled]
+ projects = projects.with_merge_requests_enabled if params[:with_merge_requests_enabled]
+ projects = projects.with_statistics if params[:statistics]
+
+ projects
+ end
+ end
+
+ prepend EE::API::Projects
+
+ helpers do
params :statistics_params do
optional :statistics, type: Boolean, default: false, desc: 'Include project statistics'
end
@@ -39,6 +56,8 @@ module API
optional :membership, type: Boolean, default: false, desc: 'Limit by projects that the current user is a member of'
optional :with_issues_enabled, type: Boolean, default: false, desc: 'Limit by enabled issues feature'
optional :with_merge_requests_enabled, type: Boolean, default: false, desc: 'Limit by enabled merge requests feature'
+
+ use :optional_filter_params_ee
end
params :create_params do
@@ -52,9 +71,7 @@ module API
def present_projects(projects, options = {})
projects = reorder_projects(projects)
- projects = projects.with_issues_available_for_user(current_user) if params[:with_issues_enabled]
- projects = projects.with_merge_requests_enabled if params[:with_merge_requests_enabled]
- projects = projects.with_statistics if params[:statistics]
+ projects = apply_filters(projects)
projects = paginate(projects)
projects, options = with_custom_attributes(projects, options)