gitlab 4.6.0 → 4.7.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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gitlab/client/access_requests.rb +92 -90
  3. data/lib/gitlab/client/award_emojis.rb +126 -124
  4. data/lib/gitlab/client/boards.rb +81 -79
  5. data/lib/gitlab/client/branches.rb +89 -87
  6. data/lib/gitlab/client/build_variables.rb +117 -115
  7. data/lib/gitlab/client/builds.rb +98 -96
  8. data/lib/gitlab/client/commits.rb +167 -152
  9. data/lib/gitlab/client/deployments.rb +29 -27
  10. data/lib/gitlab/client/environments.rb +80 -78
  11. data/lib/gitlab/client/events.rb +54 -52
  12. data/lib/gitlab/client/group_milestones.rb +85 -83
  13. data/lib/gitlab/client/groups.rb +178 -176
  14. data/lib/gitlab/client/issues.rb +212 -188
  15. data/lib/gitlab/client/jobs.rb +150 -148
  16. data/lib/gitlab/client/keys.rb +14 -12
  17. data/lib/gitlab/client/labels.rb +79 -77
  18. data/lib/gitlab/client/merge_request_approvals.rb +101 -99
  19. data/lib/gitlab/client/merge_requests.rb +291 -277
  20. data/lib/gitlab/client/milestones.rb +85 -83
  21. data/lib/gitlab/client/namespaces.rb +18 -16
  22. data/lib/gitlab/client/notes.rb +260 -258
  23. data/lib/gitlab/client/pipeline_schedules.rb +123 -121
  24. data/lib/gitlab/client/pipeline_triggers.rb +93 -91
  25. data/lib/gitlab/client/pipelines.rb +73 -60
  26. data/lib/gitlab/client/projects.rb +538 -524
  27. data/lib/gitlab/client/repositories.rb +67 -65
  28. data/lib/gitlab/client/repository_files.rb +103 -101
  29. data/lib/gitlab/client/runners.rb +114 -112
  30. data/lib/gitlab/client/services.rb +45 -43
  31. data/lib/gitlab/client/sidekiq.rb +32 -30
  32. data/lib/gitlab/client/snippets.rb +86 -84
  33. data/lib/gitlab/client/system_hooks.rb +57 -55
  34. data/lib/gitlab/client/tags.rb +88 -86
  35. data/lib/gitlab/client/todos.rb +40 -38
  36. data/lib/gitlab/client/users.rb +243 -241
  37. data/lib/gitlab/client/versions.rb +13 -11
  38. data/lib/gitlab/error.rb +1 -1
  39. data/lib/gitlab/help.rb +1 -1
  40. data/lib/gitlab/page_links.rb +1 -1
  41. data/lib/gitlab/version.rb +1 -1
  42. metadata +3 -3
@@ -1,95 +1,97 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Defines methods related to tags.
4
- # @see https://docs.gitlab.com/ce/api/tags.html
5
- module Tags
6
- # Gets a list of project repository tags.
7
- #
8
- # @example
9
- # Gitlab.tags(42)
10
- #
11
- # @param [Integer, String] project The ID or name of a project.
12
- # @param [Hash] options A customizable set of options.
13
- # @option options [Integer] :page The page number.
14
- # @option options [Integer] :per_page The number of results per page.
15
- # @return [Array<Gitlab::ObjectifiedHash>]
16
- def tags(project, options = {})
17
- get("/projects/#{url_encode project}/repository/tags", query: options)
18
- end
19
- alias repo_tags tags
3
+ class Gitlab::Client
4
+ # Defines methods related to tags.
5
+ # @see https://docs.gitlab.com/ce/api/tags.html
6
+ module Tags
7
+ # Gets a list of project repository tags.
8
+ #
9
+ # @example
10
+ # Gitlab.tags(42)
11
+ #
12
+ # @param [Integer, String] project The ID or 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 tags(project, options = {})
18
+ get("/projects/#{url_encode project}/repository/tags", query: options)
19
+ end
20
+ alias repo_tags tags
20
21
 
