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/api/helpers/import_github_helpers.rb')
-rw-r--r--lib/api/helpers/import_github_helpers.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/api/helpers/import_github_helpers.rb b/lib/api/helpers/import_github_helpers.rb
new file mode 100644
index 00000000000..1634e064d73
--- /dev/null
+++ b/lib/api/helpers/import_github_helpers.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+module API
+ module Helpers
+ module ImportGithubHelpers
+ def client
+ @client ||= Gitlab::GithubImport::Client.new(params[:personal_access_token], host: params[:github_hostname])
+ end
+
+ def access_params
+ {
+ github_access_token: params[:personal_access_token],
+ additional_access_tokens: params[:additional_access_tokens]
+ }
+ end
+
+ def provider
+ :github
+ end
+
+ def provider_unauthorized
+ error!("Access denied to your #{Gitlab::ImportSources.title(provider.to_s)} account.", 401)
+ end
+
+ def too_many_requests
+ error!('Too Many Requests', 429)
+ end
+ end
+ end
+end