gitlab 4.5.0 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/stale.yml +18 -0
- data/.rubocop_todo.yml +46 -0
- data/Gemfile +2 -0
- data/README.md +22 -22
- data/Rakefile +3 -5
- data/bin/console +1 -0
- data/exe/gitlab +5 -1
- data/gitlab.gemspec +9 -6
- data/lib/gitlab.rb +6 -3
- data/lib/gitlab/api.rb +5 -3
- data/lib/gitlab/cli.rb +11 -5
- data/lib/gitlab/cli_helpers.rb +31 -22
- data/lib/gitlab/client.rb +7 -8
- data/lib/gitlab/client/access_requests.rb +100 -93
- data/lib/gitlab/client/award_emojis.rb +127 -127
- data/lib/gitlab/client/boards.rb +82 -82
- data/lib/gitlab/client/branches.rb +89 -89
- data/lib/gitlab/client/build_variables.rb +117 -117
- data/lib/gitlab/client/builds.rb +98 -98
- data/lib/gitlab/client/commits.rb +154 -154
- data/lib/gitlab/client/deployments.rb +29 -29
- data/lib/gitlab/client/environments.rb +80 -80
- data/lib/gitlab/client/events.rb +54 -54
- data/lib/gitlab/client/group_milestones.rb +85 -86
- data/lib/gitlab/client/groups.rb +178 -178
- data/lib/gitlab/client/issues.rb +195 -196
- data/lib/gitlab/client/jobs.rb +150 -150
- data/lib/gitlab/client/keys.rb +14 -14
- data/lib/gitlab/client/labels.rb +79 -79
- data/lib/gitlab/client/merge_request_approvals.rb +102 -102
- data/lib/gitlab/client/merge_requests.rb +281 -256
- data/lib/gitlab/client/milestones.rb +85 -85
- data/lib/gitlab/client/namespaces.rb +18 -18
- data/lib/gitlab/client/notes.rb +260 -260
- data/lib/gitlab/client/pipeline_schedules.rb +123 -123
- data/lib/gitlab/client/pipeline_triggers.rb +93 -93
- data/lib/gitlab/client/pipelines.rb +62 -62
- data/lib/gitlab/client/projects.rb +526 -505
- data/lib/gitlab/client/repositories.rb +68 -55
- data/lib/gitlab/client/repository_files.rb +103 -103
- data/lib/gitlab/client/runners.rb +113 -115
- data/lib/gitlab/client/services.rb +46 -45
- data/lib/gitlab/client/sidekiq.rb +32 -32
- data/lib/gitlab/client/snippets.rb +86 -86
- data/lib/gitlab/client/system_hooks.rb +57 -57
- data/lib/gitlab/client/tags.rb +87 -88
- data/lib/gitlab/client/todos.rb +41 -41
- data/lib/gitlab/client/users.rb +242 -228
- data/lib/gitlab/client/versions.rb +16 -0
- data/lib/gitlab/configuration.rb +7 -5
- data/lib/gitlab/error.rb +3 -1
- data/lib/gitlab/file_response.rb +4 -2
- data/lib/gitlab/help.rb +9 -9
- data/lib/gitlab/objectified_hash.rb +5 -4
- data/lib/gitlab/page_links.rb +9 -7
- data/lib/gitlab/paginated_response.rb +14 -4
- data/lib/gitlab/request.rb +8 -5
- data/lib/gitlab/shell.rb +6 -4
- data/lib/gitlab/shell_history.rb +7 -5
- data/lib/gitlab/version.rb +3 -1
- metadata +8 -5
data/lib/gitlab/client/tags.rb
CHANGED
@@ -1,96 +1,95 @@
|
|
1
|
-
|
2
|
-
# Defines methods related to tags.
|
3
|
-
# @see https://docs.gitlab.com/ce/api/tags.html
|
4
|
-
module Tags
|
5
|
-
# Gets a list of project repository tags.
|
6
|
-
#
|
7
|
-
# @example
|
8
|
-
# Gitlab.tags(42)
|
9
|
-
#
|
10
|
-
# @param [Integer, String] project The ID or 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 tags(project, options={})
|
16
|
-
get("/projects/#{url_encode project}/repository/tags", query: options)
|
17
|
-
end
|
18
|
-
alias_method :repo_tags, :tags
|
1
|
+
# frozen_string_literal: true
|
19
2
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
36
20
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
50
37
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
64
51
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
alias_method :repo_create_release, :create_release
|
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
|
79
65
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
94
80
|
|
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 })
|
95
93
|
end
|
94
|
+
alias repo_update_release update_release
|
96
95
|
end
|
data/lib/gitlab/client/todos.rb
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
|
2
|
-
# Defines methods related to todos
|
3
|
-
# @see https://docs.gitlab.com/ce/api/todos.html
|
4
|
-
module Todos
|
5
|
-
# Gets a list of todos.
|
6
|
-
#
|
7
|
-
# @example
|
8
|
-
# Gitlab.todos
|
9
|
-
# Gitlab.todos({ action: 'assigned' })
|
10
|
-
# Gitlab.todos({ state: 'pending' })
|
11
|
-
#
|
12
|
-
# @param [Hash] options A customizable set of options.
|
13
|
-
# @option options [Integer] :action The action to be filtered. Can be `assigned`, `mentioned`, `build_failed`, `marked`, or `approval_required`.
|
14
|
-
# @option options [Integer] :author_id The ID of an author
|
15
|
-
# @option options [Integer] :project_id The ID of a project
|
16
|
-
# @option options [Integer] :state The state of the todo. Can be either `pending` or `done`
|
17
|
-
# @option options [Integer] :type The type of a todo. Can be either `Issue` or `MergeRequest`
|
18
|
-
# @return [Array<Gitlab::ObjectifiedHash>]
|
19
|
-
def todos(options={})
|
20
|
-
get("/todos", query: options)
|
21
|
-
end
|
1
|
+
# frozen_string_literal: true
|
22
2
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
23
|
+
|
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
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
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')
|
43
43
|
end
|
44
|
-
end
|
44
|
+
end
|
data/lib/gitlab/client/users.rb
CHANGED
@@ -1,250 +1,264 @@
|
|
1
|
-
|
2
|
-
# Defines methods related to users.
|
3
|
-
# @see https://docs.gitlab.com/ce/api/users.html
|
4
|
-
# @see https://docs.gitlab.com/ce/api/session.html
|
5
|
-
module Users
|
6
|
-
# Gets a list of users.
|
7
|
-
#
|
8
|
-
# @example
|
9
|
-
# Gitlab.users
|
10
|
-
#
|
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 users(options={})
|
16
|
-
get("/users", query: options)
|
17
|
-
end
|
1
|
+
# frozen_string_literal: true
|
18
2
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
31
19
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
# @option options [String] :name The name of a user. Defaults to email.
|
45
|
-
# @option options [String] :skype The skype of a user.
|
46
|
-
# @option options [String] :linkedin The linkedin of a user.
|
47
|
-
# @option options [String] :twitter The twitter of a user.
|
48
|
-
# @option options [Integer] :projects_limit The limit of projects for a user.
|
49
|
-
# @return [Gitlab::ObjectifiedHash] Information about created user.
|
50
|
-
def create_user(*args)
|
51
|
-
options = Hash === args.last ? args.pop : {}
|
52
|
-
body = if args[2]
|
53
|
-
{ email: args[0], password: args[1], username: args[2] }
|
54
|
-
else
|
55
|
-
{ email: args[0], password: args[1], name: args[0] }
|
56
|
-
end
|
57
|
-
body.merge!(options)
|
58
|
-
post('/users', body: body)
|
59
|
-
end
|
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
|
60
32
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
79
61
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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
|
90
80
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
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
|
101
91
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
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
|
112
102
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
post("/session", body: { email: email, password: password }, unauthenticated: true)
|
124
|
-
end
|
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
|
125
113
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
user_id = options.delete :user_id
|
139
|
-
if user_id.to_i.zero?
|
140
|
-
get("/user/keys", query: options)
|
141
|
-
else
|
142
|
-
get("/users/#{user_id}/keys", query: options)
|
143
|
-
end
|
144
|
-
end
|
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
|
145
126
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
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)
|
155
144
|
end
|
145
|
+
end
|
146
|
+
|
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
|
156
157
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
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 })
|
167
174
|
end
|
175
|
+
end
|
168
176
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
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?
|
177
189
|
delete("/user/keys/#{id}")
|
190
|
+
else
|
191
|
+
delete("/users/#{user_id}/keys/#{id}")
|
178
192
|
end
|
193
|
+
end
|
179
194
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
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
|
193
208
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
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
|
204
219
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
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
|
219
234
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
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
|
234
249
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
end
|
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)
|
249
263
|
end
|
250
264
|
end
|