21
- # Creates a new project repository tag.
22
- #
23
- # @example
24
- # Gitlab.create_tag(42, 'new_tag', 'master')
25
- # Gitlab.create_tag(42, 'v1.0', 'master', 'Release 1.0')
26
- #
27
- # @param [Integer, String] project The ID or name of a project.
28
- # @param [String] tag_name The name of the new tag.
29
- # @param [String] ref The ref (commit sha, branch name, or another tag) the tag will point to.
30
- # @param [String] message Optional message for tag, creates annotated tag if specified.
31
- # @param [String] description Optional release notes for tag.
32
- # @return [Gitlab::ObjectifiedHash]
33
- def create_tag(project, tag_name, ref, message = '', description = nil)
34
- post("/projects/#{url_encode project}/repository/tags", body: { tag_name: tag_name, ref: ref, message: message, release_description: description })
35
- end
36
- alias repo_create_tag create_tag
22
+ # Creates a new project repository tag.
23
+ #
24
+ # @example
25
+ # Gitlab.create_tag(42, 'new_tag', 'master')
26
+ # Gitlab.create_tag(42, 'v1.0', 'master', 'Release 1.0')
27
+ #
28
+ # @param [Integer, String] project The ID or name of a project.
29
+ # @param [String] tag_name The name of the new tag.
30
+ # @param [String] ref The ref (commit sha, branch name, or another tag) the tag will point to.
31
+ # @param [String] message Optional message for tag, creates annotated tag if specified.
32
+ # @param [String] description Optional release notes for tag.
33
+ # @return [Gitlab::ObjectifiedHash]
34
+ def create_tag(project, tag_name, ref, message = '', description = nil)
35
+ post("/projects/#{url_encode project}/repository/tags", body: { tag_name: tag_name, ref: ref, message: message, release_description: description })
36
+ end
37
+ alias repo_create_tag create_tag
37
38
 
38
- # Gets information about a repository tag.
39
- #
40
- # @example
41
- # Gitlab.tag(3, 'api')
42
- # Gitlab.repo_tag(5, 'master')
43
- #
44
- # @param [Integer, String] project The ID or name of a project.
45
- # @param [String] tag The name of the tag.
46
- # @return [Gitlab::ObjectifiedHash]
47
- def tag(project, tag)
48
- get("/projects/#{url_encode project}/repository/tags/#{url_encode tag}")
49
- end
50
- alias repo_tag tag
39
+ # Gets information about a repository tag.
40
+ #
41
+ # @example
42
+ # Gitlab.tag(3, 'api')
43
+ # Gitlab.repo_tag(5, 'master')
44
+ #
45
+ # @param [Integer, String] project The ID or name of a project.
46
+ # @param [String] tag The name of the tag.
47
+ # @return [Gitlab::ObjectifiedHash]
48
+ def tag(project, tag)
49
+ get("/projects/#{url_encode project}/repository/tags/#{url_encode tag}")
50
+ end
51
+ alias repo_tag tag
51
52
 
52
- # Deletes a repository tag. Requires Gitlab >= 6.8.x
53
- #
54
- # @example
55
- # Gitlab.delete_tag(3, 'api')
56
- # Gitlab.repo_delete_tag(5, 'master')
57
- #
58
- # @param [Integer, String] project The ID or name of a project.
59
- # @param [String] tag The name of the tag to delete
60
- # @return [Gitlab::ObjectifiedHash]
61
- def delete_tag(project, tag)
62
- delete("/projects/#{url_encode project}/repository/tags/#{url_encode tag}")
63
- end
64
- alias repo_delete_tag delete_tag
53
+ # Deletes a repository tag. Requires Gitlab >= 6.8.x
54
+ #
55
+ # @example
56
+ # Gitlab.delete_tag(3, 'api')
57
+ # Gitlab.repo_delete_tag(5, 'master')
58
+ #
59
+ # @param [Integer, String] project The ID or name of a project.
60
+ # @param [String] tag The name of the tag to delete
61
+ # @return [Gitlab::ObjectifiedHash]
62
+ def delete_tag(project, tag)
63
+ delete("/projects/#{url_encode project}/repository/tags/#{url_encode tag}")
64
+ end
65
+ alias repo_delete_tag delete_tag
65
66
 
