gitlab 4.8.0 → 4.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -7
  3. data/lib/gitlab/cli.rb +0 -3
  4. data/lib/gitlab/cli_helpers.rb +11 -10
  5. data/lib/gitlab/client.rb +15 -0
  6. data/lib/gitlab/client/application_settings.rb +172 -0
  7. data/lib/gitlab/client/avatar.rb +21 -0
  8. data/lib/gitlab/client/boards.rb +56 -0
  9. data/lib/gitlab/client/build_variables.rb +14 -10
  10. data/lib/gitlab/client/commits.rb +18 -2
  11. data/lib/gitlab/client/container_registry.rb +85 -0
  12. data/lib/gitlab/client/epics.rb +73 -0
  13. data/lib/gitlab/client/features.rb +48 -0
  14. data/lib/gitlab/client/group_boards.rb +141 -0
  15. data/lib/gitlab/client/group_labels.rb +88 -0
  16. data/lib/gitlab/client/groups.rb +66 -2
  17. data/lib/gitlab/client/issue_links.rb +48 -0
  18. data/lib/gitlab/client/labels.rb +1 -1
  19. data/lib/gitlab/client/lint.rb +19 -0
  20. data/lib/gitlab/client/markdown.rb +23 -0
  21. data/lib/gitlab/client/merge_request_approvals.rb +9 -8
  22. data/lib/gitlab/client/merge_requests.rb +12 -0
  23. data/lib/gitlab/client/notes.rb +1 -1
  24. data/lib/gitlab/client/pipelines.rb +12 -0
  25. data/lib/gitlab/client/project_clusters.rb +83 -0
  26. data/lib/gitlab/client/project_release_links.rb +76 -0
  27. data/lib/gitlab/client/project_releases.rb +79 -0
  28. data/lib/gitlab/client/projects.rb +27 -6
  29. data/lib/gitlab/client/repositories.rb +5 -3
  30. data/lib/gitlab/client/repository_files.rb +16 -0
  31. data/lib/gitlab/client/resource_label_events.rb +82 -0
  32. data/lib/gitlab/client/runners.rb +49 -2
  33. data/lib/gitlab/client/search.rb +66 -0
  34. data/lib/gitlab/client/users.rb +7 -9
  35. data/lib/gitlab/configuration.rb +1 -1
  36. data/lib/gitlab/error.rb +46 -1
  37. data/lib/gitlab/paginated_response.rb +19 -0
  38. data/lib/gitlab/request.rb +15 -25
  39. data/lib/gitlab/shell_history.rb +4 -8
  40. data/lib/gitlab/version.rb +1 -1
  41. metadata +33 -15
  42. data/.github/stale.yml +0 -18
  43. data/.gitignore +0 -22
  44. data/.rubocop_todo.yml +0 -46
  45. data/CONTRIBUTING.md +0 -195
  46. data/Gemfile +0 -6
  47. data/Rakefile +0 -15
  48. data/bin/console +0 -11
  49. data/bin/setup +0 -6
  50. data/gitlab.gemspec +0 -36
@@ -8,11 +8,11 @@ class Gitlab::Client
8
8
  #
9
9
  # @example
10
10
  # Gitlab.commits('viking')
11
- # Gitlab.repo_commits('gitlab', { ref_name: 'api' })
11
+ # Gitlab.repo_commits('gitlab', { ref: 'api' })
12
12
  #
13
13
  # @param [Integer, String] project The ID or name of a project.
14
14
  # @param [Hash] options A customizable set of options.
15
- # @option options [String] :ref_name The branch or tag name of a project repository.
15
+ # @option options [String] :ref The branch or tag name of a project repository.
16
16
  # @option options [Integer] :page The page number.
17
17
  # @option options [Integer] :per_page The number of results per page.
18
18
  # @return [Array<Gitlab::ObjectifiedHash>]
@@ -35,6 +35,22 @@ class Gitlab::Client
35
35
  end
36
36
  alias repo_commit commit
