Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/bulk_import/client.rb')
-rw-r--r--lib/gitlab/bulk_import/client.rb72
1 files changed, 0 insertions, 72 deletions
diff --git a/lib/gitlab/bulk_import/client.rb b/lib/gitlab/bulk_import/client.rb
deleted file mode 100644
index c6e77a158cd..00000000000
--- a/lib/gitlab/bulk_import/client.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module BulkImport
- class Client
- API_VERSION = 'v4'.freeze
- DEFAULT_PAGE = 1.freeze
- DEFAULT_PER_PAGE = 30.freeze
-
- ConnectionError = Class.new(StandardError)
-
- def initialize(uri:, token:, page: DEFAULT_PAGE, per_page: DEFAULT_PER_PAGE, api_version: API_VERSION)
- @uri = URI.parse(uri)
- @token = token&.strip
- @page = page
- @per_page = per_page
- @api_version = api_version
- end
-
- def get(resource, query = {})
- response = with_error_handling do
- Gitlab::HTTP.get(
- resource_url(resource),
- headers: request_headers,
- follow_redirects: false,
- query: query.merge(request_query)
- )
- end
-
- response.parsed_response
- end
-
- private
-
- def request_query
- {
- page: @page,
- per_page: @per_page
- }
- end
-
- def request_headers
- {
- 'Content-Type' => 'application/json',
- 'Authorization' => "Bearer #{@token}"
- }
- end
-
- def with_error_handling
- response = yield
-
- raise ConnectionError.new("Error #{response.code}") unless response.success?
-
- response
- rescue *Gitlab::HTTP::HTTP_ERRORS => e
- raise ConnectionError, e
- end
-
- def base_uri
- @base_uri ||= "#{@uri.scheme}://#{@uri.host}:#{@uri.port}"
- end
-
- def api_url
- Gitlab::Utils.append_path(base_uri, "/api/#{@api_version}")
- end
-
- def resource_url(resource)
- Gitlab::Utils.append_path(api_url, resource)
- end
- end
- end
-end