Package list ruby-gitlab / 56aea8b
Update upstream source from tag 'upstream/4.14.1' Update to upstream version '4.14.1' with Debian dir 386c127654268e3baa0ab6b6512625bb8e4bdc48 Daniel Leidert 1 year, 5 months ago
152 changed file(s) with 5292 addition(s) and 220 deletion(s). Raw diff Collapse all Expand all
0 plugins:
1 rubocop:
2 enabled: true
0 # These are supported funding model platforms
1
2 github: NARKOZ
3 patreon: # Replace with a single Patreon username
4 open_collective: # Replace with a single Open Collective username
5 ko_fi: # Replace with a single Ko-fi username
6 tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
7 custom: # Replace with a single custom sponsorship URL
55 exemptLabels:
66 - pinned
77 - security
8 - contribution welcome
8 - help wanted
99 # Label to use when marking an issue as stale
1010 staleLabel: stale
1111 # Comment to post when marking an issue as stale. Set to `false` to disable
0 name: Ruby Gem
1
2 on:
3 push:
4 tags:
5 - v*
6
7 jobs:
8 build:
9 name: Build + Publish
10 runs-on: ubuntu-latest
11 steps:
12 - uses: actions/checkout@v2
13 - name: Set up Ruby 2.7
14 uses: actions/setup-ruby@v1
15 with:
16 version: 2.7
17 - name: Publish to RubyGems
18 run: |
19 mkdir -p $HOME/.gem
20 touch $HOME/.gem/credentials
21 chmod 0600 $HOME/.gem/credentials
22 printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
23 gem build *.gemspec
24 gem push *.gem
25 env:
26 GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
0 name: Ruby
1
2 on:
3 push:
4 branches:
5 - master
6 pull_request:
7 branches:
8 - master
9
10 jobs:
11 build:
12 runs-on: ubuntu-latest
13 strategy:
14 matrix:
15 ruby:
16 - 2.5
17 - 2.6
18 - 2.7
19 name: Ruby ${{ matrix.ruby }} test
20 steps:
21 - uses: actions/checkout@v2
22 - name: Set up Ruby ${{ matrix.ruby }}
23 uses: actions/setup-ruby@v1
24 with:
25 ruby-version: ${{ matrix.ruby }}
26 - name: Build and test with Rake
27 run: |
28 gem install bundler --no-document
29 bundle install --jobs 4 --retry 3
30 bundle exec rake
31
32 lint:
33 runs-on: ubuntu-latest
34 name: Rubocop lint
35 steps:
36 - uses: actions/checkout@v2
37 - name: Set up Ruby 2.5
38 uses: actions/setup-ruby@v1
39 with:
40 ruby-version: 2.5
41 - name: Lint with Rubocop
42 run: |
43 gem install bundler --no-document
44 bundle install --jobs 4 --retry 3
45 bundle exec rake rubocop
00 ---
11 inherit_from: .rubocop_todo.yml
22
3 require: rubocop-performance
4
35 AllCops:
4 TargetRubyVersion: 2.3
6 TargetRubyVersion: 2.5
57
6 Metrics/LineLength:
7 Max: 125
8 Layout/LineLength:
9 Max: 123
810 Exclude:
911 - 'lib/gitlab/client/*'
1012 - 'spec/**/*'
2123 - 'lib/gitlab/*'
2224 - 'lib/gitlab/client/*'
2325
24 Style/FrozenStringLiteralComment:
25 Exclude:
26 - 'spec/gitlab/file_response_spec.rb'
27 - 'spec/gitlab/help_spec.rb'
26 Lint/NonDeterministicRequireOrder:
27 Enabled: false
2828
29 Style/SpecialGlobalVars:
30 Exclude:
31 - 'gitlab.gemspec'
29 Style/HashEachMethods:
30 Enabled: true
31
32 Style/HashTransformKeys:
33 Enabled: true
34
35 Style/HashTransformValues:
36 Enabled: true
00 # This configuration was generated by
11 # `rubocop --auto-gen-config`
2 # on 2018-10-10 10:25:27 +0400 using RuboCop version 0.59.2.
2 # on 2020-03-12 13:38:06 +0400 using RuboCop version 0.80.1.
33 # The point is for the user to remove these configuration records
44 # one by one as the offenses are removed from the code base.
55 # Note that changes in the inspected code, or installation of new
66 # versions of RuboCop, may require this file to be generated again.
77
8 # Offense count: 1
9 Lint/UriEscapeUnescape:
10 Exclude:
11 - 'lib/gitlab/client.rb'
12
13 # Offense count: 5
8 # Offense count: 4
149 Metrics/AbcSize:
1510 Max: 34
1611
17 # Offense count: 4
12 # Offense count: 3
1813 Metrics/CyclomaticComplexity:
19 Max: 14
14 Max: 12
2015
2116 # Offense count: 10
2217 # Configuration parameters: CountComments, ExcludedMethods.
2621 # Offense count: 2
2722 # Configuration parameters: CountComments.
2823 Metrics/ModuleLength:
29 Max: 165
24 Max: 156
3025
3126 # Offense count: 2
3227 # Configuration parameters: CountKeywordArgs.
00 ---
11 language: ruby
22 rvm:
3 - 2.3
4 - 2.4
53 - 2.5
64 - 2.6
5 - 2.7
76
87 jobs:
98 include:
109 - stage: lint
11 rvm: 2.3
10 rvm: 2.5
1211 script: bundle exec rake rubocop
0 FROM ruby:2.5
0 FROM ruby:2.6
11
22 WORKDIR /app
33
33
44 # Specify your gem's dependencies in gitlab.gemspec
55 gemspec
6
7 gem 'pry'
8 gem 'rubocop'
9 gem 'rubocop-performance'
0 Copyright (c) 2012-2019 Nihad Abbasov <nihad@42na.in>
0 Copyright (c) 2012-2020 Nihad Abbasov <nihad@42na.in>
11 All rights reserved.
22
33 Redistribution and use in source and binary forms, with or without
00 # Gitlab
11
2 [![Build Status](https://img.shields.io/travis/NARKOZ/gitlab.svg)](https://travis-ci.org/NARKOZ/gitlab)
2 [![Build Status](https://img.shields.io/github/workflow/status/NARKOZ/gitlab/Ruby/master)](https://github.com/NARKOZ/gitlab/actions?query=workflow%3ARuby)
33 [![Maintainability](https://api.codeclimate.com/v1/badges/2e310b334b1b5db4a7e1/maintainability)](https://codeclimate.com/github/NARKOZ/gitlab)
44 [![Inline docs](https://inch-ci.org/github/NARKOZ/gitlab.svg)](https://inch-ci.org/github/NARKOZ/gitlab)
55 [![Gem version](https://img.shields.io/gem/v/gitlab.svg)](https://rubygems.org/gems/gitlab)
66 [![License](https://img.shields.io/badge/license-BSD-red.svg)](https://github.com/NARKOZ/gitlab/blob/master/LICENSE.txt)
77
88 [website](https://narkoz.github.io/gitlab) |
9 [documentation](https://rubydoc.info/gems/gitlab/frames) |
9 [documentation](https://www.rubydoc.info/gems/gitlab/frames) |
1010 [gitlab-live](https://github.com/NARKOZ/gitlab-live)
1111
1212 Gitlab is a Ruby wrapper and CLI for the [GitLab API](https://docs.gitlab.com/ce/api/README.html).
13 As of version `4.0.0` this gem only supports Ruby 2.0+ and GitLab API v4.
13 As of version `4.0.0` this gem only supports GitLab API v4.
1414
1515 ## Installation
1616
3939
4040 ```ruby
4141 Gitlab.configure do |config|
42 config.endpoint = 'https://example.net/api/v4' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
42 config.endpoint = 'https://example.net/api/v4' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT'] and falls back to ENV['CI_API_V4_URL']
4343 config.private_token = 'qEsq1pt6HJPaNciie3MG' # user's private token or OAuth2 access token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
4444 # Optional
4545 # config.user_agent = 'Custom User Agent' # user agent, default: 'Gitlab Ruby Gem [version]'
7171 Gitlab.projects(per_page: 5)
7272 # => [#<Gitlab::ObjectifiedHash:0x000000023326e0 @data={"id"=>1, "code"=>"brute", "name"=>"Brute", "description"=>nil, "path"=>"brute", "default_branch"=>nil, "owner"=>#<Gitlab::ObjectifiedHash:0x00000002331600 @data={"id"=>1, "email"=>"john@example.com", "name"=>"John Smith", "blocked"=>false, "created_at"=>"2012-09-17T09:41:56Z"}>, "private"=>true, "issues_enabled"=>true, "merge_requests_enabled"=>true, "wall_enabled"=>true, "wiki_enabled"=>true, "created_at"=>"2012-09-17T09:41:56Z"}>, #<Gitlab::ObjectifiedHash:0x000000023450d8 @data={"id"=>2, "code"=>"mozart", "name"=>"Mozart", "description"=>nil, "path"=>"mozart", "default_branch"=>nil, "owner"=>#<Gitlab::ObjectifiedHash:0x00000002344ca0 @data={"id"=>1, "email"=>"john@example.com", "name"=>"John Smith", "blocked"=>false, "created_at"=>"2012-09-17T09:41:56Z"}>, "private"=>true, "issues_enabled"=>true, "merge_requests_enabled"=>true, "wall_enabled"=>true, "wiki_enabled"=>true, "created_at"=>"2012-09-17T09:41:57Z"}>, #<Gitlab::ObjectifiedHash:0x00000002344958 @data={"id"=>3, "code"=>"gitlab", "name"=>"Gitlab", "description"=>nil, "path"=>"gitlab", "default_branch"=>nil, "owner"=>#<Gitlab::ObjectifiedHash:0x000000023447a0 @data={"id"=>1, "email"=>"john@example.com", "name"=>"John Smith", "blocked"=>false, "created_at"=>"2012-09-17T09:41:56Z"}>, "private"=>true, "issues_enabled"=>true, "merge_requests_enabled"=>true, "wall_enabled"=>true, "wiki_enabled"=>true, "created_at"=>"2012-09-17T09:41:58Z"}>]
7373
74 # initialize a new client
75 g = Gitlab.client(endpoint: 'https://api.example.com', private_token: 'qEsq1pt6HJPaNciie3MG')
74 # initialize a new client with custom headers
75 g = Gitlab.client(
76 endpoint: 'https://example.com/api/v4',
77 private_token: 'qEsq1pt6HJPaNciie3MG',
78 httparty: {
79 headers: { 'Cookie' => 'gitlab_canary=true' }
80 }
81 )
7682 # => #<Gitlab::Client:0x00000001e62408 @endpoint="https://api.example.com", @private_token="qEsq1pt6HJPaNciie3MG", @user_agent="Gitlab Ruby Gem 2.0.0">
7783
7884 # get a user
109115 projects.auto_paginate
110116 ```
111117
112 For more information, refer to [documentation](https://rubydoc.info/gems/gitlab/frames).
118 For more information, refer to [documentation](https://www.rubydoc.info/gems/gitlab/frames).
113119
114120 ## CLI
115121
116122 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:
117123 ```sh
118124 export GITLAB_API_ENDPOINT=https://gitlab.yourcompany.com/api/v4
119 export GITLAB_API_PRIVATE_TOKEN=<your private token from /profile/account>
125 export GITLAB_API_PRIVATE_TOKEN=<your private token from /profile/account or /profile/personal_access_tokens in newer version>
120126 # This one is optional and can be used to set any HTTParty option you may need
121127 # using YAML hash syntax. For example, this is how you would disable SSL
122128 # verification (useful if using a self-signed cert).
0 ---
01 # For more information, see https://docs.gitlab.com/omnibus/docker/README.html#install-gitlab-using-docker-compose
12 version: '3'
23 services:
77 gem.name = 'gitlab'
88 gem.version = Gitlab::VERSION
99 gem.authors = ['Nihad Abbasov', 'Sean Edge']
10 gem.email = ['mail@narkoz.me', 'asedge@gmail.com']
10 gem.email = ['nihad@42na.in', 'asedge@gmail.com']
1111 gem.description = 'Ruby client and CLI for GitLab API'
1212 gem.summary = 'A Ruby wrapper and CLI for the GitLab API'
13 gem.homepage = 'https://github.com/narkoz/gitlab'
13 gem.homepage = 'https://github.com/NARKOZ/gitlab'
1414
15 gem.files = `git ls-files`.split($/)
16 .grep_v(/^spec/) -
17 %w[Dockerfile docker-compose.yml docker.env .travis.yml
18 .rubocop.yml .dockerignore]
15 gem.files = Dir['{exe,lib}/**/*', 'LICENSE.txt', 'README.md', 'CHANGELOG.md']
1916 gem.bindir = 'exe'
2017 gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
2118 gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
2219 gem.require_paths = ['lib']
23 gem.license = 'BSD'
20 gem.license = 'BSD-2-Clause'
2421
25 gem.required_ruby_version = '>= 2.3'
22 gem.required_ruby_version = '>= 2.5'
2623
27 gem.add_runtime_dependency 'httparty', '>= 0.14.0'
28 gem.add_runtime_dependency 'terminal-table', '>= 1.5.1'
24 gem.add_runtime_dependency 'httparty', '~> 0.14', '>= 0.14.0'
25 gem.add_runtime_dependency 'terminal-table', '~> 1.5', '>= 1.5.1'
2926
30 gem.add_development_dependency 'pry'
3127 gem.add_development_dependency 'rake'
3228 gem.add_development_dependency 'rspec'
33 gem.add_development_dependency 'rubocop'
3429 gem.add_development_dependency 'webmock'
3530 end
66
77 class Gitlab::CLI
88 extend Helpers
9
10 # If set to true, JSON will be rendered as output
11 @render_json = false
129
1310 # Starts a new CLI session.
1411 #
3838 #
3939 # @return [Array]
4040 def required_fields(args)
41 if args.any? && args.last.is_a?(String) && args.last.start_with?('--only=')
42 args.last.gsub('--only=', '').split(',')
43 else
44 []
45 end
41 filtered_fields(args, '--only=')
4642 end
4743
4844 # Returns filtered excluded fields.
4945 #
5046 # @return [Array]
5147 def excluded_fields(args)
52 if args.any? && args.last.is_a?(String) && args.last.start_with?('--except=')
53 args.last.gsub('--except=', '').split(',')
54 else
55 []
56 end
48 filtered_fields(args, '--except=')
49 end
50
51 # Returns fields filtered by a keyword.
52 #
53 # @return [Array]
54 def filtered_fields(args, key)
55 return [] unless args.any? && args.last.is_a?(String) && args.last.start_with?(key)
56
57 args.last.gsub(key, '').split(',')
5758 end
5859
5960 # Confirms command is valid.
204205
205206 # Helper function to call Gitlab commands with args.
206207 def gitlab_helper(cmd, args = [])
207 begin
208 data = args.any? ? Gitlab.send(cmd, *args) : Gitlab.send(cmd)
209 rescue StandardError => e
210 puts e.message
211 yield if block_given?
212 end
213
214 data
208 args.any? ? Gitlab.send(cmd, *args) : Gitlab.send(cmd)
209 rescue StandardError => e
210 puts e.message
211 yield if block_given?
215212 end
216213
217214 # Convert a hash (recursively) to use symbol hash keys
219216 def symbolize_keys(hash)
220217 if hash.is_a?(Hash)
221218 hash = hash.each_with_object({}) do |(key, value), new_hash|
222 begin
223 new_hash[key.to_sym] = symbolize_keys(value)
224 rescue NoMethodError
225 raise "Error: cannot convert hash key to symbol: #{key}"
226 end
219 new_hash[key.to_sym] = symbolize_keys(value)
220 rescue NoMethodError
221 raise "Error: cannot convert hash key to symbol: #{key}"
227222 end
228223 end
229224
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to application settings.
4 # @see https://docs.gitlab.com/ee/api/settings.html
5 module ApplicationSettings
6 # Retrives the application settings of Gitlab.
7 #
8 # @example
9 # Gitlab.application_settings
10 #
11 # @return [Array<Gitlab::ObjectifiedHash>]
12 def application_settings
13 get('/application/settings')
14 end
15
16 # Edit the applications settings of Gitlab.
17 #
18 # @example
19 # Gitlab.edit_application_settings({ signup_enabled: false })
20 #
21 # @param [Hash] options A customizable set of options.
22 # @option options [String] :admin_notification_email
23 # @option options [String] :after_sign_out_path
24 # @option options [String] :after_sign_up_text
25 # @option options [String] :akismet_api_key
26 # @option options [Boolean] :akismet_enabled
27 # @option options [Boolean] :allow_group_owners_to_manage_ldap
28 # @option options [Boolean] :allow_local_requests_from_hooks_and_services
29 # @option options [Boolean] :authorized_keys_enabled
30 # @option options [String] :auto_devops_domain
31 # @option options [Boolean] :auto_devops_enabled
32 # @option options [Boolean] :check_namespace_plan
33 # @option options [String] :clientside_sentry_dsn
34 # @option options [Boolean] :clientside_sentry_enabled
35 # @option options [Integer] :container_registry_token_expire_delay
36 # @option options [String] :default_artifacts_expire_in
37 # @option options [Integer] :default_branch_protection
38 # @option options [String] :default_group_visibility
39 # @option options [String] :default_project_visibility
40 # @option options [Integer] :default_projects_limit
41 # @option options [String] :default_snippet_visibility
42 # @option options [Array<String>] :disabled_oauth_sign_in_sources
43 # @option options [Array<String>] :domain_blacklist
44 # @option options [Boolean] :domain_blacklist_enabled
45 # @option options [Array<String>] :domain_whitelist
46 # @option options [Integer] :dsa_key_restriction
47 # @option options [Integer] :ecdsa_key_restriction
48 # @option options [Integer] :ed25519_key_restriction
49 # @option options [Boolean] :elasticsearch_aws
50 # @option options [String] :elasticsearch_aws_access_key
51 # @option options [String] :elasticsearch_aws_region
52 # @option options [String] :elasticsearch_aws_secret_access_key
53 # @option options [Boolean] :elasticsearch_experimental_indexer
54 # @option options [Boolean] :elasticsearch_indexing
55 # @option options [Boolean] :elasticsearch_search
56 # @option options [String] :elasticsearch_url
57 # @option options [Boolean] :elasticsearch_limit_indexing
58 # @option options [Array<Integer>] :elasticsearch_project_ids
59 # @option options [Array<Integer>] :elasticsearch_namespace_ids
60 # @option options [String] :email_additional_text
61 # @option options [Boolean] :email_author_in_body
62 # @option options [String] :enabled_git_access_protocol
63 # @option options [Boolean] :enforce_terms
64 # @option options [String] :external_auth_client_cert
65 # @option options [String] :external_auth_client_key
66 # @option options [String] :external_auth_client_key_pass
67 # @option options [Boolean] :external_authorization_service_enabled
68 # @option options [String] :external_authorization_service_default_label
69 # @option options [Float] :external_authorization_service_timeout float
70 # @option options [String] :external_authorization_service_url
71 # @option options [Integer] :file_template_project_id
72 # @option options [Integer] :first_day_of_week
73 # @option options [Integer] :geo_status_timeout
74 # @option options [Integer] :gitaly_timeout_default
75 # @option options [Integer] :gitaly_timeout_fast
76 # @option options [Integer] :gitaly_timeout_medium
77 # @option options [Boolean] :gravatar_enabled
78 # @option options [Boolean] :hashed_storage_enabled
79 # @option options [Boolean] :help_page_hide_commercial_content
80 # @option options [String] :help_page_support_url
81 # @option options [String] :help_page_text
82 # @option options [String] :help_text
83 # @option options [Boolean] :hide_third_party_offers
84 # @option options [String] :home_page_url
85 # @option options [Boolean] :housekeeping_bitmaps_enabled
86 # @option options [Boolean] :housekeeping_enabled
87 # @option options [Integer] :housekeeping_full_repack_period
88 # @option options [Integer] :housekeeping_gc_period
89 # @option options [Integer] :housekeeping_incremental_repack_period
90 # @option options [Boolean] :html_emails_enabled
91 # @option options [Boolean] :instance_statistics_visibility_private
92 # @option options [Array<String>] :import_sources
93 # @option options [Integer] :max_artifacts_size
94 # @option options [Integer] :max_attachment_size
95 # @option options [Integer] :max_pages_size
96 # @option options [Boolean] :metrics_enabled
97 # @option options [String] :metrics_host
98 # @option options [Integer] :metrics_method_call_threshold
99 # @option options [Integer] :metrics_packet_size
100 # @option options [Integer] :metrics_pool_size
101 # @option options [Integer] :metrics_port
102 # @option options [Integer] :metrics_sample_interval
103 # @option options [Integer] :metrics_timeout
104 # @option options [Boolean] :mirror_available
105 # @option options [Integer] :mirror_capacity_threshold
106 # @option options [Integer] :mirror_max_capacity
107 # @option options [Integer] :mirror_max_delay
108 # @option options [Boolean] :pages_domain_verification_enabled
109 # @option options [Boolean] :password_authentication_enabled_for_git
110 # @option options [Boolean] :password_authentication_enabled_for_web
111 # @option options [String] :performance_bar_allowed_group_id
112 # @option options [String] :performance_bar_allowed_group_path
113 # @option options [Boolean] :performance_bar_enabled
114 # @option options [Boolean] :plantuml_enabled
115 # @option options [String] :plantuml_url
116 # @option options [Float] :polling_interval_multiplier
117 # @option options [Boolean] :project_export_enabled
118 # @option options [Boolean] :prometheus_metrics_enabled
119 # @option options [Boolean] :pseudonymizer_enabled
120 # @option options [Boolean] :recaptcha_enabled
121 # @option options [String] :recaptcha_private_key
122 # @option options [String] :recaptcha_site_key
123 # @option options [Boolean] :repository_checks_enabled
124 # @option options [Integer] :repository_size_limit
125 # @option options [Array<String>] :repository_storages
126 # @option options [Boolean] :require_two_factor_authentication
127 # @option options [Array<String>] :restricted_visibility_levels
128 # @option options [Integer] :rsa_key_restriction
129 # @option options [Boolean] :send_user_confirmation_email
130 # @option options [String] :sentry_dsn
131 # @option options [Boolean] :sentry_enabled
132 # @option options [Integer] :session_expire_delay
133 # @option options [Boolean] :shared_runners_enabled
134 # @option options [Integer] :shared_runners_minutes
135 # @option options [String] :shared_runners_text
136 # @option options [String] :sign_in_text
137 # @option options [String] :signin_enabled
138 # @option options [Boolean] :signup_enabled
139 # @option options [Boolean] :slack_app_enabled
140 # @option options [String] :slack_app_id
141 # @option options [String] :slack_app_secret
142 # @option options [String] :slack_app_verification_token
143 # @option options [Integer] :terminal_max_session_time
144 # @option options [String] :terms
145 # @option options [Boolean] :throttle_authenticated_api_enabled
146 # @option options [Integer] :throttle_authenticated_api_period_in_seconds
147 # @option options [Integer] :throttle_authenticated_api_requests_per_period
148 # @option options [Boolean] :throttle_authenticated_web_enabled
149 # @option options [Integer] :throttle_authenticated_web_period_in_seconds
150 # @option options [Integer] :throttle_authenticated_web_requests_per_period
151 # @option options [Boolean] :throttle_unauthenticated_enabled
152 # @option options [Integer] :throttle_unauthenticated_period_in_seconds
153 # @option options [Integer] :throttle_unauthenticated_requests_per_period
154 # @option options [Integer] :two_factor_grace_period
155 # @option options [Boolean] :unique_ips_limit_enabled
156 # @option options [Integer] :unique_ips_limit_per_user
157 # @option options [Integer] :unique_ips_limit_time_window
158 # @option options [Boolean] :usage_ping_enabled
159 # @option options [Boolean] :user_default_external
160 # @option options [Boolean] :user_oauth_applications
161 # @option options [Boolean] :user_show_add_ssh_key_message
162 # @option options [Boolean] :version_check_enabled
163 # @option options [Integer] :local_markdown_version
164 # @option options [String] :geo_node_allowed_ips
165 #
166 # @return [Array<Gitlab::ObjectifiedHash>]
167 def edit_application_settings(options = {})
168 put('/application/settings', body: options)
169 end
170 end
171 end
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to avatar.
4 # @see https://docs.gitlab.com/ce/api/avatar.html
5 module Avatar
6 # Get a single avatar URL for a user with the given email address.
7 #
8 # @example
9 # Gitlab.avatar(email: 'admin@example.com')
10 # Gitlab.avatar(email: 'admin@example.com', size: 32)
11 #
12 # @param [Hash] options A customizable set of options.
13 # @option options [String] :email(required) Public email address of the user.
14 # @option options [Integer] :size(optional) Single pixel dimension (since images are squares). Only used for avatar lookups at Gravatar or at the configured Libravatar server.
15 # @return <Gitlab::ObjectifiedHash>
16 def avatar(options = {})
17 get('/avatar', query: options)
18 end
19 end
20 end
1616 # @return [Array<Gitlab::ObjectifiedHash>]
1717 def boards(project, options = {})
1818 get("/projects/#{url_encode project}/boards", query: options)
19 end
20
21 # Get a single board.
22 #
23 # @example
24 # Gitlab.board(5, 1)
25 #
26 # @param [Integer, String] project The ID or name of a project.
27 # @param [Integer] id The ID of a board.
28 # @return [Gitlab::ObjectifiedHash] Returns information about the board
29 def board(project, id)
30 get("/projects/#{url_encode project}/boards/#{id}")
31 end
32
33 # Creates a new board.
34 #
35 # @example
36 # Gitlab.create_board(5, 'newboard')
37 #
38 # @param [Integer, String] project The ID or name of a project.
39 # @param [String] name The name of the new board.
40 # @return [Gitlab::ObjectifiedHash] Information about created board.
41 def create_board(project, name)
42 body = { name: name }
43 post("/projects/#{url_encode project}/boards", body: body)
44 end
45
46 # Updates a board.
47 #
48 # @example
49 # Gitlab.edit_board(5, 1, name: 'new_name')
50 # Gitlab.edit_board(5, 1, name: 'new_name', assignee_id: 1, milestone_id: 1)
51 #
52 # @param [Integer, String] project The ID or name of a project.
53 # @param [Integer] id The ID of a board.
54 # @param [Hash] options A customizable set of options.
55 # @option options [String] :name(optional) The new name of the board.
56 # @option options [Integer] :assignee_id(optional) The assignee the board should be scoped to.
57 # @option options [Integer] :milestone_id(optional) The milestone the board should be scoped to.
58 # @option options [String] :labels(optional) Comma-separated list of label names which the board should be scoped to.
59 # @option options [Integer] :weight(optional) The weight range from 0 to 9, to which the board should be scoped to.
60 # @return [Gitlab::ObjectifiedHash] Information about updated board.
61 def edit_board(project, id, options = {})
62 put("/projects/#{url_encode project}/boards/#{id}", body: options)
63 end
64
65 # Deletes a board.
66 #
67 # @example
68 # Gitlab.delete_board(5, 1)
69 #
70 # @param [Integer, String] project The ID or name of a project.
71 # @param [Integer] id The ID of a board.
72 # @return [void] This API call returns an empty response body.
73 def delete_board(project, id)
74 delete("/projects/#{url_encode project}/boards/#{id}")
1975 end
2076
2177 # Gets a board lists
11
22 class Gitlab::Client
33 # Defines methods related to builds.
4 # @see https://docs.gitlab.com/ce/api/build_variables.html
5 # @see https://docs.gitlab.com/ee/api/group_level_variables.html
4 # @see https://docs.gitlab.com/ce/api/project_level_variables.html
5 # @see https://docs.gitlab.com/ce/api/group_level_variables.html
66 module BuildVariables
77 # Gets a list of the project's build variables
88 #
3535 # @param [Integer, String] project The ID or name of a project.
3636 # @param [String] key The key of a variable; must have no more than 255 characters; only `A-Z`, `a-z`, `0-9` and `_` are allowed
3737 # @param [String] value The value of a variable
38 # @param [Hash] opts optional parameters
3839 # @return [Gitlab::ObjectifiedHash] The variable.
39 def create_variable(project, key, value)
40 post("/projects/#{url_encode project}/variables", body: { key: key, value: value })
40 def create_variable(project, key, value, **opts)
41 post("/projects/#{url_encode project}/variables", body: opts.merge(key: key, value: value))
4142 end
4243
4344 # Update a project's build variable.
4849 # @param [Integer, String] project The ID or name of a project.
4950 # @param [String] key The key of a variable
5051 # @param [String] value The value of a variable
52 # @param [Hash] opts optional parameters
5153 # @return [Gitlab::ObjectifiedHash] The variable.
52 def update_variable(project, key, value)
53 put("/projects/#{url_encode project}/variables/#{key}", body: { value: value })
54 def update_variable(project, key, value, **opts)
55 put("/projects/#{url_encode project}/variables/#{key}", body: opts.merge(value: value))
5456 end
5557
5658 # Remove a project's build variable.
9698 # @param [Integer, String] group The ID or name of a group.
9799 # @param [String] key The key of a variable; must have no more than 255 characters; only `A-Z`, `a-z`, `0-9` and `_` are allowed
98100 # @param [String] value The value of a variable
101 # @param [Hash] opts optional parameters
99102 # @return [Gitlab::ObjectifiedHash] The variable.
100 def create_group_variable(group, key, value)
101 post("/groups/#{url_encode group}/variables", body: { key: key, value: value })
103 def create_group_variable(group, key, value, **opts)
104 post("/groups/#{url_encode group}/variables", body: opts.merge(key: key, value: value))
102105 end
103106
104107 # Update a group's build variable.
109112 # @param [Integer, String] group The ID or name of a group.
110113 # @param [String] key The key of a variable
111114 # @param [String] value The value of a variable
115 # @param [Hash] opts optional parameters
112116 # @return [Gitlab::ObjectifiedHash] The variable.
113 def update_group_variable(group, key, value)
114 put("/groups/#{url_encode group}/variables/#{key}", body: { value: value })
117 def update_group_variable(group, key, value, **opts)
118 put("/groups/#{url_encode group}/variables/#{key}", body: opts.merge(value: value))
115119 end
116120
117121 # Remove a group's build variable.
77 #
88 # @example
99 # Gitlab.commits('viking')
10 # Gitlab.repo_commits('gitlab', { ref_name: 'api' })
10 # Gitlab.repo_commits('gitlab', { ref: 'api' })
1111 #
1212 # @param [Integer, String] project The ID or name of a project.
1313 # @param [Hash] options A customizable set of options.
14 # @option options [String] :ref_name The branch or tag name of a project repository.
14 # @option options [String] :ref The branch or tag name of a project repository.
1515 # @option options [Integer] :page The page number.
1616 # @option options [Integer] :per_page The number of results per page.
1717 # @return [Array<Gitlab::ObjectifiedHash>]
3333 get("/projects/#{url_encode project}/repository/commits/#{sha}")
3434 end
3535 alias repo_commit commit
36
37 # Get all references (from branches or tags) a commit is pushed to.
38 #
39 # @example
40 # Gitlab.commit_refs(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
41 #
42 # @param [Integer, String] project The ID or name of a project.
43 # @param [String] sha The commit hash
44 # @param [Hash] options A customizable set of options.
45 # @option options [String] :type The scope of commits. Possible values `branch`, `tag`, `all`. Default is `all`.
46 # @option options [Integer] :page The page number.
47 # @option options [Integer] :per_page The number of results per page.
48 # @return [Gitlab::ObjectifiedHash]
49 def commit_refs(project, sha, options = {})
50 get("/projects/#{url_encode project}/repository/commits/#{sha}/refs", query: options)
51 end
3652
3753 # Cherry picks a commit to a given branch.
3854 #
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to GitLab Container Registry.
4 # @see https://docs.gitlab.com/ce/api/container_registry.html
5 module ContainerRegistry
6 # Get a list of registry repositories in a project.
7 #
8 # @example
9 # Gitlab.registry_repositories(5)
10 #
11 # @param [Integer, String] project The ID or name of a project.
12 # @return [Array<Gitlab::ObjectifiedHash>] Returns list of registry repositories in a project.
13 def registry_repositories(project)
14 get("/projects/#{url_encode project}/registry/repositories")
15 end
16
17 # Delete a repository in registry.
18 #
19 # @example
20 # Gitlab.delete_registry_repository(5, 2)
21 #
22 # @param [Integer, String] project The ID or name of a project.
23 # @param [Integer] id The ID of registry repository.
24 # @return [void] This API call returns an empty response body.
25 def delete_registry_repository(project, id)
26 delete("/projects/#{url_encode project}/registry/repositories/#{id}")
27 end
28
29 # Get a list of tags for given registry repository.
30 #
31 # @example
32 # Gitlab.registry_repository_tags(5, 2)
33 #
34 # @param [Integer, String] project The ID or name of a project.
35 # @param [Integer] repository_id The ID of registry repository.
36 # @return [Array<Gitlab::ObjectifiedHash>] Returns list of tags of a registry repository.
37 def registry_repository_tags(project, repository_id)
38 get("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags")
39 end
40
41 # Get details of a registry repository tag.
42 #
43 # @example
44 # Gitlab.registry_repository_tag(5, 2, 'v10.0.0')
45 #
46 # @param [Integer, String] project The ID or name of a project.
47 # @param [Integer] repository_id The ID of registry repository.
48 # @param [String] tag_name The name of tag.
49 # @return <Gitlab::ObjectifiedHash> Returns details about the registry repository tag
50 def registry_repository_tag(project, repository_id, tag_name)
51 get("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags/#{tag_name}")
52 end
53
54 # Delete a registry repository tag.
55 #
56 # @example
57 # Gitlab.delete_registry_repository_tag(5, 2, 'v10.0.0')
58 #
59 # @param [Integer, String] project The ID or name of a project.
60 # @param [Integer] repository_id The ID of registry repository.
61 # @param [String] tag_name The name of tag.
62 # @return [void] This API call returns an empty response body.
63 def delete_registry_repository_tag(project, repository_id, tag_name)
64 delete("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags/#{tag_name}")
65 end
66
67 # Delete repository tags in bulk based on given criteria.
68 #
69 # @example
70 # Gitlab.bulk_delete_registry_repository_tags(5, 2, name_regex: '.*')
71 # Gitlab.bulk_delete_registry_repository_tags(5, 2, name_regex: '[0-9a-z]{40}', keep_n: 5, older_than: '1d')
72 #
73 # @param [Integer, String] project The ID or name of a project.
74 # @param [Integer] repository_id The ID of registry repository.
75 # @param [Hash] options A customizable set of options.
76 # @option options [String] :name_regex(required) The regex of the name to delete. To delete all tags specify .*.
77 # @option options [Integer] :keep_n(optional) The amount of latest tags of given name to keep.
78 # @option options [String] :older_than(required) Tags to delete that are older than the given time, written in human readable form 1h, 1d, 1month.
79 # @return [void] This API call returns an empty response body.
80 def bulk_delete_registry_repository_tags(project, repository_id, options = {})
81 delete("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags", query: options)
82 end
83 end
84 end
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to Epics.
4 # @see https://docs.gitlab.com/ee/api/epics.html
5 module Epics
6 # Gets a list of epics.
7 #
8 # @example
9 # Gitlab.epics(123)
10 # Gitlab.epics(123, { per_page: 40, page: 2 })
11 #
12 # @param [Integer] group_id The ID of a group.
13 # @param [Hash] options A customizable set of options.
14 # @option options [Integer] :page The page number.
15 # @option options [Integer] :per_page The number of results per page.
16 # @return [Array<Gitlab::ObjectifiedHash>]
17 def epics(group_id, options = {})
18 get("/groups/#{group_id}/epics", query: options)
19 end
20
21 # Gets a single epic.
22 #
23 # @example
24 # Gitlab.epic(123, 1)
25 #
26 # @param [Integer] group_id The ID of a group.
27 # @param [Integer] epic_iid The ID of a epic.
28 # @param [Hash] options A customizable set of options.
29 # @return [Gitlab::ObjectifiedHash]
30 def epic(group_id, epic_iid, options = {})
31 get("/groups/#{group_id}/epics/#{epic_iid}", query: options)
32 end
33
34 # Creates a new epic.
35 #
36 # @example
37 # Gitlab.create_epic(123, "My new epic title")
38 #
39 # @param [Integer] group_id The ID of a group.
40 # @param [String] title
41 # @param [Hash] options A customizable set of options.
42 # @return [Gitlab::ObjectifiedHash] Information about created epic.
43 def create_epic(group_id, title, options = {})
44 body = options.merge(title: title)
45 post("/groups/#{group_id}/epics", body: body)
46 end
47
48 # Deletes an epic.
49 #
50 # @example
51 # Gitlab.delete_epic(42, 123)
52 # @param [Integer] group_id The ID of a group.
53 # @param [Integer] epic_iid The IID of an epic.
54 def delete_epic(group_id, epic_iid)
55 delete("/groups/#{group_id}/epics/#{epic_iid}")
56 end
57
58 # Updates an existing epic.
59 #
60 # @example
61 # Gitlab.edit_epic(42)
62 # Gitlab.edit_epic(42, 123, { title: 'New epic title' })
63 #
64 # @param [Integer] group_id The ID.
65 # @param [Integer] epic_iid The IID of an epic.
66 # @param [Hash] options A customizable set of options
67 # @return [Gitlab::ObjectifiedHash] Information about the edited epic.
68 def edit_epic(group_id, epic_iid, options = {})
69 put("/groups/#{group_id}/epics/#{epic_iid}", body: options)
70 end
71 end
72 end
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to feature flags.
4 # https://docs.gitlab.com/ce/api/features.html
5 module Features
6 # Get a list of all persisted features, with its gate values.
7 #
8 # @example
9 # Gitlab.features
10 #
11 # @return [Array<Gitlab::ObjectifiedHash>]
12 def features
13 get('/features')
14 end
15
16 # Set a features gate value.
17 # 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.
18 #
19 # @example
20 # Gitlab.set_feature('new_library', true)
21 # Gitlab.set_feature('new_library', 8)
22 # Gitlab.set_feature('new_library', true, {user: 'gitlab'})
23 #
24 # @param [String] name(required) Name of the feature to create or update
25 # @param [String, Integer] value(required) true or false to enable/disable, or an integer for percentage of time
26 # @param [Hash] options A customizable set of options.
27 # @option options [String] :feature_group(optional) A Feature group name
28 # @option options [String] :user(optional) A GitLab username
29 # @option options [String] :project(optional) A projects path, for example "gitlab-org/gitlab-ce"
30 # @return [Gitlab::ObjectifiedHash] Information about the set/created/updated feature.
31 def set_feature(name, value, options = {})
32 body = { value: value }.merge(options)
33 post("/features/#{name}", body: body)
34 end
35
36 # Delete a feature.
37 #
38 # @example
39 # Gitlab.delete_feature('new_library')
40 #
41 # @param [String] name Name of the feature to delete
42 # @return [void] This API call returns an empty response body.
43 def delete_feature(name)
44 delete("/features/#{name}")
45 end
46 end
47 end
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to group issue boards.
4 # @see https://docs.gitlab.com/ee/api/group_boards.html
5 module GroupBoards
6 # Lists Issue Boards in the given group.
7 #
8 # @example
9 # Gitlab.group_boards(5)
10 #
11 # @param [Integer, String] group The ID or name of a group.
12 # @return [Array<Gitlab::ObjectifiedHash>] List of issue boards of the group
13 def group_boards(group)
14 get("/groups/#{url_encode group}/boards")
15 end
16
17 # Gets a single group issue board.
18 #
19 # @example
20 # Gitlab.group_board(5, 1)
21 #
22 # @param [Integer, String] group The ID or name of a group.
23 # @param [Integer] id The ID of the issue board.
24 # @return [Gitlab::ObjectifiedHash] Returns information about a group issue board
25 def group_board(group, id)
26 get("/groups/#{url_encode group}/boards/#{id}")
27 end
28
29 # Creates a new group issue board.
30 #
31 # @example
32 # Gitlab.create_group_board(5, 'Documentcloud')
33 #
34 # @param [Integer, String] group The ID or name of a group.
35 # @param [String] name The name of the new board.
36 # @return [Gitlab::ObjectifiedHash] Information about created group issue board.
37 def create_group_board(group, name)
38 body = { name: name }
39 post("/groups/#{url_encode group}/boards", body: body)
40 end
41
42 # Updates a group issue board.
43 #
44 # @example
45 # Gitlab.edit_group_board(5, 1, { name: 'DocumentCloud2' })
46 # Gitlab.edit_group_board(5, 1, { name: 'DocumentCloud2', assignee_id: 3 })
47 #
48 # @param [Integer, String] group The ID or name of a group.
49 # @param [Integer] id The ID of the issue board.
50 # @param [Hash] options A customizable set of options.
51 # @option options [String] :name(optional) The new name of the board.
52 # @option options [Integer] :assignee_id(optional) The assignee the board should be scoped to.
53 # @option options [Integer] :milestone_id(optional) The milestone the board should be scoped to.
54 # @option options [String] :labels(optional) Comma-separated list of label names which the board should be scoped to.
55 # @option options [Integer] :weight(optional) The weight range from 0 to 9, to which the board should be scoped to.
56 # @return [Gitlab::ObjectifiedHash] Information about updated group issue board.
57 def edit_group_board(group, id, options = {})
58 put("/groups/#{url_encode group}/boards/#{id}", body: options)
59 end
60
61 # Deletes a group issue board.
62 #
63 # @example
64 # Gitlab.delete_group_board(5, 1)
65 #
66 # @param [Integer, String] group The ID or name of a group.
67 # @param [Integer] id The ID of the issue board.
68 # @return [void] This API call returns an empty response body.
69 def delete_group_board(group, id)
70 delete("/groups/#{url_encode group}/boards/#{id}")
71 end
72
73 # Get a list of the boards lists. Does not include open and closed lists
74 #
75 # @example
76 # Gitlab.group_board_lists(5, 1)
77 #
78 # @param [Integer, String] group The ID or name of a group.
79 # @param [Integer] board_id The ID of the group issue board.
80 # @return [Array<Gitlab::ObjectifiedHash>] List of boards lists of the group
81 def group_board_lists(group, board_id)
82 get("/groups/#{url_encode group}/boards/#{board_id}/lists")
83 end
84
85 # Get a single group issue board list.
86 #
87 # @example
88 # Gitlab.group_board_list(5, 1, 1)
89 #
90 # @param [Integer, String] group The ID or name of a group.
91 # @param [Integer] board_id The ID of the group issue board.
92 # @param [Integer] list_id The ID of a boards list.
93 # @return [Gitlab::ObjectifiedHash] Returns information about a single group issue board list
94 def group_board_list(group, board_id, id)
95 get("/groups/#{url_encode group}/boards/#{board_id}/lists/#{id}")
96 end
97
98 # Creates a new group issue board list.
99 #
100 # @example
101 # Gitlab.create_group_board_list(5, 1)
102 #
103 # @param [Integer, String] group The ID or name of a group.
104 # @param [Integer] board_id The ID of the group issue board.
105 # @param [Integer] label_id The ID of a label.
106 # @return [Gitlab::ObjectifiedHash] Information about created group issue board list.
107 def create_group_board_list(group, board_id, label_id)
108 body = { label_id: label_id }
109 post("/groups/#{url_encode group}/boards/#{board_id}/lists", body: body)
110 end
111
112 # Updates an existing group issue board list. This call is used to change list position.
113 #
114 # @example
115 # Gitlab.edit_group_board_list(5, 1, 1, { position: 1 })
116 #
117 # @param [Integer, String] group The ID or name of a group.
118 # @param [Integer] board_id The ID of the group issue board.
119 # @param [Integer] list_id The ID of a boards list.
120 # @param [Hash] options A customizable set of options.
121 # @option options [String] :position(required) The position of the list.
122 # @return [Gitlab::ObjectifiedHash] Information about updated group issue board list.
123 def edit_group_board_list(group, board_id, id, options = {})
124 put("/groups/#{url_encode group}/boards/#{board_id}/lists/#{id}", body: options)
125 end
126
127 # Deletes a group issue board list.
128 #
129 # @example
130 # Gitlab.delete_group_board_list(5, 1, 1)
131 #
132 # @param [Integer, String] group The ID or name of a group.
133 # @param [Integer] board_id The ID of the group issue board.
134 # @param [Integer] list_id The ID of a boards list.
135 # @return [void] This API call returns an empty response body.
136 def delete_group_board_list(group, board_id, id)
137 delete("/groups/#{url_encode group}/boards/#{board_id}/lists/#{id}")
138 end
139 end
140 end
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to group labels.
4 #
5 # @note Requires GitLab 11.8+
6 # @see https://docs.gitlab.com/ee/api/group_labels.html
7 module GroupLabels
8 # Gets a list of group's labels.
9 #
10 # @example
11 # Gitlab.group_labels('globex')
12 #
13 # @param [Integer, String] group The ID or name of a group.
14 # @return [Array<Gitlab::ObjectifiedHash>]
15 def group_labels(group, options = {})
16 get("/groups/#{url_encode group}/labels", query: options)
17 end
18
19 # Creates a new group label.
20 #
21 # @example
22 # Gitlab.create_group_label('globex', 'Backlog', '#DD10AA')
23 #
24 # @param [Integer, String] group The ID or name of a group.
25 # @param [String] name The name of a label.
26 # @param [String] color The color of a label.
27 # @param [Hash] options A customizable set of options.
28 # @option options [String] :description The description of the label.
29 # @return [Gitlab::ObjectifiedHash] Information about created label.
30 def create_group_label(group, name, color, options = {})
31 post("/groups/#{url_encode group}/labels", body: options.merge(name: name, color: color))
32 end
33
34 # Updates a group label.
35 #
36 # @example
37 # Gitlab.edit_group_label('globex', 'Backlog', { new_name: 'Priority' })
38 # Gitlab.edit_group_label('globex', 'Backlog', { new_name: 'Priority', color: '#DD10AA' })
39 #
40 # @param [Integer, String] group The ID or name of a group.
41 # @param [String] name The name of a label.
42 # @param [Hash] options A customizable set of options.
43 # @option options [String] :new_name The new name of a label.
44 # @option options [String] :color The color of a label.
45 # @option options [String] :description The description of the label.
46 # @return [Gitlab::ObjectifiedHash] Information about updated label.
47 def edit_group_label(group, name, options = {})
48 put("/groups/#{url_encode group}/labels", body: options.merge(name: name))
49 end
50
51 # Deletes a group label.
52 #
53 # @example
54 # Gitlab.delete_group_label('globex', 'Backlog')
55 #
56 # @param [Integer, String] group The ID or name of a group.
57 # @param [String] name The name of a label.
58 # @return [Gitlab::ObjectifiedHash] Information about deleted label.
59 def delete_group_label(group, name)
60 delete("/groups/#{url_encode group}/labels", body: { name: name })
61 end
62
63 # Subscribes the user to a group label to receive notifications
64 #
65 # @example
66 # Gitlab.subscribe_to_group_label('globex', 'Backlog')
67 #
68 # @param [Integer, String] group The ID or name of a group.
69 # @param [String] name The name of a label.
70 # @return [Gitlab::ObjectifiedHash] Information about the label subscribed to.
71 def subscribe_to_group_label(group, name)
72 post("/groups/#{url_encode group}/labels/#{url_encode name}/subscribe")
73 end
74
75 # Unsubscribes the user from a group label to not receive notifications from it
76 #
77 # @example
78 # Gitlab.unsubscribe_from_group_label('globex', 'Backlog')
79 #
80 # @param [Integer, String] group The ID or name of a group.
81 # @param [String] name The name of a label.
82 # @return [Gitlab::ObjectifiedHash] Information about the label unsubscribed from.
83 def unsubscribe_from_group_label(group, name)
84 post("/groups/#{url_encode group}/labels/#{url_encode name}/unsubscribe")
85 end
86 end
87 end
2323 # Gitlab.group(42)
2424 #
2525 # @param [Integer] id The ID of a group.
26 # @param [Hash] options A customizable set of options.
27 # @option options [Boolean] :with_custom_attributes Include custom attributes in response (admins only)
28 # @option options [Boolean] :with_projects Include details about group projects (default: true)
2629 # @return [Gitlab::ObjectifiedHash]
27 def group(id)
28 get("/groups/#{url_encode id}")
30 def group(id, options = {})
31 get("/groups/#{url_encode id}", query: options)
2932 end
3033
3134 # Creates a new group.
7780 # @return [Gitlab::ObjectifiedHash] (id, username, name, email, state, access_level ...)
7881 def group_member(team_id, user_id)
7982 get("/groups/#{url_encode team_id}/members/#{user_id}")
83 end
84
85 # Gets a list of merge requests of a group.
86 #
87 # @example
88 # Gitlab.group_merge_requests(5)
89 #
90 # @param [Integer, String] group_id The ID or name of a group.
91 # @param [Hash] options A customizable set of options.
92 # @return [Array<Gitlab::ObjectifiedHash>]
93 def group_merge_requests(group, options = {})
94 get("/groups/#{group}/merge_requests", query: options)
8095 end
8196
8297 # Adds a user to group.
190205 def edit_group(id, options = {})
191206 put("/groups/#{url_encode id}", body: options)
192207 end
208
209 # Gets a list of issues of a group.
210 #
211 # @example
212 # Gitlab.group_issues(5)
213 #
214 # @param [Integer, String] group_id The ID or name of a group.
215 # @param [Hash] options A customizable set of options.
216 # @return [Array<Gitlab::ObjectifiedHash>]
217 def group_issues(group, options = {})
218 get("/groups/#{group}/issues", query: options)
219 end
220
221 # Sync group with LDAP
222 #
223 # @example
224 # Gitlab.sync_ldap_group(1)
225 #
226 # @param [Integer] id The ID or name of a group.
227 # @return [Array<Gitlab::ObjectifiedHash>]
228 def sync_ldap_group(id)
229 post("/groups/#{url_encode id}/ldap_sync")
230 end
231
232 # Add LDAP group link
233 #
234 # @example
235 # Gitlab.add_ldap_group_links(1, 'all', 50, 'ldap')
236 #
237 # @param [Integer] id The ID of a group
238 # @param [String] cn The CN of a LDAP group
239 # @param [Integer] group_access Minimum access level for members of the LDAP group.
240 # @param [String] provider LDAP provider for the LDAP group
241 # @return [Gitlab::ObjectifiedHash] Information about added ldap group link
242 def add_ldap_group_links(id, commonname, group_access, provider)
243 post("/groups/#{url_encode id}/ldap_group_links", body: { cn: commonname, group_access: group_access, provider: provider })
244 end
245
246 # Delete LDAP group link
247 #
248 # @example
249 # Gitlab.delete_ldap_group_links(1, 'all')
250 #
251 # @param [Integer] id The ID of a group
252 # @param [String] cn The CN of a LDAP group
253 # @return [Gitlab::ObjectifiedHash] Empty hash
254 def delete_ldap_group_links(id, commonname, provider)
255 delete("/groups/#{url_encode id}/ldap_group_links/#{url_encode provider}/#{url_encode commonname}")
256 end
193257 end
194258 end
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to issue links.
4 # @see https://docs.gitlab.com/ee/api/issue_links.html
5 module IssueLinks
6 # Gets a list of links for a issue.
7 #
8 # @example
9 # Gitlab.issue_links(5, 10)
10 #
11 # @param [Integer] project The ID of a project.
12 # @param [Integer] issue The ID of an issue.
13 # @option options [Integer] :page The page number.
14 # @option options [Integer] :per_page The number of results per page.
15 # @return [Array<Gitlab::ObjectifiedHash>]
16 def issue_links(project, issue, options = {})
17 get("/projects/#{url_encode project}/issues/#{issue}/links", query: options)
18 end
19
20 # Creates a new issue link.
21 #
22 # @example
23 # Gitlab.create_issue_link(6, 1, 6, 2)
24 #
25 # @param [Integer, String] project The ID or name of a project.
26 # @param [Integer] issue The ID of an issue.
27 # @param [Integer] target_project_id Project ID the target issue is located in.
28 # @param [Integer] target_issue_iid The ID of the target issue.
29 # @return [Gitlab::ObjectifiedHash] Information about created link.
30 def create_issue_link(project, issue, target_project_id, target_issue_iid)
31 post("/projects/#{url_encode project}/issues/#{issue}/links", body: { target_project_id: target_project_id, target_issue_iid: target_issue_iid })
32 end
33
34 # Deletes an issue link.
35 #
36 # @example
37 # Gitlab.delete_issue_link(5, 10, 123)
38 #
39 # @param [Integer] project The ID of a project.
40 # @param [Integer] issue The ID of an issue.
41 # @param [Integer] id The ID of a link.
42 # @return [Gitlab::ObjectifiedHash]
43 def delete_issue_link(project, issue, id)
44 delete("/projects/#{url_encode project}/issues/#{issue}/links/#{id}")
45 end
46 end
47 end
180180 # @param [Integer] id The ID of an issue.
181181 # @param [String] duration The time spent in human format. e.g: 3h30m
182182 def add_time_spent_on_issue(project, id, duration)
183 post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration: url_encode(duration) })
183 post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration: duration })
184184 end
185185
186186 # Resets the total spent time for this issue to 0 seconds.
162162 def job_artifacts_keep(project_id, job_id)
163163 post("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/keep")
164164 end
165
166 # Delete Artifacts
167 # Deletes the artifacts associated with a job.
168 #
169 # @example
170 # Gitlab.job_artifacts_delete(1,1)
171 # Gitlab.job_artifacts_delete("project", 1)
172 #
173 # @param [Integer, String] The ID or name of a project.
174 # @param [Integer] the id of the job
175 # @return [Array<Gitlab::ObjectifiedHash>]
176 def job_artifacts_delete(project_id, job_id)
177 delete("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts")
178 end
165179 end
166180 end
00 # frozen_string_literal: true
11
22 class Gitlab::Client
3 # Defines methods related to labels.
3 # Defines methods related to project labels.
44 # @see https://docs.gitlab.com/ce/api/labels.html
55 module Labels
66 # Gets a list of project's labels.
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to lint/validations.
4 # @see https://docs.gitlab.com/ce/api/lint.html
5 module Lint
6 # Checks if your .gitlab-ci.yml file is valid.
7 #
8 # @example
9 # Gitlab.validate_gitlab_ci_yml("{ \"image\": \"ruby:2.6\", \"services\": [\"postgres\"], \"before_script\": [\"bundle install\", \"bundle exec rake db:create\"], \"variables\": {\"DB_NAME\": \"postgres\"}, \"types\": [\"test\", \"deploy\", \"notify\"], \"rspec\": { \"script\": \"rake spec\", \"tags\": [\"ruby\", \"postgres\"], \"only\": [\"branches\"]}}")
10 #
11 # @param [String] content the .gitlab-ci.yaml content.
12 # @return <Gitlab::ObjectifiedHash> Returns information about validity of the yml.
13 def validate_gitlab_ci_yml(content)
14 body = { content: content }
15 post('/lint', body: body)
16 end
17 end
18 end
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to markdown.
4 # @see https://docs.gitlab.com/ce/api/markdown.html
5 module Markdown
6 # Render an arbitrary Markdown document
7 #
8 # @example
9 # Gitlab.markdown('Hello world! :tada:')
10 # Gitlab.markdown('Hello world! :tada:', gfm: true, project: 'group_example/project_example')
11 #
12 # @param [String] text The markdown text to render.
13 # @param [Hash] options A customizable set of options.
14 # @option options [Boolean] :gfm(optional) Render text using GitLab Flavored Markdown. Default is false.
15 # @option options [String] :project(optional) Use project as a context when creating references using GitLab Flavored Markdown. Authentication is required if a project is not public.
16 # @return <Gitlab::ObjectifiedHash> Returns the rendered markdown as response
17 def markdown(text, options = {})
18 body = { text: text }.merge(options)
19 post('/markdown', body: body)
20 end
21 end
22 end
3636 # Gitlab.edit_project_approvers(1, {approver_ids: [5], approver_groups: [1]})
3737 #
3838 # @param [Integer] project(required) The ID of a project.
39 # @option options [Array] :approver_ids(optional) An array of User IDs that can approve MRs
40 # @option options [Array] :approver_group_ids(optional) An array of Group IDs whose members can approve MRs
39 # @option options [Array] :approver_ids(required, nil if none) An array of User IDs that can approve MRs
40 # @option options [Array] :approver_group_ids(required, nil if none) An array of Group IDs whose members can approve MRs
4141 # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
4242 def edit_project_approvers(project, options = {})
43 put("/projects/#{url_encode project}/approvals", body: options)
43 put("/projects/#{url_encode project}/approvers", body: options)
4444 end
4545
4646 # Get Configuration for approvals on a specific Merge Request.
7575 #
7676 # @param [Integer] project(required) The ID of a project.
7777 # @param [Integer] merge_request(required) The IID of a merge_request.
78 # @option options [Array] :approver_ids(optional) An array of User IDs that can approve MRs
79 # @option options [Array] :approver_group_ids(optional) An array of Group IDs whose members can approve MRs
78 # @option options [Array] :approver_ids(required, nil if none) An array of User IDs that can approve MRs
79 # @option options [Array] :approver_group_ids(required, nil if none) An array of Group IDs whose members can approve MRs
8080 # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
8181 def edit_merge_request_approvers(project, merge_request, options = {})
82 put("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals", body: options)
82 put("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvers", body: options)
8383 end
8484
8585 # Approve a merge request
103103 #
104104 # @param [Integer] project(required) The ID of a project.
105105 # @param [Integer] merge_request(required) The IID of a merge request.
106 # @option options [String] :sudo(optional) The username of the user you want to remove the approval for
106107 # @return [void] This API call returns an empty response body.
107 def unapprove_merge_request(project, merge_request)
108 post("/projects/#{url_encode project}/merge_requests/#{merge_request}/unapprove")
108 def unapprove_merge_request(project, merge_request, options = {})
109 post("/projects/#{url_encode project}/merge_requests/#{merge_request}/unapprove", body: options)
109110 end
110111 end
111112 end
5252 # @return [Array<Gitlab::ObjectifiedHash>]
5353 def merge_request_pipelines(project, id)
5454 get("/projects/#{url_encode project}/merge_requests/#{id}/pipelines")
55 end
56
57 # Get a list of merge request participants.
58 #
59 # @example
60 # Gitlab.merge_request_participants(5, 36)
61 #
62 # @param [Integer, String] project The ID or name of a project.
63 # @param [Integer] id The ID of a merge request.
64 # @return [Array<Gitlab::ObjectifiedHash>]
65 def merge_request_participants(project, id)
66 get("/projects/#{url_encode project}/merge_requests/#{id}/participants")
5567 end
5668
5769 # Creates a merge request.
275275 # in the 'else'.
276276 def note_content(body)
277277 if body.is_a?(Hash)
278 STDERR.puts 'Passing the note body as a Hash is deprecated. You should just pass the String.'
278 warn 'Passing the note body as a Hash is deprecated. You should just pass the String.'
279279 body
280280 else
281281 { body: body }
7676 def retry_pipeline(project, id)
7777 post("/projects/#{url_encode project}/pipelines/#{id}/retry")
7878 end
79
80 # Delete a pipeline
81 #
82 # @example
83 # Gitlab.delete_pipeline(5, 1)
84 #
85 # @param [Integer, String] project The ID or name of a project.
86 # @param [Integer] id The ID of a pipeline.
87 # @return [void] This API call returns an empty response body.
88 def delete_pipeline(project, id)
89 delete("/projects/#{url_encode project}/pipelines/#{id}")
90 end
7991 end
8092 end
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to project clusters.
4 # @see https://docs.gitlab.com/ce/api/project_clusters.html
5 module ProjectClusters
6 # Returns a list of project clusters.
7 #
8 # @example
9 # Gitlab.project_clusters(5)
10 #
11 # @param [Integer, String] project The ID or name of a project.
12 # @return [Array<Gitlab::ObjectifiedHash>] List of all clusters of a project
13 def project_clusters(project)
14 get("/projects/#{url_encode project}/clusters")
15 end
16
17 # Gets a single project cluster.
18 #
19 # @example
20 # Gitlab.project_cluster(5, 42)
21 #
22 # @param [Integer, String] project The ID or name of a project.
23 # @param [Integer] cluster_id The ID of the cluster.
24 # @return [Gitlab::ObjectifiedHash] Information about the requested cluster
25 def project_cluster(project, cluster_id)
26 get("/projects/#{url_encode project}/clusters/#{cluster_id}")
27 end
28
29 # Adds an existing Kubernetes cluster to the project.
30 #
31 # @example
32 # 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' } })
33 # Gitlab.add_project_cluster(5, 'cluster-5', { platform_kubernetes_attributes: { api_url: 'https://35.111.51.20', token: '12345' } })
34 #
35 # @param [Integer, String] project The ID or name of a project.
36 # @param [String] name The name of the existing cluster.
37 # @param [Hash] options A customizable set of options.
38 # @option options [Boolean] :enabled(optional) Determines if cluster is active or not, defaults to true
39 # @option options [Hash] :platform_kubernetes_attributes A customizable set of Kubernetes platform attributes
40 # @suboption platform_kubernetes_attributes [String] :api_url(required) The URL to access the Kubernetes API
41 # @suboption platform_kubernetes_attributes [String] :token(required) The token to authenticate against Kubernetes
42 # @suboption platform_kubernetes_attributes [String] :ca_cert(optional) TLS certificate (needed if API is using a self-signed TLS certificate
43 # @suboption platform_kubernetes_attributes [String] :namespace(optional) The unique namespace related to the project
44 # @suboption platform_kubernetes_attributes [String] :authorization_type(optional) The cluster authorization type: rbac, abac or unknown_authorization. Defaults to rbac.
45 # @return [Gitlab::ObjectifiedHash] Information about the added project cluster.
46 def add_project_cluster(project, name, options = {})
47 body = { name: name }.merge(options)
48 post("/projects/#{url_encode project}/clusters/user", body: body)
49 end
50
51 # Updates an existing project cluster.
52 #
53 # @example
54 # 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' } })
55 #
56 # @param [Integer, String] project The ID or name of a project.
57 # @param [Integer] cluster_id The ID of the cluster.
58 # @param [Hash] options A customizable set of options.
59 # @option options [String] :name(optional) The name of the cluster
60 # @option options [Hash] :platform_kubernetes_attributes A customizable set of Kubernetes platform attributes
61 # @suboption platform_kubernetes_attributes [String] :api_url(required) The URL to access the Kubernetes API
62 # @suboption platform_kubernetes_attributes [String] :token(required) The token to authenticate against Kubernetes
63 # @suboption platform_kubernetes_attributes [String] :ca_cert(optional) TLS certificate (needed if API is using a self-signed TLS certificate
64 # @suboption platform_kubernetes_attributes [String] :namespace(optional) The unique namespace related to the project
65 # @return [Gitlab::ObjectifiedHash] Information about the updated project cluster.
66 def edit_project_cluster(project, cluster_id, options = {})
67 put("/projects/#{url_encode project}/clusters/#{cluster_id}", body: options)
68 end
69
70 # Deletes an existing project cluster.
71 #
72 # @example
73 # Gitlab.delete_project_cluster(5, 42)
74 #
75 # @param [Integer, String] project The ID or name of a project.
76 # @param [Integer] cluster_id The ID of the cluster.
77 # @return [nil] This API call returns an empty response body.
78 def delete_project_cluster(project, cluster_id)
79 delete("/projects/#{url_encode project}/clusters/#{cluster_id}")
80 end
81 end
82 end
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to project release links.
4 # @see https://docs.gitlab.com/ce/api/releases/links.html
5 module ProjectReleaseLinks
6 # Get assets as links from a Release.
7 #
8 # @example
9 # Gitlab.project_release_links(5, 'v0.3')
10 #
11 # @param [Integer, String] project The ID or name of a project.
12 # @param [String] tag_name The tag associated with the Release.
13 # @return [Array<Gitlab::ObjectifiedHash>] List of assets as links from a Release.
14 def project_release_links(project, tag_name)
15 get("/projects/#{url_encode project}/releases/#{tag_name}/assets/links")
16 end
17
18 # Get an asset as link from a Release.
19 #
20 # @example
21 # Gitlab.project_release_link(5, 'v0.3', 1)
22 #
23 # @param [Integer, String] project The ID or name of a project.
24 # @param [String] tag_name The tag associated with the Release.
25 # @param [Integer] link_id The id of the link.
26 # @return [Gitlab::ObjectifiedHash] Information about the release link
27 def project_release_link(project, tag_name, link_id)
28 get("/projects/#{url_encode project}/releases/#{tag_name}/assets/links/#{link_id}")
29 end
30
31 # Create an asset as a link from a Release.
32 #
33 # @example
34 # Gitlab.create_project_release_link(5, 'v0.1', { name: 'awesome-v0.2.dmg', url: 'http://192.168.10.15:3000' })
35 #
36 # @param [Integer, String] project The ID or name of a project.
37 # @param [String] tag_name The tag associated with the Release.
38 # @param [Hash] options A customizable set of options.
39 # @option options [String] :name(required) The name of the link.
40 # @option options [String] :url(required) The URL of the link.
41 # @return [Gitlab::ObjectifiedHash] Information about the created release link.
42 def create_project_release_link(project, tag_name, options = {})
43 post("/projects/#{url_encode project}/releases/#{tag_name}/assets/links", body: options)
44 end
45
46 # Update an asset as a link from a Release. You have to specify at least one of name or url
47 #
48 # @example
49 # Gitlab.update_project_release_link(5, 'v0.3', 1, { name: 'awesome-v0.2.dmg', url: 'http://192.168.10.15:3000' })
50 #
51 # @param [Integer, String] project The ID or name of a project.
52 # @param [String] tag_name The tag where the release will be created from.
53 # @param [Integer] link_id The id of the link.
54 # @param [Hash] options A customizable set of options.
55 # @option options [String] :name(optional) The name of the link.
56 # @option options [String] :url(optional) The URL of the link.
57 # @return [Gitlab::ObjectifiedHash] Information about the updated release link.
58 def update_project_release_link(project, tag_name, link_id, options = {})
59 put("/projects/#{url_encode project}/releases/#{tag_name}/assets/links/#{link_id}", body: options)
60 end
61
62 # Delete an asset as a link from a Release.
63 #
64 # @example
65 # Gitlab.delete_project_release_link(5, 'v0.3', 1)
66 #
67 # @param [Integer, String] project The ID or name of a project.
68 # @param [String] tag_name The tag where the release will be created from.
69 # @param [Integer] link_id The id of the link.
70 # @return [Gitlab::ObjectifiedHash] Information about the deleted release link.
71 def delete_project_release_link(project, tag_name, link_id)
72 delete("/projects/#{url_encode project}/releases/#{tag_name}/assets/links/#{link_id}")
73 end
74 end
75 end
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to project releases.
4 # @see https://docs.gitlab.com/ce/api/releases/
5 module ProjectReleases
6 # Returns Paginated list of a project's releases, sorted by created_at.
7 #
8 # @example
9 # Gitlab.project_releases(5)
10 #
11 # @param [Integer, String] project The ID or name of a project.
12 # @return [Array<Gitlab::ObjectifiedHash>] Paginated list of Releases, sorted by created_at.
13 def project_releases(project)
14 get("/projects/#{url_encode project}/releases")
15 end
16
17 # Gets a Release by a tag name
18 #
19 # @example
20 # Gitlab.project_release(5, 'v0.1')
21 #
22 # @param [Integer, String] project The ID or name of a project.
23 # @param [String] tag_name The tag where the release will be created from..
24 # @return [Gitlab::ObjectifiedHash] Information about the release
25 def project_release(project, tag_name)
26 get("/projects/#{url_encode project}/releases/#{tag_name}")
27 end
28
29 # Creates a Release. You need push access to the repository to create a Release.
30 #
31 # @example
32 # Gitlab.create_project_release(5, { name: 'New Release', tag_name: 'v0.3', description: 'Super nice release' })
33 # Gitlab.create_project_release(5, { name: 'New Release', tag_name: 'v0.3', description: 'Super nice release', assets: { links: [{ name: 'hoge', url: 'https://google.com' }] } })
34 #
35 # @param [Integer, String] project The ID or name of a project.
36 # @param [Hash] options A customizable set of options.
37 # @option options [String] :name(required) The release name.
38 # @option options [String] :tag_name(required) The tag where the release will be created from.
39 # @option options [String] :description(required) The description of the release. You can use markdown.
40 # @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.
41 # @option options [Hash] :assets(optional) A customizable set of options for release assets
42 # @asset assets [Array<link>] :links(optional) An array of assets links as hashes.
43 # @link links [Hash] link_elements A combination of a link name and a link url
44 # @link_element [String] :name The name of the link.
45 # @link_element [String] :url The url of the link.
46 # @return [Gitlab::ObjectifiedHash] Information about the created release.
47 def create_project_release(project, options = {})
48 post("/projects/#{url_encode project}/releases", body: options)
49 end
50
51 # Updates a release.
52 #
53 # @example
54 # Gitlab.update_project_release(5, 'v0.3', { name: 'New Release', description: 'Super nice release' })
55 #
56 # @param [Integer, String] project The ID or name of a project.
57 # @param [String] tag_name The tag where the release will be created from.
58 # @param [Hash] options A customizable set of options.
59 # @option options [String] :name(optional) The release name.
60 # @option options [String] :description(optional) The description of the release. You can use markdown.
61 # @return [Gitlab::ObjectifiedHash] Information about the updated release.
62 def update_project_release(project, tag_name, options = {})
63 put("/projects/#{url_encode project}/releases/#{tag_name}", body: options)
64 end
65
66 # Delete a Release. Deleting a Release will not delete the associated tag.
67 #
68 # @example
69 # Gitlab.delete_project_release(5, 'v0.3')
70 #
71 # @param [Integer, String] project The ID or name of a project.
72 # @param [String] tag_name The tag where the release will be created from.
73 # @return [Gitlab::ObjectifiedHash] Information about the deleted release.
74 def delete_project_release(project, tag_name)
75 delete("/projects/#{url_encode project}/releases/#{tag_name}")
76 end
77 end
78 end
6666 # @option options [Boolean] :issues_enabled The issues integration for a project (0 = false, 1 = true).
6767 # @option options [Boolean] :snippets_enabled The snippets integration for a project (0 = false, 1 = true).
6868 # @option options [Boolean] :merge_requests_enabled The merge requests functionality for a project (0 = false, 1 = true).
69 # @option options [Boolean] :public The setting for making a project public (0 = false, 1 = true).
69 # @option options [String] :visibility The setting for making a project public ('private', 'internal', 'public').
7070 # @option options [Integer] :user_id The user/owner id of a project.
7171 # @return [Gitlab::ObjectifiedHash] Information about created project.
7272 def create_project(name, options = {})
379379 post("/projects/#{url_encode project}/deploy_keys/#{key}/disable", body: { id: project, key_id: key })
380380 end
381381
382 # Updates an existing deploy key.
383 #
384 # @example
385 # Gitlab.edit_deploy_key(42, 66, 'New key name', can_push: false)
386 #
387 # @param [Integer, String] project The ID or path of a project.
388 # @param [Integer] id The ID of a deploy key.
389 # @param [String] title The title of a deploy key.
390 # @param [Hash] options A customizable set of options.
391 # @return [Gitlab::ObjectifiedHash] Information about created deploy key.
392 def edit_deploy_key(project, id, title, options = {})
393 put("/projects/#{url_encode project}/deploy_keys/#{id}", body: { title: title }.merge(options))
394 end
395
382396 # Deletes a deploy key from project.
383397 #
384398 # @example
528542 # @see https://docs.gitlab.com/ee/api/projects.html#upload-a-file
529543 #
530544 # @example
531 # Gitlab.upload_file(1, File.open(File::NULL, 'r'))
532 # File.open('myfile') { |file| Gitlab.upload_file(1, file) }
545 # Gitlab.upload_file(1, '/full/path/to/avatar.jpg')
533546 #
534547 # @param [Integer, String] id The ID or path of a project.
535 # @param [File] The file you are interested to upload.
548 # @param [String] file_fullpath The fullpath of the file you are interested to upload.
536549 # @return [Gitlab::ObjectifiedHash]
537 def upload_file(id, file)
538 post("/projects/#{url_encode id}/uploads", body: { file: file })
550 def upload_file(id, file_fullpath)
551 post("/projects/#{url_encode id}/uploads", body: { file: File.open(file_fullpath, 'r') })
539552 end
540553
541554 # Get all project templates of a particular type
569582 def project_template(project, type, key, options = {})
570583 get("/projects/#{url_encode project}/templates/#{type}/#{key}", query: options)
571584 end
585
586 # Archives a project.
587 #
588 # @example
589 # Gitlab.archive_project(4)
590 #
591 # @param [Integer, String] id The ID or path of a project.
592 # @return [Gitlab::ObjectifiedHash] Information about archived project.
593 def archive_project(id)
594 post("/projects/#{url_encode id}/archive")
595 end
596
597 # Unarchives a project.
598 #
599 # @example
600 # Gitlab.unarchive_project(4)
601 #
602 # @param [Integer, String] id The ID or path of a project.
603 # @return [Gitlab::ObjectifiedHash] Information about unarchived project.
604 def unarchive_project(id)
605 post("/projects/#{url_encode id}/unarchive")
606 end
572607 end
573608 end
1212 # @param [Integer, String] project The ID or name of a project.
1313 # @param [Hash] options A customizable set of options.
1414 # @option options [String] :path The path inside repository.
15 # @option options [String] :ref_name The name of a repository branch or tag.
15 # @option options [String] :ref The name of a repository branch or tag.
16 # @option options [Integer] :per_page Number of results to show per page (default = 20)
1617 # @return [Gitlab::ObjectifiedHash]
1718 def tree(project, options = {})
1819 get("/projects/#{url_encode project}/repository/tree", query: options)
2728 #
2829 # @param [Integer, String] project The ID or name of a project.
2930 # @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
3032 # @return [Gitlab::FileResponse]
31 def repo_archive(project, ref = 'master')
32 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}",
3335 format: nil,
3436 headers: { Accept: 'application/octet-stream' },
3537 query: { sha: ref },
6971 def merge_base(project, refs)
7072 get("/projects/#{url_encode project}/repository/merge_base", query: { refs: refs })
7173 end
74
75 # Get project repository contributors.
76 #
77 # @example
78 # Gitlab.contributors(42)
79 # Gitlab.contributors(42, { order: 'name' })
80 #
81 # @param [Integer, String] project The ID or name of a project.
82 # @param [Hash] options A customizable set of options.
83 # @option options [String] :order_by Order by name, email or commits (default = commits).
84 # @option options [String] :sort Sort order asc or desc (default = asc).
85 # @return [Array<Gitlab::ObjectifiedHash>]
86 def contributors(project, options = {})
87 get("/projects/#{url_encode project}/repository/contributors", query: options)
88 end
89 alias repo_contributors contributors
7290 end
7391 end
2323 parser: ::Gitlab::Request::Parser
2424 end
2525 alias repo_file_contents file_contents
26
27 # Get file blame from repository
28 #
29 # @example
30 # Gitlab.get_file_blame(42, "README.md", "master")
31 #
32 # @param [Integer, String] project The ID or name of a project.
33 # @param [String] file_path The full path of the file.
34 # @param [String] ref The name of branch, tag or commit.
35 # @return [Gitlab::ObjectifiedHash]
36 #
37 def get_file_blame(project, file_path, ref)
38 get("/projects/#{url_encode project}/repository/files/#{url_encode file_path}/blame", query: {
39 ref: ref
40 })
41 end
2642
2743 # Gets a repository file.
2844 #
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to resource label events.
4 # @see https://docs.gitlab.com/ee/api/resource_label_events.html
5 module ResourceLabelEvents
6 # Gets a list of all label events for a single issue.
7 #
8 # @example
9 # Gitlab.issue_label_events(5, 42)
10 #
11 # @param [Integer, String] project The ID or name of a project.
12 # @param [Integer] issue_iid The IID of an issue.
13 # @return [Array<Gitlab::ObjectifiedHash>]
14 def issue_label_events(project, issue_iid)
15 get("/projects/#{url_encode project}/issues/#{issue_iid}/resource_label_events")
16 end
17
18 # Returns a single label event for a specific project issue
19 #
20 # @example
21 # Gitlab.issue_label_event(5, 42, 1)
22 #
23 # @param [Integer, String] project The ID or name of a project.
24 # @param [Integer] issue_iid The IID of an issue.
25 # @param [Integer] id The ID of a label event.
26 # @return Gitlab::ObjectifiedHash
27 def issue_label_event(project, issue_iid, id)
28 get("/projects/#{url_encode project}/issues/#{issue_iid}/resource_label_events/#{id}")
29 end
30
31 # Gets a list of all label events for a single epic.
32 #
33 # @example
34 # Gitlab.epic_label_events(5, 42)
35 #
36 # @param [Integer, String] group The ID or name of a group.
37 # @param [Integer] epic_id The ID of an epic.
38 # @return [Array<Gitlab::ObjectifiedHash>]
39 def epic_label_events(group, epic_id)
40 get("/groups/#{url_encode group}/epics/#{epic_id}/resource_label_events")
41 end
42
43 # Returns a single label event for a specific group epic
44 #
45 # @example
46 # Gitlab.epic_label_event(5, 42, 1)
47 #
48 # @param [Integer, String] group The ID or name of a group.
49 # @param [Integer] epic_id The ID of an epic.
50 # @param [Integer] id The ID of a label event.
51 # @return Gitlab::ObjectifiedHash
52 def epic_label_event(group, epic_id, id)
53 get("/groups/#{url_encode group}/epics/#{epic_id}/resource_label_events/#{id}")
54 end
55
56 # Gets a list of all label events for a single merge request.
57 #
58 # @example
59 # Gitlab.merge_request_label_events(5, 42)
60 #
61 # @param [Integer, String] project The ID or name of a project.
62 # @param [Integer] merge_request_iid The IID of a merge request.
63 # @return [Array<Gitlab::ObjectifiedHash>]
64 def merge_request_label_events(project, merge_request_iid)
65 get("/projects/#{url_encode project}/merge_requests/#{merge_request_iid}/resource_label_events")
66 end
67
68 # Returns a single label event for a specific project merge request
69 #
70 # @example
71 # Gitlab.merge_request_label_event(5, 42, 1)
72 #
73 # @param [Integer, String] project The ID or name of a project.
74 # @param [Integer] merge_request_iid The IID of an merge request.
75 # @param [Integer] id The ID of a label event.
76 # @return Gitlab::ObjectifiedHash
77 def merge_request_label_event(project, merge_request_iid, id)
78 get("/projects/#{url_encode project}/merge_requests/#{merge_request_iid}/resource_label_events/#{id}")
79 end
80 end
81 end
7878 # Gitlab.runner_jobs(1)
7979 #
8080 # @param [Integer] id The ID of a runner.
81 # @param [Hash] options A customizable set of options.
82 # @option options [String] :status Status of the job; one of: running, success, failed, canceled
8183 # @return [Array<Gitlab::ObjectifiedHash>]
82 def runner_jobs(runner_id)
83 get("/runners/#{url_encode runner_id}/jobs")
84 def runner_jobs(runner_id, options = {})
85 get("/runners/#{url_encode runner_id}/jobs", query: options)
8486 end
8587
8688 # List all runners (specific and shared) available in the project. Shared runners are listed if at least one shared runner is defined and shared runners usage is enabled in the project's settings.
121123 def project_disable_runner(id, runner_id)
122124 delete("/projects/#{url_encode id}/runners/#{runner_id}")
123125 end
126
127 # Register a new Runner for the instance.
128 #
129 # @example
130 # Gitlab.register_runner('9142c16ea169eaaea3d752313a434a6e')
131 # Gitlab.register_runner('9142c16ea169eaaea3d752313a434a6e', description: 'Some Description', active: true, locked: false)
132 #
133 # @param [String] token Registration token.
134 # @param [Hash] options A customizable set of options.
135 # @option options [String] :description Runner description.
136 # @option options [Hash] :info Runner metadata.
137 # @option options [Boolean] :active Whether the Runner is active.
138 # @option options [Boolean] :locked Whether the Runner should be locked for current project.
139 # @option options [Boolean] :run_untagged Whether the Runner should handle untagged jobs.
140 # @option options [Array<String>] :tag_list List of Runner tags.
141 # @option options [Integer] :maximum_timeout Maximum timeout set when this Runner will handle the job.
142 # @return <Gitlab::ObjectifiedHash> Response against runner registration
143 def register_runner(token, options = {})
144 body = { token: token }.merge(options)
145 post('/runners', body: body)
146 end
147
148 # Deletes a registed Runner.
149 #
150 # @example
151 # Gitlab.delete_registered_runner('9142c16ea169eaaea3d752313a434a6e')
152 #
153 # @param [String] token Runner authentication token.
154 # @return [nil] This API call returns an empty response body.
155 def delete_registered_runner(token)
156 body = { token: token }
157 delete('/runners', body: body)
158 end
159
160 # Validates authentication credentials for a registered Runner.
161 #
162 # @example
163 # Gitlab.verify_auth_registered_runner('9142c16ea169eaaea3d752313a434a6e')
164 #
165 # @param [String] token Runner authentication token.
166 # @return [nil] This API call returns an empty response body.
167 def verify_auth_registered_runner(token)
168 body = { token: token }
169 post('/runners/verify', body: body)
170 end
124171 end
125172 end
0 # frozen_string_literal: true
1
2 class Gitlab::Client
3 # Defines methods related to global searches, searching in projects and searching in groups.
4 # @see https://docs.gitlab.com/ce/api/search.html
5 module Search
6 # Search globally across the GitLab instance.
7 #
8 # @example
9 # Gitlab.search_globally('projects', 'gitlab')
10 # Gitlab.search_globally('issues', 'gitlab')
11 # Gitlab.search_globally('merge_requests', 'gitlab')
12 # Gitlab.search_globally('milestones', 'gitlab')
13 # Gitlab.search_globally('snippet_titles', 'gitlab')
14 # Gitlab.search_globally('snippet_blobs', 'gitlab')
15 #
16 # @param [String] scope The scope to search in. Currently these scopes are supported: projects, issues, merge_requests, milestones, snippet_titles, snippet_blobs.
17 # @param [String] search The search query.
18 # @return [Array<Gitlab::ObjectifiedHash>] Returns a list of responses depending on the requested scope.
19 def search_globally(scope, search)
20 options = { scope: scope, search: search }
21 get('/search', query: options)
22 end
23
24 # Search within the specified group.
25 #
26 # @example
27 # Gitlab.search_in_group(1, 'projects', 'gitlab')
28 # Gitlab.search_in_group(1, 'issues', 'gitlab')
29 # Gitlab.search_in_group(1, 'merge_requests', 'gitlab')
30 # Gitlab.search_in_group(1, 'milestones', 'gitlab')
31 #
32 # @param [Integer, String] group The ID or name of a group.
33 # @param [String] scope The scope to search in. Currently these scopes are supported: projects, issues, merge_requests, milestones.
34 # @param [String] search The search query.
35 # @return [Array<Gitlab::ObjectifiedHash>] Returns a list of responses depending on the requested scope.
36 def search_in_group(group, scope, search)
37 options = { scope: scope, search: search }
38 get("/groups/#{url_encode group}/search", query: options)
39 end
40
41 # Search within the specified project.
42 #
43 # @example
44 # Gitlab.search_in_project(1, 'issues', 'gitlab')
45 # Gitlab.search_in_project(1, 'merge_requests', 'gitlab')
46 # Gitlab.search_in_project(1, 'milestones', 'gitlab')
47 # Gitlab.search_in_project(1, 'notes', 'gitlab')
48 # Gitlab.search_in_project(1, 'wiki_blobs', 'gitlab')
49 # Gitlab.search_in_project(1, 'commits', 'gitlab')
50 # Gitlab.search_in_project(1, 'blobs', 'gitlab')
51 #
52 # @param [Integer, String] project The ID or name of a project.
53 # @param [String] scope The scope to search in. Currently these scopes are supported: issues, merge_requests, milestones, notes, wiki_blobs, commits, blobs.
54 # @param [String] search The search query.
55 # @return [Array<Gitlab::ObjectifiedHash>] Returns a list of responses depending on the requested scope.
56 def search_in_project(project, scope, search, ref = nil)
57 options = { scope: scope, search: search }
58
59 # Add ref filter if provided - backward compatible with main project
60 options[:ref] = ref unless ref.nil?
61
62 get("/projects/#{url_encode project}/search", query: options)
63 end
64 end
65 end
3636 # @example
3737 # Gitlab.create_user('joe@foo.org', 'secret', 'joe', { name: 'Joe Smith' })
3838 # or
39 # Gitlab.create_user('joe@foo.org', 'secret')
40 #
41 # @param [String] email The email of a user.
42 # @param [String] password The password of a user.
43 # @param [String] username The username of a user.
39 # Gitlab.create_user('joe@foo.org', 'secret', 'joe')
40 #
41 # @param [String] email(required) The email of a user.
42 # @param [String] password(required) The password of a user.
43 # @param [String] username(required) The username of a user.
4444 # @param [Hash] options A customizable set of options.
4545 # @option options [String] :name The name of a user. Defaults to email.
4646 # @option options [String] :skype The skype of a user.
5050 # @return [Gitlab::ObjectifiedHash] Information about created user.
5151 def create_user(*args)
5252 options = args.last.is_a?(Hash) ? args.pop : {}
53 body = if args[2]
54 { email: args[0], password: args[1], username: args[2] }
55 else
56 { email: args[0], password: args[1], name: args[0] }
57 end
53 raise ArgumentError, 'Missing required parameters' unless args[2]
54
55 body = { email: args[0], password: args[1], username: args[2], name: args[0] }
5856 body.merge!(options)
5957 post('/users', body: body)
6058 end
66
77 # Please keep in alphabetical order
88 include AccessRequests
9 include ApplicationSettings
10 include Avatar
911 include AwardEmojis
1012 include Boards
1113 include Branches
1315 include BuildVariables
1416 include Builds
1517 include Commits
18 include ContainerRegistry
1619 include Deployments
1720 include Environments
21 include Epics
1822 include Events
23 include Features
24 include GroupBoards
25 include GroupLabels
1926 include GroupMilestones
2027 include Groups
28 include IssueLinks
2129 include Issues
2230 include Jobs
2331 include Keys
2432 include Labels
33 include Lint
34 include Markdown
2535 include MergeRequestApprovals
2636 include MergeRequests
2737 include Milestones
3141 include PipelineTriggers
3242 include Pipelines
3343 include ProjectBadges
44 include ProjectClusters
45 include ProjectReleaseLinks
46 include ProjectReleases
3447 include Projects
3548 include ProtectedTags
3649 include Repositories
3750 include RepositoryFiles
3851 include RepositorySubmodules
52 include ResourceLabelEvents
3953 include Runners
54 include Search
4055 include Services
4156 include Sidekiq
4257 include Snippets
5772 inspected
5873 end
5974
75 # Utility method for URL encoding of a string.
76 # Copied from https://ruby-doc.org/stdlib-2.7.0/libdoc/erb/rdoc/ERB/Util.html
77 #
78 # @return [String]
6079 def url_encode(url)
61 URI.encode(url.to_s, /\W/)
80 url.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m| sprintf('%%%02X', m.unpack1('C')) } # rubocop:disable Style/FormatString, Style/FormatStringToken
6281 end
6382
6483 private
3434
3535 # Resets all configuration options to the defaults.
3636 def reset
37 self.endpoint = ENV['GITLAB_API_ENDPOINT']
37 self.endpoint = ENV['GITLAB_API_ENDPOINT'] || ENV['CI_API_V4_URL']
3838 self.private_token = ENV['GITLAB_API_PRIVATE_TOKEN'] || ENV['GITLAB_API_AUTH_TOKEN']
3939 self.httparty = get_httparty_config(ENV['GITLAB_API_HTTPARTY_OPTIONS'])
4040 self.sudo = nil
3939 #
4040 # @return [String]
4141 def build_error_message
42 parsed_response = @response.parsed_response
42 parsed_response = classified_response
4343 message = check_error_keys(parsed_response)
4444 "Server responded with code #{@response.code}, message: " \
4545 "#{handle_message(message)}. " \
5151 def check_error_keys(resp)
5252 key = POSSIBLE_MESSAGE_KEYS.find { |k| resp.respond_to?(k) }
5353 key ? resp.send(key) : resp
54 end
55
56 # Parse the body based on the classification of the body content type
57 #
58 # @return parsed response
59 def classified_response
60 if @response.respond_to?('headers')
61 @response.headers['content-type'] == 'text/plain' ? { message: @response.to_s } : @response.parsed_response
62 else
63 @response.parsed_response
64 end
5465 end
5566
5667 # Handle error response message in case of nested hashes
8394 # Raised when API endpoint returns the HTTP status code 405.
8495 class MethodNotAllowed < ResponseError; end
8596
97 # Raised when API endpoint returns the HTTP status code 406.
98 class NotAcceptable < ResponseError; end
99
86100 # Raised when API endpoint returns the HTTP status code 409.
87101 class Conflict < ResponseError; end
88102
89103 # Raised when API endpoint returns the HTTP status code 422.
90104 class Unprocessable < ResponseError; end
105
106 # Raised when API endpoint returns the HTTP status code 429.
107 class TooManyRequests < ResponseError; end
91108
92109 # Raised when API endpoint returns the HTTP status code 500.
93110 class InternalServerError < ResponseError; end
97114
98115 # Raised when API endpoint returns the HTTP status code 503.
99116 class ServiceUnavailable < ResponseError; end
117
118 # HTTP status codes mapped to error classes.
119 STATUS_MAPPINGS = {
120 400 => BadRequest,
121 401 => Unauthorized,
122 403 => Forbidden,
123 404 => NotFound,
124 405 => MethodNotAllowed,
125 406 => NotAcceptable,
126 409 => Conflict,
127 422 => Unprocessable,
128 429 => TooManyRequests,
129 500 => InternalServerError,
130 502 => BadGateway,
131 503 => ServiceUnavailable
132 }.freeze
100133 end
101134 end
7979
8080 # Massage output from 'ri'.
8181 def change_help_output!(cmd, output_str)
82 output_str = +output_str
8283 output_str.gsub!(/#{cmd}\((.*?)\)/m, cmd + ' \1')
8384 output_str.gsub!(/\,[\s]*/, ' ')
8485
5555 response
5656 end
5757
58 def paginate_with_limit(limit)
59 response = block_given? ? nil : []
60 count = 0
61 each_page do |page|
62 if block_given?
63 page.each do |item|
64 yield item
65 count += 1
66 break if count >= limit
67 end
68 else
69 response += page[0, limit - count]
70 count = response.length
71 end
72 break if count >= limit
73 end
74 response
75 end
76
5877 def last_page?
5978 !(@links.nil? || @links.last.nil?)
6079 end
4040
4141 %w[get post put delete].each do |method|
4242 define_method method do |path, options = {}|
43 httparty_config(options)
44 authorization_header(options)
45 validate self.class.send(method, @endpoint + path, options)
43 params = options.dup
44
45 httparty_config(params)
46
47 unless params[:unauthenticated]
48 params[:headers] ||= {}
49 params[:headers].merge!(authorization_header)
50 end
51
52 validate self.class.send(method, @endpoint + path, params)
4653 end
4754 end
4855
4956 # Checks the response code for common errors.
5057 # Returns parsed response for successful requests.
5158 def validate(response)
52 error_klass = case response.code
53 when 400 then Error::BadRequest
54 when 401 then Error::Unauthorized
55 when 403 then Error::Forbidden
56 when 404 then Error::NotFound
57 when 405 then Error::MethodNotAllowed
58 when 409 then Error::Conflict
59 when 422 then Error::Unprocessable
60 when 500 then Error::InternalServerError
61 when 502 then Error::BadGateway
62 when 503 then Error::ServiceUnavailable
63 end
64
59 error_klass = Error::STATUS_MAPPINGS[response.code]
6560 raise error_klass, response if error_klass
6661
6762 parsed = response.parsed_response
7368 # Sets a base_uri and default_params for requests.
7469 # @raise [Error::MissingCredentials] if endpoint not set.
7570 def request_defaults(sudo = nil)
76 self.class.default_params sudo: sudo
7771 raise Error::MissingCredentials, 'Please set an endpoint to API' unless @endpoint
7872
73 self.class.default_params sudo: sudo
7974 self.class.default_params.delete(:sudo) if sudo.nil?
8075 end
8176
8277 private
8378
84 # Sets a PRIVATE-TOKEN or Authorization header for requests.
79 # Returns an Authorization header hash
8580 #
86 # @param [Hash] options A customizable set of options.
87 # @option options [Boolean] :unauthenticated true if the API call does not require user authentication.
8881 # @raise [Error::MissingCredentials] if private_token and auth_token are not set.
89 def authorization_header(options)
90 return if options[:unauthenticated]
82 def authorization_header
9183 raise Error::MissingCredentials, 'Please provide a private_token or auth_token for user' unless @private_token
9284
93 options[:headers] = if @private_token.size < 21
94 { 'PRIVATE-TOKEN' => @private_token }
95 else
96 { 'Authorization' => "Bearer #{@private_token}" }
97 end
85 if @private_token.size < 21
86 { 'PRIVATE-TOKEN' => @private_token }
87 else
88 { 'Authorization' => "Bearer #{@private_token}" }
89 end
9890 end
9991
10092 # Set HTTParty configuration
2929 private
3030
3131 def history_file
32 if defined?(@history_file)
33 @history_file
34 else
35 @history_file = File.open(history_file_path, 'w', 0o600).tap do |file|
36 file.sync = true
37 end
32 @history_file ||= File.open(history_file_path, 'w', 0o600).tap do |file|
33 file.sync = true
3834 end
3935 rescue Errno::EACCES
4036 warn 'History not saved; unable to open your history file for writing.'
4945 path = history_file_path
5046
5147 File.foreach(path) { |line| yield(line) } if File.exist?(path)
52 rescue StandardError => error
53 warn "History file not loaded: #{error.message}"
48 rescue StandardError => e
49 warn "History file not loaded: #{e.message}"
5450 end
5551
5652 def max_lines
00 # frozen_string_literal: true
11
22 module Gitlab
3 VERSION = '4.8.0'
3 VERSION = '4.14.1'
44 end
0 {
1 "default_projects_limit": 100000,
2 "signup_enabled": true,
3 "id": 1,
4 "default_branch_protection": 2,
5 "restricted_visibility_levels": [],
6 "password_authentication_enabled_for_web": true,
7 "after_sign_out_path": null,
8 "max_attachment_size": 10,
9 "user_oauth_applications": true,
10 "updated_at": "2016-01-04T15:44:55.176Z",
11 "session_expire_delay": 10080,
12 "home_page_url": null,
13 "default_snippet_visibility": "private",
14 "domain_whitelist": [],
15 "domain_blacklist_enabled": false,
16 "domain_blacklist": [],
17 "created_at": "2016-01-04T15:44:55.176Z",
18 "default_project_visibility": "private",
19 "default_group_visibility": "private",
20 "gravatar_enabled": true,
21 "sign_in_text": null,
22 "container_registry_token_expire_delay": 5,
23 "repository_storages": [
24 "default"
25 ],
26 "plantuml_enabled": false,
27 "plantuml_url": null,
28 "terminal_max_session_time": 0,
29 "polling_interval_multiplier": 1,
30 "rsa_key_restriction": 0,
31 "dsa_key_restriction": 0,
32 "ecdsa_key_restriction": 0,
33 "ed25519_key_restriction": 0,
34 "first_day_of_week": 0,
35 "enforce_terms": true,
36 "terms": "Hello world!",
37 "performance_bar_allowed_group_id": 42,
38 "instance_statistics_visibility_private": false,
39 "user_show_add_ssh_key_message": true,
40 "file_template_project_id": 1,
41 "local_markdown_version": 0,
42 "geo_node_allowed_ips": "0.0.0.0/0, ::/0"
43 }
0 {
1 "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=64&d=identicon"
2 }
0 {
1 "id": 1,
2 "name": "project issue board",
3 "project": {
4 "id": 5,
5 "name": "Diaspora Project Site",
6 "name_with_namespace": "Diaspora / Diaspora Project Site",
7 "path": "diaspora-project-site",
8 "path_with_namespace": "diaspora/diaspora-project-site",
9 "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git",
10 "web_url": "http://example.com/diaspora/diaspora-project-site"
11 },
12 "milestone": {
13 "id": 12,
14 "title": "10.0"
15 },
16 "lists" : [
17 {
18 "id" : 1,
19 "label" : {
20 "name" : "Testing",
21 "color" : "#F0AD4E",
22 "description" : null
23 },
24 "position" : 1
25 },
26 {
27 "id" : 2,
28 "label" : {
29 "name" : "Ready",
30 "color" : "#FF0000",
31 "description" : null
32 },
33 "position" : 2
34 },
35 {
36 "id" : 3,
37 "label" : {
38 "name" : "Production",
39 "color" : "#FF5F00",
40 "description" : null
41 },
42 "position" : 3
43 }
44 ]
45 }
0 [{
1 "name": "Dmitriy Zaporozhets",
2 "email": "dmitriy.zaporozhets@gmail.com",
3 "commits": 117,
4 "additions": 2097,
5 "deletions": 517
6 }, {
7 "name": "Jacob Vosmaer",
8 "email": "contact@jacobvosmaer.nl",
9 "commits": 33,
10 "additions": 338,
11 "deletions": 244
12 }]
0 {
1 "source_issue": {
2 "id": 83,
3 "iid": 11,
4 "project_id": 4,
5 "created_at": "2016-01-07T12:44:33.959Z",
6 "title": "Issues with auth",
7 "state": "opened",
8 "assignees": [],
9 "assignee": null,
10 "labels": [
11 "bug"
12 ],
13 "author": {
14 "name": "Alexandra Bashirian",
15 "avatar_url": null,
16 "state": "active",
17 "web_url": "https://gitlab.example.com/eileen.lowe",
18 "id": 18,
19 "username": "eileen.lowe"
20 },
21 "description": null,
22 "updated_at": "2016-01-07T12:44:33.959Z",
23 "milestone": null,
24 "subscribed": true,
25 "user_notes_count": 0,
26 "due_date": null,
27 "web_url": "http://example.com/example/example/issues/11",
28 "confidential": false,
29 "weight": null
30 },
31 "target_issue": {
32 "id": 84,
33 "iid": 14,
34 "project_id": 4,
35 "created_at": "2016-01-07T12:44:33.959Z",
36 "title": "Issues with auth",
37 "state": "opened",
38 "assignees": [],
39 "assignee": null,
40 "labels": [
41 "bug"
42 ],
43 "author": {
44 "name": "Alexandra Bashirian",
45 "avatar_url": null,
46 "state": "active",
47 "web_url": "https://gitlab.example.com/eileen.lowe",
48 "id": 18,
49 "username": "eileen.lowe"
50 },
51 "description": null,
52 "updated_at": "2016-01-07T12:44:33.959Z",
53 "milestone": null,
54 "subscribed": true,
55 "user_notes_count": 0,
56 "due_date": null,
57 "web_url": "http://example.com/example/example/issues/14",
58 "confidential": false,
59 "weight": null
60 }
61 }
0 {
1 "source_issue": {
2 "id": 83,
3 "iid": 11,
4 "project_id": 4,
5 "created_at": "2016-01-07T12:44:33.959Z",
6 "title": "Issues with auth",
7 "state": "opened",
8 "assignees": [],
9 "assignee": null,
10 "labels": [
11 "bug"
12 ],
13 "author": {
14 "name": "Alexandra Bashirian",
15 "avatar_url": null,
16 "state": "active",
17 "web_url": "https://gitlab.example.com/eileen.lowe",
18 "id": 18,
19 "username": "eileen.lowe"
20 },
21 "description": null,
22 "updated_at": "2016-01-07T12:44:33.959Z",
23 "milestone": null,
24 "subscribed": true,
25 "user_notes_count": 0,
26 "due_date": null,
27 "web_url": "http://example.com/example/example/issues/11",
28 "confidential": false,
29 "weight": null
30 },
31 "target_issue": {
32 "id": 84,
33 "iid": 14,
34 "project_id": 4,
35 "created_at": "2016-01-07T12:44:33.959Z",
36 "title": "Issues with auth",
37 "state": "opened",
38 "assignees": [],
39 "assignee": null,
40 "labels": [
41 "bug"
42 ],
43 "author": {
44 "name": "Alexandra Bashirian",
45 "avatar_url": null,
46 "state": "active",
47 "web_url": "https://gitlab.example.com/eileen.lowe",
48 "id": 18,
49 "username": "eileen.lowe"
50 },
51 "description": null,
52 "updated_at": "2016-01-07T12:44:33.959Z",
53 "milestone": null,
54 "subscribed": true,
55 "user_notes_count": 0,
56 "due_date": null,
57 "web_url": "http://example.com/example/example/issues/14",
58 "confidential": false,
59 "weight": null
60 }
61 }
0 {
1 "id": 30,
2 "iid": 5,
3 "group_id": 7,
4 "title": "Ea cupiditate dolores ut vero consequatur quasi veniam voluptatem et non.",
5 "description": "Molestias dolorem eos vitae expedita impedit necessitatibus quo voluptatum.",
6 "state": "opened",
7 "web_url": "http://localhost:3001/groups/test/-/epics/5",
8 "reference": "&5",
9 "author":{
10 "id": 7,
11 "name": "Pamella Huel",
12 "username": "arnita",
13 "state": "active",
14 "avatar_url": "http://www.gravatar.com/avatar/a2f5c6fcef64c9c69cb8779cb292be1b?s=80&d=identicon",
15 "web_url": "http://localhost:3001/arnita"
16 },
17 "start_date": null,
18 "start_date_is_fixed": false,
19 "start_date_fixed": null,
20 "start_date_from_inherited_source": null,
21 "due_date": "2018-07-31",
22 "due_date_is_fixed": false,
23 "due_date_fixed": null,
24 "due_date_from_inherited_source": "2018-07-31",
25 "created_at": "2018-07-17T13:36:22.770Z",
26 "updated_at": "2018-07-18T12:22:05.239Z",
27 "closed_at": "2018-08-18T12:22:05.239Z",
28 "labels": [],
29 "upvotes": 4,
30 "downvotes": 0,
31 "subscribed": true
32 }
33
0 [
1 {
2 "id": 29,
3 "iid": 4,
4 "group_id": 7,
5 "title": "Accusamus iste et ullam ratione voluptatem omnis debitis dolor est.",
6 "description": "Molestias dolorem eos vitae expedita impedit necessitatibus quo voluptatum.",
7 "state": "opened",
8 "web_url": "http://localhost:3001/groups/test/-/epics/4",
9 "reference": "&4",
10 "author": {
11 "id": 10,
12 "name": "Lu Mayer",
13 "username": "kam",
14 "state": "active",
15 "avatar_url": "http://www.gravatar.com/avatar/018729e129a6f31c80a6327a30196823?s=80&d=identicon",
16 "web_url": "http://localhost:3001/kam"
17 },
18 "start_date": null,
19 "start_date_is_fixed": false,
20 "start_date_fixed": null,
21 "start_date_from_inherited_source": null,
22 "due_date": "2018-07-31",
23 "due_date_is_fixed": false,
24 "due_date_fixed": null,
25 "due_date_from_inherited_source": "2018-07-31",
26 "created_at": "2018-07-17T13:36:22.770Z",
27 "updated_at": "2018-07-18T12:22:05.239Z",
28 "closed_at": "2018-08-18T12:22:05.239Z",
29 "labels": [],
30 "upvotes": 4,
31 "downvotes": 0
32 }
33 ]
34
0 {
1 "name": "new_library",
2 "state": "conditional",
3 "gates": [
4 {
5 "key": "boolean",
6 "value": false
7 },
8 {
9 "key": "percentage_of_time",
10 "value": 30
11 }
12 ]
13 }
0 [
1 {
2 "name": "experimental_feature",
3 "state": "off",
4 "gates": [
5 {
6 "key": "boolean",
7 "value": false
8 }
9 ]
10 },
11 {
12 "name": "new_library",
13 "state": "on",
14 "gates": [
15 {
16 "key": "boolean",
17 "value": true
18 }
19 ]
20 }
21 ]
0 [
1 {
2 "commit": {
3 "id": "d42409d56517157c48bf3bd97d3f75974dde19fb",
4 "message": "Add feature\n\nalso fix bug\n",
5 "parent_ids": [
6 "cc6e14f9328fa6d7b5a0d3c30dc2002a3f2a3822"
7 ],
8 "authored_date": "2015-12-18T08:12:22.000Z",
9 "author_name": "John Doe",
10 "author_email": "john.doe@example.com",
11 "committed_date": "2015-12-18T08:12:22.000Z",
12 "committer_name": "John Doe",
13 "committer_email": "john.doe@example.com"
14 },
15 "lines": [
16 "require 'fileutils'",
17 "require 'open3'"
18 ]
19 }
20 ]
21
22
0 {"cn":"all","group_access":50,"provider":"ldap"}
0 {
1 "id": 1,
2 "name": "group issue board",
3 "group": {
4 "id": 5,
5 "name": "Documentcloud",
6 "path": "documentcloud",
7 "owner_id": null,
8 "created_at": "2018-05-07T06:52:45.788Z",
9 "updated_at": "2018-07-03T06:48:17.005Z",
10 "description": "Consequatur aut a aperiam ut.",
11 "avatar": {
12 "url": null
13 },
14 "membership_lock": false,
15 "share_with_group_lock": false,
16 "visibility_level": 20,
17 "request_access_enabled": false,
18 "ldap_sync_status": "ready",
19 "ldap_sync_error": null,
20 "ldap_sync_last_update_at": null,
21 "ldap_sync_last_successful_update_at": null,
22 "ldap_sync_last_sync_at": null,
23 "lfs_enabled": null,
24 "parent_id": null,
25 "shared_runners_minutes_limit": null,
26 "repository_size_limit": null,
27 "require_two_factor_authentication": false,
28 "two_factor_grace_period": 48,
29 "plan_id": null,
30 "project_creation_level": 2,
31 "runners_token": "rgeeL-nv4wa9YdRvuMid"
32 },
33 "milestone": {
34 "id": 12,
35 "title": "10.0"
36 },
37 "lists" : [
38 {
39 "id" : 1,
40 "label" : {
41 "name" : "Testing",
42 "color" : "#F0AD4E",
43 "description" : null
44 },
45 "position" : 1
46 },
47 {
48 "id" : 2,
49 "label" : {
50 "name" : "Ready",
51 "color" : "#FF0000",
52 "description" : null
53 },
54 "position" : 2
55 },
56 {
57 "id" : 3,
58 "label" : {
59 "name" : "Production",
60 "color" : "#FF5F00",
61 "description" : null
62 },
63 "position" : 3
64 }
65 ]
66 }
0 {
1 "id" : 1,
2 "label" : {
3 "name" : "Testing",
4 "color" : "#F0AD4E",
5 "description" : null
6 },
7 "position" : 1
8 }
0 [
1 {
2 "id" : 1,
3 "label" : {
4 "name" : "Testing",
5 "color" : "#F0AD4E",
6 "description" : null
7 },
8 "position" : 1
9 },
10 {
11 "id" : 2,
12 "label" : {
13 "name" : "Ready",
14 "color" : "#FF0000",
15 "description" : null
16 },
17 "position" : 2
18 },
19 {
20 "id" : 3,
21 "label" : {
22 "name" : "Production",
23 "color" : "#FF5F00",
24 "description" : null
25 },
26 "position" : 3
27 }
28 ]
0 [
1 {
2 "id": 1,
3 "name": "group issue board",
4 "group": {
5 "id": 5,
6 "name": "Documentcloud",
7 "path": "documentcloud",
8 "owner_id": null,
9 "created_at": "2018-05-07T06:52:45.788Z",
10 "updated_at": "2018-07-03T06:48:17.005Z",
11 "description": "Consequatur aut a aperiam ut.",
12 "avatar": {
13 "url": null
14 },
15 "membership_lock": false,
16 "share_with_group_lock": false,
17 "visibility_level": 20,
18 "request_access_enabled": false,
19 "ldap_sync_status": "ready",
20 "ldap_sync_error": null,
21 "ldap_sync_last_update_at": null,
22 "ldap_sync_last_successful_update_at": null,
23 "ldap_sync_last_sync_at": null,
24 "lfs_enabled": null,
25 "parent_id": null,
26 "shared_runners_minutes_limit": null,
27 "repository_size_limit": null,
28 "require_two_factor_authentication": false,
29 "two_factor_grace_period": 48,
30 "plan_id": null,
31 "project_creation_level": 2,
32 "runners_token": "rgeeL-nv4wa9YdRvuMid"
33 },
34 "milestone": {
35 "id": 12,
36 "title": "10.0"
37 },
38 "lists" : [
39 {
40 "id" : 1,
41 "label" : {
42 "name" : "Testing",
43 "color" : "#F0AD4E",
44 "description" : null
45 },
46 "position" : 1
47 },
48 {
49 "id" : 2,
50 "label" : {
51 "name" : "Ready",
52 "color" : "#FF0000",
53 "description" : null
54 },
55 "position" : 2
56 },
57 {
58 "id" : 3,
59 "label" : {
60 "name" : "Production",
61 "color" : "#FF5F00",
62 "description" : null
63 },
64 "position" : 3
65 }
66 ]
67 }
68 ]
0 [
1 {
2 "project_id" : 4,
3 "milestone" : {
4 "due_date" : null,
5 "project_id" : 4,
6 "state" : "closed",
7 "description" : "Rerum est voluptatem provident consequuntur molestias similique ipsum dolor.",
8 "iid" : 3,
9 "id" : 11,
10 "title" : "v3.0",
11 "created_at" : "2016-01-04T15:31:39.788Z",
12 "updated_at" : "2016-01-04T15:31:39.788Z"
13 },
14 "author" : {
15 "state" : "active",
16 "web_url" : "https://gitlab.example.com/root",
17 "avatar_url" : null,
18 "username" : "root",
19 "id" : 1,
20 "name" : "Administrator"
21 },
22 "description" : "Omnis vero earum sunt corporis dolor et placeat.",
23 "state" : "closed",
24 "iid" : 1,
25 "assignees" : [{
26 "avatar_url" : null,
27 "web_url" : "https://gitlab.example.com/lennie",
28 "state" : "active",
29 "username" : "lennie",
30 "id" : 9,
31 "name" : "Dr. Luella Kovacek"
32 }],
33 "assignee" : {
34 "avatar_url" : null,
35 "web_url" : "https://gitlab.example.com/lennie",
36 "state" : "active",
37 "username" : "lennie",
38 "id" : 9,
39 "name" : "Dr. Luella Kovacek"
40 },
41 "labels" : [],
42 "id" : 41,
43 "title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
44 "updated_at" : "2016-01-04T15:31:46.176Z",
45 "created_at" : "2016-01-04T15:31:46.176Z",
46 "closed_at" : null,
47 "user_notes_count": 1,
48 "due_date": null,
49 "web_url": "http://example.com/example/example/issues/1",
50 "time_stats": {
51 "time_estimate": 0,
52 "total_time_spent": 0,
53 "human_time_estimate": null,
54 "human_total_time_spent": null
55 },
56 "confidential": false,
57 "discussion_locked": false
58 },
59 {
60 "project_id" : 4,
61 "milestone" : {
62 "due_date" : null,
63 "project_id" : 4,
64 "state" : "closed",
65 "description" : "Rerum est voluptatem provident consequuntur molestias similique ipsum dolor.",
66 "iid" : 3,
67 "id" : 11,
68 "title" : "v3.0",
69 "created_at" : "2016-01-04T15:31:39.788Z",
70 "updated_at" : "2016-01-04T15:31:39.788Z"
71 },
72 "author" : {