37
37
 
38
+ # Get all references (from branches or tags) a commit is pushed to.
39
+ #
40
+ # @example
41
+ # Gitlab.commit_refs(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
42
+ #
43
+ # @param [Integer, String] project The ID or name of a project.
44
+ # @param [String] sha The commit hash
45
+ # @param [Hash] options A customizable set of options.
46
+ # @option options [String] :type The scope of commits. Possible values `branch`, `tag`, `all`. Default is `all`.
47
+ # @option options [Integer] :page The page number.
48
+ # @option options [Integer] :per_page The number of results per page.
49
+ # @return [Gitlab::ObjectifiedHash]
50
+ def commit_refs(project, sha, options = {})
51
+ get("/projects/#{url_encode project}/repository/commits/#{sha}/refs", query: options)
52
+ end
53
+
38
54
  # Cherry picks a commit to a given branch.
39
55
  #
40
56
  # @example
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to GitLab Container Registry.
5
+ # @see https://docs.gitlab.com/ce/api/container_registry.html
6
+ module ContainerRegistry
7
+ # Get a list of registry repositories in a project.
8
+ #
9
+ # @example
10
+ # Gitlab.registry_repositories(5)
11
+ #
12
+ # @param [Integer, String] project The ID or name of a project.
13
+ # @return [Array<Gitlab::ObjectifiedHash>] Returns list of registry repositories in a project.
14
+ def registry_repositories(project)
15
+ get("/projects/#{url_encode project}/registry/repositories")
16
+ end
17
+
18
+ # Delete a repository in registry.
19
+ #
20
+ # @example
21
+ # Gitlab.delete_registry_repository(5, 2)
22
+ #
23
+ # @param [Integer, String] project The ID or name of a project.
24
+ # @param [Integer] id The ID of registry repository.
25
+ # @return [void] This API call returns an empty response body.
26
+ def delete_registry_repository(project, id)
27
+ delete("/projects/#{url_encode project}/registry/repositories/#{id}")
28
+ end
29
+
30
+ # Get a list of tags for given registry repository.
31
+ #
32
+ # @example
33
+ # Gitlab.registry_repository_tags(5, 2)
34
+ #
35
+ # @param [Integer, String] project The ID or name of a project.
36
+ # @param [Integer] repository_id The ID of registry repository.
37
+ # @return [Array<Gitlab::ObjectifiedHash>] Returns list of tags of a registry repository.
38
+ def registry_repository_tags(project, repository_id)
39
+ get("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags")
40
+ end
41
+
42
+ # Get details of a registry repository tag.
43
+ #
44
+ # @example
45
+ # Gitlab.registry_repository_tag(5, 2, 'v10.0.0')
46
+ #
47
+ # @param [Integer, String] project The ID or name of a project.
48
+ # @param [Integer] repository_id The ID of registry repository.
49
+ # @param [String] tag_name The name of tag.
50
+ # @return <Gitlab::ObjectifiedHash> Returns details about the registry repository tag
51
+ def registry_repository_tag(project, repository_id, tag_name)
52
+ get("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags/#{tag_name}")
53
+ end
54
+
55
+ # Delete a registry repository tag.
56
+ #
57
+ # @example
58
+ # Gitlab.delete_registry_repository_tag(5, 2, 'v10.0.0')
59
+ #
60
+ # @param [Integer, String] project The ID or name of a project.
61
+ # @param [Integer] repository_id The ID of registry repository.
62
+ # @param [String] tag_name The name of tag.
63
+ # @return [void] This API call returns an empty response body.
64
+ def delete_registry_repository_tag(project, repository_id, tag_name)
65
+ delete("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags/#{tag_name}")
66
+ end
67
+
68
+ # Delete repository tags in bulk based on given criteria.
69
+ #
70
+ # @example
71
+ # Gitlab.bulk_delete_registry_repository_tags(5, 2, name_regex: '.*')
72
+ # Gitlab.bulk_delete_registry_repository_tags(5, 2, name_regex: '[0-9a-z]{40}', keep_n: 5, older_than: '1d')
73
+ #
74
+ # @param [Integer, String] project The ID or name of a project.
75
+ # @param [Integer] repository_id The ID of registry repository.
76
+ # @param [Hash] options A customizable set of options.
77
+ # @option options [String] :name_regex(required) The regex of the name to delete. To delete all tags specify .*.
78
+ # @option options [Integer] :keep_n(optional) The amount of latest tags of given name to keep.
79
+ # @option options [String] :older_than(required) Tags to delete that are older than the given time, written in human readable form 1h, 1d, 1month.
80
+ # @return [void] This API call returns an empty response body.
81
+ def bulk_delete_registry_repository_tags(project, repository_id, options = {})
82
+ delete("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags", query: options)
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to Epics.
5
+ # @see https://docs.gitlab.com/ee/api/epics.html
6
+ module Epics
7
+ # Gets a list of epics.
8
+ #
9
+ # @example
10
+ # Gitlab.epics(123)
11
+ # Gitlab.epics(123, { per_page: 40, page: 2 })
12
+ #
13
+ # @param [Integer] group_id The ID of a group.
14
+ # @param [Hash] options A customizable set of options.
15
+ # @option options [Integer] :page The page number.
16
+ # @option options [Integer] :per_page The number of results per page.
17
+ # @return [Array<Gitlab::ObjectifiedHash>]
18
+ def epics(group_id, options = {})
19
+ get("/groups/#{group_id}/epics", query: options)
20
+ end
21
+
22
+ # Gets a single epic.
23
+ #
24
+ # @example
25
+ # Gitlab.epic(123, 1)
26
+ #
27
+ # @param [Integer] group_id The ID of a group.
28
+ # @param [Integer] epic_iid The ID of a epic.
29
+ # @param [Hash] options A customizable set of options.
30
+ # @return [Gitlab::ObjectifiedHash]
31
+ def epic(group_id, epic_iid, options = {})
32
+ get("/groups/#{group_id}/epics/#{epic_iid}", query: options)
33
+ end
34
+
35
+ # Creates a new epic.
36
+ #
37
+ # @example
38
+ # Gitlab.create_epic(123, "My new epic title")
39
+ #
40
+ # @param [Integer] group_id The ID of a group.
41
+ # @param [String] title
42
+ # @param [Hash] options A customizable set of options.
43
+ # @return [Gitlab::ObjectifiedHash] Information about created epic.
44
+ def create_epic(group_id, title, options = {})
45
+ body = options.merge(title: title)
46
+ post("/groups/#{group_id}/epics", body: body)
47
+ end
48
+
49
+ # Deletes an epic.
50
+ #
51
+ # @example
52
+ # Gitlab.delete_epic(42, 123)
53
+ # @param [Integer] group_id The ID of a group.
54
+ # @param [Integer] epic_iid The IID of an epic.
55
+ def delete_epic(group_id, epic_iid)
56
+ delete("/groups/#{group_id}/epics/#{epic_iid}")
57
+ end
58
+
59
+ # Updates an existing epic.
60
+ #
61
+ # @example
62
+ # Gitlab.edit_epic(42)
63
+ # Gitlab.edit_epic(42, 123, { title: 'New epic title' })
64
+ #
65
+ # @param [Integer] group_id The ID.
66
+ # @param [Integer] epic_iid The IID of an epic.
67
+ # @param [Hash] options A customizable set of options
68
+ # @return [Gitlab::ObjectifiedHash] Information about the edited epic.
69
+ def edit_epic(group_id, epic_iid, options = {})
70
+ put("/groups/#{group_id}/epics/#{epic_iid}", body: options)
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to feature flags.
5
+ # https://docs.gitlab.com/ce/api/features.html
6
+ module Features
7
+ # Get a list of all persisted features, with its gate values.
8
+ #
9
+ # @example
10
+ # Gitlab.features
11
+ #
12
+ # @return [Array<Gitlab::ObjectifiedHash>]
13
+ def features
14
+ get('/features')
15
+ end
16
+
17
+ # Set a features gate value.
18
+ # If a feature with the given name does not exist yet it will be created. The value can be a boolean, or an integer to indicate percentage of time.
19
+ #
20
+ # @example
21
+ # Gitlab.set_feature('new_library', true)
22
+ # Gitlab.set_feature('new_library', 8)
23
+ # Gitlab.set_feature('new_library', true, {user: 'gitlab'})
24
+ #
25
+ # @param [String] name(required) Name of the feature to create or update
26
+ # @param [String, Integer] value(required) true or false to enable/disable, or an integer for percentage of time
27
+ # @param [Hash] options A customizable set of options.
28
+ # @option options [String] :feature_group(optional) A Feature group name
29
+ # @option options [String] :user(optional) A GitLab username
30
+ # @option options [String] :project(optional) A projects path, for example "gitlab-org/gitlab-ce"
31
+ # @return [Gitlab::ObjectifiedHash] Information about the set/created/updated feature.
32
+ def set_feature(name, value, options = {})
33
+ body = { value: value }.merge(options)
34
+ post("/features/#{name}", body: body)
35
+ end
36
+
37
+ # Delete a feature.
38
+ #
39
+ # @example
40
+ # Gitlab.delete_feature('new_library')
41
+ #
42
+ # @param [String] name Name of the feature to delete
43
+ # @return [void] This API call returns an empty response body.
44
+ def delete_feature(name)
45
+ delete("/features/#{name}")
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,141 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to group issue boards.
5
+ # @see https://docs.gitlab.com/ee/api/group_boards.html
6
+ module GroupBoards
7
+ # Lists Issue Boards in the given group.
8
+ #
9
+ # @example
10
+ # Gitlab.group_boards(5)
11
+ #
12
+ # @param [Integer, String] group The ID or name of a group.
13
+ # @return [Array<Gitlab::ObjectifiedHash>] List of issue boards of the group
14
+ def group_boards(group)
15
+ get("/groups/#{url_encode group}/boards")
16
+ end
17
+
18
+ # Gets a single group issue board.
19
+ #
20
+ # @example
21
+ # Gitlab.group_board(5, 1)
22
+ #
23
+ # @param [Integer, String] group The ID or name of a group.
24
+ # @param [Integer] id The ID of the issue board.
25
+ # @return [Gitlab::ObjectifiedHash] Returns information about a group issue board
26
+ def group_board(group, id)
27
+ get("/groups/#{url_encode group}/boards/#{id}")
28
+ end
29
+
30
+ # Creates a new group issue board.
31
+ #
32
+ # @example
33
+ # Gitlab.create_group_board(5, 'Documentcloud')
34
+ #
35
+ # @param [Integer, String] group The ID or name of a group.
36
+ # @param [String] name The name of the new board.
37
+ # @return [Gitlab::ObjectifiedHash] Information about created group issue board.
38
+ def create_group_board(group, name)
39
+ body = { name: name }
40
+ post("/groups/#{url_encode group}/boards", body: body)
41
+ end
42
+
43
+ # Updates a group issue board.
44
+ #
45
+ # @example
46
+ # Gitlab.edit_group_board(5, 1, { name: 'DocumentCloud2' })
47
+ # Gitlab.edit_group_board(5, 1, { name: 'DocumentCloud2', assignee_id: 3 })
48
+ #
49
+ # @param [Integer, String] group The ID or name of a group.
50
+ # @param [Integer] id The ID of the issue board.
51
+ # @param [Hash] options A customizable set of options.
52
+ # @option options [String] :name(optional) The new name of the board.
53
+ # @option options [Integer] :assignee_id(optional) The assignee the board should be scoped to.
54
+ # @option options [Integer] :milestone_id(optional) The milestone the board should be scoped to.
55
+ # @option options [String] :labels(optional) Comma-separated list of label names which the board should be scoped to.
56
+ # @option options [Integer] :weight(optional) The weight range from 0 to 9, to which the board should be scoped to.
57
+ # @return [Gitlab::ObjectifiedHash] Information about updated group issue board.
58
+ def edit_group_board(group, id, options = {})
59
+ put("/groups/#{url_encode group}/boards/#{id}", body: options)
60
+ end
61
+
62
+ # Deletes a group issue board.
63
+ #
64
+ # @example
65
+ # Gitlab.delete_group_board(5, 1)
66
+ #
67
+ # @param [Integer, String] group The ID or name of a group.
68
+ # @param [Integer] id The ID of the issue board.
69
+ # @return [void] This API call returns an empty response body.
70
+ def delete_group_board(group, id)
71
+ delete("/groups/#{url_encode group}/boards/#{id}")
72
+ end
73
+
74
+ # Get a list of the boards lists. Does not include open and closed lists
75
+ #
76
+ # @example
77
+ # Gitlab.group_board_lists(5, 1)
78
+ #
79
+ # @param [Integer, String] group The ID or name of a group.
80
+ # @param [Integer] board_id The ID of the group issue board.
81
+ # @return [Array<Gitlab::ObjectifiedHash>] List of boards lists of the group
82
+ def group_board_lists(group, board_id)
83
+ get("/groups/#{url_encode group}/boards/#{board_id}/lists")
84
+ end
85
+
86
+ # Get a single group issue board list.
87
+ #
88
+ # @example
89
+ # Gitlab.group_board_list(5, 1, 1)
90
+ #
91
+ # @param [Integer, String] group The ID or name of a group.
92
+ # @param [Integer] board_id The ID of the group issue board.
93
+ # @param [Integer] list_id The ID of a boards list.
94
+ # @return [Gitlab::ObjectifiedHash] Returns information about a single group issue board list
95
+ def group_board_list(group, board_id, id)
96
+ get("/groups/#{url_encode group}/boards/#{board_id}/lists/#{id}")
97
+ end
98
+
99
+ # Creates a new group issue board list.
100
+ #
101
+ # @example
102
+ # Gitlab.create_group_board_list(5, 1)
103
+ #
104
+ # @param [Integer, String] group The ID or name of a group.
105
+ # @param [Integer] board_id The ID of the group issue board.
106
+ # @param [Integer] label_id The ID of a label.
107
+ # @return [Gitlab::ObjectifiedHash] Information about created group issue board list.
108
+ def create_group_board_list(group, board_id, label_id)
109
+ body = { label_id: label_id }
110
+ post("/groups/#{url_encode group}/boards/#{board_id}/lists", body: body)
111
+ end
112
+
113
+ # Updates an existing group issue board list. This call is used to change list position.
114
+ #
115
+ # @example
116
+ # Gitlab.edit_group_board_list(5, 1, 1, { position: 1 })
117
+ #
118
+ # @param [Integer, String] group The ID or name of a group.
119
+ # @param [Integer] board_id The ID of the group issue board.
120
+ # @param [Integer] list_id The ID of a boards list.
121
+ # @param [Hash] options A customizable set of options.
122
+ # @option options [String] :position(required) The position of the list.
123
+ # @return [Gitlab::ObjectifiedHash] Information about updated group issue board list.
124
+ def edit_group_board_list(group, board_id, id, options = {})
125
+ put("/groups/#{url_encode group}/boards/#{board_id}/lists/#{id}", body: options)
126
+ end
127
+
128
+ # Deletes a group issue board list.
129
+ #
130
+ # @example
131
+ # Gitlab.delete_group_board_list(5, 1, 1)
132
+ #
133
+ # @param [Integer, String] group The ID or name of a group.
134
+ # @param [Integer] board_id The ID of the group issue board.
135
+ # @param [Integer] list_id The ID of a boards list.
136
+ # @return [void] This API call returns an empty response body.
137
+ def delete_group_board_list(group, board_id, id)
138
+ delete("/groups/#{url_encode group}/boards/#{board_id}/lists/#{id}")
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to group labels.
5
+ #
6
+ # @note Requires GitLab 11.8+
7
+ # @see https://docs.gitlab.com/ee/api/group_labels.html
8
+ module GroupLabels
9
+ # Gets a list of group's labels.
10
+ #
11
+ # @example
12
+ # Gitlab.group_labels('globex')
13
+ #
14
+ # @param [Integer, String] group The ID or name of a group.
15
+ # @return [Array<Gitlab::ObjectifiedHash>]
16
+ def group_labels(group, options = {})
17
+ get("/groups/#{url_encode group}/labels", query: options)
18
+ end
19
+
20
+ # Creates a new group label.
21
+ #
22
+ # @example
23
+ # Gitlab.create_group_label('globex', 'Backlog', '#DD10AA')
24
+ #
25
+ # @param [Integer, String] group The ID or name of a group.
26
+ # @param [String] name The name of a label.
27
+ # @param [String] color The color of a label.
28
+ # @param [Hash] options A customizable set of options.
29
+ # @option options [String] :description The description of the label.
30
+ # @return [Gitlab::ObjectifiedHash] Information about created label.
31
+ def create_group_label(group, name, color, options = {})
32
+ post("/groups/#{url_encode group}/labels", body: options.merge(name: name, color: color))
33
+ end
34
+
35
+ # Updates a group label.
36
+ #
37
+ # @example
38
+ # Gitlab.edit_group_label('globex', 'Backlog', { new_name: 'Priority' })
39
+ # Gitlab.edit_group_label('globex', 'Backlog', { new_name: 'Priority', color: '#DD10AA' })
40
+ #
41
+ # @param [Integer, String] group The ID or name of a group.
42
+ # @param [String] name The name of a label.
43
+ # @param [Hash] options A customizable set of options.
44
+ # @option options [String] :new_name The new name of a label.
45
+ # @option options [String] :color The color of a label.
46
+ # @option options [String] :description The description of the label.
47
+ # @return [Gitlab::ObjectifiedHash] Information about updated label.
48
+ def edit_group_label(group, name, options = {})
49
+ put("/groups/#{url_encode group}/labels", body: options.merge(name: name))
50
+ end
51
+
52
+ # Deletes a group label.
53
+ #
54
+ # @example
55
+ # Gitlab.delete_group_label('globex', 'Backlog')
56
+ #
57
+ # @param [Integer, String] group The ID or name of a group.
58
+ # @param [String] name The name of a label.
59
+ # @return [Gitlab::ObjectifiedHash] Information about deleted label.
60
+ def delete_group_label(group, name)
61
+ delete("/groups/#{url_encode group}/labels", body: { name: name })
62
+ end
63
+
64
+ # Subscribes the user to a group label to receive notifications
65
+ #
66
+ # @example
67
+ # Gitlab.subscribe_to_group_label('globex', 'Backlog')
68
+ #
69
+ # @param [Integer, String] group The ID or name of a group.
70
+ # @param [String] name The name of a label.
71
+ # @return [Gitlab::ObjectifiedHash] Information about the label subscribed to.
72
+ def subscribe_to_group_label(group, name)
73
+ post("/groups/#{url_encode group}/labels/#{url_encode name}/subscribe")
74
+ end
75
+
76
+ # Unsubscribes the user from a group label to not receive notifications from it
77
+ #
78
+ # @example
79
+ # Gitlab.unsubscribe_from_group_label('globex', 'Backlog')
80
+ #
81
+ # @param [Integer, String] group The ID or name of a group.
82
+ # @param [String] name The name of a label.
83
+ # @return [Gitlab::ObjectifiedHash] Information about the label unsubscribed from.
84
+ def unsubscribe_from_group_label(group, name)
85
+ post("/groups/#{url_encode group}/labels/#{url_encode name}/unsubscribe")
86
+ end
87
+ end
88
+ end