gitlab 4.11.0 → 4.12.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: 507d4fdc41c5f184840d8831d07c3127220f813c2ff52d8f061b82b579515d2a
4
- data.tar.gz: 8e84cda29938364f23063f6762d15d7d0a3f4b81a2cdfb5a7a8fcba56cd1071f
3
+ metadata.gz: 3b704b0067388d9f794505c41aff708ee8b6e3fc1a9d810a046bb9bfd9ef912c
4
+ data.tar.gz: a550009e3cb5478f42088268c93b7e800339dcccf071b8d81c223ad4261fdcc5
5
5
  SHA512:
6
- metadata.gz: '04025787441bfba125d1f60c918e9fb01cbe215f4bdddfcca56253201237e73fdd18153117e49c91147089436b923106853b9a43548463ebb5a3c6764b1fecac'
7
- data.tar.gz: 7a3e9cf4f21b93ce1eb8ddf0fc413aab2f3a7e48f2da53455e174ead9ea208da503b1418cd1f20a3c6913a93bf4be5d2aff5bcbb17a4036d54216c05f04d0be6
6
+ metadata.gz: 18d6a12ea3927fb06da8b86777288a48706b4fc5e1385293f0988485636caa41831bce320ed69fea92660f0dc6de2d70feafb22e5a57a7b10f08cf22e0d905ef
7
+ data.tar.gz: ab8da4935f0f68c37e8529af7070f9e478e33cab037714b60035796070f143cdf154214be1516713475b044c81986d0e967ab6fae3497f2086e721d5f64e06da
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![License](https://img.shields.io/badge/license-BSD-red.svg)](https://github.com/NARKOZ/gitlab/blob/master/LICENSE.txt)
8
8
 
9
9
  [website](https://narkoz.github.io/gitlab) |
10
- [documentation](https://rubydoc.info/gems/gitlab/frames) |
10
+ [documentation](https://www.rubydoc.info/gems/gitlab/frames) |
11
11
  [gitlab-live](https://github.com/NARKOZ/gitlab-live)
12
12
 
13
13
  Gitlab is a Ruby wrapper and CLI for the [GitLab API](https://docs.gitlab.com/ce/api/README.html).
@@ -110,7 +110,7 @@ end
110
110
  projects.auto_paginate
111
111
  ```
112
112
 
113
- For more information, refer to [documentation](https://rubydoc.info/gems/gitlab/frames).
113
+ For more information, refer to [documentation](https://www.rubydoc.info/gems/gitlab/frames).
114
114
 
115
115
  ## CLI
116
116
 
@@ -8,9 +8,6 @@ require_relative 'shell'
8
8
  class Gitlab::CLI
9
9
  extend Helpers
10
10
 
11
- # If set to true, JSON will be rendered as output
12
- @render_json = false
13
-
14
11
  # Starts a new CLI session.
15
12
  #
16
13
  # @example
@@ -39,22 +39,23 @@ class Gitlab::CLI
39
39
  #
40
40
  # @return [Array]
41
41
  def required_fields(args)
42
- if args.any? && args.last.is_a?(String) && args.last.start_with?('--only=')
43
- args.last.gsub('--only=', '').split(',')
44
- else
45
- []
46
- end
42
+ filtered_fields(args, '--only=')
47
43
  end
48
44
 
49
45
  # Returns filtered excluded fields.
50
46
  #
51
47
  # @return [Array]
52
48
  def excluded_fields(args)
53
- if args.any? && args.last.is_a?(String) && args.last.start_with?('--except=')
54
- args.last.gsub('--except=', '').split(',')
55
- else
56
- []
57
- end
49
+ filtered_fields(args, '--except=')
50
+ end
51
+
52
+ # Returns fields filtered by a keyword.
53
+ #
54
+ # @return [Array]
55
+ def filtered_fields(args, key)
56
+ return [] unless args.any? && args.last.is_a?(String) && args.last.start_with?(key)
57
+
58
+ args.last.gsub(key, '').split(',')
58
59
  end
59
60
 
60
61
  # Confirms command is valid.
@@ -7,6 +7,7 @@ module Gitlab
7
7
 
8
8
  # Please keep in alphabetical order
9
9
  include AccessRequests
10
+ include ApplicationSettings
10
11
  include Avatar
11
12
  include AwardEmojis
12
13
  include Boards
@@ -0,0 +1,172 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to application settings.
5
+ # @see https://docs.gitlab.com/ee/api/settings.html
6
+ module ApplicationSettings
7
+ # Retrives the application settings of Gitlab.
8
+ #
9
+ # @example
10
+ # Gitlab.application_settings
11
+ #
12
+ # @return [Array<Gitlab::ObjectifiedHash>]
13
+ def application_settings
14
+ get('/application/settings')
15
+ end
16
+
17
+ # Edit the applications settings of Gitlab.
18
+ #
19
+ # @example
20
+ # Gitlab.edit_application_settings({ signup_enabled: false })
21
+ #
22
+ # @param [Hash] options A customizable set of options.
23
+ # @option options [String] :admin_notification_email
24
+ # @option options [String] :after_sign_out_path
25
+ # @option options [String] :after_sign_up_text
26
+ # @option options [String] :akismet_api_key
27
+ # @option options [Boolean] :akismet_enabled
28
+ # @option options [Boolean] :allow_group_owners_to_manage_ldap
29
+ # @option options [Boolean] :allow_local_requests_from_hooks_and_services
30
+ # @option options [Boolean] :authorized_keys_enabled
31
+ # @option options [String] :auto_devops_domain
32
+ # @option options [Boolean] :auto_devops_enabled
33
+ # @option options [Boolean] :check_namespace_plan
34
+ # @option options [String] :clientside_sentry_dsn
35
+ # @option options [Boolean] :clientside_sentry_enabled
36
+ # @option options [Integer] :container_registry_token_expire_delay
37
+ # @option options [String] :default_artifacts_expire_in
38
+ # @option options [Integer] :default_branch_protection
39
+ # @option options [String] :default_group_visibility
40
+ # @option options [String] :default_project_visibility
41
+ # @option options [Integer] :default_projects_limit
42
+ # @option options [String] :default_snippet_visibility
43
+ # @option options [Array<String>] :disabled_oauth_sign_in_sources
44
+ # @option options [Array<String>] :domain_blacklist
45
+ # @option options [Boolean] :domain_blacklist_enabled
46
+ # @option options [Array<String>] :domain_whitelist
47
+ # @option options [Integer] :dsa_key_restriction
48
+ # @option options [Integer] :ecdsa_key_restriction
49
+ # @option options [Integer] :ed25519_key_restriction
50
+ # @option options [Boolean] :elasticsearch_aws
51
+ # @option options [String] :elasticsearch_aws_access_key
52
+ # @option options [String] :elasticsearch_aws_region
53
+ # @option options [String] :elasticsearch_aws_secret_access_key
54
+ # @option options [Boolean] :elasticsearch_experimental_indexer
55
+ # @option options [Boolean] :elasticsearch_indexing
56
+ # @option options [Boolean] :elasticsearch_search
57
+ # @option options [String] :elasticsearch_url
58
+ # @option options [Boolean] :elasticsearch_limit_indexing
59
+ # @option options [Array<Integer>] :elasticsearch_project_ids
60
+ # @option options [Array<Integer>] :elasticsearch_namespace_ids
61
+ # @option options [String] :email_additional_text
62
+ # @option options [Boolean] :email_author_in_body
63
+ # @option options [String] :enabled_git_access_protocol
64
+ # @option options [Boolean] :enforce_terms
65
+ # @option options [String] :external_auth_client_cert
66
+ # @option options [String] :external_auth_client_key
67
+ # @option options [String] :external_auth_client_key_pass
68
+ # @option options [Boolean] :external_authorization_service_enabled
69
+ # @option options [String] :external_authorization_service_default_label
70
+ # @option options [Float] :external_authorization_service_timeout float
71
+ # @option options [String] :external_authorization_service_url
72
+ # @option options [Integer] :file_template_project_id
73
+ # @option options [Integer] :first_day_of_week
74
+ # @option options [Integer] :geo_status_timeout
75
+ # @option options [Integer] :gitaly_timeout_default
76
+ # @option options [Integer] :gitaly_timeout_fast
77
+ # @option options [Integer] :gitaly_timeout_medium
78
+ # @option options [Boolean] :gravatar_enabled
79
+ # @option options [Boolean] :hashed_storage_enabled
80
+ # @option options [Boolean] :help_page_hide_commercial_content
81
+ # @option options [String] :help_page_support_url
82
+ # @option options [String] :help_page_text
83
+ # @option options [String] :help_text
84
+ # @option options [Boolean] :hide_third_party_offers
85
+ # @option options [String] :home_page_url
86
+ # @option options [Boolean] :housekeeping_bitmaps_enabled
87
+ # @option options [Boolean] :housekeeping_enabled
88
+ # @option options [Integer] :housekeeping_full_repack_period
89
+ # @option options [Integer] :housekeeping_gc_period
90
+ # @option options [Integer] :housekeeping_incremental_repack_period
91
+ # @option options [Boolean] :html_emails_enabled
92
+ # @option options [Boolean] :instance_statistics_visibility_private
93
+ # @option options [Array<String>] :import_sources
94
+ # @option options [Integer] :max_artifacts_size
95
+ # @option options [Integer] :max_attachment_size
96
+ # @option options [Integer] :max_pages_size
97
+ # @option options [Boolean] :metrics_enabled
98
+ # @option options [String] :metrics_host
99
+ # @option options [Integer] :metrics_method_call_threshold
100
+ # @option options [Integer] :metrics_packet_size
101
+ # @option options [Integer] :metrics_pool_size
102
+ # @option options [Integer] :metrics_port
103
+ # @option options [Integer] :metrics_sample_interval
104
+ # @option options [Integer] :metrics_timeout
105
+ # @option options [Boolean] :mirror_available
106
+ # @option options [Integer] :mirror_capacity_threshold
107
+ # @option options [Integer] :mirror_max_capacity
108
+ # @option options [Integer] :mirror_max_delay
109
+ # @option options [Boolean] :pages_domain_verification_enabled
110
+ # @option options [Boolean] :password_authentication_enabled_for_git
111
+ # @option options [Boolean] :password_authentication_enabled_for_web
112
+ # @option options [String] :performance_bar_allowed_group_id
113
+ # @option options [String] :performance_bar_allowed_group_path
114
+ # @option options [Boolean] :performance_bar_enabled
115
+ # @option options [Boolean] :plantuml_enabled
116
+ # @option options [String] :plantuml_url
117
+ # @option options [Float] :polling_interval_multiplier
118
+ # @option options [Boolean] :project_export_enabled
119
+ # @option options [Boolean] :prometheus_metrics_enabled
120
+ # @option options [Boolean] :pseudonymizer_enabled
121
+ # @option options [Boolean] :recaptcha_enabled
122
+ # @option options [String] :recaptcha_private_key
123
+ # @option options [String] :recaptcha_site_key
124
+ # @option options [Boolean] :repository_checks_enabled
125
+ # @option options [Integer] :repository_size_limit
126
+ # @option options [Array<String>] :repository_storages
127
+ # @option options [Boolean] :require_two_factor_authentication
128
+ # @option options [Array<String>] :restricted_visibility_levels
129
+ # @option options [Integer] :rsa_key_restriction
130
+ # @option options [Boolean] :send_user_confirmation_email
131
+ # @option options [String] :sentry_dsn
132
+ # @option options [Boolean] :sentry_enabled
133
+ # @option options [Integer] :session_expire_delay
134
+ # @option options [Boolean] :shared_runners_enabled
135
+ # @option options [Integer] :shared_runners_minutes
136
+ # @option options [String] :shared_runners_text
137
+ # @option options [String] :sign_in_text
138
+ # @option options [String] :signin_enabled
139
+ # @option options [Boolean] :signup_enabled
140
+ # @option options [Boolean] :slack_app_enabled
141
+ # @option options [String] :slack_app_id
142
+ # @option options [String] :slack_app_secret
143
+ # @option options [String] :slack_app_verification_token
144
+ # @option options [Integer] :terminal_max_session_time
145
+ # @option options [String] :terms
146
+ # @option options [Boolean] :throttle_authenticated_api_enabled
147
+ # @option options [Integer] :throttle_authenticated_api_period_in_seconds
148
+ # @option options [Integer] :throttle_authenticated_api_requests_per_period
149
+ # @option options [Boolean] :throttle_authenticated_web_enabled
150
+ # @option options [Integer] :throttle_authenticated_web_period_in_seconds
151
+ # @option options [Integer] :throttle_authenticated_web_requests_per_period
152
+ # @option options [Boolean] :throttle_unauthenticated_enabled
153
+ # @option options [Integer] :throttle_unauthenticated_period_in_seconds
154
+ # @option options [Integer] :throttle_unauthenticated_requests_per_period
155
+ # @option options [Integer] :two_factor_grace_period
156
+ # @option options [Boolean] :unique_ips_limit_enabled
157
+ # @option options [Integer] :unique_ips_limit_per_user
158
+ # @option options [Integer] :unique_ips_limit_time_window
159
+ # @option options [Boolean] :usage_ping_enabled
160
+ # @option options [Boolean] :user_default_external
161
+ # @option options [Boolean] :user_oauth_applications
162
+ # @option options [Boolean] :user_show_add_ssh_key_message
163
+ # @option options [Boolean] :version_check_enabled
164
+ # @option options [Integer] :local_markdown_version
165
+ # @option options [String] :geo_node_allowed_ips
166
+ #
167
+ # @return [Array<Gitlab::ObjectifiedHash>]
168
+ def edit_application_settings(options = {})
169
+ put('/application/settings', body: options)
170
+ end
171
+ end
172
+ end
@@ -67,7 +67,7 @@ class Gitlab::Client
67
67
  # @option options [Boolean] :issues_enabled The issues integration for a project (0 = false, 1 = true).
68
68
  # @option options [Boolean] :snippets_enabled The snippets integration for a project (0 = false, 1 = true).
69
69
  # @option options [Boolean] :merge_requests_enabled The merge requests functionality for a project (0 = false, 1 = true).
70
- # @option options [Boolean] :public The setting for making a project public (0 = false, 1 = true).
70
+ # @option options [String] :visibility The setting for making a project public ('private', 'internal', 'public').
71
71
  # @option options [Integer] :user_id The user/owner id of a project.
72
72
  # @return [Gitlab::ObjectifiedHash] Information about created project.
73
73
  def create_project(name, options = {})
@@ -570,5 +570,27 @@ class Gitlab::Client
570
570
  def project_template(project, type, key, options = {})
571
571
  get("/projects/#{url_encode project}/templates/#{type}/#{key}", query: options)
572
572
  end
573
+
574
+ # Archives a project.
575
+ #
576
+ # @example
577
+ # Gitlab.archive_project(4)
578
+ #
579
+ # @param [Integer, String] id The ID or path of a project.
580
+ # @return [Gitlab::ObjectifiedHash] Information about archived project.
581
+ def archive_project(id)
582
+ post("/projects/#{url_encode id}/archive")
583
+ end
584
+
585
+ # Unarchives a project.
586
+ #
587
+ # @example
588
+ # Gitlab.unarchive_project(4)
589
+ #
590
+ # @param [Integer, String] id The ID or path of a project.
591
+ # @return [Gitlab::ObjectifiedHash] Information about unarchived project.
592
+ def unarchive_project(id)
593
+ post("/projects/#{url_encode id}/unarchive")
594
+ end
573
595
  end
574
596
  end
@@ -28,9 +28,10 @@ class Gitlab::Client
28
28
  #
29
29
  # @param [Integer, String] project The ID or name of a project.
30
30
  # @param [String] ref The commit sha, branch, or tag to download.
31
+ # @param [String] format The archive format. Options are: tar.gz (default), tar.bz2, tbz, tbz2, tb2, bz2, tar, and zip
31
32
  # @return [Gitlab::FileResponse]
32
- def repo_archive(project, ref = 'master')
33
- get("/projects/#{url_encode project}/repository/archive",
33
+ def repo_archive(project, ref = 'master', format = 'tar.gz')
34
+ get("/projects/#{url_encode project}/repository/archive.#{format}",
34
35
  format: nil,
35
36
  headers: { Accept: 'application/octet-stream' },
36
37
  query: { sha: ref },
@@ -95,6 +95,9 @@ module Gitlab
95
95
  # Raised when API endpoint returns the HTTP status code 405.
96
96
  class MethodNotAllowed < ResponseError; end
97
97
 
98
+ # Raised when API endpoint returns the HTTP status code 406.
99
+ class NotAcceptable < ResponseError; end
100
+
98
101
  # Raised when API endpoint returns the HTTP status code 409.
99
102
  class Conflict < ResponseError; end
100
103
 
@@ -112,5 +115,21 @@ module Gitlab
112
115
 
113
116
  # Raised when API endpoint returns the HTTP status code 503.
114
117
  class ServiceUnavailable < ResponseError; end
118
+
119
+ # HTTP status codes mapped to error classes.
120
+ STATUS_MAPPINGS = {
121
+ 400 => BadRequest,
122
+ 401 => Unauthorized,
123
+ 403 => Forbidden,
124
+ 404 => NotFound,
125
+ 405 => MethodNotAllowed,
126
+ 406 => NotAcceptable,
127
+ 409 => Conflict,
128
+ 422 => Unprocessable,
129
+ 429 => TooManyRequests,
130
+ 500 => InternalServerError,
131
+ 502 => BadGateway,
132
+ 503 => ServiceUnavailable
133
+ }.freeze
115
134
  end
116
135
  end
@@ -56,6 +56,25 @@ module Gitlab
56
56
  response
57
57
  end
58
58
 
59
+ def paginate_with_limit(limit)
60
+ response = block_given? ? nil : []
61
+ count = 0
62
+ each_page do |page|
63
+ if block_given?
64
+ page.each do |item|
65
+ yield item
66
+ count += 1
67
+ break if count >= limit
68
+ end
69
+ else
70
+ response += page[0, limit - count]
71
+ count = response.length
72
+ end
73
+ break if count >= limit
74
+ end
75
+ response
76
+ end
77
+
59
78
  def last_page?
60
79
  !(@links.nil? || @links.last.nil?)
61
80
  end
@@ -50,20 +50,7 @@ module Gitlab
50
50
  # Checks the response code for common errors.
51
51
  # Returns parsed response for successful requests.
52
52
  def validate(response)
53
- error_klass = case response.code
54
- when 400 then Error::BadRequest
55
- when 401 then Error::Unauthorized
56
- when 403 then Error::Forbidden
57
- when 404 then Error::NotFound
58
- when 405 then Error::MethodNotAllowed
59
- when 409 then Error::Conflict
60
- when 422 then Error::Unprocessable
61
- when 429 then Error::TooManyRequests
62
- when 500 then Error::InternalServerError
63
- when 502 then Error::BadGateway
64
- when 503 then Error::ServiceUnavailable
65
- end
66
-
53
+ error_klass = Error::STATUS_MAPPINGS[response.code]
67
54
  raise error_klass, response if error_klass
68
55
 
69
56
  parsed = response.parsed_response
@@ -30,12 +30,8 @@ class Gitlab::Shell
30
30
  private
31
31
 
32
32
  def history_file
33
- if defined?(@history_file)
34
- @history_file
35
- else
36
- @history_file = File.open(history_file_path, 'w', 0o600).tap do |file|
37
- file.sync = true
38
- end
33
+ @history_file ||= File.open(history_file_path, 'w', 0o600).tap do |file|
34
+ file.sync = true
39
35
  end
40
36
  rescue Errno::EACCES
41
37
  warn 'History not saved; unable to open your history file for writing.'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gitlab
4
- VERSION = '4.11.0'
4
+ VERSION = '4.12.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.11.0
4
+ version: 4.12.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: 2019-04-23 00:00:00.000000000 Z
12
+ date: 2019-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -140,6 +140,7 @@ files:
140
140
  - lib/gitlab/cli_helpers.rb
141
141
  - lib/gitlab/client.rb
142
142
  - lib/gitlab/client/access_requests.rb
143
+ - lib/gitlab/client/application_settings.rb
143
144
  - lib/gitlab/client/avatar.rb
144
145
  - lib/gitlab/client/award_emojis.rb
145
146
  - lib/gitlab/client/boards.rb
@@ -223,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
224
  - !ruby/object:Gem::Version
224
225
  version: '0'
225
226
  requirements: []
226
- rubygems_version: 3.0.2
227
+ rubygems_version: 3.0.4
227
228
  signing_key:
228
229
  specification_version: 4
229
230
  summary: A Ruby wrapper and CLI for the GitLab API