class UniversalGitClient::Http::Gitlab
Public Instance Methods
branch(owner:, repo:, branch:)
click to toggle source
# File lib/universal-git-client/http/gitlab.rb, line 79 def branch(owner:, repo:, branch:) encoded_namespace = encode_namespace(owner, repo) encoded_branch = URI.encode_www_form_component(branch) with_response_validation! do self.class.get( "/projects/#{encoded_namespace}/repository/branches/#{encoded_branch}", default_options ) end end
branches(owner:, repo:, page: 1, per_page: nil)
click to toggle source
# File lib/universal-git-client/http/gitlab.rb, line 64 def branches(owner:, repo:, page: 1, per_page: nil) encoded_namespace = encode_namespace(owner, repo) with_response_validation! do self.class.get( "/projects/#{encoded_namespace}/repository/branches", default_options.merge( query: { page: page, per_page: per_page || default_elements_per_page, }, ) ) end end
delete_repo_webhook(owner:, repo:, webhook_id:)
click to toggle source
# File lib/universal-git-client/http/gitlab.rb, line 114 def delete_repo_webhook(owner:, repo:, webhook_id:) encoded_namespace = encode_namespace(owner, repo) with_response_validation! do self.class.delete( "/projects/#{encoded_namespace}/hooks/#{webhook_id}", default_options ) end end
download_repo_archive(owner:, repo:, branch: nil)
click to toggle source
# File lib/universal-git-client/http/gitlab.rb, line 90 def download_repo_archive(owner:, repo:, branch: nil) encoded_namespace = encode_namespace(owner, repo) path = "#{base_url}/projects/#{encoded_namespace}/repository/archive.zip" path << "?sha=#{branch}" if branch Down.download(path, down_default_options) end
orga_repos(organization:, page: 1, per_page: nil)
click to toggle source
# File lib/universal-git-client/http/gitlab.rb, line 42 def orga_repos(organization:, page: 1, per_page: nil) encoded_namespace = URI.encode_www_form_component(organization) with_response_validation! do self.class.get( "/groups/#{encoded_namespace}/projects", default_options.merge( query: { page: page, per_page: per_page || default_elements_per_page, }, ) ) end end
organizations(page: 1, per_page: nil)
click to toggle source
# File lib/universal-git-client/http/gitlab.rb, line 13 def organizations(page: 1, per_page: nil) with_response_validation! do self.class.get( '/groups', default_options.merge( query: { page: page, per_page: per_page || default_elements_per_page, }, ) ) end end
repository(owner:, repo:)
click to toggle source
# File lib/universal-git-client/http/gitlab.rb, line 57 def repository(owner:, repo:) encoded_namespace = encode_namespace(owner, repo) with_response_validation! do self.class.get("/projects/#{encoded_namespace}", default_options) end end
setup_repo_webhook(owner:, repo:, webhook_url:, webhook_secret: nil)
click to toggle source
# File lib/universal-git-client/http/gitlab.rb, line 97 def setup_repo_webhook(owner:, repo:, webhook_url:, webhook_secret: nil) encoded_namespace = encode_namespace(owner, repo) with_response_validation! do self.class.post( "/projects/#{encoded_namespace}/hooks", default_options.merge( body: { url: webhook_url, token: webhook_secret, push_events: true, enable_ssl_verification: true, }.compact.to_json, ) ) end end
user()
click to toggle source
# File lib/universal-git-client/http/gitlab.rb, line 7 def user with_response_validation! do self.class.get('/user', default_options) end end
user_repos(page: 1, per_page: nil)
click to toggle source
# File lib/universal-git-client/http/gitlab.rb, line 27 def user_repos(page: 1, per_page: nil) current_user_id = self.user['id'] with_response_validation! do self.class.get( "/users/#{current_user_id}/projects", default_options.merge( query: { page: page, per_page: per_page || default_elements_per_page, }, ) ) end end
Private Instance Methods
encode_namespace(owner, repo)
click to toggle source
# File lib/universal-git-client/http/gitlab.rb, line 126 def encode_namespace(owner, repo) URI.encode_www_form_component("#{owner}/#{repo}") end