66
- # Adds release notes to an existing repository tag. Requires Gitlab >= 8.2.0
67
- #
68
- # @example
69
- # Gitlab.create_release(3, '1.0.0', 'This is ready for production')
70
- # Gitlab.repo_create_release(5, '1.0.0', 'This is ready for production')
71
- #
72
- # @param [Integer, String] project The ID or name of a project.
73
- # @param [String] tag The name of the new tag.
74
- # @param [String] description Release notes with markdown support
75
- # @return [Gitlab::ObjectifiedHash]
76
- def create_release(project, tag, description)
77
- post("/projects/#{url_encode project}/repository/tags/#{url_encode tag}/release", body: { description: description })
78
- end
79
- alias repo_create_release create_release
67
+ # Adds release notes to an existing repository tag. Requires Gitlab >= 8.2.0
68
+ #
69
+ # @example
70
+ # Gitlab.create_release(3, '1.0.0', 'This is ready for production')
71
+ # Gitlab.repo_create_release(5, '1.0.0', 'This is ready for production')
72
+ #
73
+ # @param [Integer, String] project The ID or name of a project.
74
+ # @param [String] tag The name of the new tag.
75
+ # @param [String] description Release notes with markdown support
76
+ # @return [Gitlab::ObjectifiedHash]
77
+ def create_release(project, tag, description)
78
+ post("/projects/#{url_encode project}/repository/tags/#{url_encode tag}/release", body: { description: description })
79
+ end
80
+ alias repo_create_release create_release
80
81
 
81
- # Updates the release notes of a given release. Requires Gitlab >= 8.2.0
82
- #
83
- # @example
84
- # Gitlab.update_release(3, '1.0.0', 'This is even more ready for production')
85
- # Gitlab.repo_update_release(5, '1.0.0', 'This is even more ready for production')
86
- #
87
- # @param [Integer, String] project The ID or name of a project.
88
- # @param [String] tag The name of the new tag.
89
- # @param [String] description Release notes with markdown support
90
- # @return [Gitlab::ObjectifiedHash]
91
- def update_release(project, tag, description)
92
- put("/projects/#{url_encode project}/repository/tags/#{url_encode tag}/release", body: { description: description })
82
+ # Updates the release notes of a given release. Requires Gitlab >= 8.2.0
83
+ #
84
+ # @example
85
+ # Gitlab.update_release(3, '1.0.0', 'This is even more ready for production')
86
+ # Gitlab.repo_update_release(5, '1.0.0', 'This is even more ready for production')
87
+ #
88
+ # @param [Integer, String] project The ID or name of a project.
89
+ # @param [String] tag The name of the new tag.
90
+ # @param [String] description Release notes with markdown support
91
+ # @return [Gitlab::ObjectifiedHash]
92
+ def update_release(project, tag, description)
93
+ put("/projects/#{url_encode project}/repository/tags/#{url_encode tag}/release", body: { description: description })
94
+ end
95
+ alias repo_update_release update_release
93
96
  end
94
- alias repo_update_release update_release
95
97
  end
@@ -1,44 +1,46 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Defines methods related to todos
4
- # @see https://docs.gitlab.com/ce/api/todos.html
5
- module Todos
6
- # Gets a list of todos.
7
- #
8
- # @example
9
- # Gitlab.todos
10
- # Gitlab.todos({ action: 'assigned' })
11
- # Gitlab.todos({ state: 'pending' })
12
- #
13
- # @param [Hash] options A customizable set of options.
14
- # @option options [Integer] :action The action to be filtered. Can be `assigned`, `mentioned`, `build_failed`, `marked`, or `approval_required`.
15
- # @option options [Integer] :author_id The ID of an author
16
- # @option options [Integer] :project_id The ID of a project
17
- # @option options [Integer] :state The state of the todo. Can be either `pending` or `done`
18
- # @option options [Integer] :type The type of a todo. Can be either `Issue` or `MergeRequest`
19
- # @return [Array<Gitlab::ObjectifiedHash>]
20
- def todos(options = {})
21
- get('/todos', query: options)
22
- end
3
+ class Gitlab::Client
4
+ # Defines methods related to todos
5
+ # @see https://docs.gitlab.com/ce/api/todos.html
6
+ module Todos
7
+ # Gets a list of todos.
8
+ #
9
+ # @example
10
+ # Gitlab.todos
11
+ # Gitlab.todos({ action: 'assigned' })
12
+ # Gitlab.todos({ state: 'pending' })
13
+ #
14
+ # @param [Hash] options A customizable set of options.
15
+ # @option options [Integer] :action The action to be filtered. Can be `assigned`, `mentioned`, `build_failed`, `marked`, or `approval_required`.
16
+ # @option options [Integer] :author_id The ID of an author
17
+ # @option options [Integer] :project_id The ID of a project
18
+ # @option options [Integer] :state The state of the todo. Can be either `pending` or `done`
19
+ # @option options [Integer] :type The type of a todo. Can be either `Issue` or `MergeRequest`
20
+ # @return [Array<Gitlab::ObjectifiedHash>]
21
+ def todos(options = {})
22
+ get('/todos', query: options)
23
+ end
23
24
 
