gitlab 4.8.0 → 4.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fef48a733afd37fc66b1b532365e9ec319f9c851be914a9f98396d02f185a90e
4
- data.tar.gz: 6c11890061b7f83d161b9d3e18432192e01900c2edde6ce9124db5e9e0d2671f
3
+ metadata.gz: 6829c32454f11e11d6b7b3b15dbebaeda3b439ac5b21b6a47bf52526dc742237
4
+ data.tar.gz: bfb53a22f9838c806ae52cac72fa65abde209c6dd09baea4308587e24a0d9aa3
5
5
  SHA512:
6
- metadata.gz: 8feed2cfadd99b265276e07b3aa16a0b32b2cf51fb79f00fa290b044c993c812148cdd563bea0524edc32c42e3693bb293129a8b1589e429880e7e46825f67d7
7
- data.tar.gz: 7b2219621584d7ecb2ad3c6359adaab056c7d63b1c9a8cd805cd79eb3e39c2a353ddf762c5e55907e958b76b90fc5515463ae77275a7e87e181dd39d2ce688c8
6
+ metadata.gz: 8084547f4db3b39bbd1fb477d8a8e79dea2c73f6490551d0dfd77e685628ac57aabd8e02dca188898b7a1c04dd0083bfde9682767beb993fe86cd28522b268af
7
+ data.tar.gz: 2a7cd1d37840894dcb1e5653b565993beba6109f11961f2ddf3930739244151887cf40e28bcddad2e0394ff25610fadabd19ad63d3fbc8755112c548267bdbff
data/README.md CHANGED
@@ -117,7 +117,7 @@ For more information, refer to [documentation](https://rubydoc.info/gems/gitlab/
117
117
  It is possible to use this gem as a command line interface to GitLab. In order to make that work you need to set a few environment variables:
118
118
  ```sh
119
119
  export GITLAB_API_ENDPOINT=https://gitlab.yourcompany.com/api/v4
120
- export GITLAB_API_PRIVATE_TOKEN=<your private token from /profile/account>
120
+ export GITLAB_API_PRIVATE_TOKEN=<your private token from /profile/account or /profile/personal_access_tokens in newer version>
121
121
  # This one is optional and can be used to set any HTTParty option you may need
122
122
  # using YAML hash syntax. For example, this is how you would disable SSL
123
123
  # verification (useful if using a self-signed cert).
@@ -17,6 +17,7 @@ module Gitlab
17
17
  include Deployments
18
18
  include Environments
19
19
  include Events
20
+ include Features
20
21
  include GroupMilestones
21
22
  include Groups
22
23
  include Issues
@@ -32,11 +33,15 @@ module Gitlab
32
33
  include PipelineTriggers
33
34
  include Pipelines
34
35
  include ProjectBadges
36
+ include ProjectClusters
37
+ include ProjectReleaseLinks
38
+ include ProjectReleases
35
39
  include Projects
36
40
  include ProtectedTags
37
41
  include Repositories
38
42
  include RepositoryFiles
39
43
  include RepositorySubmodules
44
+ include ResourceLabelEvents
40
45
  include Runners
41
46
  include Services
42
47
  include Sidekiq
@@ -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
@@ -80,7 +80,7 @@ class Gitlab::Client
80
80
  # @option options [Array] :approver_group_ids(optional) An array of Group IDs whose members can approve MRs
81
81
  # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
82
82
  def edit_merge_request_approvers(project, merge_request, options = {})
83
- put("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals", body: options)
83
+ put("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvers", body: options)
84
84
  end
85
85
 
86
86
  # Approve a merge request
@@ -77,5 +77,17 @@ class Gitlab::Client
77
77
  def retry_pipeline(project, id)
78
78
  post("/projects/#{url_encode project}/pipelines/#{id}/retry")
79
79
  end
80
+
81
+ # Delete a pipeline
82
+ #
83
+ # @example
84
+ # Gitlab.delete_pipeline(5, 1)
85
+ #
86
+ # @param [Integer, String] project The ID or name of a project.
87
+ # @param [Integer] id The ID of a pipeline.
88
+ # @return [void] This API call returns an empty response body.
89
+ def delete_pipeline(project, id)
90
+ delete("/projects/#{url_encode project}/pipelines/#{id}")
91
+ end
80
92
  end
81
93
  end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to project clusters.
5
+ # @see https://docs.gitlab.com/ce/api/project_clusters.html
6
+ module ProjectClusters
7
+ # Returns a list of project clusters.
8
+ #
9
+ # @example
10
+ # Gitlab.project_clusters(5)
11
+ #
12
+ # @param [Integer, String] project The ID or name of a project.
13
+ # @return [Array<Gitlab::ObjectifiedHash>] List of all clusters of a project
14
+ def project_clusters(project)
15
+ get("/projects/#{url_encode project}/clusters")
16
+ end
17
+
18
+ # Gets a single project cluster.
19
+ #
20
+ # @example
21
+ # Gitlab.project_cluster(5, 42)
22
+ #
23
+ # @param [Integer, String] project The ID or name of a project.
24
+ # @param [Integer] cluster_id The ID of the cluster.
25
+ # @return [Gitlab::ObjectifiedHash] Information about the requested cluster
26
+ def project_cluster(project, cluster_id)
27
+ get("/projects/#{url_encode project}/clusters/#{cluster_id}")
28
+ end
29
+
30
+ # Adds an existing Kubernetes cluster to the project.
31
+ #
32
+ # @example
33
+ # Gitlab.add_project_cluster(5, 'cluster-5', { enabled: false, platform_kubernetes_attributes: { api_url: 'https://35.111.51.20', token: '12345', ca_cert: "-----BEGIN CERTIFICATE-----\r\nhFiK1L61owwDQYJKoZIhvcNAQELBQAw\r\nLzEtMCsGA1UEAxMkZDA1YzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM4ZDBj\r\nMB4XDTE4MTIyNzIwMDM1MVoXDTIzMTIyNjIxMDM1MVowLzEtMCsGA1UEAxMkZDA1\r\nYzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM.......-----END CERTIFICATE-----", namespace: 'cluster-5-namespace', authorization_type: 'rbac' } })
34
+ # Gitlab.add_project_cluster(5, 'cluster-5', { platform_kubernetes_attributes: { api_url: 'https://35.111.51.20', token: '12345' } })
35
+ #
36
+ # @param [Integer, String] project The ID or name of a project.
37
+ # @param [String] name The name of the existing cluster.
38
+ # @param [Hash] options A customizable set of options.
39
+ # @option options [Boolean] :enabled(optional) Determines if cluster is active or not, defaults to true
40
+ # @option options [Hash] :platform_kubernetes_attributes A customizable set of Kubernetes platform attributes
41
+ # @suboption platform_kubernetes_attributes [String] :api_url(required) The URL to access the Kubernetes API
42
+ # @suboption platform_kubernetes_attributes [String] :token(required) The token to authenticate against Kubernetes
43
+ # @suboption platform_kubernetes_attributes [String] :ca_cert(optional) TLS certificate (needed if API is using a self-signed TLS certificate
44
+ # @suboption platform_kubernetes_attributes [String] :namespace(optional) The unique namespace related to the project
45
+ # @suboption platform_kubernetes_attributes [String] :authorization_type(optional) The cluster authorization type: rbac, abac or unknown_authorization. Defaults to rbac.
46
+ # @return [Gitlab::ObjectifiedHash] Information about the added project cluster.
47
+ def add_project_cluster(project, name, options = {})
48
+ body = { name: name }.merge(options)
49
+ post("/projects/#{url_encode project}/clusters/user", body: body)
50
+ end
51
+
52
+ # Updates an existing project cluster.
53
+ #
54
+ # @example
55
+ # Gitlab.edit_project_cluster(5, 1, { name: 'cluster-6', platform_kubernetes_attributes: { api_url: 'https://35.111.51.20', token: '12345', ca_cert: "-----BEGIN CERTIFICATE-----\r\nhFiK1L61owwDQYJKoZIhvcNAQELBQAw\r\nLzEtMCsGA1UEAxMkZDA1YzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM4ZDBj\r\nMB4XDTE4MTIyNzIwMDM1MVoXDTIzMTIyNjIxMDM1MVowLzEtMCsGA1UEAxMkZDA1\r\nYzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM.......-----END CERTIFICATE-----", namespace: 'cluster-6-namespace' } })
56
+ #
57
+ # @param [Integer, String] project The ID or name of a project.
58
+ # @param [Integer] cluster_id The ID of the cluster.
59
+ # @param [Hash] options A customizable set of options.
60
+ # @option options [String] :name(optional) The name of the cluster
61
+ # @option options [Hash] :platform_kubernetes_attributes A customizable set of Kubernetes platform attributes
62
+ # @suboption platform_kubernetes_attributes [String] :api_url(required) The URL to access the Kubernetes API
63
+ # @suboption platform_kubernetes_attributes [String] :token(required) The token to authenticate against Kubernetes
64
+ # @suboption platform_kubernetes_attributes [String] :ca_cert(optional) TLS certificate (needed if API is using a self-signed TLS certificate
65
+ # @suboption platform_kubernetes_attributes [String] :namespace(optional) The unique namespace related to the project
66
+ # @return [Gitlab::ObjectifiedHash] Information about the updated project cluster.
67
+ def edit_project_cluster(project, cluster_id, options = {})
68
+ put("/projects/#{url_encode project}/clusters/#{cluster_id}", body: options)
69
+ end
70
+
71
+ # Deletes an existing project cluster.
72
+ #
73
+ # @example
74
+ # Gitlab.delete_project_cluster(5, 42)
75
+ #
76
+ # @param [Integer, String] project The ID or name of a project.
77
+ # @param [Integer] cluster_id The ID of the cluster.
78
+ # @return [nil] This API call returns an empty response body.
79
+ def delete_project_cluster(project, cluster_id)
80
+ delete("/projects/#{url_encode project}/clusters/#{cluster_id}")
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to project release links.
5
+ # @see https://docs.gitlab.com/ce/api/releases/links.html
6
+ module ProjectReleaseLinks
7
+ # Get assets as links from a Release.
8
+ #
9
+ # @example
10
+ # Gitlab.project_release_links(5, 'v0.3')
11
+ #
12
+ # @param [Integer, String] project The ID or name of a project.
13
+ # @param [String] tag_name The tag associated with the Release.
14
+ # @return [Array<Gitlab::ObjectifiedHash>] List of assets as links from a Release.
15
+ def project_release_links(project, tag_name)
16
+ get("/projects/#{url_encode project}/releases/#{tag_name}/assets/links")
17
+ end
18
+
19
+ # Get an asset as link from a Release.
20
+ #
21
+ # @example
22
+ # Gitlab.project_release_link(5, 'v0.3', 1)
23
+ #
24
+ # @param [Integer, String] project The ID or name of a project.
25
+ # @param [String] tag_name The tag associated with the Release.
26
+ # @param [Integer] link_id The id of the link.
27
+ # @return [Gitlab::ObjectifiedHash] Information about the release link
28
+ def project_release_link(project, tag_name, link_id)
29
+ get("/projects/#{url_encode project}/releases/#{tag_name}/assets/links/#{link_id}")
30
+ end
31
+
32
+ # Create an asset as a link from a Release.
33
+ #
34
+ # @example
35
+ # Gitlab.create_project_release_link(5, 'v0.1', { name: 'awesome-v0.2.dmg', url: 'http://192.168.10.15:3000' })
36
+ #
37
+ # @param [Integer, String] project The ID or name of a project.
38
+ # @param [String] tag_name The tag associated with the Release.
39
+ # @param [Hash] options A customizable set of options.
40
+ # @option options [String] :name(required) The name of the link.
41
+ # @option options [String] :url(required) The URL of the link.
42
+ # @return [Gitlab::ObjectifiedHash] Information about the created release link.
43
+ def create_project_release_link(project, tag_name, options = {})
44
+ post("/projects/#{url_encode project}/releases/#{tag_name}/assets/links", body: options)
45
+ end
46
+
47
+ # Update an asset as a link from a Release. You have to specify at least one of name or url
48
+ #
49
+ # @example
50
+ # Gitlab.update_project_release_link(5, 'v0.3', 1, { name: 'awesome-v0.2.dmg', url: 'http://192.168.10.15:3000' })
51
+ #
52
+ # @param [Integer, String] project The ID or name of a project.
53
+ # @param [String] tag_name The tag where the release will be created from.
54
+ # @param [Integer] link_id The id of the link.
55
+ # @param [Hash] options A customizable set of options.
56
+ # @option options [String] :name(optional) The name of the link.
57
+ # @option options [String] :url(optional) The URL of the link.
58
+ # @return [Gitlab::ObjectifiedHash] Information about the updated release link.
59
+ def update_project_release_link(project, tag_name, link_id, options = {})
60
+ put("/projects/#{url_encode project}/releases/#{tag_name}/assets/links/#{link_id}", body: options)
61
+ end
62
+
63
+ # Delete an asset as a link from a Release.
64
+ #
65
+ # @example
66
+ # Gitlab.delete_project_release_link(5, 'v0.3', 1)
67
+ #
68
+ # @param [Integer, String] project The ID or name of a project.
69
+ # @param [String] tag_name The tag where the release will be created from.
70
+ # @param [Integer] link_id The id of the link.
71
+ # @return [Gitlab::ObjectifiedHash] Information about the deleted release link.
72
+ def delete_project_release_link(project, tag_name, link_id)
73
+ delete("/projects/#{url_encode project}/releases/#{tag_name}/assets/links/#{link_id}")
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to project releases.
5
+ # @see https://docs.gitlab.com/ce/api/releases/
6
+ module ProjectReleases
7
+ # Returns Paginated list of a project's releases, sorted by created_at.
8
+ #
9
+ # @example
10
+ # Gitlab.project_releases(5)
11
+ #
12
+ # @param [Integer, String] project The ID or name of a project.
13
+ # @return [Array<Gitlab::ObjectifiedHash>] Paginated list of Releases, sorted by created_at.
14
+ def project_releases(project)
15
+ get("/projects/#{url_encode project}/releases")
16
+ end
17
+
18
+ # Gets a Release by a tag name
19
+ #
20
+ # @example
21
+ # Gitlab.project_release(5, 'v0.1')
22
+ #
23
+ # @param [Integer, String] project The ID or name of a project.
24
+ # @param [String] tag_name The tag where the release will be created from..
25
+ # @return [Gitlab::ObjectifiedHash] Information about the release
26
+ def project_release(project, tag_name)
27
+ get("/projects/#{url_encode project}/releases/#{tag_name}")
28
+ end
29
+
30
+ # Creates a Release. You need push access to the repository to create a Release.
31
+ #
32
+ # @example
33
+ # Gitlab.create_project_release(5, { name: 'New Release', tag_name: 'v0.3', description: 'Super nice release' })
34
+ # Gitlab.create_project_release(5, { name: 'New Release', tag_name: 'v0.3', description: 'Super nice release', assets: { links: [{ name: 'hoge', url: 'https://google.com' }] } })
35
+ #
36
+ # @param [Integer, String] project The ID or name of a project.
37
+ # @param [Hash] options A customizable set of options.
38
+ # @option options [String] :name(required) The release name.
39
+ # @option options [String] :tag_name(required) The tag where the release will be created from.
40
+ # @option options [String] :description(required) The description of the release. You can use markdown.
41
+ # @option options [String] :ref(optional) If tag_name does not exist, the release will be created from ref. It can be a commit SHA, another tag name, or a branch name.
42
+ # @option options [Hash] :assets(optional) A customizable set of options for release assets
43
+ # @asset assets [Array<link>] :links(optional) An array of assets links as hashes.
44
+ # @link links [Hash] link_elements A combination of a link name and a link url
45
+ # @link_element [String] :name The name of the link.
46
+ # @link_element [String] :url The url of the link.
47
+ # @return [Gitlab::ObjectifiedHash] Information about the created release.
48
+ def create_project_release(project, options = {})
49
+ post("/projects/#{url_encode project}/releases", body: options)
50
+ end
51
+
52
+ # Updates a release.
53
+ #
54
+ # @example
55
+ # Gitlab.update_project_release(5, 'v0.3', { name: 'New Release', description: 'Super nice release' })
56
+ #
57
+ # @param [Integer, String] project The ID or name of a project.
58
+ # @param [String] tag_name The tag where the release will be created from.
59
+ # @param [Hash] options A customizable set of options.
60
+ # @option options [String] :name(optional) The release name.
61
+ # @option options [String] :description(optional) The description of the release. You can use markdown.
62
+ # @return [Gitlab::ObjectifiedHash] Information about the updated release.
63
+ def update_project_release(project, tag_name, options = {})
64
+ put("/projects/#{url_encode project}/releases/#{tag_name}", body: options)
65
+ end
66
+
67
+ # Delete a Release. Deleting a Release will not delete the associated tag.
68
+ #
69
+ # @example
70
+ # Gitlab.delete_project_release(5, 'v0.3')
71
+ #
72
+ # @param [Integer, String] project The ID or name of a project.
73
+ # @param [String] tag_name The tag where the release will be created from.
74
+ # @return [Gitlab::ObjectifiedHash] Information about the deleted release.
75
+ def delete_project_release(project, tag_name)
76
+ delete("/projects/#{url_encode project}/releases/#{tag_name}")
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to resource label events.
5
+ # @see https://docs.gitlab.com/ee/api/resource_label_events.html
6
+ module ResourceLabelEvents
7
+ # Gets a list of all label events for a single issue.
8
+ #
9
+ # @example
10
+ # Gitlab.issue_label_events(5, 42)
11
+ #
12
+ # @param [Integer, String] project The ID or name of a project.
13
+ # @param [Integer] issue_iid The IID of an issue.
14
+ # @return [Array<Gitlab::ObjectifiedHash>]
15
+ def issue_label_events(project, issue_iid)
16
+ get("/projects/#{url_encode project}/issues/#{issue_iid}/resource_label_events")
17
+ end
18
+
19
+ # Returns a single label event for a specific project issue
20
+ #
21
+ # @example
22
+ # Gitlab.issue_label_event(5, 42, 1)
23
+ #
24
+ # @param [Integer, String] project The ID or name of a project.
25
+ # @param [Integer] issue_iid The IID of an issue.
26
+ # @param [Integer] id The ID of a label event.
27
+ # @return Gitlab::ObjectifiedHash
28
+ def issue_label_event(project, issue_iid, id)
29
+ get("/projects/#{url_encode project}/issues/#{issue_iid}/resource_label_events/#{id}")
30
+ end
31
+
32
+ # Gets a list of all label events for a single epic.
33
+ #
34
+ # @example
35
+ # Gitlab.epic_label_events(5, 42)
36
+ #
37
+ # @param [Integer, String] group The ID or name of a group.
38
+ # @param [Integer] epic_id The ID of an epic.
39
+ # @return [Array<Gitlab::ObjectifiedHash>]
40
+ def epic_label_events(group, epic_id)
41
+ get("/groups/#{url_encode group}/epics/#{epic_id}/resource_label_events")
42
+ end
43
+
44
+ # Returns a single label event for a specific group epic
45
+ #
46
+ # @example
47
+ # Gitlab.epic_label_event(5, 42, 1)
48
+ #
49
+ # @param [Integer, String] group The ID or name of a group.
50
+ # @param [Integer] epic_id The ID of an epic.
51
+ # @param [Integer] id The ID of a label event.
52
+ # @return Gitlab::ObjectifiedHash
53
+ def epic_label_event(group, epic_id, id)
54
+ get("/groups/#{url_encode group}/epics/#{epic_id}/resource_label_events/#{id}")
55
+ end
56
+
57
+ # Gets a list of all label events for a single merge request.
58
+ #
59
+ # @example
60
+ # Gitlab.merge_request_label_events(5, 42)
61
+ #
62
+ # @param [Integer, String] project The ID or name of a project.
63
+ # @param [Integer] merge_request_iid The IID of a merge request.
64
+ # @return [Array<Gitlab::ObjectifiedHash>]
65
+ def merge_request_label_events(project, merge_request_iid)
66
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request_iid}/resource_label_events")
67
+ end
68
+
69
+ # Returns a single label event for a specific project merge request
70
+ #
71
+ # @example
72
+ # Gitlab.merge_request_label_event(5, 42, 1)
73
+ #
74
+ # @param [Integer, String] project The ID or name of a project.
75
+ # @param [Integer] merge_request_iid The IID of an merge request.
76
+ # @param [Integer] id The ID of a label event.
77
+ # @return Gitlab::ObjectifiedHash
78
+ def merge_request_label_event(project, merge_request_iid, id)
79
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request_iid}/resource_label_events/#{id}")
80
+ end
81
+ end
82
+ end
@@ -40,7 +40,7 @@ module Gitlab
40
40
  #
41
41
  # @return [String]
42
42
  def build_error_message
43
- parsed_response = @response.parsed_response
43
+ parsed_response = classified_response
44
44
  message = check_error_keys(parsed_response)
45
45
  "Server responded with code #{@response.code}, message: " \
46
46
  "#{handle_message(message)}. " \
@@ -54,6 +54,17 @@ module Gitlab
54
54
  key ? resp.send(key) : resp
55
55
  end
56
56
 
57
+ # Parse the body based on the classification of the body content type
58
+ #
59
+ # @return parsed response
60
+ def classified_response
61
+ if @response.respond_to?('headers')
62
+ @response.headers['content-type'] == 'text/plain' ? { message: @response.to_s } : @response.parsed_response
63
+ else
64
+ @response.parsed_response
65
+ end
66
+ end
67
+
57
68
  # Handle error response message in case of nested hashes
58
69
  def handle_message(message)
59
70
  case message
@@ -90,6 +101,9 @@ module Gitlab
90
101
  # Raised when API endpoint returns the HTTP status code 422.
91
102
  class Unprocessable < ResponseError; end
92
103
 
104
+ # Raised when API endpoint returns the HTTP status code 429.
105
+ class TooManyRequests < ResponseError; end
106
+
93
107
  # Raised when API endpoint returns the HTTP status code 500.
94
108
  class InternalServerError < ResponseError; end
95
109
 
@@ -58,6 +58,7 @@ module Gitlab
58
58
  when 405 then Error::MethodNotAllowed
59
59
  when 409 then Error::Conflict
60
60
  when 422 then Error::Unprocessable
61
+ when 429 then Error::TooManyRequests
61
62
  when 500 then Error::InternalServerError
62
63
  when 502 then Error::BadGateway
63
64
  when 503 then Error::ServiceUnavailable
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gitlab
4
- VERSION = '4.8.0'
4
+ VERSION = '4.9.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.0
4
+ version: 4.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nihad Abbasov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-12-27 00:00:00.000000000 Z
12
+ date: 2019-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -18,6 +18,9 @@ dependencies:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: 0.14.0
21
+ - - "~>"
22
+ - !ruby/object:Gem::Version
23
+ version: '0.14'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -25,10 +28,16 @@ dependencies:
25
28
  - - ">="
26
29
  - !ruby/object:Gem::Version
27
30
  version: 0.14.0
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.14'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: terminal-table
30
36
  requirement: !ruby/object:Gem::Requirement
31
37
  requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
32
41
  - - ">="
33
42
  - !ruby/object:Gem::Version
34
43
  version: 1.5.1
@@ -36,6 +45,9 @@ dependencies:
36
45
  prerelease: false
37
46
  version_requirements: !ruby/object:Gem::Requirement
38
47
  requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '1.5'
39
51
  - - ">="
40
52
  - !ruby/object:Gem::Version
41
53
  version: 1.5.1
@@ -111,26 +123,17 @@ dependencies:
111
123
  version: '0'
112
124
  description: Ruby client and CLI for GitLab API
113
125
  email:
114
- - mail@narkoz.me
126
+ - nihad@42na.in
115
127
  - asedge@gmail.com
116
128
  executables:
117
129
  - gitlab
118
130
  extensions: []
119
131
  extra_rdoc_files: []
120
132
  files:
121
- - ".github/stale.yml"
122
- - ".gitignore"
123
- - ".rubocop_todo.yml"
124
133
  - CHANGELOG.md
125
- - CONTRIBUTING.md
126
- - Gemfile
127
134
  - LICENSE.txt
128
135
  - README.md
129
- - Rakefile
130
- - bin/console
131
- - bin/setup
132
136
  - exe/gitlab
133
- - gitlab.gemspec
134
137
  - lib/gitlab.rb
135
138
  - lib/gitlab/api.rb
136
139
  - lib/gitlab/cli.rb
@@ -147,6 +150,7 @@ files:
147
150
  - lib/gitlab/client/deployments.rb
148
151
  - lib/gitlab/client/environments.rb
149
152
  - lib/gitlab/client/events.rb
153
+ - lib/gitlab/client/features.rb
150
154
  - lib/gitlab/client/group_milestones.rb
151
155
  - lib/gitlab/client/groups.rb
152
156
  - lib/gitlab/client/issues.rb
@@ -162,11 +166,15 @@ files:
162
166
  - lib/gitlab/client/pipeline_triggers.rb
163
167
  - lib/gitlab/client/pipelines.rb
164
168
  - lib/gitlab/client/project_badges.rb
169
+ - lib/gitlab/client/project_clusters.rb
170
+ - lib/gitlab/client/project_release_links.rb
171
+ - lib/gitlab/client/project_releases.rb
165
172
  - lib/gitlab/client/projects.rb
166
173
  - lib/gitlab/client/protected_tags.rb
167
174
  - lib/gitlab/client/repositories.rb
168
175
  - lib/gitlab/client/repository_files.rb
169
176
  - lib/gitlab/client/repository_submodules.rb
177
+ - lib/gitlab/client/resource_label_events.rb
170
178
  - lib/gitlab/client/runners.rb
171
179
  - lib/gitlab/client/services.rb
172
180
  - lib/gitlab/client/sidekiq.rb
@@ -189,9 +197,9 @@ files:
189
197
  - lib/gitlab/shell.rb
190
198
  - lib/gitlab/shell_history.rb
191
199
  - lib/gitlab/version.rb
192
- homepage: https://github.com/narkoz/gitlab
200
+ homepage: https://github.com/NARKOZ/gitlab
193
201
  licenses:
194
- - BSD
202
+ - BSD-2-Clause
195
203
  metadata: {}
196
204
  post_install_message:
197
205
  rdoc_options: []
@@ -208,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
216
  - !ruby/object:Gem::Version
209
217
  version: '0'
210
218
  requirements: []
211
- rubygems_version: 3.0.1
219
+ rubygems_version: 3.0.2
212
220
  signing_key:
213
221
  specification_version: 4
214
222
  summary: A Ruby wrapper and CLI for the GitLab API
@@ -1,18 +0,0 @@
1
- # Number of days of inactivity before an issue becomes stale
2
- daysUntilStale: 90
3
- # Number of days of inactivity before a stale issue is closed
4
- daysUntilClose: 10
5
- # Issues with these labels will never be considered stale
6
- exemptLabels:
7
- - pinned
8
- - security
9
- - contribution welcome
10
- # Label to use when marking an issue as stale
11
- staleLabel: stale
12
- # Comment to post when marking an issue as stale. Set to `false` to disable
13
- markComment: >
14
- This issue has been automatically marked as stale because it has not had
15
- recent activity. It will be closed if no further activity occurs. Thank you
16
- for your contributions.
17
- # Comment to post when closing a stale issue. Set to `false` to disable
18
- closeComment: false
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- *.gem
2
- *.rbc
3
- *.swp
4
- .bundle
5
- .config
6
- .yardoc
7
- Gemfile.lock
8
- InstalledFiles
9
- _yardoc
10
- coverage
11
- doc/
12
- lib/bundler/man
13
- pkg
14
- rdoc
15
- spec/reports
16
- test/tmp
17
- test/version_tmp
18
- tmp
19
- vendor/bundle
20
- .idea
21
- .ruby-version
22
- .ruby-gemset
@@ -1,46 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2018-10-10 10:25:27 +0400 using RuboCop version 0.59.2.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 1
10
- Lint/UriEscapeUnescape:
11
- Exclude:
12
- - 'lib/gitlab/client.rb'
13
-
14
- # Offense count: 5
15
- Metrics/AbcSize:
16
- Max: 34
17
-
18
- # Offense count: 4
19
- Metrics/CyclomaticComplexity:
20
- Max: 14
21
-
22
- # Offense count: 10
23
- # Configuration parameters: CountComments, ExcludedMethods.
24
- Metrics/MethodLength:
25
- Max: 34
26
-
27
- # Offense count: 2
28
- # Configuration parameters: CountComments.
29
- Metrics/ModuleLength:
30
- Max: 165
31
-
32
- # Offense count: 2
33
- # Configuration parameters: CountKeywordArgs.
34
- Metrics/ParameterLists:
35
- Max: 6
36
-
37
- # Offense count: 1
38
- Metrics/PerceivedComplexity:
39
- Max: 10
40
-
41
- # Offense count: 1
42
- # Cop supports --auto-correct.
43
- # Configuration parameters: AutoCorrect.
44
- Security/JSONLoad:
45
- Exclude:
46
- - 'lib/gitlab/request.rb'
@@ -1,195 +0,0 @@
1
- # Contributing to Gitlab
2
-
3
- Please take a moment to review this document in order to make the contribution
4
- process easy and effective for everyone involved!
5
-
6
- ## Using the issue tracker
7
-
8
- You can use the issues tracker for:
9
-
10
- * [bug reports](#bug-reports)
11
- * [feature requests](#feature-requests)
12
- * [submitting pull requests](#pull-requests)
13
-
14
- Use [Stackoverflow](http://stackoverflow.com/) for questions and personal support requests.
15
-
16
- ## Bug reports
17
-
18
- A bug is a _demonstrable problem_ that is caused by the code in the repository.
19
- Good bug reports are extremely helpful - thank you!
20
-
21
- Guidelines for bug reports:
22
-
23
- 1. **Use the GitHub issue search** &mdash; check if the issue has already been
24
- reported.
25
-
26
- 2. **Check if the issue has been fixed** &mdash; try to reproduce it using the
27
- `master` branch in the repository.
28
-
29
- 3. **Isolate and report the problem** &mdash; ideally create a reduced test
30
- case.
31
-
32
- Please try to be as detailed as possible in your report. Include information about
33
- your Ruby, Gitlab client and GitLab instance versions. Please provide steps to
34
- reproduce the issue as well as the outcome you were expecting! All these details
35
- will help developers to fix any potential bugs.
36
-
37
- Example:
38
-
39
- > Short and descriptive example bug report title
40
- >
41
- > A summary of the issue and the environment in which it occurs. If suitable,
42
- > include the steps required to reproduce the bug.
43
- >
44
- > 1. This is the first step
45
- > 2. This is the second step
46
- > 3. Further steps, etc.
47
- >
48
- > Any other information you want to share that is relevant to the issue being
49
- > reported. This might include the lines of code that you have identified as
50
- > causing the bug, and potential solutions (and your opinions on their
51
- > merits).
52
-
53
- ## Feature requests
54
-
55
- Feature requests are welcome. But take a moment to find out whether your idea
56
- fits with the scope and aims of the project. It's up to *you* to make a strong
57
- case to convince the community of the merits of this feature.
58
- Please provide as much detail and context as possible.
59
-
60
- ## Contributing Documentation
61
-
62
- Code documentation has a special convention: it uses [YARD](http://yardoc.org/)
63
- formatting and the first paragraph is considered to be a short summary.
64
-
65
- For methods say what it will do. For example write something like:
66
-
67
- ```ruby
68
- # Reverses the contents of a String or IO object.
69
- #
70
- # @param [String, #read] contents the contents to reverse
71
- # @return [String] the contents reversed lexically
72
- def reverse(contents)
73
- contents = contents.read if contents.respond_to? :read
74
- contents.reverse
75
- end
76
- ```
77
-
78
- For classes, modules say what it is. For example write something like:
79
-
80
- ```ruby
81
- # Defines methods related to groups.
82
- module Groups
83
- ```
84
-
85
- Keep in mind that the documentation notes might show up in a summary somewhere,
86
- long texts in the documentation notes create very ugly summaries. As a rule of thumb
87
- anything longer than 80 characters is too long.
88
-
89
- Try to keep unnecessary details out of the first paragraph, it's only there to
90
- give a user a quick idea of what the documented "thing" does/is. The rest of the
91
- documentation notes can contain the details, for example parameters and what
92
- is returned.
93
-
94
- If possible include examples. For example:
95
-
96
- ```ruby
97
- # Gets information about a project.
98
- #
99
- # @example
100
- # Gitlab.project(3)
101
- # Gitlab.project('gitlab')
102
- #
103
- # @param [Integer, String] id The ID or name of a project.
104
- # @return [Gitlab::ObjectifiedHash]
105
- def project(id)
106
- ```
107
-
108
- This makes it easy to test the examples so that they don't go stale and examples
109
- are often a great help in explaining what a method does.
110
-
111
- ## Pull requests
112
-
113
- Good pull requests - patches, improvements, new features - are a fantastic
114
- help. They should remain focused in scope and avoid containing unrelated
115
- commits.
116
-
117
- **IMPORTANT**: By submitting a patch, you agree that your work will be
118
- licensed under the license used by the project.
119
-
120
- If you have any large pull request in mind (e.g. implementing features,
121
- refactoring code, etc), **please ask first** otherwise you risk spending
122
- a lot of time working on something that the project's developers might
123
- not want to merge into the project.
124
-
125
- Please adhere to the coding conventions in the project (indentation,
126
- accurate comments, etc.) and don't forget to add your own tests and
127
- documentation. When working with git, we recommend the following process
128
- in order to craft an excellent pull request:
129
-
130
- 1. [Fork](https://help.github.com/articles/fork-a-repo/) the project, clone your fork,
131
- and configure the remotes:
132
-
133
- ```sh
134
- # Clone your fork of the repo into the current directory
135
- git clone https://github.com/<your-username>/gitlab
136
- # Navigate to the newly cloned directory
137
- cd gitlab
138
- # Assign the original repo to a remote called "upstream"
139
- git remote add upstream https://github.com/NARKOZ/gitlab
140
- ```
141
-
142
- 2. If you cloned a while ago, get the latest changes from upstream:
143
-
144
- ```bash
145
- git checkout master
146
- git pull upstream master
147
- ```
148
-
149
- 3. Create a new topic branch (off of `master`) to contain your feature, change,
150
- or fix.
151
-
152
- **IMPORTANT**: Making changes in `master` is discouraged. You should always
153
- keep your local `master` in sync with upstream `master` and make your
154
- changes in topic branches.
155
-
156
- ```sh
157
- git checkout -b <topic-branch-name>
158
- ```
159
-
160
- 4. Commit your changes in logical chunks. Keep your commit messages organized,
161
- with a short description in the first line and more detailed information on
162
- the following lines. Feel free to use Git's
163
- [interactive rebase](https://help.github.com/articles/about-git-rebase/)
164
- feature to tidy up your commits before making them public.
165
-
166
- 5. Make sure all the tests are still passing.
167
-
168
- ```sh
169
- rake
170
- ```
171
-
172
- 6. Push your topic branch up to your fork:
173
-
174
- ```sh
175
- git push origin <topic-branch-name>
176
- ```
177
-
178
- 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
179
- with a clear title and description.
180
-
181
- 8. If you haven't updated your pull request for a while, you should consider
182
- rebasing on master and resolving any conflicts.
183
-
184
- **IMPORTANT**: _Never ever_ merge upstream `master` into your branches. You
185
- should always `git rebase` on `master` to bring your changes up to date when
186
- necessary.
187
-
188
- ```sh
189
- git checkout master
190
- git pull upstream master
191
- git checkout <your-topic-branch>
192
- git rebase master
193
- ```
194
-
195
- Thank you for your contributions!
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in gitlab.gemspec
6
- gemspec
data/Rakefile DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
-
5
- require 'rspec/core/rake_task'
6
- RSpec::Core::RakeTask.new(:spec) do |spec|
7
- spec.rspec_opts = ['--color', '--format d']
8
- end
9
-
10
- require 'rubocop/rake_task'
11
- RuboCop::RakeTask.new(:rubocop) do |task|
12
- task.options = ['-D', '--parallel']
13
- end
14
-
15
- task default: :spec
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- # ENV['GITLAB_API_ENDPOINT'] = ''
5
- # ENV['GITLAB_API_PRIVATE_TOKEN'] = ''
6
-
7
- require 'bundler/setup'
8
- require 'gitlab'
9
- require 'pry'
10
-
11
- Pry.start
data/bin/setup DELETED
@@ -1,6 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install &&
6
- echo 'NOTE: You may need to set GITLAB_API_ENDPOINT and GITLAB_API_PRIVATE_TOKEN environment variables.'
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'gitlab/version'
6
-
7
- Gem::Specification.new do |gem|
8
- gem.name = 'gitlab'
9
- gem.version = Gitlab::VERSION
10
- gem.authors = ['Nihad Abbasov', 'Sean Edge']
11
- gem.email = ['mail@narkoz.me', 'asedge@gmail.com']
12
- gem.description = 'Ruby client and CLI for GitLab API'
13
- gem.summary = 'A Ruby wrapper and CLI for the GitLab API'
14
- gem.homepage = 'https://github.com/narkoz/gitlab'
15
-
16
- gem.files = `git ls-files`.split($/)
17
- .grep_v(/^spec/) -
18
- %w[Dockerfile docker-compose.yml docker.env .travis.yml
19
- .rubocop.yml .dockerignore]
20
- gem.bindir = 'exe'
21
- gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
23
- gem.require_paths = ['lib']
24
- gem.license = 'BSD'
25
-
26
- gem.required_ruby_version = '>= 2.3'
27
-
28
- gem.add_runtime_dependency 'httparty', '>= 0.14.0'
29
- gem.add_runtime_dependency 'terminal-table', '>= 1.5.1'
30
-
31
- gem.add_development_dependency 'pry'
32
- gem.add_development_dependency 'rake'
33
- gem.add_development_dependency 'rspec'
34
- gem.add_development_dependency 'rubocop'
35
- gem.add_development_dependency 'webmock'
36
- end