diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-06 12:08:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-06 12:08:56 +0300 |
commit | 0dce1c285f8d6487daf4b83be1ca9585e3a084e6 (patch) | |
tree | f617aa00d3994c2733baaed0205dba0d3bc0413d /lib/bulk_imports/clients | |
parent | eefbee4451565989727256d36176dc2950e3a0b7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/bulk_imports/clients')
-rw-r--r-- | lib/bulk_imports/clients/http.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/bulk_imports/clients/http.rb b/lib/bulk_imports/clients/http.rb index 39f56fcc114..2e81863e53a 100644 --- a/lib/bulk_imports/clients/http.rb +++ b/lib/bulk_imports/clients/http.rb @@ -18,7 +18,7 @@ module BulkImports end def get(resource, query = {}) - response = with_error_handling do + with_error_handling do Gitlab::HTTP.get( resource_url(resource), headers: request_headers, @@ -26,8 +26,22 @@ module BulkImports query: query.merge(request_query) ) end + end + + def each_page(method, resource, query = {}, &block) + return to_enum(__method__, method, resource, query) unless block_given? + + next_page = @page - response.parsed_response + while next_page + @page = next_page.to_i + + response = self.public_send(method, resource, query) # rubocop: disable GitlabSecurity/PublicSend + collection = response.parsed_response + next_page = response.headers['x-next-page'].presence + + yield collection + end end private |