24
- # Marks a single pending todo for the current user as done.
25
- #
26
- # @example
27
- # Gitlab.mark_todo_as_done(42)
28
- #
29
- # @param [Integer] id The ID of the todo.
30
- # @return [Gitlab::ObjectifiedHash]
31
- def mark_todo_as_done(id)
32
- post("/todos/#{id}/mark_as_done")
33
- end
25
+ # Marks a single pending todo for the current user as done.
26
+ #
27
+ # @example
28
+ # Gitlab.mark_todo_as_done(42)
29
+ #
30
+ # @param [Integer] id The ID of the todo.
31
+ # @return [Gitlab::ObjectifiedHash]
32
+ def mark_todo_as_done(id)
33
+ post("/todos/#{id}/mark_as_done")
34
+ end
34
35
 
35
- # Marks all todos for the current user as done
36
- #
37
- # @example
38
- # Gitlab.mark_all_todos_as_done
39
- #
40
- # @return [void] This API call returns an empty response body.
41
- def mark_all_todos_as_done
42
- post('/todos/mark_as_done')
36
+ # Marks all todos for the current user as done
37
+ #
38
+ # @example
39
+ # Gitlab.mark_all_todos_as_done
40
+ #
41
+ # @return [void] This API call returns an empty response body.
42
+ def mark_all_todos_as_done
43
+ post('/todos/mark_as_done')
44
+ end
43
45
  end
44
46
  end
@@ -1,264 +1,266 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Defines methods related to users.
4
- # @see https://docs.gitlab.com/ce/api/users.html
5
- # @see https://docs.gitlab.com/ce/api/session.html
6
- module Users
7
- # Gets a list of users.
8
- #
9
- # @example
10
- # Gitlab.users
11
- #
12
- # @param [Hash] options A customizable set of options.
13
- # @option options [Integer] :page The page number.
14
- # @option options [Integer] :per_page The number of results per page.
15
- # @return [Array<Gitlab::ObjectifiedHash>]
16
- def users(options = {})
17
- get('/users', query: options)
18
- end
3
+ class Gitlab::Client
4
+ # Defines methods related to users.
5
+ # @see https://docs.gitlab.com/ce/api/users.html
6
+ # @see https://docs.gitlab.com/ce/api/session.html
7
+ module Users
8
+ # Gets a list of users.
9
+ #
10
+ # @example
11
+ # Gitlab.users
12
+ #
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 users(options = {})
18
+ get('/users', query: options)
19
+ end
19
20
 
20
- # Gets information about a user.
21
- # Will return information about an authorized user if no ID passed.
22
- #
23
- # @example
24
- # Gitlab.user
25
- # Gitlab.user(2)
26
- #
27
- # @param [Integer] id The ID of a user.
28
- # @return [Gitlab::ObjectifiedHash]
29
- def user(id = nil)
30
- id.to_i.zero? ? get('/user') : get("/users/#{id}")
31
- end
21
+ # Gets information about a user.
22
+ # Will return information about an authorized user if no ID passed.
23
+ #
24
+ # @example
25
+ # Gitlab.user
26
+ # Gitlab.user(2)
27
+ #
28
+ # @param [Integer] id The ID of a user.
29
+ # @return [Gitlab::ObjectifiedHash]
30
+ def user(id = nil)
31
+ id.to_i.zero? ? get('/user') : get("/users/#{id}")
32
+ end
32
33
 
