gitlab 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. data/.gitignore +17 -0
  2. data/.travis.yml +2 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +24 -0
  5. data/README.md +64 -0
  6. data/Rakefile +9 -0
  7. data/gitlab.gemspec +25 -0
  8. data/lib/gitlab.rb +29 -0
  9. data/lib/gitlab/api.rb +17 -0
  10. data/lib/gitlab/client.rb +13 -0
  11. data/lib/gitlab/client/issues.rb +69 -0
  12. data/lib/gitlab/client/milestones.rb +59 -0
  13. data/lib/gitlab/client/projects.rb +155 -0
  14. data/lib/gitlab/client/repositories.rb +67 -0
  15. data/lib/gitlab/client/snippets.rb +64 -0
  16. data/lib/gitlab/client/users.rb +89 -0
  17. data/lib/gitlab/configuration.rb +38 -0
  18. data/lib/gitlab/error.rb +33 -0
  19. data/lib/gitlab/objectified_hash.rb +18 -0
  20. data/lib/gitlab/request.rb +73 -0
  21. data/lib/gitlab/version.rb +3 -0
  22. data/spec/fixtures/issue.json +1 -0
  23. data/spec/fixtures/issues.json +1 -0
  24. data/spec/fixtures/key.json +1 -0
  25. data/spec/fixtures/keys.json +1 -0
  26. data/spec/fixtures/milestone.json +1 -0
  27. data/spec/fixtures/milestones.json +1 -0
  28. data/spec/fixtures/project.json +1 -0
  29. data/spec/fixtures/project_branch.json +1 -0
  30. data/spec/fixtures/project_branches.json +1 -0
  31. data/spec/fixtures/project_commits.json +1 -0
  32. data/spec/fixtures/project_hook.json +1 -0
  33. data/spec/fixtures/project_hooks.json +1 -0
  34. data/spec/fixtures/project_issues.json +1 -0
  35. data/spec/fixtures/project_tags.json +1 -0
  36. data/spec/fixtures/projects.json +1 -0
  37. data/spec/fixtures/session.json +1 -0
  38. data/spec/fixtures/snippet.json +1 -0
  39. data/spec/fixtures/team_member.json +1 -0
  40. data/spec/fixtures/team_members.json +1 -0
  41. data/spec/fixtures/user.json +1 -0
  42. data/spec/fixtures/users.json +1 -0
  43. data/spec/gitlab/client/issues_spec.rb +88 -0
  44. data/spec/gitlab/client/milestones_spec.rb +66 -0
  45. data/spec/gitlab/client/projects_spec.rb +177 -0
  46. data/spec/gitlab/client/repositories_spec.rb +73 -0
  47. data/spec/gitlab/client/snippets_spec.rb +69 -0
  48. data/spec/gitlab/client/users_spec.rb +129 -0
  49. data/spec/gitlab_spec.rb +49 -0
  50. data/spec/spec_helper.rb +63 -0
  51. metadata +194 -0
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,2 @@
1
+ language: ruby
2
+ rvm: 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gitlab.gemspec
4
+ gemspec
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2012 Nihad Abbasov / NARKOZ
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24
+ POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,64 @@
1
+ # Gitlab
2
+
3
+ Gitlab is a Ruby wrapper for the [GitLab API](https://github.com/gitlabhq/gitlabhq/tree/master/doc/api#gitlab-api).
4
+
5
+ ## Installation
6
+
7
+ Install it from rubygems:
8
+
9
+ ```sh
10
+ gem install gitlab
11
+ ```
12
+
13
+ Or add to a Gemfile:
14
+
15
+ ```ruby
16
+ gem 'gitlab'
17
+ # gem 'gitlab', :git => 'git://github.com/NARKOZ/gitlab.git'
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ Configuration example:
23
+
24
+ ```ruby
25
+ Gitlab.configure do |config|
26
+ config.endpoint = 'https://example.net/api/v2' # API endpoint URL (required)
27
+ config.private_token = 'qEsq1pt6HJPaNciie3MG' # user's private token (required)
28
+ config.user_agent = 'Custom User Agent' # user agent, default to 'Gitlab Ruby Gem [version]' (optional)
29
+ end
30
+ ```
31
+
32
+ Usage examples:
33
+
34
+ ```ruby
35
+ # set an API endpoint
36
+ Gitlab.endpoint = 'http://example.net/api/v2'
37
+ # => "http://example.net/api/v2"
38
+
39
+ # set a user private token
40
+ Gitlab.private_token = 'qEsq1pt6HJPaNciie3MG'
41
+ # => "qEsq1pt6HJPaNciie3MG"
42
+
43
+ # list projects
44
+ Gitlab.projects(:per_page => 5)
45
+ # => [#<Gitlab::ObjectifiedHash:0x000000023326e0 @data={"id"=>1, "code"=>"brute", "name"=>"Brute", "description"=>nil, "path"=>"brute", "default_branch"=>nil, "owner"=>#<Gitlab::ObjectifiedHash:0x00000002331600 @data={"id"=>1, "email"=>"john@example.com", "name"=>"John Smith", "blocked"=>false, "created_at"=>"2012-09-17T09:41:56Z"}>, "private"=>true, "issues_enabled"=>true, "merge_requests_enabled"=>true, "wall_enabled"=>true, "wiki_enabled"=>true, "created_at"=>"2012-09-17T09:41:56Z"}>, #<Gitlab::ObjectifiedHash:0x000000023450d8 @data={"id"=>2, "code"=>"mozart", "name"=>"Mozart", "description"=>nil, "path"=>"mozart", "default_branch"=>nil, "owner"=>#<Gitlab::ObjectifiedHash:0x00000002344ca0 @data={"id"=>1, "email"=>"john@example.com", "name"=>"John Smith", "blocked"=>false, "created_at"=>"2012-09-17T09:41:56Z"}>, "private"=>true, "issues_enabled"=>true, "merge_requests_enabled"=>true, "wall_enabled"=>true, "wiki_enabled"=>true, "created_at"=>"2012-09-17T09:41:57Z"}>, #<Gitlab::ObjectifiedHash:0x00000002344958 @data={"id"=>3, "code"=>"gitlab", "name"=>"Gitlab", "description"=>nil, "path"=>"gitlab", "default_branch"=>nil, "owner"=>#<Gitlab::ObjectifiedHash:0x000000023447a0 @data={"id"=>1, "email"=>"john@example.com", "name"=>"John Smith", "blocked"=>false, "created_at"=>"2012-09-17T09:41:56Z"}>, "private"=>true, "issues_enabled"=>true, "merge_requests_enabled"=>true, "wall_enabled"=>true, "wiki_enabled"=>true, "created_at"=>"2012-09-17T09:41:58Z"}>]
46
+
47
+ # initialize a new client
48
+ g = Gitlab.client(:endpoint => 'https://api.example.com', :private_token => 'qEsq1pt6HJPaNciie3MG')
49
+ # => #<Gitlab::Client:0x00000001e62408 @endpoint="https://api.example.com", @private_token="qEsq1pt6HJPaNciie3MG", @user_agent="Gitlab Ruby Gem 2.0.0">
50
+
51
+ # get a user
52
+ user = g.user
53
+ # => #<Gitlab::ObjectifiedHash:0x00000002217990 @data={"id"=>1, "email"=>"john@example.com", "name"=>"John Smith", "bio"=>nil, "skype"=>"", "linkedin"=>"", "twitter"=>"john", "dark_scheme"=>false, "theme_id"=>1, "blocked"=>false, "created_at"=>"2012-09-17T09:41:56Z"}>
54
+
55
+ # get a user's email
56
+ user.email
57
+ # => "john@example.com"
58
+ ```
59
+
60
+ For more information, refer to [documentation](http://rubydoc.info/gems/gitlab/frames).
61
+
62
+ ## License
63
+
64
+ Released under the BSD 2-clause license. See LICENSE.txt for details.
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec) do |spec|
5
+ spec.pattern = FileList['spec/**/*_spec.rb']
6
+ spec.rspec_opts = ['--color', '--format d']
7
+ end
8
+
9
+ task :default => :spec
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gitlab/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "gitlab"
8
+ gem.version = Gitlab::VERSION
9
+ gem.authors = ["Nihad Abbasov"]
10
+ gem.email = ["mail@narkoz.me"]
11
+ gem.description = %q{Ruby client for GitLab API}
12
+ gem.summary = %q{A Ruby wrapper for the GitLab API}
13
+ gem.homepage = "https://github.com/narkoz/gitlab"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_runtime_dependency 'httparty'
21
+
22
+ gem.add_development_dependency 'rake'
23
+ gem.add_development_dependency 'rspec'
24
+ gem.add_development_dependency 'webmock'
25
+ end
@@ -0,0 +1,29 @@
1
+ require File.expand_path('../gitlab/version', __FILE__)
2
+ require File.expand_path('../gitlab/objectified_hash', __FILE__)
3
+ require File.expand_path('../gitlab/configuration', __FILE__)
4
+ require File.expand_path('../gitlab/error', __FILE__)
5
+ require File.expand_path('../gitlab/request', __FILE__)
6
+ require File.expand_path('../gitlab/api', __FILE__)
7
+ require File.expand_path('../gitlab/client', __FILE__)
8
+
9
+ module Gitlab
10
+ extend Configuration
11
+
12
+ # Alias for Gitlab::Client.new
13
+ #
14
+ # @return [Gitlab::Client]
15
+ def self.client(options={})
16
+ Gitlab::Client.new(options)
17
+ end
18
+
19
+ # Delegate to Gitlab::Client
20
+ def self.method_missing(method, *args, &block)
21
+ return super unless client.respond_to?(method)
22
+ client.send(method, *args, &block)
23
+ end
24
+
25
+ # Delegate to Gitlab::Client
26
+ def self.respond_to?(method)
27
+ return client.respond_to?(method) || super
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ module Gitlab
2
+ # @private
3
+ class API < Request
4
+ # @private
5
+ attr_accessor *Configuration::VALID_OPTIONS_KEYS
6
+
7
+ # Creates a new API.
8
+ # @raise [Error:MissingCredentials]
9
+ def initialize(options={})
10
+ options = Gitlab.options.merge(options)
11
+ Configuration::VALID_OPTIONS_KEYS.each do |key|
12
+ send("#{key}=", options[key])
13
+ end
14
+ set_request_defaults @endpoint, @private_token
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ module Gitlab
2
+ # Wrapper for the Gitlab REST API.
3
+ class Client < API
4
+ Dir[File.expand_path('../client/*.rb', __FILE__)].each{|f| require f}
5
+
6
+ include Gitlab::Client::Users
7
+ include Gitlab::Client::Issues
8
+ include Gitlab::Client::Milestones
9
+ include Gitlab::Client::Snippets
10
+ include Gitlab::Client::Projects
11
+ include Gitlab::Client::Repositories
12
+ end
13
+ end
@@ -0,0 +1,69 @@
1
+ class Gitlab::Client
2
+ # Defines methods related to issues.
3
+ module Issues
4
+ # Gets a list of user's issues.
5
+ # Will return a list of project's issues if project ID or code name passed.
6
+ #
7
+ # @example
8
+ # Gitlab.issues
9
+ # Gitlab.issues(5)
10
+ # Gitlab.issues('gitlab', :per_page => 40)
11
+ #
12
+ # @param [Integer, String] project The ID or code name of a project.
13
+ # @param [Hash] options A customizable set of options.
14
+ # @option options [Integer] :page The page number.
15
+ # @option options [Integer] :per_page The number of results per page.
16
+ # @return [Array<Gitlab::ObjectifiedHash>]
17
+ def issues(project=nil, options={})
18
+ if project.to_i.zero?
19
+ get("/issues", :query => options)
20
+ else
21
+ get("/projects/#{project}/issues", :query => options)
22
+ end
23
+ end
24
+
25
+ # Gets a single issue.
26
+ #
27
+ # @example
28
+ # Gitlab.issue(5, 36)
29
+ # Gitlab.issue('gitlab', 42)
30
+ #
31
+ # @param [Integer, String] project The ID or code name of a project.
32
+ # @param [Integer] id The ID of an issue.
33
+ # @return [Array<Gitlab::ObjectifiedHash>]
34
+ def issue(project, id)
35
+ get("/projects/#{project}/issues/#{id}")
36
+ end
37
+
38
+ # Creates a new issue.
39
+ #
40
+ # @param [Integer, String] project The ID or code name of a project.
41
+ # @param [String] title The title of an issue.
42
+ # @param [Hash] options A customizable set of options.
43
+ # @option options [String] :description The description of an issue.
44
+ # @option options [Integer] :assignee_id The ID of a user to assign issue.
45
+ # @option options [Integer] :milestone_id The ID of a milestone to assign issue.
46
+ # @option options [String] :labels Comma-separated label names for an issue.
47
+ # @return [Gitlab::ObjectifiedHash] Information about created issue.
48
+ def create_issue(project, title, options={})
49
+ body = {:title => title}.merge(options)
50
+ post("/projects/#{project}/issues", :body => body)
51
+ end
52
+
53
+ # Updates an issue.
54
+ #
55
+ # @param [Integer, String] project The ID or code name of a project.
56
+ # @param [Integer] id The ID of an issue.
57
+ # @param [Hash] options A customizable set of options.
58
+ # @option options [String] :title The title of an issue.
59
+ # @option options [String] :description The description of an issue.
60
+ # @option options [Integer] :assignee_id The ID of a user to assign issue.
61
+ # @option options [Integer] :milestone_id The ID of a milestone to assign issue.
62
+ # @option options [String] :labels Comma-separated label names for an issue.
63
+ # @option options [Boolean] :closed The state of an issue (0 = false, 1 = true).
64
+ # @return [Gitlab::ObjectifiedHash] Information about updated issue.
65
+ def edit_issue(project, id, options={})
66
+ put("/projects/#{project}/issues/#{id}", :body => options)
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,59 @@
1
+ class Gitlab::Client
2
+ # Defines methods related to milestones.
3
+ module Milestones
4
+ # Gets a list of project's milestones.
5
+ #
6
+ # @example
7
+ # Gitlab.milestones(5)
8
+ # Gitlab.milestones('gitlab')
9
+ #
10
+ # @param [Integer, String] project The ID or code name of a project.
11
+ # @param [Hash] options A customizable set of options.
12
+ # @option options [Integer] :page The page number.
13
+ # @option options [Integer] :per_page The number of results per page.
14
+ # @return [Array<Gitlab::ObjectifiedHash>]
15
+ def milestones(project, options={})
16
+ get("/projects/#{project}/milestones", :query => options)
17
+ end
18
+
19
+ # Gets a single milestone.
20
+ #
21
+ # @example
22
+ # Gitlab.milestone(5, 36)
23
+ # Gitlab.milestone('gitlab', 42)
24
+ #
25
+ # @param [Integer, String] project The ID or code name of a project.
26
+ # @param [Integer] id The ID of a milestone.
27
+ # @return [Array<Gitlab::ObjectifiedHash>]
28
+ def milestone(project, id)
29
+ get("/projects/#{project}/milestones/#{id}")
30
+ end
31
+
32
+ # Creates a new milestone.
33
+ #
34
+ # @param [Integer, String] project The ID or code name of a project.
35
+ # @param [String] title The title of a milestone.
36
+ # @param [Hash] options A customizable set of options.
37
+ # @option options [String] :description The description of a milestone.
38
+ # @option options [String] :due_date The due date of a milestone.
39
+ # @return [Gitlab::ObjectifiedHash] Information about created milestone.
40
+ def create_milestone(project, title, options={})
41
+ body = {:title => title}.merge(options)
42
+ post("/projects/#{project}/milestones", :body => body)
43
+ end
44
+
45
+ # Updates a milestone.
46
+ #
47
+ # @param [Integer, String] project The ID or code name of a project.
48
+ # @param [Integer] id The ID of a milestone.
49
+ # @param [Hash] options A customizable set of options.
50
+ # @option options [String] :title The title of a milestone.
51
+ # @option options [String] :description The description of a milestone.
52
+ # @option options [String] :due_date The due date of a milestone.
53
+ # @option options [Boolean] :closed The state of a milestone (0 = false, 1 = true).
54
+ # @return [Gitlab::ObjectifiedHash] Information about updated milestone.
55
+ def edit_milestone(project, id, options={})
56
+ put("/projects/#{project}/milestones/#{id}", :body => options)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,155 @@
1
+ class Gitlab::Client
2
+ # Defines methods related to projects.
3
+ module Projects
4
+ # Gets a list of projects owned by the authenticated user.
5
+ #
6
+ # @example
7
+ # Gitlab.projects
8
+ #
9
+ # @param [Hash] options A customizable set of options.
10
+ # @option options [Integer] :page The page number.
11
+ # @option options [Integer] :per_page The number of results per page.
12
+ # @return [Array<Gitlab::ObjectifiedHash>]
13
+ def projects(options={})
14
+ get("/projects", :query => options)
15
+ end
16
+
17
+ # Gets information about a project.
18
+ #
19
+ # @example
20
+ # Gitlab.project(3)
21
+ # Gitlab.project('gitlab')
22
+ #
23
+ # @param [Integer, String] id The ID or code name of a project.
24
+ # @return [Gitlab::ObjectifiedHash]
25
+ def project(id)
26
+ get("/projects/#{id}")
27
+ end
28
+
29
+ # Creates a new project.
30
+ #
31
+ # @example
32
+ # Gitlab.create_project('gitlab')
33
+ # Gitlab.create_project('viking', :description => 'Awesome project')
34
+ # Gitlab.create_project('Red', :wall_enabled => false)
35
+ #
36
+ # @param [String] name The name of a project.
37
+ # @param [Hash] options A customizable set of options.
38
+ # @option options [String] :code The code name of a project.
39
+ # @option options [String] :path The path of a project.
40
+ # @option options [String] :description The description of a project.
41
+ # @option options [String] :default_branch The default branch of a project.
42
+ # @option options [Boolean] :wiki_enabled The wiki integration for a project (0 = false, 1 = true).
43
+ # @option options [Boolean] :wall_enabled The wall functionality for a project (0 = false, 1 = true).
44
+ # @option options [Boolean] :issues_enabled The issues integration for a project (0 = false, 1 = true).
45
+ # @option options [Boolean] :merge_requests_enabled The merge requests functionality for a project (0 = false, 1 = true).
46
+ # @return [Gitlab::ObjectifiedHash] Information about created project.
47
+ def create_project(name, options={})
48
+ post("/projects", :body => {:name => name}.merge(options))
49
+ end
50
+
51
+ # Gets a list of project team members.
52
+ #
53
+ # @example
54
+ # Gitlab.team_members(42)
55
+ # Gitlab.team_members('gitlab')
56
+ #
57
+ # @param [Integer, String] project The ID or code name of a project.
58
+ # @param [Hash] options A customizable set of options.
59
+ # @option options [Integer] :page The page number.
60
+ # @option options [Integer] :per_page The number of results per page.
61
+ # @return [Array<Gitlab::ObjectifiedHash>]
62
+ def team_members(project, options={})
63
+ get("/projects/#{project}/members", :query => options)
64
+ end
65
+
66
+ # Gets a project team member.
67
+ #
68
+ # @example
69
+ # Gitlab.team_member('gitlab', 2)
70
+ #
71
+ # @param [Integer, String] project The ID or code name of a project.
72
+ # @param [Integer] id The ID of a project team member.
73
+ # @return [Array<Gitlab::ObjectifiedHash>]
74
+ def team_member(project, id)
75
+ get("/projects/#{project}/members/#{id}")
76
+ end
77
+
78
+ # Adds a user to project team.
79
+ #
80
+ # @example
81
+ # Gitlab.add_team_member('gitlab', 2, 40)
82
+ #
83
+ # @param [Integer, String] project The ID or code name of a project.
84
+ # @param [Integer] id The ID of a user.
85
+ # @param [Integer] access_level The access level to project.
86
+ # @return [Array<Gitlab::ObjectifiedHash>] Information about added team member.
87
+ def add_team_member(project, id, access_level)
88
+ post("/projects/#{project}/members/#{id}", :body => {:access_level => access_level})
89
+ end
90
+
91
+ # Updates a team member's project access level.
92
+ #
93
+ # @example
94
+ # Gitlab.team_members('gitlab', 3, 20)
95
+ #
96
+ # @param [Integer, String] project The ID or code name of a project.
97
+ # @param [Integer] id The ID of a user.
98
+ # @param [Integer] access_level The access level to project.
99
+ # @return [Array<Gitlab::ObjectifiedHash>] Information about updated team member.
100
+ def edit_team_member(project, id, access_level)
101
+ put("/projects/#{project}/members/#{id}", :body => {:access_level => access_level})
102
+ end
103
+
104
+ # Removes a user from project team.
105
+ #
106
+ # @example
107
+ # Gitlab.remove_team_member('gitlab', 2)
108
+ #
109
+ # @param [Integer, String] project The ID or code name of a project.
110
+ # @param [Integer] id The ID of a user.
111
+ # @return [Array<Gitlab::ObjectifiedHash>] Information about removed team member.
112
+ def remove_team_member(project, id)
113
+ delete("/projects/#{project}/members/#{id}")
114
+ end
115
+
116
+ # Gets a list of project hooks.
117
+ #
118
+ # @example
119
+ # Gitlab.project_hooks(42)
120
+ # Gitlab.project_hooks('gitlab')
121
+ #
122
+ # @param [Integer, String] project The ID or code name of a project.
123
+ # @param [Hash] options A customizable set of options.
124
+ # @option options [Integer] :page The page number.
125
+ # @option options [Integer] :per_page The number of results per page.
126
+ # @return [Array<Gitlab::ObjectifiedHash>]
127
+ def project_hooks(project, options={})
128
+ get("/projects/#{project}/hooks", :query => options)
129
+ end
130
+
131
+ # Adds a new hook to the project.
132
+ #
133
+ # @example
134
+ # Gitlab.project_hooks(42, 'https://api.example.net/v1/webhooks/ci')
135
+ #
136
+ # @param [Integer, String] project The ID or code name of a project.
137
+ # @param [String] url The hook URL.
138
+ # @return [Gitlab::ObjectifiedHash] Information about added hook.
139
+ def add_project_hook(project, url)
140
+ post("/projects/#{project}/hooks", :body => {:url => url})
141
+ end
142
+
143
+ # Deletes a hook from project.
144
+ #
145
+ # @example
146
+ # Gitlab.delete_project_hook('gitlab', 4)
147
+ #
148
+ # @param [Integer, String] project The ID or code name of a project.
149
+ # @param [String] id The ID of the hook.
150
+ # @return [Gitlab::ObjectifiedHash] Information about deleted hook.
151
+ def delete_project_hook(project, id)
152
+ delete("/projects/#{project}/hooks/#{id}")
153
+ end
154
+ end
155
+ end