Class: BitbucketServer::Client
- Inherits:
-
Object
- Object
- BitbucketServer::Client
- Defined in:
- lib/bitbucket_server/client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #activities(project_key, repo, pull_request_id) ⇒ Object
- #create_branch(project_key, repo, branch_name, sha) ⇒ Object
- #delete_branch(project_key, repo, branch_name, sha) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #pull_requests(project_key, repo, page_offset: 0, limit: nil) ⇒ Object
- #repo(project, repo_name) ⇒ Object
- #repos(page_offset: 0, limit: nil, filter: nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 |
# File 'lib/bitbucket_server/client.rb', line 7 def initialize( = {}) @connection = Connection.new() end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/bitbucket_server/client.rb', line 5 def connection @connection end |
Instance Method Details
#activities(project_key, repo, pull_request_id) ⇒ Object
16 17 18 19 |
# File 'lib/bitbucket_server/client.rb', line 16 def activities(project_key, repo, pull_request_id) path = "/projects/#{project_key}/repos/#{repo}/pull-requests/#{pull_request_id}/activities" get_collection(path, :activity) end |
#create_branch(project_key, repo, branch_name, sha) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/bitbucket_server/client.rb', line 32 def create_branch(project_key, repo, branch_name, sha) payload = { name: branch_name, startPoint: sha, message: 'GitLab temporary branch for import' } connection.post("/projects/#{project_key}/repos/#{repo}/branches", payload.to_json) end |
#delete_branch(project_key, repo, branch_name, sha) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/bitbucket_server/client.rb', line 42 def delete_branch(project_key, repo, branch_name, sha) payload = { name: Gitlab::Git::BRANCH_REF_PREFIX + branch_name, dryRun: false } connection.delete(:branches, "/projects/#{project_key}/repos/#{repo}/branches", payload.to_json) end |
#pull_requests(project_key, repo, page_offset: 0, limit: nil) ⇒ Object
11 12 13 14 |
# File 'lib/bitbucket_server/client.rb', line 11 def pull_requests(project_key, repo, page_offset: 0, limit: nil) path = "/projects/#{project_key}/repos/#{repo}/pull-requests?state=ALL" get_collection(path, :pull_request, page_offset: page_offset, limit: limit) end |
#repo(project, repo_name) ⇒ Object
21 22 23 24 |
# File 'lib/bitbucket_server/client.rb', line 21 def repo(project, repo_name) parsed_response = connection.get("/projects/#{project}/repos/#{repo_name}") BitbucketServer::Representation::Repo.new(parsed_response) end |
#repos(page_offset: 0, limit: nil, filter: nil) ⇒ Object
26 27 28 29 30 |
# File 'lib/bitbucket_server/client.rb', line 26 def repos(page_offset: 0, limit: nil, filter: nil) path = "/repos" path += "?name=#{filter}" if filter get_collection(path, :repo, page_offset: page_offset, limit: limit) end |