33
- # Creates a new user.
34
- # Requires authentication from an admin account.
35
- #
36
- # @example
37
- # Gitlab.create_user('joe@foo.org', 'secret', 'joe', { name: 'Joe Smith' })
38
- # or
39
- # Gitlab.create_user('joe@foo.org', 'secret')
40
- #
41
- # @param [String] email The email of a user.
42
- # @param [String] password The password of a user.
43
- # @param [String] username The username of a user.
44
- # @param [Hash] options A customizable set of options.
45
- # @option options [String] :name The name of a user. Defaults to email.
46
- # @option options [String] :skype The skype of a user.
47
- # @option options [String] :linkedin The linkedin of a user.
48
- # @option options [String] :twitter The twitter of a user.
49
- # @option options [Integer] :projects_limit The limit of projects for a user.
50
- # @return [Gitlab::ObjectifiedHash] Information about created user.
51
- def create_user(*args)
52
- options = args.last.is_a?(Hash) ? args.pop : {}
53
- body = if args[2]
54
- { email: args[0], password: args[1], username: args[2] }
55
- else
56
- { email: args[0], password: args[1], name: args[0] }
57
- end
58
- body.merge!(options)
59
- post('/users', body: body)
60
- end
34
+ # Creates a new user.
35
+ # Requires authentication from an admin account.
36
+ #
37
+ # @example
38
+ # Gitlab.create_user('joe@foo.org', 'secret', 'joe', { name: 'Joe Smith' })
39
+ # or
40
+ # Gitlab.create_user('joe@foo.org', 'secret')
41
+ #
42
+ # @param [String] email The email of a user.
43
+ # @param [String] password The password of a user.
44
+ # @param [String] username The username of a user.
45
+ # @param [Hash] options A customizable set of options.
46
+ # @option options [String] :name The name of a user. Defaults to email.
47
+ # @option options [String] :skype The skype of a user.
48
+ # @option options [String] :linkedin The linkedin of a user.
49
+ # @option options [String] :twitter The twitter of a user.
50
+ # @option options [Integer] :projects_limit The limit of projects for a user.
51
+ # @return [Gitlab::ObjectifiedHash] Information about created user.
52
+ def create_user(*args)
53
+ options = args.last.is_a?(Hash) ? args.pop : {}
54
+ body = if args[2]
55
+ { email: args[0], password: args[1], username: args[2] }
56
+ else
57
+ { email: args[0], password: args[1], name: args[0] }
58
+ end
59
+ body.merge!(options)
60
+ post('/users', body: body)
61
+ end
61
62
 
62
- # Updates a user.
63
- #
64
- # @example
65
- # Gitlab.edit_user(15, { email: 'joe.smith@foo.org', projects_limit: 20 })
66
- #
67
- # @param [Integer] id The ID of a user.
68
- # @param [Hash] options A customizable set of options.
69
- # @option options [String] :email The email of a user.
70
- # @option options [String] :password The password of a user.
71
- # @option options [String] :name The name of a user. Defaults to email.
72
- # @option options [String] :skype The skype of a user.
73
- # @option options [String] :linkedin The linkedin of a user.
74
- # @option options [String] :twitter The twitter of a user.
75
- # @option options [Integer] :projects_limit The limit of projects for a user.
76
- # @return [Gitlab::ObjectifiedHash] Information about created user.
77
- def edit_user(user_id, options = {})
78
- put("/users/#{user_id}", body: options)
79
- end
63
+ # Updates a user.
64
+ #
65
+ # @example
66
+ # Gitlab.edit_user(15, { email: 'joe.smith@foo.org', projects_limit: 20 })
67
+ #
68
+ # @param [Integer] id The ID of a user.
69
+ # @param [Hash] options A customizable set of options.
70
+ # @option options [String] :email The email of a user.
71
+ # @option options [String] :password The password of a user.
72
+ # @option options [String] :name The name of a user. Defaults to email.
73
+ # @option options [String] :skype The skype of a user.
74
+ # @option options [String] :linkedin The linkedin of a user.
75
+ # @option options [String] :twitter The twitter of a user.
76
+ # @option options [Integer] :projects_limit The limit of projects for a user.
77
+ # @return [Gitlab::ObjectifiedHash] Information about created user.
78
+ def edit_user(user_id, options = {})
79
+ put("/users/#{user_id}", body: options)
80
+ end
80
81
 
81
- # Deletes a user.
82
- #
83
- # @example
84
- # Gitlab.delete_user(1)
85
- #
86
- # @param [Integer] id The ID of a user.
87
- # @return [Gitlab::ObjectifiedHash] Information about deleted user.
88
- def delete_user(user_id)
89
- delete("/users/#{user_id}")
90
- end
82
+ # Deletes a user.
83
+ #
84
+ # @example
85
+ # Gitlab.delete_user(1)
86
+ #
87
+ # @param [Integer] id The ID of a user.
88
+ # @return [Gitlab::ObjectifiedHash] Information about deleted user.
89
+ def delete_user(user_id)
90
+ delete("/users/#{user_id}")
91
+ end
91
92
 
