class StashCLI::Client
Constants
- BASE_API_URL
Attributes
resource[R]
server[R]
Public Class Methods
new(server, auth_token)
click to toggle source
# File lib/stash_cli/client.rb, line 14 def initialize(server, auth_token) @server = URI(server) @resource = RestClient::Resource.new( File.join(@server.to_s, BASE_API_URL), headers: { authorization: "Basic #{auth_token}", accept: :json, content_type: :json }) end
Public Instance Methods
branches(project, slug)
click to toggle source
# File lib/stash_cli/client.rb, line 35 def branches(project, slug) response = resource["projects/#{project}/repos/#{slug}/branches?limit=1000"].get JSON.parse(response.body) end
pull_request(options={})
click to toggle source
# File lib/stash_cli/client.rb, line 40 def pull_request(options={}) params = { title: options[:title], fromRef: { id: "refs/heads/#{options[:from_branch]}", repository: { slug: options[:from_slug], project: { key: options[:project] } } }, toRef: { id: "refs/heads/#{options[:target_branch]}", repository: { slug: options[:target_slug], project: { key: options[:project] } } }, reviewers: [] } if options[:reviewers].any? params[:reviewers] = options[:reviewers].map do |name| { user: { name: name } } end end params[:description] = options[:description] if options[:description] path = "projects/#{options[:project]}/repos/#{options[:target_slug]}/pull-requests" response = resource[path].post(params.to_json) PullRequest.from_response(JSON.parse(response.body), server.to_s) end
repositories(project)
click to toggle source
# File lib/stash_cli/client.rb, line 30 def repositories(project) response = resource["projects/#{project}/repos?limit=1000"].get JSON.parse(response.body) end
users()
click to toggle source
# File lib/stash_cli/client.rb, line 25 def users response = resource['users?limit=1000'].get JSON.parse(response.body)['values'] end