gitlab 3.4.0 → 3.5.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -2
- data/README.md +22 -0
- data/bin/console +10 -0
- data/bin/setup +6 -0
- data/{bin → exe}/gitlab +0 -0
- data/gitlab.gemspec +4 -1
- data/lib/gitlab.rb +1 -1
- data/lib/gitlab/cli.rb +20 -2
- data/lib/gitlab/cli_helpers.rb +74 -15
- data/lib/gitlab/client.rb +2 -0
- data/lib/gitlab/client/commits.rb +121 -0
- data/lib/gitlab/client/groups.rb +25 -2
- data/lib/gitlab/client/issues.rb +7 -0
- data/lib/gitlab/client/milestones.rb +6 -0
- data/lib/gitlab/client/namespaces.rb +19 -0
- data/lib/gitlab/client/notes.rb +12 -0
- data/lib/gitlab/client/projects.rb +30 -0
- data/lib/gitlab/client/repositories.rb +0 -75
- data/lib/gitlab/client/repository_files.rb +16 -0
- data/lib/gitlab/client/snippets.rb +15 -0
- data/lib/gitlab/client/users.rb +54 -5
- data/lib/gitlab/configuration.rb +14 -0
- data/lib/gitlab/error.rb +3 -0
- data/lib/gitlab/request.rb +13 -2
- data/lib/gitlab/shell.rb +1 -2
- data/lib/gitlab/version.rb +1 -1
- data/spec/fixtures/branch_delete.json +0 -0
- data/spec/fixtures/get_repository_file.json +1 -0
- data/spec/fixtures/group_create_with_description.json +1 -0
- data/spec/fixtures/group_search.json +2 -0
- data/spec/fixtures/namespaces.json +1 -0
- data/spec/fixtures/project_commit_status.json +42 -0
- data/spec/fixtures/project_edit.json +21 -0
- data/spec/fixtures/project_fork.json +50 -0
- data/spec/fixtures/project_forked_for_user.json +50 -0
- data/spec/fixtures/project_update_commit_status.json +20 -0
- data/spec/fixtures/snippet_content.json +3 -0
- data/spec/fixtures/user.json +1 -1
- data/spec/fixtures/user_block_unblock.json +1 -0
- data/spec/fixtures/users.json +1 -1
- data/spec/gitlab/cli_helpers_spec.rb +6 -6
- data/spec/gitlab/cli_spec.rb +16 -0
- data/spec/gitlab/client/commits_spec.rb +137 -0
- data/spec/gitlab/client/groups_spec.rb +51 -13
- data/spec/gitlab/client/namespaces_spec.rb +22 -0
- data/spec/gitlab/client/projects_spec.rb +51 -0
- data/spec/gitlab/client/repositories_spec.rb +0 -88
- data/spec/gitlab/client/repository_files_spec.rb +17 -0
- data/spec/gitlab/client/snippets_spec.rb +15 -0
- data/spec/gitlab/client/users_spec.rb +73 -0
- data/spec/gitlab/help_spec.rb +1 -1
- data/spec/gitlab/request_spec.rb +16 -3
- data/spec/gitlab/shell_spec.rb +2 -2
- metadata +51 -6
data/lib/gitlab/client/groups.rb
CHANGED
@@ -29,11 +29,15 @@ class Gitlab::Client
|
|
29
29
|
|
30
30
|
# Creates a new group.
|
31
31
|
#
|
32
|
+
# @example
|
33
|
+
# Gitlab.create_group('new-group', 'group-path')
|
34
|
+
# Gitlab.create_group('gitlab', 'gitlab-path', :description => "New Gitlab project")
|
35
|
+
#
|
32
36
|
# @param [String] name The name of a group.
|
33
37
|
# @param [String] path The path of a group.
|
34
38
|
# @return [Gitlab::ObjectifiedHash] Information about created group.
|
35
|
-
def create_group(name, path)
|
36
|
-
body = {:name => name, :path => path}
|
39
|
+
def create_group(name, path, options={})
|
40
|
+
body = {:name => name, :path => path}.merge(options)
|
37
41
|
post("/groups", :body => body)
|
38
42
|
end
|
39
43
|
|
@@ -79,11 +83,30 @@ class Gitlab::Client
|
|
79
83
|
|
80
84
|
# Transfers a project to a group
|
81
85
|
#
|
86
|
+
# @example
|
87
|
+
# Gitlab.transfer_project_to_group(3, 50)
|
88
|
+
#
|
82
89
|
# @param [Integer] id The ID of a group.
|
83
90
|
# @param [Integer] project_id The ID of a project.
|
84
91
|
def transfer_project_to_group(id, project_id)
|
85
92
|
body = {:id => id, :project_id => project_id}
|
86
93
|
post("/groups/#{id}/projects/#{project_id}", :body => body)
|
87
94
|
end
|
95
|
+
|
96
|
+
# Search for groups by name
|
97
|
+
#
|
98
|
+
# @example
|
99
|
+
# Gitlab.group_search('gitlab')
|
100
|
+
#
|
101
|
+
# @param [String] search A string to search for in group names and paths.
|
102
|
+
# @param [Hash] options A customizable set of options.
|
103
|
+
# @option options [String] :per_page Number of projects to return per page
|
104
|
+
# @option options [String] :page The page to retrieve
|
105
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
106
|
+
def group_search(search, options={})
|
107
|
+
options[:search] = search
|
108
|
+
get("/groups", :query => options)
|
109
|
+
end
|
110
|
+
|
88
111
|
end
|
89
112
|
end
|
data/lib/gitlab/client/issues.rb
CHANGED
@@ -37,6 +37,10 @@ class Gitlab::Client
|
|
37
37
|
|
38
38
|
# Creates a new issue.
|
39
39
|
#
|
40
|
+
# @example
|
41
|
+
# Gitlab.create_issue(5, 'New issue')
|
42
|
+
# Gitlab.create_issue(5, 'New issue', :description => "This is a new issue", :assignee_id => 42)
|
43
|
+
#
|
40
44
|
# @param [Integer] project The ID of a project.
|
41
45
|
# @param [String] title The title of an issue.
|
42
46
|
# @param [Hash] options A customizable set of options.
|
@@ -52,6 +56,9 @@ class Gitlab::Client
|
|
52
56
|
|
53
57
|
# Updates an issue.
|
54
58
|
#
|
59
|
+
# @example
|
60
|
+
# Gitlab.edit_issue(6, 1, :title => 'Updated title')
|
61
|
+
#
|
55
62
|
# @param [Integer] project The ID of a project.
|
56
63
|
# @param [Integer] id The ID of an issue.
|
57
64
|
# @param [Hash] options A customizable set of options.
|
@@ -44,6 +44,9 @@ class Gitlab::Client
|
|
44
44
|
|
45
45
|
# Creates a new milestone.
|
46
46
|
#
|
47
|
+
# @example
|
48
|
+
# Gitlab.create_milestone(5, 'v1.0')
|
49
|
+
#
|
47
50
|
# @param [Integer] project The ID of a project.
|
48
51
|
# @param [String] title The title of a milestone.
|
49
52
|
# @param [Hash] options A customizable set of options.
|
@@ -57,6 +60,9 @@ class Gitlab::Client
|
|
57
60
|
|
58
61
|
# Updates a milestone.
|
59
62
|
#
|
63
|
+
# @example
|
64
|
+
# Gitlab.edit_milestone(5, 2, :state_event => 'activate')
|
65
|
+
#
|
60
66
|
# @param [Integer] project The ID of a project.
|
61
67
|
# @param [Integer] id The ID of a milestone.
|
62
68
|
# @param [Hash] options A customizable set of options.
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Gitlab::Client
|
2
|
+
# Defines methods related to namespaces
|
3
|
+
# @see https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/namespaces.md
|
4
|
+
module Namespaces
|
5
|
+
# Gets a list of namespaces.
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# Gitlab.namespaces
|
9
|
+
#
|
10
|
+
# @param [Hash] options A customizable set of options.
|
11
|
+
# @options options [Integer] :page The page number.
|
12
|
+
# @options options [Integer] :per_page The number of results per page.
|
13
|
+
# @options opttion [String] :search The string to search for.
|
14
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
15
|
+
def namespaces(options={})
|
16
|
+
get("/namespaces", :query => options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/gitlab/client/notes.rb
CHANGED
@@ -83,6 +83,9 @@ class Gitlab::Client
|
|
83
83
|
|
84
84
|
# Creates a new wall note.
|
85
85
|
#
|
86
|
+
# @example
|
87
|
+
# Gitlab.create_note(5, 'This is a wall note!')
|
88
|
+
#
|
86
89
|
# @param [Integer] project The ID of a project.
|
87
90
|
# @param [String] body The body of a note.
|
88
91
|
# @return [Gitlab::ObjectifiedHash] Information about created note.
|
@@ -92,6 +95,9 @@ class Gitlab::Client
|
|
92
95
|
|
93
96
|
# Creates a new issue note.
|
94
97
|
#
|
98
|
+
# @example
|
99
|
+
# Gitlab.create_issue_note(6, 1, 'Adding a note to my issue.')
|
100
|
+
#
|
95
101
|
# @param [Integer] project The ID of a project.
|
96
102
|
# @param [Integer] issue The ID of an issue.
|
97
103
|
# @param [String] body The body of a note.
|
@@ -102,6 +108,9 @@ class Gitlab::Client
|
|
102
108
|
|
103
109
|
# Creates a new snippet note.
|
104
110
|
#
|
111
|
+
# @example
|
112
|
+
# Gitlab.create_snippet_note(3, 2, 'Look at this awesome snippet!')
|
113
|
+
#
|
105
114
|
# @param [Integer] project The ID of a project.
|
106
115
|
# @param [Integer] snippet The ID of a snippet.
|
107
116
|
# @param [String] body The body of a note.
|
@@ -112,6 +121,9 @@ class Gitlab::Client
|
|
112
121
|
|
113
122
|
# Creates a new note for a single merge request.
|
114
123
|
#
|
124
|
+
# @example
|
125
|
+
# Gitlab.create_merge_request_note(5, 3, 'This MR is ready for review.')
|
126
|
+
#
|
115
127
|
# @param [Integer] project The ID of a project.
|
116
128
|
# @param [Integer] merge_request The ID of a merge request.
|
117
129
|
# @param [String] body The content of a note.
|
@@ -321,5 +321,35 @@ class Gitlab::Client
|
|
321
321
|
def delete_deploy_key(project, id)
|
322
322
|
delete("/projects/#{project}/keys/#{id}")
|
323
323
|
end
|
324
|
+
|
325
|
+
# Forks a project into the user namespace.
|
326
|
+
#
|
327
|
+
# @example
|
328
|
+
# Gitlab.create_fork(42)
|
329
|
+
# Gitlab.create_fork(42, :sudo => 'another_username')
|
330
|
+
#
|
331
|
+
# @param [Integer] project The ID of a project.
|
332
|
+
# @param [Hash] options A customizable set of options.
|
333
|
+
# @option options [String] :sudo The username the project will be forked for
|
334
|
+
# @return [Gitlab::ObjectifiedHash] Information about the forked project.
|
335
|
+
def create_fork(id, options = {})
|
336
|
+
post("/projects/fork/#{id}", body: options)
|
337
|
+
end
|
338
|
+
|
339
|
+
# Updates an existing project.
|
340
|
+
#
|
341
|
+
# @example
|
342
|
+
# Gitlab.edit_project(42)
|
343
|
+
# Gitlab.edit_project(42, :name => 'project_name')
|
344
|
+
#
|
345
|
+
# @param [Integer] project The ID of a project.
|
346
|
+
# @param [Hash] options A customizable set of options.
|
347
|
+
# @option options [String] :name The name of a project
|
348
|
+
# @option options [String] :path The name of a project
|
349
|
+
# @option options [String] :description The name of a project
|
350
|
+
# @return [Gitlab::ObjectifiedHash] Information about the edited project.
|
351
|
+
def edit_project(id, options={})
|
352
|
+
put("/projects/#{id}", :query => options)
|
353
|
+
end
|
324
354
|
end
|
325
355
|
end
|
@@ -33,51 +33,6 @@ class Gitlab::Client
|
|
33
33
|
end
|
34
34
|
alias_method :repo_create_tag, :create_tag
|
35
35
|
|
36
|
-
# Gets a list of project commits.
|
37
|
-
#
|
38
|
-
# @example
|
39
|
-
# Gitlab.commits('viking')
|
40
|
-
# Gitlab.repo_commits('gitlab', :ref_name => 'api')
|
41
|
-
#
|
42
|
-
# @param [Integer] project The ID of a project.
|
43
|
-
# @param [Hash] options A customizable set of options.
|
44
|
-
# @option options [String] :ref_name The branch or tag name of a project repository.
|
45
|
-
# @option options [Integer] :page The page number.
|
46
|
-
# @option options [Integer] :per_page The number of results per page.
|
47
|
-
# @return [Array<Gitlab::ObjectifiedHash>]
|
48
|
-
def commits(project, options={})
|
49
|
-
get("/projects/#{project}/repository/commits", :query => options)
|
50
|
-
end
|
51
|
-
alias_method :repo_commits, :commits
|
52
|
-
|
53
|
-
# Gets a specific commit identified by the commit hash or name of a branch or tag.
|
54
|
-
#
|
55
|
-
# @example
|
56
|
-
# Gitlab.commit(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
|
57
|
-
# Gitlab.repo_commit(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
|
58
|
-
#
|
59
|
-
# @param [Integer] project The ID of a project.
|
60
|
-
# @param [String] sha The commit hash or name of a repository branch or tag
|
61
|
-
# @return [Gitlab::ObjectifiedHash]
|
62
|
-
def commit(project, sha)
|
63
|
-
get("/projects/#{project}/repository/commits/#{sha}")
|
64
|
-
end
|
65
|
-
alias_method :repo_commit, :commit
|
66
|
-
|
67
|
-
# Get the diff of a commit in a project.
|
68
|
-
#
|
69
|
-
# @example
|
70
|
-
# Gitlab.commit_diff(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
|
71
|
-
# Gitlab.repo_commit_diff(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
|
72
|
-
#
|
73
|
-
# @param [Integer] project The ID of a project.
|
74
|
-
# @param [String] sha The name of a repository branch or tag or if not given the default branch.
|
75
|
-
# @return [Gitlab::ObjectifiedHash]
|
76
|
-
def commit_diff(project, sha)
|
77
|
-
get("/projects/#{project}/repository/commits/#{sha}/diff")
|
78
|
-
end
|
79
|
-
alias_method :repo_commit_diff, :commit_diff
|
80
|
-
|
81
36
|
# Get the contents of a file
|
82
37
|
#
|
83
38
|
# @example
|
@@ -97,36 +52,6 @@ class Gitlab::Client
|
|
97
52
|
end
|
98
53
|
alias_method :repo_file_contents, :file_contents
|
99
54
|
|
100
|
-
# Gets a list of comments for a commit.
|
101
|
-
#
|
102
|
-
# @example
|
103
|
-
# Gitlab.commit_comments(5, c9f9662a9b1116c838b523ed64c6abdb4aae4b8b)
|
104
|
-
#
|
105
|
-
# @param [Integer] project The ID of a project.
|
106
|
-
# @param [String] sha The commit hash or name of a repository branch or tag.
|
107
|
-
# @option options [Integer] :page The page number.
|
108
|
-
# @option options [Integer] :per_page The number of results per page.
|
109
|
-
# @return [Array<Gitlab::ObjectifiedHash>]
|
110
|
-
def commit_comments(project, commit, options={})
|
111
|
-
get("/projects/#{project}/repository/commits/#{commit}/comments", :query => options)
|
112
|
-
end
|
113
|
-
alias_method :repo_commit_comments, :commit_comments
|
114
|
-
|
115
|
-
# Creates a new comment for a commit.
|
116
|
-
#
|
117
|
-
# @param [Integer] project The ID of a project.
|
118
|
-
# @param [String] sha The commit hash or name of a repository branch or tag.
|
119
|
-
# @param [String] note The text of a comment.
|
120
|
-
# @param [Hash] options A customizable set of options.
|
121
|
-
# @option options [String] :path The file path.
|
122
|
-
# @option options [Integer] :line The line number.
|
123
|
-
# @option options [String] :line_type The line type (new or old).
|
124
|
-
# @return [Gitlab::ObjectifiedHash] Information about created comment.
|
125
|
-
def create_commit_comment(project, commit, note, options={})
|
126
|
-
post("/projects/#{project}/repository/commits/#{commit}/comments", :body => options.merge(:note => note))
|
127
|
-
end
|
128
|
-
alias_method :repo_create_commit_comment, :create_commit_comment
|
129
|
-
|
130
55
|
# Get file tree project (root level).
|
131
56
|
#
|
132
57
|
# @example
|
@@ -4,6 +4,22 @@ class Gitlab::Client
|
|
4
4
|
# Defines methods related to repository files.
|
5
5
|
# @see https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/repository_files.md
|
6
6
|
module RepositoryFiles
|
7
|
+
# Gets a repository file.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.get_file(42, "README.md", "master")
|
11
|
+
#
|
12
|
+
# @param [Integer] project The ID of a project.
|
13
|
+
# @param [String] file_path The full path of the file.
|
14
|
+
# @param [String] ref The name of branch, tag or commit.
|
15
|
+
# @return [Gitlab::ObjectifiedHash]
|
16
|
+
def get_file(project, file_path, ref)
|
17
|
+
get("/projects/#{project}/repository/files", query: {
|
18
|
+
file_path: file_path,
|
19
|
+
ref: ref,
|
20
|
+
})
|
21
|
+
end
|
22
|
+
|
7
23
|
# Creates a new repository file.
|
8
24
|
#
|
9
25
|
# @example
|
@@ -72,5 +72,20 @@ class Gitlab::Client
|
|
72
72
|
def delete_snippet(project, id)
|
73
73
|
delete("/projects/#{project}/snippets/#{id}")
|
74
74
|
end
|
75
|
+
|
76
|
+
# Returns raw project snippet content as plain text.
|
77
|
+
#
|
78
|
+
# @example
|
79
|
+
# Gitlab.snippet_content(2, 14)
|
80
|
+
#
|
81
|
+
# @param [Integer] project The ID of a project.
|
82
|
+
# @param [Integer] id The ID of a snippet.
|
83
|
+
# @return [Gitlab::ObjectifiedHash] Information about deleted snippet.
|
84
|
+
def snippet_content(project, id)
|
85
|
+
get("/projects/#{project}/snippets/#{id}/raw",
|
86
|
+
format: nil,
|
87
|
+
headers: { Accept: 'text/plain' },
|
88
|
+
parser: ::Gitlab::Request::Parser)
|
89
|
+
end
|
75
90
|
end
|
76
91
|
end
|
data/lib/gitlab/client/users.rb
CHANGED
@@ -32,8 +32,14 @@ class Gitlab::Client
|
|
32
32
|
# Creates a new user.
|
33
33
|
# Requires authentication from an admin account.
|
34
34
|
#
|
35
|
+
# @example
|
36
|
+
# Gitlab.create_user('joe@foo.org', 'secret', 'joe', :name => 'Joe Smith')
|
37
|
+
# or
|
38
|
+
# Gitlab.create_user('joe@foo.org', 'secret')
|
39
|
+
#
|
35
40
|
# @param [String] email The email of a user.
|
36
41
|
# @param [String] password The password of a user.
|
42
|
+
# @param [String] username The username of a user.
|
37
43
|
# @param [Hash] options A customizable set of options.
|
38
44
|
# @option options [String] :name The name of a user. Defaults to email.
|
39
45
|
# @option options [String] :skype The skype of a user.
|
@@ -41,17 +47,26 @@ class Gitlab::Client
|
|
41
47
|
# @option options [String] :twitter The twitter of a user.
|
42
48
|
# @option options [Integer] :projects_limit The limit of projects for a user.
|
43
49
|
# @return [Gitlab::ObjectifiedHash] Information about created user.
|
44
|
-
def create_user(
|
45
|
-
|
46
|
-
|
50
|
+
def create_user(*args)
|
51
|
+
options = Hash === args.last ? args.pop : {}
|
52
|
+
if args[2]
|
53
|
+
body = { email: args[0], password: args[1], username: args[2] }
|
54
|
+
else
|
55
|
+
body = { email: args[0], password: args[1], name: args[0] }
|
56
|
+
end
|
57
|
+
body.merge!(options)
|
58
|
+
post('/users', body: body)
|
47
59
|
end
|
48
60
|
|
49
61
|
# Updates a user.
|
50
62
|
#
|
63
|
+
# @example
|
64
|
+
# Gitlab.edit_user(15, :email => 'joe.smith@foo.org', :projects_limit => 20)
|
65
|
+
#
|
51
66
|
# @param [Integer] id The ID of a user.
|
52
67
|
# @param [Hash] options A customizable set of options.
|
53
|
-
# @option options [String] email The email of a user.
|
54
|
-
# @option options [String] password The password of a user.
|
68
|
+
# @option options [String] :email The email of a user.
|
69
|
+
# @option options [String] :password The password of a user.
|
55
70
|
# @option options [String] :name The name of a user. Defaults to email.
|
56
71
|
# @option options [String] :skype The skype of a user.
|
57
72
|
# @option options [String] :linkedin The linkedin of a user.
|
@@ -62,6 +77,39 @@ class Gitlab::Client
|
|
62
77
|
put("/users/#{user_id}", :body => options)
|
63
78
|
end
|
64
79
|
|
80
|
+
# Deletes a user.
|
81
|
+
#
|
82
|
+
# @example
|
83
|
+
# Gitlab.delete_user(1)
|
84
|
+
#
|
85
|
+
# @param [Integer] id The ID of a user.
|
86
|
+
# @return [Gitlab::ObjectifiedHash] Information about deleted user.
|
87
|
+
def delete_user(user_id)
|
88
|
+
delete("/users/#{user_id}")
|
89
|
+
end
|
90
|
+
|
91
|
+
# Blocks the specified user. Available only for admin.
|
92
|
+
#
|
93
|
+
# @example
|
94
|
+
# Gitlab.block_user(15)
|
95
|
+
#
|
96
|
+
# @param [Integer] user_id The Id of user
|
97
|
+
# @return [Boolean] success or not
|
98
|
+
def block_user(user_id)
|
99
|
+
put("/users/#{user_id}/block")
|
100
|
+
end
|
101
|
+
|
102
|
+
# Unblocks the specified user. Available only for admin.
|
103
|
+
#
|
104
|
+
# @example
|
105
|
+
# Gitlab.unblock_user(15)
|
106
|
+
#
|
107
|
+
# @param [Integer] user_id The Id of user
|
108
|
+
# @return [Boolean] success or not
|
109
|
+
def unblock_user(user_id)
|
110
|
+
put("/users/#{user_id}/unblock")
|
111
|
+
end
|
112
|
+
|
65
113
|
# Creates a new user session.
|
66
114
|
#
|
67
115
|
# @example
|
@@ -121,5 +169,6 @@ class Gitlab::Client
|
|
121
169
|
def delete_ssh_key(id)
|
122
170
|
delete("/user/keys/#{id}")
|
123
171
|
end
|
172
|
+
|
124
173
|
end
|
125
174
|
end
|
data/lib/gitlab/configuration.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'gitlab/cli_helpers'
|
1
2
|
module Gitlab
|
2
3
|
# Defines constants and methods related to configuration.
|
3
4
|
module Configuration
|
@@ -34,8 +35,21 @@ module Gitlab
|
|
34
35
|
def reset
|
35
36
|
self.endpoint = ENV['GITLAB_API_ENDPOINT']
|
36
37
|
self.private_token = ENV['GITLAB_API_PRIVATE_TOKEN'] || ENV['GITLAB_API_AUTH_TOKEN']
|
38
|
+
self.httparty = get_httparty_config(ENV['GITLAB_API_HTTPARTY_OPTIONS'])
|
37
39
|
self.sudo = nil
|
38
40
|
self.user_agent = DEFAULT_USER_AGENT
|
39
41
|
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
# Allows HTTParty config to be specified in ENV using YAML hash.
|
46
|
+
def get_httparty_config options
|
47
|
+
return options if options.nil?
|
48
|
+
|
49
|
+
httparty = Gitlab::CLI::Helpers.yaml_load(options)
|
50
|
+
|
51
|
+
raise ArgumentError, "HTTParty config should be a Hash." unless httparty.is_a? Hash
|
52
|
+
Gitlab::CLI::Helpers.symbolize_keys httparty
|
53
|
+
end
|
40
54
|
end
|
41
55
|
end
|
data/lib/gitlab/error.rb
CHANGED
@@ -27,6 +27,9 @@ module Gitlab
|
|
27
27
|
# Raised when API endpoint returns the HTTP status code 409.
|
28
28
|
class Conflict < Error; end
|
29
29
|
|
30
|
+
# Raised when API endpoint returns the HTTP status code 422.
|
31
|
+
class Unprocessable < Error; end
|
32
|
+
|
30
33
|
# Raised when API endpoint returns the HTTP status code 500.
|
31
34
|
class InternalServerError < Error; end
|
32
35
|
|