92
- # Blocks the specified user. Available only for admin.
93
- #
94
- # @example
95
- # Gitlab.block_user(15)
96
- #
97
- # @param [Integer] user_id The Id of user
98
- # @return [Boolean] success or not
99
- def block_user(user_id)
100
- post("/users/#{user_id}/block")
101
- end
93
+ # Blocks the specified user. Available only for admin.
94
+ #
95
+ # @example
96
+ # Gitlab.block_user(15)
97
+ #
98
+ # @param [Integer] user_id The Id of user
99
+ # @return [Boolean] success or not
100
+ def block_user(user_id)
101
+ post("/users/#{user_id}/block")
102
+ end
102
103
 
103
- # Unblocks the specified user. Available only for admin.
104
- #
105
- # @example
106
- # Gitlab.unblock_user(15)
107
- #
108
- # @param [Integer] user_id The Id of user
109
- # @return [Boolean] success or not
110
- def unblock_user(user_id)
111
- post("/users/#{user_id}/unblock")
112
- end
104
+ # Unblocks the specified user. Available only for admin.
105
+ #
106
+ # @example
107
+ # Gitlab.unblock_user(15)
108
+ #
109
+ # @param [Integer] user_id The Id of user
110
+ # @return [Boolean] success or not
111
+ def unblock_user(user_id)
112
+ post("/users/#{user_id}/unblock")
113
+ end
113
114
 
114
- # Creates a new user session.
115
- #
116
- # @example
117
- # Gitlab.session('jack@example.com', 'secret12345')
118
- #
119
- # @param [String] email The email of a user.
120
- # @param [String] password The password of a user.
121
- # @return [Gitlab::ObjectifiedHash]
122
- # @note This method doesn't require private_token to be set.
123
- def session(email, password)
124
- post('/session', body: { email: email, password: password }, unauthenticated: true)
125
- end
115
+ # Creates a new user session.
116
+ #
117
+ # @example
118
+ # Gitlab.session('jack@example.com', 'secret12345')
119
+ #
120
+ # @param [String] email The email of a user.
121
+ # @param [String] password The password of a user.
122
+ # @return [Gitlab::ObjectifiedHash]
123
+ # @note This method doesn't require private_token to be set.
124
+ def session(email, password)
125
+ post('/session', body: { email: email, password: password }, unauthenticated: true)
126
+ end
126
127
 
127
- # Gets a list of user's SSH keys.
128
- #
129
- # @example
130
- # Gitlab.ssh_keys
131
- # Gitlab.ssh_keys({ user_id: 2 })
132
- #
133
- # @param [Hash] options A customizable set of options.
134
- # @option options [Integer] :page The page number.
135
- # @option options [Integer] :per_page The number of results per page.
136
- # @option options [Integer] :user_id The ID of the user to retrieve the keys for.
137
- # @return [Array<Gitlab::ObjectifiedHash>]
138
- def ssh_keys(options = {})
139
- user_id = options.delete :user_id
140
- if user_id.to_i.zero?
141
- get('/user/keys', query: options)
142
- else
143
- get("/users/#{user_id}/keys", query: options)
128
+ # Gets a list of user's SSH keys.
129
+ #
130
+ # @example
131
+ # Gitlab.ssh_keys
132
+ # Gitlab.ssh_keys({ user_id: 2 })
133
+ #
134
+ # @param [Hash] options A customizable set of options.
135
+ # @option options [Integer] :page The page number.
136
+ # @option options [Integer] :per_page The number of results per page.
137
+ # @option options [Integer] :user_id The ID of the user to retrieve the keys for.
138
+ # @return [Array<Gitlab::ObjectifiedHash>]
139
+ def ssh_keys(options = {})
140
+ user_id = options.delete :user_id
141
+ if user_id.to_i.zero?
142
+ get('/user/keys', query: options)
143
+ else
144
+ get("/users/#{user_id}/keys", query: options)
145
+ end
144
146
  end
145
- end
146
147
 
147
- # Gets information about SSH key.
148
- #
149
- # @example
150
- # Gitlab.ssh_key(1)
151
- #
152
- # @param [Integer] id The ID of a user's SSH key.
153
- # @return [Gitlab::ObjectifiedHash]
154
- def ssh_key(id)
155
- get("/user/keys/#{id}")
156
- end
148
+ # Gets information about SSH key.
149
+ #
150
+ # @example
151
+ # Gitlab.ssh_key(1)
152
+ #
153
+ # @param [Integer] id The ID of a user's SSH key.
154
+ # @return [Gitlab::ObjectifiedHash]
155
+ def ssh_key(id)
156
+ get("/user/keys/#{id}")
157
+ end
157
158
 
158
- # Creates a new SSH key.
159
- #
160
- # @example
161
- # Gitlab.create_ssh_key('key title', 'key body')
162
- #
163
- # @param [String] title The title of an SSH key.
164
- # @param [String] key The SSH key body.
165
- # @param [Hash] options A customizable set of options.
166
- # @option options [Integer] :user_id id of the user to associate the key with
167
- # @return [Gitlab::ObjectifiedHash] Information about created SSH key.
168
- def create_ssh_key(title, key, options = {})
169
- user_id = options.delete :user_id
170
- if user_id.to_i.zero?
171
- post('/user/keys', body: { title: title, key: key })
172
- else
173
- post("/users/#{user_id}/keys", body: { title: title, key: key })
159
+ # Creates a new SSH key.
160
+ #
161
+ # @example
162
+ # Gitlab.create_ssh_key('key title', 'key body')
163
+ #
164
+ # @param [String] title The title of an SSH key.
165
+ # @param [String] key The SSH key body.
166
+ # @param [Hash] options A customizable set of options.
167
+ # @option options [Integer] :user_id id of the user to associate the key with
168
+ # @return [Gitlab::ObjectifiedHash] Information about created SSH key.
169
+ def create_ssh_key(title, key, options = {})
170
+ user_id = options.delete :user_id
171
+ if user_id.to_i.zero?
172
+ post('/user/keys', body: { title: title, key: key })
173
+ else
174
+ post("/users/#{user_id}/keys", body: { title: title, key: key })
175
+ end
174
176
  end
175
- end
176
177
 
177
- # Deletes an SSH key.
178
- #
179
- # @example
180
- # Gitlab.delete_ssh_key(1)
181
- #
182
- # @param [Integer] id The ID of a user's SSH key.
183
- # @param [Hash] options A customizable set of options.
184
- # @option options [Integer] :user_id id of the user to associate the key with
185
- # @return [Gitlab::ObjectifiedHash] Information about deleted SSH key.
186
- def delete_ssh_key(id, options = {})
187
- user_id = options.delete :user_id
188
- if user_id.to_i.zero?
189
- delete("/user/keys/#{id}")
190
- else
191
- delete("/users/#{user_id}/keys/#{id}")
178
+ # Deletes an SSH key.
179
+ #
180
+ # @example
181
+ # Gitlab.delete_ssh_key(1)
182
+ #
183
+ # @param [Integer] id The ID of a user's SSH key.
184
+ # @param [Hash] options A customizable set of options.
185
+ # @option options [Integer] :user_id id of the user to associate the key with
186
+ # @return [Gitlab::ObjectifiedHash] Information about deleted SSH key.
187
+ def delete_ssh_key(id, options = {})
188
+ user_id = options.delete :user_id
189
+ if user_id.to_i.zero?
190
+ delete("/user/keys/#{id}")
191
+ else
192
+ delete("/users/#{user_id}/keys/#{id}")
193
+ end
192
194
  end
193
- end
194
195
 
195
- # Gets user emails.
196
- # Will return emails an authorized user if no user ID passed.
197
- #
198
- # @example
199
- # Gitlab.emails
200
- # Gitlab.emails(2)
201
- #
202
- # @param [Integer] user_id The ID of a user.
203
- # @return [Gitlab::ObjectifiedHash]
204
- def emails(user_id = nil)
205
- url = user_id.to_i.zero? ? '/user/emails' : "/users/#{user_id}/emails"
206
- get(url)
207
- end
196
+ # Gets user emails.
197
+ # Will return emails an authorized user if no user ID passed.
198
+ #
199
+ # @example
200
+ # Gitlab.emails
201
+ # Gitlab.emails(2)
202
+ #
203
+ # @param [Integer] user_id The ID of a user.
204
+ # @return [Gitlab::ObjectifiedHash]
205
+ def emails(user_id = nil)
206
+ url = user_id.to_i.zero? ? '/user/emails' : "/users/#{user_id}/emails"
207
+ get(url)
208
+ end
208
209
 
209
- # Get a single email.
210
- #
211
- # @example
212
- # Gitlab.email(3)
213
- #
214
- # @param [Integer] id The ID of a email.
215
- # @return [Gitlab::ObjectifiedHash]
216
- def email(id)
217
- get("/user/emails/#{id}")
218
- end
210
+ # Get a single email.
211
+ #
212
+ # @example
213
+ # Gitlab.email(3)
214
+ #
215
+ # @param [Integer] id The ID of a email.
216
+ # @return [Gitlab::ObjectifiedHash]
217
+ def email(id)
218
+ get("/user/emails/#{id}")
219
+ end
219
220
 
220
- # Creates a new email
221
- # Will create a new email an authorized user if no user ID passed.
222
- #
223
- # @example
224
- # Gitlab.add_email('email@example.com')
225
- # Gitlab.add_email('email@example.com', 2)
226
- #
227
- # @param [String] email Email address
228
- # @param [Integer] user_id The ID of a user.
229
- # @return [Gitlab::ObjectifiedHash]
230
- def add_email(email, user_id = nil)
231
- url = user_id.to_i.zero? ? '/user/emails' : "/users/#{user_id}/emails"
232
- post(url, body: { email: email })
233
- end
221
+ # Creates a new email
222
+ # Will create a new email an authorized user if no user ID passed.
223
+ #
224
+ # @example
225
+ # Gitlab.add_email('email@example.com')
226
+ # Gitlab.add_email('email@example.com', 2)
227
+ #
228
+ # @param [String] email Email address
229
+ # @param [Integer] user_id The ID of a user.
230
+ # @return [Gitlab::ObjectifiedHash]
231
+ def add_email(email, user_id = nil)
232
+ url = user_id.to_i.zero? ? '/user/emails' : "/users/#{user_id}/emails"
233
+ post(url, body: { email: email })
234
+ end
234
235
 
235
- # Delete email
236
- # Will delete a email an authorized user if no user ID passed.
237
- #
238
- # @example
239
- # Gitlab.delete_email(2)
240
- # Gitlab.delete_email(3, 2)
241
- #
242
- # @param [Integer] id Email address ID
243
- # @param [Integer] user_id The ID of a user.
244
- # @return [Boolean]
245
- def delete_email(id, user_id = nil)
246
- url = user_id.to_i.zero? ? "/user/emails/#{id}" : "/users/#{user_id}/emails/#{id}"
247
- delete(url)
248
- end
236
+ # Delete email
237
+ # Will delete a email an authorized user if no user ID passed.
238
+ #
239
+ # @example
240
+ # Gitlab.delete_email(2)
241
+ # Gitlab.delete_email(3, 2)
242
+ #
243
+ # @param [Integer] id Email address ID
244
+ # @param [Integer] user_id The ID of a user.
245
+ # @return [Boolean]
246
+ def delete_email(id, user_id = nil)
247
+ url = user_id.to_i.zero? ? "/user/emails/#{id}" : "/users/#{user_id}/emails/#{id}"
248
+ delete(url)
249
+ end
249
250
 
250
- # Search for groups by name
251
- #
252
- # @example
253
- # Gitlab.user_search('gitlab')
254
- #
255
- # @param [String] search A string to search for in user names and paths.
256
- # @param [Hash] options A customizable set of options.
257
- # @option options [String] :per_page Number of user to return per page
258
- # @option options [String] :page The page to retrieve
259
- # @return [Array<Gitlab::ObjectifiedHash>]
260
- def user_search(search, options = {})
261
- options[:search] = search
262
- get('/users', query: options)
251
+ # Search for groups by name
252
+ #
253
+ # @example
254
+ # Gitlab.user_search('gitlab')
255
+ #
256
+ # @param [String] search A string to search for in user names and paths.
257
+ # @param [Hash] options A customizable set of options.
258
+ # @option options [String] :per_page Number of user to return per page
259
+ # @option options [String] :page The page to retrieve
260
+ # @return [Array<Gitlab::ObjectifiedHash>]
261
+ def user_search(search, options = {})
262
+ options[:search] = search
263
+ get('/users', query: options)
264
+ end
263
265
  end
264
266
  end